Dashboard › opencode › Distillation
932db32d-6c6a-4638-878e-efa580ad551d["lore_tm_v1_ElEqiFcsScWDHKNVwr1Dyo6NDeJJFM-C507gWZxOEyQ","lore_tm_v1_Rj1HZYPBrCremhpiDYW5wZ4VC4QUht22g_VKrlZ_ZO4","lore_tm_v1_moQ0TwBi_QTgJyzXtnyRsv3R4cZOE2CcA7Vy41YmPOw"]
Date: Sep 16, 2026
packages/opencode/src/server/routes/instance/httpapi/handlers/sync.ts (89 lines). SyncHttpApi.replay converts ctx.payload.events into EventV2.SerializedEvent[], preserving id, aggregateID, seq, type, and a shallow-copied data: { ...event.data }.packages/opencode/src/server/routes/instance/httpapi/handlers/sync.ts:42, SyncHttpApi.replay derives source with payload[0].aggregateID; logging later uses optional access for payload[0]?.seq and payload.at(-1)?.seq.SyncHttpApi.replay logs "sync replay requested" with sessionID, event count, first/last sequence, and ctx.payload.directory; obtains ownerID from InstanceState.workspaceID; calls events.replayAll(payload, { ownerID, strictOwner: true }); logs "sync replay complete"; and returns { sessionID: source }.SyncHttpApi.start calls workspace.startWorkspaceSyncing((yield* InstanceState.context).project.id) and runs it with Effect.ignore and Effect.forkIn(scope), then returns true.SyncHttpApi.steal reads InstanceState.workspaceID, returns HttpApiError.BadRequest when absent, otherwise calls session.setWorkspace({ sessionID: ctx.payload.sessionID, workspaceID }), logs "sync session stolen", and returns the session ID.SyncHttpApi.history queries EventTable; for each [id, seq] in ctx.payload, it excludes rows satisfying aggregate_id = id AND seq <= supplied seq, combines exclusions with not(or(...)), orders globally by asc(EventTable.seq), calls .all(), and converts database errors with Effect.orDie.packages/schema/src/session-event.ts. Its common durable event options are { durable: { aggregate: "sessionID", version: 1 } }; step-settlement options use { durable: { aggregate: "sessionID", version: 2 } }.packages/schema/src/session-event.ts defines Source as { start: NonNegativeInt, end: NonNegativeInt, text: Schema.String }, annotated with identifier "session.next.event.source". Shared Base fields are timestamp: DateTimeUtcFromMillis and sessionID: SessionID.packages/schema/src/session-event.ts: AgentSwitched ("session.next.agent.switched", messageID, agent); ModelSwitched ("session.next.model.switched", messageID, model); Moved ("session.next.moved", location, optional subdirectory); Prompted ("session.next.prompted", messageID, prompt, delivery); PromptAdmitted ("session.next.prompt.admitted", same prompt fields plus optional boolean requestExecution); PromptExecutionRequested ("session.next.prompt.execution_requested", messageID); ContextUpdated ("session.next.context.updated", messageID, text); and Synthetic ("session.next.synthetic", messageID, text). All use durable version 1.SessionEvent.Shell.Started is durable version 1 with type "session.next.shell.started" and fields messageID, callID, and command; SessionEvent.Shell.Ended is durable version 1 with type "session.next.shell.ended" and fields callID and output.SessionEvent.Step.Started is durable version 1 with type "session.next.step.started" and fields assistantMessageID, agent, model, and optional snapshot. Step.Ended and Step.Failed use durable version 2: Step.Ended ("session.next.step.ended") includes assistantMessageID, finish, finite cost, finite token counts for input, output, reasoning, cache.read, and cache.write, plus optional snapshot and optional files; Step.Failed ("session.next.step.failed") includes assistantMessageID and UnknownError.SessionEvent.Step.Interrupted is durable version 1 with type "session.next.step.interrupted", assistantMessageID, and UnknownError. Step.Recovered is durable version 1 with type "session.next.step.recovered", executionID, optional assistantMessageID, and phase restricted to "ready", "unknown", or "continue".packages/schema/src/session-event.ts: Text.Started ("session.next.text.started") is durable version 1 with assistantMessageID and textID; Text.Delta ("session.next.text.delta") has no durable options and is explicitly documented as live-only, carrying assistantMessageID, textID, and delta; Text.Ended ("session.next.text.ended") is documented as the replayable full-value boundary.