effect-durable-agent 0.1.0-alpha.23 → 0.1.0-alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/delivery-Bb7pkQ9o.js +507 -0
  2. package/dist/delivery-Bb7pkQ9o.js.map +1 -0
  3. package/dist/delivery-o6sDIiwO.d.ts +2990 -0
  4. package/dist/in-memory-IgxnTbGb.js +150 -0
  5. package/dist/in-memory-IgxnTbGb.js.map +1 -0
  6. package/dist/{window-read-BDayZf7O.js → interpreter-BdRoYrfL.js} +94 -206
  7. package/dist/interpreter-BdRoYrfL.js.map +1 -0
  8. package/dist/services/reducer-registry.js +1 -1
  9. package/dist/services/runtime-layer.js +3 -3
  10. package/dist/services/runtime.js +1 -1
  11. package/dist/services/session-query.js +2 -2
  12. package/dist/services/session-state.js +1 -1
  13. package/dist/services/session-store.js +271 -1
  14. package/dist/services/session-store.js.map +1 -0
  15. package/dist/services/sink-registry.js +1 -1
  16. package/dist/{session-state-C6SyphC0.js → session-state-BW0l2aNk.js} +3 -3
  17. package/dist/{session-state-C6SyphC0.js.map → session-state-BW0l2aNk.js.map} +1 -1
  18. package/dist/{sink-registry-DtrssBxF.js → sink-registry-D0MetcNq.js} +2 -2
  19. package/dist/{sink-registry-DtrssBxF.js.map → sink-registry-D0MetcNq.js.map} +1 -1
  20. package/dist/{subscription-g5W0Ggqx.js → subscription-Dzr5LqPX.js} +5 -3
  21. package/dist/subscription-Dzr5LqPX.js.map +1 -0
  22. package/dist/testkit/layers.d.ts +8 -2
  23. package/dist/testkit/layers.js +7 -3
  24. package/dist/testkit/layers.js.map +1 -1
  25. package/dist/testkit/transcript.d.ts +226 -0
  26. package/dist/testkit/transcript.js +1475 -0
  27. package/dist/testkit/transcript.js.map +1 -0
  28. package/dist/transcript.d.ts +25 -101
  29. package/dist/transcript.js +4 -3
  30. package/dist/transcript.js.map +1 -1
  31. package/dist/websocket/events.d.ts +2 -0
  32. package/dist/websocket/events.js +2 -0
  33. package/dist/websocket.d.ts +1 -2986
  34. package/dist/websocket.js +3 -504
  35. package/dist/websocket.js.map +1 -1
  36. package/dist/window-read-DBf1Iktt.d.ts +104 -0
  37. package/dist/window-read-U55aAeuz.js +184 -0
  38. package/dist/window-read-U55aAeuz.js.map +1 -0
  39. package/package.json +9 -1
  40. package/dist/session-store-DuEhcqIC.js +0 -414
  41. package/dist/session-store-DuEhcqIC.js.map +0 -1
  42. package/dist/subscription-g5W0Ggqx.js.map +0 -1
  43. package/dist/window-read-BDayZf7O.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcript.js","names":[],"sources":["../../src/transcript/transcript-testkit.ts","../../src/transcript/transcript-scenarios.ts"],"sourcesContent":["import * as Prompt from \"effect/ai/Prompt\";\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\n\nimport { durableMessageTranscript } from \"../domain/message-transcript\";\nimport { reduceCommittedEvents } from \"../domain/reduced-state\";\nimport type { CommittedDurableEvent } from \"../services/session-store\";\nimport { SequenceNumber, SessionId, durablePosition } from \"../types/core\";\nimport { effectDurableAgentNamespace, type DurableEventEnvelope } from \"../types/events/envelope\";\nimport { decodeDurableEventSync } from \"../types/events/durable\";\nimport { makeEDATraceContext } from \"../types/tracing\";\nimport { canonicalJson } from \"./version\";\nimport {\n advanceTranscriptVersion,\n emptyTranscriptVersion,\n type InMemoryTranscriptVersion,\n} from \"./in-memory\";\nimport {\n emptyTranscriptMappings,\n makeTranscriptDefinition,\n type TranscriptDefinition,\n type TranscriptMappings,\n} from \"./mapping\";\nimport {\n TranscriptRecordFromEnvelope,\n isTopLevelTranscriptRecord,\n type TranscriptRecord,\n} from \"./records\";\n\n/**\n * Test-only builders for transcript interpretation: deterministic ids, a log writer that goes\n * through the real durable decoders, and helpers that project and normalize logs.\n */\n\nconst traceContext = makeEDATraceContext({\n traceId: \"0123456789abcdef0123456789abcdef\",\n spanId: \"0123456789abcdef\",\n});\n/** The encoded trace every test event carries. */\nexport const testEventTrace = { span: traceContext, links: [] };\nconst runTrace = { root: traceContext, links: [] };\n\n/** Deterministic UUIDv7-shaped id; `space` keeps identities of different kinds apart. */\nexport const testId = (space: number, slot: number): string =>\n `018f6bd5-2f2a-7${space.toString(16).padStart(3, \"0\")}-8${(slot >> 48).toString(16).padStart(3, \"0\")}-${(\n slot %\n 2 ** 48\n )\n .toString(16)\n .padStart(12, \"0\")}`;\n\nexport const ids = {\n command: (slot: number) => testId(0x101, slot),\n message: (slot: number) => testId(0x102, slot),\n run: (slot: number) => testId(0x103, slot),\n turn: (slot: number) => testId(0x104, slot),\n inference: (slot: number) => testId(0x105, slot),\n tool: (slot: number) => testId(0x106, slot),\n compaction: (slot: number) => testId(0x107, slot),\n summary: (slot: number) => testId(0x108, slot),\n event: (slot: number) => testId(0x109, slot),\n} as const;\n\nexport const testSessionId = SessionId.make(testId(0x100, 1));\nexport const testModel = { provider: \"test\", modelId: \"model-a\" } as const;\n\nconst summaryPromptMessage = (text: string) =>\n Schema.encodeSync(Prompt.UserMessage)(\n Prompt.makeMessage(\"user\", { content: [Prompt.textPart({ text })] }),\n );\n\n/**\n * Append-only test log. Every event is built as a raw envelope and decoded through the store's\n * durable decoder, so tests exercise the same shapes the interpreter receives in production.\n */\nexport class TestLog {\n readonly events: Array<CommittedDurableEvent> = [];\n private readonly envelopes: Array<DurableEventEnvelope> = [];\n private nextEvent = 1;\n\n /** The raw envelopes, for seeding an in-memory store. */\n get durableEnvelopes(): ReadonlyArray<DurableEventEnvelope> {\n return this.envelopes;\n }\n\n append(type: string, payload: Record<string, unknown>, namespace = effectDurableAgentNamespace) {\n const slot = this.nextEvent++;\n const raw = {\n namespace,\n type,\n schemaVersion: 1,\n durability: \"durable\",\n eventId: ids.event(slot),\n sessionId: testSessionId,\n createdAtMs: 1_760_000_000_000 + slot * 1_000,\n trace: testEventTrace,\n payload,\n };\n const event = decodeDurableEventSync(raw);\n const envelope = event.namespace === \"__foreign\" ? event.envelope : event;\n this.envelopes.push(envelope);\n this.events.push({\n position: durablePosition(SequenceNumber.make(this.events.length + 1)),\n event,\n });\n return this;\n }\n\n appendForeign(namespace: string, type: string, payload: Record<string, unknown>) {\n return this.append(type, payload, namespace);\n }\n\n configure() {\n return this.append(\"SessionConfigured\", { modelSelection: testModel });\n }\n\n /** Command admission plus the submitted message, as session ingress writes them. */\n submit(input: {\n readonly command: number;\n readonly message: number;\n readonly text: string;\n readonly disposition?: \"queue\" | \"steer\";\n readonly idempotencyKey?: string;\n }) {\n const disposition = input.disposition ?? \"queue\";\n this.append(\"CommandAdmitted\", {\n command: {\n _tag: \"SubmitMessage\",\n commandId: ids.command(input.command),\n disposition,\n content: input.text,\n ...(input.idempotencyKey === undefined ? {} : { idempotencyKey: input.idempotencyKey }),\n },\n });\n return this.append(\"UserMessageSubmitted\", {\n commandId: ids.command(input.command),\n messageId: ids.message(input.message),\n disposition,\n content: input.text,\n });\n }\n\n /** A legacy or interrupt-path admission: the message is committed when the command starts. */\n admitOnly(input: {\n readonly command: number;\n readonly text: string;\n readonly idempotencyKey?: string;\n }) {\n return this.append(\"CommandAdmitted\", {\n command: {\n _tag: \"SubmitMessage\",\n commandId: ids.command(input.command),\n disposition: \"interrupt\",\n content: input.text,\n ...(input.idempotencyKey === undefined ? {} : { idempotencyKey: input.idempotencyKey }),\n },\n });\n }\n\n commitUser(input: { readonly command: number; readonly message: number; readonly text: string }) {\n return this.append(\"UserMessageCommitted\", {\n commandId: ids.command(input.command),\n messageId: ids.message(input.message),\n content: input.text,\n });\n }\n\n startRun(input: { readonly run: number; readonly commands: ReadonlyArray<number> }) {\n for (const command of input.commands) {\n this.append(\"CommandStarted\", { commandId: ids.command(command) });\n }\n return this.runStarted(input);\n }\n\n runStarted(input: { readonly run: number; readonly commands: ReadonlyArray<number> }) {\n return this.append(\"RunStarted\", {\n runId: ids.run(input.run),\n commandIds: input.commands.map(ids.command),\n modelSelection: testModel,\n trace: runTrace,\n });\n }\n\n turn(input: {\n readonly run: number;\n readonly turn: number;\n readonly inputs?: ReadonlyArray<number>;\n }) {\n return this.append(\"TurnStarted\", {\n runId: ids.run(input.run),\n turnId: ids.turn(input.turn),\n ...(input.inputs === undefined ? {} : { inputMessageIds: input.inputs.map(ids.message) }),\n });\n }\n\n inferenceStarted(input: {\n readonly run: number;\n readonly turn: number;\n readonly inference: number;\n }) {\n return this.append(\"InferenceStarted\", {\n runId: ids.run(input.run),\n turnId: ids.turn(input.turn),\n inferenceId: ids.inference(input.inference),\n });\n }\n\n assistant(input: {\n readonly run: number;\n readonly turn: number;\n readonly inference: number;\n readonly message: number;\n readonly text?: string;\n readonly reasoning?: string;\n readonly toolCalls?: ReadonlyArray<{ readonly providerId: string; readonly name: string }>;\n readonly partial?: string;\n }) {\n const promptParts = [\n ...(input.reasoning === undefined ? [] : [{ type: \"reasoning\", text: input.reasoning }]),\n ...(input.text === undefined ? [] : [{ type: \"text\", text: input.text }]),\n ...(input.toolCalls ?? []).map((call) => ({\n type: \"tool-call\",\n id: call.providerId,\n name: call.name,\n params: { q: call.name },\n providerExecuted: false,\n })),\n ];\n return this.append(\n input.partial === undefined ? \"AssistantMessageCommitted\" : \"AssistantPartialCommitted\",\n {\n messageId: ids.message(input.message),\n runId: ids.run(input.run),\n turnId: ids.turn(input.turn),\n inferenceId: ids.inference(input.inference),\n promptParts,\n ...(input.partial === undefined ? {} : { reason: input.partial }),\n },\n );\n }\n\n importAssistant(input: {\n readonly run: number;\n readonly turn: number;\n readonly inference: number;\n readonly message: number;\n readonly text: string;\n }) {\n return this.append(\"AssistantMessageImported\", {\n messageId: ids.message(input.message),\n runId: ids.run(input.run),\n turnId: ids.turn(input.turn),\n inferenceId: ids.inference(input.inference),\n promptParts: [{ type: \"text\", text: input.text }],\n });\n }\n\n inferenceCompleted(input: {\n readonly run: number;\n readonly turn: number;\n readonly inference: number;\n readonly outputTokens?: number;\n }) {\n return this.append(\"InferenceCompleted\", {\n runId: ids.run(input.run),\n turnId: ids.turn(input.turn),\n inferenceId: ids.inference(input.inference),\n finishReason: \"stop\",\n usage: { inputTokens: 10, outputTokens: input.outputTokens ?? 5 },\n });\n }\n\n inferenceFailed(input: {\n readonly run: number;\n readonly turn: number;\n readonly inference: number;\n readonly code?: string;\n }) {\n return this.append(\"InferenceFailed\", {\n runId: ids.run(input.run),\n turnId: ids.turn(input.turn),\n inferenceId: ids.inference(input.inference),\n error: {\n message: \"inference failed\",\n ...(input.code === undefined ? {} : { code: input.code }),\n },\n });\n }\n\n toolCreated(input: {\n readonly run: number;\n readonly turn: number;\n readonly inference: number;\n readonly tool: number;\n readonly providerId: string;\n readonly name: string;\n }) {\n return this.append(\"ToolCallCreated\", {\n runId: ids.run(input.run),\n turnId: ids.turn(input.turn),\n inferenceId: ids.inference(input.inference),\n toolCallId: ids.tool(input.tool),\n promptPart: {\n type: \"tool-call\",\n id: input.providerId,\n name: input.name,\n params: { q: input.name },\n providerExecuted: false,\n },\n });\n }\n\n toolRejected(input: {\n readonly run: number;\n readonly turn: number;\n readonly inference: number;\n readonly tool: number;\n readonly providerId: string;\n readonly name: string;\n }) {\n return this.append(\"ToolCallRejected\", {\n runId: ids.run(input.run),\n turnId: ids.turn(input.turn),\n inferenceId: ids.inference(input.inference),\n toolCallId: ids.tool(input.tool),\n promptPart: {\n type: \"tool-result\",\n id: input.providerId,\n name: input.name,\n isFailure: true,\n result: { message: \"unknown tool\", reason: \"unknown-tool\", modelFeedback: \"no such tool\" },\n },\n });\n }\n\n toolStarted(tool: number) {\n return this.append(\"ToolCallStarted\", { toolCallId: ids.tool(tool) });\n }\n\n toolCompleted(input: {\n readonly tool: number;\n readonly providerId: string;\n readonly name: string;\n readonly result?: unknown;\n }) {\n return this.append(\"ToolCallCompleted\", {\n toolCallId: ids.tool(input.tool),\n promptPart: {\n type: \"tool-result\",\n id: input.providerId,\n name: input.name,\n isFailure: false,\n result: input.result ?? { ok: true },\n },\n });\n }\n\n toolFailed(input: { readonly tool: number; readonly providerId: string; readonly name: string }) {\n return this.append(\"ToolCallFailed\", {\n toolCallId: ids.tool(input.tool),\n error: { message: \"tool cancelled\", code: \"tool.cancelled\" },\n promptPart: {\n type: \"tool-result\",\n id: input.providerId,\n name: input.name,\n isFailure: true,\n result: { message: \"tool cancelled\" },\n },\n });\n }\n\n turnCompleted(input: { readonly run: number; readonly turn: number }) {\n return this.append(\"TurnCompleted\", {\n runId: ids.run(input.run),\n turnId: ids.turn(input.turn),\n });\n }\n\n runCompleted(run: number, commands: ReadonlyArray<number> = []) {\n this.append(\"RunCompleted\", { runId: ids.run(run) });\n for (const command of commands)\n this.append(\"CommandCompleted\", { commandId: ids.command(command) });\n return this;\n }\n\n runInterrupted(run: number) {\n return this.append(\"RunFailed\", {\n runId: ids.run(run),\n error: { message: \"run interrupted: restart\", code: \"run.interrupted\" },\n });\n }\n\n steer(input: {\n readonly command: number;\n readonly message: number;\n readonly run: number;\n readonly text: string;\n }) {\n return this.append(\"SteeringMessageQueued\", {\n commandId: ids.command(input.command),\n messageId: ids.message(input.message),\n runId: ids.run(input.run),\n content: input.text,\n });\n }\n\n compaction(input: {\n readonly compaction: number;\n readonly summary: number;\n readonly retainedFromContextSeq: number;\n readonly contextVersion: number;\n }) {\n const seq = this.events.length;\n this.append(\"CompactionRequested\", {\n compactionId: ids.compaction(input.compaction),\n sourceFromSeq: 1,\n sourceToSeq: seq,\n });\n this.append(\"CompactionStarted\", { compactionId: ids.compaction(input.compaction) });\n this.append(\"SummaryCreated\", {\n compactionId: ids.compaction(input.compaction),\n summaryId: ids.summary(input.summary),\n sourceFromSeq: 1,\n sourceToSeq: seq,\n summary: {\n compactionId: ids.compaction(input.compaction),\n summaryId: ids.summary(input.summary),\n sourceFromSeq: 1,\n sourceToSeq: seq,\n retainedFromContextSeq: input.retainedFromContextSeq,\n text: \"summary\",\n promptMessage: summaryPromptMessage(\"summary\"),\n policyId: \"test\",\n },\n });\n this.append(\"ContextRebased\", {\n compactionId: ids.compaction(input.compaction),\n summaryId: ids.summary(input.summary),\n contextVersion: input.contextVersion,\n retainedFromContextSeq: input.retainedFromContextSeq,\n });\n return this.append(\"CompactionCompleted\", {\n compactionId: ids.compaction(input.compaction),\n modelSelection: testModel,\n usage: { inputTokens: 100, outputTokens: 20 },\n });\n }\n\n /** One complete assistant turn: start, content, optional tools run to completion, finish. */\n assistantTurn(input: {\n readonly run: number;\n readonly turn: number;\n readonly inference: number;\n readonly message: number;\n readonly text: string;\n readonly inputs?: ReadonlyArray<number>;\n readonly tools?: ReadonlyArray<number>;\n }) {\n this.turn({\n run: input.run,\n turn: input.turn,\n ...(input.inputs === undefined ? {} : { inputs: input.inputs }),\n });\n this.inferenceStarted(input);\n const toolCalls = (input.tools ?? []).map((tool) => ({\n tool,\n providerId: `call_${tool}`,\n name: `tool_${tool}`,\n }));\n this.assistant({ ...input, toolCalls });\n for (const call of toolCalls) this.toolCreated({ ...input, ...call });\n this.inferenceCompleted(input);\n for (const call of toolCalls) {\n this.toolStarted(call.tool);\n this.toolCompleted(call);\n }\n return this.turnCompleted(input);\n }\n}\n\n/** A definition, built synchronously for tests. */\nexport const testDefinition = (\n mappings: TranscriptMappings = emptyTranscriptMappings,\n): TranscriptDefinition => Effect.runSync(makeTranscriptDefinition(mappings));\n\n/** Project a log split into the given batches, starting from an empty version. */\nexport const projectBatches = (\n definition: TranscriptDefinition,\n batches: ReadonlyArray<ReadonlyArray<CommittedDurableEvent>>,\n): InMemoryTranscriptVersion =>\n batches.reduce(\n (version, batch) => advanceTranscriptVersion(version, definition, batch),\n emptyTranscriptVersion(definition.version, \"active\"),\n );\n\n/**\n * A semantic view of a projected version for equality: every record encoded through its stored\n * envelope with `updatedSeq` normalized, every alias, and the cursor and status.\n */\nexport const normalizedProjection = (version: InMemoryTranscriptVersion) => ({\n meta: version.meta,\n records: Array.from(version.records.values())\n .map((record) => ({\n ...Schema.encodeSync(TranscriptRecordFromEnvelope)(record),\n updatedSeq: 0,\n }))\n .sort((left, right) => (left.id < right.id ? -1 : left.id > right.id ? 1 : 0)),\n aliases: Array.from(version.aliases.entries()).sort(([left], [right]) =>\n left < right ? -1 : left > right ? 1 : 0,\n ),\n});\n\n/** Canonical JSON of every record, for fingerprints. */\nexport const projectionJson = (records: Iterable<TranscriptRecord>): string =>\n canonicalJson(\n Array.from(records)\n .map((record) => Schema.encodeSync(TranscriptRecordFromEnvelope)(record))\n .sort((left, right) => (left.id < right.id ? -1 : left.id > right.id ? 1 : 0)),\n );\n\n/** History the transcript renders: consumed users and committed assistants, in order. */\nexport const renderedTranscriptHistory = (\n version: InMemoryTranscriptVersion,\n): ReadonlyArray<string> =>\n Array.from(version.records.values())\n .filter(isTopLevelTranscriptRecord)\n .sort(\n (left, right) =>\n left.position.anchorSeq - right.position.anchorSeq ||\n left.position.ordinal - right.position.ordinal,\n )\n .flatMap((record) => {\n switch (record.kind) {\n case \"user\":\n return [`user:${record.commandId}`];\n case \"assistant\":\n return record.messageId === undefined ? [] : [`assistant:${record.inferenceId}`];\n case \"compaction\":\n return [];\n }\n });\n\n/** The same history as the model sees it today, from the (possibly pruned) reduced state. */\nexport const reducedStateHistory = (\n events: ReadonlyArray<CommittedDurableEvent>,\n): ReadonlyArray<string> =>\n durableMessageTranscript(reduceCommittedEvents(events))\n .filter(\n (message) =>\n message._tag !== \"User\" ||\n message.requestedDisposition === undefined ||\n message.consumedSeq !== undefined,\n )\n .map((message) =>\n message._tag === \"User\" || message._tag === \"Steering\"\n ? `user:${message.commandId}`\n : `assistant:${message.inferenceId}`,\n );\n\n/**\n * Plausible logs from a small session simulator: each step picks an action that is valid in the\n * simulated state, so every generated log follows the runtime's event protocol.\n */\nexport const generatedTestLog = (\n steps: ReadonlyArray<number>,\n): { log: TestLog; compacted: boolean } => {\n const log = new TestLog().configure();\n let next = 1;\n let compacted = false;\n const pending: Array<number> = [];\n const steering: Array<number> = [];\n let active: { run: number; commands: Array<number>; turns: number; first?: number } | undefined;\n for (const step of steps) {\n const slot = next++;\n switch (step % 11) {\n case 0: {\n const key = slot % 2 === 0 ? `k:${slot}` : undefined;\n if (key !== undefined) {\n log.appendForeign(\"gia-agent\", \"GiaUserMessageAuthorCommitted\", {\n relatedCommandIdempotencyKey: key,\n userEmail: `u${slot}@example.com`,\n });\n }\n log.submit({\n command: slot,\n message: slot,\n text: `q${slot}`,\n ...(key === undefined ? {} : { idempotencyKey: key }),\n });\n pending.push(slot);\n break;\n }\n case 1:\n if (active !== undefined) {\n log.steer({ command: slot, message: slot, run: active.run, text: `s${slot}` });\n steering.push(slot);\n }\n break;\n case 2: {\n const first = pending.shift();\n if (active === undefined && first !== undefined) {\n log.startRun({ run: slot, commands: [first] });\n active = { run: slot, commands: [first], turns: 0, first };\n } else if (first !== undefined) {\n pending.unshift(first);\n }\n break;\n }\n case 3:\n case 4: {\n if (active === undefined) break;\n const inputs = [\n ...(active.first === undefined ? [] : [active.first]),\n ...steering.splice(0),\n ];\n active.first = undefined;\n active.turns += 1;\n const tools = step % 3 === 0 ? [slot] : [];\n log.assistantTurn({\n run: active.run,\n turn: slot,\n inference: slot,\n message: 10_000 + slot,\n text: `a${slot}`,\n inputs,\n tools,\n });\n break;\n }\n case 5:\n if (active !== undefined && active.first === undefined) {\n log.turn({ run: active.run, turn: slot, inputs: steering.splice(0) });\n log.inferenceStarted({ run: active.run, turn: slot, inference: slot });\n log.assistant({\n run: active.run,\n turn: slot,\n inference: slot,\n message: 10_000 + slot,\n text: \"cut\",\n partial: \"stopped\",\n });\n log.inferenceFailed({\n run: active.run,\n turn: slot,\n inference: slot,\n code: \"inference.interrupted\",\n });\n }\n break;\n case 6:\n if (active !== undefined && active.first === undefined) {\n log.runCompleted(active.run, active.commands);\n active = undefined;\n }\n break;\n case 7:\n if (active !== undefined && active.first === undefined) {\n log.runInterrupted(active.run);\n log.runStarted({ run: slot, commands: active.commands });\n log.append(\"RecoveryCompleted\", {\n trigger: \"runtime-restart\",\n continuation: {\n commandId: ids.command(active.commands[0] ?? 0),\n interruptedRunId: ids.run(active.run),\n replacementRunId: ids.run(slot),\n },\n });\n active = { ...active, run: slot };\n }\n break;\n case 8:\n if (log.events.length > 4) {\n log.compaction({\n compaction: slot,\n summary: slot,\n retainedFromContextSeq: log.events.length,\n contextVersion: slot,\n });\n compacted = true;\n }\n break;\n case 9: {\n const cancelled = pending.pop();\n if (cancelled !== undefined) {\n log.append(\"UserMessageCancelled\", {\n commandId: ids.command(slot),\n messageId: ids.message(cancelled),\n reason: \"user-cancel\",\n });\n }\n break;\n }\n case 10: {\n const promoted = pending.shift();\n if (promoted !== undefined && active !== undefined) {\n log.append(\"UserMessagePromoted\", {\n commandId: ids.command(slot),\n messageId: ids.message(promoted),\n from: \"queue\",\n to: \"steer\",\n });\n steering.push(promoted);\n } else if (promoted !== undefined) {\n pending.unshift(promoted);\n }\n break;\n }\n }\n }\n return { log, compacted };\n};\n","import type { CommittedDurableEvent } from \"../services/session-store\";\nimport type { TranscriptMappings } from \"./mapping\";\nimport { TestLog, ids } from \"./transcript-testkit\";\n\n/**\n * The fixed scenario corpus: one named log per interpretation rule the transcript must get\n * right. The oracle, the fingerprint and the prompt-parity check all run over it. Add a scenario\n * for every new rule; never edit an existing one without bumping the semantic revision.\n */\nexport interface TranscriptScenario {\n readonly name: string;\n readonly events: ReadonlyArray<CommittedDurableEvent>;\n /** Whether the log contains a context rebase (the reduced state is pruned). */\n readonly compacted: boolean;\n}\n\n/** Gia-shaped decorations used by the decoration scenarios. */\nexport const giaLikeTestMappings: TranscriptMappings = {\n mappings: [\n {\n name: \"author\",\n event: { namespace: \"gia-agent\", type: \"GiaUserMessageAuthorCommitted\", schemaVersion: 1 },\n target: { _tag: \"UserByIdempotencyKey\", path: [\"relatedCommandIdempotencyKey\"] },\n operations: [{ _tag: \"FirstWins\", from: [\"userEmail\"], to: \"author\" }],\n },\n {\n name: \"lastAuthor\",\n event: { namespace: \"gia-agent\", type: \"GiaUserMessageAuthorCommitted\", schemaVersion: 1 },\n target: { _tag: \"Session\" },\n operations: [{ _tag: \"Copy\", from: [\"userEmail\"], to: \"lastAuthor\" }],\n },\n {\n name: \"owner\",\n event: { namespace: \"gia-agent\", type: \"GiaSessionMetadataCommitted\", schemaVersion: 1 },\n target: { _tag: \"Session\" },\n operations: [{ _tag: \"FirstWins\", from: [\"ownerUserEmail\"], to: \"owner\" }],\n },\n {\n name: \"attachments\",\n event: { namespace: \"gia-agent\", type: \"GiaFileAttachmentCreated\", schemaVersion: 1 },\n target: { _tag: \"UserByIdempotencyKey\", path: [\"relatedCommandIdempotencyKey\"] },\n operations: [\n {\n _tag: \"ReplaceListEntry\",\n from: [],\n to: \"attachments\",\n key: { _tag: \"Id\", path: [\"attachmentId\"] },\n },\n ],\n },\n {\n name: \"references\",\n event: { namespace: \"gia-agent\", type: \"GiaReferenceCreated\", schemaVersion: 1 },\n target: { _tag: \"UserByIdempotencyKey\", path: [\"relatedCommandIdempotencyKey\"] },\n operations: [\n {\n _tag: \"ReplaceListEntry\",\n from: [\"target\"],\n to: \"references\",\n key: { _tag: \"Ordinal\", path: [\"ordinal\"] },\n },\n ],\n },\n {\n name: \"subagentNotice\",\n event: { namespace: \"gia-agent\", type: \"GiaSubagentNotificationCommitted\", schemaVersion: 1 },\n target: { _tag: \"UserByCommandId\", path: [\"notificationId\"] },\n operations: [\n { _tag: \"Classify\", classification: \"subagentNotice\" },\n { _tag: \"FirstWins\", from: [\"children\"], to: \"subagentChildren\" },\n ],\n },\n ],\n userFallbacks: [\n { to: \"author\", fromSession: \"lastAuthor\" },\n { to: \"author\", fromSession: \"owner\" },\n ],\n};\n\nconst author = (key: string, email: string) => ({\n relatedCommandIdempotencyKey: key,\n userEmail: email,\n});\n\nconst queueRunTools = () => {\n const log = new TestLog().configure();\n log.submit({ command: 1, message: 1, text: \"hi\", idempotencyKey: \"web:1\" });\n log.startRun({ run: 1, commands: [1] });\n log.assistantTurn({\n run: 1,\n turn: 1,\n inference: 1,\n message: 101,\n text: \"calling\",\n inputs: [1],\n tools: [1, 2],\n });\n log.assistantTurn({ run: 1, turn: 2, inference: 2, message: 102, text: \"done\" });\n return log.runCompleted(1, [1]);\n};\n\nconst legacyCommitted = () => {\n const log = new TestLog().configure();\n log.admitOnly({ command: 1, text: \"interrupting\" });\n log.append(\"CommandStarted\", { commandId: ids.command(1) });\n log.commitUser({ command: 1, message: 1, text: \"interrupting\" });\n log.runStarted({ run: 1, commands: [1] });\n log.assistantTurn({ run: 1, turn: 1, inference: 1, message: 101, text: \"ok\", inputs: [1] });\n // A committed user without any admission, as very old logs have.\n log.commitUser({ command: 2, message: 2, text: \"old\" });\n return log.runCompleted(1, [1]);\n};\n\nconst steering = () => {\n const log = new TestLog().configure();\n log.submit({ command: 1, message: 1, text: \"start\" });\n log.startRun({ run: 1, commands: [1] });\n log.turn({ run: 1, turn: 1, inputs: [1] });\n log.inferenceStarted({ run: 1, turn: 1, inference: 1 });\n log.submit({ command: 2, message: 2, text: \"steer me\", disposition: \"steer\" });\n log.steer({ command: 3, message: 3, run: 1, text: \"also this\" });\n log.steer({ command: 4, message: 4, run: 1, text: \"never mind\" });\n log.append(\"SteeringMessageCancelled\", {\n messageId: ids.message(4),\n runId: ids.run(1),\n reason: \"run ended\",\n });\n log.assistant({ run: 1, turn: 1, inference: 1, message: 101, text: \"first\" });\n log.inferenceCompleted({ run: 1, turn: 1, inference: 1 });\n log.turnCompleted({ run: 1, turn: 1 });\n log.assistantTurn({\n run: 1,\n turn: 2,\n inference: 2,\n message: 102,\n text: \"steered\",\n inputs: [2, 3],\n });\n return log.runCompleted(1, [1]);\n};\n\nconst promotePauseCancel = () => {\n const log = new TestLog().configure();\n log.submit({ command: 1, message: 1, text: \"first\" });\n log.startRun({ run: 1, commands: [1] });\n log.turn({ run: 1, turn: 1, inputs: [1] });\n log.submit({ command: 2, message: 2, text: \"queued a\" });\n log.submit({ command: 3, message: 3, text: \"queued b\" });\n log.submit({ command: 4, message: 4, text: \"queued c\" });\n log.submit({ command: 5, message: 5, text: \"queued d\" });\n log.append(\"UserMessagePromoted\", {\n commandId: ids.command(6),\n messageId: ids.message(2),\n from: \"queue\",\n to: \"steer\",\n });\n log.append(\"PendingMessagesPaused\", {\n interruptionCommandId: ids.command(7),\n runId: ids.run(1),\n messageIds: [ids.message(3), ids.message(4)],\n reason: \"user-interrupted\",\n });\n log.append(\"UserMessageCancelled\", {\n commandId: ids.command(8),\n messageId: ids.message(4),\n reason: \"user-cancel\",\n });\n log.append(\"UserMessageCancelled\", {\n commandId: ids.command(9),\n messageId: ids.message(5),\n reason: \"edit\",\n });\n log.append(\"CommandCancelled\", { commandId: ids.command(5), reason: \"edited\" });\n log.admitOnly({ command: 10, text: \"admitted then cancelled\" });\n log.append(\"CommandCancelled\", { commandId: ids.command(10), reason: \"stopped\" });\n log.inferenceStarted({ run: 1, turn: 1, inference: 1 });\n log.assistant({ run: 1, turn: 1, inference: 1, message: 101, text: \"answer\" });\n log.inferenceCompleted({ run: 1, turn: 1, inference: 1 });\n log.turnCompleted({ run: 1, turn: 1 });\n log.assistantTurn({ run: 1, turn: 2, inference: 2, message: 102, text: \"promoted\", inputs: [2] });\n return log.runCompleted(1, [1]);\n};\n\nconst partialEmptyImport = () => {\n const log = new TestLog().configure();\n log.importAssistant({ run: 9, turn: 9, inference: 9, message: 99, text: \"imported context\" });\n log.submit({ command: 1, message: 1, text: \"go\" });\n log.startRun({ run: 1, commands: [1] });\n log.turn({ run: 1, turn: 1, inputs: [1] });\n log.inferenceStarted({ run: 1, turn: 1, inference: 1 });\n log.assistant({\n run: 1,\n turn: 1,\n inference: 1,\n message: 101,\n text: \"half\",\n reasoning: \"hmm\",\n partial: \"inference failed before completion\",\n });\n log.inferenceFailed({ run: 1, turn: 1, inference: 1 });\n log.inferenceStarted({ run: 1, turn: 1, inference: 2 });\n log.inferenceCompleted({ run: 1, turn: 1, inference: 2, outputTokens: 0 });\n log.turnCompleted({ run: 1, turn: 1 });\n return log.runCompleted(1, [1]);\n};\n\nconst rejectedAndRepeatedTerminals = () => {\n const log = new TestLog().configure();\n log.submit({ command: 1, message: 1, text: \"tools\" });\n log.startRun({ run: 1, commands: [1] });\n log.turn({ run: 1, turn: 1, inputs: [1] });\n log.inferenceStarted({ run: 1, turn: 1, inference: 1 });\n // The tool is sealed before the assistant content, the reverse of the usual order.\n log.toolCreated({ run: 1, turn: 1, inference: 1, tool: 1, providerId: \"call_1\", name: \"search\" });\n log.toolRejected({ run: 1, turn: 1, inference: 1, tool: 2, providerId: \"call_2\", name: \"nope\" });\n log.assistant({\n run: 1,\n turn: 1,\n inference: 1,\n message: 101,\n text: \"using tools\",\n toolCalls: [\n { providerId: \"call_1\", name: \"search\" },\n { providerId: \"call_2\", name: \"nope\" },\n ],\n });\n log.inferenceCompleted({ run: 1, turn: 1, inference: 1 });\n log.toolStarted(1);\n log.toolCompleted({ tool: 1, providerId: \"call_1\", name: \"search\", result: { hits: 3 } });\n log.toolFailed({ tool: 1, providerId: \"call_1\", name: \"search\" });\n log.turnCompleted({ run: 1, turn: 1 });\n return log.runCompleted(1, [1]);\n};\n\nconst recovery = () => {\n const log = new TestLog().configure();\n log.submit({ command: 1, message: 1, text: \"long task\" });\n log.startRun({ run: 1, commands: [1] });\n log.turn({ run: 1, turn: 1, inputs: [1] });\n log.inferenceStarted({ run: 1, turn: 1, inference: 1 });\n log.assistant({\n run: 1,\n turn: 1,\n inference: 1,\n message: 101,\n text: \"working\",\n toolCalls: [{ providerId: \"call_1\", name: \"bash\" }],\n });\n log.toolCreated({ run: 1, turn: 1, inference: 1, tool: 1, providerId: \"call_1\", name: \"bash\" });\n log.inferenceCompleted({ run: 1, turn: 1, inference: 1 });\n log.toolStarted(1);\n // Startup recovery: one batch that fails everything open and continues the run.\n log.toolFailed({ tool: 1, providerId: \"call_1\", name: \"bash\" });\n log.append(\"TurnFailed\", {\n runId: ids.run(1),\n turnId: ids.turn(1),\n error: { message: \"turn interrupted\", code: \"turn.interrupted\" },\n });\n log.runInterrupted(1);\n log.runStarted({ run: 2, commands: [1] });\n log.append(\"RecoveryCompleted\", {\n trigger: \"runtime-restart\",\n continuation: {\n commandId: ids.command(1),\n interruptedRunId: ids.run(1),\n replacementRunId: ids.run(2),\n },\n });\n log.assistantTurn({ run: 2, turn: 2, inference: 2, message: 102, text: \"resumed\" });\n return log.runCompleted(2, [1]);\n};\n\nconst midRunCompaction = () => {\n const log = new TestLog().configure();\n log.submit({ command: 1, message: 1, text: \"first\" });\n log.startRun({ run: 1, commands: [1] });\n log.assistantTurn({\n run: 1,\n turn: 1,\n inference: 1,\n message: 101,\n text: \"one\",\n inputs: [1],\n tools: [1],\n });\n log.runCompleted(1, [1]);\n log.submit({ command: 2, message: 2, text: \"second\" });\n log.startRun({ run: 2, commands: [2] });\n log.assistantTurn({ run: 2, turn: 2, inference: 2, message: 102, text: \"two\", inputs: [2] });\n log.compaction({\n compaction: 1,\n summary: 1,\n retainedFromContextSeq: log.events.length,\n contextVersion: 1,\n });\n log.assistantTurn({ run: 2, turn: 3, inference: 3, message: 103, text: \"three\" });\n return log.runCompleted(2, [2]);\n};\n\nconst replacementMessageId = () => {\n // A pending submission pruned by a rebase is re-committed under a new message id when its\n // command starts (session 01a13b26 in the design): one record, two aliases.\n const log = new TestLog().configure();\n log.submit({ command: 1, message: 1, text: \"before\" });\n log.startRun({ run: 1, commands: [1] });\n log.assistantTurn({ run: 1, turn: 1, inference: 1, message: 101, text: \"busy\", inputs: [1] });\n log.submit({ command: 2, message: 2, text: \"queued during run\" });\n log.compaction({\n compaction: 1,\n summary: 1,\n retainedFromContextSeq: log.events.length + 1,\n contextVersion: 1,\n });\n log.runCompleted(1, [1]);\n log.append(\"CommandStarted\", { commandId: ids.command(2) });\n log.commitUser({ command: 2, message: 22, text: \"queued during run\" });\n log.runStarted({ run: 2, commands: [2] });\n log.assistantTurn({\n run: 2,\n turn: 2,\n inference: 2,\n message: 102,\n text: \"answered\",\n inputs: [22],\n });\n return log.runCompleted(2, [2]);\n};\n\nconst decorations = () => {\n const log = new TestLog().configure();\n log.appendForeign(\"gia-agent\", \"GiaSessionMetadataCommitted\", {\n ownerUserEmail: \"owner@example.com\",\n });\n // Web follow-up: author, attachments and a reference precede the command in one batch.\n log.appendForeign(\"gia-agent\", \"GiaUserMessageAuthorCommitted\", author(\"web:1\", \"a@example.com\"));\n log.appendForeign(\"gia-agent\", \"GiaFileAttachmentCreated\", {\n attachmentId: \"att-1\",\n relatedCommandIdempotencyKey: \"web:1\",\n ordinal: 0,\n fileName: \"a.txt\",\n });\n log.appendForeign(\"gia-agent\", \"GiaReferenceCreated\", {\n ordinal: 1,\n referenceId: \"ref-2\",\n relatedCommandIdempotencyKey: \"web:1\",\n target: { kind: \"doc\", id: \"d2\" },\n });\n log.appendForeign(\"gia-agent\", \"GiaReferenceCreated\", {\n ordinal: 0,\n referenceId: \"ref-1\",\n relatedCommandIdempotencyKey: \"web:1\",\n target: { kind: \"doc\", id: \"d1\" },\n });\n log.submit({ command: 1, message: 1, text: \"with files\", idempotencyKey: \"web:1\" });\n // A decoration after its command, a replaced attachment, and a second author (first wins).\n log.appendForeign(\"gia-agent\", \"GiaFileAttachmentCreated\", {\n attachmentId: \"att-1\",\n relatedCommandIdempotencyKey: \"web:1\",\n ordinal: 0,\n fileName: \"a-renamed.txt\",\n });\n log.appendForeign(\"gia-agent\", \"GiaUserMessageAuthorCommitted\", author(\"web:1\", \"b@example.com\"));\n // Subagent wakeup: the notice precedes a command whose id is the notification id.\n log.appendForeign(\"gia-agent\", \"GiaSubagentNotificationCommitted\", {\n notificationId: ids.command(2),\n children: [{ name: \"child\", sessionId: \"s\", state: \"completed\" }],\n });\n log.submit({\n command: 2,\n message: 2,\n text: \"children done\",\n idempotencyKey: `subagent:notify:${ids.command(2)}`,\n });\n // No author event for this key: the latest author is the fallback.\n log.submit({ command: 3, message: 3, text: \"no author\", idempotencyKey: \"slack:3\" });\n // Invalid decorations degrade only themselves; unmapped namespaces are ignored.\n log.appendForeign(\"gia-agent\", \"GiaUserMessageAuthorCommitted\", {\n relatedCommandIdempotencyKey: \"slack:3\",\n });\n log.appendForeign(\"gia-agent\", \"GiaFileAttachmentCreated\", {\n relatedCommandIdempotencyKey: \"slack:3\",\n fileName: \"no id\",\n });\n log.appendForeign(\"gia-agent\", \"GiaUserMessageAuthorCommitted\", {\n relatedCommandIdempotencyKey: 7,\n userEmail: \"x\",\n });\n log.appendForeign(\"other-app\", \"Whatever\", { relatedCommandIdempotencyKey: \"web:1\" });\n // An orphan decoration whose command never arrives.\n log.appendForeign(\"gia-agent\", \"GiaUserMessageAuthorCommitted\", author(\"never\", \"c@example.com\"));\n log.startRun({ run: 1, commands: [1, 2, 3] });\n log.assistantTurn({ run: 1, turn: 1, inference: 1, message: 101, text: \"ok\", inputs: [1, 2, 3] });\n return log.runCompleted(1, [1, 2, 3]);\n};\n\nconst ignoredEvents = () => {\n const log = new TestLog().configure();\n log.append(\"SystemMessageCommitted\", { messageId: ids.message(90), content: \"system prompt\" });\n log.append(\"RunSchedulingRequested\", {\n requestId: ids.event(900),\n work: { _tag: \"Command\", commandId: ids.command(1) },\n });\n log.append(\"RunSchedulingDelivered\", { requestId: ids.event(900) });\n log.append(\"RunSchedulingGranted\", { requestId: ids.event(900), runId: ids.run(1) });\n log.append(\"RunSchedulingInvalidated\", { requestId: ids.event(901), reason: \"stopped\" });\n log.submit({ command: 1, message: 1, text: \"hello\" });\n log.startRun({ run: 1, commands: [1] });\n log.turn({ run: 1, turn: 1, inputs: [1] });\n log.append(\"StopTurnRequested\", {\n commandId: ids.command(2),\n runId: ids.run(1),\n turnId: ids.turn(1),\n });\n log.append(\"StopTurnApplied\", {\n commandId: ids.command(2),\n runId: ids.run(1),\n turnId: ids.turn(1),\n });\n log.append(\"TurnStopped\", { runId: ids.run(1), turnId: ids.turn(1), reason: \"stop\" });\n log.append(\"ContextProjected\", { contextVersion: 0, throughSeq: log.events.length });\n log.append(\"BaseStateRequested\", { baseStateId: ids.event(902), requestedThroughSeq: 1 });\n log.append(\"BaseStateCreated\", { baseStateId: ids.event(902), coversThroughSeq: 1 });\n log.append(\"BaseStateFailed\", { baseStateId: ids.event(903), error: { message: \"x\" } });\n log.append(\"CompactionRequested\", {\n compactionId: ids.compaction(9),\n sourceFromSeq: 1,\n sourceToSeq: 2,\n });\n log.append(\"CompactionStarted\", { compactionId: ids.compaction(9) });\n log.append(\"CompactionFailed\", { compactionId: ids.compaction(9), error: { message: \"no\" } });\n log.append(\"RunInterrupted\", { runId: ids.run(1), reason: \"legacy stop\" });\n log.append(\"CommandFailed\", { commandId: ids.command(1), error: { message: \"x\" } });\n return log;\n};\n\nconst legacyAttempts = () => {\n const log = new TestLog().configure();\n log.submit({ command: 1, message: 1, text: \"legacy\" });\n log.startRun({ run: 1, commands: [1] });\n log.turn({ run: 1, turn: 1, inputs: [1] });\n log.append(\"TurnAttemptStarted\", {\n runId: ids.run(1),\n turnId: ids.turn(1),\n attemptId: ids.inference(1),\n });\n log.append(\"AssistantMessageCommitted\", {\n messageId: ids.message(101),\n runId: ids.run(1),\n turnId: ids.turn(1),\n attemptId: ids.inference(1),\n promptParts: [\n { type: \"text\", text: \"legacy answer\" },\n { type: \"tool-call\", id: \"call_1\", name: \"search\", params: {}, providerExecuted: false },\n ],\n });\n log.append(\"ToolCallCreated\", {\n runId: ids.run(1),\n turnId: ids.turn(1),\n attemptId: ids.inference(1),\n toolCallId: ids.tool(1),\n promptPart: {\n type: \"tool-call\",\n id: \"call_1\",\n name: \"search\",\n params: {},\n providerExecuted: false,\n },\n });\n log.append(\"TurnAttemptCompleted\", {\n runId: ids.run(1),\n turnId: ids.turn(1),\n attemptId: ids.inference(1),\n usage: { inputTokens: 3, outputTokens: 4 },\n });\n log.toolStarted(1);\n log.toolCompleted({ tool: 1, providerId: \"call_1\", name: \"search\" });\n log.turnCompleted({ run: 1, turn: 1 });\n return log.runCompleted(1, [1]);\n};\n\nconst failuresAndRepeatedCompletion = () => {\n const log = new TestLog().configure();\n // An interrupt submission whose start fails never becomes a message: it is withdrawn.\n log.admitOnly({ command: 1, text: \"stop and do this\" });\n log.append(\"CommandStarted\", { commandId: ids.command(1) });\n log.append(\"CommandFailed\", { commandId: ids.command(1), error: { message: \"start failed\" } });\n log.submit({ command: 2, message: 2, text: \"next\" });\n log.startRun({ run: 1, commands: [2] });\n log.assistantTurn({ run: 1, turn: 1, inference: 1, message: 101, text: \"ok\", inputs: [2] });\n log.compaction({\n compaction: 1,\n summary: 1,\n retainedFromContextSeq: log.events.length,\n contextVersion: 1,\n });\n // A repeated completion adds no usage, as in the reduced state.\n log.append(\"CompactionCompleted\", {\n compactionId: ids.compaction(1),\n modelSelection: { provider: \"test\", modelId: \"model-a\" },\n usage: { inputTokens: 100, outputTokens: 20 },\n });\n return log.runCompleted(1, [2]);\n};\n\nconst oneTurnConsumesSeveral = () => {\n // A queued message is promoted after steering arrives; the turn lists the steering first, but the\n // prompt (and so the transcript) orders the submissions as they were submitted.\n const log = new TestLog().configure();\n log.submit({ command: 1, message: 1, text: \"first\" });\n log.submit({ command: 2, message: 2, text: \"queued\" });\n log.startRun({ run: 1, commands: [1] });\n log.steer({ command: 3, message: 3, run: 1, text: \"steering\" });\n log.append(\"UserMessagePromoted\", {\n commandId: ids.command(9),\n messageId: ids.message(2),\n from: \"queue\",\n to: \"steer\",\n });\n log.assistantTurn({\n run: 1,\n turn: 1,\n inference: 1,\n message: 101,\n text: \"all three\",\n inputs: [1, 3, 2],\n });\n return log.runCompleted(1, [1]);\n};\n\nconst oneTurnConsumesSeveralSubmitted = () => {\n // The same tie with today's runtime shapes: steering arrives as a steer-disposition submission.\n const log = new TestLog().configure();\n log.submit({ command: 1, message: 1, text: \"first\" });\n log.submit({ command: 2, message: 2, text: \"queued\" });\n log.startRun({ run: 1, commands: [1] });\n log.submit({ command: 3, message: 3, text: \"steering\", disposition: \"steer\" });\n log.append(\"UserMessagePromoted\", {\n commandId: ids.command(9),\n messageId: ids.message(2),\n from: \"queue\",\n to: \"steer\",\n });\n log.assistantTurn({\n run: 1,\n turn: 1,\n inference: 1,\n message: 101,\n text: \"all three\",\n inputs: [1, 3, 2],\n });\n return log.runCompleted(1, [1]);\n};\n\nconst scenario = (name: string, compacted: boolean, build: () => TestLog): TranscriptScenario => ({\n name,\n compacted,\n events: build().events,\n});\n\n/** Build the corpus. Logs are deterministic: ids, timestamps and traces are fixed. */\nexport const transcriptScenarios = (): ReadonlyArray<TranscriptScenario> => [\n scenario(\"queue-run-tools\", false, queueRunTools),\n scenario(\"legacy-committed-user\", false, legacyCommitted),\n scenario(\"steering\", false, steering),\n scenario(\"promote-pause-cancel\", false, promotePauseCancel),\n scenario(\"partial-failure-empty-success-import\", false, partialEmptyImport),\n scenario(\"rejected-tool-repeated-terminals\", false, rejectedAndRepeatedTerminals),\n scenario(\"recovery-continuation\", false, recovery),\n scenario(\"mid-run-compaction\", true, midRunCompaction),\n scenario(\"replacement-message-id\", true, replacementMessageId),\n scenario(\"host-decorations\", false, decorations),\n scenario(\"events-without-transcript-meaning\", false, ignoredEvents),\n scenario(\"legacy-attempts\", false, legacyAttempts),\n scenario(\"failed-interrupt-repeated-compaction-completion\", true, failuresAndRepeatedCompletion),\n scenario(\"one-turn-consumes-several\", false, oneTurnConsumesSeveral),\n scenario(\"one-turn-consumes-several-submitted\", false, oneTurnConsumesSeveralSubmitted),\n];\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,MAAM,eAAe,oBAAoB;CACvC,SAAS;CACT,QAAQ;AACV,CAAC;;AAED,MAAa,iBAAiB;CAAE,MAAM;CAAc,OAAO,CAAC;AAAE;AAC9D,MAAM,WAAW;CAAE,MAAM;CAAc,OAAO,CAAC;AAAE;;AAGjD,MAAa,UAAU,OAAe,SACpC,kBAAkB,MAAM,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,KAAK,QAAQ,GAAA,CAAI,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,IACnG,OACA,KAAK,GAAA,CAEJ,SAAS,EAAE,CAAC,CACZ,SAAS,IAAI,GAAG;AAErB,MAAa,MAAM;CACjB,UAAU,SAAiB,OAAO,KAAO,IAA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AAO,IAAI,aAAa,GAAG,CAAC,CAAC,CAAC;AAChC;AAEA,MAAM,YAAY,MAAc,WAAoB,WAA8C;CAChG;CACA;CACA,QAAQ,MAAM,CAAC,CAAC;AAClB;;AAGA,MAAa,4BAA+D;CAC1E,SAAS,mBAAmB,OAAO,aAAa;CAChD,SAAS,yBAAyB,OAAO,eAAe;CACxD,SAAS,YAAY,OAAO,QAAQ;CACpC,SAAS,wBAAwB,OAAO,kBAAkB;CAC1D,SAAS,wCAAwC,OAAO,kBAAkB;CAC1E,SAAS,oCAAoC,OAAO,4BAA4B;CAChF,SAAS,yBAAyB,OAAO,QAAQ;CACjD,SAAS,sBAAsB,MAAM,gBAAgB;CACrD,SAAS,0BAA0B,MAAM,oBAAoB;CAC7D,SAAS,oBAAoB,OAAO,WAAW;CAC/C,SAAS,qCAAqC,OAAO,aAAa;CAClE,SAAS,mBAAmB,OAAO,cAAc;CACjD,SAAS,mDAAmD,MAAM,6BAA6B;CAC/F,SAAS,6BAA6B,OAAO,sBAAsB;CACnE,SAAS,uCAAuC,OAAO,+BAA+B;AACxF"}
