@yolk-sdk/agent 0.1.0-canary.112 → 0.1.0-canary.113
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 +17 -3
- package/dist/client/state.d.mts +45 -45
- 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/retry.d.mts +30 -30
- 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/compaction/window.d.mts +39 -39
- package/dist/compaction/window.d.mts.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 +3 -3
- package/dist/loop/run.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/index.d.mts +3 -3
- package/dist/protocol/index.d.mts.map +1 -1
- package/dist/protocol/index.mjs +3 -3
- package/dist/protocol/message.d.mts +32 -2
- 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/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 +160 -43
- 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/xai/grok-provider.d.mts +1 -1
- package/dist/providers/xai/grok-provider.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 +47 -47
- package/dist/react/chat-items.d.mts.map +1 -1
- package/dist/react/chat-messages.d.mts +74 -74
- 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/skillset/merge.d.mts +2 -2
- package/package.json +2 -2
- package/src/client/state.ts +1 -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 +5 -0
- package/src/protocol/event.ts +20 -1
- package/src/protocol/index.ts +4 -0
- package/src/protocol/message.ts +28 -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 +351 -55
- package/src/react/chat-core.ts +1 -0
- package/src/react/chat-messages.ts +3 -0
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ Published package metadata requires Node.js 22+.
|
|
|
49
49
|
| `@yolk-sdk/agent/providers/anthropic` | Anthropic/Claude OAuth and broker helpers |
|
|
50
50
|
| `@yolk-sdk/agent/providers/anthropic/claude` | Claude request and auth helpers |
|
|
51
51
|
| `@yolk-sdk/agent/providers/anthropic/usage` | Claude subscription-allowance snapshots |
|
|
52
|
-
| `@yolk-sdk/agent/providers/anthropic/claude-provider` | Claude LLM provider factory
|
|
52
|
+
| `@yolk-sdk/agent/providers/anthropic/claude-provider` | Claude LLM provider factory, thinking config, and reasoning replay provider id |
|
|
53
53
|
| `@yolk-sdk/agent/providers/anthropic/conformance` | Synthetic Anthropic Messages and Claude usage fixtures and conformance cases |
|
|
54
54
|
| `@yolk-sdk/agent/providers/xai` | Grok subscription OAuth and token broker helpers |
|
|
55
55
|
| `@yolk-sdk/agent/providers/xai/grok` | Grok subscription request and auth helpers |
|
|
@@ -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
|
|
@@ -645,7 +657,9 @@ hidden policy in annotations, author, or timestamps; providers may send them to
|
|
|
645
657
|
|
|
646
658
|
Durable transports may reconnect or replay overlapping chunks. Protocol events can carry optional
|
|
647
659
|
`eventId`; `LLMTextDelta` and `LLMReasoningDelta` can also carry `textSoFar` / `reasoningSoFar`
|
|
648
|
-
snapshots when a host can provide cumulative text.
|
|
660
|
+
snapshots when a host can provide cumulative text. `LLMReasoningReplay` closes a reasoning block
|
|
661
|
+
with opaque provider state; projections can ignore it (the final `AssistantMessage` carries it), but
|
|
662
|
+
exhaustive `AgentEvent` matches need a case.
|
|
649
663
|
|
|
650
664
|
Use `applyAgentEventToChatProjection` for replayable event logs:
|
|
651
665
|
|
package/dist/client/state.d.mts
CHANGED
|
@@ -128,10 +128,6 @@ declare const AgentToolRun: {
|
|
|
128
128
|
readonly name?: string;
|
|
129
129
|
readonly input: string;
|
|
130
130
|
}, "_tag">;
|
|
131
|
-
readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
|
|
132
|
-
readonly _tag: "InputReady";
|
|
133
|
-
readonly call: ToolCall;
|
|
134
|
-
}, "_tag">;
|
|
135
131
|
readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
136
132
|
readonly _tag: "ApprovalRequested";
|
|
137
133
|
readonly call: ToolCall;
|
|
@@ -142,21 +138,15 @@ declare const AgentToolRun: {
|
|
|
142
138
|
readonly toolCallId: string;
|
|
143
139
|
readonly reason: string;
|
|
144
140
|
}, "_tag">;
|
|
145
|
-
readonly
|
|
146
|
-
readonly _tag: "
|
|
147
|
-
readonly call: ToolCall;
|
|
148
|
-
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
149
|
-
readonly interaction?: true;
|
|
150
|
-
}, "_tag">;
|
|
151
|
-
readonly Completed: Data.TaggedEnum.ConstructorFrom<{
|
|
152
|
-
readonly _tag: "Completed";
|
|
141
|
+
readonly Accepted: Data.TaggedEnum.ConstructorFrom<{
|
|
142
|
+
readonly _tag: "Accepted";
|
|
153
143
|
readonly call: ToolCall;
|
|
154
144
|
readonly result: ToolResult;
|
|
155
145
|
readonly startedAtMs: number;
|
|
156
146
|
readonly endedAtMs: number;
|
|
157
147
|
}, "_tag">;
|
|
158
|
-
readonly
|
|
159
|
-
readonly _tag: "
|
|
148
|
+
readonly Completed: Data.TaggedEnum.ConstructorFrom<{
|
|
149
|
+
readonly _tag: "Completed";
|
|
160
150
|
readonly call: ToolCall;
|
|
161
151
|
readonly result: ToolResult;
|
|
162
152
|
readonly startedAtMs: number;
|
|
@@ -173,7 +163,17 @@ declare const AgentToolRun: {
|
|
|
173
163
|
readonly call: ToolCall;
|
|
174
164
|
readonly result: ToolResult;
|
|
175
165
|
}, "_tag">;
|
|
176
|
-
readonly
|
|
166
|
+
readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
|
|
167
|
+
readonly _tag: "InputReady";
|
|
168
|
+
readonly call: ToolCall;
|
|
169
|
+
}, "_tag">;
|
|
170
|
+
readonly Executing: Data.TaggedEnum.ConstructorFrom<{
|
|
171
|
+
readonly _tag: "Executing";
|
|
172
|
+
readonly call: ToolCall;
|
|
173
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
174
|
+
readonly interaction?: true;
|
|
175
|
+
}, "_tag">;
|
|
176
|
+
readonly $is: <Tag extends "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Accepted" | "Completed" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
177
177
|
readonly _tag: "InputStreaming";
|
|
178
178
|
readonly id: string;
|
|
179
179
|
readonly name?: string;
|
|
@@ -335,10 +335,6 @@ declare const AgentToolRun: {
|
|
|
335
335
|
readonly name?: string;
|
|
336
336
|
readonly input: string;
|
|
337
337
|
}) => any;
|
|
338
|
-
readonly InputReady: (args: {
|
|
339
|
-
readonly _tag: "InputReady";
|
|
340
|
-
readonly call: ToolCall;
|
|
341
|
-
}) => any;
|
|
342
338
|
readonly ApprovalRequested: (args: {
|
|
343
339
|
readonly _tag: "ApprovalRequested";
|
|
344
340
|
readonly call: ToolCall;
|
|
@@ -349,21 +345,15 @@ declare const AgentToolRun: {
|
|
|
349
345
|
readonly toolCallId: string;
|
|
350
346
|
readonly reason: string;
|
|
351
347
|
}) => any;
|
|
352
|
-
readonly
|
|
353
|
-
readonly _tag: "
|
|
354
|
-
readonly call: ToolCall;
|
|
355
|
-
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
356
|
-
readonly interaction?: true;
|
|
357
|
-
}) => any;
|
|
358
|
-
readonly Completed: (args: {
|
|
359
|
-
readonly _tag: "Completed";
|
|
348
|
+
readonly Accepted: (args: {
|
|
349
|
+
readonly _tag: "Accepted";
|
|
360
350
|
readonly call: ToolCall;
|
|
361
351
|
readonly result: ToolResult;
|
|
362
352
|
readonly startedAtMs: number;
|
|
363
353
|
readonly endedAtMs: number;
|
|
364
354
|
}) => any;
|
|
365
|
-
readonly
|
|
366
|
-
readonly _tag: "
|
|
355
|
+
readonly Completed: (args: {
|
|
356
|
+
readonly _tag: "Completed";
|
|
367
357
|
readonly call: ToolCall;
|
|
368
358
|
readonly result: ToolResult;
|
|
369
359
|
readonly startedAtMs: number;
|
|
@@ -380,7 +370,17 @@ declare const AgentToolRun: {
|
|
|
380
370
|
readonly call: ToolCall;
|
|
381
371
|
readonly result: ToolResult;
|
|
382
372
|
}) => any;
|
|
383
|
-
|
|
373
|
+
readonly InputReady: (args: {
|
|
374
|
+
readonly _tag: "InputReady";
|
|
375
|
+
readonly call: ToolCall;
|
|
376
|
+
}) => any;
|
|
377
|
+
readonly Executing: (args: {
|
|
378
|
+
readonly _tag: "Executing";
|
|
379
|
+
readonly call: ToolCall;
|
|
380
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
381
|
+
readonly interaction?: true;
|
|
382
|
+
}) => any;
|
|
383
|
+
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Accepted" | "Completed" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing"]>>;
|
|
384
384
|
<Cases extends {
|
|
385
385
|
readonly QuestionRequested: (args: {
|
|
386
386
|
readonly _tag: "QuestionRequested";
|
|
@@ -430,10 +430,6 @@ declare const AgentToolRun: {
|
|
|
430
430
|
readonly name?: string;
|
|
431
431
|
readonly input: string;
|
|
432
432
|
}) => any;
|
|
433
|
-
readonly InputReady: (args: {
|
|
434
|
-
readonly _tag: "InputReady";
|
|
435
|
-
readonly call: ToolCall;
|
|
436
|
-
}) => any;
|
|
437
433
|
readonly ApprovalRequested: (args: {
|
|
438
434
|
readonly _tag: "ApprovalRequested";
|
|
439
435
|
readonly call: ToolCall;
|
|
@@ -444,21 +440,15 @@ declare const AgentToolRun: {
|
|
|
444
440
|
readonly toolCallId: string;
|
|
445
441
|
readonly reason: string;
|
|
446
442
|
}) => any;
|
|
447
|
-
readonly
|
|
448
|
-
readonly _tag: "
|
|
449
|
-
readonly call: ToolCall;
|
|
450
|
-
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
451
|
-
readonly interaction?: true;
|
|
452
|
-
}) => any;
|
|
453
|
-
readonly Completed: (args: {
|
|
454
|
-
readonly _tag: "Completed";
|
|
443
|
+
readonly Accepted: (args: {
|
|
444
|
+
readonly _tag: "Accepted";
|
|
455
445
|
readonly call: ToolCall;
|
|
456
446
|
readonly result: ToolResult;
|
|
457
447
|
readonly startedAtMs: number;
|
|
458
448
|
readonly endedAtMs: number;
|
|
459
449
|
}) => any;
|
|
460
|
-
readonly
|
|
461
|
-
readonly _tag: "
|
|
450
|
+
readonly Completed: (args: {
|
|
451
|
+
readonly _tag: "Completed";
|
|
462
452
|
readonly call: ToolCall;
|
|
463
453
|
readonly result: ToolResult;
|
|
464
454
|
readonly startedAtMs: number;
|
|
@@ -475,7 +465,17 @@ declare const AgentToolRun: {
|
|
|
475
465
|
readonly call: ToolCall;
|
|
476
466
|
readonly result: ToolResult;
|
|
477
467
|
}) => any;
|
|
478
|
-
|
|
468
|
+
readonly InputReady: (args: {
|
|
469
|
+
readonly _tag: "InputReady";
|
|
470
|
+
readonly call: ToolCall;
|
|
471
|
+
}) => any;
|
|
472
|
+
readonly Executing: (args: {
|
|
473
|
+
readonly _tag: "Executing";
|
|
474
|
+
readonly call: ToolCall;
|
|
475
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
476
|
+
readonly interaction?: true;
|
|
477
|
+
}) => any;
|
|
478
|
+
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Accepted" | "Completed" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing"]>>;
|
|
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,OAAA,GAAU,eAAA;AAAA;EAAA,SAGV,IAAA;EAAA,SACA,QAAA,EAAU,gBAAA;EAAA,SACV,OAAA,GAAU,eAAA;AAAA;EAAA,SAEV,IAAA;EAAA,SAAiC,OAAA,EAAS,YAAA;AAAA;EAAA,SAE1C,IAAA;EAAA,SACA,QAA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A+HR,iBAAA,GAAqB,IAAA,EAAM,aAAA,CAAc,YAAA;EAAA;iBAxHjC,QAAA;EAAA,iBACE,UAAA;EAAA;;;cAoIV,wBAAA,GACX,QAAA,EAAU,aAAA,CAAc,WAAA,MACvB,aAAA,CAAc,YAAA;AAAA,cAwNJ,kBAAA,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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T;CACtB,GAAG;CACH,QAAQ;CACR,UAAU,wBAAwB,MAAM,QAAQ;CAChD,OAAO;CACP;CACA,WAAW;AACb;AAEA,MAAa,oBAAoB,WAA+C;CAC9E,GAAG;CACH,QAAQ;CACR,UAAU,wBAAwB,MAAM,QAAQ;CAChD,OAAO;CACP,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,QAA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