@yolk-sdk/agent 0.1.0-canary.84 → 0.1.0-canary.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.mjs +2 -2
- package/dist/client/state.d.mts +156 -73
- package/dist/client/state.d.mts.map +1 -1
- package/dist/client/state.mjs +40 -11
- package/dist/client/state.mjs.map +1 -1
- package/dist/client/transport.d.mts +17 -13
- package/dist/client/transport.d.mts.map +1 -1
- package/dist/client/transport.mjs +11 -2
- package/dist/client/transport.mjs.map +1 -1
- package/dist/loop/index.d.mts +3 -3
- package/dist/loop/index.mjs +2 -2
- package/dist/loop/run.d.mts +22 -4
- package/dist/loop/run.d.mts.map +1 -1
- package/dist/loop/run.mjs +125 -15
- package/dist/loop/run.mjs.map +1 -1
- package/dist/loop/services/tool-executor.d.mts +10 -4
- package/dist/loop/services/tool-executor.d.mts.map +1 -1
- package/dist/loop/services/tool-executor.mjs +1 -1
- package/dist/loop/services/tool-executor.mjs.map +1 -1
- package/dist/protocol/event.d.mts +26 -4
- package/dist/protocol/event.d.mts.map +1 -1
- package/dist/protocol/event.mjs +36 -2
- package/dist/protocol/event.mjs.map +1 -1
- package/dist/protocol/index.d.mts +4 -4
- package/dist/protocol/index.d.mts.map +1 -1
- package/dist/protocol/index.mjs +5 -5
- package/dist/protocol/session.d.mts +12 -5
- package/dist/protocol/session.d.mts.map +1 -1
- package/dist/protocol/session.mjs +10 -3
- package/dist/protocol/session.mjs.map +1 -1
- package/dist/protocol/tool.d.mts +422 -7
- package/dist/protocol/tool.d.mts.map +1 -1
- package/dist/protocol/tool.mjs +290 -6
- package/dist/protocol/tool.mjs.map +1 -1
- package/dist/providers/openai/realtime/session-config.d.mts.map +1 -1
- package/dist/providers/openai/realtime/session-config.mjs +1 -0
- package/dist/providers/openai/realtime/session-config.mjs.map +1 -1
- package/dist/react/chat-actions.d.mts +35 -35
- package/dist/react/chat-actions.d.mts.map +1 -1
- package/dist/react/chat-core.d.mts.map +1 -1
- package/dist/react/chat-core.mjs +3 -3
- package/dist/react/chat-core.mjs.map +1 -1
- package/dist/react/chat-items.d.mts +116 -46
- package/dist/react/chat-items.d.mts.map +1 -1
- package/dist/react/chat-items.mjs +14 -0
- package/dist/react/chat-items.mjs.map +1 -1
- package/dist/react/chat-messages.d.mts +122 -52
- package/dist/react/chat-messages.d.mts.map +1 -1
- package/dist/react/chat-messages.mjs +33 -10
- package/dist/react/chat-messages.mjs.map +1 -1
- package/dist/react/use-agent-chat.d.mts +2 -1
- package/dist/react/use-agent-chat.d.mts.map +1 -1
- package/dist/react/use-agent-chat.mjs +2 -0
- package/dist/react/use-agent-chat.mjs.map +1 -1
- package/dist/runtime/run-runtime.d.mts +4 -2
- package/dist/runtime/run-runtime.d.mts.map +1 -1
- package/dist/runtime/run-runtime.mjs +3 -1
- package/dist/runtime/run-runtime.mjs.map +1 -1
- package/dist/runtime/session-event-store.d.mts +2 -2
- package/dist/tools/index.d.mts +3 -2
- package/dist/tools/index.mjs +2 -1
- package/dist/tools/interaction.d.mts +55 -0
- package/dist/tools/interaction.d.mts.map +1 -0
- package/dist/tools/interaction.mjs +112 -0
- package/dist/tools/interaction.mjs.map +1 -0
- package/dist/tools/registry.d.mts +55 -5
- package/dist/tools/registry.d.mts.map +1 -1
- package/dist/tools/registry.mjs +160 -5
- package/dist/tools/registry.mjs.map +1 -1
- package/dist/voice/controller.mjs.map +1 -1
- package/dist/voice/index.d.mts +2 -2
- package/dist/voice/index.mjs +2 -2
- package/dist/voice/protocol.d.mts +2 -2
- package/dist/voice/tool-server.d.mts +5 -1
- package/dist/voice/tool-server.d.mts.map +1 -1
- package/dist/voice/tool-server.mjs +6 -1
- package/dist/voice/tool-server.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +2 -0
- package/src/client/state.ts +135 -5
- package/src/client/transport.ts +17 -0
- package/src/loop/index.ts +9 -1
- package/src/loop/run.ts +258 -30
- package/src/loop/services/tool-executor.ts +16 -3
- package/src/protocol/event.ts +76 -0
- package/src/protocol/index.ts +36 -1
- package/src/protocol/session.ts +18 -2
- package/src/protocol/tool.ts +622 -4
- package/src/providers/openai/realtime/session-config.ts +8 -0
- package/src/react/chat-core.ts +9 -3
- package/src/react/chat-items.ts +36 -0
- package/src/react/chat-messages.ts +158 -5
- package/src/react/use-agent-chat.ts +7 -0
- package/src/runtime/run-runtime.ts +14 -0
- package/src/tools/README.md +39 -0
- package/src/tools/index.ts +16 -0
- package/src/tools/interaction.ts +300 -0
- package/src/tools/registry.ts +451 -52
- package/src/voice/controller.ts +2 -1
- package/src/voice/index.ts +1 -0
- package/src/voice/tool-server.ts +12 -0
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Published package metadata requires Node.js 22+.
|
|
|
26
26
|
| `@yolk-sdk/agent/runtime` | Transcript or append-backed runtime orchestration |
|
|
27
27
|
| `@yolk-sdk/agent/client` | HTTP/NDJSON transport, HITL resume, retry/error state helpers |
|
|
28
28
|
| `@yolk-sdk/agent/compaction` | Host-owned compaction budgets, checkpoints, formatting, retry |
|
|
29
|
-
| `@yolk-sdk/agent/tools` | Tool registry, typed inputs,
|
|
29
|
+
| `@yolk-sdk/agent/tools` | Tool registry, typed inputs, interactions, subagents/questions |
|
|
30
30
|
| `@yolk-sdk/agent/react` | Headless React chat hook, reducer, selectors, and render model |
|
|
31
31
|
| `@yolk-sdk/agent/oauth` | Provider-neutral OAuth token and broker contracts |
|
|
32
32
|
| `@yolk-sdk/agent/providers/openai` | OpenAI/Codex OAuth and broker helpers |
|
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
makeWindowCompactionTransformer
|
|
83
83
|
} from '@yolk-sdk/agent/compaction'
|
|
84
84
|
import {
|
|
85
|
+
makeInteractionTool,
|
|
85
86
|
makeNonRecursiveSubagentToolModule,
|
|
86
87
|
makeSubagentToolResult,
|
|
87
88
|
modelVisibleToolError,
|
|
@@ -635,9 +636,11 @@ HITL is protocol-level, not UI-level:
|
|
|
635
636
|
- Use `makeQuestionToolModule` to expose the package-owned `question` tool; answers resume as structured tool results and model-visible text with selected labels. The loop intercepts questions only when the tool is enabled in `tools`; omitted questions return an unavailable result without HITL or executor dispatch, even if a provider emits one.
|
|
636
637
|
- Use `makeInputTool({ name, description, response, renderer })` for custom typed input. Apps own the response Effect schema and renderer; the SDK carries JSON data only. Pass `resolveTools(...).inputs` alongside `tools` to loop/runtime configs. The original `callParameters` and `response` schemas validate server-side, including refinements; display JSON Schema is not the validator. Invalid calls fail before prompting; invalid submissions remain pending for correction. The first valid submission or cancellation settles the request and cannot be overwritten by stale responses.
|
|
637
638
|
- Resume custom inputs with `submitInputResponse`, `streamInputResponseEventStream`, or WebSocket `InputResponseInput`. Echo request/call IDs; do not reconstruct them. Input collection is not authorization: a draft composer never grants permission to send. Input tools cannot carry approval/background policy or execute directly.
|
|
638
|
-
- Use `
|
|
639
|
+
- Use `makeInteractionTool` when a person must edit proposed values and authorize one server-defined action. Unlike data-only inputs, interactions execute the selected action on the exact validated values before the next model turn. Hosts own renderers, authentication, scoped immutable receipt storage, and atomic acceptance; browser responses alone never authorize execution. Pass `interactionHost` to `resolveTools`, then both `toolSet.interactions` and `toolSet.interactionHost` to loop/runtime configs. Durable hosts load `loadInteractionReceipts` before passing `interactionReceipts` to `prepareToolBatch`.
|
|
640
|
+
- Submit interactions with `submitInteractionResponse`, `streamInteractionResponseEventStream`, or WebSocket `InteractionResponseInput`; the host must authenticate and atomically accept the response server-side before SDK resume. Submission is not completion; only real server results settle the UI. An `unknown` outcome needs host reconciliation, never automatic action retry. Voice/realtime and background activation are unsupported. See [action-backed interactions](https://github.com/magoz/yolk-sdk/blob/main/packages/agent/src/tools/README.md#action-backed-interactions) for registration and host-boundary details.
|
|
641
|
+
- Use `questionResponseStructuredContent` / `plainHitlResponse` before storing durable HITL payloads that must be plain JSON. `PlainHitlResponse` is a `Data.taggedEnum` value (`QuestionResponse` / `ToolApprovalResponse` / `InputResponse` / `InteractionResponse`); the helpers omit absent optionals then call those constructors (`_tag` last, plain objects, not Schema classes).
|
|
639
642
|
- Use `toolRunsFromHitlRequests` to hydrate paused UI state from `AgentAwaitingInput.requests`.
|
|
640
|
-
- Use `hitlResponseEvent` when a client needs optimistic approval/question UI updates before resumed stream events arrive. Typed input
|
|
643
|
+
- Use `hitlResponseEvent` when a client needs optimistic approval/question UI updates before resumed stream events arrive. Typed input and interaction submissions stay pending until server acceptance; accepted interactions stay active until the actual outcome. Never synthesize an interaction result from local submission or acceptance.
|
|
641
644
|
- Approval is a host-enforced per-call gate for normal tools, not a model-callable permission tool or persisted allow-always system.
|
|
642
645
|
|
|
643
646
|
HTTP client helpers treat `AgentEnd`, `AgentError`, and `AgentAwaitingInput` as logical stream
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { documentPartFromTextFile, textFromBlob } from "./attachments.mjs";
|
|
2
2
|
import { AgentClientState, AgentRunStatus, AgentToolRun, AgentTranscript, ApplyAgentEventOptions, appendAgentMessage, applyAgentEvent, completedToolRuns, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, submitAgentUserMessage, toolRunsFromHitlRequests } from "./state.mjs";
|
|
3
|
-
import { AgentHttpResponseInfo, AgentRunContinuationOptions, AgentRunIdleReconnectOptions, AgentTransportError, CancelAgentRunRequest, StreamAgentEventHandler, StreamAgentEventsRequest, StreamAgentEventsUntilTerminalRequest, StreamAgentRunEventsRequest, StreamAgentRunEventsUntilTerminalRequest, StreamAgentRunHitlResponseEventsRequest, StreamAgentRunHitlResponseEventsUntilTerminalRequest, StreamCloudflareAgentEventsRequest, SubmitInputResponseRequest, SubmitQuestionResponseRequest, SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
-
export { type AgentClientState, type AgentHttpResponseInfo, type AgentRunContinuationOptions, type AgentRunIdleReconnectOptions, type AgentRunStatus, type AgentToolRun, type AgentTranscript, AgentTransportError, type ApplyAgentEventOptions, type CancelAgentRunRequest, type StreamAgentEventHandler, type StreamAgentEventsRequest, type StreamAgentEventsUntilTerminalRequest, type StreamAgentRunEventsRequest, type StreamAgentRunEventsUntilTerminalRequest, type StreamAgentRunHitlResponseEventsRequest, type StreamAgentRunHitlResponseEventsUntilTerminalRequest, type StreamCloudflareAgentEventsRequest, type SubmitInputResponseRequest, type SubmitQuestionResponseRequest, type SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
|
3
|
+
import { AgentHttpResponseInfo, AgentRunContinuationOptions, AgentRunIdleReconnectOptions, AgentTransportError, CancelAgentRunRequest, StreamAgentEventHandler, StreamAgentEventsRequest, StreamAgentEventsUntilTerminalRequest, StreamAgentRunEventsRequest, StreamAgentRunEventsUntilTerminalRequest, StreamAgentRunHitlResponseEventsRequest, StreamAgentRunHitlResponseEventsUntilTerminalRequest, StreamCloudflareAgentEventsRequest, SubmitInputResponseRequest, SubmitInteractionResponseRequest, SubmitQuestionResponseRequest, SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamInteractionResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
+
export { type AgentClientState, type AgentHttpResponseInfo, type AgentRunContinuationOptions, type AgentRunIdleReconnectOptions, type AgentRunStatus, type AgentToolRun, type AgentTranscript, AgentTransportError, type ApplyAgentEventOptions, type CancelAgentRunRequest, type StreamAgentEventHandler, type StreamAgentEventsRequest, type StreamAgentEventsUntilTerminalRequest, type StreamAgentRunEventsRequest, type StreamAgentRunEventsUntilTerminalRequest, type StreamAgentRunHitlResponseEventsRequest, type StreamAgentRunHitlResponseEventsUntilTerminalRequest, type StreamCloudflareAgentEventsRequest, type SubmitInputResponseRequest, type SubmitInteractionResponseRequest, type SubmitQuestionResponseRequest, type SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamInteractionResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { documentPartFromTextFile, textFromBlob } from "./attachments.mjs";
|
|
2
2
|
import { appendAgentMessage, applyAgentEvent, completedToolRuns, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, submitAgentUserMessage, toolRunsFromHitlRequests } from "./state.mjs";
|
|
3
|
-
import { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
-
export { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
|
3
|
+
import { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamInteractionResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
+
export { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamInteractionResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
package/dist/client/state.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Data } from "effect";
|
|
2
|
-
import { AgentError, AgentEvent, AgentMessage, AgentRetry, HitlRequest, InputRequest, InputResponse, QuestionRequest, QuestionResponse, ToolApprovalRequest, ToolCall, ToolResult, UserMessage } from "@yolk-sdk/agent/protocol";
|
|
2
|
+
import { AgentError, AgentEvent, AgentMessage, AgentRetry, HitlRequest, InputRequest, InputResponse, InteractionRequest, InteractionResponse, QuestionRequest, QuestionResponse, ToolApprovalRequest, ToolCall, ToolResult, UserMessage } from "@yolk-sdk/agent/protocol";
|
|
3
3
|
|
|
4
4
|
//#region src/client/state.d.ts
|
|
5
5
|
type AgentRunStatus = 'idle' | 'running' | 'waiting' | 'done' | 'error' | 'aborted';
|
|
@@ -41,10 +41,22 @@ type AgentToolRun = {
|
|
|
41
41
|
readonly _tag: 'InputCancelled';
|
|
42
42
|
readonly response: InputResponse;
|
|
43
43
|
readonly request?: InputRequest;
|
|
44
|
+
} | {
|
|
45
|
+
readonly _tag: 'InteractionRequested';
|
|
46
|
+
readonly request: InteractionRequest;
|
|
47
|
+
} | {
|
|
48
|
+
readonly _tag: 'InteractionSubmitted';
|
|
49
|
+
readonly response: InteractionResponse;
|
|
50
|
+
readonly request?: InteractionRequest;
|
|
51
|
+
} | {
|
|
52
|
+
readonly _tag: 'InteractionCancelled';
|
|
53
|
+
readonly response: InteractionResponse;
|
|
54
|
+
readonly request?: InteractionRequest;
|
|
44
55
|
} | {
|
|
45
56
|
readonly _tag: 'Executing';
|
|
46
57
|
readonly call: ToolCall;
|
|
47
|
-
readonly startedAtMs: number;
|
|
58
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
59
|
+
readonly interaction?: true;
|
|
48
60
|
} | {
|
|
49
61
|
readonly _tag: 'Completed';
|
|
50
62
|
readonly call: ToolCall;
|
|
@@ -96,30 +108,19 @@ declare const AgentToolRun: {
|
|
|
96
108
|
readonly response: InputResponse;
|
|
97
109
|
readonly request?: InputRequest;
|
|
98
110
|
}, "_tag">;
|
|
99
|
-
readonly
|
|
100
|
-
readonly _tag: "
|
|
101
|
-
readonly
|
|
102
|
-
readonly name?: string;
|
|
103
|
-
readonly input: string;
|
|
111
|
+
readonly InteractionRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
112
|
+
readonly _tag: "InteractionRequested";
|
|
113
|
+
readonly request: InteractionRequest;
|
|
104
114
|
}, "_tag">;
|
|
105
|
-
readonly
|
|
106
|
-
readonly _tag: "
|
|
107
|
-
readonly
|
|
115
|
+
readonly InteractionSubmitted: Data.TaggedEnum.ConstructorFrom<{
|
|
116
|
+
readonly _tag: "InteractionSubmitted";
|
|
117
|
+
readonly response: InteractionResponse;
|
|
118
|
+
readonly request?: InteractionRequest;
|
|
108
119
|
}, "_tag">;
|
|
109
|
-
readonly
|
|
110
|
-
readonly _tag: "
|
|
111
|
-
readonly
|
|
112
|
-
readonly request?:
|
|
113
|
-
}, "_tag">;
|
|
114
|
-
readonly Denied: Data.TaggedEnum.ConstructorFrom<{
|
|
115
|
-
readonly _tag: "Denied";
|
|
116
|
-
readonly toolCallId: string;
|
|
117
|
-
readonly reason: string;
|
|
118
|
-
}, "_tag">;
|
|
119
|
-
readonly Executing: Data.TaggedEnum.ConstructorFrom<{
|
|
120
|
-
readonly _tag: "Executing";
|
|
121
|
-
readonly call: ToolCall;
|
|
122
|
-
readonly startedAtMs: number;
|
|
120
|
+
readonly InteractionCancelled: Data.TaggedEnum.ConstructorFrom<{
|
|
121
|
+
readonly _tag: "InteractionCancelled";
|
|
122
|
+
readonly response: InteractionResponse;
|
|
123
|
+
readonly request?: InteractionRequest;
|
|
123
124
|
}, "_tag">;
|
|
124
125
|
readonly Completed: Data.TaggedEnum.ConstructorFrom<{
|
|
125
126
|
readonly _tag: "Completed";
|
|
@@ -135,6 +136,22 @@ declare const AgentToolRun: {
|
|
|
135
136
|
readonly startedAtMs: number;
|
|
136
137
|
readonly endedAtMs: number;
|
|
137
138
|
}, "_tag">;
|
|
139
|
+
readonly InputStreaming: Data.TaggedEnum.ConstructorFrom<{
|
|
140
|
+
readonly _tag: "InputStreaming";
|
|
141
|
+
readonly id: string;
|
|
142
|
+
readonly name?: string;
|
|
143
|
+
readonly input: string;
|
|
144
|
+
}, "_tag">;
|
|
145
|
+
readonly ApprovalRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
146
|
+
readonly _tag: "ApprovalRequested";
|
|
147
|
+
readonly call: ToolCall;
|
|
148
|
+
readonly request?: ToolApprovalRequest;
|
|
149
|
+
}, "_tag">;
|
|
150
|
+
readonly Denied: Data.TaggedEnum.ConstructorFrom<{
|
|
151
|
+
readonly _tag: "Denied";
|
|
152
|
+
readonly toolCallId: string;
|
|
153
|
+
readonly reason: string;
|
|
154
|
+
}, "_tag">;
|
|
138
155
|
readonly Errored: Data.TaggedEnum.ConstructorFrom<{
|
|
139
156
|
readonly _tag: "Errored";
|
|
140
157
|
readonly call: ToolCall;
|
|
@@ -146,7 +163,17 @@ declare const AgentToolRun: {
|
|
|
146
163
|
readonly call: ToolCall;
|
|
147
164
|
readonly result: ToolResult;
|
|
148
165
|
}, "_tag">;
|
|
149
|
-
readonly
|
|
166
|
+
readonly InputReady: Data.TaggedEnum.ConstructorFrom<{
|
|
167
|
+
readonly _tag: "InputReady";
|
|
168
|
+
readonly call: ToolCall;
|
|
169
|
+
}, "_tag">;
|
|
170
|
+
readonly Executing: Data.TaggedEnum.ConstructorFrom<{
|
|
171
|
+
readonly _tag: "Executing";
|
|
172
|
+
readonly call: ToolCall;
|
|
173
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
174
|
+
readonly interaction?: true;
|
|
175
|
+
}, "_tag">;
|
|
176
|
+
readonly $is: <Tag extends "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Completed" | "Accepted" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
150
177
|
readonly _tag: "InputStreaming";
|
|
151
178
|
readonly id: string;
|
|
152
179
|
readonly name?: string;
|
|
@@ -204,10 +231,28 @@ declare const AgentToolRun: {
|
|
|
204
231
|
readonly request?: InputRequest;
|
|
205
232
|
}, {
|
|
206
233
|
readonly _tag: Tag;
|
|
234
|
+
}> | Extract<{
|
|
235
|
+
readonly _tag: "InteractionRequested";
|
|
236
|
+
readonly request: InteractionRequest;
|
|
237
|
+
}, {
|
|
238
|
+
readonly _tag: Tag;
|
|
239
|
+
}> | Extract<{
|
|
240
|
+
readonly _tag: "InteractionSubmitted";
|
|
241
|
+
readonly response: InteractionResponse;
|
|
242
|
+
readonly request?: InteractionRequest;
|
|
243
|
+
}, {
|
|
244
|
+
readonly _tag: Tag;
|
|
245
|
+
}> | Extract<{
|
|
246
|
+
readonly _tag: "InteractionCancelled";
|
|
247
|
+
readonly response: InteractionResponse;
|
|
248
|
+
readonly request?: InteractionRequest;
|
|
249
|
+
}, {
|
|
250
|
+
readonly _tag: Tag;
|
|
207
251
|
}> | Extract<{
|
|
208
252
|
readonly _tag: "Executing";
|
|
209
253
|
readonly call: ToolCall;
|
|
210
|
-
readonly startedAtMs: number;
|
|
254
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
255
|
+
readonly interaction?: true;
|
|
211
256
|
}, {
|
|
212
257
|
readonly _tag: Tag;
|
|
213
258
|
}> | Extract<{
|
|
@@ -270,30 +315,19 @@ declare const AgentToolRun: {
|
|
|
270
315
|
readonly response: InputResponse;
|
|
271
316
|
readonly request?: InputRequest;
|
|
272
317
|
}) => any;
|
|
273
|
-
readonly
|
|
274
|
-
readonly _tag: "
|
|
275
|
-
readonly
|
|
276
|
-
readonly name?: string;
|
|
277
|
-
readonly input: string;
|
|
318
|
+
readonly InteractionRequested: (args: {
|
|
319
|
+
readonly _tag: "InteractionRequested";
|
|
320
|
+
readonly request: InteractionRequest;
|
|
278
321
|
}) => any;
|
|
279
|
-
readonly
|
|
280
|
-
readonly _tag: "
|
|
281
|
-
readonly
|
|
322
|
+
readonly InteractionSubmitted: (args: {
|
|
323
|
+
readonly _tag: "InteractionSubmitted";
|
|
324
|
+
readonly response: InteractionResponse;
|
|
325
|
+
readonly request?: InteractionRequest;
|
|
282
326
|
}) => any;
|
|
283
|
-
readonly
|
|
284
|
-
readonly _tag: "
|
|
285
|
-
readonly
|
|
286
|
-
readonly request?:
|
|
287
|
-
}) => any;
|
|
288
|
-
readonly Denied: (args: {
|
|
289
|
-
readonly _tag: "Denied";
|
|
290
|
-
readonly toolCallId: string;
|
|
291
|
-
readonly reason: string;
|
|
292
|
-
}) => any;
|
|
293
|
-
readonly Executing: (args: {
|
|
294
|
-
readonly _tag: "Executing";
|
|
295
|
-
readonly call: ToolCall;
|
|
296
|
-
readonly startedAtMs: number;
|
|
327
|
+
readonly InteractionCancelled: (args: {
|
|
328
|
+
readonly _tag: "InteractionCancelled";
|
|
329
|
+
readonly response: InteractionResponse;
|
|
330
|
+
readonly request?: InteractionRequest;
|
|
297
331
|
}) => any;
|
|
298
332
|
readonly Completed: (args: {
|
|
299
333
|
readonly _tag: "Completed";
|
|
@@ -309,6 +343,22 @@ declare const AgentToolRun: {
|
|
|
309
343
|
readonly startedAtMs: number;
|
|
310
344
|
readonly endedAtMs: number;
|
|
311
345
|
}) => any;
|
|
346
|
+
readonly InputStreaming: (args: {
|
|
347
|
+
readonly _tag: "InputStreaming";
|
|
348
|
+
readonly id: string;
|
|
349
|
+
readonly name?: string;
|
|
350
|
+
readonly input: string;
|
|
351
|
+
}) => any;
|
|
352
|
+
readonly ApprovalRequested: (args: {
|
|
353
|
+
readonly _tag: "ApprovalRequested";
|
|
354
|
+
readonly call: ToolCall;
|
|
355
|
+
readonly request?: ToolApprovalRequest;
|
|
356
|
+
}) => any;
|
|
357
|
+
readonly Denied: (args: {
|
|
358
|
+
readonly _tag: "Denied";
|
|
359
|
+
readonly toolCallId: string;
|
|
360
|
+
readonly reason: string;
|
|
361
|
+
}) => any;
|
|
312
362
|
readonly Errored: (args: {
|
|
313
363
|
readonly _tag: "Errored";
|
|
314
364
|
readonly call: ToolCall;
|
|
@@ -320,7 +370,17 @@ declare const AgentToolRun: {
|
|
|
320
370
|
readonly call: ToolCall;
|
|
321
371
|
readonly result: ToolResult;
|
|
322
372
|
}) => any;
|
|
323
|
-
|
|
373
|
+
readonly InputReady: (args: {
|
|
374
|
+
readonly _tag: "InputReady";
|
|
375
|
+
readonly call: ToolCall;
|
|
376
|
+
}) => any;
|
|
377
|
+
readonly Executing: (args: {
|
|
378
|
+
readonly _tag: "Executing";
|
|
379
|
+
readonly call: ToolCall;
|
|
380
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
381
|
+
readonly interaction?: true;
|
|
382
|
+
}) => any;
|
|
383
|
+
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Completed" | "Accepted" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing"]>>;
|
|
324
384
|
<Cases extends {
|
|
325
385
|
readonly QuestionRequested: (args: {
|
|
326
386
|
readonly _tag: "QuestionRequested";
|
|
@@ -350,30 +410,19 @@ declare const AgentToolRun: {
|
|
|
350
410
|
readonly response: InputResponse;
|
|
351
411
|
readonly request?: InputRequest;
|
|
352
412
|
}) => any;
|
|
353
|
-
readonly
|
|
354
|
-
readonly _tag: "
|
|
355
|
-
readonly
|
|
356
|
-
readonly name?: string;
|
|
357
|
-
readonly input: string;
|
|
413
|
+
readonly InteractionRequested: (args: {
|
|
414
|
+
readonly _tag: "InteractionRequested";
|
|
415
|
+
readonly request: InteractionRequest;
|
|
358
416
|
}) => any;
|
|
359
|
-
readonly
|
|
360
|
-
readonly _tag: "
|
|
361
|
-
readonly
|
|
417
|
+
readonly InteractionSubmitted: (args: {
|
|
418
|
+
readonly _tag: "InteractionSubmitted";
|
|
419
|
+
readonly response: InteractionResponse;
|
|
420
|
+
readonly request?: InteractionRequest;
|
|
362
421
|
}) => any;
|
|
363
|
-
readonly
|
|
364
|
-
readonly _tag: "
|
|
365
|
-
readonly
|
|
366
|
-
readonly request?:
|
|
367
|
-
}) => any;
|
|
368
|
-
readonly Denied: (args: {
|
|
369
|
-
readonly _tag: "Denied";
|
|
370
|
-
readonly toolCallId: string;
|
|
371
|
-
readonly reason: string;
|
|
372
|
-
}) => any;
|
|
373
|
-
readonly Executing: (args: {
|
|
374
|
-
readonly _tag: "Executing";
|
|
375
|
-
readonly call: ToolCall;
|
|
376
|
-
readonly startedAtMs: number;
|
|
422
|
+
readonly InteractionCancelled: (args: {
|
|
423
|
+
readonly _tag: "InteractionCancelled";
|
|
424
|
+
readonly response: InteractionResponse;
|
|
425
|
+
readonly request?: InteractionRequest;
|
|
377
426
|
}) => any;
|
|
378
427
|
readonly Completed: (args: {
|
|
379
428
|
readonly _tag: "Completed";
|
|
@@ -389,6 +438,22 @@ declare const AgentToolRun: {
|
|
|
389
438
|
readonly startedAtMs: number;
|
|
390
439
|
readonly endedAtMs: number;
|
|
391
440
|
}) => any;
|
|
441
|
+
readonly InputStreaming: (args: {
|
|
442
|
+
readonly _tag: "InputStreaming";
|
|
443
|
+
readonly id: string;
|
|
444
|
+
readonly name?: string;
|
|
445
|
+
readonly input: string;
|
|
446
|
+
}) => any;
|
|
447
|
+
readonly ApprovalRequested: (args: {
|
|
448
|
+
readonly _tag: "ApprovalRequested";
|
|
449
|
+
readonly call: ToolCall;
|
|
450
|
+
readonly request?: ToolApprovalRequest;
|
|
451
|
+
}) => any;
|
|
452
|
+
readonly Denied: (args: {
|
|
453
|
+
readonly _tag: "Denied";
|
|
454
|
+
readonly toolCallId: string;
|
|
455
|
+
readonly reason: string;
|
|
456
|
+
}) => any;
|
|
392
457
|
readonly Errored: (args: {
|
|
393
458
|
readonly _tag: "Errored";
|
|
394
459
|
readonly call: ToolCall;
|
|
@@ -400,7 +465,17 @@ declare const AgentToolRun: {
|
|
|
400
465
|
readonly call: ToolCall;
|
|
401
466
|
readonly result: ToolResult;
|
|
402
467
|
}) => any;
|
|
403
|
-
|
|
468
|
+
readonly InputReady: (args: {
|
|
469
|
+
readonly _tag: "InputReady";
|
|
470
|
+
readonly call: ToolCall;
|
|
471
|
+
}) => any;
|
|
472
|
+
readonly Executing: (args: {
|
|
473
|
+
readonly _tag: "Executing";
|
|
474
|
+
readonly call: ToolCall;
|
|
475
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
476
|
+
readonly interaction?: true;
|
|
477
|
+
}) => any;
|
|
478
|
+
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "InteractionRequested" | "InteractionSubmitted" | "InteractionCancelled" | "Completed" | "Accepted" | "InputStreaming" | "ApprovalRequested" | "Denied" | "Errored" | "ProviderCompleted" | "InputReady" | "Executing"]>>;
|
|
404
479
|
};
|
|
405
480
|
};
|
|
406
481
|
type AgentClientState = {
|
|
@@ -438,10 +513,18 @@ declare const isActiveToolRun: (run: AgentToolRun) => run is {
|
|
|
438
513
|
} | {
|
|
439
514
|
readonly _tag: "InputRequested";
|
|
440
515
|
readonly request: InputRequest;
|
|
516
|
+
} | {
|
|
517
|
+
readonly _tag: "InteractionRequested";
|
|
518
|
+
readonly request: InteractionRequest;
|
|
519
|
+
} | {
|
|
520
|
+
readonly _tag: "InteractionSubmitted";
|
|
521
|
+
readonly response: InteractionResponse;
|
|
522
|
+
readonly request?: InteractionRequest;
|
|
441
523
|
} | {
|
|
442
524
|
readonly _tag: "Executing";
|
|
443
525
|
readonly call: ToolCall;
|
|
444
|
-
readonly startedAtMs: number;
|
|
526
|
+
readonly startedAtMs: number; /** Preserve witnessed interaction acceptance across transport interruptions. */
|
|
527
|
+
readonly interaction?: true;
|
|
445
528
|
};
|
|
446
529
|
declare const completedToolRuns: (runs: ReadonlyArray<AgentToolRun>) => {
|
|
447
530
|
readonly _tag: "Completed";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.mts","names":[],"sources":["../../src/client/state.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"state.d.mts","names":[],"sources":["../../src/client/state.ts"],"mappings":";;;;KAoBY,cAAA;AAAA,KAEA,YAAA;EAAA,SAEG,IAAA;EAAA,SACA,EAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;AAAA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X,QAAA,EAAU,aAAA,CAAc,YAAA,GACxB,OAAA,EAAS,YAAA,KACR,eAAA;AAAA,cAUU,eAAA,GAAmB,KAAA,EAAO,gBAAA,EAAkB,KAAA,EAAO,UAAA,KAAa,gBAAA;AAAA,cAMhE,0BAAA,GACX,KAAA,EAAO,gBAAA,EACP,KAAA,EAAO,UAAA,EACP,OAAA,GAAS,sBAAA,KACR,gBAAA;AAAA,cA2SU,sBAAA,GACX,KAAA,EAAO,gBAAA,EACP,OAAA,EAAS,WAAA,KACR,gBAAA;AAAA,cAcU,cAAA,GACX,KAAA,EAAO,gBAAA,EACP,OAAA,WACA,SAAA,GAAW,UAAA,YACV,gBAAA;AAAA,cASU,gBAAA,GAAoB,KAAA,EAAO,gBAAA,KAAmB,gBAOzD;AAAA,cAEW,iBAAA,GACX,MAAA,EAAQ,aAAA,CAAc,UAAA,GACtB,YAAA,GAAc,gBAAA,EACd,OAAA,GAAS,sBAAA,KAA2B,gBAAA"}
|
package/dist/client/state.mjs
CHANGED
|
@@ -32,14 +32,14 @@ const rememberEvent = (state, event) => event.eventId === void 0 ? state : {
|
|
|
32
32
|
...state,
|
|
33
33
|
seenEventIds: [...state.seenEventIds, event.eventId]
|
|
34
34
|
};
|
|
35
|
-
const toolRunId = (run) => Match.value(run).pipe(Match.tag("InputStreaming", (current) => current.id), Match.tag("Denied", (current) => current.toolCallId), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.response.toolCallId), Match.tag("InputRequested", (current) => current.request.toolCallId), Match.tag("InputSubmitted", "InputCancelled", (current) => current.response.toolCallId), Match.tag("InputReady", "ApprovalRequested", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", (current) => current.call.id), Match.exhaustive);
|
|
36
|
-
const isActiveToolRun = (run) => !Predicate.isTagged(run, "Accepted") && !Predicate.isTagged(run, "Completed") && !Predicate.isTagged(run, "Errored") && !Predicate.isTagged(run, "Denied") && !Predicate.isTagged(run, "QuestionAnswered") && !Predicate.isTagged(run, "QuestionCancelled") && !Predicate.isTagged(run, "InputSubmitted") && !Predicate.isTagged(run, "InputCancelled") && !Predicate.isTagged(run, "ProviderCompleted");
|
|
35
|
+
const toolRunId = (run) => Match.value(run).pipe(Match.tag("InputStreaming", (current) => current.id), Match.tag("Denied", (current) => current.toolCallId), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.response.toolCallId), Match.tag("InputRequested", (current) => current.request.toolCallId), Match.tag("InputSubmitted", "InputCancelled", (current) => current.response.toolCallId), Match.tag("InteractionRequested", (current) => current.request.toolCallId), Match.tag("InteractionSubmitted", "InteractionCancelled", (current) => current.response.toolCallId), Match.tag("InputReady", "ApprovalRequested", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", (current) => current.call.id), Match.exhaustive);
|
|
36
|
+
const isActiveToolRun = (run) => !Predicate.isTagged(run, "Accepted") && !Predicate.isTagged(run, "Completed") && !Predicate.isTagged(run, "Errored") && !Predicate.isTagged(run, "Denied") && !Predicate.isTagged(run, "QuestionAnswered") && !Predicate.isTagged(run, "QuestionCancelled") && !Predicate.isTagged(run, "InputSubmitted") && !Predicate.isTagged(run, "InputCancelled") && !Predicate.isTagged(run, "InteractionCancelled") && !Predicate.isTagged(run, "ProviderCompleted");
|
|
37
37
|
const completedToolRuns = (runs) => runs.filter((run) => Predicate.isTagged(run, "Completed"));
|
|
38
|
-
const retainedSettledToolRuns = (runs) => runs.filter((run) => Predicate.isTagged(run, "Completed") || Predicate.isTagged(run, "Accepted"));
|
|
38
|
+
const retainedSettledToolRuns = (runs) => runs.filter((run) => Predicate.isTagged(run, "Completed") || Predicate.isTagged(run, "Accepted") || Predicate.isTagged(run, "InteractionSubmitted") || Predicate.isTagged(run, "Executing") && run.interaction === true);
|
|
39
39
|
const toolRunsFromHitlRequests = (requests) => requests.map((request) => Match.value(request).pipe(Match.tag("QuestionRequest", (current) => AgentToolRun.QuestionRequested({ request: current })), Match.tag("ToolApprovalRequest", (current) => AgentToolRun.ApprovalRequested({
|
|
40
40
|
call: current.call,
|
|
41
41
|
request: current
|
|
42
|
-
})), Match.tag("InputRequest", (current) => AgentToolRun.InputRequested({ request: current })), Match.exhaustive));
|
|
42
|
+
})), Match.tag("InputRequest", (current) => AgentToolRun.InputRequested({ request: current })), Match.tag("InteractionRequest", (current) => AgentToolRun.InteractionRequested({ request: current })), Match.exhaustive));
|
|
43
43
|
const replaceToolRun = (runs, run) => {
|
|
44
44
|
const id = toolRunId(run);
|
|
45
45
|
const replaceIndex = runs.findIndex((current) => toolRunId(current) === id);
|
|
@@ -58,11 +58,11 @@ const appendToolInputDelta = (runs, id, delta) => runs.map((run) => Predicate.is
|
|
|
58
58
|
} : run);
|
|
59
59
|
const questionRequestForToolCall = (runs, toolCallId) => runs.flatMap((run) => {
|
|
60
60
|
if (toolRunId(run) !== toolCallId) return [];
|
|
61
|
-
return Match.value(run).pipe(Match.tag("QuestionRequested", (current) => [current.request]), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "InputRequested", "InputSubmitted", "InputCancelled", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", () => []), Match.exhaustive);
|
|
61
|
+
return Match.value(run).pipe(Match.tag("QuestionRequested", (current) => [current.request]), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "InputRequested", "InputSubmitted", "InputCancelled", "InteractionRequested", "InteractionSubmitted", "InteractionCancelled", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", () => []), Match.exhaustive);
|
|
62
62
|
})[0];
|
|
63
63
|
const inputRequestForToolCall = (runs, toolCallId) => runs.flatMap((run) => {
|
|
64
64
|
if (toolRunId(run) !== toolCallId) return [];
|
|
65
|
-
return Match.value(run).pipe(Match.tag("InputRequested", (current) => [current.request]), Match.tag("InputSubmitted", "InputCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", "QuestionRequested", "QuestionAnswered", "QuestionCancelled", () => []), Match.exhaustive);
|
|
65
|
+
return Match.value(run).pipe(Match.tag("InputRequested", (current) => [current.request]), Match.tag("InputSubmitted", "InputCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "InteractionRequested", "InteractionSubmitted", "InteractionCancelled", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", "QuestionRequested", "QuestionAnswered", "QuestionCancelled", () => []), Match.exhaustive);
|
|
66
66
|
})[0];
|
|
67
67
|
const inputSubmittedRun = (response, request) => request === void 0 ? AgentToolRun.InputSubmitted({ response }) : AgentToolRun.InputSubmitted({
|
|
68
68
|
response,
|
|
@@ -80,6 +80,18 @@ const questionCancelledRun = (response, request) => request === void 0 ? AgentTo
|
|
|
80
80
|
response,
|
|
81
81
|
request
|
|
82
82
|
});
|
|
83
|
+
const interactionSubmittedRun = (response, request) => request === void 0 ? AgentToolRun.InteractionSubmitted({ response }) : AgentToolRun.InteractionSubmitted({
|
|
84
|
+
response,
|
|
85
|
+
request
|
|
86
|
+
});
|
|
87
|
+
const interactionCancelledRun = (response, request) => request === void 0 ? AgentToolRun.InteractionCancelled({ response }) : AgentToolRun.InteractionCancelled({
|
|
88
|
+
response,
|
|
89
|
+
request
|
|
90
|
+
});
|
|
91
|
+
const interactionRequestForToolCall = (runs, toolCallId) => runs.flatMap((run) => {
|
|
92
|
+
if (toolRunId(run) !== toolCallId) return [];
|
|
93
|
+
return Match.value(run).pipe(Match.tag("InteractionRequested", (current) => [current.request]), Match.tag("InteractionSubmitted", "InteractionCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "InputRequested", "InputSubmitted", "InputCancelled", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", "QuestionRequested", "QuestionAnswered", "QuestionCancelled", () => []), Match.exhaustive);
|
|
94
|
+
})[0];
|
|
83
95
|
const appendAgentMessage = (messages, message) => {
|
|
84
96
|
const first = messages[0];
|
|
85
97
|
if (first === void 0) return [message];
|
|
@@ -97,7 +109,7 @@ const applyAgentEventWithOptions = (state, event, options = {}) => {
|
|
|
97
109
|
if (hasSeenEvent(state, event)) return state;
|
|
98
110
|
return rememberEvent(applyAgentEventUnchecked(state, event, nowMs), event);
|
|
99
111
|
};
|
|
100
|
-
const activeEventToolCallId = (event) => Match.value(event).pipe(Match.tag("ToolInputStart", "ToolInputDelta", (current) => current.id), Match.tag("ToolInputEnd", "ToolExecutionStarted", "ToolApprovalRequested", (current) => current.call.id), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.tag("InputRequested", (current) => current.request.toolCallId), Match.orElse(() => void 0));
|
|
112
|
+
const activeEventToolCallId = (event) => Match.value(event).pipe(Match.tag("ToolInputStart", "ToolInputDelta", (current) => current.id), Match.tag("ToolInputEnd", "ToolExecutionStarted", "ToolApprovalRequested", (current) => current.call.id), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.tag("InputRequested", (current) => current.request.toolCallId), Match.tag("InteractionRequested", (current) => current.request.toolCallId), Match.orElse(() => void 0));
|
|
101
113
|
const applyAgentEventUnchecked = (state, event, nowMs) => {
|
|
102
114
|
const activeCallId = activeEventToolCallId(event);
|
|
103
115
|
const acknowledgesActiveCall = (message) => Predicate.isTagged(message, "ToolResult") && message.toolCallId === activeCallId && message.acceptance !== void 0;
|
|
@@ -152,6 +164,9 @@ const applyAgentEventUnchecked = (state, event, nowMs) => {
|
|
|
152
164
|
})), Match.tag("InputRequested", (current) => ({
|
|
153
165
|
...state,
|
|
154
166
|
toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.InputRequested({ request: current.request }))
|
|
167
|
+
})), Match.tag("InteractionRequested", (current) => ({
|
|
168
|
+
...state,
|
|
169
|
+
toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.InteractionRequested({ request: current.request }))
|
|
155
170
|
}))).pipe(Match.tag("QuestionAnswered", (current) => ({
|
|
156
171
|
...state,
|
|
157
172
|
toolRuns: replaceToolRun(state.toolRuns, questionAnsweredRun(current.response, questionRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
@@ -164,13 +179,27 @@ const applyAgentEventUnchecked = (state, event, nowMs) => {
|
|
|
164
179
|
})), Match.tag("InputCancelled", (current) => ({
|
|
165
180
|
...state,
|
|
166
181
|
toolRuns: replaceToolRun(state.toolRuns, inputCancelledRun(current.response, inputRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
167
|
-
})), Match.tag("
|
|
182
|
+
})), Match.tag("InteractionSubmitted", (current) => ({
|
|
168
183
|
...state,
|
|
169
|
-
toolRuns: replaceToolRun(state.toolRuns,
|
|
184
|
+
toolRuns: replaceToolRun(state.toolRuns, interactionSubmittedRun(current.response, interactionRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
185
|
+
})), Match.tag("InteractionCancelled", (current) => ({
|
|
186
|
+
...state,
|
|
187
|
+
toolRuns: replaceToolRun(state.toolRuns, interactionCancelledRun(current.response, interactionRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
188
|
+
})), Match.tag("ToolExecutionStarted", (current) => {
|
|
189
|
+
const prior = state.toolRuns.find((run) => toolRunId(run) === current.call.id);
|
|
190
|
+
const executing = AgentToolRun.Executing({
|
|
170
191
|
call: current.call,
|
|
171
192
|
startedAtMs: nowMs
|
|
172
|
-
})
|
|
173
|
-
|
|
193
|
+
});
|
|
194
|
+
const isInteraction = Predicate.isTagged(prior, "InteractionSubmitted") || Predicate.isTagged(prior, "Executing") && prior.interaction === true;
|
|
195
|
+
return {
|
|
196
|
+
...state,
|
|
197
|
+
toolRuns: replaceToolRun(state.toolRuns, isInteraction ? {
|
|
198
|
+
...executing,
|
|
199
|
+
interaction: true
|
|
200
|
+
} : executing)
|
|
201
|
+
};
|
|
202
|
+
}), Match.tag("ToolExecutionAccepted", "ToolExecutionCompleted", (current) => {
|
|
174
203
|
const endedAtMs = nowMs;
|
|
175
204
|
const startedAtMs = startedAtMsFor(state.toolRuns, current.call.id) ?? endedAtMs;
|
|
176
205
|
return {
|