@@ -1,69 +1,10 @@
1
1
  import { b as TurnId, h as SequenceNumber, l as InferenceId } from "./core-BcimKMIv.js";
2
2
  import { f as PositionedEvent } from "./envelope-Che6KatU.js";
3
3
  import "./events-BWuvzVml.js";
4
- import { $ as TranscriptAssistantPart, A as TranscriptDefinition, At as TranscriptToolRecord, B as makeTranscriptDefinition, Bt as transcriptDecorationBufferLimit, C as TranscriptVersionMeta, Ct as TranscriptRecordView, D as TranscriptWindowSelector, Dt as TranscriptRunOutcome, E as TranscriptWindowLimits, Et as TranscriptRunMember, F as TranscriptMappingOperation, Ft as TranscriptVersion, G as DecorationBufferRecordId, H as AssistantRecordId, Ht as transcriptRecordId, I as TranscriptMappingTarget, It as UserRecordId, J as PendingTranscriptUserRecord, K as ImportAssistantRecordId, L as TranscriptMappings, Lt as isPendingTranscriptUserRecord, M as TranscriptListEntryKey, Mt as TranscriptUnknownRecord, N as TranscriptMappedEvent, Nt as TranscriptUserRecord, O as defaultTranscriptWindowLimits, Ot as TranscriptSessionContextRecord, P as TranscriptMapping, Pt as TranscriptUserState, Q as TranscriptAssistantLifecycle, R as TranscriptUserFallback, Rt as isTopLevelTranscriptRecord, S as TranscriptReadiness, St as TranscriptRecordKind, T as TranscriptWindow, Tt as TranscriptRunGroupRecord, U as CompactionRecordId, Ut as transcriptStoredInlineBodyLimit, V as transcriptMappingBounds, Vt as transcriptRecordEnvelopeFormat, W as ConsumedTranscriptUserRecord, X as SessionContextRecordId, Y as RunGroupRecordId, Z as ToolRecordId, _ as EDATranscriptStoreShape, _t as TranscriptPosition, at as TranscriptCompactionRecord, b as TranscriptActiveContent, bt as TranscriptRecordFromEnvelope, ct as TranscriptDecorationBufferRecord, dt as TranscriptDecorationKey, et as TranscriptAssistantRecord, ft as TranscriptDecorations, g as EDATranscriptStore, gt as TranscriptOrderKey, ht as TranscriptOrder, it as TranscriptClassification, j as TranscriptDefinitionError, jt as TranscriptTopLevelRecord, k as transcriptCursorOf, kt as TranscriptToolLifecycle, lt as TranscriptDecorationEntryId, mt as TranscriptLogIncarnation, nt as TranscriptBodySource, ot as TranscriptCursor, pt as TranscriptFieldPath, q as InferenceAssistantRecordId, rt as TranscriptBufferedDecoration, st as TranscriptDecoration, t as CommittedDurableEvent, tt as TranscriptBody, ut as TranscriptDecorationEntryKey, v as TranscriptCursorMismatch, vt as TranscriptRecord, w as TranscriptVersionStatus, wt as TranscriptRecordViewFromEnvelope, x as TranscriptActivePart, xt as TranscriptRecordId, y as TranscriptMaintenanceConfig, yt as TranscriptRecordEnvelope, z as emptyTranscriptMappings, zt as runGroupStatus } from "./session-store-CWYZ29CV.js";
4
+ import { $ as TranscriptAssistantPart, A as TranscriptDefinition, At as TranscriptToolRecord, B as makeTranscriptDefinition, Bt as transcriptDecorationBufferLimit, C as TranscriptVersionMeta, Ct as TranscriptRecordView, D as TranscriptWindowSelector, Dt as TranscriptRunOutcome, E as TranscriptWindowLimits, Et as TranscriptRunMember, F as TranscriptMappingOperation, Ft as TranscriptVersion, G as DecorationBufferRecordId, H as AssistantRecordId, Ht as transcriptRecordId, I as TranscriptMappingTarget, It as UserRecordId, J as PendingTranscriptUserRecord, K as ImportAssistantRecordId, L as TranscriptMappings, Lt as isPendingTranscriptUserRecord, M as TranscriptListEntryKey, Mt as TranscriptUnknownRecord, N as TranscriptMappedEvent, Nt as TranscriptUserRecord, O as defaultTranscriptWindowLimits, Ot as TranscriptSessionContextRecord, P as TranscriptMapping, Pt as TranscriptUserState, Q as TranscriptAssistantLifecycle, R as TranscriptUserFallback, Rt as isTopLevelTranscriptRecord, S as TranscriptReadiness, St as TranscriptRecordKind, T as TranscriptWindow, Tt as TranscriptRunGroupRecord, U as CompactionRecordId, Ut as transcriptStoredInlineBodyLimit, V as transcriptMappingBounds, Vt as transcriptRecordEnvelopeFormat, W as ConsumedTranscriptUserRecord, X as SessionContextRecordId, Y as RunGroupRecordId, Z as ToolRecordId, _ as EDATranscriptStoreShape, _t as TranscriptPosition, at as TranscriptCompactionRecord, b as TranscriptActiveContent, bt as TranscriptRecordFromEnvelope, ct as TranscriptDecorationBufferRecord, dt as TranscriptDecorationKey, et as TranscriptAssistantRecord, ft as TranscriptDecorations, g as EDATranscriptStore, gt as TranscriptOrderKey, ht as TranscriptOrder, it as TranscriptClassification, j as TranscriptDefinitionError, jt as TranscriptTopLevelRecord, k as transcriptCursorOf, kt as TranscriptToolLifecycle, lt as TranscriptDecorationEntryId, mt as TranscriptLogIncarnation, nt as TranscriptBodySource, ot as TranscriptCursor, pt as TranscriptFieldPath, q as InferenceAssistantRecordId, rt as TranscriptBufferedDecoration, st as TranscriptDecoration, tt as TranscriptBody, ut as TranscriptDecorationEntryKey, v as TranscriptCursorMismatch, vt as TranscriptRecord, w as TranscriptVersionStatus, wt as TranscriptRecordViewFromEnvelope, x as TranscriptActivePart, xt as TranscriptRecordId, y as TranscriptMaintenanceConfig, yt as TranscriptRecordEnvelope, z as emptyTranscriptMappings, zt as runGroupStatus } from "./session-store-CWYZ29CV.js";
5
+ import { a as PlanTranscriptBatch, c as TranscriptChangePlan, i as transcriptReadiness, l as TranscriptLookup, n as buildingTranscriptWindow, o as TranscriptAlias, r as readTranscriptWindowFrom, s as TranscriptAliasNamespace, t as TranscriptWindowSource, u as TranscriptProjectionError } from "./window-read-DBf1Iktt.js";
5
6
  import { a as TranscriptSubscriptionRead, c as defaultTranscriptSubscriptionPolicy, d as transcriptCoverageOf, f as transcriptSubscriptionBaseOf, i as TranscriptSubscriptionPolicy, l as planTranscriptUpdate, n as TranscriptRequestId, o as TranscriptSubscriptionRequest, r as TranscriptSubscriptionBase, s as TranscriptUpdate, t as TranscriptCoverage, u as readTranscriptSubscription } from "./subscription-DelB8L87.js";
