Dashboard › opencode › Distillation
3d8589de-2046-4e94-a344-af74891987d8["lore_tm_v1_Nl103m1avUv4OTG9qeaZQZVZrY3z9CDnUozx01j6kuI","lore_tm_v1_9ScOdSocgyEYI4y5BBSJhBIAb5hMAskiSCsYRMpb6-k","lore_tm_v1_JU2UTBqjOOueLR3SB8o-WXe1A3hqjWeV7vZr6k2LMmQ"]
Date: Sep 16, 2026
/doc route, so they should not pay the cost of generating its OpenAPI specification at module load.packages/server/src/routes.ts adds SessionRecovery.node to applicationServices and builds the service layer with AppNodeBuilder.build(applicationServices, [[SessionExecution.node, SessionExecutionLocal.node]]); both regular createRoutes(password?) and unauthenticated createEmbeddedRoutes() use this graph.packages/server/src/routes.ts, createRoutes(password?) configures username "opencode" and an optional password, while createEmbeddedRoutes() configures username "opencode" with Option.none(); makeRoutes() exposes OpenAPI at /openapi.json and provides handlers, sessionLocationLayer, locationLayer, authorizationLayer, schemaErrorLayer, auth, and the service layer.packages/opencode/src/server/routes/instance/httpapi/server.ts organizes the HTTP route tree into 7 layers in order: 1. rootApiRoutes, 2. eventApiRoutes, 3. ptyConnectApiRoutes, 4. instanceRoutes, 5. serverRoutes, 6. docRoute, 7. uiRoute./doc generation in packages/opencode/src/server/routes/instance/httpapi/server.ts is deferred through const docResponse = lazy(() => HttpServerResponse.jsonUnsafe(OpenApi.fromApi(PublicApi))); because jsonUnsafe stringifies eagerly, caching the response also caches the serialized Uint8Array, avoiding regeneration and re-stringification on subsequent /doc requests.docRoute registers authenticated GET /doc via authOnlyRouterLayer; uiRoute is an authenticated raw "*"/"/*" fallback that invokes serveUIEffect(request, { fs, client, disableEmbeddedWebUi: flags.disableEmbeddedWebUi }).createRoutes(corsOptions?) provides SessionV2.node and SessionRecovery.node through AppNodeBuilderV1.build(...), overriding LocationServiceMap.node with locationServiceMapV2 and SessionExecution.node with SessionExecutionLocal.node.errorLayer, compressionLayer, corsVaryFix, fenceLayer, CORS with maxAge: 86_400, MoveSession.node, and HttpServer.layerServices; Observability.layer must remain last so eagerly forked fibers such as the ModelsDev background refresh do not capture Effect’s default stdout logger and corrupt the TUI (#34730).webHandler is lazy and calls HttpRouter.toWebHandler(routes, { disableLogger: true, memoMap, middleware: disposeMiddleware }).