@yolk-sdk/agent 0.1.0-canary.81 → 0.1.0-canary.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +12 -8
  2. package/dist/client/index.d.mts +2 -2
  3. package/dist/client/index.mjs +2 -2
  4. package/dist/client/state.d.mts +122 -49
  5. package/dist/client/state.d.mts.map +1 -1
  6. package/dist/client/state.mjs +26 -5
  7. package/dist/client/state.mjs.map +1 -1
  8. package/dist/client/transport.d.mts +16 -12
  9. package/dist/client/transport.d.mts.map +1 -1
  10. package/dist/client/transport.mjs +16 -7
  11. package/dist/client/transport.mjs.map +1 -1
  12. package/dist/compaction/checkpoint.d.mts +2 -2
  13. package/dist/compaction/checkpoint.d.mts.map +1 -1
  14. package/dist/loop/run.d.mts +6 -3
  15. package/dist/loop/run.d.mts.map +1 -1
  16. package/dist/loop/run.mjs +95 -7
  17. package/dist/loop/run.mjs.map +1 -1
  18. package/dist/protocol/event.d.mts +22 -4
  19. package/dist/protocol/event.d.mts.map +1 -1
  20. package/dist/protocol/event.mjs +31 -2
  21. package/dist/protocol/event.mjs.map +1 -1
  22. package/dist/protocol/index.d.mts +4 -4
  23. package/dist/protocol/index.d.mts.map +1 -1
  24. package/dist/protocol/index.mjs +4 -4
  25. package/dist/protocol/session.d.mts +12 -5
  26. package/dist/protocol/session.d.mts.map +1 -1
  27. package/dist/protocol/session.mjs +10 -3
  28. package/dist/protocol/session.mjs.map +1 -1
  29. package/dist/protocol/tool.d.mts +135 -8
  30. package/dist/protocol/tool.d.mts.map +1 -1
  31. package/dist/protocol/tool.mjs +74 -5
  32. package/dist/protocol/tool.mjs.map +1 -1
  33. package/dist/providers/vercel/ai-gateway-provider.d.mts +26 -0
  34. package/dist/providers/vercel/ai-gateway-provider.d.mts.map +1 -1
  35. package/dist/providers/vercel/ai-gateway-provider.mjs +4 -1
  36. package/dist/providers/vercel/ai-gateway-provider.mjs.map +1 -1
  37. package/dist/react/chat-actions.d.mts +15 -15
  38. package/dist/react/chat-core.d.mts.map +1 -1
  39. package/dist/react/chat-core.mjs +3 -3
  40. package/dist/react/chat-core.mjs.map +1 -1
  41. package/dist/react/chat-items.d.mts +128 -58
  42. package/dist/react/chat-items.d.mts.map +1 -1
  43. package/dist/react/chat-items.mjs +14 -0
  44. package/dist/react/chat-items.mjs.map +1 -1
  45. package/dist/react/chat-messages.d.mts +175 -105
  46. package/dist/react/chat-messages.d.mts.map +1 -1
  47. package/dist/react/chat-messages.mjs +38 -7
  48. package/dist/react/chat-messages.mjs.map +1 -1
  49. package/dist/react/use-agent-chat.d.mts +3 -2
  50. package/dist/react/use-agent-chat.d.mts.map +1 -1
  51. package/dist/react/use-agent-chat.mjs +2 -0
  52. package/dist/react/use-agent-chat.mjs.map +1 -1
  53. package/dist/runtime/run-runtime.d.mts +3 -2
  54. package/dist/runtime/run-runtime.d.mts.map +1 -1
  55. package/dist/runtime/run-runtime.mjs +2 -1
  56. package/dist/runtime/run-runtime.mjs.map +1 -1
  57. package/dist/runtime/session-event-store.d.mts +2 -2
  58. package/dist/tools/index.d.mts +3 -2
  59. package/dist/tools/index.mjs +3 -2
  60. package/dist/tools/input.d.mts +41 -0
  61. package/dist/tools/input.d.mts.map +1 -0
  62. package/dist/tools/input.mjs +83 -0
  63. package/dist/tools/input.mjs.map +1 -0
  64. package/dist/tools/registry.d.mts +16 -4
  65. package/dist/tools/registry.d.mts.map +1 -1
  66. package/dist/tools/registry.mjs +29 -3
  67. package/dist/tools/registry.mjs.map +1 -1
  68. package/dist/voice/controller.mjs.map +1 -1
  69. package/dist/voice/index.d.mts +2 -2
  70. package/dist/voice/index.mjs +2 -2
  71. package/dist/voice/protocol.d.mts +2 -2
  72. package/dist/voice/tool-server.d.mts +5 -1
  73. package/dist/voice/tool-server.d.mts.map +1 -1
  74. package/dist/voice/tool-server.mjs +6 -1
  75. package/dist/voice/tool-server.mjs.map +1 -1
  76. package/package.json +1 -1
  77. package/src/client/index.ts +2 -0
  78. package/src/client/state.ts +98 -0
  79. package/src/client/transport.ts +37 -15
  80. package/src/loop/run.ts +180 -19
  81. package/src/protocol/event.ts +58 -0
  82. package/src/protocol/index.ts +17 -0
  83. package/src/protocol/session.ts +13 -2
  84. package/src/protocol/tool.ts +151 -3
  85. package/src/providers/vercel/ai-gateway-provider.ts +40 -2
  86. package/src/react/chat-core.ts +10 -4
  87. package/src/react/chat-items.ts +33 -0
  88. package/src/react/chat-messages.ts +161 -1
  89. package/src/react/use-agent-chat.ts +7 -0
  90. package/src/runtime/run-runtime.ts +11 -0
  91. package/src/tools/index.ts +7 -1
  92. package/src/tools/input.ts +194 -0
  93. package/src/tools/registry.ts +67 -2
  94. package/src/voice/controller.ts +1 -0
  95. package/src/voice/index.ts +1 -0
  96. package/src/voice/tool-server.ts +11 -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, `makeTool`, subagent/question contracts |