6
7
  import * as Schema from "effect/Schema";
7
- import * as Result from "effect/Result";
8
- //#region src/transcript/plan.d.ts
9
- /**
10
- * Secondary keys that resolve to a record through an indexed join, never an in-memory map.
11
- *
12
- * - `messageId`: every message id a user submission has carried, including replacement ids.
13
- * - `idempotencyKey`: a submitting command's caller-owned retry key.
14
- * - `runId`: every run of a run group, so continuations resolve to the root's group.
15
- * - `runCommand`: commands owned by a run group; a run that reuses them continues the group.
16
- * - `toolPart`: `<inferenceId>/<providerPartId>`, linking an assistant tool-call part to its tool.
17
- */
18
- declare const TranscriptAliasNamespace: Schema.Literals<readonly ["messageId", "idempotencyKey", "runId", "runCommand", "toolPart"]>;
19
- type TranscriptAliasNamespace = typeof TranscriptAliasNamespace.Type;
20
- /** One alias row: `(namespace, key)` resolves to `recordId` within one version. */
21
- interface TranscriptAlias {
22
- readonly namespace: TranscriptAliasNamespace;
23
- readonly key: string;
24
- readonly recordId: TranscriptRecordId;
25
- }
26
- /**
27
- * Synchronous indexed reads of one transcript version, as committed before the batch.
28
- *
29
- * Adapters back this with indexed storage reads so the interpreter can run inside a synchronous
30
- * transaction (Cloudflare `storage.transactionSync`). Reads see no uncommitted plan; the
31
- * interpreter overlays its own in-batch changes.
32
- */
33
- interface TranscriptLookup {
34
- /** Last seq already projected into this version. Events at or below it are skipped. */
35
- readonly cursor: SequenceNumber;
36
- readonly record: (id: TranscriptRecordId) => TranscriptRecord | undefined;
37
- readonly alias: (namespace: TranscriptAliasNamespace, key: string) => TranscriptRecordId | undefined;
38
- /** Next free ordinal among records positioned at `anchorSeq`; 0 when none are. */
39
- readonly nextOrdinal: (anchorSeq: SequenceNumber) => number;
40
- }
41
- /**
42
- * Deterministic changes for one committed batch: the final state of every record the batch
43
- * touched, in first-touch order, the aliases it introduced, and the new cursor.
44
- *
45
- * There are no deletions. Aliases are inserts only: an alias never moves to another record.
46
- * Applying the plan and advancing the cursor must commit atomically with each other.
47
- */
48
- interface TranscriptChangePlan {
49
- readonly records: ReadonlyArray<TranscriptRecord>;
50
- readonly aliases: ReadonlyArray<TranscriptAlias>;
51
- readonly throughSeq: SequenceNumber;
52
- }
53
- /**
54
- * The interpretation boundary: a pure, synchronous function from a lookup, committed events and
55
- * a definition to a change plan.
56
- *
57
- * It throws `TranscriptProjectionError` when the stored projection is inconsistent with the log.
58
- * The adapter treats any throw as a recoverable projection failure of that version only.
59
- */
60
- type PlanTranscriptBatch = (lookup: TranscriptLookup, committed: ReadonlyArray<CommittedDurableEvent>, definition: TranscriptDefinition) => TranscriptChangePlan;
61
- declare const TranscriptProjectionError_base: Schema.Class<TranscriptProjectionError, Schema.TaggedStruct<"TranscriptProjectionError", {
62
- readonly message: Schema.String;
63
- }>, import("effect/Cause").YieldableError>;
64
- /** The stored projection cannot be advanced from the given lookup and batch. */
65
- declare class TranscriptProjectionError extends TranscriptProjectionError_base {}
66
- //#endregion
67
8
  //#region src/transcript/interpreter.d.ts
