@earendil-works/pi-agent-core 0.85.1 → 0.86.0
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.
- package/README.md +16 -6
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +64 -22
- package/dist/agent-loop.js.map +1 -1
- package/dist/agent.d.ts +5 -3
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +15 -6
- package/dist/agent.js.map +1 -1
- package/dist/harness/config.d.ts +1 -1
- package/dist/harness/config.d.ts.map +1 -1
- package/dist/harness/config.js +10 -2
- package/dist/harness/config.js.map +1 -1
- package/dist/harness/env/nodejs.d.ts +2 -1
- package/dist/harness/env/nodejs.d.ts.map +1 -1
- package/dist/harness/env/nodejs.js +98 -27
- package/dist/harness/env/nodejs.js.map +1 -1
- package/dist/harness/execution/tools.d.ts +1 -1
- package/dist/harness/execution/tools.d.ts.map +1 -1
- package/dist/harness/execution/tools.js +0 -2
- package/dist/harness/execution/tools.js.map +1 -1
- package/dist/harness/messages.d.ts.map +1 -1
- package/dist/harness/messages.js +1 -0
- package/dist/harness/messages.js.map +1 -1
- package/dist/harness/pico3/bash.d.ts +10 -0
- package/dist/harness/pico3/bash.d.ts.map +1 -0
- package/dist/harness/pico3/bash.js +25 -0
- package/dist/harness/pico3/bash.js.map +1 -0
- package/dist/harness/pico3/bounded.d.ts +21 -0
- package/dist/harness/pico3/bounded.d.ts.map +1 -0
- package/dist/harness/pico3/bounded.js +98 -0
- package/dist/harness/pico3/bounded.js.map +1 -0
- package/dist/harness/pico3/chord.d.ts +41 -0
- package/dist/harness/pico3/chord.d.ts.map +1 -0
- package/dist/harness/pico3/chord.js +130 -0
- package/dist/harness/pico3/chord.js.map +1 -0
- package/dist/harness/pico3/context.d.ts +16 -0
- package/dist/harness/pico3/context.d.ts.map +1 -0
- package/dist/harness/pico3/context.js +88 -0
- package/dist/harness/pico3/context.js.map +1 -0
- package/dist/harness/pico3/harness.d.ts +197 -0
- package/dist/harness/pico3/harness.d.ts.map +1 -0
- package/dist/harness/pico3/harness.js +654 -0
- package/dist/harness/pico3/harness.js.map +1 -0
- package/dist/harness/pico3/hooks.d.ts +10 -0
- package/dist/harness/pico3/hooks.d.ts.map +1 -0
- package/dist/harness/pico3/hooks.js +33 -0
- package/dist/harness/pico3/hooks.js.map +1 -0
- package/dist/harness/pico3/index.d.ts +19 -0
- package/dist/harness/pico3/index.d.ts.map +1 -0
- package/dist/harness/pico3/index.js +15 -0
- package/dist/harness/pico3/index.js.map +1 -0
- package/dist/harness/pico3/jsonl.d.ts +58 -0
- package/dist/harness/pico3/jsonl.d.ts.map +1 -0
- package/dist/harness/pico3/jsonl.js +325 -0
- package/dist/harness/pico3/jsonl.js.map +1 -0
- package/dist/harness/pico3/kinds/collapse.d.ts +49 -0
- package/dist/harness/pico3/kinds/collapse.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/collapse.js +191 -0
- package/dist/harness/pico3/kinds/collapse.js.map +1 -0
- package/dist/harness/pico3/kinds/entries.d.ts +78 -0
- package/dist/harness/pico3/kinds/entries.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/entries.js +13 -0
- package/dist/harness/pico3/kinds/entries.js.map +1 -0
- package/dist/harness/pico3/kinds/frames.d.ts +9 -0
- package/dist/harness/pico3/kinds/frames.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/frames.js +75 -0
- package/dist/harness/pico3/kinds/frames.js.map +1 -0
- package/dist/harness/pico3/kinds/generation.d.ts +94 -0
- package/dist/harness/pico3/kinds/generation.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/generation.js +504 -0
- package/dist/harness/pico3/kinds/generation.js.map +1 -0
- package/dist/harness/pico3/kinds/job.d.ts +44 -0
- package/dist/harness/pico3/kinds/job.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/job.js +143 -0
- package/dist/harness/pico3/kinds/job.js.map +1 -0
- package/dist/harness/pico3/kinds/plugin.d.ts +15 -0
- package/dist/harness/pico3/kinds/plugin.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/plugin.js +35 -0
- package/dist/harness/pico3/kinds/plugin.js.map +1 -0
- package/dist/harness/pico3/kinds/post-tools.d.ts +22 -0
- package/dist/harness/pico3/kinds/post-tools.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/post-tools.js +145 -0
- package/dist/harness/pico3/kinds/post-tools.js.map +1 -0
- package/dist/harness/pico3/kinds/task-api.d.ts +3 -0
- package/dist/harness/pico3/kinds/task-api.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/task-api.js +45 -0
- package/dist/harness/pico3/kinds/task-api.js.map +1 -0
- package/dist/harness/pico3/kinds/tool.d.ts +43 -0
- package/dist/harness/pico3/kinds/tool.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/tool.js +373 -0
- package/dist/harness/pico3/kinds/tool.js.map +1 -0
- package/dist/harness/pico3/membrane.d.ts +23 -0
- package/dist/harness/pico3/membrane.d.ts.map +1 -0
- package/dist/harness/pico3/membrane.js +141 -0
- package/dist/harness/pico3/membrane.js.map +1 -0
- package/dist/harness/pico3/memory.d.ts +53 -0
- package/dist/harness/pico3/memory.d.ts.map +1 -0
- package/dist/harness/pico3/memory.js +264 -0
- package/dist/harness/pico3/memory.js.map +1 -0
- package/dist/harness/pico3/scheduler.d.ts +46 -0
- package/dist/harness/pico3/scheduler.d.ts.map +1 -0
- package/dist/harness/pico3/scheduler.js +438 -0
- package/dist/harness/pico3/scheduler.js.map +1 -0
- package/dist/harness/pico3/session.d.ts +263 -0
- package/dist/harness/pico3/session.d.ts.map +1 -0
- package/dist/harness/pico3/session.js +1347 -0
- package/dist/harness/pico3/session.js.map +1 -0
- package/dist/harness/pico3/system.d.ts +126 -0
- package/dist/harness/pico3/system.d.ts.map +1 -0
- package/dist/harness/pico3/system.js +244 -0
- package/dist/harness/pico3/system.js.map +1 -0
- package/dist/harness/pico3/types.d.ts +973 -0
- package/dist/harness/pico3/types.d.ts.map +1 -0
- package/dist/harness/pico3/types.js +96 -0
- package/dist/harness/pico3/types.js.map +1 -0
- package/dist/harness/pico3/view.d.ts +34 -0
- package/dist/harness/pico3/view.d.ts.map +1 -0
- package/dist/harness/pico3/view.js +417 -0
- package/dist/harness/pico3/view.js.map +1 -0
- package/dist/harness/runtime/drive/boundary.d.ts.map +1 -1
- package/dist/harness/runtime/drive/boundary.js +6 -3
- package/dist/harness/runtime/drive/boundary.js.map +1 -1
- package/dist/harness/runtime/drive/response.d.ts.map +1 -1
- package/dist/harness/runtime/drive/response.js +4 -4
- package/dist/harness/runtime/drive/response.js.map +1 -1
- package/dist/harness/runtime/drive/retry.d.ts +2 -2
- package/dist/harness/runtime/drive/retry.d.ts.map +1 -1
- package/dist/harness/runtime/drive/retry.js +3 -6
- package/dist/harness/runtime/drive/retry.js.map +1 -1
- package/dist/harness/runtime/drive/structural.d.ts.map +1 -1
- package/dist/harness/runtime/drive/structural.js +5 -5
- package/dist/harness/runtime/drive/structural.js.map +1 -1
- package/dist/harness/runtime/drive/tool-placement.d.ts.map +1 -1
- package/dist/harness/runtime/drive/tool-placement.js +2 -27
- package/dist/harness/runtime/drive/tool-placement.js.map +1 -1
- package/dist/harness/runtime/drive/tools.d.ts.map +1 -1
- package/dist/harness/runtime/drive/tools.js.map +1 -1
- package/dist/harness/session/fork-policy.d.ts +20 -12
- package/dist/harness/session/fork-policy.d.ts.map +1 -1
- package/dist/harness/session/fork-policy.js +45 -12
- package/dist/harness/session/fork-policy.js.map +1 -1
- package/dist/harness/session/fork.d.ts +0 -2
- package/dist/harness/session/fork.d.ts.map +1 -1
- package/dist/harness/session/fork.js +20 -68
- package/dist/harness/session/fork.js.map +1 -1
- package/dist/harness/session/in-memory-storage-state.d.ts +5 -5
- package/dist/harness/session/in-memory-storage-state.d.ts.map +1 -1
- package/dist/harness/session/in-memory-storage-state.js +99 -39
- package/dist/harness/session/in-memory-storage-state.js.map +1 -1
- package/dist/harness/session/index.d.ts +1 -1
- package/dist/harness/session/index.d.ts.map +1 -1
- package/dist/harness/session/index.js +1 -1
- package/dist/harness/session/index.js.map +1 -1
- package/dist/harness/session/jsonl/fork.d.ts +38 -0
- package/dist/harness/session/jsonl/fork.d.ts.map +1 -0
- package/dist/harness/session/jsonl/fork.js +264 -0
- package/dist/harness/session/jsonl/fork.js.map +1 -0
- package/dist/harness/session/jsonl/io.d.ts +14 -0
- package/dist/harness/session/jsonl/io.d.ts.map +1 -0
- package/dist/harness/session/jsonl/io.js +86 -0
- package/dist/harness/session/jsonl/io.js.map +1 -0
- package/dist/harness/session/jsonl/legacy-v3.d.ts +33 -8
- package/dist/harness/session/jsonl/legacy-v3.d.ts.map +1 -1
- package/dist/harness/session/jsonl/legacy-v3.js +285 -206
- package/dist/harness/session/jsonl/legacy-v3.js.map +1 -1
- package/dist/harness/session/jsonl/repo.d.ts +2 -1
- package/dist/harness/session/jsonl/repo.d.ts.map +1 -1
- package/dist/harness/session/jsonl/repo.js +36 -20
- package/dist/harness/session/jsonl/repo.js.map +1 -1
- package/dist/harness/session/jsonl/storage.d.ts +4 -5
- package/dist/harness/session/jsonl/storage.d.ts.map +1 -1
- package/dist/harness/session/jsonl/storage.js +39 -113
- package/dist/harness/session/jsonl/storage.js.map +1 -1
- package/dist/harness/session/memory.d.ts +3 -5
- package/dist/harness/session/memory.d.ts.map +1 -1
- package/dist/harness/session/memory.js +9 -14
- package/dist/harness/session/memory.js.map +1 -1
- package/dist/harness/session/testing/conformance/session-repo.d.ts +2 -0
- package/dist/harness/session/testing/conformance/session-repo.d.ts.map +1 -1
- package/dist/harness/session/testing/conformance/session-repo.js +220 -1
- package/dist/harness/session/testing/conformance/session-repo.js.map +1 -1
- package/dist/harness/session/testing/index.d.ts +1 -1
- package/dist/harness/session/testing/index.d.ts.map +1 -1
- package/dist/harness/session/testing/index.js +1 -1
- package/dist/harness/session/testing/index.js.map +1 -1
- package/dist/harness/session/types.d.ts +1 -0
- package/dist/harness/session/types.d.ts.map +1 -1
- package/dist/harness/session/types.js.map +1 -1
- package/dist/harness/types.d.ts +14 -0
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/proxy.d.ts +2 -2
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js.map +1 -1
- package/dist/types.d.ts +30 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +10 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/harness/session/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC7F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtH,YAAY,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,GAAG;IACxD,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,gBAAgB,GAAG,QAAQ,CAAC;AAE/E,MAAM,WAAW,SAAS;IACzB,EAAE,EAAE,MAAM,CA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AQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,uCAAuC;IACvC,EAAE,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACA;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,EAAE,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEL,MAAM,WAAW,WAAW,CAC3B,SAAS,SAAS,eAAe,GAAG,eAAe,EACnD,cAAc,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,oBAAoB,EACvF,YAAY,GAAG,IAAI;IAEnB,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/E,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IACzE,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAChF,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;CAC7F","sourcesContent":["import type { JsonValue } from \"@earendil-works/chord\";\nimport type { AssistantMessage, StopReason, Usage } from \"@earendil-works/pi-ai\";\nimport type { AgentMessage, QueueMode, ThinkingLevel } from \"../../types.ts\";\nimport type { BranchPreparation } from \"../compaction/branch-summarization.ts\";\nimport type { CompactionPreparation, CompactionSettings } from \"../compaction/compaction.ts\";\nimport type { Context } from \"../context.ts\";\nimport type { AgentHarnessStreamOptions } from \"../types.ts\";\nimport type { ListElement, ListReadOptions, ListWrite, StoredValue, Value, ValueList, ValueWrite } from \"./values.ts\";\n\nexport type { JsonValue } from \"@earendil-works/chord\";\n\nexport type SettledAssistantMessage = AssistantMessage & {\n\tstopReason: Exclude<StopReason, \"pending\">;\n};\n\nexport type EntryType = \"message\" | \"compaction\" | \"branch_summary\" | \"custom\";\n\nexport interface EntryBase {\n\tid: string;\n\tparentId: string | null;\n\tseq: number;\n\ttimestamp: number;\n\ttype: EntryType;\n\tcustomType?: string;\n}\n\nexport interface MessageEntry extends EntryBase {\n\ttype: \"message\";\n\tmessage: AgentMessage;\n\tterminate?: true;\n}\n\nexport interface CompactionEntry extends EntryBase {\n\ttype: \"compaction\";\n\tsummary: string;\n\tretainedTail: AgentMessage[];\n\ttokensBefore: number;\n\tdetails?: JsonValue;\n\tusage?: Usage;\n\tfromHook: boolean;\n}\n\nexport interface BranchSummaryEntry extends EntryBase {\n\ttype: \"branch_summary\";\n\tfromId: string | null;\n\tsummary: string;\n\tdetails?: JsonValue;\n\tusage?: Usage;\n\tfromHook: boolean;\n}\n\nexport interface CustomEntry extends EntryBase {\n\ttype: \"custom\";\n\tcustomType: string;\n\tdata?: JsonValue;\n}\n\n/** Convert an application-defined custom entry into model context. */\nexport type EntryProjector = (\n\tentry: CustomEntry,\n\tcontext: Context,\n) => AgentMessage[] | undefined | Promise<AgentMessage[] | undefined>;\n\nexport type Entry = MessageEntry | CompactionEntry | BranchSummaryEntry | CustomEntry;\n\n/** Entry supplied to a transaction before storage assigns sequence and timestamp. */\nexport type NewEntry<TEntry extends Entry = Entry> = TEntry extends Entry ? Omit<TEntry, \"seq\" | \"timestamp\"> : never;\n\nexport interface LaneConfiguration {\n\tmodel: { provider: string; modelId: string };\n\tthinkingLevel: ThinkingLevel;\n\tactiveToolNames: string[];\n}\n\nexport interface OperationMeta {\n\toperationId: string;\n\tlane: string;\n\tsourceTipId: string | null;\n\tstartedAt: number;\n\tintent:\n\t\t| { kind: \"run\"; promptEntryIds: string[] }\n\t\t| { kind: \"compaction\"; customInstructions?: string }\n\t\t| {\n\t\t\t\tkind: \"navigation\";\n\t\t\t\ttargetId: string | null;\n\t\t\t\tsummarize: boolean;\n\t\t\t\tlabel?: string;\n\t\t\t\tcustomInstructions?: string;\n\t\t };\n}\n\nexport type Control =\n\t| { status: \"running\" }\n\t| {\n\t\t\tstatus: \"cancel_requested\";\n\t\t\trequestedAt: number;\n\t };\n\nexport interface OperationError {\n\tcode: string;\n\tmessage: string;\n\tdetails?: JsonValue;\n}\n\nexport type TerminalStatus = \"completed\" | \"declined\" | \"aborted\" | \"failed\";\n\n/** Immutable lane-lived observation record written by one terminal transaction. */\nexport interface OperationResultRecord {\n\toperationId: string;\n\tkind: OperationMeta[\"intent\"][\"kind\"];\n\tstatus: TerminalStatus;\n\terror?: OperationError;\n\tfromTipId: string | null;\n\ttipId: string | null;\n\tstartedAt: number;\n\tendedAt: number;\n}\n\nexport type Continuation =\n\t| { kind: \"need_assistant\"; overflowRecoveryUsed: boolean }\n\t| { kind: \"may_finish\"; includeFinalAssistant: boolean };\n\n/** Checkpoint payload; the flat leaf literal replaces the old nested phase tag. */\nexport interface CheckpointData {\n\tcontinuation: Continuation;\n\ttriggerEntryId: string;\n}\n\nexport type InboxItemKind = \"steer\" | \"followUp\" | \"nextRun\" | \"write\";\n\nexport interface InboxItem {\n\tentryId: string;\n\tkind: InboxItemKind;\n}\n\nexport interface NormalizedRetryPolicy {\n\tmaxAttempts: number;\n\tbaseDelayMs: number;\n}\n\nexport interface GenerationContext {\n\tstepId: string;\n\ttriggerEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n\tretryPolicy: NormalizedRetryPolicy;\n\toverflowRecoveryUsed: boolean;\n}\n\ninterface ToolCallSource {\n\t/** Zero-based index in the assistant message's complete content array, not a filtered tool-call ordinal. */\n\tsourceIndex: number;\n\tresultEntryId: string;\n}\n\nexport type ToolCall = ToolCallSource &\n\t(\n\t\t| { status: \"planned\" }\n\t\t| { status: \"effect_pending\"; replay: \"never\" | \"safe\" }\n\t\t| { status: \"outcome_ready\"; terminate: boolean }\n\t\t| { status: \"completed\"; terminate: boolean }\n\t);\n\nexport interface ToolBatch {\n\tassistantEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tturnId: string;\n\tcalls: ToolCall[];\n}\n\nexport interface SummaryContext {\n\tresultEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n\tretryPolicy: NormalizedRetryPolicy;\n}\n\n/*\n * Durable operation state is one flat union with one family-neutral discriminator\n * per dispatcher leaf. ToolBatch/ToolCall remain the nested child collection state\n * machine, and cancellation stays orthogonal via Control.\n */\n\nexport interface Cancellable {\n\tcontrol: Control;\n}\n\nexport interface RunSettings {\n\tcompaction: CompactionSettings;\n\tsteeringMode: QueueMode;\n\tfollowUpMode: QueueMode;\n\ttoolExecution: \"sequential\" | \"parallel\";\n}\n\n/** Uniform scope carried by every operation leaf. */\nexport interface OperationScope extends Cancellable {\n\tsettings: RunSettings;\n\tlatestAssistantEntryId: string | null;\n}\n\n/** Shared backoff data for every retry-wait leaf. */\nexport interface RetryWait {\n\tnextAttempt: number;\n\tnotBefore: number;\n\terrorMessage: string;\n}\n\nexport interface AssistantGenerationScope {\n\tgenerationContext: GenerationContext;\n}\n\nexport type ResultBoundary =\n\t| { kind: \"resume_checkpoint\"; resumeAfter: CheckpointData }\n\t| { kind: \"finish\" }\n\t| { kind: \"commit_navigation\"; targetId: string; label?: string };\n\nexport interface SummaryTask {\n\ttaskId: string;\n\treason?: \"manual\" | \"threshold\" | \"overflow\";\n\tcustomInstructions?: string;\n\tboundary: ResultBoundary;\n}\n\nexport interface SummaryGenerationScope {\n\ttask: SummaryTask;\n\tsummaryContext: SummaryContext;\n}\n\nexport interface SummaryGenerationReady extends SummaryGenerationScope {\n\tnextAttempt: number;\n}\n\nexport interface SummaryGenerationEffectPending extends SummaryGenerationScope {\n\tattempt: number;\n\trequest?: { index: number; usageId: string };\n\tusageIds: string[];\n}\n\nexport interface SummaryGenerationRetryWait extends SummaryGenerationScope, RetryWait {}\n\nexport interface DeferredScope extends OperationScope {\n\tstepId: string;\n\tsourceEntryId: string;\n\tpoll: number;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n}\n\nexport interface StartingOperation extends OperationScope {\n\tat: \"starting\";\n}\n\nexport interface CheckpointOperation extends OperationScope, CheckpointData {\n\tat: \"checkpoint\";\n}\n\nexport interface AssistantReadyOperation extends OperationScope, AssistantGenerationScope {\n\tat: \"assistant.ready\";\n\tnextAttempt: number;\n}\n\nexport interface AssistantEffectPendingOperation extends OperationScope, AssistantGenerationScope {\n\tat: \"assistant.effect_pending\";\n\tattempt: number;\n\tresponseEntryId: string;\n\tusageId: string;\n\tintendedOutputLimit: number;\n\tcontextWindow: number;\n}\n\nexport interface AssistantRetryWaitOperation extends OperationScope, AssistantGenerationScope, RetryWait {\n\tat: \"assistant.retry_wait\";\n}\n\nexport interface ToolsOperation extends OperationScope {\n\tat: \"tools\";\n\tbatch: ToolBatch;\n}\n\nexport interface DeferredSuspendedOperation extends DeferredScope {\n\tat: \"deferred.suspended\";\n}\n\nexport interface DeferredEffectPendingOperation extends DeferredScope {\n\tat: \"deferred.effect_pending\";\n\tresponseEntryId: string;\n\tusageId: string;\n}\n\nexport interface SummaryDecidingOperation extends OperationScope {\n\tat: \"summary.deciding\";\n\ttask: SummaryTask;\n}\n\nexport interface SummaryReadyOperation extends OperationScope, SummaryGenerationReady {\n\tat: \"summary.ready\";\n}\n\nexport interface SummaryEffectPendingOperation extends OperationScope, SummaryGenerationEffectPending {\n\tat: \"summary.effect_pending\";\n}\n\nexport interface SummaryRetryWaitOperation extends OperationScope, SummaryGenerationRetryWait {\n\tat: \"summary.retry_wait\";\n}\n\nexport interface NavigationReadyToCommitOperation extends OperationScope {\n\tat: \"navigation.ready_to_commit\";\n\t/** Unsummarized navigation may target the branch root (null). */\n\ttargetId: string | null;\n\tlabel?: string;\n}\n\n/** Flat durable operation state: exactly 13 family-neutral dispatcher leaves. */\nexport type OperationState =\n\t| StartingOperation\n\t| CheckpointOperation\n\t| AssistantReadyOperation\n\t| AssistantEffectPendingOperation\n\t| AssistantRetryWaitOperation\n\t| ToolsOperation\n\t| DeferredSuspendedOperation\n\t| DeferredEffectPendingOperation\n\t| SummaryDecidingOperation\n\t| SummaryReadyOperation\n\t| SummaryEffectPendingOperation\n\t| SummaryRetryWaitOperation\n\t| NavigationReadyToCommitOperation;\n\nexport type OperationAt = OperationState[\"at\"];\n\n/** Copy only the uniform operation scope when constructing a successor leaf. */\nexport function operationScopeOf(state: OperationState): OperationScope {\n\treturn {\n\t\tcontrol: state.control,\n\t\tsettings: state.settings,\n\t\tlatestAssistantEntryId: state.latestAssistantEntryId,\n\t};\n}\n\nexport type Operation = { meta: OperationMeta; state: OperationState };\n\nexport interface LaneState {\n\tcurrentOperationId: string | null;\n\tlastOperationId: string | null;\n\tinbox: InboxItem[];\n}\n\nexport type PendingEntry =\n\t| { type: \"message\"; payload: AgentMessage }\n\t| { type: \"custom\"; customType: string; payload?: JsonValue };\n\nexport interface DurableFileOperations {\n\tread: string[];\n\twritten: string[];\n\tedited: string[];\n}\n\nexport type DurableStructuralPreparation =\n\t| {\n\t\t\tkind: \"compaction\";\n\t\t\tmessagesToSummarize: CompactionPreparation[\"messagesToSummarize\"];\n\t\t\tturnPrefixMessages: CompactionPreparation[\"turnPrefixMessages\"];\n\t\t\tretainedTail: CompactionPreparation[\"retainedTail\"];\n\t\t\tisSplitTurn: boolean;\n\t\t\ttokensBefore: number;\n\t\t\tpreviousSummary?: string;\n\t\t\tfileOps: DurableFileOperations;\n\t\t\tsettings: CompactionSettings;\n\t }\n\t| {\n\t\t\tkind: \"branch_summary\";\n\t\t\tmessages: BranchPreparation[\"messages\"];\n\t\t\tfileOps: DurableFileOperations;\n\t\t\ttotalTokens: number;\n\t };\n\nexport interface UsageRow {\n\tid: string;\n\tseq: number;\n\tusage: Usage;\n\tentryId?: string;\n\tadjustment: boolean;\n\tdetails?: JsonValue;\n}\n\nexport interface EntryWrite {\n\tkind: \"entry\";\n\tentry: NewEntry;\n}\n\nexport interface UsageWrite {\n\tkind: \"usage\";\n\trow: Omit<UsageRow, \"seq\">;\n}\n\nexport type Write = EntryWrite | UsageWrite | ValueWrite | ListWrite;\n\nexport interface CommitResult {\n\tfirstSeq: number;\n\tseqs: number[];\n\ttimestamp: number;\n\t/** Session totals immediately after this commit was applied. */\n\tstats: SessionStats;\n}\n\nexport interface EntryStructure {\n\tid: string;\n\tparentId: string | null;\n\tseq: number;\n\ttimestamp: number;\n\ttype: EntryType;\n\tcustomType?: string;\n}\n\nexport interface EntryCursor {\n\tseq: number;\n}\n\nexport interface BranchScan {\n\tstart?: string;\n\tstopAtType?: EntryType;\n\tstopAtId?: string;\n\ttype?: EntryType;\n\tcustomType?: string;\n\torder?: \"newestFirst\" | \"oldestFirst\";\n\tlimit?: number;\n\tcursor?: EntryCursor;\n}\n\nexport type StorageBranchScan = BranchScan & { start: string };\n\nexport interface EntryScan {\n\ttype?: EntryType;\n\tcustomType?: string;\n\tfromSeq?: number;\n\ttoSeq?: number;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n}\n\nexport interface UsageScan {\n\tfromSeq?: number;\n\ttoSeq?: number;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n}\n\nexport interface SessionStats {\n\tmessageCount: number;\n\tusage: Usage;\n}\n\nexport interface Storage {\n\tcommit(writes: Write[], context: Context): Promise<CommitResult>;\n\tgetEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;\n\tgetValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;\n\tscanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;\n\treadList<T>(\n\t\taddress: ValueList<T>,\n\t\toptions: ListReadOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<ListElement<T>[]>;\n\tscanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;\n\tscanBranchStructure(query: StorageBranchScan, context: Context): Promise<EntryStructure[]>;\n\tscanEntries(query: EntryScan, context: Context): Promise<Entry[]>;\n\tscanUsage(query: UsageScan, context: Context): Promise<UsageRow[]>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tclose(context: Context): Promise<void>;\n}\n\nexport interface SessionMetadata {\n\tid: string;\n\tcreatedAt: number;\n\tstorageVersion: number;\n\tcwd?: string;\n\tparentSessionId?: string;\n\tlegacyParentSessionPath?: string;\n}\n\nexport interface IdGenerator {\n\tnext(timestampMs?: number): string;\n}\n\nexport interface EntryQuery {\n\ttype?: EntryType;\n\tcustomType?: string;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n\tcursor?: EntryCursor;\n}\n\nexport interface SessionReader {\n\tgetEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tgetValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;\n\tscanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;\n\treadList<T>(\n\t\taddress: ValueList<T>,\n\t\toptions: ListReadOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<ListElement<T>[]>;\n\t/** Scan a branch from an explicit entry while this reader capability remains valid. */\n\tscanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;\n}\n\n/** Exclusive keyless mutation barrier for one Session. */\nexport interface SessionMutation extends SessionReader {\n\t/** Exactly zero or one commit attempt. A second attempt rejects. */\n\tcommit(writes: Write[], context: Context): Promise<CommitResult>;\n\t/** Wait for any commit attempt, invalidate the capability, and release the barrier. */\n\tend(context: Context): Promise<void>;\n}\n\n/** Callback-scoped mutation capability without authority to release its Session barrier. */\nexport type SessionMutator = Omit<SessionMutation, \"end\">;\n\nexport type SessionMutationCallback<T> = (mutator: SessionMutator, context: Context) => T | Promise<T>;\n\nexport interface Branch {\n\treadonly name: string;\n\tgetTipId(context: Context): Promise<string | null>;\n\tfindEntries(query: BranchScan | undefined, context: Context): Promise<Entry[]>;\n\tfindEntry(query: BranchScan | undefined, context: Context): Promise<Entry | undefined>;\n\tappendMessage(message: AgentMessage, context: Context): Promise<string>;\n\tappendCustomEntry(customType: string, data: JsonValue | undefined, context: Context): Promise<string>;\n}\n\nexport interface Session<TMetadata extends SessionMetadata = SessionMetadata> extends SessionReader {\n\treadonly metadata: TMetadata;\n\treadonly idGenerator: IdGenerator;\n\tgetEntry(id: string, context: Context): Promise<Entry | undefined>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tgetName(context: Context): Promise<string | undefined>;\n\tgetLabel(targetId: string, context: Context): Promise<string | undefined>;\n\tfindEntries(query: EntryQuery | undefined, context: Context): Promise<Entry[]>;\n\tfindEntry(query: EntryQuery | undefined, context: Context): Promise<Entry | undefined>;\n\tbranch(name: string, context: Context): Promise<Branch | undefined>;\n\tcreateBranch(name: string, at: string | null, context: Context): Promise<Branch>;\n\tbeginMutation(context: Context): Promise<SessionMutation>;\n\t/**\n\t * Trusted exclusive callback over the Session mutation line. Calling a public Session writer from\n\t * this callback queues it behind the callback; awaiting that nested writer therefore deadlocks.\n\t * Use the supplied mutator for the callback's sole commit.\n\t */\n\tmutate<T>(mutation: SessionMutationCallback<T>, context: Context): Promise<T>;\n\tsetValue<T>(address: Value<T>, next: NoInfer<T>, context: Context): Promise<void>;\n\tdeleteValue<T>(address: Value<T>, context: Context): Promise<void>;\n\tappendList<T>(address: ValueList<T>, element: NoInfer<T>, context: Context): Promise<void>;\n\tdeleteList<T>(address: ValueList<T>, context: Context): Promise<void>;\n\tsetName(name: string | undefined, context: Context): Promise<void>;\n\tsetLabel(targetId: string, label: string | undefined, context: Context): Promise<void>;\n\tclose(context: Context): Promise<void>;\n}\n\nexport interface SessionCreateOptions {\n\tid?: string;\n\tparentSessionId?: string;\n}\n\nexport type ForkOptions =\n\t| {\n\t\t\t/**\n\t\t\t * Copy one path from a complete configured source AgentLane under the same\n\t\t\t * Branch name, with copied configuration and fresh idle lane state.\n\t\t\t */\n\t\t\tscope: \"branch\";\n\t\t\t/** Source Branch to copy. */\n\t\t\tbranch: string;\n\t\t\t/** Entry on the source Branch's current tip ancestry. Defaults to the current tip. */\n\t\t\tentryId?: string;\n\t\t\t/**\n\t\t\t * Whether the fork includes the selected entry or stops at its parent.\n\t\t\t * Defaults to including the selected entry.\n\t\t\t */\n\t\t\tposition?: \"before\" | \"at\";\n\t\t\t/** Optional destination session id. */\n\t\t\tid?: string;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Copy the whole conversation tree and every Branch tip. Each configured\n\t\t\t * AgentLane copies configuration plus fresh idle state; data-only Branches\n\t\t\t * remain data-only. Operation/pending/result/usage state is excluded.\n\t\t\t */\n\t\t\tscope: \"tree\";\n\t\t\t/** Optional destination session id. */\n\t\t\tid?: string;\n\t };\n\nexport interface SessionRepo<\n\tTMetadata extends SessionMetadata = SessionMetadata,\n\tTCreateOptions extends { id?: string; parentSessionId?: string } = SessionCreateOptions,\n\tTListOptions = void,\n> {\n\tcreate(options: TCreateOptions, context: Context): Promise<Session<TMetadata>>;\n\topen(metadata: TMetadata, context: Context): Promise<Session<TMetadata>>;\n\tlist(options: TListOptions | undefined, context: Context): Promise<TMetadata[]>;\n\tdelete(metadata: TMetadata, context: Context): Promise<void>;\n\tfork(source: TMetadata, options: ForkOptions, context: Context): Promise<Session<TMetadata>>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/harness/session/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;A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C/E,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IACzE,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAChF,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;CAC7F","sourcesContent":["import type { JsonValue } from \"@earendil-works/chord\";\nimport type { AssistantMessage, StopReason, Usage } from \"@earendil-works/pi-ai\";\nimport type { AgentMessage, QueueMode, ThinkingLevel } from \"../../types.ts\";\nimport type { BranchPreparation } from \"../compaction/branch-summarization.ts\";\nimport type { CompactionPreparation, CompactionSettings } from \"../compaction/compaction.ts\";\nimport type { Context } from \"../context.ts\";\nimport type { AgentHarnessStreamOptions } from \"../types.ts\";\nimport type { ListElement, ListReadOptions, ListWrite, StoredValue, Value, ValueList, ValueWrite } from \"./values.ts\";\n\nexport type { JsonValue } from \"@earendil-works/chord\";\n\nexport type SettledAssistantMessage = AssistantMessage & {\n\tstopReason: Exclude<StopReason, \"pending\">;\n};\n\nexport type EntryType = \"message\" | \"compaction\" | \"branch_summary\" | \"custom\";\n\nexport interface EntryBase {\n\tid: string;\n\tparentId: string | null;\n\tseq: number;\n\ttimestamp: number;\n\ttype: EntryType;\n\tcustomType?: string;\n}\n\nexport interface MessageEntry extends EntryBase {\n\ttype: \"message\";\n\tmessage: AgentMessage;\n\tterminate?: true;\n}\n\nexport interface CompactionEntry extends EntryBase {\n\ttype: \"compaction\";\n\tsummary: string;\n\tretainedTail: AgentMessage[];\n\ttokensBefore: number;\n\tdetails?: JsonValue;\n\tusage?: Usage;\n\tfromHook: boolean;\n}\n\nexport interface BranchSummaryEntry extends EntryBase {\n\ttype: \"branch_summary\";\n\tfromId: string | null;\n\tsummary: string;\n\tdetails?: JsonValue;\n\tusage?: Usage;\n\tfromHook: boolean;\n}\n\nexport interface CustomEntry extends EntryBase {\n\ttype: \"custom\";\n\tcustomType: string;\n\tdata?: JsonValue;\n}\n\n/** Convert an application-defined custom entry into model context. */\nexport type EntryProjector = (\n\tentry: CustomEntry,\n\tcontext: Context,\n) => AgentMessage[] | undefined | Promise<AgentMessage[] | undefined>;\n\nexport type Entry = MessageEntry | CompactionEntry | BranchSummaryEntry | CustomEntry;\n\n/** Entry supplied to a transaction before storage assigns sequence and timestamp. */\nexport type NewEntry<TEntry extends Entry = Entry> = TEntry extends Entry ? Omit<TEntry, \"seq\" | \"timestamp\"> : never;\n\nexport interface LaneConfiguration {\n\tmodel: { provider: string; modelId: string };\n\tthinkingLevel: ThinkingLevel;\n\tactiveToolNames: string[];\n}\n\nexport interface OperationMeta {\n\toperationId: string;\n\tlane: string;\n\tsourceTipId: string | null;\n\tstartedAt: number;\n\tintent:\n\t\t| { kind: \"run\"; promptEntryIds: string[] }\n\t\t| { kind: \"compaction\"; customInstructions?: string }\n\t\t| {\n\t\t\t\tkind: \"navigation\";\n\t\t\t\ttargetId: string | null;\n\t\t\t\tsummarize: boolean;\n\t\t\t\tlabel?: string;\n\t\t\t\tcustomInstructions?: string;\n\t\t };\n}\n\nexport type Control =\n\t| { status: \"running\" }\n\t| {\n\t\t\tstatus: \"cancel_requested\";\n\t\t\trequestedAt: number;\n\t };\n\nexport interface OperationError {\n\tcode: string;\n\tmessage: string;\n\tdetails?: JsonValue;\n}\n\nexport type TerminalStatus = \"completed\" | \"declined\" | \"aborted\" | \"failed\";\n\n/** Immutable lane-lived observation record written by one terminal transaction. */\nexport interface OperationResultRecord {\n\toperationId: string;\n\tkind: OperationMeta[\"intent\"][\"kind\"];\n\tstatus: TerminalStatus;\n\terror?: OperationError;\n\tfromTipId: string | null;\n\ttipId: string | null;\n\tstartedAt: number;\n\tendedAt: number;\n}\n\nexport type Continuation =\n\t| { kind: \"need_assistant\"; overflowRecoveryUsed: boolean }\n\t| { kind: \"may_finish\"; includeFinalAssistant: boolean };\n\n/** Checkpoint payload; the flat leaf literal replaces the old nested phase tag. */\nexport interface CheckpointData {\n\tcontinuation: Continuation;\n\ttriggerEntryId: string;\n}\n\nexport type InboxItemKind = \"steer\" | \"followUp\" | \"nextRun\" | \"write\";\n\nexport interface InboxItem {\n\tentryId: string;\n\tkind: InboxItemKind;\n}\n\nexport interface NormalizedRetryPolicy {\n\tmaxAttempts: number;\n\tbaseDelayMs: number;\n\tmaxAgentDelayMs: number;\n}\n\nexport interface GenerationContext {\n\tstepId: string;\n\ttriggerEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n\tretryPolicy: NormalizedRetryPolicy;\n\toverflowRecoveryUsed: boolean;\n}\n\ninterface ToolCallSource {\n\t/** Zero-based index in the assistant message's complete content array, not a filtered tool-call ordinal. */\n\tsourceIndex: number;\n\tresultEntryId: string;\n}\n\nexport type ToolCall = ToolCallSource &\n\t(\n\t\t| { status: \"planned\" }\n\t\t| { status: \"effect_pending\"; replay: \"never\" | \"safe\" }\n\t\t| { status: \"outcome_ready\"; terminate: boolean }\n\t\t| { status: \"completed\"; terminate: boolean }\n\t);\n\nexport interface ToolBatch {\n\tassistantEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tturnId: string;\n\tcalls: ToolCall[];\n}\n\nexport interface SummaryContext {\n\tresultEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n\tretryPolicy: NormalizedRetryPolicy;\n}\n\n/*\n * Durable operation state is one flat union with one family-neutral discriminator\n * per dispatcher leaf. ToolBatch/ToolCall remain the nested child collection state\n * machine, and cancellation stays orthogonal via Control.\n */\n\nexport interface Cancellable {\n\tcontrol: Control;\n}\n\nexport interface RunSettings {\n\tcompaction: CompactionSettings;\n\tsteeringMode: QueueMode;\n\tfollowUpMode: QueueMode;\n\ttoolExecution: \"sequential\" | \"parallel\";\n}\n\n/** Uniform scope carried by every operation leaf. */\nexport interface OperationScope extends Cancellable {\n\tsettings: RunSettings;\n\tlatestAssistantEntryId: string | null;\n}\n\n/** Shared backoff data for every retry-wait leaf. */\nexport interface RetryWait {\n\tnextAttempt: number;\n\tnotBefore: number;\n\terrorMessage: string;\n}\n\nexport interface AssistantGenerationScope {\n\tgenerationContext: GenerationContext;\n}\n\nexport type ResultBoundary =\n\t| { kind: \"resume_checkpoint\"; resumeAfter: CheckpointData }\n\t| { kind: \"finish\" }\n\t| { kind: \"commit_navigation\"; targetId: string; label?: string };\n\nexport interface SummaryTask {\n\ttaskId: string;\n\treason?: \"manual\" | \"threshold\" | \"overflow\";\n\tcustomInstructions?: string;\n\tboundary: ResultBoundary;\n}\n\nexport interface SummaryGenerationScope {\n\ttask: SummaryTask;\n\tsummaryContext: SummaryContext;\n}\n\nexport interface SummaryGenerationReady extends SummaryGenerationScope {\n\tnextAttempt: number;\n}\n\nexport interface SummaryGenerationEffectPending extends SummaryGenerationScope {\n\tattempt: number;\n\trequest?: { index: number; usageId: string };\n\tusageIds: string[];\n}\n\nexport interface SummaryGenerationRetryWait extends SummaryGenerationScope, RetryWait {}\n\nexport interface DeferredScope extends OperationScope {\n\tstepId: string;\n\tsourceEntryId: string;\n\tpoll: number;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n}\n\nexport interface StartingOperation extends OperationScope {\n\tat: \"starting\";\n}\n\nexport interface CheckpointOperation extends OperationScope, CheckpointData {\n\tat: \"checkpoint\";\n}\n\nexport interface AssistantReadyOperation extends OperationScope, AssistantGenerationScope {\n\tat: \"assistant.ready\";\n\tnextAttempt: number;\n}\n\nexport interface AssistantEffectPendingOperation extends OperationScope, AssistantGenerationScope {\n\tat: \"assistant.effect_pending\";\n\tattempt: number;\n\tresponseEntryId: string;\n\tusageId: string;\n\tintendedOutputLimit: number;\n\tcontextWindow: number;\n}\n\nexport interface AssistantRetryWaitOperation extends OperationScope, AssistantGenerationScope, RetryWait {\n\tat: \"assistant.retry_wait\";\n}\n\nexport interface ToolsOperation extends OperationScope {\n\tat: \"tools\";\n\tbatch: ToolBatch;\n}\n\nexport interface DeferredSuspendedOperation extends DeferredScope {\n\tat: \"deferred.suspended\";\n}\n\nexport interface DeferredEffectPendingOperation extends DeferredScope {\n\tat: \"deferred.effect_pending\";\n\tresponseEntryId: string;\n\tusageId: string;\n}\n\nexport interface SummaryDecidingOperation extends OperationScope {\n\tat: \"summary.deciding\";\n\ttask: SummaryTask;\n}\n\nexport interface SummaryReadyOperation extends OperationScope, SummaryGenerationReady {\n\tat: \"summary.ready\";\n}\n\nexport interface SummaryEffectPendingOperation extends OperationScope, SummaryGenerationEffectPending {\n\tat: \"summary.effect_pending\";\n}\n\nexport interface SummaryRetryWaitOperation extends OperationScope, SummaryGenerationRetryWait {\n\tat: \"summary.retry_wait\";\n}\n\nexport interface NavigationReadyToCommitOperation extends OperationScope {\n\tat: \"navigation.ready_to_commit\";\n\t/** Unsummarized navigation may target the branch root (null). */\n\ttargetId: string | null;\n\tlabel?: string;\n}\n\n/** Flat durable operation state: exactly 13 family-neutral dispatcher leaves. */\nexport type OperationState =\n\t| StartingOperation\n\t| CheckpointOperation\n\t| AssistantReadyOperation\n\t| AssistantEffectPendingOperation\n\t| AssistantRetryWaitOperation\n\t| ToolsOperation\n\t| DeferredSuspendedOperation\n\t| DeferredEffectPendingOperation\n\t| SummaryDecidingOperation\n\t| SummaryReadyOperation\n\t| SummaryEffectPendingOperation\n\t| SummaryRetryWaitOperation\n\t| NavigationReadyToCommitOperation;\n\nexport type OperationAt = OperationState[\"at\"];\n\n/** Copy only the uniform operation scope when constructing a successor leaf. */\nexport function operationScopeOf(state: OperationState): OperationScope {\n\treturn {\n\t\tcontrol: state.control,\n\t\tsettings: state.settings,\n\t\tlatestAssistantEntryId: state.latestAssistantEntryId,\n\t};\n}\n\nexport type Operation = { meta: OperationMeta; state: OperationState };\n\nexport interface LaneState {\n\tcurrentOperationId: string | null;\n\tlastOperationId: string | null;\n\tinbox: InboxItem[];\n}\n\nexport type PendingEntry =\n\t| { type: \"message\"; payload: AgentMessage }\n\t| { type: \"custom\"; customType: string; payload?: JsonValue };\n\nexport interface DurableFileOperations {\n\tread: string[];\n\twritten: string[];\n\tedited: string[];\n}\n\nexport type DurableStructuralPreparation =\n\t| {\n\t\t\tkind: \"compaction\";\n\t\t\tmessagesToSummarize: CompactionPreparation[\"messagesToSummarize\"];\n\t\t\tturnPrefixMessages: CompactionPreparation[\"turnPrefixMessages\"];\n\t\t\tretainedTail: CompactionPreparation[\"retainedTail\"];\n\t\t\tisSplitTurn: boolean;\n\t\t\ttokensBefore: number;\n\t\t\tpreviousSummary?: string;\n\t\t\tfileOps: DurableFileOperations;\n\t\t\tsettings: CompactionSettings;\n\t }\n\t| {\n\t\t\tkind: \"branch_summary\";\n\t\t\tmessages: BranchPreparation[\"messages\"];\n\t\t\tfileOps: DurableFileOperations;\n\t\t\ttotalTokens: number;\n\t };\n\nexport interface UsageRow {\n\tid: string;\n\tseq: number;\n\tusage: Usage;\n\tentryId?: string;\n\tadjustment: boolean;\n\tdetails?: JsonValue;\n}\n\nexport interface EntryWrite {\n\tkind: \"entry\";\n\tentry: NewEntry;\n}\n\nexport interface UsageWrite {\n\tkind: \"usage\";\n\trow: Omit<UsageRow, \"seq\">;\n}\n\nexport type Write = EntryWrite | UsageWrite | ValueWrite | ListWrite;\n\nexport interface CommitResult {\n\tfirstSeq: number;\n\tseqs: number[];\n\ttimestamp: number;\n\t/** Session totals immediately after this commit was applied. */\n\tstats: SessionStats;\n}\n\nexport interface EntryStructure {\n\tid: string;\n\tparentId: string | null;\n\tseq: number;\n\ttimestamp: number;\n\ttype: EntryType;\n\tcustomType?: string;\n}\n\nexport interface EntryCursor {\n\tseq: number;\n}\n\nexport interface BranchScan {\n\tstart?: string;\n\tstopAtType?: EntryType;\n\tstopAtId?: string;\n\ttype?: EntryType;\n\tcustomType?: string;\n\torder?: \"newestFirst\" | \"oldestFirst\";\n\tlimit?: number;\n\tcursor?: EntryCursor;\n}\n\nexport type StorageBranchScan = BranchScan & { start: string };\n\nexport interface EntryScan {\n\ttype?: EntryType;\n\tcustomType?: string;\n\tfromSeq?: number;\n\ttoSeq?: number;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n}\n\nexport interface UsageScan {\n\tfromSeq?: number;\n\ttoSeq?: number;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n}\n\nexport interface SessionStats {\n\tmessageCount: number;\n\tusage: Usage;\n}\n\nexport interface Storage {\n\tcommit(writes: Write[], context: Context): Promise<CommitResult>;\n\tgetEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;\n\tgetValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;\n\tscanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;\n\treadList<T>(\n\t\taddress: ValueList<T>,\n\t\toptions: ListReadOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<ListElement<T>[]>;\n\tscanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;\n\tscanBranchStructure(query: StorageBranchScan, context: Context): Promise<EntryStructure[]>;\n\tscanEntries(query: EntryScan, context: Context): Promise<Entry[]>;\n\tscanUsage(query: UsageScan, context: Context): Promise<UsageRow[]>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tclose(context: Context): Promise<void>;\n}\n\nexport interface SessionMetadata {\n\tid: string;\n\tcreatedAt: number;\n\tstorageVersion: number;\n\tcwd?: string;\n\tparentSessionId?: string;\n\tlegacyParentSessionPath?: string;\n}\n\nexport interface IdGenerator {\n\tnext(timestampMs?: number): string;\n}\n\nexport interface EntryQuery {\n\ttype?: EntryType;\n\tcustomType?: string;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n\tcursor?: EntryCursor;\n}\n\nexport interface SessionReader {\n\tgetEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tgetValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;\n\tscanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;\n\treadList<T>(\n\t\taddress: ValueList<T>,\n\t\toptions: ListReadOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<ListElement<T>[]>;\n\t/** Scan a branch from an explicit entry while this reader capability remains valid. */\n\tscanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;\n}\n\n/** Exclusive keyless mutation barrier for one Session. */\nexport interface SessionMutation extends SessionReader {\n\t/** Exactly zero or one commit attempt. A second attempt rejects. */\n\tcommit(writes: Write[], context: Context): Promise<CommitResult>;\n\t/** Wait for any commit attempt, invalidate the capability, and release the barrier. */\n\tend(context: Context): Promise<void>;\n}\n\n/** Callback-scoped mutation capability without authority to release its Session barrier. */\nexport type SessionMutator = Omit<SessionMutation, \"end\">;\n\nexport type SessionMutationCallback<T> = (mutator: SessionMutator, context: Context) => T | Promise<T>;\n\nexport interface Branch {\n\treadonly name: string;\n\tgetTipId(context: Context): Promise<string | null>;\n\tfindEntries(query: BranchScan | undefined, context: Context): Promise<Entry[]>;\n\tfindEntry(query: BranchScan | undefined, context: Context): Promise<Entry | undefined>;\n\tappendMessage(message: AgentMessage, context: Context): Promise<string>;\n\tappendCustomEntry(customType: string, data: JsonValue | undefined, context: Context): Promise<string>;\n}\n\nexport interface Session<TMetadata extends SessionMetadata = SessionMetadata> extends SessionReader {\n\treadonly metadata: TMetadata;\n\treadonly idGenerator: IdGenerator;\n\tgetEntry(id: string, context: Context): Promise<Entry | undefined>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tgetName(context: Context): Promise<string | undefined>;\n\tgetLabel(targetId: string, context: Context): Promise<string | undefined>;\n\tfindEntries(query: EntryQuery | undefined, context: Context): Promise<Entry[]>;\n\tfindEntry(query: EntryQuery | undefined, context: Context): Promise<Entry | undefined>;\n\tbranch(name: string, context: Context): Promise<Branch | undefined>;\n\tcreateBranch(name: string, at: string | null, context: Context): Promise<Branch>;\n\tbeginMutation(context: Context): Promise<SessionMutation>;\n\t/**\n\t * Trusted exclusive callback over the Session mutation line. Calling a public Session writer from\n\t * this callback queues it behind the callback; awaiting that nested writer therefore deadlocks.\n\t * Use the supplied mutator for the callback's sole commit.\n\t */\n\tmutate<T>(mutation: SessionMutationCallback<T>, context: Context): Promise<T>;\n\tsetValue<T>(address: Value<T>, next: NoInfer<T>, context: Context): Promise<void>;\n\tdeleteValue<T>(address: Value<T>, context: Context): Promise<void>;\n\tappendList<T>(address: ValueList<T>, element: NoInfer<T>, context: Context): Promise<void>;\n\tdeleteList<T>(address: ValueList<T>, context: Context): Promise<void>;\n\tsetName(name: string | undefined, context: Context): Promise<void>;\n\tsetLabel(targetId: string, label: string | undefined, context: Context): Promise<void>;\n\tclose(context: Context): Promise<void>;\n}\n\nexport interface SessionCreateOptions {\n\tid?: string;\n\tparentSessionId?: string;\n}\n\nexport type ForkOptions =\n\t| {\n\t\t\t/**\n\t\t\t * Copy one path from a complete configured source AgentLane under the same\n\t\t\t * Branch name, with copied configuration and fresh idle lane state.\n\t\t\t */\n\t\t\tscope: \"branch\";\n\t\t\t/** Source Branch to copy. */\n\t\t\tbranch: string;\n\t\t\t/** Entry on the source Branch's current tip ancestry. Defaults to the current tip. */\n\t\t\tentryId?: string;\n\t\t\t/**\n\t\t\t * Whether the fork includes the selected entry or stops at its parent.\n\t\t\t * Defaults to including the selected entry.\n\t\t\t */\n\t\t\tposition?: \"before\" | \"at\";\n\t\t\t/** Optional destination session id. */\n\t\t\tid?: string;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Copy the whole conversation tree and every Branch tip. Each configured\n\t\t\t * AgentLane copies configuration plus fresh idle state; data-only Branches\n\t\t\t * remain data-only. Operation/pending/result/usage state is excluded.\n\t\t\t */\n\t\t\tscope: \"tree\";\n\t\t\t/** Optional destination session id. */\n\t\t\tid?: string;\n\t };\n\nexport interface SessionRepo<\n\tTMetadata extends SessionMetadata = SessionMetadata,\n\tTCreateOptions extends { id?: string; parentSessionId?: string } = SessionCreateOptions,\n\tTListOptions = void,\n> {\n\tcreate(options: TCreateOptions, context: Context): Promise<Session<TMetadata>>;\n\topen(metadata: TMetadata, context: Context): Promise<Session<TMetadata>>;\n\tlist(options: TListOptions | undefined, context: Context): Promise<TMetadata[]>;\n\tdelete(metadata: TMetadata, context: Context): Promise<void>;\n\tfork(source: TMetadata, options: ForkOptions, context: Context): Promise<Session<TMetadata>>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/harness/session/types.ts"],"names":[],"mappings":"AA2UA,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,KAAqB,EAAkB;IACvE,OAAO;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;KACpD,CAAC;AAAA,CACF","sourcesContent":["import type { JsonValue } from \"@earendil-works/chord\";\nimport type { AssistantMessage, StopReason, Usage } from \"@earendil-works/pi-ai\";\nimport type { AgentMessage, QueueMode, ThinkingLevel } from \"../../types.ts\";\nimport type { BranchPreparation } from \"../compaction/branch-summarization.ts\";\nimport type { CompactionPreparation, CompactionSettings } from \"../compaction/compaction.ts\";\nimport type { Context } from \"../context.ts\";\nimport type { AgentHarnessStreamOptions } from \"../types.ts\";\nimport type { ListElement, ListReadOptions, ListWrite, StoredValue, Value, ValueList, ValueWrite } from \"./values.ts\";\n\nexport type { JsonValue } from \"@earendil-works/chord\";\n\nexport type SettledAssistantMessage = AssistantMessage & {\n\tstopReason: Exclude<StopReason, \"pending\">;\n};\n\nexport type EntryType = \"message\" | \"compaction\" | \"branch_summary\" | \"custom\";\n\nexport interface EntryBase {\n\tid: string;\n\tparentId: string | null;\n\tseq: number;\n\ttimestamp: number;\n\ttype: EntryType;\n\tcustomType?: string;\n}\n\nexport interface MessageEntry extends EntryBase {\n\ttype: \"message\";\n\tmessage: AgentMessage;\n\tterminate?: true;\n}\n\nexport interface CompactionEntry extends EntryBase {\n\ttype: \"compaction\";\n\tsummary: string;\n\tretainedTail: AgentMessage[];\n\ttokensBefore: number;\n\tdetails?: JsonValue;\n\tusage?: Usage;\n\tfromHook: boolean;\n}\n\nexport interface BranchSummaryEntry extends EntryBase {\n\ttype: \"branch_summary\";\n\tfromId: string | null;\n\tsummary: string;\n\tdetails?: JsonValue;\n\tusage?: Usage;\n\tfromHook: boolean;\n}\n\nexport interface CustomEntry extends EntryBase {\n\ttype: \"custom\";\n\tcustomType: string;\n\tdata?: JsonValue;\n}\n\n/** Convert an application-defined custom entry into model context. */\nexport type EntryProjector = (\n\tentry: CustomEntry,\n\tcontext: Context,\n) => AgentMessage[] | undefined | Promise<AgentMessage[] | undefined>;\n\nexport type Entry = MessageEntry | CompactionEntry | BranchSummaryEntry | CustomEntry;\n\n/** Entry supplied to a transaction before storage assigns sequence and timestamp. */\nexport type NewEntry<TEntry extends Entry = Entry> = TEntry extends Entry ? Omit<TEntry, \"seq\" | \"timestamp\"> : never;\n\nexport interface LaneConfiguration {\n\tmodel: { provider: string; modelId: string };\n\tthinkingLevel: ThinkingLevel;\n\tactiveToolNames: string[];\n}\n\nexport interface OperationMeta {\n\toperationId: string;\n\tlane: string;\n\tsourceTipId: string | null;\n\tstartedAt: number;\n\tintent:\n\t\t| { kind: \"run\"; promptEntryIds: string[] }\n\t\t| { kind: \"compaction\"; customInstructions?: string }\n\t\t| {\n\t\t\t\tkind: \"navigation\";\n\t\t\t\ttargetId: string | null;\n\t\t\t\tsummarize: boolean;\n\t\t\t\tlabel?: string;\n\t\t\t\tcustomInstructions?: string;\n\t\t };\n}\n\nexport type Control =\n\t| { status: \"running\" }\n\t| {\n\t\t\tstatus: \"cancel_requested\";\n\t\t\trequestedAt: number;\n\t };\n\nexport interface OperationError {\n\tcode: string;\n\tmessage: string;\n\tdetails?: JsonValue;\n}\n\nexport type TerminalStatus = \"completed\" | \"declined\" | \"aborted\" | \"failed\";\n\n/** Immutable lane-lived observation record written by one terminal transaction. */\nexport interface OperationResultRecord {\n\toperationId: string;\n\tkind: OperationMeta[\"intent\"][\"kind\"];\n\tstatus: TerminalStatus;\n\terror?: OperationError;\n\tfromTipId: string | null;\n\ttipId: string | null;\n\tstartedAt: number;\n\tendedAt: number;\n}\n\nexport type Continuation =\n\t| { kind: \"need_assistant\"; overflowRecoveryUsed: boolean }\n\t| { kind: \"may_finish\"; includeFinalAssistant: boolean };\n\n/** Checkpoint payload; the flat leaf literal replaces the old nested phase tag. */\nexport interface CheckpointData {\n\tcontinuation: Continuation;\n\ttriggerEntryId: string;\n}\n\nexport type InboxItemKind = \"steer\" | \"followUp\" | \"nextRun\" | \"write\";\n\nexport interface InboxItem {\n\tentryId: string;\n\tkind: InboxItemKind;\n}\n\nexport interface NormalizedRetryPolicy {\n\tmaxAttempts: number;\n\tbaseDelayMs: number;\n}\n\nexport interface GenerationContext {\n\tstepId: string;\n\ttriggerEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n\tretryPolicy: NormalizedRetryPolicy;\n\toverflowRecoveryUsed: boolean;\n}\n\ninterface ToolCallSource {\n\t/** Zero-based index in the assistant message's complete content array, not a filtered tool-call ordinal. */\n\tsourceIndex: number;\n\tresultEntryId: string;\n}\n\nexport type ToolCall = ToolCallSource &\n\t(\n\t\t| { status: \"planned\" }\n\t\t| { status: \"effect_pending\"; replay: \"never\" | \"safe\" }\n\t\t| { status: \"outcome_ready\"; terminate: boolean }\n\t\t| { status: \"completed\"; terminate: boolean }\n\t);\n\nexport interface ToolBatch {\n\tassistantEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tturnId: string;\n\tcalls: ToolCall[];\n}\n\nexport interface SummaryContext {\n\tresultEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n\tretryPolicy: NormalizedRetryPolicy;\n}\n\n/*\n * Durable operation state is one flat union with one family-neutral discriminator\n * per dispatcher leaf. ToolBatch/ToolCall remain the nested child collection state\n * machine, and cancellation stays orthogonal via Control.\n */\n\nexport interface Cancellable {\n\tcontrol: Control;\n}\n\nexport interface RunSettings {\n\tcompaction: CompactionSettings;\n\tsteeringMode: QueueMode;\n\tfollowUpMode: QueueMode;\n\ttoolExecution: \"sequential\" | \"parallel\";\n}\n\n/** Uniform scope carried by every operation leaf. */\nexport interface OperationScope extends Cancellable {\n\tsettings: RunSettings;\n\tlatestAssistantEntryId: string | null;\n}\n\n/** Shared backoff data for every retry-wait leaf. */\nexport interface RetryWait {\n\tnextAttempt: number;\n\tnotBefore: number;\n\terrorMessage: string;\n}\n\nexport interface AssistantGenerationScope {\n\tgenerationContext: GenerationContext;\n}\n\nexport type ResultBoundary =\n\t| { kind: \"resume_checkpoint\"; resumeAfter: CheckpointData }\n\t| { kind: \"finish\" }\n\t| { kind: \"commit_navigation\"; targetId: string; label?: string };\n\nexport interface SummaryTask {\n\ttaskId: string;\n\treason?: \"manual\" | \"threshold\" | \"overflow\";\n\tcustomInstructions?: string;\n\tboundary: ResultBoundary;\n}\n\nexport interface SummaryGenerationScope {\n\ttask: SummaryTask;\n\tsummaryContext: SummaryContext;\n}\n\nexport interface SummaryGenerationReady extends SummaryGenerationScope {\n\tnextAttempt: number;\n}\n\nexport interface SummaryGenerationEffectPending extends SummaryGenerationScope {\n\tattempt: number;\n\trequest?: { index: number; usageId: string };\n\tusageIds: string[];\n}\n\nexport interface SummaryGenerationRetryWait extends SummaryGenerationScope, RetryWait {}\n\nexport interface DeferredScope extends OperationScope {\n\tstepId: string;\n\tsourceEntryId: string;\n\tpoll: number;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n}\n\nexport interface StartingOperation extends OperationScope {\n\tat: \"starting\";\n}\n\nexport interface CheckpointOperation extends OperationScope, CheckpointData {\n\tat: \"checkpoint\";\n}\n\nexport interface AssistantReadyOperation extends OperationScope, AssistantGenerationScope {\n\tat: \"assistant.ready\";\n\tnextAttempt: number;\n}\n\nexport interface AssistantEffectPendingOperation extends OperationScope, AssistantGenerationScope {\n\tat: \"assistant.effect_pending\";\n\tattempt: number;\n\tresponseEntryId: string;\n\tusageId: string;\n\tintendedOutputLimit: number;\n\tcontextWindow: number;\n}\n\nexport interface AssistantRetryWaitOperation extends OperationScope, AssistantGenerationScope, RetryWait {\n\tat: \"assistant.retry_wait\";\n}\n\nexport interface ToolsOperation extends OperationScope {\n\tat: \"tools\";\n\tbatch: ToolBatch;\n}\n\nexport interface DeferredSuspendedOperation extends DeferredScope {\n\tat: \"deferred.suspended\";\n}\n\nexport interface DeferredEffectPendingOperation extends DeferredScope {\n\tat: \"deferred.effect_pending\";\n\tresponseEntryId: string;\n\tusageId: string;\n}\n\nexport interface SummaryDecidingOperation extends OperationScope {\n\tat: \"summary.deciding\";\n\ttask: SummaryTask;\n}\n\nexport interface SummaryReadyOperation extends OperationScope, SummaryGenerationReady {\n\tat: \"summary.ready\";\n}\n\nexport interface SummaryEffectPendingOperation extends OperationScope, SummaryGenerationEffectPending {\n\tat: \"summary.effect_pending\";\n}\n\nexport interface SummaryRetryWaitOperation extends OperationScope, SummaryGenerationRetryWait {\n\tat: \"summary.retry_wait\";\n}\n\nexport interface NavigationReadyToCommitOperation extends OperationScope {\n\tat: \"navigation.ready_to_commit\";\n\t/** Unsummarized navigation may target the branch root (null). */\n\ttargetId: string | null;\n\tlabel?: string;\n}\n\n/** Flat durable operation state: exactly 13 family-neutral dispatcher leaves. */\nexport type OperationState =\n\t| StartingOperation\n\t| CheckpointOperation\n\t| AssistantReadyOperation\n\t| AssistantEffectPendingOperation\n\t| AssistantRetryWaitOperation\n\t| ToolsOperation\n\t| DeferredSuspendedOperation\n\t| DeferredEffectPendingOperation\n\t| SummaryDecidingOperation\n\t| SummaryReadyOperation\n\t| SummaryEffectPendingOperation\n\t| SummaryRetryWaitOperation\n\t| NavigationReadyToCommitOperation;\n\nexport type OperationAt = OperationState[\"at\"];\n\n/** Copy only the uniform operation scope when constructing a successor leaf. */\nexport function operationScopeOf(state: OperationState): OperationScope {\n\treturn {\n\t\tcontrol: state.control,\n\t\tsettings: state.settings,\n\t\tlatestAssistantEntryId: state.latestAssistantEntryId,\n\t};\n}\n\nexport type Operation = { meta: OperationMeta; state: OperationState };\n\nexport interface LaneState {\n\tcurrentOperationId: string | null;\n\tlastOperationId: string | null;\n\tinbox: InboxItem[];\n}\n\nexport type PendingEntry =\n\t| { type: \"message\"; payload: AgentMessage }\n\t| { type: \"custom\"; customType: string; payload?: JsonValue };\n\nexport interface DurableFileOperations {\n\tread: string[];\n\twritten: string[];\n\tedited: string[];\n}\n\nexport type DurableStructuralPreparation =\n\t| {\n\t\t\tkind: \"compaction\";\n\t\t\tmessagesToSummarize: CompactionPreparation[\"messagesToSummarize\"];\n\t\t\tturnPrefixMessages: CompactionPreparation[\"turnPrefixMessages\"];\n\t\t\tretainedTail: CompactionPreparation[\"retainedTail\"];\n\t\t\tisSplitTurn: boolean;\n\t\t\ttokensBefore: number;\n\t\t\tpreviousSummary?: string;\n\t\t\tfileOps: DurableFileOperations;\n\t\t\tsettings: CompactionSettings;\n\t }\n\t| {\n\t\t\tkind: \"branch_summary\";\n\t\t\tmessages: BranchPreparation[\"messages\"];\n\t\t\tfileOps: DurableFileOperations;\n\t\t\ttotalTokens: number;\n\t };\n\nexport interface UsageRow {\n\tid: string;\n\tseq: number;\n\tusage: Usage;\n\tentryId?: string;\n\tadjustment: boolean;\n\tdetails?: JsonValue;\n}\n\nexport interface EntryWrite {\n\tkind: \"entry\";\n\tentry: NewEntry;\n}\n\nexport interface UsageWrite {\n\tkind: \"usage\";\n\trow: Omit<UsageRow, \"seq\">;\n}\n\nexport type Write = EntryWrite | UsageWrite | ValueWrite | ListWrite;\n\nexport interface CommitResult {\n\tfirstSeq: number;\n\tseqs: number[];\n\ttimestamp: number;\n\t/** Session totals immediately after this commit was applied. */\n\tstats: SessionStats;\n}\n\nexport interface EntryStructure {\n\tid: string;\n\tparentId: string | null;\n\tseq: number;\n\ttimestamp: number;\n\ttype: EntryType;\n\tcustomType?: string;\n}\n\nexport interface EntryCursor {\n\tseq: number;\n}\n\nexport interface BranchScan {\n\tstart?: string;\n\tstopAtType?: EntryType;\n\tstopAtId?: string;\n\ttype?: EntryType;\n\tcustomType?: string;\n\torder?: \"newestFirst\" | \"oldestFirst\";\n\tlimit?: number;\n\tcursor?: EntryCursor;\n}\n\nexport type StorageBranchScan = BranchScan & { start: string };\n\nexport interface EntryScan {\n\ttype?: EntryType;\n\tcustomType?: string;\n\tfromSeq?: number;\n\ttoSeq?: number;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n}\n\nexport interface UsageScan {\n\tfromSeq?: number;\n\ttoSeq?: number;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n}\n\nexport interface SessionStats {\n\tmessageCount: number;\n\tusage: Usage;\n}\n\nexport interface Storage {\n\tcommit(writes: Write[], context: Context): Promise<CommitResult>;\n\tgetEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;\n\tgetValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;\n\tscanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;\n\treadList<T>(\n\t\taddress: ValueList<T>,\n\t\toptions: ListReadOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<ListElement<T>[]>;\n\tscanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;\n\tscanBranchStructure(query: StorageBranchScan, context: Context): Promise<EntryStructure[]>;\n\tscanEntries(query: EntryScan, context: Context): Promise<Entry[]>;\n\tscanUsage(query: UsageScan, context: Context): Promise<UsageRow[]>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tclose(context: Context): Promise<void>;\n}\n\nexport interface SessionMetadata {\n\tid: string;\n\tcreatedAt: number;\n\tstorageVersion: number;\n\tcwd?: string;\n\tparentSessionId?: string;\n\tlegacyParentSessionPath?: string;\n}\n\nexport interface IdGenerator {\n\tnext(timestampMs?: number): string;\n}\n\nexport interface EntryQuery {\n\ttype?: EntryType;\n\tcustomType?: string;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n\tcursor?: EntryCursor;\n}\n\nexport interface SessionReader {\n\tgetEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tgetValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;\n\tscanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;\n\treadList<T>(\n\t\taddress: ValueList<T>,\n\t\toptions: ListReadOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<ListElement<T>[]>;\n\t/** Scan a branch from an explicit entry while this reader capability remains valid. */\n\tscanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;\n}\n\n/** Exclusive keyless mutation barrier for one Session. */\nexport interface SessionMutation extends SessionReader {\n\t/** Exactly zero or one commit attempt. A second attempt rejects. */\n\tcommit(writes: Write[], context: Context): Promise<CommitResult>;\n\t/** Wait for any commit attempt, invalidate the capability, and release the barrier. */\n\tend(context: Context): Promise<void>;\n}\n\n/** Callback-scoped mutation capability without authority to release its Session barrier. */\nexport type SessionMutator = Omit<SessionMutation, \"end\">;\n\nexport type SessionMutationCallback<T> = (mutator: SessionMutator, context: Context) => T | Promise<T>;\n\nexport interface Branch {\n\treadonly name: string;\n\tgetTipId(context: Context): Promise<string | null>;\n\tfindEntries(query: BranchScan | undefined, context: Context): Promise<Entry[]>;\n\tfindEntry(query: BranchScan | undefined, context: Context): Promise<Entry | undefined>;\n\tappendMessage(message: AgentMessage, context: Context): Promise<string>;\n\tappendCustomEntry(customType: string, data: JsonValue | undefined, context: Context): Promise<string>;\n}\n\nexport interface Session<TMetadata extends SessionMetadata = SessionMetadata> extends SessionReader {\n\treadonly metadata: TMetadata;\n\treadonly idGenerator: IdGenerator;\n\tgetEntry(id: string, context: Context): Promise<Entry | undefined>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tgetName(context: Context): Promise<string | undefined>;\n\tgetLabel(targetId: string, context: Context): Promise<string | undefined>;\n\tfindEntries(query: EntryQuery | undefined, context: Context): Promise<Entry[]>;\n\tfindEntry(query: EntryQuery | undefined, context: Context): Promise<Entry | undefined>;\n\tbranch(name: string, context: Context): Promise<Branch | undefined>;\n\tcreateBranch(name: string, at: string | null, context: Context): Promise<Branch>;\n\tbeginMutation(context: Context): Promise<SessionMutation>;\n\t/**\n\t * Trusted exclusive callback over the Session mutation line. Calling a public Session writer from\n\t * this callback queues it behind the callback; awaiting that nested writer therefore deadlocks.\n\t * Use the supplied mutator for the callback's sole commit.\n\t */\n\tmutate<T>(mutation: SessionMutationCallback<T>, context: Context): Promise<T>;\n\tsetValue<T>(address: Value<T>, next: NoInfer<T>, context: Context): Promise<void>;\n\tdeleteValue<T>(address: Value<T>, context: Context): Promise<void>;\n\tappendList<T>(address: ValueList<T>, element: NoInfer<T>, context: Context): Promise<void>;\n\tdeleteList<T>(address: ValueList<T>, context: Context): Promise<void>;\n\tsetName(name: string | undefined, context: Context): Promise<void>;\n\tsetLabel(targetId: string, label: string | undefined, context: Context): Promise<void>;\n\tclose(context: Context): Promise<void>;\n}\n\nexport interface SessionCreateOptions {\n\tid?: string;\n\tparentSessionId?: string;\n}\n\nexport type ForkOptions =\n\t| {\n\t\t\t/**\n\t\t\t * Copy one path from a complete configured source AgentLane under the same\n\t\t\t * Branch name, with copied configuration and fresh idle lane state.\n\t\t\t */\n\t\t\tscope: \"branch\";\n\t\t\t/** Source Branch to copy. */\n\t\t\tbranch: string;\n\t\t\t/** Entry on the source Branch's current tip ancestry. Defaults to the current tip. */\n\t\t\tentryId?: string;\n\t\t\t/**\n\t\t\t * Whether the fork includes the selected entry or stops at its parent.\n\t\t\t * Defaults to including the selected entry.\n\t\t\t */\n\t\t\tposition?: \"before\" | \"at\";\n\t\t\t/** Optional destination session id. */\n\t\t\tid?: string;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Copy the whole conversation tree and every Branch tip. Each configured\n\t\t\t * AgentLane copies configuration plus fresh idle state; data-only Branches\n\t\t\t * remain data-only. Operation/pending/result/usage state is excluded.\n\t\t\t */\n\t\t\tscope: \"tree\";\n\t\t\t/** Optional destination session id. */\n\t\t\tid?: string;\n\t };\n\nexport interface SessionRepo<\n\tTMetadata extends SessionMetadata = SessionMetadata,\n\tTCreateOptions extends { id?: string; parentSessionId?: string } = SessionCreateOptions,\n\tTListOptions = void,\n> {\n\tcreate(options: TCreateOptions, context: Context): Promise<Session<TMetadata>>;\n\topen(metadata: TMetadata, context: Context): Promise<Session<TMetadata>>;\n\tlist(options: TListOptions | undefined, context: Context): Promise<TMetadata[]>;\n\tdelete(metadata: TMetadata, context: Context): Promise<void>;\n\tfork(source: TMetadata, options: ForkOptions, context: Context): Promise<Session<TMetadata>>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/harness/session/types.ts"],"names":[],"mappings":"AA4UA,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,KAAqB,EAAkB;IACvE,OAAO;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;KACpD,CAAC;AAAA,CACF","sourcesContent":["import type { JsonValue } from \"@earendil-works/chord\";\nimport type { AssistantMessage, StopReason, Usage } from \"@earendil-works/pi-ai\";\nimport type { AgentMessage, QueueMode, ThinkingLevel } from \"../../types.ts\";\nimport type { BranchPreparation } from \"../compaction/branch-summarization.ts\";\nimport type { CompactionPreparation, CompactionSettings } from \"../compaction/compaction.ts\";\nimport type { Context } from \"../context.ts\";\nimport type { AgentHarnessStreamOptions } from \"../types.ts\";\nimport type { ListElement, ListReadOptions, ListWrite, StoredValue, Value, ValueList, ValueWrite } from \"./values.ts\";\n\nexport type { JsonValue } from \"@earendil-works/chord\";\n\nexport type SettledAssistantMessage = AssistantMessage & {\n\tstopReason: Exclude<StopReason, \"pending\">;\n};\n\nexport type EntryType = \"message\" | \"compaction\" | \"branch_summary\" | \"custom\";\n\nexport interface EntryBase {\n\tid: string;\n\tparentId: string | null;\n\tseq: number;\n\ttimestamp: number;\n\ttype: EntryType;\n\tcustomType?: string;\n}\n\nexport interface MessageEntry extends EntryBase {\n\ttype: \"message\";\n\tmessage: AgentMessage;\n\tterminate?: true;\n}\n\nexport interface CompactionEntry extends EntryBase {\n\ttype: \"compaction\";\n\tsummary: string;\n\tretainedTail: AgentMessage[];\n\ttokensBefore: number;\n\tdetails?: JsonValue;\n\tusage?: Usage;\n\tfromHook: boolean;\n}\n\nexport interface BranchSummaryEntry extends EntryBase {\n\ttype: \"branch_summary\";\n\tfromId: string | null;\n\tsummary: string;\n\tdetails?: JsonValue;\n\tusage?: Usage;\n\tfromHook: boolean;\n}\n\nexport interface CustomEntry extends EntryBase {\n\ttype: \"custom\";\n\tcustomType: string;\n\tdata?: JsonValue;\n}\n\n/** Convert an application-defined custom entry into model context. */\nexport type EntryProjector = (\n\tentry: CustomEntry,\n\tcontext: Context,\n) => AgentMessage[] | undefined | Promise<AgentMessage[] | undefined>;\n\nexport type Entry = MessageEntry | CompactionEntry | BranchSummaryEntry | CustomEntry;\n\n/** Entry supplied to a transaction before storage assigns sequence and timestamp. */\nexport type NewEntry<TEntry extends Entry = Entry> = TEntry extends Entry ? Omit<TEntry, \"seq\" | \"timestamp\"> : never;\n\nexport interface LaneConfiguration {\n\tmodel: { provider: string; modelId: string };\n\tthinkingLevel: ThinkingLevel;\n\tactiveToolNames: string[];\n}\n\nexport interface OperationMeta {\n\toperationId: string;\n\tlane: string;\n\tsourceTipId: string | null;\n\tstartedAt: number;\n\tintent:\n\t\t| { kind: \"run\"; promptEntryIds: string[] }\n\t\t| { kind: \"compaction\"; customInstructions?: string }\n\t\t| {\n\t\t\t\tkind: \"navigation\";\n\t\t\t\ttargetId: string | null;\n\t\t\t\tsummarize: boolean;\n\t\t\t\tlabel?: string;\n\t\t\t\tcustomInstructions?: string;\n\t\t };\n}\n\nexport type Control =\n\t| { status: \"running\" }\n\t| {\n\t\t\tstatus: \"cancel_requested\";\n\t\t\trequestedAt: number;\n\t };\n\nexport interface OperationError {\n\tcode: string;\n\tmessage: string;\n\tdetails?: JsonValue;\n}\n\nexport type TerminalStatus = \"completed\" | \"declined\" | \"aborted\" | \"failed\";\n\n/** Immutable lane-lived observation record written by one terminal transaction. */\nexport interface OperationResultRecord {\n\toperationId: string;\n\tkind: OperationMeta[\"intent\"][\"kind\"];\n\tstatus: TerminalStatus;\n\terror?: OperationError;\n\tfromTipId: string | null;\n\ttipId: string | null;\n\tstartedAt: number;\n\tendedAt: number;\n}\n\nexport type Continuation =\n\t| { kind: \"need_assistant\"; overflowRecoveryUsed: boolean }\n\t| { kind: \"may_finish\"; includeFinalAssistant: boolean };\n\n/** Checkpoint payload; the flat leaf literal replaces the old nested phase tag. */\nexport interface CheckpointData {\n\tcontinuation: Continuation;\n\ttriggerEntryId: string;\n}\n\nexport type InboxItemKind = \"steer\" | \"followUp\" | \"nextRun\" | \"write\";\n\nexport interface InboxItem {\n\tentryId: string;\n\tkind: InboxItemKind;\n}\n\nexport interface NormalizedRetryPolicy {\n\tmaxAttempts: number;\n\tbaseDelayMs: number;\n\tmaxAgentDelayMs: number;\n}\n\nexport interface GenerationContext {\n\tstepId: string;\n\ttriggerEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n\tretryPolicy: NormalizedRetryPolicy;\n\toverflowRecoveryUsed: boolean;\n}\n\ninterface ToolCallSource {\n\t/** Zero-based index in the assistant message's complete content array, not a filtered tool-call ordinal. */\n\tsourceIndex: number;\n\tresultEntryId: string;\n}\n\nexport type ToolCall = ToolCallSource &\n\t(\n\t\t| { status: \"planned\" }\n\t\t| { status: \"effect_pending\"; replay: \"never\" | \"safe\" }\n\t\t| { status: \"outcome_ready\"; terminate: boolean }\n\t\t| { status: \"completed\"; terminate: boolean }\n\t);\n\nexport interface ToolBatch {\n\tassistantEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tturnId: string;\n\tcalls: ToolCall[];\n}\n\nexport interface SummaryContext {\n\tresultEntryId: string;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n\tretryPolicy: NormalizedRetryPolicy;\n}\n\n/*\n * Durable operation state is one flat union with one family-neutral discriminator\n * per dispatcher leaf. ToolBatch/ToolCall remain the nested child collection state\n * machine, and cancellation stays orthogonal via Control.\n */\n\nexport interface Cancellable {\n\tcontrol: Control;\n}\n\nexport interface RunSettings {\n\tcompaction: CompactionSettings;\n\tsteeringMode: QueueMode;\n\tfollowUpMode: QueueMode;\n\ttoolExecution: \"sequential\" | \"parallel\";\n}\n\n/** Uniform scope carried by every operation leaf. */\nexport interface OperationScope extends Cancellable {\n\tsettings: RunSettings;\n\tlatestAssistantEntryId: string | null;\n}\n\n/** Shared backoff data for every retry-wait leaf. */\nexport interface RetryWait {\n\tnextAttempt: number;\n\tnotBefore: number;\n\terrorMessage: string;\n}\n\nexport interface AssistantGenerationScope {\n\tgenerationContext: GenerationContext;\n}\n\nexport type ResultBoundary =\n\t| { kind: \"resume_checkpoint\"; resumeAfter: CheckpointData }\n\t| { kind: \"finish\" }\n\t| { kind: \"commit_navigation\"; targetId: string; label?: string };\n\nexport interface SummaryTask {\n\ttaskId: string;\n\treason?: \"manual\" | \"threshold\" | \"overflow\";\n\tcustomInstructions?: string;\n\tboundary: ResultBoundary;\n}\n\nexport interface SummaryGenerationScope {\n\ttask: SummaryTask;\n\tsummaryContext: SummaryContext;\n}\n\nexport interface SummaryGenerationReady extends SummaryGenerationScope {\n\tnextAttempt: number;\n}\n\nexport interface SummaryGenerationEffectPending extends SummaryGenerationScope {\n\tattempt: number;\n\trequest?: { index: number; usageId: string };\n\tusageIds: string[];\n}\n\nexport interface SummaryGenerationRetryWait extends SummaryGenerationScope, RetryWait {}\n\nexport interface DeferredScope extends OperationScope {\n\tstepId: string;\n\tsourceEntryId: string;\n\tpoll: number;\n\tconfiguration: LaneConfiguration;\n\tstreamOptions: AgentHarnessStreamOptions;\n}\n\nexport interface StartingOperation extends OperationScope {\n\tat: \"starting\";\n}\n\nexport interface CheckpointOperation extends OperationScope, CheckpointData {\n\tat: \"checkpoint\";\n}\n\nexport interface AssistantReadyOperation extends OperationScope, AssistantGenerationScope {\n\tat: \"assistant.ready\";\n\tnextAttempt: number;\n}\n\nexport interface AssistantEffectPendingOperation extends OperationScope, AssistantGenerationScope {\n\tat: \"assistant.effect_pending\";\n\tattempt: number;\n\tresponseEntryId: string;\n\tusageId: string;\n\tintendedOutputLimit: number;\n\tcontextWindow: number;\n}\n\nexport interface AssistantRetryWaitOperation extends OperationScope, AssistantGenerationScope, RetryWait {\n\tat: \"assistant.retry_wait\";\n}\n\nexport interface ToolsOperation extends OperationScope {\n\tat: \"tools\";\n\tbatch: ToolBatch;\n}\n\nexport interface DeferredSuspendedOperation extends DeferredScope {\n\tat: \"deferred.suspended\";\n}\n\nexport interface DeferredEffectPendingOperation extends DeferredScope {\n\tat: \"deferred.effect_pending\";\n\tresponseEntryId: string;\n\tusageId: string;\n}\n\nexport interface SummaryDecidingOperation extends OperationScope {\n\tat: \"summary.deciding\";\n\ttask: SummaryTask;\n}\n\nexport interface SummaryReadyOperation extends OperationScope, SummaryGenerationReady {\n\tat: \"summary.ready\";\n}\n\nexport interface SummaryEffectPendingOperation extends OperationScope, SummaryGenerationEffectPending {\n\tat: \"summary.effect_pending\";\n}\n\nexport interface SummaryRetryWaitOperation extends OperationScope, SummaryGenerationRetryWait {\n\tat: \"summary.retry_wait\";\n}\n\nexport interface NavigationReadyToCommitOperation extends OperationScope {\n\tat: \"navigation.ready_to_commit\";\n\t/** Unsummarized navigation may target the branch root (null). */\n\ttargetId: string | null;\n\tlabel?: string;\n}\n\n/** Flat durable operation state: exactly 13 family-neutral dispatcher leaves. */\nexport type OperationState =\n\t| StartingOperation\n\t| CheckpointOperation\n\t| AssistantReadyOperation\n\t| AssistantEffectPendingOperation\n\t| AssistantRetryWaitOperation\n\t| ToolsOperation\n\t| DeferredSuspendedOperation\n\t| DeferredEffectPendingOperation\n\t| SummaryDecidingOperation\n\t| SummaryReadyOperation\n\t| SummaryEffectPendingOperation\n\t| SummaryRetryWaitOperation\n\t| NavigationReadyToCommitOperation;\n\nexport type OperationAt = OperationState[\"at\"];\n\n/** Copy only the uniform operation scope when constructing a successor leaf. */\nexport function operationScopeOf(state: OperationState): OperationScope {\n\treturn {\n\t\tcontrol: state.control,\n\t\tsettings: state.settings,\n\t\tlatestAssistantEntryId: state.latestAssistantEntryId,\n\t};\n}\n\nexport type Operation = { meta: OperationMeta; state: OperationState };\n\nexport interface LaneState {\n\tcurrentOperationId: string | null;\n\tlastOperationId: string | null;\n\tinbox: InboxItem[];\n}\n\nexport type PendingEntry =\n\t| { type: \"message\"; payload: AgentMessage }\n\t| { type: \"custom\"; customType: string; payload?: JsonValue };\n\nexport interface DurableFileOperations {\n\tread: string[];\n\twritten: string[];\n\tedited: string[];\n}\n\nexport type DurableStructuralPreparation =\n\t| {\n\t\t\tkind: \"compaction\";\n\t\t\tmessagesToSummarize: CompactionPreparation[\"messagesToSummarize\"];\n\t\t\tturnPrefixMessages: CompactionPreparation[\"turnPrefixMessages\"];\n\t\t\tretainedTail: CompactionPreparation[\"retainedTail\"];\n\t\t\tisSplitTurn: boolean;\n\t\t\ttokensBefore: number;\n\t\t\tpreviousSummary?: string;\n\t\t\tfileOps: DurableFileOperations;\n\t\t\tsettings: CompactionSettings;\n\t }\n\t| {\n\t\t\tkind: \"branch_summary\";\n\t\t\tmessages: BranchPreparation[\"messages\"];\n\t\t\tfileOps: DurableFileOperations;\n\t\t\ttotalTokens: number;\n\t };\n\nexport interface UsageRow {\n\tid: string;\n\tseq: number;\n\tusage: Usage;\n\tentryId?: string;\n\tadjustment: boolean;\n\tdetails?: JsonValue;\n}\n\nexport interface EntryWrite {\n\tkind: \"entry\";\n\tentry: NewEntry;\n}\n\nexport interface UsageWrite {\n\tkind: \"usage\";\n\trow: Omit<UsageRow, \"seq\">;\n}\n\nexport type Write = EntryWrite | UsageWrite | ValueWrite | ListWrite;\n\nexport interface CommitResult {\n\tfirstSeq: number;\n\tseqs: number[];\n\ttimestamp: number;\n\t/** Session totals immediately after this commit was applied. */\n\tstats: SessionStats;\n}\n\nexport interface EntryStructure {\n\tid: string;\n\tparentId: string | null;\n\tseq: number;\n\ttimestamp: number;\n\ttype: EntryType;\n\tcustomType?: string;\n}\n\nexport interface EntryCursor {\n\tseq: number;\n}\n\nexport interface BranchScan {\n\tstart?: string;\n\tstopAtType?: EntryType;\n\tstopAtId?: string;\n\ttype?: EntryType;\n\tcustomType?: string;\n\torder?: \"newestFirst\" | \"oldestFirst\";\n\tlimit?: number;\n\tcursor?: EntryCursor;\n}\n\nexport type StorageBranchScan = BranchScan & { start: string };\n\nexport interface EntryScan {\n\ttype?: EntryType;\n\tcustomType?: string;\n\tfromSeq?: number;\n\ttoSeq?: number;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n}\n\nexport interface UsageScan {\n\tfromSeq?: number;\n\ttoSeq?: number;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n}\n\nexport interface SessionStats {\n\tmessageCount: number;\n\tusage: Usage;\n}\n\nexport interface Storage {\n\tcommit(writes: Write[], context: Context): Promise<CommitResult>;\n\tgetEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;\n\tgetValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;\n\tscanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;\n\treadList<T>(\n\t\taddress: ValueList<T>,\n\t\toptions: ListReadOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<ListElement<T>[]>;\n\tscanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;\n\tscanBranchStructure(query: StorageBranchScan, context: Context): Promise<EntryStructure[]>;\n\tscanEntries(query: EntryScan, context: Context): Promise<Entry[]>;\n\tscanUsage(query: UsageScan, context: Context): Promise<UsageRow[]>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tclose(context: Context): Promise<void>;\n}\n\nexport interface SessionMetadata {\n\tid: string;\n\tcreatedAt: number;\n\tstorageVersion: number;\n\tcwd?: string;\n\tparentSessionId?: string;\n\tlegacyParentSessionPath?: string;\n}\n\nexport interface IdGenerator {\n\tnext(timestampMs?: number): string;\n}\n\nexport interface EntryQuery {\n\ttype?: EntryType;\n\tcustomType?: string;\n\torder?: \"asc\" | \"desc\";\n\tlimit?: number;\n\tcursor?: EntryCursor;\n}\n\nexport interface SessionReader {\n\tgetEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tgetValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;\n\tscanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;\n\treadList<T>(\n\t\taddress: ValueList<T>,\n\t\toptions: ListReadOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<ListElement<T>[]>;\n\t/** Scan a branch from an explicit entry while this reader capability remains valid. */\n\tscanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;\n}\n\n/** Exclusive keyless mutation barrier for one Session. */\nexport interface SessionMutation extends SessionReader {\n\t/** Exactly zero or one commit attempt. A second attempt rejects. */\n\tcommit(writes: Write[], context: Context): Promise<CommitResult>;\n\t/** Wait for any commit attempt, invalidate the capability, and release the barrier. */\n\tend(context: Context): Promise<void>;\n}\n\n/** Callback-scoped mutation capability without authority to release its Session barrier. */\nexport type SessionMutator = Omit<SessionMutation, \"end\">;\n\nexport type SessionMutationCallback<T> = (mutator: SessionMutator, context: Context) => T | Promise<T>;\n\nexport interface Branch {\n\treadonly name: string;\n\tgetTipId(context: Context): Promise<string | null>;\n\tfindEntries(query: BranchScan | undefined, context: Context): Promise<Entry[]>;\n\tfindEntry(query: BranchScan | undefined, context: Context): Promise<Entry | undefined>;\n\tappendMessage(message: AgentMessage, context: Context): Promise<string>;\n\tappendCustomEntry(customType: string, data: JsonValue | undefined, context: Context): Promise<string>;\n}\n\nexport interface Session<TMetadata extends SessionMetadata = SessionMetadata> extends SessionReader {\n\treadonly metadata: TMetadata;\n\treadonly idGenerator: IdGenerator;\n\tgetEntry(id: string, context: Context): Promise<Entry | undefined>;\n\tgetStats(context: Context): Promise<SessionStats>;\n\tgetName(context: Context): Promise<string | undefined>;\n\tgetLabel(targetId: string, context: Context): Promise<string | undefined>;\n\tfindEntries(query: EntryQuery | undefined, context: Context): Promise<Entry[]>;\n\tfindEntry(query: EntryQuery | undefined, context: Context): Promise<Entry | undefined>;\n\tbranch(name: string, context: Context): Promise<Branch | undefined>;\n\tcreateBranch(name: string, at: string | null, context: Context): Promise<Branch>;\n\tbeginMutation(context: Context): Promise<SessionMutation>;\n\t/**\n\t * Trusted exclusive callback over the Session mutation line. Calling a public Session writer from\n\t * this callback queues it behind the callback; awaiting that nested writer therefore deadlocks.\n\t * Use the supplied mutator for the callback's sole commit.\n\t */\n\tmutate<T>(mutation: SessionMutationCallback<T>, context: Context): Promise<T>;\n\tsetValue<T>(address: Value<T>, next: NoInfer<T>, context: Context): Promise<void>;\n\tdeleteValue<T>(address: Value<T>, context: Context): Promise<void>;\n\tappendList<T>(address: ValueList<T>, element: NoInfer<T>, context: Context): Promise<void>;\n\tdeleteList<T>(address: ValueList<T>, context: Context): Promise<void>;\n\tsetName(name: string | undefined, context: Context): Promise<void>;\n\tsetLabel(targetId: string, label: string | undefined, context: Context): Promise<void>;\n\tclose(context: Context): Promise<void>;\n}\n\nexport interface SessionCreateOptions {\n\tid?: string;\n\tparentSessionId?: string;\n}\n\nexport type ForkOptions =\n\t| {\n\t\t\t/**\n\t\t\t * Copy one path from a complete configured source AgentLane under the same\n\t\t\t * Branch name, with copied configuration and fresh idle lane state.\n\t\t\t */\n\t\t\tscope: \"branch\";\n\t\t\t/** Source Branch to copy. */\n\t\t\tbranch: string;\n\t\t\t/** Entry on the source Branch's current tip ancestry. Defaults to the current tip. */\n\t\t\tentryId?: string;\n\t\t\t/**\n\t\t\t * Whether the fork includes the selected entry or stops at its parent.\n\t\t\t * Defaults to including the selected entry.\n\t\t\t */\n\t\t\tposition?: \"before\" | \"at\";\n\t\t\t/** Optional destination session id. */\n\t\t\tid?: string;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Copy the whole conversation tree and every Branch tip. Each configured\n\t\t\t * AgentLane copies configuration plus fresh idle state; data-only Branches\n\t\t\t * remain data-only. Operation/pending/result/usage state is excluded.\n\t\t\t */\n\t\t\tscope: \"tree\";\n\t\t\t/** Optional destination session id. */\n\t\t\tid?: string;\n\t };\n\nexport interface SessionRepo<\n\tTMetadata extends SessionMetadata = SessionMetadata,\n\tTCreateOptions extends { id?: string; parentSessionId?: string } = SessionCreateOptions,\n\tTListOptions = void,\n> {\n\tcreate(options: TCreateOptions, context: Context): Promise<Session<TMetadata>>;\n\topen(metadata: TMetadata, context: Context): Promise<Session<TMetadata>>;\n\tlist(options: TListOptions | undefined, context: Context): Promise<TMetadata[]>;\n\tdelete(metadata: TMetadata, context: Context): Promise<void>;\n\tfork(source: TMetadata, options: ForkOptions, context: Context): Promise<Session<TMetadata>>;\n}\n"]}
|
package/dist/harness/types.d.ts
CHANGED
|
@@ -158,6 +158,18 @@ export interface FileInfo {
|
|
|
158
158
|
/** Modification time as milliseconds since Unix epoch. */
|
|
159
159
|
mtimeMs: number;
|
|
160
160
|
}
|
|
161
|
+
/** One UTF-8 line read from a text file. */
|
|
162
|
+
export interface TextLine {
|
|
163
|
+
text: string;
|
|
164
|
+
/** Whether the line ended with `\n`; callers use this to discard a torn final record. */
|
|
165
|
+
terminated: boolean;
|
|
166
|
+
}
|
|
167
|
+
/** Pull-based UTF-8 line reader that preserves final-line termination. */
|
|
168
|
+
export interface TextLineReader {
|
|
169
|
+
readLine(context: Context): Promise<Result<TextLine | undefined, FileError>>;
|
|
170
|
+
/** Release the open file. Must be best-effort and must not throw or reject. */
|
|
171
|
+
close(context: Context): Promise<void>;
|
|
172
|
+
}
|
|
161
173
|
/**
|
|
162
174
|
* Filesystem capability used by the harness.
|
|
163
175
|
*
|
|
@@ -176,6 +188,8 @@ export interface FileSystem {
|
|
|
176
188
|
joinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;
|
|
177
189
|
/** Read a UTF-8 text file. */
|
|
178
190
|
readTextFile(path: string, context: Context): Promise<Result<string, FileError>>;
|
|
191
|
+
/** Open a UTF-8 text file for pull-based line reading. */
|
|
192
|
+
openTextLineReader(path: string, context: Context): Promise<Result<TextLineReader, FileError>>;
|
|
179
193
|
/** Read UTF-8 text lines. Implementations should stop once `maxLines` lines have been read. */
|
|
180
194
|
readTextLines(path: string, options: {
|
|
181
195
|
maxLines?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/harness/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,uGAAuG;AACvG,MAAM,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,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EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACjE;AAED,sDAAsD;AACtD,MAAM,WAAW,KAAK;IACrB,0FAA0F;IAC1F,IAAI,CACH,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,GAAG,SAAS,EACrC,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC;IACpD,iFAAiF;IACjF,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC;AAED,wEAAwE;AACxE,MAAM,WAAW,YAAa,SAAQ,UAAU,EAAE,KAAK;CAAG","sourcesContent":["import type { SimpleStreamOptions, Transport } from \"@earendil-works/pi-ai\";\nimport type { Static, TSchema } from \"typebox\";\nimport type { AgentTool, AgentToolResult } from \"../types.ts\";\nimport type { Context } from \"./context.ts\";\nimport type { JsonValue } from \"./session/types.ts\";\nimport type { TruncationResult } from \"./utils/truncate.ts\";\n\n/** Result of a fallible operation. Expected failures are returned as `ok: false` instead of thrown. */\nexport type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\n/** Create a successful {@link Result}. */\nexport function ok<TValue, TError>(value: TValue): Result<TValue, TError> {\n\treturn { ok: true, value };\n}\n\n/** Create a failed {@link Result}. */\nexport function err<TValue, TError>(error: TError): Result<TValue, TError> {\n\treturn { ok: false, error };\n}\n\n/** Return the success value or throw the failure error. Intended for tests and explicit adapter boundaries. */\nexport function getOrThrow<TValue, TError>(result: Result<TValue, TError>): TValue {\n\tif (!result.ok) throw result.error;\n\treturn result.value;\n}\n\n/** Return the success value or `undefined`. Only object values are allowed to avoid truthiness bugs with primitives. */\nexport function getOrUndefined<TValue extends object, TError>(result: Result<TValue, TError>): TValue | undefined {\n\treturn result.ok ? result.value : undefined;\n}\n\n/** Normalize unknown thrown values into Error instances before using them as typed error causes. */\nexport function toError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\tif (typeof error === \"string\") return new Error(error);\n\ttry {\n\t\treturn new Error(JSON.stringify(error));\n\t} catch {\n\t\treturn new Error(String(error));\n\t}\n}\n\n/**\n * Skill loaded from a `SKILL.md` file or provided by an application.\n *\n * `name`, `description`, and `filePath` are inserted into the system prompt in an XML-formatted block as suggested by agentskills.io.\n * Use {@link formatSkillsForSystemPrompt} to generate the spec-compatible system prompt block.\n */\nexport interface Skill {\n\t/** Stable skill name used for lookup and model-visible listings. */\n\tname: string;\n\t/** Short model-visible description of when to use the skill. */\n\tdescription: string;\n\t/** Full skill instructions. */\n\tcontent: string;\n\t/** Absolute path to the skill file. Used for model-visible location and resolving relative references. */\n\tfilePath: string;\n\t/** Exclude this skill from model-visible skill lists while still allowing explicit application invocation. */\n\tdisableModelInvocation?: boolean;\n}\n\n/** Prompt template that can be formatted into a prompt for explicit invocation. */\nexport interface PromptTemplate {\n\t/** Stable template name used for lookup or application command routing. */\n\tname: string;\n\t/** Optional description for command lists or autocomplete. */\n\tdescription?: string;\n\t/** Template content. Argument placeholders are formatted by `formatPromptTemplateInvocation`. */\n\tcontent: string;\n}\n\n/** Resources made available to explicit invocation methods and system-prompt callbacks. */\nexport interface AgentHarnessResources<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\t/** Prompt templates available for explicit invocation. */\n\tpromptTemplates?: TPromptTemplate[];\n\t/** Skills available to the model and explicit skill invocation. */\n\tskills?: TSkill[];\n}\n\n/** Options for one live harness tool progress update. */\nexport interface AgentHarnessToolUpdateOptions {\n\t/** Request replacement of this invocation's durable recovery checkpoint. */\n\tcheckpoint?: true;\n}\n\n/** Synchronous full-snapshot progress callback supplied to harness-native tools. */\nexport type AgentHarnessToolUpdateCallback<TDetails> = (\n\tpartialResult: AgentToolResult<TDetails>,\n\toptions?: AgentHarnessToolUpdateOptions,\n) => void;\n\n/** Stable harness identity for one logical tool call, unchanged during safe replay. */\nexport interface AgentHarnessToolInvocation {\n\t/** Opaque session-unique id equal to the call's reserved result-entry id. */\n\treadonly invocationId: string;\n\treadonly operationId: string;\n\treadonly turnId: string;\n\t/** Read one invocation-scoped durable replay memo. */\n\tgetMemo(name: string): Promise<JsonValue | undefined>;\n\t/** Set or delete one invocation-scoped durable replay memo. */\n\tsetMemo(name: string, value: JsonValue | undefined): Promise<void>;\n}\n\n/** Tool definition executed by an {@link AgentHarness} with an application-defined context. */\nexport type AgentHarnessTool<\n\tTContext extends object | undefined,\n\tTParameters extends TSchema = TSchema,\n\tTDetails = unknown,\n> = Omit<AgentTool<TParameters, TDetails>, \"execute\"> & {\n\t/** Execute the tool call with the context resolved for the current turn snapshot. */\n\texecute(\n\t\ttoolCallId: string,\n\t\tparams: Static<TParameters>,\n\t\tonUpdate: AgentHarnessToolUpdateCallback<TDetails>,\n\t\ttoolContext: TContext,\n\t\tinvocation: AgentHarnessToolInvocation,\n\t\tcontext: Context,\n\t): Promise<AgentToolResult<TDetails>>;\n};\n\n/** Static tool context or provider resolved for each turn snapshot. */\nexport type AgentHarnessToolContextSource<TContext extends object | undefined> =\n\t| TContext\n\t| ((context: Context) => TContext | Promise<TContext>);\n\n/** Curated provider request options owned by the harness and snapshotted per turn. */\nexport interface AgentHarnessStreamOptions {\n\t/** Preferred transport forwarded to the stream function. */\n\ttransport?: Transport;\n\t/** Provider request timeout in milliseconds. */\n\ttimeoutMs?: number;\n\t/** Maximum provider retry attempts. */\n\tmaxRetries?: number;\n\t/** Optional cap for provider-requested retry delays. */\n\tmaxRetryDelayMs?: number;\n\t/** Additional request headers merged with auth and lifecycle headers. */\n\theaders?: Record<string, string>;\n\t/** Provider metadata forwarded with requests. */\n\tmetadata?: SimpleStreamOptions[\"metadata\"];\n\t/** Provider cache retention hint. */\n\tcacheRetention?: SimpleStreamOptions[\"cacheRetention\"];\n\t/** Ask a capable provider to continue generation asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n}\n\n/** Per-request stream option patch returned by provider hooks. */\nexport interface AgentHarnessStreamOptionsPatch\n\textends Omit<Partial<AgentHarnessStreamOptions>, \"headers\" | \"metadata\"> {\n\t/** Header patch. `undefined` values delete keys; explicit `headers: undefined` clears all headers. */\n\theaders?: Record<string, string | undefined>;\n\t/** Metadata patch. `undefined` values delete keys; explicit `metadata: undefined` clears all metadata. */\n\tmetadata?: Record<string, unknown | undefined>;\n}\n\n/** Kind of filesystem object as addressed by a {@link FileSystem}. Symlinks are not followed automatically. */\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\n/** Stable, backend-independent file error codes returned by {@link FileSystem} file operations. */\nexport type FileErrorCode =\n\t| \"aborted\"\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\n/** Error returned by {@link FileSystem} file operations. */\nexport class FileError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: FileErrorCode;\n\t/** Absolute addressed path associated with the failure, when available. */\n\tpublic path?: string;\n\n\tconstructor(code: FileErrorCode, message: string, path?: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"FileError\";\n\t\tthis.code = code;\n\t\tthis.path = path;\n\t}\n}\n\n/** Stable, backend-independent execution error codes returned by {@link ExecutionEnv.exec}. */\nexport type ExecutionErrorCode =\n\t| \"aborted\"\n\t| \"timeout\"\n\t| \"shell_unavailable\"\n\t| \"spawn_error\"\n\t| \"callback_error\"\n\t| \"unknown\";\n\n/** Error returned by {@link ExecutionEnv.exec}. */\nexport class ExecutionError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: ExecutionErrorCode;\n\n\tconstructor(code: ExecutionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"ExecutionError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Stable compaction error codes returned by compaction helpers. */\nexport type CompactionErrorCode = \"aborted\" | \"summarization_failed\";\n\n/** Error returned by compaction helpers. */\nexport class CompactionError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: CompactionErrorCode;\n\n\tconstructor(code: CompactionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"CompactionError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Stable branch-summary error codes returned by branch summarization helpers. */\nexport type BranchSummaryErrorCode = \"aborted\" | \"summarization_failed\";\n\n/** Error returned by branch summarization helpers. */\nexport class BranchSummaryError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: BranchSummaryErrorCode;\n\n\tconstructor(code: BranchSummaryErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"BranchSummaryError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Metadata for one filesystem object in a {@link FileSystem}. */\nexport interface FileInfo {\n\t/** Basename of {@link path}. */\n\tname: string;\n\t/** Absolute, syntactically normalized addressed path in the execution environment. Symlinks are not followed. */\n\tpath: string;\n\t/** Object kind. Symlink targets are not followed; use {@link FileSystem.canonicalPath} explicitly. */\n\tkind: FileKind;\n\t/** Size in bytes for the addressed filesystem object. */\n\tsize: number;\n\t/** Modification time as milliseconds since Unix epoch. */\n\tmtimeMs: number;\n}\n\n/**\n * Filesystem capability used by the harness.\n *\n * Paths passed to methods may be absolute or relative to {@link cwd}. Paths returned by file operations are addressed paths\n * in the filesystem namespace, but are not canonicalized through symlinks unless returned by {@link canonicalPath}.\n *\n * Operation methods must never throw or reject. All filesystem failures, including unexpected backend failures, must be\n * encoded in the returned {@link Result}. Implementations must preserve this invariant.\n */\nexport interface FileSystem {\n\t/** Current working directory for relative paths. */\n\tcwd: string;\n\n\t/** Return an absolute addressed path without requiring it to exist and without resolving symlinks. */\n\tabsolutePath(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Join path segments in the filesystem namespace without requiring the result to exist. */\n\tjoinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;\n\t/** Read a UTF-8 text file. */\n\treadTextFile(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Read UTF-8 text lines. Implementations should stop once `maxLines` lines have been read. */\n\treadTextLines(\n\t\tpath: string,\n\t\toptions: { maxLines?: number } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string[], FileError>>;\n\t/** Read a binary file. */\n\treadBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/** Create or overwrite a file, creating parent directories when supported. */\n\twriteFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Create or append to a file, creating parent directories when supported. */\n\tappendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Atomically rename a file, replacing the destination when it exists. Does not copy across filesystems. */\n\trenameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;\n\t/** Return metadata for the addressed path without following symlinks. */\n\tfileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;\n\t/** List direct children of a directory without following symlinks. */\n\tlistDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;\n\t/** Return the canonical path for an existing path, resolving symlinks where supported. */\n\tcanonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Return false for missing paths. Other errors, such as permission failures, return a {@link FileError}. */\n\texists(path: string, context: Context): Promise<Result<boolean, FileError>>;\n\t/** Create a directory. Defaults to `recursive: true`. */\n\tcreateDir(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\t/** Remove a file or directory. Defaults to `recursive: false` and `force: false`. */\n\tremove(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean; force?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\t/** Create a temporary directory and return its absolute path. Defaults to `prefix: \"tmp-\"`. */\n\tcreateTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;\n\t/** Create a temporary file and return its absolute path. Defaults to `prefix: \"\"` and `suffix: \"\"`. */\n\tcreateTempFile(\n\t\toptions: { prefix?: string; suffix?: string } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string, FileError>>;\n\n\t/** Release filesystem resources. Must be best-effort and must not throw or reject. */\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Which portion of bounded output survives after the limit is crossed. */\nexport type ShellOutputRetention = \"head\" | \"tail\";\n\n/** Source-side limits for one combined shell output view. */\nexport interface ShellOutputLimits {\n\tmaxBytes: number;\n\tmaxLines: number;\n\t/** Defaults to `\"tail\"`. */\n\tretain?: ShellOutputRetention;\n}\n\n/** Bounded shell capture requested by the caller. */\nexport interface ShellOutputCaptureOptions {\n\tlimits: ShellOutputLimits;\n\t/** Preserve complete output in an execution-environment-local file after the limits are crossed. */\n\tspill?: boolean;\n}\n\n/** Truncation metadata without a duplicate copy of the retained text. */\nexport type ShellOutputTruncation = Omit<TruncationResult, \"content\">;\n\n/** Metadata accompanying a bounded shell output view. */\nexport interface ShellOutputMetadata {\n\ttruncation: ShellOutputTruncation;\n\tspillPath?: string;\n\tlastLineBytes?: number;\n}\n\n/** Complete bounded shell output view. */\nexport interface ShellOutputView extends ShellOutputMetadata {\n\ttext: string;\n}\n\n/** Incremental source-side change to one bounded shell output view. */\nexport type ShellOutputUpdate =\n\t| { kind: \"replace\"; output: ShellOutputView }\n\t| { kind: \"append\"; text: string; metadata: ShellOutputMetadata }\n\t| { kind: \"slide\"; drop: number; text: string; metadata: ShellOutputMetadata }\n\t| { kind: \"metadata\"; metadata: ShellOutputMetadata };\n\n/** Bounded shell completion. Output text is delivered through {@link ShellExecOptions.onUpdate}. */\nexport interface ShellExecResult extends ShellOutputMetadata {\n\texitCode: number;\n}\n\n/** Options for {@link Shell.exec}. */\nexport interface ShellExecOptions {\n\t/** Working directory for the command. Relative paths are resolved against {@link ExecutionEnv.cwd}. Defaults to {@link ExecutionEnv.cwd}. */\n\tcwd?: string;\n\t/** Environment variables for the command. Values override inherited defaults when `inheritEnv` is true. */\n\tenv?: Record<string, string>;\n\t/** Whether to inherit the execution environment's default variables. Defaults to true. */\n\tinheritEnv?: boolean;\n\t/** Timeout in seconds. Implementations should return a timeout error when the command exceeds this duration. Defaults to no timeout. */\n\ttimeout?: number;\n\t/** Source-side bounded capture. Output is discarded when this and `onUpdate` are both absent. */\n\tcapture?: ShellOutputCaptureOptions;\n\t/** Called with bounded output changes. */\n\tonUpdate?: (update: ShellOutputUpdate, context: Context) => void;\n}\n\n/** Shell execution capability used by the harness. */\nexport interface Shell {\n\t/** Execute a shell command in {@link FileSystem.cwd} unless `options.cwd` is provided. */\n\texec(\n\t\tcommand: string,\n\t\toptions: ShellExecOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<ShellExecResult, ExecutionError>>;\n\t/** Release shell resources. Must be best-effort and must not throw or reject. */\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Filesystem and process execution environment used by the harness. */\nexport interface ExecutionEnv extends FileSystem, Shell {}\n"]}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/harness/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,uGAAuG;AACvG,MAAM,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAA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AE,CAAC;AAEvD,oGAAoG;AACpG,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC3D,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,sCAAsC;AACtC,MAAM,WAAW,gBAAgB;IAChC,6IAA6I;IAC7I,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2GAA2G;IAC3G,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,0FAA0F;IAC1F,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wIAAwI;IACxI,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iGAAiG;IACjG,OAAO,CAAC,EAAE,yBAAyB,CAAC;IACpC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACjE;AAED,sDAAsD;AACtD,MAAM,WAAW,KAAK;IACrB,0FAA0F;IAC1F,IAAI,CACH,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,GAAG,SAAS,EACrC,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC;IACpD,iFAAiF;IACjF,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC;AAED,wEAAwE;AACxE,MAAM,WAAW,YAAa,SAAQ,UAAU,EAAE,KAAK;CAAG","sourcesContent":["import type { SimpleStreamOptions, Transport } from \"@earendil-works/pi-ai\";\nimport type { Static, TSchema } from \"typebox\";\nimport type { AgentTool, AgentToolResult } from \"../types.ts\";\nimport type { Context } from \"./context.ts\";\nimport type { JsonValue } from \"./session/types.ts\";\nimport type { TruncationResult } from \"./utils/truncate.ts\";\n\n/** Result of a fallible operation. Expected failures are returned as `ok: false` instead of thrown. */\nexport type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\n/** Create a successful {@link Result}. */\nexport function ok<TValue, TError>(value: TValue): Result<TValue, TError> {\n\treturn { ok: true, value };\n}\n\n/** Create a failed {@link Result}. */\nexport function err<TValue, TError>(error: TError): Result<TValue, TError> {\n\treturn { ok: false, error };\n}\n\n/** Return the success value or throw the failure error. Intended for tests and explicit adapter boundaries. */\nexport function getOrThrow<TValue, TError>(result: Result<TValue, TError>): TValue {\n\tif (!result.ok) throw result.error;\n\treturn result.value;\n}\n\n/** Return the success value or `undefined`. Only object values are allowed to avoid truthiness bugs with primitives. */\nexport function getOrUndefined<TValue extends object, TError>(result: Result<TValue, TError>): TValue | undefined {\n\treturn result.ok ? result.value : undefined;\n}\n\n/** Normalize unknown thrown values into Error instances before using them as typed error causes. */\nexport function toError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\tif (typeof error === \"string\") return new Error(error);\n\ttry {\n\t\treturn new Error(JSON.stringify(error));\n\t} catch {\n\t\treturn new Error(String(error));\n\t}\n}\n\n/**\n * Skill loaded from a `SKILL.md` file or provided by an application.\n *\n * `name`, `description`, and `filePath` are inserted into the system prompt in an XML-formatted block as suggested by agentskills.io.\n * Use {@link formatSkillsForSystemPrompt} to generate the spec-compatible system prompt block.\n */\nexport interface Skill {\n\t/** Stable skill name used for lookup and model-visible listings. */\n\tname: string;\n\t/** Short model-visible description of when to use the skill. */\n\tdescription: string;\n\t/** Full skill instructions. */\n\tcontent: string;\n\t/** Absolute path to the skill file. Used for model-visible location and resolving relative references. */\n\tfilePath: string;\n\t/** Exclude this skill from model-visible skill lists while still allowing explicit application invocation. */\n\tdisableModelInvocation?: boolean;\n}\n\n/** Prompt template that can be formatted into a prompt for explicit invocation. */\nexport interface PromptTemplate {\n\t/** Stable template name used for lookup or application command routing. */\n\tname: string;\n\t/** Optional description for command lists or autocomplete. */\n\tdescription?: string;\n\t/** Template content. Argument placeholders are formatted by `formatPromptTemplateInvocation`. */\n\tcontent: string;\n}\n\n/** Resources made available to explicit invocation methods and system-prompt callbacks. */\nexport interface AgentHarnessResources<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\t/** Prompt templates available for explicit invocation. */\n\tpromptTemplates?: TPromptTemplate[];\n\t/** Skills available to the model and explicit skill invocation. */\n\tskills?: TSkill[];\n}\n\n/** Options for one live harness tool progress update. */\nexport interface AgentHarnessToolUpdateOptions {\n\t/** Request replacement of this invocation's durable recovery checkpoint. */\n\tcheckpoint?: true;\n}\n\n/** Synchronous full-snapshot progress callback supplied to harness-native tools. */\nexport type AgentHarnessToolUpdateCallback<TDetails> = (\n\tpartialResult: AgentToolResult<TDetails>,\n\toptions?: AgentHarnessToolUpdateOptions,\n) => void;\n\n/** Stable harness identity for one logical tool call, unchanged during safe replay. */\nexport interface AgentHarnessToolInvocation {\n\t/** Opaque session-unique id equal to the call's reserved result-entry id. */\n\treadonly invocationId: string;\n\treadonly operationId: string;\n\treadonly turnId: string;\n\t/** Read one invocation-scoped durable replay memo. */\n\tgetMemo(name: string): Promise<JsonValue | undefined>;\n\t/** Set or delete one invocation-scoped durable replay memo. */\n\tsetMemo(name: string, value: JsonValue | undefined): Promise<void>;\n}\n\n/** Tool definition executed by an {@link AgentHarness} with an application-defined context. */\nexport type AgentHarnessTool<\n\tTContext extends object | undefined,\n\tTParameters extends TSchema = TSchema,\n\tTDetails = unknown,\n> = Omit<AgentTool<TParameters, TDetails>, \"execute\"> & {\n\t/** Execute the tool call with the context resolved for the current turn snapshot. */\n\texecute(\n\t\ttoolCallId: string,\n\t\tparams: Static<TParameters>,\n\t\tonUpdate: AgentHarnessToolUpdateCallback<TDetails>,\n\t\ttoolContext: TContext,\n\t\tinvocation: AgentHarnessToolInvocation,\n\t\tcontext: Context,\n\t): Promise<AgentToolResult<TDetails>>;\n};\n\n/** Static tool context or provider resolved for each turn snapshot. */\nexport type AgentHarnessToolContextSource<TContext extends object | undefined> =\n\t| TContext\n\t| ((context: Context) => TContext | Promise<TContext>);\n\n/** Curated provider request options owned by the harness and snapshotted per turn. */\nexport interface AgentHarnessStreamOptions {\n\t/** Preferred transport forwarded to the stream function. */\n\ttransport?: Transport;\n\t/** Provider request timeout in milliseconds. */\n\ttimeoutMs?: number;\n\t/** Maximum provider retry attempts. */\n\tmaxRetries?: number;\n\t/** Optional cap for provider-requested retry delays. */\n\tmaxRetryDelayMs?: number;\n\t/** Additional request headers merged with auth and lifecycle headers. */\n\theaders?: Record<string, string>;\n\t/** Provider metadata forwarded with requests. */\n\tmetadata?: SimpleStreamOptions[\"metadata\"];\n\t/** Provider cache retention hint. */\n\tcacheRetention?: SimpleStreamOptions[\"cacheRetention\"];\n\t/** Ask a capable provider to continue generation asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n}\n\n/** Per-request stream option patch returned by provider hooks. */\nexport interface AgentHarnessStreamOptionsPatch\n\textends Omit<Partial<AgentHarnessStreamOptions>, \"headers\" | \"metadata\"> {\n\t/** Header patch. `undefined` values delete keys; explicit `headers: undefined` clears all headers. */\n\theaders?: Record<string, string | undefined>;\n\t/** Metadata patch. `undefined` values delete keys; explicit `metadata: undefined` clears all metadata. */\n\tmetadata?: Record<string, unknown | undefined>;\n}\n\n/** Kind of filesystem object as addressed by a {@link FileSystem}. Symlinks are not followed automatically. */\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\n/** Stable, backend-independent file error codes returned by {@link FileSystem} file operations. */\nexport type FileErrorCode =\n\t| \"aborted\"\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\n/** Error returned by {@link FileSystem} file operations. */\nexport class FileError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: FileErrorCode;\n\t/** Absolute addressed path associated with the failure, when available. */\n\tpublic path?: string;\n\n\tconstructor(code: FileErrorCode, message: string, path?: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"FileError\";\n\t\tthis.code = code;\n\t\tthis.path = path;\n\t}\n}\n\n/** Stable, backend-independent execution error codes returned by {@link ExecutionEnv.exec}. */\nexport type ExecutionErrorCode =\n\t| \"aborted\"\n\t| \"timeout\"\n\t| \"shell_unavailable\"\n\t| \"spawn_error\"\n\t| \"callback_error\"\n\t| \"unknown\";\n\n/** Error returned by {@link ExecutionEnv.exec}. */\nexport class ExecutionError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: ExecutionErrorCode;\n\n\tconstructor(code: ExecutionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"ExecutionError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Stable compaction error codes returned by compaction helpers. */\nexport type CompactionErrorCode = \"aborted\" | \"summarization_failed\";\n\n/** Error returned by compaction helpers. */\nexport class CompactionError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: CompactionErrorCode;\n\n\tconstructor(code: CompactionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"CompactionError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Stable branch-summary error codes returned by branch summarization helpers. */\nexport type BranchSummaryErrorCode = \"aborted\" | \"summarization_failed\";\n\n/** Error returned by branch summarization helpers. */\nexport class BranchSummaryError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: BranchSummaryErrorCode;\n\n\tconstructor(code: BranchSummaryErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"BranchSummaryError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Metadata for one filesystem object in a {@link FileSystem}. */\nexport interface FileInfo {\n\t/** Basename of {@link path}. */\n\tname: string;\n\t/** Absolute, syntactically normalized addressed path in the execution environment. Symlinks are not followed. */\n\tpath: string;\n\t/** Object kind. Symlink targets are not followed; use {@link FileSystem.canonicalPath} explicitly. */\n\tkind: FileKind;\n\t/** Size in bytes for the addressed filesystem object. */\n\tsize: number;\n\t/** Modification time as milliseconds since Unix epoch. */\n\tmtimeMs: number;\n}\n\n/** One UTF-8 line read from a text file. */\nexport interface TextLine {\n\ttext: string;\n\t/** Whether the line ended with `\\n`; callers use this to discard a torn final record. */\n\tterminated: boolean;\n}\n\n/** Pull-based UTF-8 line reader that preserves final-line termination. */\nexport interface TextLineReader {\n\treadLine(context: Context): Promise<Result<TextLine | undefined, FileError>>;\n\t/** Release the open file. Must be best-effort and must not throw or reject. */\n\tclose(context: Context): Promise<void>;\n}\n\n/**\n * Filesystem capability used by the harness.\n *\n * Paths passed to methods may be absolute or relative to {@link cwd}. Paths returned by file operations are addressed paths\n * in the filesystem namespace, but are not canonicalized through symlinks unless returned by {@link canonicalPath}.\n *\n * Operation methods must never throw or reject. All filesystem failures, including unexpected backend failures, must be\n * encoded in the returned {@link Result}. Implementations must preserve this invariant.\n */\nexport interface FileSystem {\n\t/** Current working directory for relative paths. */\n\tcwd: string;\n\n\t/** Return an absolute addressed path without requiring it to exist and without resolving symlinks. */\n\tabsolutePath(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Join path segments in the filesystem namespace without requiring the result to exist. */\n\tjoinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;\n\t/** Read a UTF-8 text file. */\n\treadTextFile(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Open a UTF-8 text file for pull-based line reading. */\n\topenTextLineReader(path: string, context: Context): Promise<Result<TextLineReader, FileError>>;\n\t/** Read UTF-8 text lines. Implementations should stop once `maxLines` lines have been read. */\n\treadTextLines(\n\t\tpath: string,\n\t\toptions: { maxLines?: number } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string[], FileError>>;\n\t/** Read a binary file. */\n\treadBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/** Create or overwrite a file, creating parent directories when supported. */\n\twriteFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Create or append to a file, creating parent directories when supported. */\n\tappendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Atomically rename a file, replacing the destination when it exists. Does not copy across filesystems. */\n\trenameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;\n\t/** Return metadata for the addressed path without following symlinks. */\n\tfileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;\n\t/** List direct children of a directory without following symlinks. */\n\tlistDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;\n\t/** Return the canonical path for an existing path, resolving symlinks where supported. */\n\tcanonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Return false for missing paths. Other errors, such as permission failures, return a {@link FileError}. */\n\texists(path: string, context: Context): Promise<Result<boolean, FileError>>;\n\t/** Create a directory. Defaults to `recursive: true`. */\n\tcreateDir(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\t/** Remove a file or directory. Defaults to `recursive: false` and `force: false`. */\n\tremove(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean; force?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\t/** Create a temporary directory and return its absolute path. Defaults to `prefix: \"tmp-\"`. */\n\tcreateTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;\n\t/** Create a temporary file and return its absolute path. Defaults to `prefix: \"\"` and `suffix: \"\"`. */\n\tcreateTempFile(\n\t\toptions: { prefix?: string; suffix?: string } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string, FileError>>;\n\n\t/** Release filesystem resources. Must be best-effort and must not throw or reject. */\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Which portion of bounded output survives after the limit is crossed. */\nexport type ShellOutputRetention = \"head\" | \"tail\";\n\n/** Source-side limits for one combined shell output view. */\nexport interface ShellOutputLimits {\n\tmaxBytes: number;\n\tmaxLines: number;\n\t/** Defaults to `\"tail\"`. */\n\tretain?: ShellOutputRetention;\n}\n\n/** Bounded shell capture requested by the caller. */\nexport interface ShellOutputCaptureOptions {\n\tlimits: ShellOutputLimits;\n\t/** Preserve complete output in an execution-environment-local file after the limits are crossed. */\n\tspill?: boolean;\n}\n\n/** Truncation metadata without a duplicate copy of the retained text. */\nexport type ShellOutputTruncation = Omit<TruncationResult, \"content\">;\n\n/** Metadata accompanying a bounded shell output view. */\nexport interface ShellOutputMetadata {\n\ttruncation: ShellOutputTruncation;\n\tspillPath?: string;\n\tlastLineBytes?: number;\n}\n\n/** Complete bounded shell output view. */\nexport interface ShellOutputView extends ShellOutputMetadata {\n\ttext: string;\n}\n\n/** Incremental source-side change to one bounded shell output view. */\nexport type ShellOutputUpdate =\n\t| { kind: \"replace\"; output: ShellOutputView }\n\t| { kind: \"append\"; text: string; metadata: ShellOutputMetadata }\n\t| { kind: \"slide\"; drop: number; text: string; metadata: ShellOutputMetadata }\n\t| { kind: \"metadata\"; metadata: ShellOutputMetadata };\n\n/** Bounded shell completion. Output text is delivered through {@link ShellExecOptions.onUpdate}. */\nexport interface ShellExecResult extends ShellOutputMetadata {\n\texitCode: number;\n}\n\n/** Options for {@link Shell.exec}. */\nexport interface ShellExecOptions {\n\t/** Working directory for the command. Relative paths are resolved against {@link ExecutionEnv.cwd}. Defaults to {@link ExecutionEnv.cwd}. */\n\tcwd?: string;\n\t/** Environment variables for the command. Values override inherited defaults when `inheritEnv` is true. */\n\tenv?: Record<string, string>;\n\t/** Whether to inherit the execution environment's default variables. Defaults to true. */\n\tinheritEnv?: boolean;\n\t/** Timeout in seconds. Implementations should return a timeout error when the command exceeds this duration. Defaults to no timeout. */\n\ttimeout?: number;\n\t/** Source-side bounded capture. Output is discarded when this and `onUpdate` are both absent. */\n\tcapture?: ShellOutputCaptureOptions;\n\t/** Called with bounded output changes. */\n\tonUpdate?: (update: ShellOutputUpdate, context: Context) => void;\n}\n\n/** Shell execution capability used by the harness. */\nexport interface Shell {\n\t/** Execute a shell command in {@link FileSystem.cwd} unless `options.cwd` is provided. */\n\texec(\n\t\tcommand: string,\n\t\toptions: ShellExecOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<ShellExecResult, ExecutionError>>;\n\t/** Release shell resources. Must be best-effort and must not throw or reject. */\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Filesystem and process execution environment used by the harness. */\nexport interface ExecutionEnv extends FileSystem, Shell {}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/harness/types.ts"],"names":[],"mappings":"AAUA,0CAA0C;AAC1C,MAAM,UAAU,EAAE,CAAiB,KAAa,EAA0B;IACzE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAAA,CAC3B;AAED,sCAAsC;AACtC,MAAM,UAAU,GAAG,CAAiB,KAAa,EAA0B;IAC1E,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAAA,CAC5B;AAED,+GAA+G;AAC/G,MAAM,UAAU,UAAU,CAAiB,MAA8B,EAAU;IAClF,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,MAAM,CAAC,KAAK,CAAC;IACnC,OAAO,MAAM,CAAC,KAAK,CAAC;AAAA,CACpB;AAED,wHAAwH;AACxH,MAAM,UAAU,cAAc,CAAgC,MAA8B,EAAsB;IACjH,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAAA,CAC5C;AAED,oGAAoG;AACpG,MAAM,UAAU,OAAO,CAAC,KAAc,EAAS;IAC9C,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;IACvD,IAAI,CAAC;QACJ,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CA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AAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD;AAKD,sDAAsD;AACtD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC5C,sCAAsC;IAC/B,IAAI,CAAyB;IAEpC,YAAY,IAA4B,EAAE,OAAe,EAAE,KAAa,EAAE;QACzE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD","sourcesContent":["import type { SimpleStreamOptions, Transport } from \"@earendil-works/pi-ai\";\nimport type { Static, TSchema } from \"typebox\";\nimport type { AgentTool, AgentToolResult } from \"../types.ts\";\nimport type { Context } from \"./context.ts\";\nimport type { JsonValue } from \"./session/types.ts\";\nimport type { TruncationResult } from \"./utils/truncate.ts\";\n\n/** Result of a fallible operation. Expected failures are returned as `ok: false` instead of thrown. */\nexport type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\n/** Create a successful {@link Result}. */\nexport function ok<TValue, TError>(value: TValue): Result<TValue, TError> {\n\treturn { ok: true, value };\n}\n\n/** Create a failed {@link Result}. */\nexport function err<TValue, TError>(error: TError): Result<TValue, TError> {\n\treturn { ok: false, error };\n}\n\n/** Return the success value or throw the failure error. Intended for tests and explicit adapter boundaries. */\nexport function getOrThrow<TValue, TError>(result: Result<TValue, TError>): TValue {\n\tif (!result.ok) throw result.error;\n\treturn result.value;\n}\n\n/** Return the success value or `undefined`. Only object values are allowed to avoid truthiness bugs with primitives. */\nexport function getOrUndefined<TValue extends object, TError>(result: Result<TValue, TError>): TValue | undefined {\n\treturn result.ok ? result.value : undefined;\n}\n\n/** Normalize unknown thrown values into Error instances before using them as typed error causes. */\nexport function toError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\tif (typeof error === \"string\") return new Error(error);\n\ttry {\n\t\treturn new Error(JSON.stringify(error));\n\t} catch {\n\t\treturn new Error(String(error));\n\t}\n}\n\n/**\n * Skill loaded from a `SKILL.md` file or provided by an application.\n *\n * `name`, `description`, and `filePath` are inserted into the system prompt in an XML-formatted block as suggested by agentskills.io.\n * Use {@link formatSkillsForSystemPrompt} to generate the spec-compatible system prompt block.\n */\nexport interface Skill {\n\t/** Stable skill name used for lookup and model-visible listings. */\n\tname: string;\n\t/** Short model-visible description of when to use the skill. */\n\tdescription: string;\n\t/** Full skill instructions. */\n\tcontent: string;\n\t/** Absolute path to the skill file. Used for model-visible location and resolving relative references. */\n\tfilePath: string;\n\t/** Exclude this skill from model-visible skill lists while still allowing explicit application invocation. */\n\tdisableModelInvocation?: boolean;\n}\n\n/** Prompt template that can be formatted into a prompt for explicit invocation. */\nexport interface PromptTemplate {\n\t/** Stable template name used for lookup or application command routing. */\n\tname: string;\n\t/** Optional description for command lists or autocomplete. */\n\tdescription?: string;\n\t/** Template content. Argument placeholders are formatted by `formatPromptTemplateInvocation`. */\n\tcontent: string;\n}\n\n/** Resources made available to explicit invocation methods and system-prompt callbacks. */\nexport interface AgentHarnessResources<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\t/** Prompt templates available for explicit invocation. */\n\tpromptTemplates?: TPromptTemplate[];\n\t/** Skills available to the model and explicit skill invocation. */\n\tskills?: TSkill[];\n}\n\n/** Options for one live harness tool progress update. */\nexport interface AgentHarnessToolUpdateOptions {\n\t/** Request replacement of this invocation's durable recovery checkpoint. */\n\tcheckpoint?: true;\n}\n\n/** Synchronous full-snapshot progress callback supplied to harness-native tools. */\nexport type AgentHarnessToolUpdateCallback<TDetails> = (\n\tpartialResult: AgentToolResult<TDetails>,\n\toptions?: AgentHarnessToolUpdateOptions,\n) => void;\n\n/** Stable harness identity for one logical tool call, unchanged during safe replay. */\nexport interface AgentHarnessToolInvocation {\n\t/** Opaque session-unique id equal to the call's reserved result-entry id. */\n\treadonly invocationId: string;\n\treadonly operationId: string;\n\treadonly turnId: string;\n\t/** Read one invocation-scoped durable replay memo. */\n\tgetMemo(name: string): Promise<JsonValue | undefined>;\n\t/** Set or delete one invocation-scoped durable replay memo. */\n\tsetMemo(name: string, value: JsonValue | undefined): Promise<void>;\n}\n\n/** Tool definition executed by an {@link AgentHarness} with an application-defined context. */\nexport type AgentHarnessTool<\n\tTContext extends object | undefined,\n\tTParameters extends TSchema = TSchema,\n\tTDetails = unknown,\n> = Omit<AgentTool<TParameters, TDetails>, \"execute\"> & {\n\t/** Execute the tool call with the context resolved for the current turn snapshot. */\n\texecute(\n\t\ttoolCallId: string,\n\t\tparams: Static<TParameters>,\n\t\tonUpdate: AgentHarnessToolUpdateCallback<TDetails>,\n\t\ttoolContext: TContext,\n\t\tinvocation: AgentHarnessToolInvocation,\n\t\tcontext: Context,\n\t): Promise<AgentToolResult<TDetails>>;\n};\n\n/** Static tool context or provider resolved for each turn snapshot. */\nexport type AgentHarnessToolContextSource<TContext extends object | undefined> =\n\t| TContext\n\t| ((context: Context) => TContext | Promise<TContext>);\n\n/** Curated provider request options owned by the harness and snapshotted per turn. */\nexport interface AgentHarnessStreamOptions {\n\t/** Preferred transport forwarded to the stream function. */\n\ttransport?: Transport;\n\t/** Provider request timeout in milliseconds. */\n\ttimeoutMs?: number;\n\t/** Maximum provider retry attempts. */\n\tmaxRetries?: number;\n\t/** Optional cap for provider-requested retry delays. */\n\tmaxRetryDelayMs?: number;\n\t/** Additional request headers merged with auth and lifecycle headers. */\n\theaders?: Record<string, string>;\n\t/** Provider metadata forwarded with requests. */\n\tmetadata?: SimpleStreamOptions[\"metadata\"];\n\t/** Provider cache retention hint. */\n\tcacheRetention?: SimpleStreamOptions[\"cacheRetention\"];\n\t/** Ask a capable provider to continue generation asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n}\n\n/** Per-request stream option patch returned by provider hooks. */\nexport interface AgentHarnessStreamOptionsPatch\n\textends Omit<Partial<AgentHarnessStreamOptions>, \"headers\" | \"metadata\"> {\n\t/** Header patch. `undefined` values delete keys; explicit `headers: undefined` clears all headers. */\n\theaders?: Record<string, string | undefined>;\n\t/** Metadata patch. `undefined` values delete keys; explicit `metadata: undefined` clears all metadata. */\n\tmetadata?: Record<string, unknown | undefined>;\n}\n\n/** Kind of filesystem object as addressed by a {@link FileSystem}. Symlinks are not followed automatically. */\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\n/** Stable, backend-independent file error codes returned by {@link FileSystem} file operations. */\nexport type FileErrorCode =\n\t| \"aborted\"\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\n/** Error returned by {@link FileSystem} file operations. */\nexport class FileError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: FileErrorCode;\n\t/** Absolute addressed path associated with the failure, when available. */\n\tpublic path?: string;\n\n\tconstructor(code: FileErrorCode, message: string, path?: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"FileError\";\n\t\tthis.code = code;\n\t\tthis.path = path;\n\t}\n}\n\n/** Stable, backend-independent execution error codes returned by {@link ExecutionEnv.exec}. */\nexport type ExecutionErrorCode =\n\t| \"aborted\"\n\t| \"timeout\"\n\t| \"shell_unavailable\"\n\t| \"spawn_error\"\n\t| \"callback_error\"\n\t| \"unknown\";\n\n/** Error returned by {@link ExecutionEnv.exec}. */\nexport class ExecutionError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: ExecutionErrorCode;\n\n\tconstructor(code: ExecutionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"ExecutionError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Stable compaction error codes returned by compaction helpers. */\nexport type CompactionErrorCode = \"aborted\" | \"summarization_failed\";\n\n/** Error returned by compaction helpers. */\nexport class CompactionError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: CompactionErrorCode;\n\n\tconstructor(code: CompactionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"CompactionError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Stable branch-summary error codes returned by branch summarization helpers. */\nexport type BranchSummaryErrorCode = \"aborted\" | \"summarization_failed\";\n\n/** Error returned by branch summarization helpers. */\nexport class BranchSummaryError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: BranchSummaryErrorCode;\n\n\tconstructor(code: BranchSummaryErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"BranchSummaryError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Metadata for one filesystem object in a {@link FileSystem}. */\nexport interface FileInfo {\n\t/** Basename of {@link path}. */\n\tname: string;\n\t/** Absolute, syntactically normalized addressed path in the execution environment. Symlinks are not followed. */\n\tpath: string;\n\t/** Object kind. Symlink targets are not followed; use {@link FileSystem.canonicalPath} explicitly. */\n\tkind: FileKind;\n\t/** Size in bytes for the addressed filesystem object. */\n\tsize: number;\n\t/** Modification time as milliseconds since Unix epoch. */\n\tmtimeMs: number;\n}\n\n/**\n * Filesystem capability used by the harness.\n *\n * Paths passed to methods may be absolute or relative to {@link cwd}. Paths returned by file operations are addressed paths\n * in the filesystem namespace, but are not canonicalized through symlinks unless returned by {@link canonicalPath}.\n *\n * Operation methods must never throw or reject. All filesystem failures, including unexpected backend failures, must be\n * encoded in the returned {@link Result}. Implementations must preserve this invariant.\n */\nexport interface FileSystem {\n\t/** Current working directory for relative paths. */\n\tcwd: string;\n\n\t/** Return an absolute addressed path without requiring it to exist and without resolving symlinks. */\n\tabsolutePath(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Join path segments in the filesystem namespace without requiring the result to exist. */\n\tjoinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;\n\t/** Read a UTF-8 text file. */\n\treadTextFile(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Read UTF-8 text lines. Implementations should stop once `maxLines` lines have been read. */\n\treadTextLines(\n\t\tpath: string,\n\t\toptions: { maxLines?: number } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string[], FileError>>;\n\t/** Read a binary file. */\n\treadBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/** Create or overwrite a file, creating parent directories when supported. */\n\twriteFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Create or append to a file, creating parent directories when supported. */\n\tappendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Atomically rename a file, replacing the destination when it exists. Does not copy across filesystems. */\n\trenameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;\n\t/** Return metadata for the addressed path without following symlinks. */\n\tfileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;\n\t/** List direct children of a directory without following symlinks. */\n\tlistDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;\n\t/** Return the canonical path for an existing path, resolving symlinks where supported. */\n\tcanonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Return false for missing paths. Other errors, such as permission failures, return a {@link FileError}. */\n\texists(path: string, context: Context): Promise<Result<boolean, FileError>>;\n\t/** Create a directory. Defaults to `recursive: true`. */\n\tcreateDir(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\t/** Remove a file or directory. Defaults to `recursive: false` and `force: false`. */\n\tremove(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean; force?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\t/** Create a temporary directory and return its absolute path. Defaults to `prefix: \"tmp-\"`. */\n\tcreateTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;\n\t/** Create a temporary file and return its absolute path. Defaults to `prefix: \"\"` and `suffix: \"\"`. */\n\tcreateTempFile(\n\t\toptions: { prefix?: string; suffix?: string } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string, FileError>>;\n\n\t/** Release filesystem resources. Must be best-effort and must not throw or reject. */\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Which portion of bounded output survives after the limit is crossed. */\nexport type ShellOutputRetention = \"head\" | \"tail\";\n\n/** Source-side limits for one combined shell output view. */\nexport interface ShellOutputLimits {\n\tmaxBytes: number;\n\tmaxLines: number;\n\t/** Defaults to `\"tail\"`. */\n\tretain?: ShellOutputRetention;\n}\n\n/** Bounded shell capture requested by the caller. */\nexport interface ShellOutputCaptureOptions {\n\tlimits: ShellOutputLimits;\n\t/** Preserve complete output in an execution-environment-local file after the limits are crossed. */\n\tspill?: boolean;\n}\n\n/** Truncation metadata without a duplicate copy of the retained text. */\nexport type ShellOutputTruncation = Omit<TruncationResult, \"content\">;\n\n/** Metadata accompanying a bounded shell output view. */\nexport interface ShellOutputMetadata {\n\ttruncation: ShellOutputTruncation;\n\tspillPath?: string;\n\tlastLineBytes?: number;\n}\n\n/** Complete bounded shell output view. */\nexport interface ShellOutputView extends ShellOutputMetadata {\n\ttext: string;\n}\n\n/** Incremental source-side change to one bounded shell output view. */\nexport type ShellOutputUpdate =\n\t| { kind: \"replace\"; output: ShellOutputView }\n\t| { kind: \"append\"; text: string; metadata: ShellOutputMetadata }\n\t| { kind: \"slide\"; drop: number; text: string; metadata: ShellOutputMetadata }\n\t| { kind: \"metadata\"; metadata: ShellOutputMetadata };\n\n/** Bounded shell completion. Output text is delivered through {@link ShellExecOptions.onUpdate}. */\nexport interface ShellExecResult extends ShellOutputMetadata {\n\texitCode: number;\n}\n\n/** Options for {@link Shell.exec}. */\nexport interface ShellExecOptions {\n\t/** Working directory for the command. Relative paths are resolved against {@link ExecutionEnv.cwd}. Defaults to {@link ExecutionEnv.cwd}. */\n\tcwd?: string;\n\t/** Environment variables for the command. Values override inherited defaults when `inheritEnv` is true. */\n\tenv?: Record<string, string>;\n\t/** Whether to inherit the execution environment's default variables. Defaults to true. */\n\tinheritEnv?: boolean;\n\t/** Timeout in seconds. Implementations should return a timeout error when the command exceeds this duration. Defaults to no timeout. */\n\ttimeout?: number;\n\t/** Source-side bounded capture. Output is discarded when this and `onUpdate` are both absent. */\n\tcapture?: ShellOutputCaptureOptions;\n\t/** Called with bounded output changes. */\n\tonUpdate?: (update: ShellOutputUpdate, context: Context) => void;\n}\n\n/** Shell execution capability used by the harness. */\nexport interface Shell {\n\t/** Execute a shell command in {@link FileSystem.cwd} unless `options.cwd` is provided. */\n\texec(\n\t\tcommand: string,\n\t\toptions: ShellExecOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<ShellExecResult, ExecutionError>>;\n\t/** Release shell resources. Must be best-effort and must not throw or reject. */\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Filesystem and process execution environment used by the harness. */\nexport interface ExecutionEnv extends FileSystem, Shell {}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/harness/types.ts"],"names":[],"mappings":"AAUA,0CAA0C;AAC1C,MAAM,UAAU,EAAE,CAAiB,KAAa,EAA0B;IACzE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAAA,CAC3B;AAED,sCAAsC;AACtC,MAAM,UAAU,GAAG,CAAiB,KAAa,EAA0B;IAC1E,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAAA,CAC5B;AAED,+GAA+G;AAC/G,MAAM,UAAU,UAAU,CAAiB,MAA8B,EAAU;IAClF,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,MAAM,CAAC,KAAK,CAAC;IACnC,OAAO,MAAM,CAAC,KAAK,CAAC;AAAA,CACpB;AAED,wHAAwH;AACxH,MAAM,UAAU,cAAc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AAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD;AAKD,4CAA4C;AAC5C,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACzC,sCAAsC;IAC/B,IAAI,CAAsB;IAEjC,YAAY,IAAyB,EAAE,OAAe,EAAE,KAAa,EAAE;QACtE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD;AAKD,sDAAsD;AACtD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC5C,sCAAsC;IAC/B,IAAI,CAAyB;IAEpC,YAAY,IAA4B,EAAE,OAAe,EAAE,KAAa,EAAE;QACzE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD","sourcesContent":["import type { SimpleStreamOptions, Transport } from \"@earendil-works/pi-ai\";\nimport type { Static, TSchema } from \"typebox\";\nimport type { AgentTool, AgentToolResult } from \"../types.ts\";\nimport type { Context } from \"./context.ts\";\nimport type { JsonValue } from \"./session/types.ts\";\nimport type { TruncationResult } from \"./utils/truncate.ts\";\n\n/** Result of a fallible operation. Expected failures are returned as `ok: false` instead of thrown. */\nexport type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\n/** Create a successful {@link Result}. */\nexport function ok<TValue, TError>(value: TValue): Result<TValue, TError> {\n\treturn { ok: true, value };\n}\n\n/** Create a failed {@link Result}. */\nexport function err<TValue, TError>(error: TError): Result<TValue, TError> {\n\treturn { ok: false, error };\n}\n\n/** Return the success value or throw the failure error. Intended for tests and explicit adapter boundaries. */\nexport function getOrThrow<TValue, TError>(result: Result<TValue, TError>): TValue {\n\tif (!result.ok) throw result.error;\n\treturn result.value;\n}\n\n/** Return the success value or `undefined`. Only object values are allowed to avoid truthiness bugs with primitives. */\nexport function getOrUndefined<TValue extends object, TError>(result: Result<TValue, TError>): TValue | undefined {\n\treturn result.ok ? result.value : undefined;\n}\n\n/** Normalize unknown thrown values into Error instances before using them as typed error causes. */\nexport function toError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\tif (typeof error === \"string\") return new Error(error);\n\ttry {\n\t\treturn new Error(JSON.stringify(error));\n\t} catch {\n\t\treturn new Error(String(error));\n\t}\n}\n\n/**\n * Skill loaded from a `SKILL.md` file or provided by an application.\n *\n * `name`, `description`, and `filePath` are inserted into the system prompt in an XML-formatted block as suggested by agentskills.io.\n * Use {@link formatSkillsForSystemPrompt} to generate the spec-compatible system prompt block.\n */\nexport interface Skill {\n\t/** Stable skill name used for lookup and model-visible listings. */\n\tname: string;\n\t/** Short model-visible description of when to use the skill. */\n\tdescription: string;\n\t/** Full skill instructions. */\n\tcontent: string;\n\t/** Absolute path to the skill file. Used for model-visible location and resolving relative references. */\n\tfilePath: string;\n\t/** Exclude this skill from model-visible skill lists while still allowing explicit application invocation. */\n\tdisableModelInvocation?: boolean;\n}\n\n/** Prompt template that can be formatted into a prompt for explicit invocation. */\nexport interface PromptTemplate {\n\t/** Stable template name used for lookup or application command routing. */\n\tname: string;\n\t/** Optional description for command lists or autocomplete. */\n\tdescription?: string;\n\t/** Template content. Argument placeholders are formatted by `formatPromptTemplateInvocation`. */\n\tcontent: string;\n}\n\n/** Resources made available to explicit invocation methods and system-prompt callbacks. */\nexport interface AgentHarnessResources<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\t/** Prompt templates available for explicit invocation. */\n\tpromptTemplates?: TPromptTemplate[];\n\t/** Skills available to the model and explicit skill invocation. */\n\tskills?: TSkill[];\n}\n\n/** Options for one live harness tool progress update. */\nexport interface AgentHarnessToolUpdateOptions {\n\t/** Request replacement of this invocation's durable recovery checkpoint. */\n\tcheckpoint?: true;\n}\n\n/** Synchronous full-snapshot progress callback supplied to harness-native tools. */\nexport type AgentHarnessToolUpdateCallback<TDetails> = (\n\tpartialResult: AgentToolResult<TDetails>,\n\toptions?: AgentHarnessToolUpdateOptions,\n) => void;\n\n/** Stable harness identity for one logical tool call, unchanged during safe replay. */\nexport interface AgentHarnessToolInvocation {\n\t/** Opaque session-unique id equal to the call's reserved result-entry id. */\n\treadonly invocationId: string;\n\treadonly operationId: string;\n\treadonly turnId: string;\n\t/** Read one invocation-scoped durable replay memo. */\n\tgetMemo(name: string): Promise<JsonValue | undefined>;\n\t/** Set or delete one invocation-scoped durable replay memo. */\n\tsetMemo(name: string, value: JsonValue | undefined): Promise<void>;\n}\n\n/** Tool definition executed by an {@link AgentHarness} with an application-defined context. */\nexport type AgentHarnessTool<\n\tTContext extends object | undefined,\n\tTParameters extends TSchema = TSchema,\n\tTDetails = unknown,\n> = Omit<AgentTool<TParameters, TDetails>, \"execute\"> & {\n\t/** Execute the tool call with the context resolved for the current turn snapshot. */\n\texecute(\n\t\ttoolCallId: string,\n\t\tparams: Static<TParameters>,\n\t\tonUpdate: AgentHarnessToolUpdateCallback<TDetails>,\n\t\ttoolContext: TContext,\n\t\tinvocation: AgentHarnessToolInvocation,\n\t\tcontext: Context,\n\t): Promise<AgentToolResult<TDetails>>;\n};\n\n/** Static tool context or provider resolved for each turn snapshot. */\nexport type AgentHarnessToolContextSource<TContext extends object | undefined> =\n\t| TContext\n\t| ((context: Context) => TContext | Promise<TContext>);\n\n/** Curated provider request options owned by the harness and snapshotted per turn. */\nexport interface AgentHarnessStreamOptions {\n\t/** Preferred transport forwarded to the stream function. */\n\ttransport?: Transport;\n\t/** Provider request timeout in milliseconds. */\n\ttimeoutMs?: number;\n\t/** Maximum provider retry attempts. */\n\tmaxRetries?: number;\n\t/** Optional cap for provider-requested retry delays. */\n\tmaxRetryDelayMs?: number;\n\t/** Additional request headers merged with auth and lifecycle headers. */\n\theaders?: Record<string, string>;\n\t/** Provider metadata forwarded with requests. */\n\tmetadata?: SimpleStreamOptions[\"metadata\"];\n\t/** Provider cache retention hint. */\n\tcacheRetention?: SimpleStreamOptions[\"cacheRetention\"];\n\t/** Ask a capable provider to continue generation asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n}\n\n/** Per-request stream option patch returned by provider hooks. */\nexport interface AgentHarnessStreamOptionsPatch\n\textends Omit<Partial<AgentHarnessStreamOptions>, \"headers\" | \"metadata\"> {\n\t/** Header patch. `undefined` values delete keys; explicit `headers: undefined` clears all headers. */\n\theaders?: Record<string, string | undefined>;\n\t/** Metadata patch. `undefined` values delete keys; explicit `metadata: undefined` clears all metadata. */\n\tmetadata?: Record<string, unknown | undefined>;\n}\n\n/** Kind of filesystem object as addressed by a {@link FileSystem}. Symlinks are not followed automatically. */\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\n/** Stable, backend-independent file error codes returned by {@link FileSystem} file operations. */\nexport type FileErrorCode =\n\t| \"aborted\"\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\n/** Error returned by {@link FileSystem} file operations. */\nexport class FileError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: FileErrorCode;\n\t/** Absolute addressed path associated with the failure, when available. */\n\tpublic path?: string;\n\n\tconstructor(code: FileErrorCode, message: string, path?: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"FileError\";\n\t\tthis.code = code;\n\t\tthis.path = path;\n\t}\n}\n\n/** Stable, backend-independent execution error codes returned by {@link ExecutionEnv.exec}. */\nexport type ExecutionErrorCode =\n\t| \"aborted\"\n\t| \"timeout\"\n\t| \"shell_unavailable\"\n\t| \"spawn_error\"\n\t| \"callback_error\"\n\t| \"unknown\";\n\n/** Error returned by {@link ExecutionEnv.exec}. */\nexport class ExecutionError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: ExecutionErrorCode;\n\n\tconstructor(code: ExecutionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"ExecutionError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Stable compaction error codes returned by compaction helpers. */\nexport type CompactionErrorCode = \"aborted\" | \"summarization_failed\";\n\n/** Error returned by compaction helpers. */\nexport class CompactionError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: CompactionErrorCode;\n\n\tconstructor(code: CompactionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"CompactionError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Stable branch-summary error codes returned by branch summarization helpers. */\nexport type BranchSummaryErrorCode = \"aborted\" | \"summarization_failed\";\n\n/** Error returned by branch summarization helpers. */\nexport class BranchSummaryError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: BranchSummaryErrorCode;\n\n\tconstructor(code: BranchSummaryErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"BranchSummaryError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Metadata for one filesystem object in a {@link FileSystem}. */\nexport interface FileInfo {\n\t/** Basename of {@link path}. */\n\tname: string;\n\t/** Absolute, syntactically normalized addressed path in the execution environment. Symlinks are not followed. */\n\tpath: string;\n\t/** Object kind. Symlink targets are not followed; use {@link FileSystem.canonicalPath} explicitly. */\n\tkind: FileKind;\n\t/** Size in bytes for the addressed filesystem object. */\n\tsize: number;\n\t/** Modification time as milliseconds since Unix epoch. */\n\tmtimeMs: number;\n}\n\n/** One UTF-8 line read from a text file. */\nexport interface TextLine {\n\ttext: string;\n\t/** Whether the line ended with `\\n`; callers use this to discard a torn final record. */\n\tterminated: boolean;\n}\n\n/** Pull-based UTF-8 line reader that preserves final-line termination. */\nexport interface TextLineReader {\n\treadLine(context: Context): Promise<Result<TextLine | undefined, FileError>>;\n\t/** Release the open file. Must be best-effort and must not throw or reject. */\n\tclose(context: Context): Promise<void>;\n}\n\n/**\n * Filesystem capability used by the harness.\n *\n * Paths passed to methods may be absolute or relative to {@link cwd}. Paths returned by file operations are addressed paths\n * in the filesystem namespace, but are not canonicalized through symlinks unless returned by {@link canonicalPath}.\n *\n * Operation methods must never throw or reject. All filesystem failures, including unexpected backend failures, must be\n * encoded in the returned {@link Result}. Implementations must preserve this invariant.\n */\nexport interface FileSystem {\n\t/** Current working directory for relative paths. */\n\tcwd: string;\n\n\t/** Return an absolute addressed path without requiring it to exist and without resolving symlinks. */\n\tabsolutePath(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Join path segments in the filesystem namespace without requiring the result to exist. */\n\tjoinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;\n\t/** Read a UTF-8 text file. */\n\treadTextFile(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Open a UTF-8 text file for pull-based line reading. */\n\topenTextLineReader(path: string, context: Context): Promise<Result<TextLineReader, FileError>>;\n\t/** Read UTF-8 text lines. Implementations should stop once `maxLines` lines have been read. */\n\treadTextLines(\n\t\tpath: string,\n\t\toptions: { maxLines?: number } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string[], FileError>>;\n\t/** Read a binary file. */\n\treadBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/** Create or overwrite a file, creating parent directories when supported. */\n\twriteFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Create or append to a file, creating parent directories when supported. */\n\tappendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Atomically rename a file, replacing the destination when it exists. Does not copy across filesystems. */\n\trenameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;\n\t/** Return metadata for the addressed path without following symlinks. */\n\tfileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;\n\t/** List direct children of a directory without following symlinks. */\n\tlistDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;\n\t/** Return the canonical path for an existing path, resolving symlinks where supported. */\n\tcanonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Return false for missing paths. Other errors, such as permission failures, return a {@link FileError}. */\n\texists(path: string, context: Context): Promise<Result<boolean, FileError>>;\n\t/** Create a directory. Defaults to `recursive: true`. */\n\tcreateDir(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\t/** Remove a file or directory. Defaults to `recursive: false` and `force: false`. */\n\tremove(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean; force?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\t/** Create a temporary directory and return its absolute path. Defaults to `prefix: \"tmp-\"`. */\n\tcreateTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;\n\t/** Create a temporary file and return its absolute path. Defaults to `prefix: \"\"` and `suffix: \"\"`. */\n\tcreateTempFile(\n\t\toptions: { prefix?: string; suffix?: string } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string, FileError>>;\n\n\t/** Release filesystem resources. Must be best-effort and must not throw or reject. */\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Which portion of bounded output survives after the limit is crossed. */\nexport type ShellOutputRetention = \"head\" | \"tail\";\n\n/** Source-side limits for one combined shell output view. */\nexport interface ShellOutputLimits {\n\tmaxBytes: number;\n\tmaxLines: number;\n\t/** Defaults to `\"tail\"`. */\n\tretain?: ShellOutputRetention;\n}\n\n/** Bounded shell capture requested by the caller. */\nexport interface ShellOutputCaptureOptions {\n\tlimits: ShellOutputLimits;\n\t/** Preserve complete output in an execution-environment-local file after the limits are crossed. */\n\tspill?: boolean;\n}\n\n/** Truncation metadata without a duplicate copy of the retained text. */\nexport type ShellOutputTruncation = Omit<TruncationResult, \"content\">;\n\n/** Metadata accompanying a bounded shell output view. */\nexport interface ShellOutputMetadata {\n\ttruncation: ShellOutputTruncation;\n\tspillPath?: string;\n\tlastLineBytes?: number;\n}\n\n/** Complete bounded shell output view. */\nexport interface ShellOutputView extends ShellOutputMetadata {\n\ttext: string;\n}\n\n/** Incremental source-side change to one bounded shell output view. */\nexport type ShellOutputUpdate =\n\t| { kind: \"replace\"; output: ShellOutputView }\n\t| { kind: \"append\"; text: string; metadata: ShellOutputMetadata }\n\t| { kind: \"slide\"; drop: number; text: string; metadata: ShellOutputMetadata }\n\t| { kind: \"metadata\"; metadata: ShellOutputMetadata };\n\n/** Bounded shell completion. Output text is delivered through {@link ShellExecOptions.onUpdate}. */\nexport interface ShellExecResult extends ShellOutputMetadata {\n\texitCode: number;\n}\n\n/** Options for {@link Shell.exec}. */\nexport interface ShellExecOptions {\n\t/** Working directory for the command. Relative paths are resolved against {@link ExecutionEnv.cwd}. Defaults to {@link ExecutionEnv.cwd}. */\n\tcwd?: string;\n\t/** Environment variables for the command. Values override inherited defaults when `inheritEnv` is true. */\n\tenv?: Record<string, string>;\n\t/** Whether to inherit the execution environment's default variables. Defaults to true. */\n\tinheritEnv?: boolean;\n\t/** Timeout in seconds. Implementations should return a timeout error when the command exceeds this duration. Defaults to no timeout. */\n\ttimeout?: number;\n\t/** Source-side bounded capture. Output is discarded when this and `onUpdate` are both absent. */\n\tcapture?: ShellOutputCaptureOptions;\n\t/** Called with bounded output changes. */\n\tonUpdate?: (update: ShellOutputUpdate, context: Context) => void;\n}\n\n/** Shell execution capability used by the harness. */\nexport interface Shell {\n\t/** Execute a shell command in {@link FileSystem.cwd} unless `options.cwd` is provided. */\n\texec(\n\t\tcommand: string,\n\t\toptions: ShellExecOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<ShellExecResult, ExecutionError>>;\n\t/** Release shell resources. Must be best-effort and must not throw or reject. */\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Filesystem and process execution environment used by the harness. */\nexport interface ExecutionEnv extends FileSystem, Shell {}\n"]}
|
package/dist/proxy.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Proxy stream function for apps that route LLM calls through a server.
|
|
3
3
|
* The server manages auth and proxies requests to LLM providers.
|
|
4
4
|
*/
|
|
5
|
-
import { type AssistantMessage, type AssistantMessageEvent,
|
|
5
|
+
import { type AssistantMessage, type AssistantMessageEvent, EventStream, type Model, type SimpleStreamOptions, type StopReason, type ToolCall, type TranscriptContext } from "@earendil-works/pi-ai";
|
|
6
6
|
declare class ProxyMessageEventStream extends EventStream<AssistantMessageEvent, AssistantMessage> {
|
|
7
7
|
constructor();
|
|
8
8
|
}
|
|
@@ -67,6 +67,6 @@ export interface ProxyStreamOptions extends ProxySerializableStreamOptions {
|
|
|
67
67
|
/** Proxy server URL (e.g., "https://genai.example.com") */
|
|
68
68
|
proxyUrl: string;
|
|
69
69
|
}
|
|
70
|
-
export declare function streamProxy(model: Model<any>, context:
|
|
70
|
+
export declare function streamProxy(model: Model<any>, context: TranscriptContext, options: ProxyStreamOptions): ProxyMessageEventStream;
|
|
71
71
|
export {};
|
|
72
72
|
//# sourceMappingURL=proxy.d.ts.map
|