@@ -5,6 +5,7 @@ import { lazy } from "@/util/lazy"
55import * as Log from "@opencode-ai/core/util/log"
66import { Flag } from "@opencode-ai/core/flag/flag"
77import { WorkspaceID } from "@/control-plane/schema"
8+ import { OpenApi } from "effect/unstable/httpapi"
89import { MDNS } from "./mdns"
910import { AuthMiddleware , CompressionMiddleware , CorsMiddleware , ErrorMiddleware , LoggerMiddleware } from "./middleware"
1011import { FenceMiddleware } from "./fence"
@@ -17,6 +18,7 @@ import { WorkspaceRouterMiddleware } from "./workspace"
1718import { InstanceMiddleware } from "./routes/instance/middleware"
1819import { WorkspaceRoutes } from "./routes/control/workspace"
1920import { ExperimentalHttpApiServer } from "./routes/instance/httpapi/server"
21+ import { PublicApi } from "./routes/instance/httpapi/public"
2022import * as ServerBackend from "./backend"
2123import type { CorsOptions } from "./cors"
2224
@@ -135,7 +137,30 @@ function createHono(opts: CorsOptions, selection: ServerBackend.Selection = Serv
135137 }
136138}
137139
140+ /**
141+ * Generate the OpenAPI document used by the SDK build.
142+ *
143+ * Since the Effect HttpApi backend now covers every Hono route (plus the new
144+ * `/api/session/*` v2 routes — see `httpapi-bridge.test.ts` for the parity
145+ * audit), `Server.openapi()` derives the spec from `OpenApi.fromApi(PublicApi)`.
146+ * `PublicApi` is `OpenCodeHttpApi` annotated with the `matchLegacyOpenApi`
147+ * transform that injects instance query parameters, strips Effect's optional
148+ * null arms, normalizes component names, and patches SSE response schemas so
149+ * the generated SDK keeps the legacy Hono shape.
150+ *
151+ * The Hono-derived spec is still reachable via `openapiHono()` so reviewers
152+ * can diff the two outputs while the Hono backend lingers; once the Hono
153+ * backend is deleted that helper goes with it.
154+ */
138155export async function openapi ( ) {
156+ return OpenApi . fromApi ( PublicApi )
157+ }
158+
159+ /**
160+ * Hono-derived OpenAPI spec, retained for parity diffing only. Delete once
161+ * the Hono backend is removed.
162+ */
163+ export async function openapiHono ( ) {
139164 // Build a fresh app with all routes registered directly so
140165 // hono-openapi can see describeRoute metadata (`.route()` wraps
141166 // handlers when the sub-app has a custom errorHandler, which
0 commit comments