29
+ | `@yolk-sdk/agent/tools` | Tool registry, typed inputs, subagent/question contracts |
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 |
@@ -110,7 +110,7 @@ import { FauxProvider, Reply, TestToolExecutor } from '@yolk-sdk/agent/loop/test
110
110
  ## Headless React chat
111
111
 
112
112
  `useAgentChat` exposes protocol messages, render-oriented chat messages, run/error/waiting state,
113
- and actions for submit, stop, edit, regenerate, delete, tool approval, and question responses. The
113
+ and actions for submit, stop, edit, regenerate, delete, tool approval, question, and typed input responses. The
114
114
  package supplies no components, styling, auth, or route ownership, and React remains an optional
115
115
  peer used only by React subpaths.
116
116
 
@@ -253,14 +253,16 @@ the adapter preserves the provider's timestamp. Missing/invalid percentages are
253
253
  as zero. Treat snapshots as best-effort; hosts own polling, stale-data policy, persistence, and UI.
254
254
  The fetcher blocks redirects and sanitizes failures using the shared subscription-usage error types.
255
255
 
256
- Vercel AI Gateway uses its OpenAI-compatible JSON Chat Completions endpoint. Pass either an AI
256
+ Vercel AI Gateway uses its OpenAI-compatible Chat Completions endpoint, with a single JSON
257
+ completion by default. Set factory option `streaming: true` for SSE deltas and independently set
258
+ `reasoningContent: true` to preserve compatible models' `reasoning_content` output and assistant
259
+ replay. Both default to false; replayed reasoning spends input tokens. Pass either an AI
257
260
  Gateway API key or Vercel OIDC token as `apiKey`; `maxCompletionTokens` is sent as Gateway
