Dashboard › opencode › Distillation
62fd75b3-3b9b-49d9-a8be-c5b3ee526dc2["lore_tm_v1_p6ojSEI0dC8fadEmQU6CQP-LTpQ6GJrF75xMQYvgtmk","lore_tm_v1_xjIfiXeZnWiE7sFEykScVMVp_LNa6o5tSEFVq7necis","lore_tm_v1_w15rsJmoe1FMtUZl7pQeRdqTySBoWKxZDWNRs5e5tnc","lore_tm_v1_WNpgqhYC7ZMzgSwp_BybM_OnXemFBkZAI5dbyA-XTMQ","lore_tm_v1_61OYZ0KFgL5KuJrIhLQs82xd912Wy4Jo1phJ0dbIHnA","lore_tm_v1_Hbna2ML5CsbJA3ZRgacdmDDHfNtHtr9Fvn4COWoNx64","lore_tm_v1_uKvt3bQFI87pbXv9EkO2g6v76QcLgvPoPuEKq96dB3c","lore_tm_v1_vggmZO1KPp9eRVtx8b4bFfaW6X9ysC_FQ-zMW9XgsnA","lore_tm_v1_59MbhM5milJdELr1U3V9ooveAw0wBy32GQZ5G5AQ91M","lore_tm_v1_Z0MOPxUzWoURlagn61uUB-Oj2_ciXjnzh9fJyAOe6MA","lore_tm_v1_N_bo6EelnCXyfvyf1I14T8v9GRqGt8ccFC4IXnydFLc","lore_tm_v1_UYj_oi-TYSmjXksYolJK9oEurSnrRLpqUPkTQ8Jojxw","lore_tm_v1_vtvDtqirg7NJcXUf1D8iFVzGeXIK9Yj7MWPpui_1yaA","lore_tm_v1_TlbgssbvNeoWt57R8zO6fZOK89W-HJmU2kIfPebhy8U","lore_tm_v1_tEwghNVfFbR-886ucmd8JwHNbCAIfPthZiZyGgp6n2Q","lore_tm_v1_-hbAg3WMmna_XcY2-lB7zaQo4DbBZ3GtpZOEPPTCgXE"]
Date: Sep 16, 2026
packages/core/src/session/execution.ts:9-18 defines SessionExecution.Interface: active snapshots ReadonlySet<SessionSchema.ID> executions owned by the process; resume(sessionID) starts idle execution or joins active execution and can fail with SessionRunner.RunError; wake(sessionID) registers newly recorded work with coalescible repeated wakeups; interrupt(sessionID) interrupts active local work and is a no-op when idle.packages/core/src/session/execution.ts:20-34 defines Service as Context.Service under "@opencode/v2/SessionExecution", binds node globally with LayerNode.unbound(Service, Node.tags.values.global), and provides noopLayer for durable-recording-only callers: empty active set and no-op resume, wake, and interrupt./tmp/opencode/session-recovery-final-v4.patch:6823-6843 adds client event variants session.next.step.interrupted with timestamp, sessionID, assistantMessageID, and SessionErrorUnknown, plus session.next.step.recovered with timestamp, sessionID, executionID, optional assistantMessageID, and phase "ready" | "unknown" | "continue"./tmp/opencode/session-recovery-final-v4.patch:6847-6897 adds SyncEventSessionNextPromptExecutionRequested, SyncEventSessionNextStepInterrupted, and SyncEventSessionNextStepRecovered to GlobalEvent; adds corresponding durable event types to SessionDurableEvent; and adds corresponding ordinary event types to V2Event./tmp/opencode/session-recovery-final-v4.patch:6898-6921 extends SyncEventSessionNextPromptAdmitted.syncEvent.data with optional requestExecution?: boolean and defines SyncEventSessionNextPromptExecutionRequested with outer type: "sync" and a nested event of type "session.next.prompt.execution_requested.1" containing id, seq, aggregateID, and data fields timestamp, sessionID, and messageID./tmp/opencode/session-recovery-final-v4.patch:6922-6959 defines sync forms SyncEventSessionNextStepInterrupted ("session.next.step.interrupted.1", carrying timestamp, sessionID, assistantMessageID, and SessionErrorUnknown) and SyncEventSessionNextStepRecovered ("session.next.step.recovered.1", carrying timestamp, sessionID, executionID, optional assistantMessageID, and phase "ready" | "unknown" | "continue")./tmp/opencode/session-recovery-final-v4.patch:6964-7034 adds requestExecution?: boolean to SessionNextPromptAdmitted, and defines durable-capable SessionNextPromptExecutionRequested, SessionNextStepInterrupted, and SessionNextStepRecovered, each supporting optional metadata, optional durable { aggregateID, seq, version }, and optional location./tmp/opencode/session-recovery-final-v4.patch:7039-7082 adds public event forms EventSessionNextPromptExecutionRequested, EventSessionNextStepInterrupted, and EventSessionNextStepRecovered; the latter exposes executionID, optional assistantMessageID, and phase "ready" | "unknown" | "continue".packages/server/src/routes.ts:27-39 includes Database.node, EventV2.node, httpClient, ToolOutputStore.cleanupNode, SessionV2.node, SessionRecovery.node, PermissionSaved.node, PtyTicket.node, Credential.node, PtyEnvironment.node, and LocationServiceMap.node in applicationServices.packages/server/src/routes.ts:41-64 configures normal routes with username "opencode" and either an optional supplied password or ServerAuth.Config.layer; embedded routes use username "opencode" with no password. makeRoutes() binds SessionExecution.node to SessionExecutionLocal.node, exposes OpenAPI at /openapi.json, and provides handlers, session-location middleware, location, authorization, schema-error handling, auth, and the built service layer.packages/server/src/handlers/event.ts:9-48 implements event.subscribe as an SSE endpoint with bounded subscriber capacity 256. It creates a server.connected event, acquires EventV2.allBounded(events, subscriberCapacity) before readiness is observable, concatenates the connected event before the live stream, JSON-encodes events through OpenCodeEvent, emits heartbeats every 15 seconds, and sets Cache-Control: no-cache, no-transform, X-Accel-Buffering: no, and X-Content-Type-Options: nosniff.packages/sdk/js/src/v2/gen/types.gen.ts:1638-1675 includes SyncEventSessionNextPromptExecutionRequested, SyncEventSessionNextStepInterrupted, and SyncEventSessionNextStepRecovered in the sync-event union alongside the existing session event variants; their generated declarations occur at lines 3435, 3585, and 3602, respectively.packages/core/src/session/recovery.ts identified recovery logic using SessionExecutionClaim, SessionExecutionTable, SessionRecoveryTable, and SessionInputTable; phases include "ready", "safe", "unknown", and "continue". The scanner conditionally excludes a recovery executionID, claims expired executions by setting owner_id and expires_at to now + SESSION_EXECUTION_LEASE_MS, publishes recovered events, and processes recovery and ordinary pending wakes with concurrency: 1; top-level failure is logged as "Failed to recover Sessions".packages/opencode/src/control-plane/workspace.ts:366-429 continuously connects non-local workspaces to global sync via SSE, invokes syncHistory(...) after connection, tracks "connecting", "error", and "connected" status, and resets retry attempt to 0 after connecting.packages/opencode/src/control-plane/workspace.ts:395-412 accepts an SSE payload typed as { type?: string; syncEvent?: EventV2.SerializedEvent }; when payload.type === "sync" and payload.syncEvent exists, it calls events.replay(payload.syncEvent, { publish: true, ownerID: space.id }). Replay failures are logged as "failed to replay global event" with workspaceID, and failed events are not forwarded.packages/opencode/src/control-plane/workspace.ts:414-427 forwards successfully handled incoming events to GlobalBus.emit("event", ...) with directory, project, workspace: space.id, and payload; emit failures are logged as "failed to emit global event".packages/core/src/session/projector.ts:357-390 requires durable sequence metadata for SessionEvent.Prompted and SessionEvent.PromptAdmitted. Prompt admission projects requestExecution: event.data.requestExecution ?? false; SessionEvent.PromptExecutionRequested calls SessionInput.projectExecutionRequested(db, { id: messageID, sessionID }).packages/core/src/session/projector.ts:395-399 projects SessionEvent.Step.Started, .Ended, .Failed, and .Interrupted through run(db, event), while SessionEvent.Step.Recovered has custom recovery projection logic.packages/core/src/session/projector.ts:399-414 requires SessionEvent.Step.Recovered to have durable sequence metadata, computes continuationMessageID = continuation(event.data.executionID), and treats an existing SessionRecoveryTable row matching both execution_id and session_id as idempotently complete by returning early.packages/core/src/session/projector.ts:415-431 validates a supplied assistantMessageID by selecting the latest assistant row for the session ordered by descending SessionMessageTable.seq; projection dies if no latest row exists, if its ID differs ("Recovery target is not the latest assistant: ..."), or if decoding does not produce an assistant ("Recovery target is not an assistant: ...").packages/core/src/session/projector.ts:432-455 projects the recovered event through run(db, event), creates a queued continuation prompt with ID derived from executionID, text "continue", requestExecution: false, and admittedSeq equal to the recovered eventβs durable sequence, then inserts SessionRecoveryTable fields session_id, execution_id, nullable assistant_message_id, continuation_message_id, phase, wake_pending: true, and event-derived time_created; insertion uses .onConflictDoNothing() and failures are converted to defects with Effect.orDie.