@yolk-sdk/agent 0.1.0-canary.112 → 0.1.0-canary.114
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 +72 -43
- package/dist/client/state.d.mts +63 -63
- package/dist/client/state.d.mts.map +1 -1
- package/dist/client/state.mjs +1 -1
- package/dist/client/state.mjs.map +1 -1
- package/dist/client/transport.d.mts +12 -12
- package/dist/client/transport.d.mts.map +1 -1
- package/dist/compaction/estimator.d.mts.map +1 -1
- package/dist/compaction/estimator.mjs +2 -2
- package/dist/compaction/estimator.mjs.map +1 -1
- package/dist/compaction/retry.d.mts.map +1 -1
- package/dist/compaction/retry.mjs +1 -1
- package/dist/compaction/retry.mjs.map +1 -1
- package/dist/loop/accumulator.d.mts.map +1 -1
- package/dist/loop/accumulator.mjs +32 -6
- package/dist/loop/accumulator.mjs.map +1 -1
- package/dist/loop/collect.d.mts.map +1 -1
- package/dist/loop/collect.mjs +2 -2
- package/dist/loop/collect.mjs.map +1 -1
- package/dist/loop/index.d.mts +2 -2
- package/dist/loop/index.mjs +2 -2
- package/dist/loop/llm-event.d.mts +17 -2
- package/dist/loop/llm-event.d.mts.map +1 -1
- package/dist/loop/llm-event.mjs +9 -2
- package/dist/loop/llm-event.mjs.map +1 -1
- package/dist/loop/run.d.mts.map +1 -1
- package/dist/loop/run.mjs +4 -4
- package/dist/loop/run.mjs.map +1 -1
- package/dist/protocol/content.d.mts +28 -3
- package/dist/protocol/content.d.mts.map +1 -1
- package/dist/protocol/content.mjs +58 -5
- package/dist/protocol/content.mjs.map +1 -1
- package/dist/protocol/event.d.mts +19 -2
- package/dist/protocol/event.d.mts.map +1 -1
- package/dist/protocol/event.mjs +12 -2
- package/dist/protocol/event.mjs.map +1 -1
- package/dist/protocol/file.d.mts +38 -0
- package/dist/protocol/file.d.mts.map +1 -0
- package/dist/protocol/file.mjs +49 -0
- package/dist/protocol/file.mjs.map +1 -0
- package/dist/protocol/index.d.mts +5 -4
- package/dist/protocol/index.d.mts.map +1 -1
- package/dist/protocol/index.mjs +5 -4
- package/dist/protocol/message.d.mts +36 -6
- package/dist/protocol/message.d.mts.map +1 -1
- package/dist/protocol/message.mjs +23 -2
- package/dist/protocol/message.mjs.map +1 -1
- package/dist/protocol/session.d.mts +2 -2
- package/dist/protocol/session.d.mts.map +1 -1
- package/dist/protocol/tool.d.mts +7 -2
- package/dist/protocol/tool.d.mts.map +1 -1
- package/dist/protocol/tool.mjs +6 -1
- package/dist/protocol/tool.mjs.map +1 -1
- package/dist/providers/anthropic/claude-provider.d.mts +41 -2
- package/dist/providers/anthropic/claude-provider.d.mts.map +1 -1
- package/dist/providers/anthropic/claude-provider.mjs +7 -2
- package/dist/providers/anthropic/claude-provider.mjs.map +1 -1
- package/dist/providers/anthropic-messages-provider-internal.mjs +5 -1
- package/dist/providers/anthropic-messages-provider-internal.mjs.map +1 -1
- package/dist/providers/anthropic-provider-internal.d.mts +46 -4
- package/dist/providers/anthropic-provider-internal.d.mts.map +1 -1
- package/dist/providers/anthropic-provider-internal.mjs +165 -45
- package/dist/providers/anthropic-provider-internal.mjs.map +1 -1
- package/dist/providers/openai/codex-provider.d.mts +1 -1
- package/dist/providers/openai/codex-provider.d.mts.map +1 -1
- package/dist/providers/openai/provider.d.mts.map +1 -1
- package/dist/providers/openai/provider.mjs +8 -3
- package/dist/providers/openai/provider.mjs.map +1 -1
- package/dist/providers/openai-responses-provider-internal.d.mts.map +1 -1
- package/dist/providers/openai-responses-provider-internal.mjs +6 -3
- package/dist/providers/openai-responses-provider-internal.mjs.map +1 -1
- package/dist/providers/xai/grok-provider.d.mts +1 -1
- package/dist/providers/xai/grok-provider.d.mts.map +1 -1
- package/dist/react/chat-actions.d.mts +15 -15
- package/dist/react/chat-actions.d.mts.map +1 -1
- package/dist/react/chat-core.d.mts.map +1 -1
- package/dist/react/chat-core.mjs +1 -1
- package/dist/react/chat-core.mjs.map +1 -1
- package/dist/react/chat-items.d.mts +66 -66
- package/dist/react/chat-items.d.mts.map +1 -1
- package/dist/react/chat-messages.d.mts +69 -69
- package/dist/react/chat-messages.d.mts.map +1 -1
- package/dist/react/chat-messages.mjs +1 -1
- package/dist/react/chat-messages.mjs.map +1 -1
- package/dist/react/chat-session-events.d.mts +1 -1
- package/dist/skillset/merge.d.mts +1 -1
- package/dist/tools/files.d.mts +57 -0
- package/dist/tools/files.d.mts.map +1 -0
- package/dist/tools/files.mjs +119 -0
- package/dist/tools/files.mjs.map +1 -0
- package/dist/tools/index.d.mts +2 -1
- package/dist/tools/index.mjs +2 -1
- package/dist/tools/ledger.d.mts.map +1 -1
- package/dist/tools/ledger.mjs +11 -3
- package/dist/tools/ledger.mjs.map +1 -1
- package/dist/tools/registry.d.mts +6 -0
- package/dist/tools/registry.d.mts.map +1 -1
- package/dist/tools/registry.mjs +24 -14
- package/dist/tools/registry.mjs.map +1 -1
- package/package.json +2 -2
- package/src/client/state.ts +1 -0
- package/src/compaction/estimator.ts +2 -0
- package/src/compaction/retry.ts +1 -0
- package/src/loop/accumulator.ts +46 -7
- package/src/loop/collect.ts +4 -0
- package/src/loop/index.ts +1 -0
- package/src/loop/llm-event.ts +19 -1
- package/src/loop/run.ts +11 -0
- package/src/protocol/content.ts +66 -1
- package/src/protocol/event.ts +20 -1
- package/src/protocol/file.ts +70 -0
- package/src/protocol/index.ts +19 -0
- package/src/protocol/message.ts +28 -1
- package/src/protocol/tool.ts +6 -1
- package/src/providers/anthropic/claude-provider.ts +52 -1
- package/src/providers/anthropic-messages-provider-internal.ts +7 -1
- package/src/providers/anthropic-provider-internal.ts +356 -55
- package/src/providers/openai/provider.ts +12 -0
- package/src/providers/openai-responses-provider-internal.ts +5 -0
- package/src/react/chat-core.ts +1 -0
- package/src/react/chat-messages.ts +3 -0
- package/src/tools/files.ts +260 -0
- package/src/tools/index.ts +4 -0
- package/src/tools/ledger.ts +28 -2
- package/src/tools/registry.ts +56 -16
package/README.md
CHANGED
|
@@ -20,47 +20,47 @@ Published package metadata requires Node.js 22+.
|
|
|
20
20
|
|
|
21
21
|
## Subpaths
|
|
22
22
|
|
|
23
|
-
| Subpath | Purpose
|
|
24
|
-
| -------------------------------------------------------- |
|
|
25
|
-
| `@yolk-sdk/agent/protocol` | Wire messages, events, content, usage, tool schemas
|
|
26
|
-
| `@yolk-sdk/agent/loop` | Stateless LLM/tool loop, host instructions
|
|
27
|
-
| `@yolk-sdk/agent/loop/testing` | Faux provider and tool executor test helpers
|
|
28
|
-
| `@yolk-sdk/agent/runtime` | Transcript or append-backed runtime orchestration
|
|
29
|
-
| `@yolk-sdk/agent/client` | HTTP/NDJSON transport, HITL resume, retry/error state helpers
|
|
30
|
-
| `@yolk-sdk/agent/compaction` | Host-owned compaction budgets, checkpoints, formatting, retry
|
|
31
|
-
| `@yolk-sdk/agent/classification` | Classifier model contract: typed questions, answers, usage, errors
|
|
32
|
-
| `@yolk-sdk/agent/tools` | Tool registry, deferred loading (`tool_search`), typed inputs, interactions, subagents/questions, durable tool ledger, staged tool plans, tool change previews |
|
|
33
|
-
| `@yolk-sdk/agent/react` | Headless React chat hook, reducer, selectors, and render model
|
|
34
|
-
| `@yolk-sdk/agent/oauth` | Provider-neutral OAuth token and broker contracts
|
|
35
|
-
| `@yolk-sdk/agent/providers/openai` | OpenAI/Codex OAuth and broker helpers
|
|
36
|
-
| `@yolk-sdk/agent/providers/openai/codex` | OpenAI Codex request and auth helpers
|
|
37
|
-
| `@yolk-sdk/agent/providers/openai/codex-usage` | Codex subscription-allowance snapshots
|
|
38
|
-
| `@yolk-sdk/agent/providers/openai/codex-provider` | Codex LLM provider factory
|
|
39
|
-
| `@yolk-sdk/agent/providers/openai/provider` | OpenAI-compatible LLM provider factory
|
|
40
|
-
| `@yolk-sdk/agent/providers/openai/conformance` | Synthetic OpenAI chat, Codex Responses, and Codex usage fixtures and conformance cases
|
|
41
|
-
| `@yolk-sdk/agent/providers/openai/realtime` | OpenAI Realtime session config and event codecs
|
|
42
|
-
| `@yolk-sdk/agent/providers/openai/speech` | OpenAI text-to-speech and transcription adapters
|
|
43
|
-
| `@yolk-sdk/agent/providers/vercel/ai-gateway-provider` | Vercel AI Gateway Chat Completions provider factory
|
|
44
|
-
| `@yolk-sdk/agent/providers/vercel/ai-gateway-classifier` | Vercel AI Gateway classifier (`POST /v1/evaluate`) layer
|
|
45
|
-
| `@yolk-sdk/agent/providers/vercel/conformance` | Verified Gateway chat fixtures, synthetic classifier fixtures, and conformance cases
|
|
46
|
-
| `@yolk-sdk/agent/providers/opencode/go-provider` | OpenCode Go Chat Completions, Messages, and Responses provider
|
|
47
|
-
| `@yolk-sdk/agent/providers/opencode/usage` | OpenCode Go subscription-allowance snapshots
|
|
48
|
-
| `@yolk-sdk/agent/providers/opencode/conformance` | Synthetic OpenCode Go (per protocol, commentary replay, usage) fixtures and conformance cases
|
|
49
|
-
| `@yolk-sdk/agent/providers/anthropic` | Anthropic/Claude OAuth and broker helpers
|
|
50
|
-
| `@yolk-sdk/agent/providers/anthropic/claude` | Claude request and auth helpers
|
|
51
|
-
| `@yolk-sdk/agent/providers/anthropic/usage` | Claude subscription-allowance snapshots
|
|
52
|
-
| `@yolk-sdk/agent/providers/anthropic/claude-provider` | Claude LLM provider factory
|
|
53
|
-
| `@yolk-sdk/agent/providers/anthropic/conformance` | Synthetic Anthropic Messages and Claude usage fixtures and conformance cases
|
|
54
|
-
| `@yolk-sdk/agent/providers/xai` | Grok subscription OAuth and token broker helpers
|
|
55
|
-
| `@yolk-sdk/agent/providers/xai/grok` | Grok subscription request and auth helpers
|
|
56
|
-
| `@yolk-sdk/agent/providers/xai/grok-provider` | Grok subscription LLM provider factory
|
|
57
|
-
| `@yolk-sdk/agent/providers/xai/usage` | Grok subscription-allowance snapshots
|
|
58
|
-
| `@yolk-sdk/agent/providers/xai/conformance` | Synthetic Grok Responses and Grok usage fixtures and conformance cases
|
|
59
|
-
| `@yolk-sdk/agent/providers/subscription-usage` | Shared allowance snapshot and safe error schemas
|
|
60
|
-
| `@yolk-sdk/agent/skillset` | Portable skill and slash-command parsing/catalogs
|
|
61
|
-
| `@yolk-sdk/agent/voice` | Voice protocol, controller, tool handler, projection, speech
|
|
62
|
-
| `@yolk-sdk/agent/voice/browser` | Browser WebRTC voice transport
|
|
63
|
-
| `@yolk-sdk/agent/voice/react` | Headless browser voice React hook
|
|
23
|
+
| Subpath | Purpose |
|
|
24
|
+
| -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| `@yolk-sdk/agent/protocol` | Wire messages, events, content (including `FilePart`), usage, tool schemas |
|
|
26
|
+
| `@yolk-sdk/agent/loop` | Stateless LLM/tool loop, host instructions |
|
|
27
|
+
| `@yolk-sdk/agent/loop/testing` | Faux provider and tool executor test helpers |
|
|
28
|
+
| `@yolk-sdk/agent/runtime` | Transcript or append-backed runtime orchestration |
|
|
29
|
+
| `@yolk-sdk/agent/client` | HTTP/NDJSON transport, HITL resume, retry/error state helpers |
|
|
30
|
+
| `@yolk-sdk/agent/compaction` | Host-owned compaction budgets, checkpoints, formatting, retry |
|
|
31
|
+
| `@yolk-sdk/agent/classification` | Classifier model contract: typed questions, answers, usage, errors |
|
|
32
|
+
| `@yolk-sdk/agent/tools` | Tool registry, deferred loading (`tool_search`), typed inputs, interactions, subagents/questions, durable tool ledger, staged tool plans, tool change previews, file capture |
|
|
33
|
+
| `@yolk-sdk/agent/react` | Headless React chat hook, reducer, selectors, and render model |
|
|
34
|
+
| `@yolk-sdk/agent/oauth` | Provider-neutral OAuth token and broker contracts |
|
|
35
|
+
| `@yolk-sdk/agent/providers/openai` | OpenAI/Codex OAuth and broker helpers |
|
|
36
|
+
| `@yolk-sdk/agent/providers/openai/codex` | OpenAI Codex request and auth helpers |
|
|
37
|
+
| `@yolk-sdk/agent/providers/openai/codex-usage` | Codex subscription-allowance snapshots |
|
|
38
|
+
| `@yolk-sdk/agent/providers/openai/codex-provider` | Codex LLM provider factory |
|
|
39
|
+
| `@yolk-sdk/agent/providers/openai/provider` | OpenAI-compatible LLM provider factory |
|
|
40
|
+
| `@yolk-sdk/agent/providers/openai/conformance` | Synthetic OpenAI chat, Codex Responses, and Codex usage fixtures and conformance cases |
|
|
41
|
+
| `@yolk-sdk/agent/providers/openai/realtime` | OpenAI Realtime session config and event codecs |
|
|
42
|
+
| `@yolk-sdk/agent/providers/openai/speech` | OpenAI text-to-speech and transcription adapters |
|
|
43
|
+
| `@yolk-sdk/agent/providers/vercel/ai-gateway-provider` | Vercel AI Gateway Chat Completions provider factory |
|
|
44
|
+
| `@yolk-sdk/agent/providers/vercel/ai-gateway-classifier` | Vercel AI Gateway classifier (`POST /v1/evaluate`) layer |
|
|
45
|
+
| `@yolk-sdk/agent/providers/vercel/conformance` | Verified Gateway chat fixtures, synthetic classifier fixtures, and conformance cases |
|
|
46
|
+
| `@yolk-sdk/agent/providers/opencode/go-provider` | OpenCode Go Chat Completions, Messages, and Responses provider |
|
|
47
|
+
| `@yolk-sdk/agent/providers/opencode/usage` | OpenCode Go subscription-allowance snapshots |
|
|
48
|
+
| `@yolk-sdk/agent/providers/opencode/conformance` | Synthetic OpenCode Go (per protocol, commentary replay, usage) fixtures and conformance cases |
|
|
49
|
+
| `@yolk-sdk/agent/providers/anthropic` | Anthropic/Claude OAuth and broker helpers |
|
|
50
|
+
| `@yolk-sdk/agent/providers/anthropic/claude` | Claude request and auth helpers |
|
|
51
|
+
| `@yolk-sdk/agent/providers/anthropic/usage` | Claude subscription-allowance snapshots |
|
|
52
|
+
| `@yolk-sdk/agent/providers/anthropic/claude-provider` | Claude LLM provider factory, thinking config, and reasoning replay provider id |
|
|
53
|
+
| `@yolk-sdk/agent/providers/anthropic/conformance` | Synthetic Anthropic Messages and Claude usage fixtures and conformance cases |
|
|
54
|
+
| `@yolk-sdk/agent/providers/xai` | Grok subscription OAuth and token broker helpers |
|
|
55
|
+
| `@yolk-sdk/agent/providers/xai/grok` | Grok subscription request and auth helpers |
|
|
56
|
+
| `@yolk-sdk/agent/providers/xai/grok-provider` | Grok subscription LLM provider factory |
|
|
57
|
+
| `@yolk-sdk/agent/providers/xai/usage` | Grok subscription-allowance snapshots |
|
|
58
|
+
| `@yolk-sdk/agent/providers/xai/conformance` | Synthetic Grok Responses and Grok usage fixtures and conformance cases |
|
|
59
|
+
| `@yolk-sdk/agent/providers/subscription-usage` | Shared allowance snapshot and safe error schemas |
|
|
60
|
+
| `@yolk-sdk/agent/skillset` | Portable skill and slash-command parsing/catalogs |
|
|
61
|
+
| `@yolk-sdk/agent/voice` | Voice protocol, controller, tool handler, projection, speech |
|
|
62
|
+
| `@yolk-sdk/agent/voice/browser` | Browser WebRTC voice transport |
|
|
63
|
+
| `@yolk-sdk/agent/voice/react` | Headless browser voice React hook |
|
|
64
64
|
|
|
65
65
|
## Imports
|
|
66
66
|
|
|
@@ -162,7 +162,7 @@ const program = run({
|
|
|
162
162
|
Loop composition is those four Layers plus `run` / `runModelTurn` / `runToolBatch`.
|
|
163
163
|
Merge them with `makeAgentLoopLayer`. Omitted tools use `ToolExecutor.unavailable`; omitted transformer/config use identity and `LoopConfig.defaultLayer`.
|
|
164
164
|
Intercept by decorating a service (`decorateLLMProvider`), not with hooks.
|
|
165
|
-
Durable hosts fold model-turn steps with `collectModelTurn`. Use `collectModelTurnAttempt` when the fold must retain partial output after a failed stream. Kernel incomplete streams (zero `Done` events) set optional `LLMError.responseIssue: 'missing_done'` and stay `invalid_response` / `retryable: false`.
|
|
165
|
+
Durable hosts fold model-turn steps with `collectModelTurn`. Use `collectModelTurnAttempt` when the fold must retain partial output after a failed stream; the partial keeps reasoning replay state, and an `LLMReasoningReplay` event alone does not count as started output. Kernel incomplete streams (zero `Done` events) set optional `LLMError.responseIssue: 'missing_done'` and stay `invalid_response` / `retryable: false`.
|
|
166
166
|
|
|
167
167
|
```ts
|
|
168
168
|
import { makeAgentLoopLayer } from '@yolk-sdk/agent/loop'
|
|
@@ -303,6 +303,18 @@ configuration. Anthropic Claude forwards `low`, `medium`, `high`, and `xhigh` th
|
|
|
303
303
|
`output_config.effort`. It omits `minimal`, which Anthropic does not support. Hosts remain
|
|
304
304
|
responsible for choosing an effort accepted by the selected provider and model.
|
|
305
305
|
|
|
306
|
+
Newer Claude models think by default but return empty thinking blocks unless asked. Set
|
|
307
|
+
`thinking: { display: 'summarized' }` on `makeAnthropicClaudeProviderLayer` to stream readable
|
|
308
|
+
summaries as reasoning deltas; `prefixMismatchBehavior` (`'drop_block'` or `'error'`) sets what
|
|
309
|
+
Anthropic does with replayed thinking whose earlier context changed (absent: the account default).
|
|
310
|
+
With or without `thinking`, the Claude provider keeps each thinking block's signature, or
|
|
311
|
+
a redacted block's data, on its reasoning part (`AssistantReasoningPart.replay`, an
|
|
312
|
+
`AssistantReasoningReplay`) and sends the block back unchanged, in produced order, so tool-use turns
|
|
313
|
+
keep their reasoning. Reasoning from another provider is never sent to Claude. Never edit, truncate
|
|
314
|
+
or reorder a reasoning part that has `replay`: Anthropic rejects modified thinking blocks. Hosts
|
|
315
|
+
that rewrite history per request can skip parts whose `replay.provider` is
|
|
316
|
+
`anthropicClaudeReasoningReplayProvider`.
|
|
317
|
+
|
|
306
318
|
### Prompt caching
|
|
307
319
|
|
|
308
320
|
Provider prompt caching is always on (ADR 0008). Set `cacheKey` (for example the session id) on
|
|
@@ -552,6 +564,21 @@ inside one source fail validation. Hosts own file discovery, storage, enablement
|
|
|
552
564
|
- `ImagePart` with `InlineBase64`, `Url`, or host-owned `Ref` source
|
|
553
565
|
- `DocumentPart` with `InlineBase64`, `Url`, or host-owned `Ref` source
|
|
554
566
|
- `AudioPart` with `InlineBase64`, `Url`, or host-owned `Ref` source
|
|
567
|
+
- `FilePart`: bytes a tool yields for other tools to move, not for the model to view. Providers
|
|
568
|
+
render it as its label only (`filePartText`)
|
|
569
|
+
|
|
570
|
+
### File capture
|
|
571
|
+
|
|
572
|
+
`resolveTools(modules, context, { files: { store, maxFileBytes? } })` stores the inline bytes of
|
|
573
|
+
every executed result (direct, code mode nested, staged and interaction calls) through the host
|
|
574
|
+
`FileStoreApi` before the ledger or transcript sees them
|
|
575
|
+
([ADR 0009](https://github.com/magoz/yolk-sdk/blob/main/docs/adr/0009-file-claim-check.md)). A
|
|
576
|
+
`FilePart` becomes a `fileId` label (`[file file_…: name, mime, size]`), inline images, documents
|
|
577
|
+
and audio keep their source and gain a label, and `ToolResult.files` lists the descriptors
|
|
578
|
+
(`FileDescriptor`, not sent to providers). Without `files`, over `maxFileBytes` (default 100 MiB)
|
|
579
|
+
or when storing fails, inline `FilePart` bytes become a "file not captured" label. Tools build
|
|
580
|
+
file parts with `filePartFromBytes`. `@yolk-sdk/files` provides an object-storage store and tools
|
|
581
|
+
that move a `fileId` to upload URLs, links and the sandbox.
|
|
555
582
|
|
|
556
583
|
Build sources with `inlineBase64AttachmentSource`, `urlAttachmentSource`, or
|
|
557
584
|
`refAttachmentSource`. OpenAI-compatible Chat Completions providers support inline text documents;
|
|
@@ -645,7 +672,9 @@ hidden policy in annotations, author, or timestamps; providers may send them to
|
|
|
645
672
|
|
|
646
673
|
Durable transports may reconnect or replay overlapping chunks. Protocol events can carry optional
|
|
647
674
|
`eventId`; `LLMTextDelta` and `LLMReasoningDelta` can also carry `textSoFar` / `reasoningSoFar`
|
|
648
|
-
snapshots when a host can provide cumulative text.
|
|
675
|
+
snapshots when a host can provide cumulative text. `LLMReasoningReplay` closes a reasoning block
|
|
676
|
+
with opaque provider state; projections can ignore it (the final `AssistantMessage` carries it), but
|
|
677
|
+
exhaustive `AgentEvent` matches need a case.
|
|
649
678
|
|
|
650
679
|
Use `applyAgentEventToChatProjection` for replayable event logs:
|
|
651
680
|
|
package/dist/client/state.d.mts
CHANGED
|
@@ -80,6 +80,26 @@ type AgentToolRun = {
|
|
|
80
80
|
readonly result: ToolResult;
|
|
81
81
|
};
|
|
82
82
|
declare const AgentToolRun: {
|
|
83
|
+
readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
|
|
84
|
+
readonly _tag: "InputStreaming";
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly name?: string;
|
|
87
|
+
readonly input: string;
|
|
88
|
+
}, "_tag">;
|
|
89
|
+
readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
|
|
90
|
+
readonly _tag: "InputReady";
|
|
91
|
+
readonly call: ToolCall;
|
|
92
|
+
}, "_tag">;
|
|
93
|
+
readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
94
|
+
readonly _tag: "ApprovalRequested";
|
|
95
|
+
readonly call: ToolCall;
|
|
96
|
+
readonly request?: ToolApprovalRequest;
|
|
97
|
+
}, "_tag">;
|
|
98
|
+
readonly Denied: Data.TaggedEnum.ConstructorFrom<{
|
|
99
|
+
readonly _tag: "Denied";
|
|
100
|
+
readonly toolCallId: string;
|
|
101
|
+
readonly reason: string;
|
|
102
|
+
}, "_tag">;
|
|
83
103
|
readonly QuestionRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
84
104
|
readonly _tag: "QuestionRequested";
|
|
85
105
|
readonly request: QuestionRequest;
|
|
@@ -122,26 +142,6 @@ declare const AgentToolRun: {
|
|
|
122
142
|
readonly response: InteractionResponse;
|
|
123
143
|
readonly request?: InteractionRequest;
|
|
124
144
|
}, "_tag">;
|
|
125
|
-
readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
|
|
126
|
-
readonly _tag: "InputStreaming";
|
|
127
|
-
readonly id: string;
|
|
128
|
-
readonly name?: string;
|
|
129
|
-
readonly input: string;
|
|
130
|
-
}, "_tag">;
|
|
131
|
-
readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
|
|
132
|
-
readonly _tag: "InputReady";
|
|
133
|
-
readonly call: ToolCall;
|
|
134
|
-
}, "_tag">;
|
|
135
|
-
readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
136
|
-
readonly _tag: "ApprovalRequested";
|
|
137
|
-
readonly call: ToolCall;
|
|
138
|
-
readonly request?: ToolApprovalRequest;
|
|
139
|
-
}, "_tag">;
|
|
140
|
-
readonly Denied: Data.TaggedEnum.ConstructorFrom<{
|
|
141
|
-
readonly _tag: "Denied";
|
|
142
|
-
readonly toolCallId: string;
|
|
143
|
-
readonly reason: string;
|
|
144
|
-
}, "_tag">;
|
|
145
145
|
readonly Executing: Data.TaggedEnum.ConstructorFrom<{
|
|
146
146
|
readonly _tag: "Executing";
|
|
147
147
|
readonly call: ToolCall;
|
|
@@ -173,7 +173,7 @@ declare const AgentToolRun: {
|
|
|
173
173
|
readonly call: ToolCall;
|
|
174
174
|
readonly result: ToolResult;
|
|
175
175
|
}, "_tag">;
|
|
176
|
-
readonly $is: <Tag extends "
|
|
176
|
+
readonly $is: <Tag extends "InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
177
177
|
readonly _tag: "InputStreaming";
|
|
178
178
|
readonly id: string;
|
|
179
179
|
readonly name?: string;
|
|
@@ -287,6 +287,26 @@ declare const AgentToolRun: {
|
|
|
287
287
|
}>;
|
|
288
288
|
readonly $match: {
|
|
289
289
|
<Cases extends {
|
|
290
|
+
readonly InputStreaming: (args: {
|
|
291
|
+
readonly _tag: "InputStreaming";
|
|
292
|
+
readonly id: string;
|
|
293
|
+
readonly name?: string;
|
|
294
|
+
readonly input: string;
|
|
295
|
+
}) => any;
|
|
296
|
+
readonly InputReady: (args: {
|
|
297
|
+
readonly _tag: "InputReady";
|
|
298
|
+
readonly call: ToolCall;
|
|
299
|
+
}) => any;
|
|
300
|
+
readonly ApprovalRequested: (args: {
|
|
301
|
+
readonly _tag: "ApprovalRequested";
|
|
302
|
+
readonly call: ToolCall;
|
|
303
|
+
readonly request?: ToolApprovalRequest;
|
|
304
|
+
}) => any;
|
|
305
|
+
readonly Denied: (args: {
|
|
306
|
+
readonly _tag: "Denied";
|
|
307
|
+
readonly toolCallId: string;
|
|
308
|
+
readonly reason: string;
|
|
309
|
+
}) => any;
|
|
290
310
|
readonly QuestionRequested: (args: {
|
|
291
311
|
readonly _tag: "QuestionRequested";
|
|
292
312
|
readonly request: QuestionRequest;
|
|
@@ -329,26 +349,6 @@ declare const AgentToolRun: {
|
|
|
329
349
|
readonly response: InteractionResponse;
|
|
330
350
|
readonly request?: InteractionRequest;
|
|
331
351
|
}) => any;
|
|
332
|
-
readonly InputStreaming: (args: {
|
|
333
|
-
readonly _tag: "InputStreaming";
|
|
334
|
-
readonly id: string;
|
|
335
|
-
readonly name?: string;
|
|
336
|
-
readonly input: string;
|
|
337
|
-
}) => any;
|
|
338
|
-
readonly InputReady: (args: {
|
|
339
|
-
readonly _tag: "InputReady";
|
|
340
|
-
readonly call: ToolCall;
|
|
341
|
-
}) => any;
|
|
342
|
-
readonly ApprovalRequested: (args: {
|
|
343
|
-
readonly _tag: "ApprovalRequested";
|
|
344
|
-
readonly call: ToolCall;
|
|
345
|
-
readonly request?: ToolApprovalRequest;
|
|
346
|
-
}) => any;
|
|
347
|
-
readonly Denied: (args: {
|
|
348
|
-
readonly _tag: "Denied";
|
|
349
|
-
readonly toolCallId: string;
|
|
350
|
-
readonly reason: string;
|
|
351
|
-
}) => any;
|
|
352
352
|
readonly Executing: (args: {
|
|
353
353
|
readonly _tag: "Executing";
|
|
354
354
|
readonly call: ToolCall;
|
|
@@ -380,8 +380,28 @@ declare const AgentToolRun: {
|
|
|
380
380
|
readonly call: ToolCall;
|
|
381
381
|
readonly result: ToolResult;
|
|
382
382
|
}) => any;
|
|
383
|
-
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["
|
|
383
|
+
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
|
|
384
384
|
<Cases extends {
|
|
385
|
+
readonly InputStreaming: (args: {
|
|
386
|
+
readonly _tag: "InputStreaming";
|
|
387
|
+
readonly id: string;
|
|
388
|
+
readonly name?: string;
|
|
389
|
+
readonly input: string;
|
|
390
|
+
}) => any;
|
|
391
|
+
readonly InputReady: (args: {
|
|
392
|
+
readonly _tag: "InputReady";
|
|
393
|
+
readonly call: ToolCall;
|
|
394
|
+
}) => any;
|
|
395
|
+
readonly ApprovalRequested: (args: {
|
|
396
|
+
readonly _tag: "ApprovalRequested";
|
|
397
|
+
readonly call: ToolCall;
|
|
398
|
+
readonly request?: ToolApprovalRequest;
|
|
399
|
+
}) => any;
|
|
400
|
+
readonly Denied: (args: {
|
|
401
|
+
readonly _tag: "Denied";
|
|
402
|
+
readonly toolCallId: string;
|
|
403
|
+
readonly reason: string;
|
|
404
|
+
}) => any;
|
|
385
405
|
readonly QuestionRequested: (args: {
|
|
386
406
|
readonly _tag: "QuestionRequested";
|
|
387
407
|
readonly request: QuestionRequest;
|
|
@@ -424,26 +444,6 @@ declare const AgentToolRun: {
|
|
|
424
444
|
readonly response: InteractionResponse;
|
|
425
445
|
readonly request?: InteractionRequest;
|
|
426
446
|
}) => any;
|
|
427
|
-
readonly InputStreaming: (args: {
|
|
428
|
-
readonly _tag: "InputStreaming";
|
|
429
|
-
readonly id: string;
|
|
430
|
-
readonly name?: string;
|
|
431
|
-
readonly input: string;
|
|
432
|
-
}) => any;
|
|
433
|
-
readonly InputReady: (args: {
|
|
434
|
-
readonly _tag: "InputReady";
|
|
435
|
-
readonly call: ToolCall;
|
|
436
|
-
}) => any;
|
|
437
|
-
readonly ApprovalRequested: (args: {
|
|
438
|
-
readonly _tag: "ApprovalRequested";
|
|
439
|
-
readonly call: ToolCall;
|
|
440
|
-
readonly request?: ToolApprovalRequest;
|
|
441
|
-
}) => any;
|
|
442
|
-
readonly Denied: (args: {
|
|
443
|
-
readonly _tag: "Denied";
|
|
444
|
-
readonly toolCallId: string;
|
|
445
|
-
readonly reason: string;
|
|
446
|
-
}) => any;
|
|
447
447
|
readonly Executing: (args: {
|
|
448
448
|
readonly _tag: "Executing";
|
|
449
449
|
readonly call: ToolCall;
|
|
@@ -475,7 +475,7 @@ declare const AgentToolRun: {
|
|
|
475
475
|
readonly call: ToolCall;
|
|
476
476
|
readonly result: ToolResult;
|
|
477
477
|
}) => any;
|
|
478
|
-
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["
|
|
478
|
+
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
|
|
479
479
|
};
|
|
480
480
|
};
|
|
481
481
|
type AgentClientState = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.mts","names":[],"sources":["../../src/client/state.ts"],"mappings":";;;;KAoBY,cAAA;AAAA,KAEA,YAAA;EAAA,SAEG,IAAA;EAAA,SACA,EAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;AAAA;EAAA,SAEA,IAAA;EAAA,SAA6B,IAAA,EAAM,QAAA;AAAA;EAAA,SAEnC,IAAA;EAAA,SACA,IAAA,EAAM,QAAA;EAAA,SACN,OAAA,GAAU,mBAAA;AAAA;EAAA,SAEV,IAAA;EAAA,SAAyB,UAAA;EAAA,SAA6B,MAAA;AAAA;EAAA,SACtD,IAAA;EAAA,SAAoC,OAAA,EAAS,eAAA;AAAA;EAAA,SAE7C,IAAA;EAAA,SACA,QAAA,EAAU,gBAAA;EAAA,SACV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AA,GACX,QAAA,EAAU,aAAA,CAAc,YAAA,GACxB,OAAA,EAAS,YAAA,KACR,eAAA;AAAA,cAUU,eAAA,GAAmB,KAAA,EAAO,gBAAA,EAAkB,KAAA,EAAO,UAAA,KAAa,gBAAA;AAAA,cAMhE,0BAAA,GACX,KAAA,EAAO,gBAAA,EACP,KAAA,EAAO,UAAA,EACP,OAAA,GAAS,sBAAA,KACR,gBAAA;AAAA,cA4SU,sBAAA,GACX,KAAA,EAAO,gBAAA,EACP,OAAA,EAAS,WAAA,KACR,gBAAA;AAAA,cAcU,cAAA,GACX,KAAA,EAAO,gBAAA,EACP,OAAA,WACA,SAAA,GAAW,UAAA,YACV,gBAAA;AAAA,cASU,gBAAA,GAAoB,KAAA,EAAO,gBAAA,KAAmB,gBAOzD;AAAA,cAEW,iBAAA,GACX,MAAA,EAAQ,aAAA,CAAc,UAAA,GACtB,YAAA,GAAc,gBAAA,EACd,OAAA,GAAS,sBAAA,KAA2B,gBAAA"}
|
package/dist/client/state.mjs
CHANGED
|
@@ -133,7 +133,7 @@ const applyAgentEventUnchecked = (state, event, nowMs) => {
|
|
|
133
133
|
})), Match.tag("LLMReasoningDelta", (current) => clearRetryInfo({
|
|
134
134
|
...state,
|
|
135
135
|
reasoning: `${state.reasoning}${current.text}`
|
|
136
|
-
})), Match.tag("ToolInputStart", (current) => clearRetryInfo({
|
|
136
|
+
})), Match.tag("LLMReasoningReplay", () => clearRetryInfo(state)), Match.tag("ToolInputStart", (current) => clearRetryInfo({
|
|
137
137
|
...state,
|
|
138
138
|
toolRuns: replaceToolRun(state.toolRuns, AgentToolRunInputStreaming.make({
|
|
139
139
|
id: current.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.mjs","names":["Schema"],"sources":["../../src/client/state.ts"],"sourcesContent":["import {\n type AgentError,\n type AgentEvent,\n type AgentMessage,\n type AgentRetry,\n type HitlRequest,\n type InputRequest,\n type InputResponse,\n type InteractionRequest,\n type InteractionResponse,\n type QuestionRequest,\n type QuestionResponse,\n type ToolCall,\n type ToolApprovalRequest,\n type ToolResult,\n type UserMessage\n} from '@yolk-sdk/agent/protocol'\nimport { Data, Match, Predicate } from 'effect'\nimport * as Schema from 'effect/Schema'\n\nexport type AgentRunStatus = 'idle' | 'running' | 'waiting' | 'done' | 'error' | 'aborted'\n\nexport type AgentToolRun =\n | {\n readonly _tag: 'InputStreaming'\n readonly id: string\n readonly name?: string\n readonly input: string\n }\n | { readonly _tag: 'InputReady'; readonly call: ToolCall }\n | {\n readonly _tag: 'ApprovalRequested'\n readonly call: ToolCall\n readonly request?: ToolApprovalRequest\n }\n | { readonly _tag: 'Denied'; readonly toolCallId: string; readonly reason: string }\n | { readonly _tag: 'QuestionRequested'; readonly request: QuestionRequest }\n | {\n readonly _tag: 'QuestionAnswered'\n readonly response: QuestionResponse\n readonly request?: QuestionRequest\n }\n | {\n readonly _tag: 'QuestionCancelled'\n readonly response: QuestionResponse\n readonly request?: QuestionRequest\n }\n | { readonly _tag: 'InputRequested'; readonly request: InputRequest }\n | {\n readonly _tag: 'InputSubmitted'\n readonly response: InputResponse\n readonly request?: InputRequest\n }\n | {\n readonly _tag: 'InputCancelled'\n readonly response: InputResponse\n readonly request?: InputRequest\n }\n | { readonly _tag: 'InteractionRequested'; readonly request: InteractionRequest }\n | {\n readonly _tag: 'InteractionSubmitted'\n readonly response: InteractionResponse\n readonly request?: InteractionRequest\n }\n | {\n readonly _tag: 'InteractionCancelled'\n readonly response: InteractionResponse\n readonly request?: InteractionRequest\n }\n | {\n readonly _tag: 'Executing'\n readonly call: ToolCall\n readonly startedAtMs: number\n /** Preserve witnessed interaction acceptance across transport interruptions. */\n readonly interaction?: true\n }\n | {\n readonly _tag: 'Completed'\n readonly call: ToolCall\n readonly result: ToolResult\n readonly startedAtMs: number\n readonly endedAtMs: number\n }\n | {\n readonly _tag: 'Accepted'\n readonly call: ToolCall\n readonly result: ToolResult\n readonly startedAtMs: number\n readonly endedAtMs: number\n }\n | {\n readonly _tag: 'Errored'\n readonly call: ToolCall\n readonly message: string\n readonly endedAtMs: number\n }\n | { readonly _tag: 'ProviderCompleted'; readonly call: ToolCall; readonly result: ToolResult }\n\nexport const AgentToolRun = Data.taggedEnum<AgentToolRun>()\n\ntype StartedAgentToolRun = Extract<\n AgentToolRun,\n { readonly _tag: 'Executing' | 'Accepted' | 'Completed' }\n>\n\nexport type AgentClientState = {\n readonly status: AgentRunStatus\n readonly messages: ReadonlyArray<AgentMessage>\n readonly liveMessages: ReadonlyArray<AgentMessage>\n readonly text: string\n readonly reasoning: string\n readonly toolRuns: ReadonlyArray<AgentToolRun>\n readonly error: string | null\n readonly errorInfo: AgentError | null\n readonly retryInfo: AgentRetry | null\n readonly seenEventIds: ReadonlyArray<string>\n}\n\nexport type ApplyAgentEventOptions = {\n readonly nowMs?: number\n}\n\nconst AgentToolRunInputStreaming = Schema.TaggedStruct('InputStreaming', {\n id: Schema.String,\n name: Schema.UndefinedOr(Schema.String),\n input: Schema.String\n})\n\nconst AgentToolRunDenied = Schema.TaggedStruct('Denied', {\n toolCallId: Schema.String,\n reason: Schema.String\n})\n\nexport type AgentTranscript = readonly [AgentMessage, ...Array<AgentMessage>]\n\nexport const initialAgentClientState: AgentClientState = {\n status: 'idle',\n messages: [],\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: [],\n error: null,\n errorInfo: null,\n retryInfo: null,\n seenEventIds: []\n}\n\nconst clearRetryInfo = (state: AgentClientState): AgentClientState =>\n state.retryInfo === null ? state : { ...state, retryInfo: null }\n\nconst hasSeenEvent = (state: AgentClientState, event: AgentEvent) =>\n event.eventId !== undefined && state.seenEventIds.includes(event.eventId)\n\nconst rememberEvent = (state: AgentClientState, event: AgentEvent): AgentClientState =>\n event.eventId === undefined\n ? state\n : { ...state, seenEventIds: [...state.seenEventIds, event.eventId] }\n\nconst toolRunId = (run: AgentToolRun) =>\n Match.value(run).pipe(\n Match.tag('InputStreaming', current => current.id),\n Match.tag('Denied', current => current.toolCallId),\n Match.tag('QuestionRequested', current => current.request.toolCallId),\n Match.tag('QuestionAnswered', 'QuestionCancelled', current => current.response.toolCallId),\n Match.tag('InputRequested', current => current.request.toolCallId),\n Match.tag('InputSubmitted', 'InputCancelled', current => current.response.toolCallId),\n Match.tag('InteractionRequested', current => current.request.toolCallId),\n Match.tag(\n 'InteractionSubmitted',\n 'InteractionCancelled',\n current => current.response.toolCallId\n ),\n Match.tag(\n 'InputReady',\n 'ApprovalRequested',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n current => current.call.id\n ),\n Match.exhaustive\n )\n\nexport const isActiveToolRun = (run: AgentToolRun) =>\n !Predicate.isTagged(run, 'Accepted') &&\n !Predicate.isTagged(run, 'Completed') &&\n !Predicate.isTagged(run, 'Errored') &&\n !Predicate.isTagged(run, 'Denied') &&\n !Predicate.isTagged(run, 'QuestionAnswered') &&\n !Predicate.isTagged(run, 'QuestionCancelled') &&\n !Predicate.isTagged(run, 'InputSubmitted') &&\n !Predicate.isTagged(run, 'InputCancelled') &&\n !Predicate.isTagged(run, 'InteractionCancelled') &&\n !Predicate.isTagged(run, 'ProviderCompleted')\n\nexport const completedToolRuns = (runs: ReadonlyArray<AgentToolRun>) =>\n runs.filter(run => Predicate.isTagged(run, 'Completed'))\n\n// Retention is not completion: transport interruption cannot revoke witnessed acceptance.\nconst retainedSettledToolRuns = (runs: ReadonlyArray<AgentToolRun>) =>\n runs.filter(\n run =>\n Predicate.isTagged(run, 'Completed') ||\n Predicate.isTagged(run, 'Accepted') ||\n Predicate.isTagged(run, 'InteractionSubmitted') ||\n (Predicate.isTagged(run, 'Executing') && run.interaction === true)\n )\n\nexport const toolRunsFromHitlRequests = (\n requests: ReadonlyArray<HitlRequest>\n): ReadonlyArray<AgentToolRun> =>\n requests.map(request =>\n Match.value(request).pipe(\n Match.tag('QuestionRequest', current => AgentToolRun.QuestionRequested({ request: current })),\n Match.tag('ToolApprovalRequest', current =>\n AgentToolRun.ApprovalRequested({\n call: current.call,\n request: current\n })\n ),\n Match.tag('InputRequest', current => AgentToolRun.InputRequested({ request: current })),\n Match.tag('InteractionRequest', current =>\n AgentToolRun.InteractionRequested({ request: current })\n ),\n Match.exhaustive\n )\n )\n\nconst replaceToolRun = (\n runs: ReadonlyArray<AgentToolRun>,\n run: AgentToolRun\n): ReadonlyArray<AgentToolRun> => {\n const id = toolRunId(run)\n const replaceIndex = runs.findIndex(current => toolRunId(current) === id)\n\n // Input/approval/Started replays without event ids cannot reopen an acknowledged call.\n if (runs[replaceIndex]?._tag === 'Accepted' && isActiveToolRun(run)) return runs\n\n if (replaceIndex === -1) {\n return [...runs, run]\n }\n\n return runs.flatMap((current, index) => {\n if (toolRunId(current) !== id) {\n return [current]\n }\n\n return index === replaceIndex ? [run] : []\n })\n}\n\nconst isStartedToolRun = (run: AgentToolRun): run is StartedAgentToolRun =>\n Predicate.isTagged(run, 'Executing') ||\n Predicate.isTagged(run, 'Accepted') ||\n Predicate.isTagged(run, 'Completed')\n\nconst startedAtMsFor = (runs: ReadonlyArray<AgentToolRun>, toolCallId: string) =>\n runs.filter(isStartedToolRun).find(run => run.call.id === toolCallId)?.startedAtMs\n\nconst appendToolInputDelta = (\n runs: ReadonlyArray<AgentToolRun>,\n id: string,\n delta: string\n): ReadonlyArray<AgentToolRun> =>\n runs.map(run =>\n Predicate.isTagged(run, 'InputStreaming') && run.id === id\n ? { ...run, input: `${run.input}${delta}` }\n : run\n )\n\nconst questionRequestForToolCall = (\n runs: ReadonlyArray<AgentToolRun>,\n toolCallId: string\n): QuestionRequest | undefined =>\n runs.flatMap(run => {\n if (toolRunId(run) !== toolCallId) {\n return []\n }\n\n return Match.value(run).pipe(\n Match.tag('QuestionRequested', current => [current.request]),\n Match.tag('QuestionAnswered', 'QuestionCancelled', current =>\n current.request === undefined ? [] : [current.request]\n ),\n Match.tag(\n 'InputStreaming',\n 'InputReady',\n 'InputRequested',\n 'InputSubmitted',\n 'InputCancelled',\n 'InteractionRequested',\n 'InteractionSubmitted',\n 'InteractionCancelled',\n 'ApprovalRequested',\n 'Denied',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n () => []\n ),\n Match.exhaustive\n )\n })[0]\n\nconst inputRequestForToolCall = (\n runs: ReadonlyArray<AgentToolRun>,\n toolCallId: string\n): InputRequest | undefined =>\n runs.flatMap(run => {\n if (toolRunId(run) !== toolCallId) {\n return []\n }\n\n return Match.value(run).pipe(\n Match.tag('InputRequested', current => [current.request]),\n Match.tag('InputSubmitted', 'InputCancelled', current =>\n current.request === undefined ? [] : [current.request]\n ),\n Match.tag(\n 'InputStreaming',\n 'InputReady',\n 'InteractionRequested',\n 'InteractionSubmitted',\n 'InteractionCancelled',\n 'ApprovalRequested',\n 'Denied',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n 'QuestionRequested',\n 'QuestionAnswered',\n 'QuestionCancelled',\n () => []\n ),\n Match.exhaustive\n )\n })[0]\n\nconst inputSubmittedRun = (\n response: InputResponse,\n request: InputRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.InputSubmitted({ response })\n : AgentToolRun.InputSubmitted({ response, request })\n\nconst inputCancelledRun = (\n response: InputResponse,\n request: InputRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.InputCancelled({ response })\n : AgentToolRun.InputCancelled({ response, request })\n\nconst questionAnsweredRun = (\n response: QuestionResponse,\n request: QuestionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.QuestionAnswered({ response })\n : AgentToolRun.QuestionAnswered({ response, request })\n\nconst questionCancelledRun = (\n response: QuestionResponse,\n request: QuestionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.QuestionCancelled({ response })\n : AgentToolRun.QuestionCancelled({ response, request })\n\nconst interactionSubmittedRun = (\n response: InteractionResponse,\n request: InteractionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.InteractionSubmitted({ response })\n : AgentToolRun.InteractionSubmitted({ response, request })\n\nconst interactionCancelledRun = (\n response: InteractionResponse,\n request: InteractionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.InteractionCancelled({ response })\n : AgentToolRun.InteractionCancelled({ response, request })\n\nconst interactionRequestForToolCall = (\n runs: ReadonlyArray<AgentToolRun>,\n toolCallId: string\n): InteractionRequest | undefined =>\n runs.flatMap(run => {\n if (toolRunId(run) !== toolCallId) {\n return []\n }\n\n return Match.value(run).pipe(\n Match.tag('InteractionRequested', current => [current.request]),\n Match.tag('InteractionSubmitted', 'InteractionCancelled', current =>\n current.request === undefined ? [] : [current.request]\n ),\n Match.tag(\n 'InputStreaming',\n 'InputReady',\n 'InputRequested',\n 'InputSubmitted',\n 'InputCancelled',\n 'ApprovalRequested',\n 'Denied',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n 'QuestionRequested',\n 'QuestionAnswered',\n 'QuestionCancelled',\n () => []\n ),\n Match.exhaustive\n )\n })[0]\n\nexport const appendAgentMessage = (\n messages: ReadonlyArray<AgentMessage>,\n message: AgentMessage\n): AgentTranscript => {\n const first = messages[0]\n\n if (first === undefined) {\n return [message]\n }\n\n return [first, ...messages.slice(1), message]\n}\n\nexport const applyAgentEvent = (state: AgentClientState, event: AgentEvent): AgentClientState => {\n const nowMs = 0\n\n return applyAgentEventWithOptions(state, event, { nowMs })\n}\n\nexport const applyAgentEventWithOptions = (\n state: AgentClientState,\n event: AgentEvent,\n options: ApplyAgentEventOptions = {}\n): AgentClientState => {\n const nowMs = options.nowMs ?? 0\n\n if (hasSeenEvent(state, event)) {\n return state\n }\n\n return rememberEvent(applyAgentEventUnchecked(state, event, nowMs), event)\n}\n\nconst activeEventToolCallId = (event: AgentEvent): string | undefined =>\n Match.value(event).pipe(\n Match.tag('ToolInputStart', 'ToolInputDelta', current => current.id),\n Match.tag(\n 'ToolInputEnd',\n 'ToolExecutionStarted',\n 'ToolApprovalRequested',\n current => current.call.id\n ),\n Match.tag('QuestionRequested', current => current.request.toolCallId),\n Match.tag('InputRequested', current => current.request.toolCallId),\n Match.tag('InteractionRequested', current => current.request.toolCallId),\n Match.orElse(() => undefined)\n )\n\nconst applyAgentEventUnchecked = (\n state: AgentClientState,\n event: AgentEvent,\n nowMs: number\n): AgentClientState => {\n const activeCallId = activeEventToolCallId(event)\n\n const acknowledgesActiveCall = (message: AgentMessage) =>\n Predicate.isTagged(message, 'ToolResult') &&\n message.toolCallId === activeCallId &&\n message.acceptance !== undefined\n\n if (\n activeCallId !== undefined &&\n (state.messages.some(acknowledgesActiveCall) || state.liveMessages.some(acknowledgesActiveCall))\n ) {\n // Hydration need not restore transient runs; the transcript itself is a replay fence.\n return {\n ...state,\n toolRuns: state.toolRuns.filter(\n run => toolRunId(run) !== activeCallId || !isActiveToolRun(run)\n )\n }\n }\n\n return Match.value(event)\n .pipe(\n Match.withReturnType<AgentClientState>(),\n Match.tag('AgentStart', () => ({\n ...state,\n status: 'running',\n text: '',\n reasoning: '',\n liveMessages: [],\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null\n })),\n Match.tag('AgentError', current => markAgentError(state, current.message, current)),\n Match.tag('LLMTextDelta', current =>\n clearRetryInfo({ ...state, text: `${state.text}${current.text}` })\n ),\n Match.tag('LLMReasoningDelta', current =>\n clearRetryInfo({ ...state, reasoning: `${state.reasoning}${current.text}` })\n ),\n Match.tag('ToolInputStart', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRunInputStreaming.make({ id: current.id, name: current.name, input: '' })\n )\n })\n ),\n Match.tag('ToolInputDelta', current =>\n clearRetryInfo({\n ...state,\n toolRuns: appendToolInputDelta(state.toolRuns, current.id, current.delta)\n })\n ),\n Match.tag('ToolInputEnd', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.InputReady({ call: current.call }))\n })\n ),\n Match.tag('ToolApprovalRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.ApprovalRequested({\n call: current.call,\n request: current.request\n })\n )\n })),\n Match.tag('ToolApprovalGranted', () => state),\n Match.tag('ToolApprovalDenied', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRunDenied.make({ toolCallId: current.toolCallId, reason: current.reason })\n )\n })),\n Match.tag('QuestionRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.QuestionRequested({ request: current.request })\n )\n })),\n Match.tag('InputRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.InputRequested({ request: current.request })\n )\n })),\n Match.tag('InteractionRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.InteractionRequested({ request: current.request })\n )\n }))\n )\n .pipe(\n Match.tag('QuestionAnswered', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n questionAnsweredRun(\n current.response,\n questionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('QuestionCancelled', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n questionCancelledRun(\n current.response,\n questionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('InputSubmitted', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n inputSubmittedRun(\n current.response,\n inputRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('InputCancelled', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n inputCancelledRun(\n current.response,\n inputRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('InteractionSubmitted', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n interactionSubmittedRun(\n current.response,\n interactionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('InteractionCancelled', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n interactionCancelledRun(\n current.response,\n interactionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('ToolExecutionStarted', current => {\n const prior = state.toolRuns.find(run => toolRunId(run) === current.call.id)\n const executing = AgentToolRun.Executing({ call: current.call, startedAtMs: nowMs })\n\n const isInteraction =\n Predicate.isTagged(prior, 'InteractionSubmitted') ||\n (Predicate.isTagged(prior, 'Executing') && prior.interaction === true)\n\n return {\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n isInteraction ? { ...executing, interaction: true } : executing\n )\n }\n }),\n Match.tag('ToolExecutionAccepted', 'ToolExecutionCompleted', current => {\n const endedAtMs = nowMs\n const startedAtMs = startedAtMsFor(state.toolRuns, current.call.id) ?? endedAtMs\n\n return {\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n Predicate.isTagged(current, 'ToolExecutionAccepted')\n ? AgentToolRun.Accepted({\n call: current.call,\n result: current.result,\n startedAtMs,\n endedAtMs\n })\n : AgentToolRun.Completed({\n call: current.call,\n result: current.result,\n startedAtMs,\n endedAtMs\n })\n )\n }\n }),\n Match.tag('ToolExecutionError', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.Errored({\n call: current.call,\n message: current.message,\n endedAtMs: nowMs\n })\n )\n })),\n Match.tag('ProviderToolResult', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.ProviderCompleted({ call: current.call, result: current.result })\n )\n })\n ),\n Match.tag('UserMessage', 'AssistantMessage', current =>\n clearRetryInfo({\n ...state,\n liveMessages: [...state.liveMessages, current.message],\n text: '',\n reasoning: ''\n })\n ),\n Match.tag('AgentEnd', current => ({\n ...state,\n status: 'done',\n messages: [...state.messages, ...current.messages],\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n retryInfo: null\n })),\n Match.tag('AgentAwaitingInput', current => ({\n ...state,\n status: 'waiting',\n messages: [...state.messages, ...current.messages],\n liveMessages: [],\n text: '',\n reasoning: '',\n error: null,\n errorInfo: null,\n retryInfo: null\n })),\n Match.tag('AgentRetry', current => ({ ...state, retryInfo: current })),\n Match.tag(\n 'CompactionEnd',\n 'CompactionStart',\n 'LLMStreamEnd',\n 'LLMStreamStart',\n 'SubagentCompleted',\n 'SubagentStarted',\n 'TurnEnd',\n 'TurnStart',\n 'UsageUpdate',\n () => state\n ),\n Match.exhaustive\n )\n}\n\nexport const submitAgentUserMessage = (\n state: AgentClientState,\n message: UserMessage\n): AgentClientState => ({\n ...state,\n status: 'running',\n messages: appendAgentMessage(state.messages, message),\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null,\n seenEventIds: []\n})\n\nexport const markAgentError = (\n state: AgentClientState,\n message = 'Agent request failed',\n errorInfo: AgentError | null = null\n): AgentClientState => ({\n ...state,\n status: 'error',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: message,\n errorInfo,\n retryInfo: null\n})\n\nexport const markAgentAborted = (state: AgentClientState): AgentClientState => ({\n ...state,\n status: 'aborted',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null\n})\n\nexport const reduceAgentEvents = (\n events: ReadonlyArray<AgentEvent>,\n initialState: AgentClientState = initialAgentClientState,\n options: ApplyAgentEventOptions = {}\n) =>\n events.reduce((state, event) => applyAgentEventWithOptions(state, event, options), initialState)\n"],"mappings":";;;AAkGA,MAAa,eAAe,KAAK,WAAyB;AAwB1D,MAAM,6BAA6BA,SAAO,aAAa,kBAAkB;CACvE,IAAIA,SAAO;CACX,MAAMA,SAAO,YAAYA,SAAO,MAAM;CACtC,OAAOA,SAAO;AAChB,CAAC;AAED,MAAM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ACP,WAAW;CACX,WAAW;AACb;AAEA,MAAa,qBACX,QACA,eAAiC,yBACjC,UAAkC,CAAC,MAEnC,OAAO,QAAQ,OAAO,UAAU,2BAA2B,OAAO,OAAO,OAAO,GAAG,YAAY"}
|
|
1
|
+
{"version":3,"file":"state.mjs","names":["Schema"],"sources":["../../src/client/state.ts"],"sourcesContent":["import {\n type AgentError,\n type AgentEvent,\n type AgentMessage,\n type AgentRetry,\n type HitlRequest,\n type InputRequest,\n type InputResponse,\n type InteractionRequest,\n type InteractionResponse,\n type QuestionRequest,\n type QuestionResponse,\n type ToolCall,\n type ToolApprovalRequest,\n type ToolResult,\n type UserMessage\n} from '@yolk-sdk/agent/protocol'\nimport { Data, Match, Predicate } from 'effect'\nimport * as Schema from 'effect/Schema'\n\nexport type AgentRunStatus = 'idle' | 'running' | 'waiting' | 'done' | 'error' | 'aborted'\n\nexport type AgentToolRun =\n | {\n readonly _tag: 'InputStreaming'\n readonly id: string\n readonly name?: string\n readonly input: string\n }\n | { readonly _tag: 'InputReady'; readonly call: ToolCall }\n | {\n readonly _tag: 'ApprovalRequested'\n readonly call: ToolCall\n readonly request?: ToolApprovalRequest\n }\n | { readonly _tag: 'Denied'; readonly toolCallId: string; readonly reason: string }\n | { readonly _tag: 'QuestionRequested'; readonly request: QuestionRequest }\n | {\n readonly _tag: 'QuestionAnswered'\n readonly response: QuestionResponse\n readonly request?: QuestionRequest\n }\n | {\n readonly _tag: 'QuestionCancelled'\n readonly response: QuestionResponse\n readonly request?: QuestionRequest\n }\n | { readonly _tag: 'InputRequested'; readonly request: InputRequest }\n | {\n readonly _tag: 'InputSubmitted'\n readonly response: InputResponse\n readonly request?: InputRequest\n }\n | {\n readonly _tag: 'InputCancelled'\n readonly response: InputResponse\n readonly request?: InputRequest\n }\n | { readonly _tag: 'InteractionRequested'; readonly request: InteractionRequest }\n | {\n readonly _tag: 'InteractionSubmitted'\n readonly response: InteractionResponse\n readonly request?: InteractionRequest\n }\n | {\n readonly _tag: 'InteractionCancelled'\n readonly response: InteractionResponse\n readonly request?: InteractionRequest\n }\n | {\n readonly _tag: 'Executing'\n readonly call: ToolCall\n readonly startedAtMs: number\n /** Preserve witnessed interaction acceptance across transport interruptions. */\n readonly interaction?: true\n }\n | {\n readonly _tag: 'Completed'\n readonly call: ToolCall\n readonly result: ToolResult\n readonly startedAtMs: number\n readonly endedAtMs: number\n }\n | {\n readonly _tag: 'Accepted'\n readonly call: ToolCall\n readonly result: ToolResult\n readonly startedAtMs: number\n readonly endedAtMs: number\n }\n | {\n readonly _tag: 'Errored'\n readonly call: ToolCall\n readonly message: string\n readonly endedAtMs: number\n }\n | { readonly _tag: 'ProviderCompleted'; readonly call: ToolCall; readonly result: ToolResult }\n\nexport const AgentToolRun = Data.taggedEnum<AgentToolRun>()\n\ntype StartedAgentToolRun = Extract<\n AgentToolRun,\n { readonly _tag: 'Executing' | 'Accepted' | 'Completed' }\n>\n\nexport type AgentClientState = {\n readonly status: AgentRunStatus\n readonly messages: ReadonlyArray<AgentMessage>\n readonly liveMessages: ReadonlyArray<AgentMessage>\n readonly text: string\n readonly reasoning: string\n readonly toolRuns: ReadonlyArray<AgentToolRun>\n readonly error: string | null\n readonly errorInfo: AgentError | null\n readonly retryInfo: AgentRetry | null\n readonly seenEventIds: ReadonlyArray<string>\n}\n\nexport type ApplyAgentEventOptions = {\n readonly nowMs?: number\n}\n\nconst AgentToolRunInputStreaming = Schema.TaggedStruct('InputStreaming', {\n id: Schema.String,\n name: Schema.UndefinedOr(Schema.String),\n input: Schema.String\n})\n\nconst AgentToolRunDenied = Schema.TaggedStruct('Denied', {\n toolCallId: Schema.String,\n reason: Schema.String\n})\n\nexport type AgentTranscript = readonly [AgentMessage, ...Array<AgentMessage>]\n\nexport const initialAgentClientState: AgentClientState = {\n status: 'idle',\n messages: [],\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: [],\n error: null,\n errorInfo: null,\n retryInfo: null,\n seenEventIds: []\n}\n\nconst clearRetryInfo = (state: AgentClientState): AgentClientState =>\n state.retryInfo === null ? state : { ...state, retryInfo: null }\n\nconst hasSeenEvent = (state: AgentClientState, event: AgentEvent) =>\n event.eventId !== undefined && state.seenEventIds.includes(event.eventId)\n\nconst rememberEvent = (state: AgentClientState, event: AgentEvent): AgentClientState =>\n event.eventId === undefined\n ? state\n : { ...state, seenEventIds: [...state.seenEventIds, event.eventId] }\n\nconst toolRunId = (run: AgentToolRun) =>\n Match.value(run).pipe(\n Match.tag('InputStreaming', current => current.id),\n Match.tag('Denied', current => current.toolCallId),\n Match.tag('QuestionRequested', current => current.request.toolCallId),\n Match.tag('QuestionAnswered', 'QuestionCancelled', current => current.response.toolCallId),\n Match.tag('InputRequested', current => current.request.toolCallId),\n Match.tag('InputSubmitted', 'InputCancelled', current => current.response.toolCallId),\n Match.tag('InteractionRequested', current => current.request.toolCallId),\n Match.tag(\n 'InteractionSubmitted',\n 'InteractionCancelled',\n current => current.response.toolCallId\n ),\n Match.tag(\n 'InputReady',\n 'ApprovalRequested',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n current => current.call.id\n ),\n Match.exhaustive\n )\n\nexport const isActiveToolRun = (run: AgentToolRun) =>\n !Predicate.isTagged(run, 'Accepted') &&\n !Predicate.isTagged(run, 'Completed') &&\n !Predicate.isTagged(run, 'Errored') &&\n !Predicate.isTagged(run, 'Denied') &&\n !Predicate.isTagged(run, 'QuestionAnswered') &&\n !Predicate.isTagged(run, 'QuestionCancelled') &&\n !Predicate.isTagged(run, 'InputSubmitted') &&\n !Predicate.isTagged(run, 'InputCancelled') &&\n !Predicate.isTagged(run, 'InteractionCancelled') &&\n !Predicate.isTagged(run, 'ProviderCompleted')\n\nexport const completedToolRuns = (runs: ReadonlyArray<AgentToolRun>) =>\n runs.filter(run => Predicate.isTagged(run, 'Completed'))\n\n// Retention is not completion: transport interruption cannot revoke witnessed acceptance.\nconst retainedSettledToolRuns = (runs: ReadonlyArray<AgentToolRun>) =>\n runs.filter(\n run =>\n Predicate.isTagged(run, 'Completed') ||\n Predicate.isTagged(run, 'Accepted') ||\n Predicate.isTagged(run, 'InteractionSubmitted') ||\n (Predicate.isTagged(run, 'Executing') && run.interaction === true)\n )\n\nexport const toolRunsFromHitlRequests = (\n requests: ReadonlyArray<HitlRequest>\n): ReadonlyArray<AgentToolRun> =>\n requests.map(request =>\n Match.value(request).pipe(\n Match.tag('QuestionRequest', current => AgentToolRun.QuestionRequested({ request: current })),\n Match.tag('ToolApprovalRequest', current =>\n AgentToolRun.ApprovalRequested({\n call: current.call,\n request: current\n })\n ),\n Match.tag('InputRequest', current => AgentToolRun.InputRequested({ request: current })),\n Match.tag('InteractionRequest', current =>\n AgentToolRun.InteractionRequested({ request: current })\n ),\n Match.exhaustive\n )\n )\n\nconst replaceToolRun = (\n runs: ReadonlyArray<AgentToolRun>,\n run: AgentToolRun\n): ReadonlyArray<AgentToolRun> => {\n const id = toolRunId(run)\n const replaceIndex = runs.findIndex(current => toolRunId(current) === id)\n\n // Input/approval/Started replays without event ids cannot reopen an acknowledged call.\n if (runs[replaceIndex]?._tag === 'Accepted' && isActiveToolRun(run)) return runs\n\n if (replaceIndex === -1) {\n return [...runs, run]\n }\n\n return runs.flatMap((current, index) => {\n if (toolRunId(current) !== id) {\n return [current]\n }\n\n return index === replaceIndex ? [run] : []\n })\n}\n\nconst isStartedToolRun = (run: AgentToolRun): run is StartedAgentToolRun =>\n Predicate.isTagged(run, 'Executing') ||\n Predicate.isTagged(run, 'Accepted') ||\n Predicate.isTagged(run, 'Completed')\n\nconst startedAtMsFor = (runs: ReadonlyArray<AgentToolRun>, toolCallId: string) =>\n runs.filter(isStartedToolRun).find(run => run.call.id === toolCallId)?.startedAtMs\n\nconst appendToolInputDelta = (\n runs: ReadonlyArray<AgentToolRun>,\n id: string,\n delta: string\n): ReadonlyArray<AgentToolRun> =>\n runs.map(run =>\n Predicate.isTagged(run, 'InputStreaming') && run.id === id\n ? { ...run, input: `${run.input}${delta}` }\n : run\n )\n\nconst questionRequestForToolCall = (\n runs: ReadonlyArray<AgentToolRun>,\n toolCallId: string\n): QuestionRequest | undefined =>\n runs.flatMap(run => {\n if (toolRunId(run) !== toolCallId) {\n return []\n }\n\n return Match.value(run).pipe(\n Match.tag('QuestionRequested', current => [current.request]),\n Match.tag('QuestionAnswered', 'QuestionCancelled', current =>\n current.request === undefined ? [] : [current.request]\n ),\n Match.tag(\n 'InputStreaming',\n 'InputReady',\n 'InputRequested',\n 'InputSubmitted',\n 'InputCancelled',\n 'InteractionRequested',\n 'InteractionSubmitted',\n 'InteractionCancelled',\n 'ApprovalRequested',\n 'Denied',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n () => []\n ),\n Match.exhaustive\n )\n })[0]\n\nconst inputRequestForToolCall = (\n runs: ReadonlyArray<AgentToolRun>,\n toolCallId: string\n): InputRequest | undefined =>\n runs.flatMap(run => {\n if (toolRunId(run) !== toolCallId) {\n return []\n }\n\n return Match.value(run).pipe(\n Match.tag('InputRequested', current => [current.request]),\n Match.tag('InputSubmitted', 'InputCancelled', current =>\n current.request === undefined ? [] : [current.request]\n ),\n Match.tag(\n 'InputStreaming',\n 'InputReady',\n 'InteractionRequested',\n 'InteractionSubmitted',\n 'InteractionCancelled',\n 'ApprovalRequested',\n 'Denied',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n 'QuestionRequested',\n 'QuestionAnswered',\n 'QuestionCancelled',\n () => []\n ),\n Match.exhaustive\n )\n })[0]\n\nconst inputSubmittedRun = (\n response: InputResponse,\n request: InputRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.InputSubmitted({ response })\n : AgentToolRun.InputSubmitted({ response, request })\n\nconst inputCancelledRun = (\n response: InputResponse,\n request: InputRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.InputCancelled({ response })\n : AgentToolRun.InputCancelled({ response, request })\n\nconst questionAnsweredRun = (\n response: QuestionResponse,\n request: QuestionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.QuestionAnswered({ response })\n : AgentToolRun.QuestionAnswered({ response, request })\n\nconst questionCancelledRun = (\n response: QuestionResponse,\n request: QuestionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.QuestionCancelled({ response })\n : AgentToolRun.QuestionCancelled({ response, request })\n\nconst interactionSubmittedRun = (\n response: InteractionResponse,\n request: InteractionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.InteractionSubmitted({ response })\n : AgentToolRun.InteractionSubmitted({ response, request })\n\nconst interactionCancelledRun = (\n response: InteractionResponse,\n request: InteractionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.InteractionCancelled({ response })\n : AgentToolRun.InteractionCancelled({ response, request })\n\nconst interactionRequestForToolCall = (\n runs: ReadonlyArray<AgentToolRun>,\n toolCallId: string\n): InteractionRequest | undefined =>\n runs.flatMap(run => {\n if (toolRunId(run) !== toolCallId) {\n return []\n }\n\n return Match.value(run).pipe(\n Match.tag('InteractionRequested', current => [current.request]),\n Match.tag('InteractionSubmitted', 'InteractionCancelled', current =>\n current.request === undefined ? [] : [current.request]\n ),\n Match.tag(\n 'InputStreaming',\n 'InputReady',\n 'InputRequested',\n 'InputSubmitted',\n 'InputCancelled',\n 'ApprovalRequested',\n 'Denied',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n 'QuestionRequested',\n 'QuestionAnswered',\n 'QuestionCancelled',\n () => []\n ),\n Match.exhaustive\n )\n })[0]\n\nexport const appendAgentMessage = (\n messages: ReadonlyArray<AgentMessage>,\n message: AgentMessage\n): AgentTranscript => {\n const first = messages[0]\n\n if (first === undefined) {\n return [message]\n }\n\n return [first, ...messages.slice(1), message]\n}\n\nexport const applyAgentEvent = (state: AgentClientState, event: AgentEvent): AgentClientState => {\n const nowMs = 0\n\n return applyAgentEventWithOptions(state, event, { nowMs })\n}\n\nexport const applyAgentEventWithOptions = (\n state: AgentClientState,\n event: AgentEvent,\n options: ApplyAgentEventOptions = {}\n): AgentClientState => {\n const nowMs = options.nowMs ?? 0\n\n if (hasSeenEvent(state, event)) {\n return state\n }\n\n return rememberEvent(applyAgentEventUnchecked(state, event, nowMs), event)\n}\n\nconst activeEventToolCallId = (event: AgentEvent): string | undefined =>\n Match.value(event).pipe(\n Match.tag('ToolInputStart', 'ToolInputDelta', current => current.id),\n Match.tag(\n 'ToolInputEnd',\n 'ToolExecutionStarted',\n 'ToolApprovalRequested',\n current => current.call.id\n ),\n Match.tag('QuestionRequested', current => current.request.toolCallId),\n Match.tag('InputRequested', current => current.request.toolCallId),\n Match.tag('InteractionRequested', current => current.request.toolCallId),\n Match.orElse(() => undefined)\n )\n\nconst applyAgentEventUnchecked = (\n state: AgentClientState,\n event: AgentEvent,\n nowMs: number\n): AgentClientState => {\n const activeCallId = activeEventToolCallId(event)\n\n const acknowledgesActiveCall = (message: AgentMessage) =>\n Predicate.isTagged(message, 'ToolResult') &&\n message.toolCallId === activeCallId &&\n message.acceptance !== undefined\n\n if (\n activeCallId !== undefined &&\n (state.messages.some(acknowledgesActiveCall) || state.liveMessages.some(acknowledgesActiveCall))\n ) {\n // Hydration need not restore transient runs; the transcript itself is a replay fence.\n return {\n ...state,\n toolRuns: state.toolRuns.filter(\n run => toolRunId(run) !== activeCallId || !isActiveToolRun(run)\n )\n }\n }\n\n return Match.value(event)\n .pipe(\n Match.withReturnType<AgentClientState>(),\n Match.tag('AgentStart', () => ({\n ...state,\n status: 'running',\n text: '',\n reasoning: '',\n liveMessages: [],\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null\n })),\n Match.tag('AgentError', current => markAgentError(state, current.message, current)),\n Match.tag('LLMTextDelta', current =>\n clearRetryInfo({ ...state, text: `${state.text}${current.text}` })\n ),\n Match.tag('LLMReasoningDelta', current =>\n clearRetryInfo({ ...state, reasoning: `${state.reasoning}${current.text}` })\n ),\n Match.tag('LLMReasoningReplay', () => clearRetryInfo(state)),\n Match.tag('ToolInputStart', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRunInputStreaming.make({ id: current.id, name: current.name, input: '' })\n )\n })\n ),\n Match.tag('ToolInputDelta', current =>\n clearRetryInfo({\n ...state,\n toolRuns: appendToolInputDelta(state.toolRuns, current.id, current.delta)\n })\n ),\n Match.tag('ToolInputEnd', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.InputReady({ call: current.call }))\n })\n ),\n Match.tag('ToolApprovalRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.ApprovalRequested({\n call: current.call,\n request: current.request\n })\n )\n })),\n Match.tag('ToolApprovalGranted', () => state),\n Match.tag('ToolApprovalDenied', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRunDenied.make({ toolCallId: current.toolCallId, reason: current.reason })\n )\n })),\n Match.tag('QuestionRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.QuestionRequested({ request: current.request })\n )\n })),\n Match.tag('InputRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.InputRequested({ request: current.request })\n )\n })),\n Match.tag('InteractionRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.InteractionRequested({ request: current.request })\n )\n }))\n )\n .pipe(\n Match.tag('QuestionAnswered', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n questionAnsweredRun(\n current.response,\n questionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('QuestionCancelled', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n questionCancelledRun(\n current.response,\n questionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('InputSubmitted', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n inputSubmittedRun(\n current.response,\n inputRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('InputCancelled', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n inputCancelledRun(\n current.response,\n inputRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('InteractionSubmitted', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n interactionSubmittedRun(\n current.response,\n interactionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('InteractionCancelled', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n interactionCancelledRun(\n current.response,\n interactionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('ToolExecutionStarted', current => {\n const prior = state.toolRuns.find(run => toolRunId(run) === current.call.id)\n const executing = AgentToolRun.Executing({ call: current.call, startedAtMs: nowMs })\n\n const isInteraction =\n Predicate.isTagged(prior, 'InteractionSubmitted') ||\n (Predicate.isTagged(prior, 'Executing') && prior.interaction === true)\n\n return {\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n isInteraction ? { ...executing, interaction: true } : executing\n )\n }\n }),\n Match.tag('ToolExecutionAccepted', 'ToolExecutionCompleted', current => {\n const endedAtMs = nowMs\n const startedAtMs = startedAtMsFor(state.toolRuns, current.call.id) ?? endedAtMs\n\n return {\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n Predicate.isTagged(current, 'ToolExecutionAccepted')\n ? AgentToolRun.Accepted({\n call: current.call,\n result: current.result,\n startedAtMs,\n endedAtMs\n })\n : AgentToolRun.Completed({\n call: current.call,\n result: current.result,\n startedAtMs,\n endedAtMs\n })\n )\n }\n }),\n Match.tag('ToolExecutionError', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.Errored({\n call: current.call,\n message: current.message,\n endedAtMs: nowMs\n })\n )\n })),\n Match.tag('ProviderToolResult', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.ProviderCompleted({ call: current.call, result: current.result })\n )\n })\n ),\n Match.tag('UserMessage', 'AssistantMessage', current =>\n clearRetryInfo({\n ...state,\n liveMessages: [...state.liveMessages, current.message],\n text: '',\n reasoning: ''\n })\n ),\n Match.tag('AgentEnd', current => ({\n ...state,\n status: 'done',\n messages: [...state.messages, ...current.messages],\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n retryInfo: null\n })),\n Match.tag('AgentAwaitingInput', current => ({\n ...state,\n status: 'waiting',\n messages: [...state.messages, ...current.messages],\n liveMessages: [],\n text: '',\n reasoning: '',\n error: null,\n errorInfo: null,\n retryInfo: null\n })),\n Match.tag('AgentRetry', current => ({ ...state, retryInfo: current })),\n Match.tag(\n 'CompactionEnd',\n 'CompactionStart',\n 'LLMStreamEnd',\n 'LLMStreamStart',\n 'SubagentCompleted',\n 'SubagentStarted',\n 'TurnEnd',\n 'TurnStart',\n 'UsageUpdate',\n () => state\n ),\n Match.exhaustive\n )\n}\n\nexport const submitAgentUserMessage = (\n state: AgentClientState,\n message: UserMessage\n): AgentClientState => ({\n ...state,\n status: 'running',\n messages: appendAgentMessage(state.messages, message),\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null,\n seenEventIds: []\n})\n\nexport const markAgentError = (\n state: AgentClientState,\n message = 'Agent request failed',\n errorInfo: AgentError | null = null\n): AgentClientState => ({\n ...state,\n status: 'error',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: message,\n errorInfo,\n retryInfo: null\n})\n\nexport const markAgentAborted = (state: AgentClientState): AgentClientState => ({\n ...state,\n status: 'aborted',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null\n})\n\nexport const reduceAgentEvents = (\n events: ReadonlyArray<AgentEvent>,\n initialState: AgentClientState = initialAgentClientState,\n options: ApplyAgentEventOptions = {}\n) =>\n events.reduce((state, event) => applyAgentEventWithOptions(state, event, options), initialState)\n"],"mappings":";;;AAkGA,MAAa,eAAe,KAAK,WAAyB;AAwB1D,MAAM,6BAA6BA,SAAO,aAAa,kBAAkB;CACvE,IAAIA,SAAO;CACX,MAAMA,SAAO,YAAYA,SAAO,MAAM;CACtC,OAAOA,SAAO;AAChB,CAAC;AAED,MAAM,qBAAqBA,SAAO,aAAa,UAAU;CACvD,YAAYA,SAAO;CACnB,QAAQA,SAAO;AACjB,CAAC;AAID,MAAa,0BAA4C;CACvD,QAAQ;CACR,UAAU,CAAC;CACX,cAAc,CAAC;CACf,MAAM;CACN,WAAW;CACX,UAAU,CAAC;CACX,OAAO;CACP,WAAW;CACX,WAAW;CACX,cAAc,CAAC;AACjB;AAEA,MAAM,kBAAkB,UACtB,MAAM,cAAc,OAAO,QAAQ;CAAE,GAAG;CAAO,WAAW;AAAK;AAEjE,MAAM,gBAAgB,OAAyB,UAC7C,MAAM,YAAY,KAAA,KAAa,MAAM,aAAa,SAAS,MAAM,OAAO;AAE1E,MAAM,iBAAiB,OAAyB,UAC9C,MAAM,YAAY,KAAA,IACd,QACA;CAAE,GAAG;CAAO,cAAc,CAAC,GAAG,MAAM,cAAc,MAAM,OAAO;AAAE;AAEvE,MAAM,aAAa,QACjB,MAAM,MAAM,GAAG,EAAE,KACf,MAAM,IAAI,mBAAkB,YAAW,QAAQ,EAAE,GACjD,MAAM,IAAI,WAAU,YAAW,QAAQ,UAAU,GACjD,MAAM,IAAI,sBAAqB,YAAW,QAAQ,QAAQ,UAAU,GACpE,MAAM,IAAI,oBAAoB,sBAAqB,YAAW,QAAQ,SAAS,UAAU,GACzF,MAAM,IAAI,mBAAkB,YAAW,QAAQ,QAAQ,UAAU,GACjE,MAAM,IA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