258
261
  `max_tokens`. The env-backed `VercelAiGatewayProviderLayer` tries `AI_GATEWAY_API_KEY` first, then
259
262
  `VERCEL_OIDC_TOKEN`, and requires integer
260
263
  `AI_GATEWAY_MAX_COMPLETION_TOKENS`. Model ids are opaque `provider/model` strings. Hosts may set
261
264
  `fallbackModels`, provider `routing`, and optional `http-referer` / `x-title` attribution headers.
262
- A request `reasoningEffort` is sent as Gateway `{ reasoning: { effort } }` for any opaque model id;
263
- hosts remain responsible for offering only efforts supported by the selected model. Required
265
+ A request `reasoningEffort` is sent as Gateway `{ reasoning: { effort } }` by default; `reasoningEffortFormat: 'reasoning-effort'` sends the literal field instead (e.g. for DeepSeek-style hosts, with an optional `thinking` toggle merged into the request body). Hosts remain responsible for offering only efforts supported by the selected model. Required
264
266
  authorization and JSON headers cannot be replaced through `extraHeaders`. Only override
265
267
  `chatCompletionsUrl` with a trusted proxy because it receives the bearer credential.
266
268
 
@@ -631,9 +633,11 @@ HITL is protocol-level, not UI-level:
631
633
  `streamToolApprovalResponseEventStream`.
632
634
  - Denials become model-visible `ToolResult` messages with `isError = true`.
633
635
  - 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.
634
- - Use `questionResponseStructuredContent` / `plainHitlResponse` before storing durable HITL payloads that must be plain JSON. `PlainHitlResponse` is a `Data.taggedEnum` value (`QuestionResponse` / `ToolApprovalResponse`); the helpers omit absent optionals then call those constructors (`_tag` last, plain objects, not Schema classes).
636
+ - 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
+ - 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 `questionResponseStructuredContent` / `plainHitlResponse` before storing durable HITL payloads that must be plain JSON. `PlainHitlResponse` is a `Data.taggedEnum` value (`QuestionResponse` / `ToolApprovalResponse` / `InputResponse`); the helpers omit absent optionals then call those constructors (`_tag` last, plain objects, not Schema classes).
635
639
  - Use `toolRunsFromHitlRequests` to hydrate paused UI state from `AgentAwaitingInput.requests`.
636
- - Use `hitlResponseEvent` when a client needs optimistic approval/question UI updates before resumed stream events arrive.
640
+ - Use `hitlResponseEvent` when a client needs optimistic approval/question UI updates before resumed stream events arrive. Typed input stays pending until server acceptance so rejected or interrupted submissions cannot become replayable tool results.
637
641
  - Approval is a host-enforced per-call gate for normal tools, not a model-callable permission tool or persisted allow-always system.
638
642
 
639
643
  HTTP client helpers treat `AgentEnd`, `AgentError`, and `AgentAwaitingInput` as logical stream
@@ -701,7 +705,7 @@ handler, approval HITL, transcript projection, and one-shot TTS/STT contracts.
701
705
  JSON-compatible `VoiceToolCallOutcome` envelope, applies `ToolDef.approval` policy, and never runs
702
706
  approval-gated tools without a matching approved response.
703
707
  - Approval-gated calls pause with `AwaitingInput`; approvals/denials resume through
704
- `submitHitlResponse`. Voice `question` is deferred in v1.
708
+ `submitHitlResponse`. Voice questions and custom typed inputs are unsupported in v1.
705
709
  - `projectVoiceEvent` turns voice events into protocol messages with no dangling host tool
706
710
  calls. Assistant drafts are keyed per provider output item (falling back to response id), so
707
711
  back-to-back responses, multi-item responses, and duplicate final transcript event families
@@ -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, SubmitQuestionResponseRequest, SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, 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 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, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
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 };
@@ -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, 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, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
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 };
@@ -1,5 +1,5 @@
1
1
  import { Data } from "effect";
