refactor(client): simplify embedded setup

This commit is contained in:
Kit Langton
2026-06-23 13:18:36 -04:00
parent 51e5e4186f
commit 22ee85671b
2 changed files with 5 additions and 4 deletions
+3 -2
View File
@@ -3,6 +3,7 @@ import { SessionGroup } from "@opencode-ai/server/groups/session"
import { compile, emitEffectImported, emitPromise, write } from "@opencode-ai/httpapi-codegen"
import { Effect } from "effect"
import { HttpApi } from "effect/unstable/httpapi"
import { fileURLToPath } from "url"
const Api = HttpApi.make("opencode-client").add(SessionGroup)
const contract = compile(Api, { groupNames: { "server.session": "sessions" } })
@@ -10,13 +11,13 @@ const contract = compile(Api, { groupNames: { "server.session": "sessions" } })
await Effect.runPromise(
Effect.all(
[
write(emitPromise(contract), new URL("../src/generated", import.meta.url).pathname),
write(emitPromise(contract), fileURLToPath(new URL("../src/generated", import.meta.url))),
write(
emitEffectImported(contract, {
module: "@opencode-ai/server/groups/session",
group: "SessionGroup",
}),
new URL("../src/generated-effect", import.meta.url).pathname,
fileURLToPath(new URL("../src/generated-effect", import.meta.url)),
),
],
{ concurrency: 2, discard: true },
+2 -2
View File
@@ -44,11 +44,11 @@ export const create = Effect.fn("OpenCode.create")(function* () {
}
})
export interface Interface extends Effect.Success<ReturnType<typeof create>> {}
export type Interface = Effect.Success<ReturnType<typeof create>>
export class Service extends Context.Service<Service, Interface>()("@opencode-ai/client/OpenCode") {}
export const layer = Layer.effect(Service, create().pipe(Effect.map(Service.of)))
export const layer = Layer.effect(Service, create())
export { ClientError } from "./generated-effect/index"
export { Tool } from "@opencode-ai/core/public/tool"