Dashboard › opencode › Distillation
567c9660-e828-4d7e-8189-66ea03fd277c["lore_tm_v1_qwx6SW4IXBuvi-MQ2v9V0cK-AdGCs1P5R2Qrr0oO8SA","lore_tm_v1_WSz_3SgJSSLluW7LXTR42ThOEnyvgMcz6SS2ILWSuN4","lore_tm_v1_0BgtnX4nA4ScasqaSRHtxjQ4n-AbAJ6a5ui-8WNP4h4","lore_tm_v1_951YjmkctbL-fNmg5-9qMXSG9JDczBJmOczt1-mRfqc","lore_tm_v1_hmMpVu4XuybMN9JqksyWL-325IRuDV_AOQsJNEdYYCU","lore_tm_v1_NR_nzS5z40K85qNpUwOMv5mTlYg0_iDz78TNT5n4jI0","lore_tm_v1_tdDE_n5U-_vEfhxHWCbaLoKlEFh9ZAt7Nw22SccTkzk","lore_tm_v1_HT-8d_6SE_sm_gU8Xs7Uiw2Dj6sbnBAGskNbV78P0Lc","lore_tm_v1_Cp9RocH4u-oWF5Q2Orec8F2Dxt3PhOpFfwS8liOBh18","lore_tm_v1_Hn9GgYToLNqjlfBxJJFRsxO9QhdmPKWu8LLhYfTqrJ4","lore_tm_v1_ZvMwM7vVU0O3n2R7BFdOXoNmRJzGauO00EcF1xH1X00","lore_tm_v1_EowBIF8YRjRx8M923P6RQMfYWmPDbBcAqWFxZ1JUxgY"]
Date: Sep 16, 2026
OpenApi.fromApi(PublicApi) to be deferred for processes that never serve /doc, specifically CLI processes and scripts, so they do not pay the cost at module load.packages/core/src/session/context-epoch.ts defines Prepared as { baseline: string, baselineSeq: number }; exported initialize(...) can return Prepared | undefined, while exported prepare(...) always returns Prepared and can fail with SystemContext.InitializationBlocked | ContextSnapshotDecodeError.SessionContextEpoch.prepareOnce concurrently loads the current SystemContext.SystemContext, the stored SessionContextEpochTable row, and SessionHistory.latestCompaction(db, sessionID) using Effect.all(..., { concurrency: "unbounded" }).SessionContextEpoch.prepareOnce runs SystemContext.initialize(value), inserts the generation under the SessionExecutionClaim.Claim, and returns its generation.baseline with the inserted baselineSeq.Schema.decodeUnknownEffect(SystemContext.Snapshot); decode failures become ContextSnapshotDecodeError({ sessionID, details: String(error) }).stored.baseline_seq; it calls SystemContext.replace(value, snapshot). Otherwise context preparation calls SystemContext.reconcile(value, snapshot).SessionContextEpoch.prepareOnce preserves the stored baseline for Unchanged and ReplacementBlocked. For ReplacementReady, it uses the compaction sequence when available or EventV2.latestSequence(db, sessionID), calls replace(...), and returns the replacement generation’s baseline. A reconciliation update publishes SessionEvent.ContextUpdated and atomically advances the snapshot through its local commit hook.SessionContextEpoch.initializeOnce checks exists(db, sessionID) and does nothing when an epoch already exists; otherwise it initializes context, inserts the generation, and returns { baseline, baselineSeq }.packages/core/src/session/context-epoch.ts are claim-fenced through SessionExecutionClaim.transaction: insert(...) stores session_id, baseline, snapshot, and baseline_seq; replace(...) updates all three generation fields; advance(...) updates only snapshot. replace(...) and advance(...) die with Context Epoch not found if no row is returned.SessionContextEpoch.reset(db, sessionID) deletes the matching SessionContextEpochTable row without taking a SessionExecutionClaim.Claim.packages/core/src/session/message-updater.ts scopes event-driven assistant mutation through updateOwnedAssistant(event.data.assistantMessageID, ...), consistent with refusing to mutate an older assistant projection after a newer turn supersedes it.packages/core/src/session/message-updater.ts, "session.next.tool.input.delta" is ignored; "session.next.tool.input.ended" replaces the input text only for the latest matching pending tool; "session.next.tool.called" records provider and run timestamp and changes the tool to running with parsed input, empty structured, and empty content.running tool’s structured and content. Tool success merges the provider’s executed flag with any prior executed === true, preserves prior provider metadata as metadata, stores completion metadata as resultMetadata, sets time.completed, and changes state to completed with input, structured data, content, outputPaths defaulting to [], and result.pending or running tool. It preserves prior execution truth and provider metadata, adds result metadata and completion time, and creates an error state containing event.data.error, {} when the prior input is still a string, prior structured/content only when previously running, and event.data.result.packages/core/src/session/message-updater.ts appends an empty AssistantReasoning on "session.next.reasoning.started", concatenates deltas into the latest matching reasoning block, and on "session.next.reasoning.ended" replaces text with the final text, preserves the original creation timestamp when present, records completion time, and replaces provider metadata only when the ending event supplies it."session.next.compaction.started" and "session.next.compaction.delta" are ignored by the message updater. "session.next.compaction.ended" appends a SessionMessage.Compaction containing messageID, event metadata, reason, summary text, recent context, and creation timestamp. All three revert events—staged, cleared, and committed—are ignored.packages/core/src/event.ts defines durable event commit as a local operational projection committed atomically with the new durable event; it is not replayed or serialized. Supplying a local commit hook for a non-durable event is rejected with Local commit hooks require a durable event.packages/opencode/src/server/routes/instance/httpapi/server.ts divides routing into rootApiRoutes, eventApiRoutes, ptyConnectApiRoutes, instanceApiRoutes, serverRoutes, docRoute, and uiRoute, with distinct authorization layers for normal HTTP APIs, PTY connection, server APIs, and raw router middleware./doc response is created as lazy(() => HttpServerResponse.jsonUnsafe(OpenApi.fromApi(PublicApi))); this both defers non-trivial OpenAPI generation until /doc is requested and caches the eagerly serialized Uint8Array so later /doc requests do not re-stringify the specification.packages/opencode/src/server/routes/instance/httpapi/server.ts currently builds LayerNode.group([SessionV2.node, SessionRecovery.node]) with [SessionExecution.node, SessionExecutionLocal.node], meaning this route graph still wires local session execution ownership.Observability.layer must remain the final provider because later-provided layers build beneath earlier ones; otherwise eagerly forked fibers such as the ModelsDev background refresh capture Effect’s default stdout logger and corrupt the TUI (#34730).packages/server/src/routes.ts groups Database.node, EventV2.node, httpClient, ToolOutputStore.cleanupNode, SessionV2.node, SessionRecovery.node, PermissionSaved.node, PtyTicket.node, Credential.node, PtyEnvironment.node, and LocationServiceMap.node as applicationServices.packages/server/src/routes.ts also currently wires [SessionExecution.node, SessionExecutionLocal.node] through AppNodeBuilder.build(applicationServices, ...), so the newer server route graph likewise uses local execution ownership./openapi.json; createRoutes(password?) configures username "opencode" with the supplied password when present, while createEmbeddedRoutes() configures username "opencode" with Option.none() for the password.