Files
anomalyco_opencode/packages/opencode/src/account/index.ts
T
Kit Langton 386eb03427 effectify Installation service and drop Effect suffix from service namespaces
Migrate Installation to Effect with HttpClient for version fetching and
ChildProcessSpawner for package manager detection/upgrade. Register in
global ManagedRuntime. Split into effect.ts (service) and index.ts
(legacy adapters) to break the runtime circular dependency.

Rename AccountEffect → Account, AuthEffect → Auth,
TruncateEffect → Truncate to establish consistent naming where both
the effect.ts and index.ts files use the same namespace name.
2026-03-19 14:29:34 -04:00

42 lines
1.2 KiB
TypeScript

import { Effect, Option } from "effect"
import {
Account as S,
AccountSchema,
type AccountError,
type AccessToken,
AccountID,
OrgID,
} from "./effect"
export { AccessToken, AccountID, OrgID } from "./effect"
import { runtime } from "@/effect/runtime"
function runSync<A>(f: (service: S.Interface) => Effect.Effect<A, AccountError>) {
return runtime.runSync(S.Service.use(f))
}
function runPromise<A>(f: (service: S.Interface) => Effect.Effect<A, AccountError>) {
return runtime.runPromise(S.Service.use(f))
}
export namespace Account {
export const Account = AccountSchema
export type Account = AccountSchema
export function active(): Account | undefined {
return Option.getOrUndefined(runSync((service) => service.active()))
}
export async function config(accountID: AccountID, orgID: OrgID): Promise<Record<string, unknown> | undefined> {
const config = await runPromise((service) => service.config(accountID, orgID))
return Option.getOrUndefined(config)
}
export async function token(accountID: AccountID): Promise<AccessToken | undefined> {
const token = await runPromise((service) => service.token(accountID))
return Option.getOrUndefined(token)
}
}