Dashboard › opencode › Distillation
6fa4252a-11a2-4e99-baaa-be70d43e8f55["lore_tm_v1_tW6ssKvQh2-f3FRTGtFm_sZOanNpmclkGYGVpByilLY","lore_tm_v1_Qbbb28f7avOhvYxeMLZYZhJC5S3oRbeg7V1T6JkCQmY","lore_tm_v1_Kgt3Gs-Ysne5ArquUTpcgb55-84pidbVrjyyju0cU5Q","lore_tm_v1_lIbVlWzrwefAawCbs82GGh-Y4_yzcQB0y6egsecBLac","lore_tm_v1_lFSU0BjPza8JKBUpay6dJLwGuuJ9yKTkQePZm3R-oZQ","lore_tm_v1_qmLy3vPhuskBs37-rIHJ8r8_RIyNwr4Bbg8BQjB7SEY","lore_tm_v1_je2ZT173x79zSXmUDDmTTCW0rTioEj0kbMDDT4XlTZQ","lore_tm_v1_VIJAkwUaR7JUtdEMWZjaS4o1VCvys1s93MVXyKvwZTs","lore_tm_v1_nnolQ1fS9ObRDX_cP6gjjKzxtStM1GGwznXBVYy7BFw","lore_tm_v1_tnSQu08sRSxrSAwnXW8kvrlYd10mq2xvwFBAAHeR844","lore_tm_v1_k5l-n7ETyJHDaqDZ-tSrYbred9eDcijHG2kNnfqrPc0"]
Date: Sep 16, 2026
packages/core/src/event.ts:205-237, commitDurableEvent(definition, event, input?, commit?) reads the aggregate value from event.data[durable.aggregate]; a non-string value dies with InvalidDurableEventError, type: event.type, and exact message Expected string aggregate field ${durable.aggregate}.commitDurableEvent(...) rejects a supplied input.aggregateID that differs from the aggregate in event data, using exact message Aggregate mismatch: expected ${input.aggregateID}, got ${aggregateID}. Projectors are selected with projectors.get(event.type) ?? [], and durable processing runs through Effect.uninterruptible(...).EventV2 layer finalizer in packages/core/src/event.ts:193-203 shuts down pubsub.all, every PubSub in every pubsub.durable set, and every PubSub in pubsub.typed.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?), which uses username "opencode" and Option.some(password) when a password is supplied, otherwise ServerAuth.Config.layer; createEmbeddedRoutes() uses username "opencode" with Option.none().makeRoutes(...) in packages/server/src/routes.ts builds services with AppNodeBuilder.build(applicationServices, [[SessionExecution.node, SessionExecutionLocal.node]]); the API exposes OpenAPI at /openapi.json and provides handlers, sessionLocationLayer, locationLayer, authorizationLayer, schemaErrorLayer, authentication, and the service layer.packages/server/src/routes.ts exports routes = createRoutes() and webHandler, with HttpRouter.toWebHandler(...) configured as { disableLogger: true }.packages/opencode/src/server/routes/instance/httpapi/server.ts, route composition is split into: rootApiRoutes for typed /global/* and control routes; eventApiRoutes for typed SSE with instance-routing context; ptyConnectApiRoutes for WebSocket upgrade with ticket-aware auth; instanceApiRoutes for remaining typed instance routes; and uiRoute as a raw catch-all whose router-level auth allows public static assets to bypass authentication.packages/opencode/src/server/routes/instance/httpapi/server.ts are authOnlyRouterLayer, httpApiAuthLayer, ptyConnectHttpApiAuthLayer, and serverHttpApiAuthLayer, respectively based on authorizationRouterMiddleware.layer, authorizationLayer, ptyConnectAuthorizationLayer, and serverAuthorizationLayer, each provided with ServerAuth.Config.layer.rootApiRoutes provides controlHandlers, controlPlaneHandlers, globalHandlers, schemaErrorLayer, and httpApiAuthLayer; eventApiRoutes provides eventHandlers plus httpApiAuthLayer, workspaceRoutingLive, and instanceContextLayer; ptyConnectApiRoutes provides ptyConnectHandlers plus ptyConnectHttpApiAuthLayer, workspaceRoutingLive, and instanceContextLayer.instanceApiRoutes provides handlers in this order: configHandlers, experimentalHandlers, fileHandlers, instanceHandlers, mcpHandlers, projectHandlers, projectCopyHandlers, ptyHandlers, questionHandlers, permissionHandlers, providerHandlers, sessionHandlers, syncHandlers, tuiHandlers, and workspaceHandlers; instanceRoutes additionally provides httpApiAuthLayer, workspaceRoutingLive, instanceContextLayer, and schemaErrorLayer.serverRoutes builds @opencode-ai/serverβs Api, provides handlers and PluginPtyEnvironment.layer, and uses serverHttpApiAuthLayer plus v2SchemaErrorLayer.OpenApi.fromApi(PublicApi) to be deferred until /doc is requested so processes that βnever serve it (CLI, scripts)β do not pay its cost at module load./doc response construction in packages/opencode/src/server/routes/instance/httpapi/server.ts:184-193 uses const docResponse = lazy(() => HttpServerResponse.jsonUnsafe(OpenApi.fromApi(PublicApi))); because jsonUnsafe eagerly runs JSON.stringify, caching the response also caches the serialized body so every /doc request reuses the same Uint8Array. docRoute registers GET /doc and is provided with authOnlyRouterLayer.uiRoute resolves FSUtil.Service, HttpClient.HttpClient, and RuntimeFlags.Service, then registers * /* to call serveUIEffect(request, { fs, client, disableEmbeddedWebUi: flags.disableEmbeddedWebUi }); it is provided with authOnlyRouterLayer.createRoutes(corsOptions?) merges routes in this exact order: 1. rootApiRoutes, 2. eventApiRoutes, 3. ptyConnectApiRoutes, 4. instanceRoutes, 5. serverRoutes, 6. docRoute, 7. uiRoute.errorLayer, compressionLayer, corsVaryFix, fenceLayer, cors(corsOptions), AppNodeBuilderV1.build(MoveSession.node, [[LocationServiceMap.node, locationServiceMapV2]]), and HttpServer.layerServices; CORS uses isAllowedCorsOrigin(origin, corsOptions) and maxAge: 86_400.CorsConfig, sessionLocationLayer, locationLayer, PtyEnvironment.layer, and AppNodeBuilderV1.build(LayerNode.group([SessionV2.node, SessionRecovery.node]), [[LocationServiceMap.node, locationServiceMapV2], [SessionExecution.node, SessionExecutionLocal.node]]), followed by locationServiceMapV2 and AppNodeBuilderV1.build(app).Observability.layer must remain the final Layer.provideMerge(...) in createRoutes(...): later-provided layers build beneath earlier ones, and placing observability sooner allows eagerly forked fibers such as the ModelsDev background refresh to capture Effectβs default stdout logger and corrupt the TUI (#34730).packages/opencode/src/server/routes/instance/httpapi/server.ts exports lazy webHandler, which calls HttpRouter.toWebHandler(routes, { disableLogger: true, memoMap, middleware: disposeMiddleware }).packages/sdk/js/src/v2/gen/types.gen.ts found 26 references related to EventSessionNextPromptExecutionRequested, EventSessionNextStepRecovered, SyncEventSessionNextPromptExecutionRequested, SyncEventSessionNextStepRecovered, SessionNextPromptExecutionRequested, SessionNextStepRecovered, requestExecution, session.next.prompt.execution_requested, and session.next.step.recovered, including versioned sync event types ending in .1.session.next.prompt.admitted with properties timestamp, sessionID, messageID, prompt, delivery: "steer" | "queue", and optional requestExecution?: boolean; session.next.prompt.execution_requested has timestamp, sessionID, and messageID.session.next.step.recovered has timestamp, sessionID, executionID, optional assistantMessageID?: string, and phase: "ready" | "unknown" | "continue".session.next.step.started with assistantMessageID, agent, model, and optional snapshot; session.next.step.ended with finish, cost, token counts (input, output, reasoning, cache.read, cache.write), optional snapshot, and optional files; and session.next.step.failed / session.next.step.interrupted with error: SessionErrorUnknown.packages/core/src/database/migration.gen.ts registers 39 migrations in chronological import order; the latest is ./migration/20260914170650_session-recovery, following ./migration/20260622202450_simplify_session_input.packages/core/schema.json found 44 references for session_execution and session_recovery, covering table declarations, columns, foreign keys, primary keys, indexes, and checks including session_execution_phase_check, session_recovery_wake_attempts_check, and session_wake_attempts_check.session_execution in packages/core/schema.json has columns: required text id, required text session_id, required text owner_id, nullable text assistant_message_id, required text phase, required integer time_created, required integer expires_at, and nullable text recovery_error.session_recovery in packages/core/schema.json has columns: required text session_id, required text execution_id, nullable text assistant_message_id, required text continuation_message_id, required text phase, required integer wake_pending defaulting to true, required integer wake_attempts defaulting to 0, nullable text recovery_error, and required integer time_created.session_execution.session_id references session.id with ON DELETE CASCADE; the generated foreign-key name is fk_session_execution_session_id_session_id_fk.session_recovery has three cascading foreign keys: session_id β session.id as fk_session_recovery_session_id_session_id_fk; assistant_message_id β session_message.id as fk_session_recovery_assistant_message_id_session_message_id_fk; and continuation_message_id β session_input.id as fk_session_recovery_continuation_message_id_session_input_id_fk.