@yolk-sdk/agent 0.1.0-canary.85 → 0.1.0-canary.87

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 (104) hide show
  1. package/README.md +6 -3
  2. package/dist/client/index.d.mts +2 -2
  3. package/dist/client/index.mjs +2 -2
  4. package/dist/client/state.d.mts +160 -77
  5. package/dist/client/state.d.mts.map +1 -1
  6. package/dist/client/state.mjs +40 -11
  7. package/dist/client/state.mjs.map +1 -1
  8. package/dist/client/transport.d.mts +17 -13
  9. package/dist/client/transport.d.mts.map +1 -1
  10. package/dist/client/transport.mjs +11 -2
  11. package/dist/client/transport.mjs.map +1 -1
  12. package/dist/loop/index.d.mts +3 -3
  13. package/dist/loop/index.mjs +2 -2
  14. package/dist/loop/run.d.mts +22 -4
  15. package/dist/loop/run.d.mts.map +1 -1
  16. package/dist/loop/run.mjs +125 -15
  17. package/dist/loop/run.mjs.map +1 -1
  18. package/dist/loop/services/tool-executor.d.mts +10 -4
  19. package/dist/loop/services/tool-executor.d.mts.map +1 -1
  20. package/dist/loop/services/tool-executor.mjs +1 -1
  21. package/dist/loop/services/tool-executor.mjs.map +1 -1
  22. package/dist/protocol/event.d.mts +26 -4
  23. package/dist/protocol/event.d.mts.map +1 -1
  24. package/dist/protocol/event.mjs +36 -2
  25. package/dist/protocol/event.mjs.map +1 -1
  26. package/dist/protocol/index.d.mts +4 -4
  27. package/dist/protocol/index.d.mts.map +1 -1
  28. package/dist/protocol/index.mjs +4 -4
  29. package/dist/protocol/session.d.mts +12 -5
  30. package/dist/protocol/session.d.mts.map +1 -1
  31. package/dist/protocol/session.mjs +10 -3
  32. package/dist/protocol/session.mjs.map +1 -1
  33. package/dist/protocol/tool.d.mts +422 -7
  34. package/dist/protocol/tool.d.mts.map +1 -1
  35. package/dist/protocol/tool.mjs +290 -6
  36. package/dist/protocol/tool.mjs.map +1 -1
  37. package/dist/providers/openai/realtime/session-config.d.mts.map +1 -1
  38. package/dist/providers/openai/realtime/session-config.mjs +1 -0
  39. package/dist/providers/openai/realtime/session-config.mjs.map +1 -1
  40. package/dist/react/chat-actions.d.mts +35 -35
  41. package/dist/react/chat-actions.d.mts.map +1 -1
  42. package/dist/react/chat-core.d.mts.map +1 -1
  43. package/dist/react/chat-core.mjs +3 -3
  44. package/dist/react/chat-core.mjs.map +1 -1
  45. package/dist/react/chat-items.d.mts +140 -70
  46. package/dist/react/chat-items.d.mts.map +1 -1
  47. package/dist/react/chat-items.mjs +14 -0
  48. package/dist/react/chat-items.mjs.map +1 -1
  49. package/dist/react/chat-messages.d.mts +193 -123
  50. package/dist/react/chat-messages.d.mts.map +1 -1
  51. package/dist/react/chat-messages.mjs +33 -10
  52. package/dist/react/chat-messages.mjs.map +1 -1
  53. package/dist/react/use-agent-chat.d.mts +2 -1
  54. package/dist/react/use-agent-chat.d.mts.map +1 -1
  55. package/dist/react/use-agent-chat.mjs +2 -0
  56. package/dist/react/use-agent-chat.mjs.map +1 -1
  57. package/dist/runtime/run-runtime.d.mts +4 -2
  58. package/dist/runtime/run-runtime.d.mts.map +1 -1
  59. package/dist/runtime/run-runtime.mjs +3 -1
  60. package/dist/runtime/run-runtime.mjs.map +1 -1
  61. package/dist/runtime/session-event-store.d.mts +2 -2
  62. package/dist/skillset/merge.d.mts +3 -3
  63. package/dist/tools/index.d.mts +3 -2
  64. package/dist/tools/index.mjs +2 -1
  65. package/dist/tools/interaction.d.mts +55 -0
  66. package/dist/tools/interaction.d.mts.map +1 -0
  67. package/dist/tools/interaction.mjs +112 -0
  68. package/dist/tools/interaction.mjs.map +1 -0
  69. package/dist/tools/registry.d.mts +55 -5
  70. package/dist/tools/registry.d.mts.map +1 -1
  71. package/dist/tools/registry.mjs +160 -5
  72. package/dist/tools/registry.mjs.map +1 -1
  73. package/dist/voice/controller.mjs.map +1 -1
  74. package/dist/voice/index.d.mts +2 -2
  75. package/dist/voice/index.mjs +2 -2
  76. package/dist/voice/protocol.d.mts +2 -2
  77. package/dist/voice/tool-server.d.mts +5 -1
  78. package/dist/voice/tool-server.d.mts.map +1 -1
  79. package/dist/voice/tool-server.mjs +6 -1
  80. package/dist/voice/tool-server.mjs.map +1 -1
  81. package/package.json +1 -1
  82. package/src/client/index.ts +2 -0
  83. package/src/client/state.ts +135 -5
  84. package/src/client/transport.ts +17 -0
  85. package/src/loop/index.ts +9 -1
  86. package/src/loop/run.ts +258 -30
  87. package/src/loop/services/tool-executor.ts +16 -3
  88. package/src/protocol/event.ts +76 -0
  89. package/src/protocol/index.ts +36 -1
  90. package/src/protocol/session.ts +18 -2
  91. package/src/protocol/tool.ts +622 -4
  92. package/src/providers/openai/realtime/session-config.ts +8 -0
  93. package/src/react/chat-core.ts +9 -3
  94. package/src/react/chat-items.ts +36 -0
  95. package/src/react/chat-messages.ts +158 -5
  96. package/src/react/use-agent-chat.ts +7 -0
  97. package/src/runtime/run-runtime.ts +14 -0
  98. package/src/tools/README.md +39 -0
  99. package/src/tools/index.ts +16 -0
  100. package/src/tools/interaction.ts +300 -0
  101. package/src/tools/registry.ts +451 -52
  102. package/src/voice/controller.ts +2 -1
  103. package/src/voice/index.ts +1 -0
  104. 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, subagent/question contracts |
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 `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).
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 stays pending until server acceptance so rejected or interrupted submissions cannot become replayable tool results.
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
@@ -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 };
@@ -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 };
@@ -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;
@@ -68,6 +80,26 @@ type AgentToolRun = {
68
80
  readonly result: ToolResult;
69
81
  };
70
82
  declare const AgentToolRun: {
83
+ readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
84
+ readonly _tag: "InputStreaming";
85
+ readonly id: string;
86
+ readonly name?: string;
87
+ readonly input: string;
88
+ }, "_tag">;
89
+ readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
90
+ readonly _tag: "InputReady";
91
+ readonly call: ToolCall;
92
+ }, "_tag">;
93
+ readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
94
+ readonly _tag: "ApprovalRequested";
95
+ readonly call: ToolCall;
96
+ readonly request?: ToolApprovalRequest;
97
+ }, "_tag">;
98
+ readonly Denied: Data.TaggedEnum.ConstructorFrom<{
99
+ readonly _tag: "Denied";
100
+ readonly toolCallId: string;
101
+ readonly reason: string;
102
+ }, "_tag">;
71
103
  readonly QuestionRequested: Data.TaggedEnum.ConstructorFrom<{
72
104
  readonly _tag: "QuestionRequested";
73
105
  readonly request: QuestionRequest;
@@ -96,6 +128,26 @@ declare const AgentToolRun: {
96
128
  readonly response: InputResponse;
97
129
  readonly request?: InputRequest;
98
130
  }, "_tag">;
131
+ readonly InteractionRequested: Data.TaggedEnum.ConstructorFrom<{
132
+ readonly _tag: "InteractionRequested";
133
+ readonly request: InteractionRequest;
134
+ }, "_tag">;
135
+ readonly InteractionSubmitted: Data.TaggedEnum.ConstructorFrom<{
136
+ readonly _tag: "InteractionSubmitted";
137
+ readonly response: InteractionResponse;
138
+ readonly request?: InteractionRequest;
139
+ }, "_tag">;
140
+ readonly InteractionCancelled: Data.TaggedEnum.ConstructorFrom<{
141
+ readonly _tag: "InteractionCancelled";
142
+ readonly response: InteractionResponse;
143
+ readonly request?: InteractionRequest;
144
+ }, "_tag">;
145
+ readonly Executing: Data.TaggedEnum.ConstructorFrom<{
146
+ readonly _tag: "Executing";
147
+ readonly call: ToolCall;
148
+ readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
149
+ readonly interaction?: true;
150
+ }, "_tag">;
99
151
  readonly Completed: Data.TaggedEnum.ConstructorFrom<{
100
152
  readonly _tag: "Completed";
101
153
  readonly call: ToolCall;
@@ -110,22 +162,6 @@ declare const AgentToolRun: {
110
162
  readonly startedAtMs: number;
111
163
  readonly endedAtMs: number;
112
164
  }, "_tag">;
113
- readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
114
- readonly _tag: "InputStreaming";
115
- readonly id: string;
116
- readonly name?: string;
117
- readonly input: string;
118
- }, "_tag">;
119
- readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
120
- readonly _tag: "ApprovalRequested";
121
- readonly call: ToolCall;
122
- readonly request?: ToolApprovalRequest;
123
- }, "_tag">;
124
- readonly Denied: Data.TaggedEnum.ConstructorFrom<{
125
- readonly _tag: "Denied";
126
- readonly toolCallId: string;
127
- readonly reason: string;
128
- }, "_tag">;
129
165
  readonly Errored: Data.TaggedEnum.ConstructorFrom<{
130
166
  readonly _tag: "Errored";
131
167
  readonly call: ToolCall;
@@ -137,16 +173,7 @@ declare const AgentToolRun: {
137
173
  readonly call: ToolCall;
138
174
  readonly result: ToolResult;
139
175
  }, "_tag">;
140
- readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
141
- readonly _tag: "InputReady";
142
- readonly call: ToolCall;
143
- }, "_tag">;
144
- readonly Executing: Data.TaggedEnum.ConstructorFrom<{
145
- readonly _tag: "Executing";
146
- readonly call: ToolCall;
147
- readonly startedAtMs: number;
148
- }, "_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 "InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted">(tag: Tag) => (u: unknown) => u is Extract<{
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<{
@@ -242,6 +287,26 @@ declare const AgentToolRun: {
242
287
  }>;
243
288
  readonly $match: {
244
289
  <Cases extends {
290
+ readonly InputStreaming: (args: {
291
+ readonly _tag: "InputStreaming";
292
+ readonly id: string;
293
+ readonly name?: string;
294
+ readonly input: string;
295
+ }) => any;
296
+ readonly InputReady: (args: {
297
+ readonly _tag: "InputReady";
298
+ readonly call: ToolCall;
299
+ }) => any;
300
+ readonly ApprovalRequested: (args: {
301
+ readonly _tag: "ApprovalRequested";
302
+ readonly call: ToolCall;
303
+ readonly request?: ToolApprovalRequest;
304
+ }) => any;
305
+ readonly Denied: (args: {
306
+ readonly _tag: "Denied";
307
+ readonly toolCallId: string;
308
+ readonly reason: string;
309
+ }) => any;
245
310
  readonly QuestionRequested: (args: {
246
311
  readonly _tag: "QuestionRequested";
247
312
  readonly request: QuestionRequest;
@@ -270,6 +335,26 @@ declare const AgentToolRun: {
270
335
  readonly response: InputResponse;
271
336
  readonly request?: InputRequest;
272
337
  }) => any;
338
+ readonly InteractionRequested: (args: {
339
+ readonly _tag: "InteractionRequested";
340
+ readonly request: InteractionRequest;
341
+ }) => any;
342
+ readonly InteractionSubmitted: (args: {
343
+ readonly _tag: "InteractionSubmitted";
344
+ readonly response: InteractionResponse;
345
+ readonly request?: InteractionRequest;
346
+ }) => any;
347
+ readonly InteractionCancelled: (args: {
348
+ readonly _tag: "InteractionCancelled";
349
+ readonly response: InteractionResponse;
350
+ readonly request?: InteractionRequest;
351
+ }) => any;
352
+ readonly Executing: (args: {
353
+ readonly _tag: "Executing";
354
+ readonly call: ToolCall;
355
+ readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
356
+ readonly interaction?: true;
357
+ }) => any;
273
358
  readonly Completed: (args: {
274
359
  readonly _tag: "Completed";
275
360
  readonly call: ToolCall;
@@ -284,22 +369,6 @@ declare const AgentToolRun: {
284
369
  readonly startedAtMs: number;
285
370
  readonly endedAtMs: number;
286
371
  }) => any;
287
- readonly InputStreaming: (args: {
288
- readonly _tag: "InputStreaming";
289
- readonly id: string;
290
- readonly name?: string;
291
- readonly input: string;
292
- }) => any;
293
- readonly ApprovalRequested: (args: {
294
- readonly _tag: "ApprovalRequested";
295
- readonly call: ToolCall;
296
- readonly request?: ToolApprovalRequest;
297
- }) => any;
298
- readonly Denied: (args: {
299
- readonly _tag: "Denied";
300
- readonly toolCallId: string;
301
- readonly reason: string;
302
- }) => any;
303
372
  readonly Errored: (args: {
304
373
  readonly _tag: "Errored";
305
374
  readonly call: ToolCall;
@@ -311,17 +380,28 @@ declare const AgentToolRun: {
311
380
  readonly call: ToolCall;
312
381
  readonly result: ToolResult;
313
382
  }) => any;
383
+ }>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
384
+ <Cases extends {
385
+ readonly InputStreaming: (args: {
386
+ readonly _tag: "InputStreaming";
387
+ readonly id: string;
388
+ readonly name?: string;
389
+ readonly input: string;
390
+ }) => any;
314
391
  readonly InputReady: (args: {
315
392
  readonly _tag: "InputReady";
316
393
  readonly call: ToolCall;
317
394
  }) => any;
318
- readonly Executing: (args: {
319
- readonly _tag: "Executing";
395
+ readonly ApprovalRequested: (args: {
396
+ readonly _tag: "ApprovalRequested";
320
397
  readonly call: ToolCall;
321
- readonly startedAtMs: number;
398
+ readonly request?: ToolApprovalRequest;
399
+ }) => any;
400
+ readonly Denied: (args: {
401
+ readonly _tag: "Denied";
402
+ readonly toolCallId: string;
403
+ readonly reason: string;
322
404
  }) => 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"]>>;
324
- <Cases extends {
325
405
  readonly QuestionRequested: (args: {
326
406
  readonly _tag: "QuestionRequested";
327
407
  readonly request: QuestionRequest;
@@ -350,6 +430,26 @@ declare const AgentToolRun: {
350
430
  readonly response: InputResponse;
351
431
  readonly request?: InputRequest;
352
432
  }) => any;
433
+ readonly InteractionRequested: (args: {
434
+ readonly _tag: "InteractionRequested";
435
+ readonly request: InteractionRequest;
436
+ }) => any;
437
+ readonly InteractionSubmitted: (args: {
438
+ readonly _tag: "InteractionSubmitted";
439
+ readonly response: InteractionResponse;
440
+ readonly request?: InteractionRequest;
441
+ }) => any;
442
+ readonly InteractionCancelled: (args: {
443
+ readonly _tag: "InteractionCancelled";
444
+ readonly response: InteractionResponse;
445
+ readonly request?: InteractionRequest;
446
+ }) => any;
447
+ readonly Executing: (args: {
448
+ readonly _tag: "Executing";
449
+ readonly call: ToolCall;
450
+ readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
451
+ readonly interaction?: true;
452
+ }) => any;
353
453
  readonly Completed: (args: {
354
454
  readonly _tag: "Completed";
355
455
  readonly call: ToolCall;
@@ -364,22 +464,6 @@ declare const AgentToolRun: {
364
464
  readonly startedAtMs: number;
365
465
  readonly endedAtMs: number;
366
466
  }) => any;
367
- readonly InputStreaming: (args: {
368
- readonly _tag: "InputStreaming";
369
- readonly id: string;
370
- readonly name?: string;
371
- readonly input: string;
372
- }) => any;
373
- readonly ApprovalRequested: (args: {
374
- readonly _tag: "ApprovalRequested";
375
- readonly call: ToolCall;
376
- readonly request?: ToolApprovalRequest;
377
- }) => any;
378
- readonly Denied: (args: {
379
- readonly _tag: "Denied";
380
- readonly toolCallId: string;
381
- readonly reason: string;
382
- }) => any;
383
467
  readonly Errored: (args: {
384
468
  readonly _tag: "Errored";
385
469
  readonly call: ToolCall;
@@ -391,16 +475,7 @@ declare const AgentToolRun: {
391
475
  readonly call: ToolCall;
392
476
  readonly result: ToolResult;
393
477
  }) => any;
394
- readonly InputReady: (args: {
395
- readonly _tag: "InputReady";
396
- readonly call: ToolCall;
397
- }) => any;
398
- readonly Executing: (args: {
399
- readonly _tag: "Executing";
400
- readonly call: ToolCall;
401
- readonly startedAtMs: number;
402
- }) => 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["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
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":";;;;KAkBY,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,SAA4B,IAAA,EAAM,QAAA;EAAA,SAAmB,WAAA;AAAA;EAAA,SAErD,IAAA;EAAA,SACA,IAAA,EAAM,QAAA;EAAA,SACN,MAAA,EAAQ,UAAA;EAAA,SACR,WAAA;EAAA,SACA,SAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,IAAA,EAAM,QAAA;EAAA,SACN,MAAA,EAAQ,UAAA;EAAA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,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"}
@@ -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("ToolExecutionStarted", (current) => ({
182
+ })), Match.tag("InteractionSubmitted", (current) => ({
168
183
  ...state,
169
- toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.Executing({
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
- })), Match.tag("ToolExecutionAccepted", "ToolExecutionCompleted", (current) => {
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 {