68
9
  /**
69
10
  * Interpret one committed batch into a transcript change plan.
@@ -100,45 +41,6 @@ declare const canonicalJson: (value: unknown) => string;
100
41
  /** Transcript version for a semantic revision and already-encoded canonical mapping data. */
101
42
  declare const computeTranscriptVersion: (semanticRevision: number, encodedMappings: unknown) => TranscriptVersion;
102
43
  //#endregion
103
- //#region src/transcript/window-read.d.ts
104
- /**
105
- * Synchronous indexed reads of the served version at one cut, as a store provides them.
106
- *
107
- * Window assembly (paging, dependency collection, byte budgeting and body references) is shared
108
- * by every store through `readTranscriptWindowFrom`; a store only supplies these reads.
109
- */
110
- interface TranscriptWindowSource {
111
- readonly incarnation: TranscriptLogIncarnation;
112
- /** Maintenance state of the served (active) version; its cursor is the window's `throughSeq`. */
113
- readonly meta: TranscriptVersionMeta;
114
- /** False when this release no longer carries the served version (a missed session). */
115
- readonly carried: boolean;
116
- /** Top-level records before `key` (or before the end), newest first. */
117
- readonly topLevelBefore: (key: TranscriptOrderKey | undefined, limit: number, inclusive: boolean) => ReadonlyArray<TranscriptTopLevelRecord>;
118
- /** Top-level records after `key` (or after the start), oldest first. */
119
- readonly topLevelAfter: (key: TranscriptOrderKey | undefined, limit: number, inclusive: boolean) => ReadonlyArray<TranscriptTopLevelRecord>;
120
- readonly record: (id: TranscriptRecordId) => TranscriptRecord | undefined;
121
- readonly alias: (namespace: TranscriptAliasNamespace, key: string) => TranscriptRecordId | undefined;
122
- /** Tool records of one assistant (the typed dependency lookup). */
123
- readonly toolsOf: (assistantId: AssistantRecordId) => ReadonlyArray<TranscriptToolRecord>;
124
- /** Every user record still waiting for the agent (the pending-membership index). */
125
- readonly pendingUsers: () => ReadonlyArray<TranscriptUserRecord>;
126
- }
127
- /** Readiness of a served version: why its cut may be behind the log. */
128
- declare const transcriptReadiness: (meta: TranscriptVersionMeta, carried: boolean) => TranscriptReadiness;
129
- /** The empty window served while no version is servable yet. */
130
- declare const buildingTranscriptWindow: (incarnation: TranscriptLogIncarnation, version: TranscriptVersion) => TranscriptWindow;
131
- /**
132
- * Assemble one window from a source at a single cut.
133
- *
134
- * The response never contains anything newer than the served version's cursor: a frozen (failed
135
- * or no longer carried) version's rows, pending users and session context all stop at its last
136
- * good cut, which is the degraded-read rule. Bodies above the inline limit become references;
137
- * if the response still exceeds the byte budget, records are dropped from the far end of the
138
- * selection, keeping at least one so paging always progresses.
139
- */
140
- declare const readTranscriptWindowFrom: (source: TranscriptWindowSource, selector: TranscriptWindowSelector, limits: TranscriptWindowLimits) => Result.Result<TranscriptWindow, TranscriptCursorMismatch>;
141
- //#endregion
142
44
  //#region src/transcript/active-content.d.ts
