Dashboard › opencode › Distillation
2c8a2ba3-8e62-4c35-ae14-8189cc109999["lore_tm_v1_r72yHbpJCx9RYgplhH8WvTqBRLA7po4srOUQClpByng","lore_tm_v1_F4GYWwxEDyToUlRklf4uajgWjekEkACS1zavPRQv110","lore_tm_v1_KWrdhsH1S9qt60z1VXnMA_t1NQFdGA3RXvVCkCmwt18","lore_tm_v1_djXwTEyBAA15rUR8YbcnHQVGMXa7OmxqWYQilKbBL4w","lore_tm_v1_sgflBy3GLLR8PGEqTTUdbpdVLq2yW6BbBOA-5Bk8gUo","lore_tm_v1_VuKL31u35Z_cVBfjx7mc07jTAkbA_3ZayPHmPuTxdaw","lore_tm_v1_ucmxmQ0rzg2BAGcZvAi-nCoCdJhQg0qkAWFUPJJe_sY","lore_tm_v1_TUd6foXfCZZplfokfSUqbJfFbIAxdbpoLFtaWatJ0G4","lore_tm_v1_z0G-uzkUap7jH1L9JM4dW7P5bHCfPH7nnUqhGJdtXow"]
Date: Sep 16, 2026
packages/schema/src/session-event.ts defines Durable as Schema.Union(DurableDefinitions, { mode: "oneOf" }).pipe(Schema.toTaggedUnion("type")).annotate({ identifier: "SessionDurableEvent" }); DurableEvent is typeof Durable.Type.packages/schema/src/session-event.ts defines All as Schema.Union(Definitions, { mode: "oneOf" }).pipe(Schema.toTaggedUnion("type")); Event is typeof All.Type and Type is Event["type"].Moved, Prompted, PromptAdmitted, PromptExecutionRequested, ContextUpdated, Synthetic, Shell.Started, Shell.Ended, Step.Started, Step.Ended, Step.Failed, Step.Interrupted, Step.Recovered, Text.Started, Text.Delta, Text.Ended, Reasoning.Started, Reasoning.Delta, Reasoning.Ended, Tool.Input.Started, Tool.Input.Delta, Tool.Input.Ended, Tool.Called, Tool.Progress, Tool.Success, Tool.Failed, Retried, Compaction.Started, Compaction.Delta, Compaction.Ended, RevertEvent.Staged, RevertEvent.Cleared, and RevertEvent.Committed.packages/server/src/routes.ts, applicationServices groups Database.node, EventV2.node, httpClient, ToolOutputStore.cleanupNode, SessionV2.node, SessionRecovery.node, PermissionSaved.node, PtyTicket.node, Credential.node, PtyEnvironment.node, and LocationServiceMap.node.packages/server/src/routes.ts defines createRoutes(password?) with username "opencode" and Option.some(password) when a password is supplied, otherwise ServerAuth.Config.layer; createEmbeddedRoutes() uses username "opencode" with Option.none().packages/server/src/routes.ts builds services through AppNodeBuilder.build(applicationServices, [[SessionExecution.node, SessionExecutionLocal.node]]); the API serves OpenAPI at /openapi.json and is provided handlers, sessionLocationLayer, locationLayer, authorizationLayer, schemaErrorLayer, auth, and the service layer.packages/server/src/routes.ts exports routes = createRoutes() and webHandler, which invokes HttpRouter.toWebHandler with HttpServer.layerServices and { disableLogger: true }.packages/opencode/src/server/routes/instance/httpapi/server.ts splits routing into rootApiRoutes for typed /global/* and control routes, eventApiRoutes for typed SSE with instance routing context, ptyConnectApiRoutes for ticket-aware WebSocket upgrades, instanceApiRoutes for remaining typed instance routes, and uiRoute as a raw catch-all whose router-level authentication lets public static assets bypass auth.packages/opencode/src/server/routes/instance/httpapi/server.ts configures CORS through isAllowedCorsOrigin(origin, corsOptions) with maxAge: 86_400 and global middleware./doc OpenAPI response is defined as lazy(() => HttpServerResponse.jsonUnsafe(OpenApi.fromApi(PublicApi))); OpenAPI generation is deferred until /doc is hit so processes that βnever serve it (CLI, scripts)β do not pay the cost at module load, and caching the response reuses the same serialized Uint8Array instead of rerunning JSON.stringify for every request./doc route is GET /doc, returns Effect.succeed(docResponse()), and is provided authOnlyRouterLayer.uiRoute obtains FSUtil.Service, HttpClient.HttpClient, and RuntimeFlags.Service, then sends all * /* requests to serveUIEffect(request, { fs, client, disableEmbeddedWebUi: flags.disableEmbeddedWebUi }); it is provided authOnlyRouterLayer.packages/opencode/src/server/routes/instance/httpapi/server.ts merges rootApiRoutes, eventApiRoutes, ptyConnectApiRoutes, instanceRoutes, serverRoutes, docRoute, and uiRoute.errorLayer, compressionLayer, corsVaryFix, fenceLayer, cors(corsOptions), AppNodeBuilderV1.build(MoveSession.node, [[LocationServiceMap.node, locationServiceMapV2]]), HttpServer.layerServices, CorsConfig, sessionLocationLayer, locationLayer, PtyEnvironment.layer, locationServiceMapV2, and AppNodeBuilderV1.build(app).SessionV2.node and SessionRecovery.node are built together with LocationServiceMap.node replaced by locationServiceMapV2 and SessionExecution.node replaced by SessionExecutionLocal.node.Observability.layer must remain the final Layer.provideMerge(...) because layers provided later build beneath earlier ones; otherwise eagerly forked fibers such as the ModelsDev background refresh capture Effectβs default stdout logger and corrupt the TUI, tracked as issue #34730.routes = createRoutes() and lazily creates webHandler via HttpRouter.toWebHandler(routes, { disableLogger: true, memoMap, middleware: disposeMiddleware }).packages/core/src/database/migration.gen.ts dynamically imports 39 migrations in chronological order, ending with ./migration/20260914170650_session-recovery, then maps each imported module to module.default and satisfies DatabaseMigration.Migration[].packages/core/src/database/schema.gen.ts contains the generated baseline schema corresponding to session recovery, including the session_execution and session_recovery tables, the added session_input.wake_pending and session_input.wake_attempts columns, and their generated indexes.packages/core/test/session-execution-local.test.ts contains a describe("SessionExecutionLocal", ...) suite and synchronization points involving Deferred.await(started), Deferred.await(firstStarted), Deferred.await(finalizerStarted), Deferred.await(releaseFinalizer), and Deferred.await(successorStarted).