@yolk-sdk/agent 0.1.0-canary.85 → 0.1.0-canary.86
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 +6 -3
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.mjs +2 -2
- package/dist/client/state.d.mts +93 -10
- package/dist/client/state.d.mts.map +1 -1
- package/dist/client/state.mjs +40 -11
- package/dist/client/state.mjs.map +1 -1
- package/dist/client/transport.d.mts +17 -13
- package/dist/client/transport.d.mts.map +1 -1
- package/dist/client/transport.mjs +11 -2
- package/dist/client/transport.mjs.map +1 -1
- package/dist/loop/index.d.mts +3 -3
- package/dist/loop/index.mjs +2 -2
- package/dist/loop/run.d.mts +22 -4
- package/dist/loop/run.d.mts.map +1 -1
- package/dist/loop/run.mjs +125 -15
- package/dist/loop/run.mjs.map +1 -1
- package/dist/loop/services/tool-executor.d.mts +10 -4
- package/dist/loop/services/tool-executor.d.mts.map +1 -1
- package/dist/loop/services/tool-executor.mjs +1 -1
- package/dist/loop/services/tool-executor.mjs.map +1 -1
- package/dist/protocol/event.d.mts +26 -4
- package/dist/protocol/event.d.mts.map +1 -1
- package/dist/protocol/event.mjs +36 -2
- package/dist/protocol/event.mjs.map +1 -1
- package/dist/protocol/index.d.mts +4 -4
- package/dist/protocol/index.d.mts.map +1 -1
- package/dist/protocol/index.mjs +4 -4
- package/dist/protocol/session.d.mts +12 -5
- package/dist/protocol/session.d.mts.map +1 -1
- package/dist/protocol/session.mjs +10 -3
- package/dist/protocol/session.mjs.map +1 -1
- package/dist/protocol/tool.d.mts +422 -7
- package/dist/protocol/tool.d.mts.map +1 -1
- package/dist/protocol/tool.mjs +290 -6
- package/dist/protocol/tool.mjs.map +1 -1
- package/dist/providers/openai/realtime/session-config.d.mts.map +1 -1
- package/dist/providers/openai/realtime/session-config.mjs +1 -0
- package/dist/providers/openai/realtime/session-config.mjs.map +1 -1
- package/dist/react/chat-core.d.mts.map +1 -1
- package/dist/react/chat-core.mjs +3 -3
- package/dist/react/chat-core.mjs.map +1 -1
- package/dist/react/chat-items.d.mts +74 -4
- package/dist/react/chat-items.d.mts.map +1 -1
- package/dist/react/chat-items.mjs +14 -0
- package/dist/react/chat-items.mjs.map +1 -1
- package/dist/react/chat-messages.d.mts +74 -4
- package/dist/react/chat-messages.d.mts.map +1 -1
- package/dist/react/chat-messages.mjs +33 -10
- package/dist/react/chat-messages.mjs.map +1 -1
- package/dist/react/use-agent-chat.d.mts +2 -1
- package/dist/react/use-agent-chat.d.mts.map +1 -1
- package/dist/react/use-agent-chat.mjs +2 -0
- package/dist/react/use-agent-chat.mjs.map +1 -1
- package/dist/runtime/run-runtime.d.mts +4 -2
- package/dist/runtime/run-runtime.d.mts.map +1 -1
- package/dist/runtime/run-runtime.mjs +3 -1
- package/dist/runtime/run-runtime.mjs.map +1 -1
- package/dist/runtime/session-event-store.d.mts +2 -2
- package/dist/tools/index.d.mts +3 -2
- package/dist/tools/index.mjs +2 -1
- package/dist/tools/interaction.d.mts +55 -0
- package/dist/tools/interaction.d.mts.map +1 -0
- package/dist/tools/interaction.mjs +112 -0
- package/dist/tools/interaction.mjs.map +1 -0
- package/dist/tools/registry.d.mts +55 -5
- package/dist/tools/registry.d.mts.map +1 -1
- package/dist/tools/registry.mjs +160 -5
- package/dist/tools/registry.mjs.map +1 -1
- package/dist/voice/controller.mjs.map +1 -1
- package/dist/voice/index.d.mts +2 -2
- package/dist/voice/index.mjs +2 -2
- package/dist/voice/protocol.d.mts +2 -2
- package/dist/voice/tool-server.d.mts +5 -1
- package/dist/voice/tool-server.d.mts.map +1 -1
- package/dist/voice/tool-server.mjs +6 -1
- package/dist/voice/tool-server.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +2 -0
- package/src/client/state.ts +135 -5
- package/src/client/transport.ts +17 -0
- package/src/loop/index.ts +9 -1
- package/src/loop/run.ts +258 -30
- package/src/loop/services/tool-executor.ts +16 -3
- package/src/protocol/event.ts +76 -0
- package/src/protocol/index.ts +36 -1
- package/src/protocol/session.ts +18 -2
- package/src/protocol/tool.ts +622 -4
- package/src/providers/openai/realtime/session-config.ts +8 -0
- package/src/react/chat-core.ts +9 -3
- package/src/react/chat-items.ts +36 -0
- package/src/react/chat-messages.ts +158 -5
- package/src/react/use-agent-chat.ts +7 -0
- package/src/runtime/run-runtime.ts +14 -0
- package/src/tools/README.md +39 -0
- package/src/tools/index.ts +16 -0
- package/src/tools/interaction.ts +300 -0
- package/src/tools/registry.ts +451 -52
- package/src/voice/controller.ts +2 -1
- package/src/voice/index.ts +1 -0
- package/src/voice/tool-server.ts +12 -0
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Published package metadata requires Node.js 22+.
|
|
|
26
26
|
| `@yolk-sdk/agent/runtime` | Transcript or append-backed runtime orchestration |
|
|
27
27
|
| `@yolk-sdk/agent/client` | HTTP/NDJSON transport, HITL resume, retry/error state helpers |
|
|
28
28
|
| `@yolk-sdk/agent/compaction` | Host-owned compaction budgets, checkpoints, formatting, retry |
|
|
29
|
-
| `@yolk-sdk/agent/tools` | Tool registry, typed inputs,
|
|
29
|
+
| `@yolk-sdk/agent/tools` | Tool registry, typed inputs, interactions, subagents/questions |
|
|
30
30
|
| `@yolk-sdk/agent/react` | Headless React chat hook, reducer, selectors, and render model |
|
|
31
31
|
| `@yolk-sdk/agent/oauth` | Provider-neutral OAuth token and broker contracts |
|
|
32
32
|
| `@yolk-sdk/agent/providers/openai` | OpenAI/Codex OAuth and broker helpers |
|
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
makeWindowCompactionTransformer
|
|
83
83
|
} from '@yolk-sdk/agent/compaction'
|
|
84
84
|
import {
|
|
85
|
+
makeInteractionTool,
|
|
85
86
|
makeNonRecursiveSubagentToolModule,
|
|
86
87
|
makeSubagentToolResult,
|
|
87
88
|
modelVisibleToolError,
|
|
@@ -635,9 +636,11 @@ HITL is protocol-level, not UI-level:
|
|
|
635
636
|
- Use `makeQuestionToolModule` to expose the package-owned `question` tool; answers resume as structured tool results and model-visible text with selected labels. The loop intercepts questions only when the tool is enabled in `tools`; omitted questions return an unavailable result without HITL or executor dispatch, even if a provider emits one.
|
|
636
637
|
- Use `makeInputTool({ name, description, response, renderer })` for custom typed input. Apps own the response Effect schema and renderer; the SDK carries JSON data only. Pass `resolveTools(...).inputs` alongside `tools` to loop/runtime configs. The original `callParameters` and `response` schemas validate server-side, including refinements; display JSON Schema is not the validator. Invalid calls fail before prompting; invalid submissions remain pending for correction. The first valid submission or cancellation settles the request and cannot be overwritten by stale responses.
|
|
637
638
|
- Resume custom inputs with `submitInputResponse`, `streamInputResponseEventStream`, or WebSocket `InputResponseInput`. Echo request/call IDs; do not reconstruct them. Input collection is not authorization: a draft composer never grants permission to send. Input tools cannot carry approval/background policy or execute directly.
|
|
638
|
-
- Use `
|
|
639
|
+
- Use `makeInteractionTool` when a person must edit proposed values and authorize one server-defined action. Unlike data-only inputs, interactions execute the selected action on the exact validated values before the next model turn. Hosts own renderers, authentication, scoped immutable receipt storage, and atomic acceptance; browser responses alone never authorize execution. Pass `interactionHost` to `resolveTools`, then both `toolSet.interactions` and `toolSet.interactionHost` to loop/runtime configs. Durable hosts load `loadInteractionReceipts` before passing `interactionReceipts` to `prepareToolBatch`.
|
|
640
|
+
- Submit interactions with `submitInteractionResponse`, `streamInteractionResponseEventStream`, or WebSocket `InteractionResponseInput`; the host must authenticate and atomically accept the response server-side before SDK resume. Submission is not completion; only real server results settle the UI. An `unknown` outcome needs host reconciliation, never automatic action retry. Voice/realtime and background activation are unsupported. See [action-backed interactions](https://github.com/magoz/yolk-sdk/blob/main/packages/agent/src/tools/README.md#action-backed-interactions) for registration and host-boundary details.
|
|
641
|
+
- Use `questionResponseStructuredContent` / `plainHitlResponse` before storing durable HITL payloads that must be plain JSON. `PlainHitlResponse` is a `Data.taggedEnum` value (`QuestionResponse` / `ToolApprovalResponse` / `InputResponse` / `InteractionResponse`); the helpers omit absent optionals then call those constructors (`_tag` last, plain objects, not Schema classes).
|
|
639
642
|
- Use `toolRunsFromHitlRequests` to hydrate paused UI state from `AgentAwaitingInput.requests`.
|
|
640
|
-
- Use `hitlResponseEvent` when a client needs optimistic approval/question UI updates before resumed stream events arrive. Typed input
|
|
643
|
+
- Use `hitlResponseEvent` when a client needs optimistic approval/question UI updates before resumed stream events arrive. Typed input and interaction submissions stay pending until server acceptance; accepted interactions stay active until the actual outcome. Never synthesize an interaction result from local submission or acceptance.
|
|
641
644
|
- Approval is a host-enforced per-call gate for normal tools, not a model-callable permission tool or persisted allow-always system.
|
|
642
645
|
|
|
643
646
|
HTTP client helpers treat `AgentEnd`, `AgentError`, and `AgentAwaitingInput` as logical stream
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { documentPartFromTextFile, textFromBlob } from "./attachments.mjs";
|
|
2
2
|
import { AgentClientState, AgentRunStatus, AgentToolRun, AgentTranscript, ApplyAgentEventOptions, appendAgentMessage, applyAgentEvent, completedToolRuns, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, submitAgentUserMessage, toolRunsFromHitlRequests } from "./state.mjs";
|
|
3
|
-
import { AgentHttpResponseInfo, AgentRunContinuationOptions, AgentRunIdleReconnectOptions, AgentTransportError, CancelAgentRunRequest, StreamAgentEventHandler, StreamAgentEventsRequest, StreamAgentEventsUntilTerminalRequest, StreamAgentRunEventsRequest, StreamAgentRunEventsUntilTerminalRequest, StreamAgentRunHitlResponseEventsRequest, StreamAgentRunHitlResponseEventsUntilTerminalRequest, StreamCloudflareAgentEventsRequest, SubmitInputResponseRequest, SubmitQuestionResponseRequest, SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
-
export { type AgentClientState, type AgentHttpResponseInfo, type AgentRunContinuationOptions, type AgentRunIdleReconnectOptions, type AgentRunStatus, type AgentToolRun, type AgentTranscript, AgentTransportError, type ApplyAgentEventOptions, type CancelAgentRunRequest, type StreamAgentEventHandler, type StreamAgentEventsRequest, type StreamAgentEventsUntilTerminalRequest, type StreamAgentRunEventsRequest, type StreamAgentRunEventsUntilTerminalRequest, type StreamAgentRunHitlResponseEventsRequest, type StreamAgentRunHitlResponseEventsUntilTerminalRequest, type StreamCloudflareAgentEventsRequest, type SubmitInputResponseRequest, type SubmitQuestionResponseRequest, type SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
|
3
|
+
import { AgentHttpResponseInfo, AgentRunContinuationOptions, AgentRunIdleReconnectOptions, AgentTransportError, CancelAgentRunRequest, StreamAgentEventHandler, StreamAgentEventsRequest, StreamAgentEventsUntilTerminalRequest, StreamAgentRunEventsRequest, StreamAgentRunEventsUntilTerminalRequest, StreamAgentRunHitlResponseEventsRequest, StreamAgentRunHitlResponseEventsUntilTerminalRequest, StreamCloudflareAgentEventsRequest, SubmitInputResponseRequest, SubmitInteractionResponseRequest, SubmitQuestionResponseRequest, SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamInteractionResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
+
export { type AgentClientState, type AgentHttpResponseInfo, type AgentRunContinuationOptions, type AgentRunIdleReconnectOptions, type AgentRunStatus, type AgentToolRun, type AgentTranscript, AgentTransportError, type ApplyAgentEventOptions, type CancelAgentRunRequest, type StreamAgentEventHandler, type StreamAgentEventsRequest, type StreamAgentEventsUntilTerminalRequest, type StreamAgentRunEventsRequest, type StreamAgentRunEventsUntilTerminalRequest, type StreamAgentRunHitlResponseEventsRequest, type StreamAgentRunHitlResponseEventsUntilTerminalRequest, type StreamCloudflareAgentEventsRequest, type SubmitInputResponseRequest, type SubmitInteractionResponseRequest, type SubmitQuestionResponseRequest, type SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamInteractionResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { documentPartFromTextFile, textFromBlob } from "./attachments.mjs";
|
|
2
2
|
import { appendAgentMessage, applyAgentEvent, completedToolRuns, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, submitAgentUserMessage, toolRunsFromHitlRequests } from "./state.mjs";
|
|
3
|
-
import { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
-
export { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
|
3
|
+
import { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamInteractionResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
+
export { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamInteractionResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
package/dist/client/state.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Data } from "effect";
|
|
2
|
-
import { AgentError, AgentEvent, AgentMessage, AgentRetry, HitlRequest, InputRequest, InputResponse, QuestionRequest, QuestionResponse, ToolApprovalRequest, ToolCall, ToolResult, UserMessage } from "@yolk-sdk/agent/protocol";
|
|
2
|
+
import { AgentError, AgentEvent, AgentMessage, AgentRetry, HitlRequest, InputRequest, InputResponse, InteractionRequest, InteractionResponse, QuestionRequest, QuestionResponse, ToolApprovalRequest, ToolCall, ToolResult, UserMessage } from "@yolk-sdk/agent/protocol";
|
|
3
3
|
|
|
4
4
|
//#region src/client/state.d.ts
|
|
5
5
|
type AgentRunStatus = 'idle' | 'running' | 'waiting' | 'done' | 'error' | 'aborted';
|
|
@@ -41,10 +41,22 @@ type AgentToolRun = {
|
|
|
41
41
|
readonly _tag: 'InputCancelled';
|
|
42
42
|
readonly response: InputResponse;
|
|
43
43
|
readonly request?: InputRequest;
|
|
44
|
+
} | {
|
|
45
|
+
readonly _tag: 'InteractionRequested';
|
|
46
|
+
readonly request: InteractionRequest;
|
|
47
|
+
} | {
|
|
48
|
+
readonly _tag: 'InteractionSubmitted';
|
|
49
|
+
readonly response: InteractionResponse;
|
|
50
|
+
readonly request?: InteractionRequest;
|
|
51
|
+
} | {
|
|
52
|
+
readonly _tag: 'InteractionCancelled';
|
|
53
|
+
readonly response: InteractionResponse;
|
|
54
|
+
readonly request?: InteractionRequest;
|
|
44
55
|
} | {
|
|
45
56
|
readonly _tag: 'Executing';
|
|
46
57
|
readonly call: ToolCall;
|
|
47
|
-
readonly startedAtMs: number;
|
|
58
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
59
|
+
readonly interaction?: true;
|
|
48
60
|
} | {
|
|
49
61
|
readonly _tag: 'Completed';
|
|
50
62
|
readonly call: ToolCall;
|
|
@@ -96,6 +108,20 @@ declare const AgentToolRun: {
|
|
|
96
108
|
readonly response: InputResponse;
|
|
97
109
|
readonly request?: InputRequest;
|
|
98
110
|
}, "_tag">;
|
|
111
|
+
readonly InteractionRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
112
|
+
readonly _tag: "InteractionRequested";
|
|
113
|
+
readonly request: InteractionRequest;
|
|
114
|
+
}, "_tag">;
|
|
115
|
+
readonly InteractionSubmitted: Data.TaggedEnum.ConstructorFrom<{
|
|
116
|
+
readonly _tag: "InteractionSubmitted";
|
|
117
|
+
readonly response: InteractionResponse;
|
|
118
|
+
readonly request?: InteractionRequest;
|
|
119
|
+
}, "_tag">;
|
|
120
|
+
readonly InteractionCancelled: Data.TaggedEnum.ConstructorFrom<{
|
|
121
|
+
readonly _tag: "InteractionCancelled";
|
|
122
|
+
readonly response: InteractionResponse;
|
|
123
|
+
readonly request?: InteractionRequest;
|
|
124
|
+
}, "_tag">;
|
|
99
125
|
readonly Completed: Data.TaggedEnum.ConstructorFrom<{
|
|
100
126
|
readonly _tag: "Completed";
|
|
101
127
|
readonly call: ToolCall;
|
|
@@ -144,9 +170,10 @@ declare const AgentToolRun: {
|
|
|
144
170
|
readonly Executing: Data.TaggedEnum.ConstructorFrom<{
|
|
145
171
|
readonly _tag: "Executing";
|
|
146
172
|
readonly call: ToolCall;
|
|
147
|
-
readonly startedAtMs: number;
|
|
173
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
174
|
+
readonly interaction?: true;
|
|
148
175
|
}, "_tag">;
|
|
149
|
-
readonly $is: <Tag extends "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "Completed" | "Accepted" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
176
|
+
readonly $is: <Tag extends "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Completed" | "Accepted" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
150
177
|
readonly _tag: "InputStreaming";
|
|
151
178
|
readonly id: string;
|
|
152
179
|
readonly name?: string;
|
|
@@ -204,10 +231,28 @@ declare const AgentToolRun: {
|
|
|
204
231
|
readonly request?: InputRequest;
|
|
205
232
|
}, {
|
|
206
233
|
readonly _tag: Tag;
|
|
234
|
+
}> | Extract<{
|
|
235
|
+
readonly _tag: "InteractionRequested";
|
|
236
|
+
readonly request: InteractionRequest;
|
|
237
|
+
}, {
|
|
238
|
+
readonly _tag: Tag;
|
|
239
|
+
}> | Extract<{
|
|
240
|
+
readonly _tag: "InteractionSubmitted";
|
|
241
|
+
readonly response: InteractionResponse;
|
|
242
|
+
readonly request?: InteractionRequest;
|
|
243
|
+
}, {
|
|
244
|
+
readonly _tag: Tag;
|
|
245
|
+
}> | Extract<{
|
|
246
|
+
readonly _tag: "InteractionCancelled";
|
|
247
|
+
readonly response: InteractionResponse;
|
|
248
|
+
readonly request?: InteractionRequest;
|
|
249
|
+
}, {
|
|
250
|
+
readonly _tag: Tag;
|
|
207
251
|
}> | Extract<{
|
|
208
252
|
readonly _tag: "Executing";
|
|
209
253
|
readonly call: ToolCall;
|
|
210
|
-
readonly startedAtMs: number;
|
|
254
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
255
|
+
readonly interaction?: true;
|
|
211
256
|
}, {
|
|
212
257
|
readonly _tag: Tag;
|
|
213
258
|
}> | Extract<{
|
|
@@ -270,6 +315,20 @@ declare const AgentToolRun: {
|
|
|
270
315
|
readonly response: InputResponse;
|
|
271
316
|
readonly request?: InputRequest;
|
|
272
317
|
}) => any;
|
|
318
|
+
readonly InteractionRequested: (args: {
|
|
319
|
+
readonly _tag: "InteractionRequested";
|
|
320
|
+
readonly request: InteractionRequest;
|
|
321
|
+
}) => any;
|
|
322
|
+
readonly InteractionSubmitted: (args: {
|
|
323
|
+
readonly _tag: "InteractionSubmitted";
|
|
324
|
+
readonly response: InteractionResponse;
|
|
325
|
+
readonly request?: InteractionRequest;
|
|
326
|
+
}) => any;
|
|
327
|
+
readonly InteractionCancelled: (args: {
|
|
328
|
+
readonly _tag: "InteractionCancelled";
|
|
329
|
+
readonly response: InteractionResponse;
|
|
330
|
+
readonly request?: InteractionRequest;
|
|
331
|
+
}) => any;
|
|
273
332
|
readonly Completed: (args: {
|
|
274
333
|
readonly _tag: "Completed";
|
|
275
334
|
readonly call: ToolCall;
|
|
@@ -318,9 +377,10 @@ declare const AgentToolRun: {
|
|
|
318
377
|
readonly Executing: (args: {
|
|
319
378
|
readonly _tag: "Executing";
|
|
320
379
|
readonly call: ToolCall;
|
|
321
|
-
readonly startedAtMs: number;
|
|
380
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
381
|
+
readonly interaction?: true;
|
|
322
382
|
}) => any;
|
|
323
|
-
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "Completed" | "Accepted" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing"]>>;
|
|
383
|
+
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Completed" | "Accepted" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing"]>>;
|
|
324
384
|
<Cases extends {
|
|
325
385
|
readonly QuestionRequested: (args: {
|
|
326
386
|
readonly _tag: "QuestionRequested";
|
|
@@ -350,6 +410,20 @@ declare const AgentToolRun: {
|
|
|
350
410
|
readonly response: InputResponse;
|
|
351
411
|
readonly request?: InputRequest;
|
|
352
412
|
}) => any;
|
|
413
|
+
readonly InteractionRequested: (args: {
|
|
414
|
+
readonly _tag: "InteractionRequested";
|
|
415
|
+
readonly request: InteractionRequest;
|
|
416
|
+
}) => any;
|
|
417
|
+
readonly InteractionSubmitted: (args: {
|
|
418
|
+
readonly _tag: "InteractionSubmitted";
|
|
419
|
+
readonly response: InteractionResponse;
|
|
420
|
+
readonly request?: InteractionRequest;
|
|
421
|
+
}) => any;
|
|
422
|
+
readonly InteractionCancelled: (args: {
|
|
423
|
+
readonly _tag: "InteractionCancelled";
|
|
424
|
+
readonly response: InteractionResponse;
|
|
425
|
+
readonly request?: InteractionRequest;
|
|
426
|
+
}) => any;
|
|
353
427
|
readonly Completed: (args: {
|
|
354
428
|
readonly _tag: "Completed";
|
|
355
429
|
readonly call: ToolCall;
|
|
@@ -398,9 +472,10 @@ declare const AgentToolRun: {
|
|
|
398
472
|
readonly Executing: (args: {
|
|
399
473
|
readonly _tag: "Executing";
|
|
400
474
|
readonly call: ToolCall;
|
|
401
|
-
readonly startedAtMs: number;
|
|
475
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
476
|
+
readonly interaction?: true;
|
|
402
477
|
}) => any;
|
|
403
|
-
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "Completed" | "Accepted" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing"]>>;
|
|
478
|
+
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Completed" | "Accepted" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing"]>>;
|
|
404
479
|
};
|
|
405
480
|
};
|
|
406
481
|
type AgentClientState = {
|
|
@@ -438,10 +513,18 @@ declare const isActiveToolRun: (run: AgentToolRun) => run is {
|
|
|
438
513
|
} | {
|
|
439
514
|
readonly _tag: "InputRequested";
|
|
440
515
|
readonly request: InputRequest;
|
|
516
|
+
} | {
|
|
517
|
+
readonly _tag: "InteractionRequested";
|
|
518
|
+
readonly request: InteractionRequest;
|
|
519
|
+
} | {
|
|
520
|
+
readonly _tag: "InteractionSubmitted";
|
|
521
|
+
readonly response: InteractionResponse;
|
|
522
|
+
readonly request?: InteractionRequest;
|
|
441
523
|
} | {
|
|
442
524
|
readonly _tag: "Executing";
|
|
443
525
|
readonly call: ToolCall;
|
|
444
|
-
readonly startedAtMs: number;
|
|
526
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
527
|
+
readonly interaction?: true;
|
|
445
528
|
};
|
|
446
529
|
declare const completedToolRuns: (runs: ReadonlyArray<AgentToolRun>) => {
|
|
447
530
|
readonly _tag: "Completed";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.mts","names":[],"sources":["../../src/client/state.ts"],"mappings":";;;;
|
|
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,QAAA,EAAU,aAAA;EAAA,SACV,OAAA,GAAU,YAAA;AAAA;EAAA,SAGV,IAAA;EAAA,SACA,QAAA,EAAU,aAAA;EAAA,SACV,OAAA,GAAU,YAAA;AAAA;EAAA,SAEV,IAAA;EAAA,SAAuC,OAAA,EAAS,kBAAA;AAAA;EAAA,SAEhD,IAAA;EAAA,SACA,QAAA,EAAU,mBAAA;EAAA,SACV,OAAA,GAAU,kBAAA;AAAA;EAAA,SAGV,IAAA;E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A;;;;;;iBA7JC,QAAA;AAAA;EAAA;iBAG7B,QAAA;EAAA,mBACI,mBAAA;AAAA;EAAA;oBAGmC,eAAA;AAAA;EAAA;oBAWH,YAAA;AAAA;EAAA;oBAWM,kBAAA;AAAA;EAAA;qBAGtC,mBAAA;EAAA,mBACA,kBAAA;AAAA;EAAA;iBASJ,QAAA;EAAA;;;cA+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,cA2SU,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
|
@@ -32,14 +32,14 @@ const rememberEvent = (state, event) => event.eventId === void 0 ? state : {
|
|
|
32
32
|
...state,
|
|
33
33
|
seenEventIds: [...state.seenEventIds, event.eventId]
|
|
34
34
|
};
|
|
35
|
-
const toolRunId = (run) => Match.value(run).pipe(Match.tag("InputStreaming", (current) => current.id), Match.tag("Denied", (current) => current.toolCallId), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.response.toolCallId), Match.tag("InputRequested", (current) => current.request.toolCallId), Match.tag("InputSubmitted", "InputCancelled", (current) => current.response.toolCallId), Match.tag("InputReady", "ApprovalRequested", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", (current) => current.call.id), Match.exhaustive);
|
|
36
|
-
const isActiveToolRun = (run) => !Predicate.isTagged(run, "Accepted") && !Predicate.isTagged(run, "Completed") && !Predicate.isTagged(run, "Errored") && !Predicate.isTagged(run, "Denied") && !Predicate.isTagged(run, "QuestionAnswered") && !Predicate.isTagged(run, "QuestionCancelled") && !Predicate.isTagged(run, "InputSubmitted") && !Predicate.isTagged(run, "InputCancelled") && !Predicate.isTagged(run, "ProviderCompleted");
|
|
35
|
+
const toolRunId = (run) => Match.value(run).pipe(Match.tag("InputStreaming", (current) => current.id), Match.tag("Denied", (current) => current.toolCallId), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.response.toolCallId), Match.tag("InputRequested", (current) => current.request.toolCallId), Match.tag("InputSubmitted", "InputCancelled", (current) => current.response.toolCallId), Match.tag("InteractionRequested", (current) => current.request.toolCallId), Match.tag("InteractionSubmitted", "InteractionCancelled", (current) => current.response.toolCallId), Match.tag("InputReady", "ApprovalRequested", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", (current) => current.call.id), Match.exhaustive);
|
|
36
|
+
const isActiveToolRun = (run) => !Predicate.isTagged(run, "Accepted") && !Predicate.isTagged(run, "Completed") && !Predicate.isTagged(run, "Errored") && !Predicate.isTagged(run, "Denied") && !Predicate.isTagged(run, "QuestionAnswered") && !Predicate.isTagged(run, "QuestionCancelled") && !Predicate.isTagged(run, "InputSubmitted") && !Predicate.isTagged(run, "InputCancelled") && !Predicate.isTagged(run, "InteractionCancelled") && !Predicate.isTagged(run, "ProviderCompleted");
|
|
37
37
|
const completedToolRuns = (runs) => runs.filter((run) => Predicate.isTagged(run, "Completed"));
|
|
38
|
-
const retainedSettledToolRuns = (runs) => runs.filter((run) => Predicate.isTagged(run, "Completed") || Predicate.isTagged(run, "Accepted"));
|
|
38
|
+
const retainedSettledToolRuns = (runs) => runs.filter((run) => Predicate.isTagged(run, "Completed") || Predicate.isTagged(run, "Accepted") || Predicate.isTagged(run, "InteractionSubmitted") || Predicate.isTagged(run, "Executing") && run.interaction === true);
|
|
39
39
|
const toolRunsFromHitlRequests = (requests) => requests.map((request) => Match.value(request).pipe(Match.tag("QuestionRequest", (current) => AgentToolRun.QuestionRequested({ request: current })), Match.tag("ToolApprovalRequest", (current) => AgentToolRun.ApprovalRequested({
|
|
40
40
|
call: current.call,
|
|
41
41
|
request: current
|
|
42
|
-
})), Match.tag("InputRequest", (current) => AgentToolRun.InputRequested({ request: current })), Match.exhaustive));
|
|
42
|
+
})), Match.tag("InputRequest", (current) => AgentToolRun.InputRequested({ request: current })), Match.tag("InteractionRequest", (current) => AgentToolRun.InteractionRequested({ request: current })), Match.exhaustive));
|
|
43
43
|
const replaceToolRun = (runs, run) => {
|
|
44
44
|
const id = toolRunId(run);
|
|
45
45
|
const replaceIndex = runs.findIndex((current) => toolRunId(current) === id);
|
|
@@ -58,11 +58,11 @@ const appendToolInputDelta = (runs, id, delta) => runs.map((run) => Predicate.is
|
|
|
58
58
|
} : run);
|
|
59
59
|
const questionRequestForToolCall = (runs, toolCallId) => runs.flatMap((run) => {
|
|
60
60
|
if (toolRunId(run) !== toolCallId) return [];
|
|
61
|
-
return Match.value(run).pipe(Match.tag("QuestionRequested", (current) => [current.request]), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "InputRequested", "InputSubmitted", "InputCancelled", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", () => []), Match.exhaustive);
|
|
61
|
+
return Match.value(run).pipe(Match.tag("QuestionRequested", (current) => [current.request]), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "InputRequested", "InputSubmitted", "InputCancelled", "InteractionRequested", "InteractionSubmitted", "InteractionCancelled", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", () => []), Match.exhaustive);
|
|
62
62
|
})[0];
|
|
63
63
|
const inputRequestForToolCall = (runs, toolCallId) => runs.flatMap((run) => {
|
|
64
64
|
if (toolRunId(run) !== toolCallId) return [];
|
|
65
|
-
return Match.value(run).pipe(Match.tag("InputRequested", (current) => [current.request]), Match.tag("InputSubmitted", "InputCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", "QuestionRequested", "QuestionAnswered", "QuestionCancelled", () => []), Match.exhaustive);
|
|
65
|
+
return Match.value(run).pipe(Match.tag("InputRequested", (current) => [current.request]), Match.tag("InputSubmitted", "InputCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "InteractionRequested", "InteractionSubmitted", "InteractionCancelled", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", "QuestionRequested", "QuestionAnswered", "QuestionCancelled", () => []), Match.exhaustive);
|
|
66
66
|
})[0];
|
|
67
67
|
const inputSubmittedRun = (response, request) => request === void 0 ? AgentToolRun.InputSubmitted({ response }) : AgentToolRun.InputSubmitted({
|
|
68
68
|
response,
|
|
@@ -80,6 +80,18 @@ const questionCancelledRun = (response, request) => request === void 0 ? AgentTo
|
|
|
80
80
|
response,
|
|
81
81
|
request
|
|
82
82
|
});
|
|
83
|
+
const interactionSubmittedRun = (response, request) => request === void 0 ? AgentToolRun.InteractionSubmitted({ response }) : AgentToolRun.InteractionSubmitted({
|
|
84
|
+
response,
|
|
85
|
+
request
|
|
86
|
+
});
|
|
87
|
+
const interactionCancelledRun = (response, request) => request === void 0 ? AgentToolRun.InteractionCancelled({ response }) : AgentToolRun.InteractionCancelled({
|
|
88
|
+
response,
|
|
89
|
+
request
|
|
90
|
+
});
|
|
91
|
+
const interactionRequestForToolCall = (runs, toolCallId) => runs.flatMap((run) => {
|
|
92
|
+
if (toolRunId(run) !== toolCallId) return [];
|
|
93
|
+
return Match.value(run).pipe(Match.tag("InteractionRequested", (current) => [current.request]), Match.tag("InteractionSubmitted", "InteractionCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "InputRequested", "InputSubmitted", "InputCancelled", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", "QuestionRequested", "QuestionAnswered", "QuestionCancelled", () => []), Match.exhaustive);
|
|
94
|
+
})[0];
|
|
83
95
|
const appendAgentMessage = (messages, message) => {
|
|
84
96
|
const first = messages[0];
|
|
85
97
|
if (first === void 0) return [message];
|
|
@@ -97,7 +109,7 @@ const applyAgentEventWithOptions = (state, event, options = {}) => {
|
|
|
97
109
|
if (hasSeenEvent(state, event)) return state;
|
|
98
110
|
return rememberEvent(applyAgentEventUnchecked(state, event, nowMs), event);
|
|
99
111
|
};
|
|
100
|
-
const activeEventToolCallId = (event) => Match.value(event).pipe(Match.tag("ToolInputStart", "ToolInputDelta", (current) => current.id), Match.tag("ToolInputEnd", "ToolExecutionStarted", "ToolApprovalRequested", (current) => current.call.id), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.tag("InputRequested", (current) => current.request.toolCallId), Match.orElse(() => void 0));
|
|
112
|
+
const activeEventToolCallId = (event) => Match.value(event).pipe(Match.tag("ToolInputStart", "ToolInputDelta", (current) => current.id), Match.tag("ToolInputEnd", "ToolExecutionStarted", "ToolApprovalRequested", (current) => current.call.id), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.tag("InputRequested", (current) => current.request.toolCallId), Match.tag("InteractionRequested", (current) => current.request.toolCallId), Match.orElse(() => void 0));
|
|
101
113
|
const applyAgentEventUnchecked = (state, event, nowMs) => {
|
|
102
114
|
const activeCallId = activeEventToolCallId(event);
|
|
103
115
|
const acknowledgesActiveCall = (message) => Predicate.isTagged(message, "ToolResult") && message.toolCallId === activeCallId && message.acceptance !== void 0;
|
|
@@ -152,6 +164,9 @@ const applyAgentEventUnchecked = (state, event, nowMs) => {
|
|
|
152
164
|
})), Match.tag("InputRequested", (current) => ({
|
|
153
165
|
...state,
|
|
154
166
|
toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.InputRequested({ request: current.request }))
|
|
167
|
+
})), Match.tag("InteractionRequested", (current) => ({
|
|
168
|
+
...state,
|
|
169
|
+
toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.InteractionRequested({ request: current.request }))
|
|
155
170
|
}))).pipe(Match.tag("QuestionAnswered", (current) => ({
|
|
156
171
|
...state,
|
|
157
172
|
toolRuns: replaceToolRun(state.toolRuns, questionAnsweredRun(current.response, questionRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
@@ -164,13 +179,27 @@ const applyAgentEventUnchecked = (state, event, nowMs) => {
|
|
|
164
179
|
})), Match.tag("InputCancelled", (current) => ({
|
|
165
180
|
...state,
|
|
166
181
|
toolRuns: replaceToolRun(state.toolRuns, inputCancelledRun(current.response, inputRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
167
|
-
})), Match.tag("
|
|
182
|
+
})), Match.tag("InteractionSubmitted", (current) => ({
|
|
168
183
|
...state,
|
|
169
|
-
toolRuns: replaceToolRun(state.toolRuns,
|
|
184
|
+
toolRuns: replaceToolRun(state.toolRuns, interactionSubmittedRun(current.response, interactionRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
185
|
+
})), Match.tag("InteractionCancelled", (current) => ({
|
|
186
|
+
...state,
|
|
187
|
+
toolRuns: replaceToolRun(state.toolRuns, interactionCancelledRun(current.response, interactionRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
188
|
+
})), Match.tag("ToolExecutionStarted", (current) => {
|
|
189
|
+
const prior = state.toolRuns.find((run) => toolRunId(run) === current.call.id);
|
|
190
|
+
const executing = AgentToolRun.Executing({
|
|
170
191
|
call: current.call,
|
|
171
192
|
startedAtMs: nowMs
|
|
172
|
-
})
|
|
173
|
-
|
|
193
|
+
});
|
|
194
|
+
const isInteraction = Predicate.isTagged(prior, "InteractionSubmitted") || Predicate.isTagged(prior, "Executing") && prior.interaction === true;
|
|
195
|
+
return {
|
|
196
|
+
...state,
|
|
197
|
+
toolRuns: replaceToolRun(state.toolRuns, isInteraction ? {
|
|
198
|
+
...executing,
|
|
199
|
+
interaction: true
|
|
200
|
+
} : executing)
|
|
201
|
+
};
|
|
202
|
+
}), Match.tag("ToolExecutionAccepted", "ToolExecutionCompleted", (current) => {
|
|
174
203
|
const endedAtMs = nowMs;
|
|
175
204
|
const startedAtMs = startedAtMsFor(state.toolRuns, current.call.id) ?? endedAtMs;
|
|
176
205
|
return {
|
|
@@ -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 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: 'Executing'; readonly call: ToolCall; readonly startedAtMs: number }\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(\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, 'ProviderCompleted')\n\nexport const completedToolRuns = (runs: ReadonlyArray<AgentToolRun>) =>\n runs.filter(run => Predicate.isTagged(run, 'Completed'))\n\n// Retention is not completion: an acknowledgement remains replay-fenced between turns.\nconst retainedSettledToolRuns = (runs: ReadonlyArray<AgentToolRun>) =>\n runs.filter(run => Predicate.isTagged(run, 'Completed') || Predicate.isTagged(run, 'Accepted'))\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.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 '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 '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\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.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 )\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('ToolExecutionStarted', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.Executing({ call: current.call, startedAtMs: nowMs })\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":";;;AA+EA,MAAa,eAAe,KAAK,WAAyB;AAwB1D,MAAM,6BAA6B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I,uBAAsB,aAAY;EAC1C,GAAG;EACH,QAAQ;EACR,UAAU,CAAC,GAAG,MAAM,UAAU,GAAG,QAAQ,QAAQ;EACjD,cAAc,CAAC;EACf,MAAM;EACN,WAAW;EACX,OAAO;EACP,WAAW;EACX,WAAW;CACb,EAAE,GACF,MAAM,IAAI,eAAc,aAAY;EAAE,GAAG;EAAO,WAAW;CAAQ,EAAE,GACrE,MAAM,IACJ,iBACA,mBACA,gBACA,kBACA,qBACA,mBACA,WACA,aACA,qBACM,KACR,GACA,MAAM,UACR;AACJ;AAEA,MAAa,0BACX,OACA,aACsB;CACtB,GAAG;CACH,QAAQ;CACR,UAAU,mBAAmB,MAAM,UAAU,OAAO;CACpD,cAAc,CAAC;CACf,MAAM;CACN,WAAW;CACX,UAAU,wBAAwB,MAAM,QAAQ;CAChD,OAAO;CACP,WAAW;CACX,WAAW;CACX,cAAc,CAAC;AACjB;AAEA,MAAa,kBACX,OACA,UAAU,wBACV,YAA+B,UACT;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('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;CACv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