143
45
  /**
144
46
  * The accumulated value of the inference streaming now, folded from the published live stream.
@@ -173,5 +75,27 @@ declare const foldTranscriptActiveContent: (state: TranscriptActiveContentState,
173
75
  /** The active content to serve, in the window's shape; empty when nothing is streaming. */
174
76
  declare const transcriptActiveContentOf: (state: TranscriptActiveContentState) => ReadonlyArray<TranscriptActiveContent>;
175
77
  //#endregion
176
- export { AssistantRecordId, CompactionRecordId, ConsumedTranscriptUserRecord, DecorationBufferRecordId, EDATranscriptStore, EDATranscriptStoreShape, ImportAssistantRecordId, InferenceAssistantRecordId, PendingTranscriptUserRecord, PlanTranscriptBatch, RunGroupRecordId, SessionContextRecordId, ToolRecordId, TranscriptActiveContent, TranscriptActiveContentState, TranscriptActivePart, TranscriptAlias, TranscriptAliasNamespace, TranscriptAssistantLifecycle, TranscriptAssistantPart, TranscriptAssistantRecord, TranscriptBody, TranscriptBodySource, TranscriptBufferedDecoration, TranscriptChangePlan, TranscriptClassification, TranscriptCompactionRecord, TranscriptCoverage, TranscriptCursor, TranscriptCursorMismatch, TranscriptDecoration, TranscriptDecorationBufferRecord, TranscriptDecorationEntryId, TranscriptDecorationEntryKey, TranscriptDecorationKey, TranscriptDecorations, TranscriptDefinition, TranscriptDefinitionError, TranscriptFieldPath, TranscriptListEntryKey, TranscriptLogIncarnation, TranscriptLookup, TranscriptMaintenanceConfig, TranscriptMappedEvent, TranscriptMapping, TranscriptMappingOperation, TranscriptMappingTarget, TranscriptMappings, TranscriptOrder, TranscriptOrderKey, TranscriptPosition, TranscriptProjectionError, TranscriptReadiness, TranscriptRecord, TranscriptRecordEnvelope, TranscriptRecordFromEnvelope, TranscriptRecordId, TranscriptRecordKind, TranscriptRecordView, TranscriptRecordViewFromEnvelope, TranscriptRequestId, TranscriptRunGroupRecord, TranscriptRunMember, TranscriptRunOutcome, TranscriptSessionContextRecord, TranscriptSubscriptionBase, TranscriptSubscriptionPolicy, TranscriptSubscriptionRead, TranscriptSubscriptionRequest, TranscriptToolLifecycle, TranscriptToolRecord, TranscriptTopLevelRecord, TranscriptUnknownRecord, TranscriptUpdate, TranscriptUserFallback, TranscriptUserRecord, TranscriptUserState, TranscriptVersion, TranscriptVersionMeta, TranscriptVersionStatus, TranscriptWindow, TranscriptWindowLimits, TranscriptWindowSelector, type TranscriptWindowSource, UserRecordId, buildingTranscriptWindow, canonicalJson, computeTranscriptVersion, defaultTranscriptSubscriptionPolicy, defaultTranscriptWindowLimits, emptyTranscriptActiveContentState, emptyTranscriptMappings, foldTranscriptActiveContent, isPendingTranscriptUserRecord, isTopLevelTranscriptRecord, makeTranscriptDefinition, planTranscriptBatch, planTranscriptUpdate, readTranscriptSubscription, readTranscriptWindowFrom, runGroupStatus, transcriptActiveContentOf, transcriptCoverageOf, transcriptCursorOf, transcriptDecorationBufferLimit, transcriptMappingBounds, transcriptReadiness, transcriptRecordEnvelopeFormat, transcriptRecordId, transcriptSemanticRevision, transcriptStoredInlineBodyLimit, transcriptSubscriptionBaseOf };
78
+ //#region src/transcript/body.d.ts
79
+ /** The committed-event fields that decide where its bodies are. */
80
+ interface TranscriptBodyEvent {
81
+ readonly namespace: string;
82
+ readonly type: string;
83
+ readonly payload: unknown;
84
+ }
85
+ /** A resolved body: the JSON the interpreter inlined there, or why there is none. */
86
+ type ResolvedTranscriptBody = {
87
+ readonly _tag: "Found";
88
+ readonly value: Schema.Json;
89
+ } | {
90
+ readonly _tag: "Missing";
91
+ readonly message: string;
92
+ };
93
+ /**
94
+ * Resolve a body reference against the committed event it names: the read side of the
95
+ * interpreter's body rule. Resolving through the log keeps a `Ref` valid after projection rows are
96
+ * rebuilt or deleted; any path that is not a body site resolves to nothing.
97
+ */
98
+ declare const resolveTranscriptBody: (event: TranscriptBodyEvent, path: TranscriptFieldPath) => ResolvedTranscriptBody;
99
+ //#endregion
100
+ export { AssistantRecordId, CompactionRecordId, ConsumedTranscriptUserRecord, DecorationBufferRecordId, EDATranscriptStore, EDATranscriptStoreShape, ImportAssistantRecordId, InferenceAssistantRecordId, PendingTranscriptUserRecord, PlanTranscriptBatch, type ResolvedTranscriptBody, RunGroupRecordId, SessionContextRecordId, ToolRecordId, TranscriptActiveContent, TranscriptActiveContentState, TranscriptActivePart, TranscriptAlias, TranscriptAliasNamespace, TranscriptAssistantLifecycle, TranscriptAssistantPart, TranscriptAssistantRecord, TranscriptBody, TranscriptBodySource, TranscriptBufferedDecoration, TranscriptChangePlan, TranscriptClassification, TranscriptCompactionRecord, TranscriptCoverage, TranscriptCursor, TranscriptCursorMismatch, TranscriptDecoration, TranscriptDecorationBufferRecord, TranscriptDecorationEntryId, TranscriptDecorationEntryKey, TranscriptDecorationKey, TranscriptDecorations, TranscriptDefinition, TranscriptDefinitionError, TranscriptFieldPath, TranscriptListEntryKey, TranscriptLogIncarnation, TranscriptLookup, TranscriptMaintenanceConfig, TranscriptMappedEvent, TranscriptMapping, TranscriptMappingOperation, TranscriptMappingTarget, TranscriptMappings, TranscriptOrder, TranscriptOrderKey, TranscriptPosition, TranscriptProjectionError, TranscriptReadiness, TranscriptRecord, TranscriptRecordEnvelope, TranscriptRecordFromEnvelope, TranscriptRecordId, TranscriptRecordKind, TranscriptRecordView, TranscriptRecordViewFromEnvelope, TranscriptRequestId, TranscriptRunGroupRecord, TranscriptRunMember, TranscriptRunOutcome, TranscriptSessionContextRecord, TranscriptSubscriptionBase, TranscriptSubscriptionPolicy, TranscriptSubscriptionRead, TranscriptSubscriptionRequest, TranscriptToolLifecycle, TranscriptToolRecord, TranscriptTopLevelRecord, TranscriptUnknownRecord, TranscriptUpdate, TranscriptUserFallback, TranscriptUserRecord, TranscriptUserState, TranscriptVersion, TranscriptVersionMeta, TranscriptVersionStatus, TranscriptWindow, TranscriptWindowLimits, TranscriptWindowSelector, type TranscriptWindowSource, UserRecordId, buildingTranscriptWindow, canonicalJson, computeTranscriptVersion, defaultTranscriptSubscriptionPolicy, defaultTranscriptWindowLimits, emptyTranscriptActiveContentState, emptyTranscriptMappings, foldTranscriptActiveContent, isPendingTranscriptUserRecord, isTopLevelTranscriptRecord, makeTranscriptDefinition, planTranscriptBatch, planTranscriptUpdate, readTranscriptSubscription, readTranscriptWindowFrom, resolveTranscriptBody, runGroupStatus, transcriptActiveContentOf, transcriptCoverageOf, transcriptCursorOf, transcriptDecorationBufferLimit, transcriptMappingBounds, transcriptReadiness, transcriptRecordEnvelopeFormat, transcriptRecordId, transcriptSemanticRevision, transcriptStoredInlineBodyLimit, transcriptSubscriptionBaseOf };
177
101
  //# sourceMappingURL=transcript.d.ts.map
