mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-24 12:15:51 -04:00
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { NodeFileSystem } from "@effect/platform-node"
|
|
import { compile, emitEffectImported, emitPromise, write } from "@opencode-ai/httpapi-codegen"
|
|
import { ClientApi } from "../src/contract"
|
|
import { Effect } from "effect"
|
|
import { fileURLToPath } from "url"
|
|
|
|
const contract = compile(ClientApi, {
|
|
groupNames: { "server.session": "sessions", "server.event": "events" },
|
|
})
|
|
|
|
await Effect.runPromise(
|
|
Effect.all(
|
|
[
|
|
write(
|
|
emitPromise(contract, {
|
|
outputTypes: {
|
|
"events.subscribe": {
|
|
name: "OpenCodeEventEncoded",
|
|
import: 'import type { OpenCodeEventEncoded } from "@opencode-ai/protocol/groups/event"',
|
|
},
|
|
},
|
|
}),
|
|
fileURLToPath(new URL("../src/generated", import.meta.url)),
|
|
),
|
|
write(
|
|
emitEffectImported(contract, { module: "../contract", api: "ClientApi" }),
|
|
fileURLToPath(new URL("../src/generated-effect", import.meta.url)),
|
|
),
|
|
],
|
|
{ concurrency: 2, discard: true },
|
|
).pipe(Effect.provide(NodeFileSystem.layer)),
|
|
)
|