2
- import { AgentError, AgentEvent, AgentMessage, AgentRetry, HitlRequest, QuestionRequest, QuestionResponse, ToolApprovalRequest, ToolCall, ToolResult, UserMessage } from "@yolk-sdk/agent/protocol";
2
+ import { AgentError, AgentEvent, AgentMessage, AgentRetry, HitlRequest, InputRequest, InputResponse, 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';
@@ -30,6 +30,17 @@ type AgentToolRun = {
30
30
  readonly _tag: 'QuestionCancelled';
31
31
  readonly response: QuestionResponse;
32
32
  readonly request?: QuestionRequest;
33
+ } | {
34
+ readonly _tag: 'InputRequested';
35
+ readonly request: InputRequest;
36
+ } | {
37
+ readonly _tag: 'InputSubmitted';
38
+ readonly response: InputResponse;
39
+ readonly request?: InputRequest;
40
+ } | {
41
+ readonly _tag: 'InputCancelled';
42
+ readonly response: InputResponse;
43
+ readonly request?: InputRequest;
33
44
  } | {
34
45
  readonly _tag: 'Executing';
35
46
  readonly call: ToolCall;
@@ -57,21 +68,6 @@ type AgentToolRun = {
57
68
  readonly result: ToolResult;
58
69
  };
59
70
  declare const AgentToolRun: {
60
- readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
61
- readonly _tag: "InputStreaming";
62
- readonly id: string;
63
- readonly name?: string;
64
- readonly input: string;
65
- }, "_tag">;
66
- readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
67
- readonly _tag: "InputReady";
68
- readonly call: ToolCall;
69
- }, "_tag">;
70
- readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
71
- readonly _tag: "ApprovalRequested";
72
- readonly call: ToolCall;
73
- readonly request?: ToolApprovalRequest;
74
- }, "_tag">;
75
71
  readonly Denied: Data.TaggedEnum.ConstructorFrom<{
76
72
  readonly _tag: "Denied";
77
73
  readonly toolCallId: string;
@@ -91,6 +87,35 @@ declare const AgentToolRun: {
91
87
  readonly response: QuestionResponse;
92
88
  readonly request?: QuestionRequest;
93
89
  }, "_tag">;
90
+ readonly InputRequested: Data.TaggedEnum.ConstructorFrom<{
91
+ readonly _tag: "InputRequested";
92
+ readonly request: InputRequest;
93
+ }, "_tag">;
94
+ readonly InputSubmitted: Data.TaggedEnum.ConstructorFrom<{
95
+ readonly _tag: "InputSubmitted";
96
+ readonly response: InputResponse;
97
+ readonly request?: InputRequest;
98
+ }, "_tag">;
99
+ readonly InputCancelled: Data.TaggedEnum.ConstructorFrom<{
100
+ readonly _tag: "InputCancelled";
101
+ readonly response: InputResponse;
102
+ readonly request?: InputRequest;
103
+ }, "_tag">;
104
+ readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
105
+ readonly _tag: "InputStreaming";
106
+ readonly id: string;
107
+ readonly name?: string;
108
+ readonly input: string;
109
+ }, "_tag">;
110
+ readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
111
+ readonly _tag: "InputReady";
112
+ readonly call: ToolCall;
113
+ }, "_tag">;
114
+ readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
115
+ readonly _tag: "ApprovalRequested";
116
+ readonly call: ToolCall;
117
+ readonly request?: ToolApprovalRequest;
118
+ }, "_tag">;
94
119
  readonly Executing: Data.TaggedEnum.ConstructorFrom<{
95
120
  readonly _tag: "Executing";
96
121
  readonly call: ToolCall;
@@ -121,7 +146,7 @@ declare const AgentToolRun: {
121
146
  readonly call: ToolCall;
122
147
  readonly result: ToolResult;
123
148
  }, "_tag">;
124
- readonly $is: <Tag extends "InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted">(tag: Tag) => (u: unknown) => u is Extract<{
149
+ readonly $is: <Tag extends "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InputStreaming" | "InputReady" | "ApprovalRequested" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted">(tag: Tag) => (u: unknown) => u is Extract<{
125
150
  readonly _tag: "InputStreaming";
126
151
  readonly id: string;
127
152
  readonly name?: string;
@@ -162,6 +187,23 @@ declare const AgentToolRun: {
162
187
  readonly request?: QuestionRequest;
163
188
  }, {
164
189
  readonly _tag: Tag;
190
+ }> | Extract<{
191
+ readonly _tag: "InputRequested";
192
+ readonly request: InputRequest;
193
+ }, {
194
+ readonly _tag: Tag;
195
+ }> | Extract<{
196
+ readonly _tag: "InputSubmitted";
197
+ readonly response: InputResponse;
198
+ readonly request?: InputRequest;
199
+ }, {
200
+ readonly _tag: Tag;
201
+ }> | Extract<{
202
+ readonly _tag: "InputCancelled";
203
+ readonly response: InputResponse;
204
+ readonly request?: InputRequest;
205
+ }, {
206
+ readonly _tag: Tag;
165
207
  }> | Extract<{
166
208
  readonly _tag: "Executing";
167
209
  readonly call: ToolCall;
@@ -200,21 +242,6 @@ declare const AgentToolRun: {
200
242
  }>;
201
243
  readonly $match: {
202
244
  <Cases extends {
203
- readonly InputStreaming: (args: {
204
- readonly _tag: "InputStreaming";
205
- readonly id: string;
206
- readonly name?: string;
207
- readonly input: string;
208
- }) => any;
209
- readonly InputReady: (args: {
210
- readonly _tag: "InputReady";
211
- readonly call: ToolCall;
212
- }) => any;
213
- readonly ApprovalRequested: (args: {
214
- readonly _tag: "ApprovalRequested";
215
- readonly call: ToolCall;
216
- readonly request?: ToolApprovalRequest;
217
- }) => any;
218
245
  readonly Denied: (args: {
219
246
  readonly _tag: "Denied";
220
247
  readonly toolCallId: string;
@@ -234,6 +261,35 @@ declare const AgentToolRun: {
234
261
  readonly response: QuestionResponse;
235
262
  readonly request?: QuestionRequest;
236
263
  }) => any;
264
+ readonly InputRequested: (args: {
265
+ readonly _tag: "InputRequested";
266
+ readonly request: InputRequest;
267
+ }) => any;
268
+ readonly InputSubmitted: (args: {
269
+ readonly _tag: "InputSubmitted";
270
+ readonly response: InputResponse;
271
+ readonly request?: InputRequest;
272
+ }) => any;
273
+ readonly InputCancelled: (args: {
274
+ readonly _tag: "InputCancelled";
275
+ readonly response: InputResponse;
276
+ readonly request?: InputRequest;
277
+ }) => any;
278
+ readonly InputStreaming: (args: {
279
+ readonly _tag: "InputStreaming";
280
+ readonly id: string;
281
+ readonly name?: string;
282
+ readonly input: string;
283
+ }) => any;
284
+ readonly InputReady: (args: {
285
+ readonly _tag: "InputReady";
286
+ readonly call: ToolCall;
287
+ }) => any;
288
+ readonly ApprovalRequested: (args: {
289
+ readonly _tag: "ApprovalRequested";
290
+ readonly call: ToolCall;
291
+ readonly request?: ToolApprovalRequest;
292
+ }) => any;
237
293
  readonly Executing: (args: {
238
294
  readonly _tag: "Executing";
239
295
  readonly call: ToolCall;
@@ -264,23 +320,8 @@ declare const AgentToolRun: {
264
320
  readonly call: ToolCall;
265
321
  readonly result: ToolResult;
266
322
  }) => any;
267
- }>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
323
+ }>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InputStreaming" | "InputReady" | "ApprovalRequested" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
268
324
  <Cases extends {
269
- readonly InputStreaming: (args: {
270
- readonly _tag: "InputStreaming";
271
- readonly id: string;
272
- readonly name?: string;
273
- readonly input: string;
274
- }) => any;
275
- readonly InputReady: (args: {
276
- readonly _tag: "InputReady";
277
- readonly call: ToolCall;
278
- }) => any;
279
- readonly ApprovalRequested: (args: {
280
- readonly _tag: "ApprovalRequested";
281
- readonly call: ToolCall;
282
- readonly request?: ToolApprovalRequest;
283
- }) => any;
284
325
  readonly Denied: (args: {
285
326
  readonly _tag: "Denied";
286
327
  readonly toolCallId: string;
@@ -300,6 +341,35 @@ declare const AgentToolRun: {
300
341
  readonly response: QuestionResponse;
301
342
  readonly request?: QuestionRequest;
302
343
  }) => any;
344
+ readonly InputRequested: (args: {
345
+ readonly _tag: "InputRequested";
346
+ readonly request: InputRequest;
347
+ }) => any;
348
+ readonly InputSubmitted: (args: {
349
+ readonly _tag: "InputSubmitted";
350
+ readonly response: InputResponse;
351
+ readonly request?: InputRequest;
352
+ }) => any;
353
+ readonly InputCancelled: (args: {
354
+ readonly _tag: "InputCancelled";
355
+ readonly response: InputResponse;
356
+ readonly request?: InputRequest;
357
+ }) => any;
358
+ readonly InputStreaming: (args: {
359
+ readonly _tag: "InputStreaming";
360
+ readonly id: string;
361
+ readonly name?: string;
362
+ readonly input: string;
363
+ }) => any;
364
+ readonly InputReady: (args: {
365
+ readonly _tag: "InputReady";
366
+ readonly call: ToolCall;
367
+ }) => any;
368
+ readonly ApprovalRequested: (args: {
369
+ readonly _tag: "ApprovalRequested";
370
+ readonly call: ToolCall;
371
+ readonly request?: ToolApprovalRequest;
372
+ }) => any;
303
373
  readonly Executing: (args: {
304
374
  readonly _tag: "Executing";
305
375
  readonly call: ToolCall;
@@ -330,7 +400,7 @@ declare const AgentToolRun: {
330
400
  readonly call: ToolCall;
331
401
  readonly result: ToolResult;
332
402
  }) => any;
333
- }>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
403
+ }>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InputStreaming" | "InputReady" | "ApprovalRequested" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
334
404
  };
335
405
  };
336
406
  type AgentClientState = {
@@ -365,6 +435,9 @@ declare const isActiveToolRun: (run: AgentToolRun) => run is {
365
435
  } | {
366
436
  readonly _tag: "QuestionRequested";
367
437
  readonly request: QuestionRequest;
438
+ } | {
439
+ readonly _tag: "InputRequested";
440
+ readonly request: InputRequest;
368
441
  } | {
369
442
  readonly _tag: "Executing";
370
443
  readonly call: ToolCall;
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.mts","names":[],"sources":["../../src/client/state.ts"],"mappings":";;;;KAgBY,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,SAA4B,IAAA,EAA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;;iBAtIC,QAAA;AAAA;EAAA;iBAG7B,QAAA;EAAA,mBACI,mBAAA;AAAA;EAAA;oBAGmC,eAAA;AAAA;EAAA;oBAWH,YAAA;AAAA;EAAA;iBAWR,QAAA;EAAA;;cAoHpC,iBAAA,GAAqB,IAAA,EAAM,aAAA,CAAc,YAAA;EAAA;iBAjHjC,QAAA;EAAA,iBACE,UAAA;EAAA;;;cAuHV,wBAAA,GACX,QAAA,EAAU,aAAA,CAAc,WAAA,MACvB,aAAA,CAAc,YAAA;AAAA,cA2JJ,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,cAsQU,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"}
@@ -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("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, "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("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");
37
37
  const completedToolRuns = (runs) => runs.filter((run) => Predicate.isTagged(run, "Completed"));
38
38
  const retainedSettledToolRuns = (runs) => runs.filter((run) => Predicate.isTagged(run, "Completed") || Predicate.isTagged(run, "Accepted"));
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.exhaustive));
42
+ })), Match.tag("InputRequest", (current) => AgentToolRun.InputRequested({ 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,8 +58,20 @@ 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", "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", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", () => []), Match.exhaustive);
62
62
  })[0];
63
+ const inputRequestForToolCall = (runs, toolCallId) => runs.flatMap((run) => {
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);
66
+ })[0];
67
+ const inputSubmittedRun = (response, request) => request === void 0 ? AgentToolRun.InputSubmitted({ response }) : AgentToolRun.InputSubmitted({
68
+ response,
69
+ request
70
+ });
71
+ const inputCancelledRun = (response, request) => request === void 0 ? AgentToolRun.InputCancelled({ response }) : AgentToolRun.InputCancelled({
72
+ response,
73
+ request
74
+ });
63
75
  const questionAnsweredRun = (response, request) => request === void 0 ? AgentToolRun.QuestionAnswered({ response }) : AgentToolRun.QuestionAnswered({
64
76
  response,
65
77
  request
@@ -85,7 +97,7 @@ const applyAgentEventWithOptions = (state, event, options = {}) => {
85
97
  if (hasSeenEvent(state, event)) return state;
86
98
  return rememberEvent(applyAgentEventUnchecked(state, event, nowMs), event);
87
99
  };
88
- 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.orElse(() => void 0));
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));
89
101
  const applyAgentEventUnchecked = (state, event, nowMs) => {
90
102
  const activeCallId = activeEventToolCallId(event);
91
103
  const acknowledgesActiveCall = (message) => Predicate.isTagged(message, "ToolResult") && message.toolCallId === activeCallId && message.acceptance !== void 0;
@@ -137,12 +149,21 @@ const applyAgentEventUnchecked = (state, event, nowMs) => {
137
149
  })), Match.tag("QuestionRequested", (current) => ({
138
150
  ...state,
139
151
  toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.QuestionRequested({ request: current.request }))
152
+ })), Match.tag("InputRequested", (current) => ({
153
+ ...state,
154
+ toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.InputRequested({ request: current.request }))
140
155
  }))).pipe(Match.tag("QuestionAnswered", (current) => ({
141
156
  ...state,
142
157
  toolRuns: replaceToolRun(state.toolRuns, questionAnsweredRun(current.response, questionRequestForToolCall(state.toolRuns, current.response.toolCallId)))
143
158
  })), Match.tag("QuestionCancelled", (current) => ({
144
159
  ...state,
145
160
  toolRuns: replaceToolRun(state.toolRuns, questionCancelledRun(current.response, questionRequestForToolCall(state.toolRuns, current.response.toolCallId)))
161
+ })), Match.tag("InputSubmitted", (current) => ({
162
+ ...state,
163
+ toolRuns: replaceToolRun(state.toolRuns, inputSubmittedRun(current.response, inputRequestForToolCall(state.toolRuns, current.response.toolCallId)))
164
+ })), Match.tag("InputCancelled", (current) => ({
165
+ ...state,
166
+ toolRuns: replaceToolRun(state.toolRuns, inputCancelledRun(current.response, inputRequestForToolCall(state.toolRuns, current.response.toolCallId)))
146
167
  })), Match.tag("ToolExecutionStarted", (current) => ({
147
168
  ...state,
148
169
  toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.Executing({
@@ -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 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: '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(\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, '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.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 'ApprovalRequested',\n 'Denied',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n () => []\n ),\n Match.exhaustive\n )\n })[0]\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.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 )\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('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":";;;AAkEA,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,MAA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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 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,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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