|
|
@@ -1,12 +1,13 @@
|
|
|
import { Schema } from "effect"
|
|
|
import { HttpApi } from "effect/unstable/httpapi"
|
|
|
import { EventV2 } from "@opencode-ai/core/event"
|
|
|
+import { InstanceDisposed } from "@/server/event"
|
|
|
+import { Question } from "@/question"
|
|
|
import { ConfigApi } from "./groups/config"
|
|
|
import { ControlApi } from "./groups/control"
|
|
|
import { EventApi } from "./groups/event"
|
|
|
import { ExperimentalApi } from "./groups/experimental"
|
|
|
import { FileApi } from "./groups/file"
|
|
|
-import { GlobalApi } from "./groups/global"
|
|
|
import { InstanceApi } from "./groups/instance"
|
|
|
import { McpApi } from "./groups/mcp"
|
|
|
import { PermissionApi } from "./groups/permission"
|
|
|
@@ -19,11 +20,13 @@ import { SyncApi } from "./groups/sync"
|
|
|
import { TuiApi } from "./groups/tui"
|
|
|
import { WorkspaceApi } from "./groups/workspace"
|
|
|
import { V2Api } from "./groups/v2"
|
|
|
+// GlobalEventSchema snapshots the registry after event-producing groups register their variants.
|
|
|
+import { GlobalApi } from "./groups/global"
|
|
|
import { Authorization } from "./middleware/authorization"
|
|
|
import { SchemaErrorMiddleware } from "./middleware/schema-error"
|
|
|
|
|
|
-const EventSchema = Schema.Union(
|
|
|
- EventV2.registry
|
|
|
+const EventSchema = Schema.Union([
|
|
|
+ ...EventV2.registry
|
|
|
.values()
|
|
|
.map((definition) =>
|
|
|
Schema.Struct({
|
|
|
@@ -33,7 +36,8 @@ const EventSchema = Schema.Union(
|
|
|
}).annotate({ identifier: `Event.${definition.type}` }),
|
|
|
)
|
|
|
.toArray(),
|
|
|
-).annotate({ identifier: "Event" })
|
|
|
+ InstanceDisposed,
|
|
|
+]).annotate({ identifier: "Event" })
|
|
|
|
|
|
export const RootHttpApi = HttpApi.make("opencode-root")
|
|
|
.addHttpApi(ControlApi)
|
|
|
@@ -64,7 +68,7 @@ export const OpenCodeHttpApi = HttpApi.make("opencode")
|
|
|
.addHttpApi(EventApi)
|
|
|
.addHttpApi(InstanceHttpApi)
|
|
|
.addHttpApi(PtyConnectApi)
|
|
|
- .annotate(HttpApi.AdditionalSchemas, [EventSchema])
|
|
|
+ .annotate(HttpApi.AdditionalSchemas, [EventSchema, Question.Replied, Question.Rejected])
|
|
|
|
|
|
export type RootHttpApiType = typeof RootHttpApi
|
|
|
export type InstanceHttpApiType = typeof InstanceHttpApi
|