@@ -1,9 +1,10 @@
1
1
  import { SequenceNumber } from "./types/core.js";
2
2
  import { G as InferenceCompletedEvent, J as InferenceFailedEvent, X as InferenceStartedEvent, cn as TurnCompletedEvent, dn as TurnFailedEvent, hn as TurnStoppedEvent } from "./durable-CD__3ztN.js";
3
3
  import { ReasoningDeltaEvent, TextDeltaEvent, ToolParamsDeltaEvent, ToolParamsStartEvent } from "./types/events.js";
4
+ import { _ as computeTranscriptVersion, a as TranscriptDefinitionError, c as TranscriptMapping, d as TranscriptMappings, f as TranscriptUserFallback, g as canonicalJson, h as transcriptMappingBounds, i as TranscriptDefinition, l as TranscriptMappingOperation, m as makeTranscriptDefinition, n as TranscriptAliasNamespace, o as TranscriptListEntryKey, p as emptyTranscriptMappings, r as TranscriptProjectionError, s as TranscriptMappedEvent, t as planTranscriptBatch, u as TranscriptMappingTarget, v as transcriptSemanticRevision, y as resolveTranscriptBody } from "./interpreter-BdRoYrfL.js";
4
5
  import { A as TranscriptRecordFromEnvelope, B as TranscriptUserRecord, C as TranscriptDecorations, D as TranscriptPosition, E as TranscriptOrder, F as TranscriptRunOutcome, G as isTopLevelTranscriptRecord, H as TranscriptVersion, I as TranscriptSessionContextRecord, J as transcriptRecordEnvelopeFormat, K as runGroupStatus, L as TranscriptToolLifecycle, M as TranscriptRecordViewFromEnvelope, N as TranscriptRunGroupRecord, O as TranscriptRecord, P as TranscriptRunMember, R as TranscriptToolRecord, S as TranscriptDecorationKey, T as TranscriptLogIncarnation, U as UserRecordId, V as TranscriptUserState, W as isPendingTranscriptUserRecord, X as transcriptStoredInlineBodyLimit, Y as transcriptRecordId, _ as TranscriptCursor, a as InferenceAssistantRecordId, b as TranscriptDecorationEntryId, c as ToolRecordId, d as TranscriptAssistantRecord, f as TranscriptBody, g as TranscriptCompactionRecord, h as TranscriptClassification, i as ImportAssistantRecordId, j as TranscriptRecordId, k as TranscriptRecordEnvelope, l as TranscriptAssistantLifecycle, m as TranscriptBufferedDecoration, n as CompactionRecordId, o as RunGroupRecordId, p as TranscriptBodySource, q as transcriptDecorationBufferLimit, r as DecorationBufferRecordId, s as SessionContextRecordId, t as AssistantRecordId, u as TranscriptAssistantPart, v as TranscriptDecoration, w as TranscriptFieldPath, x as TranscriptDecorationEntryKey, y as TranscriptDecorationBufferRecord, z as TranscriptUnknownRecord } from "./records-DWKEjuqb.js";
5
- import { C as transcriptSemanticRevision, S as computeTranscriptVersion, _ as TranscriptUserFallback, a as TranscriptCursorMismatch, b as transcriptMappingBounds, c as TranscriptProjectionError, d as TranscriptListEntryKey, f as TranscriptMappedEvent, g as TranscriptMappings, h as TranscriptMappingTarget, i as EDATranscriptStore, l as TranscriptDefinition, m as TranscriptMappingOperation, n as readTranscriptWindowFrom, o as planTranscriptBatch, p as TranscriptMapping, r as transcriptReadiness, s as TranscriptAliasNamespace, t as buildingTranscriptWindow, u as TranscriptDefinitionError, v as emptyTranscriptMappings, x as canonicalJson, y as makeTranscriptDefinition } from "./window-read-BDayZf7O.js";
6
- import { _ as TranscriptWindowSelector, a as defaultTranscriptSubscriptionPolicy, c as transcriptCoverageOf, d as TranscriptActivePart, f as TranscriptReadiness, g as TranscriptWindowLimits, h as TranscriptWindow, i as TranscriptUpdate, l as transcriptSubscriptionBaseOf, m as TranscriptVersionStatus, n as TranscriptRequestId, o as planTranscriptUpdate, p as TranscriptVersionMeta, r as TranscriptSubscriptionBase, s as readTranscriptSubscription, t as TranscriptCoverage, u as TranscriptActiveContent, v as defaultTranscriptWindowLimits, y as transcriptCursorOf } from "./subscription-g5W0Ggqx.js";
6
+ import { a as TranscriptCursorMismatch, i as EDATranscriptStore, n as readTranscriptWindowFrom, r as transcriptReadiness, t as buildingTranscriptWindow } from "./window-read-U55aAeuz.js";
7
+ import { _ as TranscriptWindowSelector, a as defaultTranscriptSubscriptionPolicy, c as transcriptCoverageOf, d as TranscriptActivePart, f as TranscriptReadiness, g as TranscriptWindowLimits, h as TranscriptWindow, i as TranscriptUpdate, l as transcriptSubscriptionBaseOf, m as TranscriptVersionStatus, n as TranscriptRequestId, o as planTranscriptUpdate, p as TranscriptVersionMeta, r as TranscriptSubscriptionBase, s as readTranscriptSubscription, t as TranscriptCoverage, u as TranscriptActiveContent, v as defaultTranscriptWindowLimits, y as transcriptCursorOf } from "./subscription-Dzr5LqPX.js";
7
8
  import * as Schema from "effect/Schema";
8
9
  //#region src/transcript/active-content.ts
9
10
  /** The accumulator before anything is published in this isolate. */
@@ -101,6 +102,6 @@ const transcriptActiveContentOf = (state) => state.inference === void 0 ? [] : [
101
102
  parts: state.inference.parts
102
103
  }];
103
104
  //#endregion
