Dashboard › opencode › Distillation
02ff97a9-ce51-4a55-b3bb-484d0d17abcc["lore_tm_v1_qPy7Ve43gKMqlK-5vxTp_sCVSVB1TCZQpMe4awoGWig","lore_tm_v1_p6FddMRQEqJIqjPbicV4IuegbdyuiPALZPUWHnquYtA","lore_tm_v1_nLznspwXwft1BtWYlOCkNKyQo5xQMr5krd5lVgXnOwk","lore_tm_v1_Q4gzSQJGClGypITP-zBJHnR15r2vpYSWBNnRxd2IESM"]
Date: Sep 16, 2026
packages/core/src/session.ts:338-487. V2Session.message returns a stored message only when stored?.sessionID === input.sessionID; V2Session.context, V2Session.events, and V2Session.history first validate the session with result.get(sessionID).packages/core/src/session.ts:346-358 exposes durable session events through events.durable({ aggregateID: input.sessionID, after: input.after }), filters them with isDurableSessionEvent, and reads aggregate history using EventV2.readAggregate(db, { ...input, aggregateID: input.sessionID, manifest: SessionDurable }).V2Session.prompt in packages/core/src/session.ts:360-386 runs uninterruptibly, resolves the prompt, uses input.id ?? SessionMessage.ID.create(), defaults delivery to "steer", and calls SessionInput.admit(db, events, { id: messageID, sessionID, prompt, delivery, requestExecution: input.resume !== false }).V2Session.prompt converts a SessionInput.LifecycleConflict defect into PromptConflictError, dies on other defects, rejects a non-equivalent admitted input with PromptConflictError, calls execution.wake(admission.admitted.sessionID) only when admission.shouldWake, and returns admission.admitted.packages/core/src/session.ts leaves shell, skill, compact, and wait unavailable via OperationUnavailableError; exposes active: execution.active; validates the session before execution.resume(sessionID); and wraps execution.interrupt(sessionID) in Effect.uninterruptible.V2Session.switchAgent publishes SessionEvent.AgentSwitched with a newly created SessionMessage.ID, current DateTime, and the requested agent. V2Session.switchModel skips publication when providerID, model id, and normalized variant (variant ?? "default") are unchanged; otherwise it publishes SessionEvent.ModelSwitched.resolvePrompt in packages/core/src/session.ts:461-473 preserves text, agents, and files; derives a file MIME type from a data: URI when possible; otherwise uses the URL pathname or file.name ?? file.uri; directories ending in / receive "application/x-directory", and other targets use FSUtil.mimeType(target).packages/core/src/session.ts registers the global session node with dependencies Database.node, EventV2.node, ProjectV2.node, SessionExecution.node, SessionStore.node, LocationServiceMap.node, and SessionProjector.node.packages/core/test/session-projector.test.ts includes recovery tests for durable wake redrive after admission, quarantining a malformed recovery row without blocking a valid wake, quarantining a full poison batch before valid work, fair redrive of recovery and ordinary work beyond a full bounded batch, durable ordinary input intent after a lost advisory wake, and ordinary-input redrive without recovering a claim that crashed before promotion.packages/core/test/session-projector.test.ts uses poisonCount = SessionRecovery.BATCH_SIZE + 1, creates poisonCount + 1 sessions, expects SessionRecovery.BATCH_SIZE rows in one bounded result, wakes sessions[poisonCount], and ultimately expects poisonCount quarantined rows with recovery_error = "Invalid recovery continuation input".packages/core/test/session-projector.test.ts sets failedCount = SessionRecovery.BATCH_SIZE + 1 and expects SessionRecovery.BATCH_SIZE * 2 wakes.packages/core/test/session-projector.test.ts also covers redriving one existing recovery after its replacement claim crashes before promotion, quarantining a recovery wake behind a newer assistant, quarantining a malformed execution claim without blocking a valid claim, and stale-publication behavior involving messageID: SessionMessage.ID.make("msg_stale_publication").