104
- export { AssistantRecordId, CompactionRecordId, DecorationBufferRecordId, EDATranscriptStore, ImportAssistantRecordId, InferenceAssistantRecordId, RunGroupRecordId, SessionContextRecordId, ToolRecordId, TranscriptActiveContent, TranscriptActivePart, TranscriptAliasNamespace, TranscriptAssistantLifecycle, TranscriptAssistantPart, TranscriptAssistantRecord, TranscriptBody, TranscriptBodySource, TranscriptBufferedDecoration, TranscriptClassification, TranscriptCompactionRecord, TranscriptCoverage, TranscriptCursor, TranscriptCursorMismatch, TranscriptDecoration, TranscriptDecorationBufferRecord, TranscriptDecorationEntryId, TranscriptDecorationEntryKey, TranscriptDecorationKey, TranscriptDecorations, TranscriptDefinition, TranscriptDefinitionError, TranscriptFieldPath, TranscriptListEntryKey, TranscriptLogIncarnation, TranscriptMappedEvent, TranscriptMapping, TranscriptMappingOperation, TranscriptMappingTarget, TranscriptMappings, TranscriptOrder, TranscriptPosition, TranscriptProjectionError, TranscriptReadiness, TranscriptRecord, TranscriptRecordEnvelope, TranscriptRecordFromEnvelope, TranscriptRecordId, TranscriptRecordViewFromEnvelope, TranscriptRequestId, TranscriptRunGroupRecord, TranscriptRunMember, TranscriptRunOutcome, TranscriptSessionContextRecord, TranscriptSubscriptionBase, TranscriptToolLifecycle, TranscriptToolRecord, TranscriptUnknownRecord, TranscriptUpdate, TranscriptUserFallback, TranscriptUserRecord, TranscriptUserState, TranscriptVersion, TranscriptVersionMeta, TranscriptVersionStatus, TranscriptWindow, TranscriptWindowLimits, TranscriptWindowSelector, UserRecordId, buildingTranscriptWindow, canonicalJson, computeTranscriptVersion, defaultTranscriptSubscriptionPolicy, defaultTranscriptWindowLimits, emptyTranscriptActiveContentState, emptyTranscriptMappings, foldTranscriptActiveContent, isPendingTranscriptUserRecord, isTopLevelTranscriptRecord, makeTranscriptDefinition, planTranscriptBatch, planTranscriptUpdate, readTranscriptSubscription, readTranscriptWindowFrom, runGroupStatus, transcriptActiveContentOf, transcriptCoverageOf, transcriptCursorOf, transcriptDecorationBufferLimit, transcriptMappingBounds, transcriptReadiness, transcriptRecordEnvelopeFormat, transcriptRecordId, transcriptSemanticRevision, transcriptStoredInlineBodyLimit, transcriptSubscriptionBaseOf };
105
+ export { AssistantRecordId, CompactionRecordId, DecorationBufferRecordId, EDATranscriptStore, ImportAssistantRecordId, InferenceAssistantRecordId, RunGroupRecordId, SessionContextRecordId, ToolRecordId, TranscriptActiveContent, TranscriptActivePart, TranscriptAliasNamespace, TranscriptAssistantLifecycle, TranscriptAssistantPart, TranscriptAssistantRecord, TranscriptBody, TranscriptBodySource, TranscriptBufferedDecoration, TranscriptClassification, TranscriptCompactionRecord, TranscriptCoverage, TranscriptCursor, TranscriptCursorMismatch, TranscriptDecoration, TranscriptDecorationBufferRecord, TranscriptDecorationEntryId, TranscriptDecorationEntryKey, TranscriptDecorationKey, TranscriptDecorations, TranscriptDefinition, TranscriptDefinitionError, TranscriptFieldPath, TranscriptListEntryKey, TranscriptLogIncarnation, TranscriptMappedEvent, TranscriptMapping, TranscriptMappingOperation, TranscriptMappingTarget, TranscriptMappings, TranscriptOrder, TranscriptPosition, TranscriptProjectionError, TranscriptReadiness, TranscriptRecord, TranscriptRecordEnvelope, TranscriptRecordFromEnvelope, TranscriptRecordId, TranscriptRecordViewFromEnvelope, TranscriptRequestId, TranscriptRunGroupRecord, TranscriptRunMember, TranscriptRunOutcome, TranscriptSessionContextRecord, TranscriptSubscriptionBase, TranscriptToolLifecycle, TranscriptToolRecord, TranscriptUnknownRecord, TranscriptUpdate, TranscriptUserFallback, TranscriptUserRecord, TranscriptUserState, TranscriptVersion, TranscriptVersionMeta, TranscriptVersionStatus, TranscriptWindow, TranscriptWindowLimits, TranscriptWindowSelector, UserRecordId, buildingTranscriptWindow, canonicalJson, computeTranscriptVersion, defaultTranscriptSubscriptionPolicy, defaultTranscriptWindowLimits, emptyTranscriptActiveContentState, emptyTranscriptMappings, foldTranscriptActiveContent, isPendingTranscriptUserRecord, isTopLevelTranscriptRecord, makeTranscriptDefinition, planTranscriptBatch, planTranscriptUpdate, readTranscriptSubscription, readTranscriptWindowFrom, resolveTranscriptBody, runGroupStatus, transcriptActiveContentOf, transcriptCoverageOf, transcriptCursorOf, transcriptDecorationBufferLimit, transcriptMappingBounds, transcriptReadiness, transcriptRecordEnvelopeFormat, transcriptRecordId, transcriptSemanticRevision, transcriptStoredInlineBodyLimit, transcriptSubscriptionBaseOf };
105
106
 
106
107
  //# sourceMappingURL=transcript.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transcript.js","names":[],"sources":["../src/transcript/active-content.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport { SequenceNumber, type InferenceId, type TurnId } from \"../types/core\";\nimport type { PositionedEvent } from \"../types/events\";\nimport {\n InferenceCompletedEvent,\n InferenceFailedEvent,\n InferenceStartedEvent,\n TurnCompletedEvent,\n TurnFailedEvent,\n TurnStoppedEvent,\n} from \"../types/events/durable\";\nimport {\n ReasoningDeltaEvent,\n TextDeltaEvent,\n ToolParamsDeltaEvent,\n ToolParamsStartEvent,\n} from \"../types/events/ephemeral\";\nimport { transcriptRecordId } from \"./records\";\nimport type { TranscriptActiveContent, TranscriptActivePart } from \"./window\";\n\n/**\n * The accumulated value of the inference streaming now, folded from the published live stream.\n *\n * Text and reasoning deltas carry only a `providerPartId`; they belong to the session's one\n * active inference, which is the latest `InferenceStarted` without a terminal. That association\n * is sound because `SessionState` publishes every durable and ephemeral event under one append\n * gate, in commit order: an inference's start is published before its first delta and its\n * terminal after its last. A session runs at most one inference at a time.\n *\n * The value is retired on every inference terminal (commit, partial plus failure, empty success\n * and recovery failure all end in `InferenceCompleted` or `InferenceFailed`), and on its turn's\n * terminal as a backstop. It is volatile: an isolate loss loses it, and recovery records the\n * inference as failed (design decision 6).\n */\nexport interface TranscriptActiveContentState {\n /** Highest durable seq this accumulator has folded; the publication side of the capture fence. */\n readonly publishedThroughSeq: SequenceNumber;\n /** Increases whenever the served active content changes; lets subscribers skip unchanged sends. */\n readonly revision: number;\n readonly inference: ActiveInference | undefined;\n}\n\ninterface ActiveInference {\n readonly inferenceId: InferenceId;\n readonly turnId: TurnId;\n readonly parts: ReadonlyArray<TranscriptActivePart>;\n}\n\n/** The accumulator before anything is published in this isolate. */\nexport const emptyTranscriptActiveContentState: TranscriptActiveContentState = {\n publishedThroughSeq: SequenceNumber.make(0),\n revision: 0,\n inference: undefined,\n};\n\nconst isInferenceStarted = Schema.is(InferenceStartedEvent);\nconst isInferenceCompleted = Schema.is(InferenceCompletedEvent);\nconst isInferenceFailed = Schema.is(InferenceFailedEvent);\nconst isTurnCompleted = Schema.is(TurnCompletedEvent);\nconst isTurnFailed = Schema.is(TurnFailedEvent);\nconst isTurnStopped = Schema.is(TurnStoppedEvent);\nconst isTextDelta = Schema.is(TextDeltaEvent);\nconst isReasoningDelta = Schema.is(ReasoningDeltaEvent);\nconst isToolParamsStart = Schema.is(ToolParamsStartEvent);\nconst isToolParamsDelta = Schema.is(ToolParamsDeltaEvent);\n\n/** Fold one published event, in publication order, into the active-content accumulator. */\nexport const foldTranscriptActiveContent = (\n state: TranscriptActiveContentState,\n positioned: PositionedEvent,\n): TranscriptActiveContentState => {\n const event = positioned.event;\n if (event.durability === \"durable\") {\n const published: TranscriptActiveContentState = {\n ...state,\n publishedThroughSeq: SequenceNumber.make(\n Math.max(state.publishedThroughSeq, positioned.position.seq),\n ),\n };\n if (isInferenceStarted(event)) {\n return withInference(published, {\n inferenceId: event.payload.inferenceId,\n turnId: event.payload.turnId,\n parts: [],\n });\n }\n const active = published.inference;\n if (active === undefined) return published;\n const retires =\n ((isInferenceCompleted(event) || isInferenceFailed(event)) &&\n event.payload.inferenceId === active.inferenceId) ||\n ((isTurnCompleted(event) || isTurnFailed(event) || isTurnStopped(event)) &&\n event.payload.turnId === active.turnId);\n return retires ? withInference(published, undefined) : published;\n }\n\n const active = state.inference;\n if (active === undefined) return state;\n if (isTextDelta(event)) {\n return appendText(\n state,\n active,\n \"Text\",\n `text:${event.payload.providerPartId}`,\n event.payload.delta,\n );\n }\n if (isReasoningDelta(event)) {\n return appendText(\n state,\n active,\n \"Reasoning\",\n `reasoning:${event.payload.providerPartId}`,\n event.payload.delta,\n );\n }\n if (isToolParamsStart(event)) {\n const id = `tool:${event.payload.toolCallId}`;\n if (active.parts.some((part) => part.id === id)) return state;\n return withInference(state, {\n ...active,\n parts: [\n ...active.parts,\n {\n id,\n part: {\n _tag: \"ToolCall\",\n providerPartId: event.payload.providerPartId,\n toolName: event.payload.toolName,\n providerExecuted: event.payload.providerExecuted,\n },\n paramsText: \"\",\n },\n ],\n });\n }\n if (isToolParamsDelta(event)) {\n const id = `tool:${event.payload.toolCallId}`;\n const delta = event.payload.delta;\n if (delta.length === 0 || !active.parts.some((part) => part.id === id)) return state;\n return withInference(state, {\n ...active,\n parts: active.parts.map((part) =>\n part.id === id ? { ...part, paramsText: (part.paramsText ?? \"\") + delta } : part,\n ),\n });\n }\n return state;\n};\n\nconst appendText = (\n state: TranscriptActiveContentState,\n active: ActiveInference,\n tag: \"Text\" | \"Reasoning\",\n id: string,\n delta: string,\n): TranscriptActiveContentState => {\n if (delta.length === 0) return state;\n const index = active.parts.findIndex((part) => part.id === id);\n const existing = index === -1 ? undefined : active.parts[index];\n const text =\n existing !== undefined && existing.part._tag === tag ? existing.part.text + delta : delta;\n const part: TranscriptActivePart = { id, part: { _tag: tag, text } };\n return withInference(state, {\n ...active,\n parts:\n index === -1\n ? [...active.parts, part]\n : active.parts.map((candidate, candidateIndex) =>\n candidateIndex === index ? part : candidate,\n ),\n });\n};\n\nconst withInference = (\n state: TranscriptActiveContentState,\n inference: ActiveInference | undefined,\n): TranscriptActiveContentState =>\n state.inference === undefined && inference === undefined\n ? state\n : { ...state, revision: state.revision + 1, inference };\n\n/** The active content to serve, in the window's shape; empty when nothing is streaming. */\nexport const transcriptActiveContentOf = (\n state: TranscriptActiveContentState,\n): ReadonlyArray<TranscriptActiveContent> =>\n state.inference === undefined\n ? []\n : [\n {\n assistantId: transcriptRecordId.assistant(state.inference.inferenceId),\n parts: state.inference.parts,\n },\n ];\n"],"mappings":";;;;;;;;;AAkDA,MAAa,oCAAkE;CAC7E,qBAAqB,eAAe,KAAK,CAAC;CAC1C,UAAU;CACV,WAAW,KAAA;AACb;AAEA,MAAM,qBAAqB,OAAO,GAAG,qBAAqB;AAC1D,MAAM,uBAAuB,OAAO,GAAG,uBAAuB;AAC9D,MAAM,oBAAoB,OAAO,GAAG,oBAAoB;AACxD,MAAM,kBAAkB,OAAO,GAAG,kBAAkB;AACpD,MAAM,eAAe,OAAO,GAAG,eAAe;AAC9C,MAAM,gBAAgB,OAAO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AAA,IAChB,CAAC,IACD,CACE;CACE,aAAa,mBAAmB,UAAU,MAAM,UAAU,WAAW;CACrE,OAAO,MAAM,UAAU;AACzB,CACF"}
1
+ {"version":3,"file":"transcript.js","names":[],"sources":["../src/transcript/active-content.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport { SequenceNumber, type InferenceId, type TurnId } from \"../types/core\";\nimport type { PositionedEvent } from \"../types/events\";\nimport {\n InferenceCompletedEvent,\n InferenceFailedEvent,\n InferenceStartedEvent,\n TurnCompletedEvent,\n TurnFailedEvent,\n TurnStoppedEvent,\n} from \"../types/events/durable\";\nimport {\n ReasoningDeltaEvent,\n TextDeltaEvent,\n ToolParamsDeltaEvent,\n ToolParamsStartEvent,\n} from \"../types/events/ephemeral\";\nimport { transcriptRecordId } from \"./records\";\nimport type { TranscriptActiveContent, TranscriptActivePart } from \"./window\";\n\n/**\n * The accumulated value of the inference streaming now, folded from the published live stream.\n *\n * Text and reasoning deltas carry only a `providerPartId`; they belong to the session's one\n * active inference, which is the latest `InferenceStarted` without a terminal. That association\n * is sound because `SessionState` publishes every durable and ephemeral event under one append\n * gate, in commit order: an inference's start is published before its first delta and its\n * terminal after its last. A session runs at most one inference at a time.\n *\n * The value is retired on every inference terminal (commit, partial plus failure, empty success\n * and recovery failure all end in `InferenceCompleted` or `InferenceFailed`), and on its turn's\n * terminal as a backstop. It is volatile: an isolate loss loses it, and recovery records the\n * inference as failed (design decision 6).\n */\nexport interface TranscriptActiveContentState {\n /** Highest durable seq this accumulator has folded; the publication side of the capture fence. */\n readonly publishedThroughSeq: SequenceNumber;\n /** Increases whenever the served active content changes; lets subscribers skip unchanged sends. */\n readonly revision: number;\n readonly inference: ActiveInference | undefined;\n}\n\ninterface ActiveInference {\n readonly inferenceId: InferenceId;\n readonly turnId: TurnId;\n readonly parts: ReadonlyArray<TranscriptActivePart>;\n}\n\n/** The accumulator before anything is published in this isolate. */\nexport const emptyTranscriptActiveContentState: TranscriptActiveContentState = {\n publishedThroughSeq: SequenceNumber.make(0),\n revision: 0,\n inference: undefined,\n};\n\nconst isInferenceStarted = Schema.is(InferenceStartedEvent);\nconst isInferenceCompleted = Schema.is(InferenceCompletedEvent);\nconst isInferenceFailed = Schema.is(InferenceFailedEvent);\nconst isTurnCompleted = Schema.is(TurnCompletedEvent);\nconst isTurnFailed = Schema.is(TurnFailedEvent);\nconst isTurnStopped = Schema.is(TurnStoppedEvent);\nconst isTextDelta = Schema.is(TextDeltaEvent);\nconst isReasoningDelta = Schema.is(ReasoningDeltaEvent);\nconst isToolParamsStart = Schema.is(ToolParamsStartEvent);\nconst isToolParamsDelta = Schema.is(ToolParamsDeltaEvent);\n\n/** Fold one published event, in publication order, into the active-content accumulator. */\nexport const foldTranscriptActiveContent = (\n state: TranscriptActiveContentState,\n positioned: PositionedEvent,\n): TranscriptActiveContentState => {\n const event = positioned.event;\n if (event.durability === \"durable\") {\n const published: TranscriptActiveContentState = {\n ...state,\n publishedThroughSeq: SequenceNumber.make(\n Math.max(state.publishedThroughSeq, positioned.position.seq),\n ),\n };\n if (isInferenceStarted(event)) {\n return withInference(published, {\n inferenceId: event.payload.inferenceId,\n turnId: event.payload.turnId,\n parts: [],\n });\n }\n const active = published.inference;\n if (active === undefined) return published;\n const retires =\n ((isInferenceCompleted(event) || isInferenceFailed(event)) &&\n event.payload.inferenceId === active.inferenceId) ||\n ((isTurnCompleted(event) || isTurnFailed(event) || isTurnStopped(event)) &&\n event.payload.turnId === active.turnId);\n return retires ? withInference(published, undefined) : published;\n }\n\n const active = state.inference;\n if (active === undefined) return state;\n if (isTextDelta(event)) {\n return appendText(\n state,\n active,\n \"Text\",\n `text:${event.payload.providerPartId}`,\n event.payload.delta,\n );\n }\n if (isReasoningDelta(event)) {\n return appendText(\n state,\n active,\n \"Reasoning\",\n `reasoning:${event.payload.providerPartId}`,\n event.payload.delta,\n );\n }\n if (isToolParamsStart(event)) {\n const id = `tool:${event.payload.toolCallId}`;\n if (active.parts.some((part) => part.id === id)) return state;\n return withInference(state, {\n ...active,\n parts: [\n ...active.parts,\n {\n id,\n part: {\n _tag: \"ToolCall\",\n providerPartId: event.payload.providerPartId,\n toolName: event.payload.toolName,\n providerExecuted: event.payload.providerExecuted,\n },\n paramsText: \"\",\n },\n ],\n });\n }\n if (isToolParamsDelta(event)) {\n const id = `tool:${event.payload.toolCallId}`;\n const delta = event.payload.delta;\n if (delta.length === 0 || !active.parts.some((part) => part.id === id)) return state;\n return withInference(state, {\n ...active,\n parts: active.parts.map((part) =>\n part.id === id ? { ...part, paramsText: (part.paramsText ?? \"\") + delta } : part,\n ),\n });\n }\n return state;\n};\n\nconst appendText = (\n state: TranscriptActiveContentState,\n active: ActiveInference,\n tag: \"Text\" | \"Reasoning\",\n id: string,\n delta: string,\n): TranscriptActiveContentState => {\n if (delta.length === 0) return state;\n const index = active.parts.findIndex((part) => part.id === id);\n const existing = index === -1 ? undefined : active.parts[index];\n const text =\n existing !== undefined && existing.part._tag === tag ? existing.part.text + delta : delta;\n const part: TranscriptActivePart = { id, part: { _tag: tag, text } };\n return withInference(state, {\n ...active,\n parts:\n index === -1\n ? [...active.parts, part]\n : active.parts.map((candidate, candidateIndex) =>\n candidateIndex === index ? part : candidate,\n ),\n });\n};\n\nconst withInference = (\n state: TranscriptActiveContentState,\n inference: ActiveInference | undefined,\n): TranscriptActiveContentState =>\n state.inference === undefined && inference === undefined\n ? state\n : { ...state, revision: state.revision + 1, inference };\n\n/** The active content to serve, in the window's shape; empty when nothing is streaming. */\nexport const transcriptActiveContentOf = (\n state: TranscriptActiveContentState,\n): ReadonlyArray<TranscriptActiveContent> =>\n state.inference === undefined\n ? []\n : [\n {\n assistantId: transcriptRecordId.assistant(state.inference.inferenceId),\n parts: state.inference.parts,\n },\n ];\n"],"mappings":";;;;;;;;;;AAkDA,MAAa,oCAAkE;CAC7E,qBAAqB,eAAe,KAAK,CAAC;CAC1C,UAAU;CACV,WAAW,KAAA;AACb;AAEA,MAAM,qBAAqB,OAAO,GAAG,q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,OAAO,SACpC;CACR,CAAC;AACH;AAEA,MAAM,iBACJ,OACA,cAEA,MAAM,cAAc,KAAA,KAAa,cAAc,KAAA,IAC3C,QACA;CAAE,GAAG;CAAO,UAAU,MAAM,WAAW;CAAG;AAAU;;AAG1D,MAAa,6BACX,UAEA,MAAM,cAAc,KAAA,IAChB,CAAC,IACD,CACE;CACE,aAAa,mBAAmB,UAAU,MAAM,UAAU,WAAW;CACrE,OAAO,MAAM,UAAU;AACzB,CACF"}
@@ -0,0 +1,2 @@
1
+ import { $ as EDAWebSocketWireProtocol, A as EDA_WS_CLOSE_LAGGED, B as EDAFrameworkWebSocketEvent, C as EDAWebSocketHelloFrame, D as EDAWebSocketServerFrame, E as EDAWebSocketPongFrame, F as SubscriberId, G as EDAWebSocketWireClientFrame, H as EDAWebSocketServerFrameEncoder, I as decodeEDAWebSocketClientMessage, J as EDAWebSocketWireHeartbeatFrame, K as EDAWebSocketWireErrorFrame, L as defaultEDAWebSocketFlowControl, M as EDA_WS_CLOSE_SEND_FAILED, N as EDA_WS_CLOSE_UNSUPPORTED_DATA, O as EDA_WEB_SOCKET_PROTOCOL_VERSION, P as FrameId, Q as EDAWebSocketWirePongFrame, R as encodeEDAWebSocketServerFrame, S as EDAWebSocketHeartbeatFrame, T as EDAWebSocketPingFrame, U as EDAWebSocketServerFrameInput, V as EDAWebSocketEventConsumerPolicy, W as EDAWebSocketWireAckFrame, X as EDAWebSocketWireLaggedFrame, Y as EDAWebSocketWireHelloFrame, Z as EDAWebSocketWirePingFrame, _ as EDAWebSocketAckFrame, a as EDAWebSocketInFlightFrame, b as EDAWebSocketEventsFrame, c as SubscriberLagReason, d as makeWebSocketDeliveryState, et as EDA_WEB_SOCKET_PING_MESSAGE, f as onClientAck, g as restoreWebSocketDeliveryState, h as onHostSuppressedFrame, i as EDAWebSocketDeliveryState, it as makeEDAWebSocketWireProtocol, j as EDA_WS_CLOSE_PROTOCOL_ERROR, k as EDA_WS_CLOSE_GOING_AWAY, l as checkpointWebSocketDeliveryState, m as onEphemeralEvent, n as EDAWebSocketDeliveryCheckpoint, nt as EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, o as EDAWebSocketSuppressedRange, p as onDurableEvents, q as EDAWebSocketWireFlowControl, r as EDAWebSocketDeliveryResult, rt as edaFrameworkWebSocketWireProtocol, s as MakeDeliveryStateInput, t as EDAWebSocketDeliveryAction, tt as EDA_WEB_SOCKET_PONG_MESSAGE, u as deliveryHelloFrame, v as EDAWebSocketClientFrame, w as EDAWebSocketLaggedFrame, x as EDAWebSocketFlowControl, y as EDAWebSocketErrorFrame, z as laggedCloseReason } from "../delivery-o6sDIiwO.js";
2
+ export { EDAFrameworkWebSocketEvent, EDAWebSocketAckFrame, EDAWebSocketClientFrame, EDAWebSocketDeliveryAction, EDAWebSocketDeliveryCheckpoint, EDAWebSocketDeliveryResult, EDAWebSocketDeliveryState, EDAWebSocketErrorFrame, EDAWebSocketEventConsumerPolicy, EDAWebSocketEventsFrame, EDAWebSocketFlowControl, EDAWebSocketHeartbeatFrame, EDAWebSocketHelloFrame, EDAWebSocketInFlightFrame, EDAWebSocketLaggedFrame, EDAWebSocketPingFrame, EDAWebSocketPongFrame, EDAWebSocketServerFrame, EDAWebSocketServerFrameEncoder, EDAWebSocketServerFrameInput, EDAWebSocketSuppressedRange, EDAWebSocketWireAckFrame, EDAWebSocketWireClientFrame, EDAWebSocketWireErrorFrame, EDAWebSocketWireFlowControl, EDAWebSocketWireHeartbeatFrame, EDAWebSocketWireHelloFrame, EDAWebSocketWireLaggedFrame, EDAWebSocketWirePingFrame, EDAWebSocketWirePongFrame, EDAWebSocketWireProtocol, EDA_WEB_SOCKET_PING_MESSAGE, EDA_WEB_SOCKET_PONG_MESSAGE, EDA_WEB_SOCKET_PROTOCOL_VERSION, EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, EDA_WS_CLOSE_GOING_AWAY, EDA_WS_CLOSE_LAGGED, EDA_WS_CLOSE_PROTOCOL_ERROR, EDA_WS_CLOSE_SEND_FAILED, EDA_WS_CLOSE_UNSUPPORTED_DATA, FrameId, MakeDeliveryStateInput, SubscriberId, SubscriberLagReason, checkpointWebSocketDeliveryState, decodeEDAWebSocketClientMessage, defaultEDAWebSocketFlowControl, deliveryHelloFrame, edaFrameworkWebSocketWireProtocol, encodeEDAWebSocketServerFrame, laggedCloseReason, makeEDAWebSocketWireProtocol, makeWebSocketDeliveryState, onClientAck, onDurableEvents, onEphemeralEvent, onHostSuppressedFrame, restoreWebSocketDeliveryState };
@@ -0,0 +1,2 @@
1
+ import { A as FrameId, B as EDAWebSocketWireFlowControl, C as EDAWebSocketServerFrame, D as EDA_WS_CLOSE_PROTOCOL_ERROR, E as EDA_WS_CLOSE_LAGGED, F as laggedCloseReason, G as EDAWebSocketWirePongFrame, H as EDAWebSocketWireHelloFrame, I as EDAFrameworkWebSocketEvent, J as EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, K as EDA_WEB_SOCKET_PING_MESSAGE, L as EDAWebSocketWireAckFrame, M as decodeEDAWebSocketClientMessage, N as defaultEDAWebSocketFlowControl, O as EDA_WS_CLOSE_SEND_FAILED, P as encodeEDAWebSocketServerFrame, R as EDAWebSocketWireClientFrame, S as EDAWebSocketPongFrame, T as EDA_WS_CLOSE_GOING_AWAY, U as EDAWebSocketWireLaggedFrame, V as EDAWebSocketWireHeartbeatFrame, W as EDAWebSocketWirePingFrame, X as makeEDAWebSocketWireProtocol, Y as edaFrameworkWebSocketWireProtocol, _ as EDAWebSocketFlowControl, a as checkpointWebSocketDeliveryState, b as EDAWebSocketLaggedFrame, c as onClientAck, d as onHostSuppressedFrame, f as restoreWebSocketDeliveryState, g as EDAWebSocketEventsFrame, h as EDAWebSocketErrorFrame, i as SubscriberLagReason, j as SubscriberId, k as EDA_WS_CLOSE_UNSUPPORTED_DATA, l as onDurableEvents, m as EDAWebSocketClientFrame, n as EDAWebSocketInFlightFrame, o as deliveryHelloFrame, p as EDAWebSocketAckFrame, q as EDA_WEB_SOCKET_PONG_MESSAGE, r as EDAWebSocketSuppressedRange, s as makeWebSocketDeliveryState, t as EDAWebSocketDeliveryCheckpoint, u as onEphemeralEvent, v as EDAWebSocketHeartbeatFrame, w as EDA_WEB_SOCKET_PROTOCOL_VERSION, x as EDAWebSocketPingFrame, y as EDAWebSocketHelloFrame, z as EDAWebSocketWireErrorFrame } from "../delivery-Bb7pkQ9o.js";
2
+ export { EDAFrameworkWebSocketEvent, EDAWebSocketAckFrame, EDAWebSocketClientFrame, EDAWebSocketDeliveryCheckpoint, EDAWebSocketErrorFrame, EDAWebSocketEventsFrame, EDAWebSocketFlowControl, EDAWebSocketHeartbeatFrame, EDAWebSocketHelloFrame, EDAWebSocketInFlightFrame, EDAWebSocketLaggedFrame, EDAWebSocketPingFrame, EDAWebSocketPongFrame, EDAWebSocketServerFrame, EDAWebSocketSuppressedRange, EDAWebSocketWireAckFrame, EDAWebSocketWireClientFrame, EDAWebSocketWireErrorFrame, EDAWebSocketWireFlowControl, EDAWebSocketWireHeartbeatFrame, EDAWebSocketWireHelloFrame, EDAWebSocketWireLaggedFrame, EDAWebSocketWirePingFrame, EDAWebSocketWirePongFrame, EDA_WEB_SOCKET_PING_MESSAGE, EDA_WEB_SOCKET_PONG_MESSAGE, EDA_WEB_SOCKET_PROTOCOL_VERSION, EDA_WEB_SOCKET_WIRE_PROTOCOL_VERSION, EDA_WS_CLOSE_GOING_AWAY, EDA_WS_CLOSE_LAGGED, EDA_WS_CLOSE_PROTOCOL_ERROR, EDA_WS_CLOSE_SEND_FAILED, EDA_WS_CLOSE_UNSUPPORTED_DATA, FrameId, SubscriberId, SubscriberLagReason, checkpointWebSocketDeliveryState, decodeEDAWebSocketClientMessage, defaultEDAWebSocketFlowControl, deliveryHelloFrame, edaFrameworkWebSocketWireProtocol, encodeEDAWebSocketServerFrame, laggedCloseReason, makeEDAWebSocketWireProtocol, makeWebSocketDeliveryState, onClientAck, onDurableEvents, onEphemeralEvent, onHostSuppressedFrame, restoreWebSocketDeliveryState };