@yolk-sdk/agent 0.1.0-canary.80 → 0.1.0-canary.82
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 +16 -8
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.mjs +2 -2
- package/dist/client/state.d.mts +77 -4
- package/dist/client/state.d.mts.map +1 -1
- package/dist/client/state.mjs +26 -5
- package/dist/client/state.mjs.map +1 -1
- package/dist/client/transport.d.mts +16 -12
- package/dist/client/transport.d.mts.map +1 -1
- package/dist/client/transport.mjs +16 -7
- package/dist/client/transport.mjs.map +1 -1
- package/dist/loop/run.d.mts +6 -3
- package/dist/loop/run.d.mts.map +1 -1
- package/dist/loop/run.mjs +95 -7
- package/dist/loop/run.mjs.map +1 -1
- package/dist/protocol/event.d.mts +38 -4
- package/dist/protocol/event.d.mts.map +1 -1
- package/dist/protocol/event.mjs +58 -3
- package/dist/protocol/event.mjs.map +1 -1
- package/dist/protocol/index.d.mts +4 -4
- package/dist/protocol/index.d.mts.map +1 -1
- package/dist/protocol/index.mjs +4 -4
- package/dist/protocol/session.d.mts +12 -5
- package/dist/protocol/session.d.mts.map +1 -1
- package/dist/protocol/session.mjs +10 -3
- package/dist/protocol/session.mjs.map +1 -1
- package/dist/protocol/tool.d.mts +135 -8
- package/dist/protocol/tool.d.mts.map +1 -1
- package/dist/protocol/tool.mjs +74 -5
- package/dist/protocol/tool.mjs.map +1 -1
- package/dist/providers/openai/provider.d.mts.map +1 -1
- package/dist/providers/openai/provider.mjs +55 -9
- package/dist/providers/openai/provider.mjs.map +1 -1
- package/dist/providers/provider-error.d.mts +2 -1
- package/dist/providers/provider-error.d.mts.map +1 -1
- package/dist/providers/provider-error.mjs +1 -0
- package/dist/providers/provider-error.mjs.map +1 -1
- package/dist/providers/vercel/ai-gateway-provider.d.mts +13 -0
- package/dist/providers/vercel/ai-gateway-provider.d.mts.map +1 -1
- package/dist/providers/vercel/ai-gateway-provider.mjs +2 -0
- package/dist/providers/vercel/ai-gateway-provider.mjs.map +1 -1
- package/dist/react/chat-actions.d.mts +20 -20
- 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 +92 -22
- package/dist/react/chat-items.d.mts.map +1 -1
- package/dist/react/chat-items.mjs +14 -0
- package/dist/react/chat-items.mjs.map +1 -1
- package/dist/react/chat-messages.d.mts +74 -4
- package/dist/react/chat-messages.d.mts.map +1 -1
- package/dist/react/chat-messages.mjs +38 -7
- 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 +3 -2
- package/dist/runtime/run-runtime.d.mts.map +1 -1
- package/dist/runtime/run-runtime.mjs +2 -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 +3 -2
- package/dist/tools/input.d.mts +41 -0
- package/dist/tools/input.d.mts.map +1 -0
- package/dist/tools/input.mjs +83 -0
- package/dist/tools/input.mjs.map +1 -0
- package/dist/tools/registry.d.mts +16 -4
- package/dist/tools/registry.d.mts.map +1 -1
- package/dist/tools/registry.mjs +29 -3
- 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 +98 -0
- package/src/client/transport.ts +37 -15
- package/src/loop/run.ts +180 -19
- package/src/protocol/event.ts +85 -1
- package/src/protocol/index.ts +20 -0
- package/src/protocol/session.ts +13 -2
- package/src/protocol/tool.ts +151 -3
- package/src/providers/openai/provider.ts +90 -5
- package/src/providers/provider-error.ts +8 -1
- package/src/providers/vercel/ai-gateway-provider.ts +23 -0
- package/src/react/chat-core.ts +10 -4
- package/src/react/chat-items.ts +33 -0
- package/src/react/chat-messages.ts +161 -1
- package/src/react/use-agent-chat.ts +7 -0
- package/src/runtime/run-runtime.ts +11 -0
- package/src/tools/index.ts +7 -1
- package/src/tools/input.ts +194 -0
- package/src/tools/registry.ts +67 -2
- package/src/voice/controller.ts +1 -0
- package/src/voice/index.ts +1 -0
- package/src/voice/tool-server.ts +11 -0
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Published package metadata requires Node.js 22+.
|
|
|
26
26
|
| `@yolk-sdk/agent/runtime` | Transcript or append-backed runtime orchestration |
|
|
27
27
|
| `@yolk-sdk/agent/client` | HTTP/NDJSON transport, HITL resume, retry/error state helpers |
|
|
28
28
|
| `@yolk-sdk/agent/compaction` | Host-owned compaction budgets, checkpoints, formatting, retry |
|
|
29
|
-
| `@yolk-sdk/agent/tools` | Tool registry,
|
|
29
|
+
| `@yolk-sdk/agent/tools` | Tool registry, typed inputs, subagent/question contracts |
|
|
30
30
|
| `@yolk-sdk/agent/react` | Headless React chat hook, reducer, selectors, and render model |
|
|
31
31
|
| `@yolk-sdk/agent/oauth` | Provider-neutral OAuth token and broker contracts |
|
|
32
32
|
| `@yolk-sdk/agent/providers/openai` | OpenAI/Codex OAuth and broker helpers |
|
|
@@ -110,7 +110,7 @@ import { FauxProvider, Reply, TestToolExecutor } from '@yolk-sdk/agent/loop/test
|
|
|
110
110
|
## Headless React chat
|
|
111
111
|
|
|
112
112
|
`useAgentChat` exposes protocol messages, render-oriented chat messages, run/error/waiting state,
|
|
113
|
-
and actions for submit, stop, edit, regenerate, delete, tool approval, and
|
|
113
|
+
and actions for submit, stop, edit, regenerate, delete, tool approval, question, and typed input responses. The
|
|
114
114
|
package supplies no components, styling, auth, or route ownership, and React remains an optional
|
|
115
115
|
peer used only by React subpaths.
|
|
116
116
|
|
|
@@ -253,7 +253,10 @@ the adapter preserves the provider's timestamp. Missing/invalid percentages are
|
|
|
253
253
|
as zero. Treat snapshots as best-effort; hosts own polling, stale-data policy, persistence, and UI.
|
|
254
254
|
The fetcher blocks redirects and sanitizes failures using the shared subscription-usage error types.
|
|
255
255
|
|
|
256
|
-
Vercel AI Gateway uses its OpenAI-compatible
|
|
256
|
+
Vercel AI Gateway uses its OpenAI-compatible Chat Completions endpoint, with a single JSON
|
|
257
|
+
completion by default. Set factory option `streaming: true` for SSE deltas and independently set
|
|
258
|
+
`reasoningContent: true` to preserve compatible models' `reasoning_content` output and assistant
|
|
259
|
+
replay. Both default to false; replayed reasoning spends input tokens. Pass either an AI
|
|
257
260
|
Gateway API key or Vercel OIDC token as `apiKey`; `maxCompletionTokens` is sent as Gateway
|
|
258
261
|
`max_tokens`. The env-backed `VercelAiGatewayProviderLayer` tries `AI_GATEWAY_API_KEY` first, then
|
|
259
262
|
`VERCEL_OIDC_TOKEN`, and requires integer
|
|
@@ -371,8 +374,11 @@ and object-root identity are unchanged.
|
|
|
371
374
|
Provider adapters classify safe failure metadata at the boundary. The loop owns bounded retry
|
|
372
375
|
policy and emits protocol-visible retry/error state:
|
|
373
376
|
|
|
374
|
-
- `ProviderErrorInfo` carries safe provider id, failure kind, HTTP status, provider code,
|
|
375
|
-
optional `
|
|
377
|
+
- `ProviderErrorInfo` carries safe provider id, failure kind, HTTP status, provider code, optional
|
|
378
|
+
`retryAfterMs`, and optional `stream` diagnostics (`ProviderStreamDiagnostics`) on chat
|
|
379
|
+
`unexpected_content_type` / `incomplete_stream` failures. Diagnostics contain counters and
|
|
380
|
+
milestones, never transcript content, raw headers, or body fragments. See the
|
|
381
|
+
[stream diagnostics guide](https://github.com/magoz/yolk-sdk/blob/main/apps/docs/content/docs/troubleshooting.mdx#diagnose-chat-stream-failures-with-stream-diagnostics).
|
|
376
382
|
- Chat Completions and Responses HTTP failures copy the envelope string `code` (falling back to
|
|
377
383
|
`type`) into `provider.providerCode`; free-text upstream bodies stay out of `LLMError`.
|
|
378
384
|
- `AgentRetry.provider` exposes current retry metadata and chosen `delayMs`.
|
|
@@ -628,9 +634,11 @@ HITL is protocol-level, not UI-level:
|
|
|
628
634
|
`streamToolApprovalResponseEventStream`.
|
|
629
635
|
- Denials become model-visible `ToolResult` messages with `isError = true`.
|
|
630
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.
|
|
631
|
-
- Use `
|
|
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.
|
|
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.
|
|
639
|
+
- 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).
|
|
632
640
|
- Use `toolRunsFromHitlRequests` to hydrate paused UI state from `AgentAwaitingInput.requests`.
|
|
633
|
-
- Use `hitlResponseEvent` when a client needs optimistic approval/question UI updates before resumed stream events arrive.
|
|
641
|
+
- 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.
|
|
634
642
|
- Approval is a host-enforced per-call gate for normal tools, not a model-callable permission tool or persisted allow-always system.
|
|
635
643
|
|
|
636
644
|
HTTP client helpers treat `AgentEnd`, `AgentError`, and `AgentAwaitingInput` as logical stream
|
|
@@ -698,7 +706,7 @@ handler, approval HITL, transcript projection, and one-shot TTS/STT contracts.
|
|
|
698
706
|
JSON-compatible `VoiceToolCallOutcome` envelope, applies `ToolDef.approval` policy, and never runs
|
|
699
707
|
approval-gated tools without a matching approved response.
|
|
700
708
|
- Approval-gated calls pause with `AwaitingInput`; approvals/denials resume through
|
|
701
|
-
`submitHitlResponse`. Voice
|
|
709
|
+
`submitHitlResponse`. Voice questions and custom typed inputs are unsupported in v1.
|
|
702
710
|
- `projectVoiceEvent` turns voice events into protocol messages with no dangling host tool
|
|
703
711
|
calls. Assistant drafts are keyed per provider output item (falling back to response id), so
|
|
704
712
|
back-to-back responses, multi-item responses, and duplicate final transcript event families
|
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, SubmitQuestionResponseRequest, SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
-
export { type AgentClientState, type AgentHttpResponseInfo, type AgentRunContinuationOptions, type AgentRunIdleReconnectOptions, type AgentRunStatus, type AgentToolRun, type AgentTranscript, AgentTransportError, type ApplyAgentEventOptions, type CancelAgentRunRequest, type StreamAgentEventHandler, type StreamAgentEventsRequest, type StreamAgentEventsUntilTerminalRequest, type StreamAgentRunEventsRequest, type StreamAgentRunEventsUntilTerminalRequest, type StreamAgentRunHitlResponseEventsRequest, type StreamAgentRunHitlResponseEventsUntilTerminalRequest, type StreamCloudflareAgentEventsRequest, type SubmitQuestionResponseRequest, type SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
|
3
|
+
import { AgentHttpResponseInfo, AgentRunContinuationOptions, AgentRunIdleReconnectOptions, AgentTransportError, CancelAgentRunRequest, StreamAgentEventHandler, StreamAgentEventsRequest, StreamAgentEventsUntilTerminalRequest, StreamAgentRunEventsRequest, StreamAgentRunEventsUntilTerminalRequest, StreamAgentRunHitlResponseEventsRequest, StreamAgentRunHitlResponseEventsUntilTerminalRequest, StreamCloudflareAgentEventsRequest, SubmitInputResponseRequest, SubmitQuestionResponseRequest, SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
+
export { type AgentClientState, type AgentHttpResponseInfo, type AgentRunContinuationOptions, type AgentRunIdleReconnectOptions, type AgentRunStatus, type AgentToolRun, type AgentTranscript, AgentTransportError, type ApplyAgentEventOptions, type CancelAgentRunRequest, type StreamAgentEventHandler, type StreamAgentEventsRequest, type StreamAgentEventsUntilTerminalRequest, type StreamAgentRunEventsRequest, type StreamAgentRunEventsUntilTerminalRequest, type StreamAgentRunHitlResponseEventsRequest, type StreamAgentRunHitlResponseEventsUntilTerminalRequest, type StreamCloudflareAgentEventsRequest, type SubmitInputResponseRequest, type SubmitQuestionResponseRequest, type SubmitToolApprovalResponseRequest, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
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, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
-
export { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
|
3
|
+
import { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, cancelAgentRun, collectAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream } from "./transport.mjs";
|
|
4
|
+
export { AgentTransportError, agentRunEndpointWithStartIndex, agentRunIdFromHeaders, agentRunStreamStartIndexFromHeaders, agentRunStreamTailIndexFromHeaders, appendAgentMessage, applyAgentEvent, cancelAgentRun, collectAgentEvents, completedToolRuns, documentPartFromTextFile, initialAgentClientState, isActiveToolRun, markAgentAborted, markAgentError, reduceAgentEvents, streamAgentEventStream, streamAgentEventStreamUntilTerminal, streamAgentRunEventStream, streamAgentRunEventStreamUntilTerminal, streamAgentRunHitlResponseEventStream, streamAgentRunHitlResponseEventStreamUntilTerminal, streamCloudflareAgentEventStream, streamInputResponseEventStream, streamQuestionResponseEventStream, streamToolApprovalResponseEventStream, submitAgentUserMessage, textFromBlob, toolRunsFromHitlRequests };
|
package/dist/client/state.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Data } from "effect";
|
|
2
|
-
import { AgentError, AgentEvent, AgentMessage, AgentRetry, HitlRequest, QuestionRequest, QuestionResponse, ToolApprovalRequest, ToolCall, ToolResult, UserMessage } from "@yolk-sdk/agent/protocol";
|
|
2
|
+
import { AgentError, AgentEvent, AgentMessage, AgentRetry, HitlRequest, InputRequest, InputResponse, QuestionRequest, QuestionResponse, ToolApprovalRequest, ToolCall, ToolResult, UserMessage } from "@yolk-sdk/agent/protocol";
|
|
3
3
|
|
|
4
4
|
//#region src/client/state.d.ts
|
|
5
5
|
type AgentRunStatus = 'idle' | 'running' | 'waiting' | 'done' | 'error' | 'aborted';
|
|
@@ -30,6 +30,17 @@ type AgentToolRun = {
|
|
|
30
30
|
readonly _tag: 'QuestionCancelled';
|
|
31
31
|
readonly response: QuestionResponse;
|
|
32
32
|
readonly request?: QuestionRequest;
|
|
33
|
+
} | {
|
|
34
|
+
readonly _tag: 'InputRequested';
|
|
35
|
+
readonly request: InputRequest;
|
|
36
|
+
} | {
|
|
37
|
+
readonly _tag: 'InputSubmitted';
|
|
38
|
+
readonly response: InputResponse;
|
|
39
|
+
readonly request?: InputRequest;
|
|
40
|
+
} | {
|
|
41
|
+
readonly _tag: 'InputCancelled';
|
|
42
|
+
readonly response: InputResponse;
|
|
43
|
+
readonly request?: InputRequest;
|
|
33
44
|
} | {
|
|
34
45
|
readonly _tag: 'Executing';
|
|
35
46
|
readonly call: ToolCall;
|
|
@@ -91,6 +102,20 @@ declare const AgentToolRun: {
|
|
|
91
102
|
readonly response: QuestionResponse;
|
|
92
103
|
readonly request?: QuestionRequest;
|
|
93
104
|
}, "_tag">;
|
|
105
|
+
readonly InputRequested: Data.TaggedEnum.ConstructorFrom<{
|
|
106
|
+
readonly _tag: "InputRequested";
|
|
107
|
+
readonly request: InputRequest;
|
|
108
|
+
}, "_tag">;
|
|
109
|
+
readonly InputSubmitted: Data.TaggedEnum.ConstructorFrom<{
|
|
110
|
+
readonly _tag: "InputSubmitted";
|
|
111
|
+
readonly response: InputResponse;
|
|
112
|
+
readonly request?: InputRequest;
|
|
113
|
+
}, "_tag">;
|
|
114
|
+
readonly InputCancelled: Data.TaggedEnum.ConstructorFrom<{
|
|
115
|
+
readonly _tag: "InputCancelled";
|
|
116
|
+
readonly response: InputResponse;
|
|
117
|
+
readonly request?: InputRequest;
|
|
118
|
+
}, "_tag">;
|
|
94
119
|
readonly Executing: Data.TaggedEnum.ConstructorFrom<{
|
|
95
120
|
readonly _tag: "Executing";
|
|
96
121
|
readonly call: ToolCall;
|
|
@@ -121,7 +146,7 @@ declare const AgentToolRun: {
|
|
|
121
146
|
readonly call: ToolCall;
|
|
122
147
|
readonly result: ToolResult;
|
|
123
148
|
}, "_tag">;
|
|
124
|
-
readonly $is: <Tag extends "InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
149
|
+
readonly $is: <Tag extends "InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
125
150
|
readonly _tag: "InputStreaming";
|
|
126
151
|
readonly id: string;
|
|
127
152
|
readonly name?: string;
|
|
@@ -162,6 +187,23 @@ declare const AgentToolRun: {
|
|
|
162
187
|
readonly request?: QuestionRequest;
|
|
163
188
|
}, {
|
|
164
189
|
readonly _tag: Tag;
|
|
190
|
+
}> | Extract<{
|
|
191
|
+
readonly _tag: "InputRequested";
|
|
192
|
+
readonly request: InputRequest;
|
|
193
|
+
}, {
|
|
194
|
+
readonly _tag: Tag;
|
|
195
|
+
}> | Extract<{
|
|
196
|
+
readonly _tag: "InputSubmitted";
|
|
197
|
+
readonly response: InputResponse;
|
|
198
|
+
readonly request?: InputRequest;
|
|
199
|
+
}, {
|
|
200
|
+
readonly _tag: Tag;
|
|
201
|
+
}> | Extract<{
|
|
202
|
+
readonly _tag: "InputCancelled";
|
|
203
|
+
readonly response: InputResponse;
|
|
204
|
+
readonly request?: InputRequest;
|
|
205
|
+
}, {
|
|
206
|
+
readonly _tag: Tag;
|
|
165
207
|
}> | Extract<{
|
|
166
208
|
readonly _tag: "Executing";
|
|
167
209
|
readonly call: ToolCall;
|
|
@@ -234,6 +276,20 @@ declare const AgentToolRun: {
|
|
|
234
276
|
readonly response: QuestionResponse;
|
|
235
277
|
readonly request?: QuestionRequest;
|
|
236
278
|
}) => any;
|
|
279
|
+
readonly InputRequested: (args: {
|
|
280
|
+
readonly _tag: "InputRequested";
|
|
281
|
+
readonly request: InputRequest;
|
|
282
|
+
}) => any;
|
|
283
|
+
readonly InputSubmitted: (args: {
|
|
284
|
+
readonly _tag: "InputSubmitted";
|
|
285
|
+
readonly response: InputResponse;
|
|
286
|
+
readonly request?: InputRequest;
|
|
287
|
+
}) => any;
|
|
288
|
+
readonly InputCancelled: (args: {
|
|
289
|
+
readonly _tag: "InputCancelled";
|
|
290
|
+
readonly response: InputResponse;
|
|
291
|
+
readonly request?: InputRequest;
|
|
292
|
+
}) => any;
|
|
237
293
|
readonly Executing: (args: {
|
|
238
294
|
readonly _tag: "Executing";
|
|
239
295
|
readonly call: ToolCall;
|
|
@@ -264,7 +320,7 @@ declare const AgentToolRun: {
|
|
|
264
320
|
readonly call: ToolCall;
|
|
265
321
|
readonly result: ToolResult;
|
|
266
322
|
}) => any;
|
|
267
|
-
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
|
|
323
|
+
}>(cases: Cases): (value: AgentToolRun) => import("effect/Unify").Unify<ReturnType<Cases["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
|
|
268
324
|
<Cases extends {
|
|
269
325
|
readonly InputStreaming: (args: {
|
|
270
326
|
readonly _tag: "InputStreaming";
|
|
@@ -300,6 +356,20 @@ declare const AgentToolRun: {
|
|
|
300
356
|
readonly response: QuestionResponse;
|
|
301
357
|
readonly request?: QuestionRequest;
|
|
302
358
|
}) => any;
|
|
359
|
+
readonly InputRequested: (args: {
|
|
360
|
+
readonly _tag: "InputRequested";
|
|
361
|
+
readonly request: InputRequest;
|
|
362
|
+
}) => any;
|
|
363
|
+
readonly InputSubmitted: (args: {
|
|
364
|
+
readonly _tag: "InputSubmitted";
|
|
365
|
+
readonly response: InputResponse;
|
|
366
|
+
readonly request?: InputRequest;
|
|
367
|
+
}) => any;
|
|
368
|
+
readonly InputCancelled: (args: {
|
|
369
|
+
readonly _tag: "InputCancelled";
|
|
370
|
+
readonly response: InputResponse;
|
|
371
|
+
readonly request?: InputRequest;
|
|
372
|
+
}) => any;
|
|
303
373
|
readonly Executing: (args: {
|
|
304
374
|
readonly _tag: "Executing";
|
|
305
375
|
readonly call: ToolCall;
|
|
@@ -330,7 +400,7 @@ declare const AgentToolRun: {
|
|
|
330
400
|
readonly call: ToolCall;
|
|
331
401
|
readonly result: ToolResult;
|
|
332
402
|
}) => any;
|
|
333
|
-
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
|
|
403
|
+
}>(value: AgentToolRun, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["InputStreaming" | "InputReady" | "ApprovalRequested" | "Denied" | "QuestionRequested" | "QuestionAnswered" | "QuestionCancelled" | "InputRequested" | "InputSubmitted" | "InputCancelled" | "Executing" | "Completed" | "Accepted" | "Errored" | "ProviderCompleted"]>>;
|
|
334
404
|
};
|
|
335
405
|
};
|
|
336
406
|
type AgentClientState = {
|
|
@@ -365,6 +435,9 @@ declare const isActiveToolRun: (run: AgentToolRun) => run is {
|
|
|
365
435
|
} | {
|
|
366
436
|
readonly _tag: "QuestionRequested";
|
|
367
437
|
readonly request: QuestionRequest;
|
|
438
|
+
} | {
|
|
439
|
+
readonly _tag: "InputRequested";
|
|
440
|
+
readonly request: InputRequest;
|
|
368
441
|
} | {
|
|
369
442
|
readonly _tag: "Executing";
|
|
370
443
|
readonly call: ToolCall;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.mts","names":[],"sources":["../../src/client/state.ts"],"mappings":";;;;
|
|
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,SACR,WAAA;EAAA,SACA,SAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,I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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("InputReady", "ApprovalRequested", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", (current) => current.call.id), Match.exhaustive);
|
|
36
|
-
const isActiveToolRun = (run) => !Predicate.isTagged(run, "Accepted") && !Predicate.isTagged(run, "Completed") && !Predicate.isTagged(run, "Errored") && !Predicate.isTagged(run, "Denied") && !Predicate.isTagged(run, "QuestionAnswered") && !Predicate.isTagged(run, "QuestionCancelled") && !Predicate.isTagged(run, "ProviderCompleted");
|
|
35
|
+
const toolRunId = (run) => Match.value(run).pipe(Match.tag("InputStreaming", (current) => current.id), Match.tag("Denied", (current) => current.toolCallId), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.response.toolCallId), Match.tag("InputRequested", (current) => current.request.toolCallId), Match.tag("InputSubmitted", "InputCancelled", (current) => current.response.toolCallId), Match.tag("InputReady", "ApprovalRequested", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", (current) => current.call.id), Match.exhaustive);
|
|
36
|
+
const isActiveToolRun = (run) => !Predicate.isTagged(run, "Accepted") && !Predicate.isTagged(run, "Completed") && !Predicate.isTagged(run, "Errored") && !Predicate.isTagged(run, "Denied") && !Predicate.isTagged(run, "QuestionAnswered") && !Predicate.isTagged(run, "QuestionCancelled") && !Predicate.isTagged(run, "InputSubmitted") && !Predicate.isTagged(run, "InputCancelled") && !Predicate.isTagged(run, "ProviderCompleted");
|
|
37
37
|
const completedToolRuns = (runs) => runs.filter((run) => Predicate.isTagged(run, "Completed"));
|
|
38
38
|
const retainedSettledToolRuns = (runs) => runs.filter((run) => Predicate.isTagged(run, "Completed") || Predicate.isTagged(run, "Accepted"));
|
|
39
39
|
const toolRunsFromHitlRequests = (requests) => requests.map((request) => Match.value(request).pipe(Match.tag("QuestionRequest", (current) => AgentToolRun.QuestionRequested({ request: current })), Match.tag("ToolApprovalRequest", (current) => AgentToolRun.ApprovalRequested({
|
|
40
40
|
call: current.call,
|
|
41
41
|
request: current
|
|
42
|
-
})), Match.exhaustive));
|
|
42
|
+
})), Match.tag("InputRequest", (current) => AgentToolRun.InputRequested({ request: current })), Match.exhaustive));
|
|
43
43
|
const replaceToolRun = (runs, run) => {
|
|
44
44
|
const id = toolRunId(run);
|
|
45
45
|
const replaceIndex = runs.findIndex((current) => toolRunId(current) === id);
|
|
@@ -58,8 +58,20 @@ const appendToolInputDelta = (runs, id, delta) => runs.map((run) => Predicate.is
|
|
|
58
58
|
} : run);
|
|
59
59
|
const questionRequestForToolCall = (runs, toolCallId) => runs.flatMap((run) => {
|
|
60
60
|
if (toolRunId(run) !== toolCallId) return [];
|
|
61
|
-
return Match.value(run).pipe(Match.tag("QuestionRequested", (current) => [current.request]), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", () => []), Match.exhaustive);
|
|
61
|
+
return Match.value(run).pipe(Match.tag("QuestionRequested", (current) => [current.request]), Match.tag("QuestionAnswered", "QuestionCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "InputRequested", "InputSubmitted", "InputCancelled", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", () => []), Match.exhaustive);
|
|
62
62
|
})[0];
|
|
63
|
+
const inputRequestForToolCall = (runs, toolCallId) => runs.flatMap((run) => {
|
|
64
|
+
if (toolRunId(run) !== toolCallId) return [];
|
|
65
|
+
return Match.value(run).pipe(Match.tag("InputRequested", (current) => [current.request]), Match.tag("InputSubmitted", "InputCancelled", (current) => current.request === void 0 ? [] : [current.request]), Match.tag("InputStreaming", "InputReady", "ApprovalRequested", "Denied", "Executing", "Accepted", "Completed", "Errored", "ProviderCompleted", "QuestionRequested", "QuestionAnswered", "QuestionCancelled", () => []), Match.exhaustive);
|
|
66
|
+
})[0];
|
|
67
|
+
const inputSubmittedRun = (response, request) => request === void 0 ? AgentToolRun.InputSubmitted({ response }) : AgentToolRun.InputSubmitted({
|
|
68
|
+
response,
|
|
69
|
+
request
|
|
70
|
+
});
|
|
71
|
+
const inputCancelledRun = (response, request) => request === void 0 ? AgentToolRun.InputCancelled({ response }) : AgentToolRun.InputCancelled({
|
|
72
|
+
response,
|
|
73
|
+
request
|
|
74
|
+
});
|
|
63
75
|
const questionAnsweredRun = (response, request) => request === void 0 ? AgentToolRun.QuestionAnswered({ response }) : AgentToolRun.QuestionAnswered({
|
|
64
76
|
response,
|
|
65
77
|
request
|
|
@@ -85,7 +97,7 @@ const applyAgentEventWithOptions = (state, event, options = {}) => {
|
|
|
85
97
|
if (hasSeenEvent(state, event)) return state;
|
|
86
98
|
return rememberEvent(applyAgentEventUnchecked(state, event, nowMs), event);
|
|
87
99
|
};
|
|
88
|
-
const activeEventToolCallId = (event) => Match.value(event).pipe(Match.tag("ToolInputStart", "ToolInputDelta", (current) => current.id), Match.tag("ToolInputEnd", "ToolExecutionStarted", "ToolApprovalRequested", (current) => current.call.id), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.orElse(() => void 0));
|
|
100
|
+
const activeEventToolCallId = (event) => Match.value(event).pipe(Match.tag("ToolInputStart", "ToolInputDelta", (current) => current.id), Match.tag("ToolInputEnd", "ToolExecutionStarted", "ToolApprovalRequested", (current) => current.call.id), Match.tag("QuestionRequested", (current) => current.request.toolCallId), Match.tag("InputRequested", (current) => current.request.toolCallId), Match.orElse(() => void 0));
|
|
89
101
|
const applyAgentEventUnchecked = (state, event, nowMs) => {
|
|
90
102
|
const activeCallId = activeEventToolCallId(event);
|
|
91
103
|
const acknowledgesActiveCall = (message) => Predicate.isTagged(message, "ToolResult") && message.toolCallId === activeCallId && message.acceptance !== void 0;
|
|
@@ -137,12 +149,21 @@ const applyAgentEventUnchecked = (state, event, nowMs) => {
|
|
|
137
149
|
})), Match.tag("QuestionRequested", (current) => ({
|
|
138
150
|
...state,
|
|
139
151
|
toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.QuestionRequested({ request: current.request }))
|
|
152
|
+
})), Match.tag("InputRequested", (current) => ({
|
|
153
|
+
...state,
|
|
154
|
+
toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.InputRequested({ request: current.request }))
|
|
140
155
|
}))).pipe(Match.tag("QuestionAnswered", (current) => ({
|
|
141
156
|
...state,
|
|
142
157
|
toolRuns: replaceToolRun(state.toolRuns, questionAnsweredRun(current.response, questionRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
143
158
|
})), Match.tag("QuestionCancelled", (current) => ({
|
|
144
159
|
...state,
|
|
145
160
|
toolRuns: replaceToolRun(state.toolRuns, questionCancelledRun(current.response, questionRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
161
|
+
})), Match.tag("InputSubmitted", (current) => ({
|
|
162
|
+
...state,
|
|
163
|
+
toolRuns: replaceToolRun(state.toolRuns, inputSubmittedRun(current.response, inputRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
164
|
+
})), Match.tag("InputCancelled", (current) => ({
|
|
165
|
+
...state,
|
|
166
|
+
toolRuns: replaceToolRun(state.toolRuns, inputCancelledRun(current.response, inputRequestForToolCall(state.toolRuns, current.response.toolCallId)))
|
|
146
167
|
})), Match.tag("ToolExecutionStarted", (current) => ({
|
|
147
168
|
...state,
|
|
148
169
|
toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.Executing({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.mjs","names":["Schema"],"sources":["../../src/client/state.ts"],"sourcesContent":["import {\n type AgentError,\n type AgentEvent,\n type AgentMessage,\n type AgentRetry,\n type HitlRequest,\n type QuestionRequest,\n type QuestionResponse,\n type ToolCall,\n type ToolApprovalRequest,\n type ToolResult,\n type UserMessage\n} from '@yolk-sdk/agent/protocol'\nimport { Data, Match, Predicate } from 'effect'\nimport * as Schema from 'effect/Schema'\n\nexport type AgentRunStatus = 'idle' | 'running' | 'waiting' | 'done' | 'error' | 'aborted'\n\nexport type AgentToolRun =\n | {\n readonly _tag: 'InputStreaming'\n readonly id: string\n readonly name?: string\n readonly input: string\n }\n | { readonly _tag: 'InputReady'; readonly call: ToolCall }\n | {\n readonly _tag: 'ApprovalRequested'\n readonly call: ToolCall\n readonly request?: ToolApprovalRequest\n }\n | { readonly _tag: 'Denied'; readonly toolCallId: string; readonly reason: string }\n | { readonly _tag: 'QuestionRequested'; readonly request: QuestionRequest }\n | {\n readonly _tag: 'QuestionAnswered'\n readonly response: QuestionResponse\n readonly request?: QuestionRequest\n }\n | {\n readonly _tag: 'QuestionCancelled'\n readonly response: QuestionResponse\n readonly request?: QuestionRequest\n }\n | { readonly _tag: 'Executing'; readonly call: ToolCall; readonly startedAtMs: number }\n | {\n readonly _tag: 'Completed'\n readonly call: ToolCall\n readonly result: ToolResult\n readonly startedAtMs: number\n readonly endedAtMs: number\n }\n | {\n readonly _tag: 'Accepted'\n readonly call: ToolCall\n readonly result: ToolResult\n readonly startedAtMs: number\n readonly endedAtMs: number\n }\n | {\n readonly _tag: 'Errored'\n readonly call: ToolCall\n readonly message: string\n readonly endedAtMs: number\n }\n | { readonly _tag: 'ProviderCompleted'; readonly call: ToolCall; readonly result: ToolResult }\n\nexport const AgentToolRun = Data.taggedEnum<AgentToolRun>()\n\ntype StartedAgentToolRun = Extract<\n AgentToolRun,\n { readonly _tag: 'Executing' | 'Accepted' | 'Completed' }\n>\n\nexport type AgentClientState = {\n readonly status: AgentRunStatus\n readonly messages: ReadonlyArray<AgentMessage>\n readonly liveMessages: ReadonlyArray<AgentMessage>\n readonly text: string\n readonly reasoning: string\n readonly toolRuns: ReadonlyArray<AgentToolRun>\n readonly error: string | null\n readonly errorInfo: AgentError | null\n readonly retryInfo: AgentRetry | null\n readonly seenEventIds: ReadonlyArray<string>\n}\n\nexport type ApplyAgentEventOptions = {\n readonly nowMs?: number\n}\n\nconst AgentToolRunInputStreaming = Schema.TaggedStruct('InputStreaming', {\n id: Schema.String,\n name: Schema.UndefinedOr(Schema.String),\n input: Schema.String\n})\n\nconst AgentToolRunDenied = Schema.TaggedStruct('Denied', {\n toolCallId: Schema.String,\n reason: Schema.String\n})\n\nexport type AgentTranscript = readonly [AgentMessage, ...Array<AgentMessage>]\n\nexport const initialAgentClientState: AgentClientState = {\n status: 'idle',\n messages: [],\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: [],\n error: null,\n errorInfo: null,\n retryInfo: null,\n seenEventIds: []\n}\n\nconst clearRetryInfo = (state: AgentClientState): AgentClientState =>\n state.retryInfo === null ? state : { ...state, retryInfo: null }\n\nconst hasSeenEvent = (state: AgentClientState, event: AgentEvent) =>\n event.eventId !== undefined && state.seenEventIds.includes(event.eventId)\n\nconst rememberEvent = (state: AgentClientState, event: AgentEvent): AgentClientState =>\n event.eventId === undefined\n ? state\n : { ...state, seenEventIds: [...state.seenEventIds, event.eventId] }\n\nconst toolRunId = (run: AgentToolRun) =>\n Match.value(run).pipe(\n Match.tag('InputStreaming', current => current.id),\n Match.tag('Denied', current => current.toolCallId),\n Match.tag('QuestionRequested', current => current.request.toolCallId),\n Match.tag('QuestionAnswered', 'QuestionCancelled', current => current.response.toolCallId),\n Match.tag(\n 'InputReady',\n 'ApprovalRequested',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n current => current.call.id\n ),\n Match.exhaustive\n )\n\nexport const isActiveToolRun = (run: AgentToolRun) =>\n !Predicate.isTagged(run, 'Accepted') &&\n !Predicate.isTagged(run, 'Completed') &&\n !Predicate.isTagged(run, 'Errored') &&\n !Predicate.isTagged(run, 'Denied') &&\n !Predicate.isTagged(run, 'QuestionAnswered') &&\n !Predicate.isTagged(run, 'QuestionCancelled') &&\n !Predicate.isTagged(run, 'ProviderCompleted')\n\nexport const completedToolRuns = (runs: ReadonlyArray<AgentToolRun>) =>\n runs.filter(run => Predicate.isTagged(run, 'Completed'))\n\n// Retention is not completion: an acknowledgement remains replay-fenced between turns.\nconst retainedSettledToolRuns = (runs: ReadonlyArray<AgentToolRun>) =>\n runs.filter(run => Predicate.isTagged(run, 'Completed') || Predicate.isTagged(run, 'Accepted'))\n\nexport const toolRunsFromHitlRequests = (\n requests: ReadonlyArray<HitlRequest>\n): ReadonlyArray<AgentToolRun> =>\n requests.map(request =>\n Match.value(request).pipe(\n Match.tag('QuestionRequest', current => AgentToolRun.QuestionRequested({ request: current })),\n Match.tag('ToolApprovalRequest', current =>\n AgentToolRun.ApprovalRequested({\n call: current.call,\n request: current\n })\n ),\n Match.exhaustive\n )\n )\n\nconst replaceToolRun = (\n runs: ReadonlyArray<AgentToolRun>,\n run: AgentToolRun\n): ReadonlyArray<AgentToolRun> => {\n const id = toolRunId(run)\n const replaceIndex = runs.findIndex(current => toolRunId(current) === id)\n\n // Input/approval/Started replays without event ids cannot reopen an acknowledged call.\n if (runs[replaceIndex]?._tag === 'Accepted' && isActiveToolRun(run)) return runs\n\n if (replaceIndex === -1) {\n return [...runs, run]\n }\n\n return runs.flatMap((current, index) => {\n if (toolRunId(current) !== id) {\n return [current]\n }\n\n return index === replaceIndex ? [run] : []\n })\n}\n\nconst isStartedToolRun = (run: AgentToolRun): run is StartedAgentToolRun =>\n Predicate.isTagged(run, 'Executing') ||\n Predicate.isTagged(run, 'Accepted') ||\n Predicate.isTagged(run, 'Completed')\n\nconst startedAtMsFor = (runs: ReadonlyArray<AgentToolRun>, toolCallId: string) =>\n runs.filter(isStartedToolRun).find(run => run.call.id === toolCallId)?.startedAtMs\n\nconst appendToolInputDelta = (\n runs: ReadonlyArray<AgentToolRun>,\n id: string,\n delta: string\n): ReadonlyArray<AgentToolRun> =>\n runs.map(run =>\n Predicate.isTagged(run, 'InputStreaming') && run.id === id\n ? { ...run, input: `${run.input}${delta}` }\n : run\n )\n\nconst questionRequestForToolCall = (\n runs: ReadonlyArray<AgentToolRun>,\n toolCallId: string\n): QuestionRequest | undefined =>\n runs.flatMap(run => {\n if (toolRunId(run) !== toolCallId) {\n return []\n }\n\n return Match.value(run).pipe(\n Match.tag('QuestionRequested', current => [current.request]),\n Match.tag('QuestionAnswered', 'QuestionCancelled', current =>\n current.request === undefined ? [] : [current.request]\n ),\n Match.tag(\n 'InputStreaming',\n 'InputReady',\n 'ApprovalRequested',\n 'Denied',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n () => []\n ),\n Match.exhaustive\n )\n })[0]\n\nconst questionAnsweredRun = (\n response: QuestionResponse,\n request: QuestionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.QuestionAnswered({ response })\n : AgentToolRun.QuestionAnswered({ response, request })\n\nconst questionCancelledRun = (\n response: QuestionResponse,\n request: QuestionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.QuestionCancelled({ response })\n : AgentToolRun.QuestionCancelled({ response, request })\n\nexport const appendAgentMessage = (\n messages: ReadonlyArray<AgentMessage>,\n message: AgentMessage\n): AgentTranscript => {\n const first = messages[0]\n\n if (first === undefined) {\n return [message]\n }\n\n return [first, ...messages.slice(1), message]\n}\n\nexport const applyAgentEvent = (state: AgentClientState, event: AgentEvent): AgentClientState => {\n const nowMs = 0\n\n return applyAgentEventWithOptions(state, event, { nowMs })\n}\n\nexport const applyAgentEventWithOptions = (\n state: AgentClientState,\n event: AgentEvent,\n options: ApplyAgentEventOptions = {}\n): AgentClientState => {\n const nowMs = options.nowMs ?? 0\n\n if (hasSeenEvent(state, event)) {\n return state\n }\n\n return rememberEvent(applyAgentEventUnchecked(state, event, nowMs), event)\n}\n\nconst activeEventToolCallId = (event: AgentEvent): string | undefined =>\n Match.value(event).pipe(\n Match.tag('ToolInputStart', 'ToolInputDelta', current => current.id),\n Match.tag(\n 'ToolInputEnd',\n 'ToolExecutionStarted',\n 'ToolApprovalRequested',\n current => current.call.id\n ),\n Match.tag('QuestionRequested', current => current.request.toolCallId),\n Match.orElse(() => undefined)\n )\n\nconst applyAgentEventUnchecked = (\n state: AgentClientState,\n event: AgentEvent,\n nowMs: number\n): AgentClientState => {\n const activeCallId = activeEventToolCallId(event)\n\n const acknowledgesActiveCall = (message: AgentMessage) =>\n Predicate.isTagged(message, 'ToolResult') &&\n message.toolCallId === activeCallId &&\n message.acceptance !== undefined\n\n if (\n activeCallId !== undefined &&\n (state.messages.some(acknowledgesActiveCall) || state.liveMessages.some(acknowledgesActiveCall))\n ) {\n // Hydration need not restore transient runs; the transcript itself is a replay fence.\n return {\n ...state,\n toolRuns: state.toolRuns.filter(\n run => toolRunId(run) !== activeCallId || !isActiveToolRun(run)\n )\n }\n }\n\n return Match.value(event)\n .pipe(\n Match.withReturnType<AgentClientState>(),\n Match.tag('AgentStart', () => ({\n ...state,\n status: 'running',\n text: '',\n reasoning: '',\n liveMessages: [],\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null\n })),\n Match.tag('AgentError', current => markAgentError(state, current.message, current)),\n Match.tag('LLMTextDelta', current =>\n clearRetryInfo({ ...state, text: `${state.text}${current.text}` })\n ),\n Match.tag('LLMReasoningDelta', current =>\n clearRetryInfo({ ...state, reasoning: `${state.reasoning}${current.text}` })\n ),\n Match.tag('ToolInputStart', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRunInputStreaming.make({ id: current.id, name: current.name, input: '' })\n )\n })\n ),\n Match.tag('ToolInputDelta', current =>\n clearRetryInfo({\n ...state,\n toolRuns: appendToolInputDelta(state.toolRuns, current.id, current.delta)\n })\n ),\n Match.tag('ToolInputEnd', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.InputReady({ call: current.call }))\n })\n ),\n Match.tag('ToolApprovalRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.ApprovalRequested({\n call: current.call,\n request: current.request\n })\n )\n })),\n Match.tag('ToolApprovalGranted', () => state),\n Match.tag('ToolApprovalDenied', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRunDenied.make({ toolCallId: current.toolCallId, reason: current.reason })\n )\n })),\n Match.tag('QuestionRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.QuestionRequested({ request: current.request })\n )\n }))\n )\n .pipe(\n Match.tag('QuestionAnswered', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n questionAnsweredRun(\n current.response,\n questionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('QuestionCancelled', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n questionCancelledRun(\n current.response,\n questionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('ToolExecutionStarted', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.Executing({ call: current.call, startedAtMs: nowMs })\n )\n })),\n Match.tag('ToolExecutionAccepted', 'ToolExecutionCompleted', current => {\n const endedAtMs = nowMs\n const startedAtMs = startedAtMsFor(state.toolRuns, current.call.id) ?? endedAtMs\n\n return {\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n Predicate.isTagged(current, 'ToolExecutionAccepted')\n ? AgentToolRun.Accepted({\n call: current.call,\n result: current.result,\n startedAtMs,\n endedAtMs\n })\n : AgentToolRun.Completed({\n call: current.call,\n result: current.result,\n startedAtMs,\n endedAtMs\n })\n )\n }\n }),\n Match.tag('ToolExecutionError', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.Errored({\n call: current.call,\n message: current.message,\n endedAtMs: nowMs\n })\n )\n })),\n Match.tag('ProviderToolResult', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.ProviderCompleted({ call: current.call, result: current.result })\n )\n })\n ),\n Match.tag('UserMessage', 'AssistantMessage', current =>\n clearRetryInfo({\n ...state,\n liveMessages: [...state.liveMessages, current.message],\n text: '',\n reasoning: ''\n })\n ),\n Match.tag('AgentEnd', current => ({\n ...state,\n status: 'done',\n messages: [...state.messages, ...current.messages],\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n retryInfo: null\n })),\n Match.tag('AgentAwaitingInput', current => ({\n ...state,\n status: 'waiting',\n messages: [...state.messages, ...current.messages],\n liveMessages: [],\n text: '',\n reasoning: '',\n error: null,\n errorInfo: null,\n retryInfo: null\n })),\n Match.tag('AgentRetry', current => ({ ...state, retryInfo: current })),\n Match.tag(\n 'CompactionEnd',\n 'CompactionStart',\n 'LLMStreamEnd',\n 'LLMStreamStart',\n 'SubagentCompleted',\n 'SubagentStarted',\n 'TurnEnd',\n 'TurnStart',\n 'UsageUpdate',\n () => state\n ),\n Match.exhaustive\n )\n}\n\nexport const submitAgentUserMessage = (\n state: AgentClientState,\n message: UserMessage\n): AgentClientState => ({\n ...state,\n status: 'running',\n messages: appendAgentMessage(state.messages, message),\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null,\n seenEventIds: []\n})\n\nexport const markAgentError = (\n state: AgentClientState,\n message = 'Agent request failed',\n errorInfo: AgentError | null = null\n): AgentClientState => ({\n ...state,\n status: 'error',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: message,\n errorInfo,\n retryInfo: null\n})\n\nexport const markAgentAborted = (state: AgentClientState): AgentClientState => ({\n ...state,\n status: 'aborted',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null\n})\n\nexport const reduceAgentEvents = (\n events: ReadonlyArray<AgentEvent>,\n initialState: AgentClientState = initialAgentClientState,\n options: ApplyAgentEventOptions = {}\n) =>\n events.reduce((state, event) => applyAgentEventWithOptions(state, event, options), initialState)\n"],"mappings":";;;AAkEA,MAAa,eAAe,KAAK,WAAyB;AAwB1D,MAAM,6BAA6BA,SAAO,aAAa,kBAAkB;CACvE,IAAIA,SAAO;CACX,MAAMA,SAAO,YAAYA,SAAO,MAAM;CACtC,OAAOA,SAAO;AAChB,CAAC;AAED,MAAM,qBAAqBA,SAAO,aAAa,UAAU;CACvD,YAAYA,SAAO;CACnB,QAAQA,SAAO;AACjB,CAAC;AAID,MAAa,0BAA4C;CACvD,QAAQ;CACR,UAAU,CAAC;CACX,cAAc,CAAC;CACf,MAAM;CACN,WAAW;CACX,UAAU,CAAC;CACX,OAAO;CACP,WAAW;CACX,WAAW;CACX,cAAc,CAAC;AACjB;AAEA,MAAM,kBAAkB,UACtB,MAAM,cAAc,OAAO,QAAQ;CAAE,GAAG;CAAO,WAAW;AAAK;AAEjE,MAAM,gBAAgB,OAAyB,UAC7C,MAAM,YAAY,KAAA,KAAa,MAAM,aAAa,SAAS,MAAM,OAAO;AAE1E,MAAM,iBAAiB,OAAyB,UAC9C,MAAM,YAAY,KAAA,IACd,QACA;CAAE,GAAG;CAAO,cAAc,CAAC,GAAG,MAAM,cAAc,MAAM,OAAO;AAAE;AAEvE,MAAM,aAAa,QACjB,MAAM,MAAM,GAAG,EAAE,KACf,MAAM,IAAI,mBAAkB,YAAW,QAAQ,EAAE,GACjD,MAAM,IAAI,WAAU,YAAW,QAAQ,UAAU,GACjD,MAAM,IAAI,sBAAqB,YAAW,QAAQ,QAAQ,UAAU,GACpE,MAAM,IAAI,oBAAoB,sBAAqB,YAAW,QAAQ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AU,GAAG,QAAQ,QAAQ;EACjD,cAAc,CAAC;EACf,MAAM;EACN,WAAW;EACX,UAAU,wBAAwB,MAAM,QAAQ;EAChD,WAAW;CACb,EAAE,GACF,MAAM,IAAI,uBAAsB,aAAY;EAC1C,GAAG;EACH,QAAQ;EACR,UAAU,CAAC,GAAG,MAAM,UAAU,GAAG,QAAQ,QAAQ;EACjD,cAAc,CAAC;EACf,MAAM;EACN,WAAW;EACX,OAAO;EACP,WAAW;EACX,WAAW;CACb,EAAE,GACF,MAAM,IAAI,eAAc,aAAY;EAAE,GAAG;EAAO,WAAW;CAAQ,EAAE,GACrE,MAAM,IACJ,iBACA,mBACA,gBACA,kBACA,qBACA,mBACA,WACA,aACA,qBACM,KACR,GACA,MAAM,UACR;AACJ;AAEA,MAAa,0BACX,OACA,aACsB;CACtB,GAAG;CACH,QAAQ;CACR,UAAU,mBAAmB,MAAM,UAAU,OAAO;CACpD,cAAc,CAAC;CACf,MAAM;CACN,WAAW;CACX,UAAU,wBAAwB,MAAM,QAAQ;CAChD,OAAO;CACP,WAAW;CACX,WAAW;CACX,cAAc,CAAC;AACjB;AAEA,MAAa,kBACX,OACA,UAAU,wBACV,YAA+B,UACT;CACtB,GAAG;CACH,QAAQ;CACR,UAAU,wBAAwB,MAAM,QAAQ;CAChD,OAAO;CACP;CACA,WAAW;AACb;AAEA,MAAa,oBAAoB,WAA+C;CAC9E,GAAG;CACH,QAAQ;CACR,UAAU,wBAAwB,MAAM,QAAQ;CAChD,OAAO;CACP,WAAW;CACX,WAAW;AACb;AAEA,MAAa,qBACX,QACA,eAAiC,yBACjC,UAAkC,CAAC,MAEnC,OAAO,QAAQ,OAAO,UAAU,2BAA2B,OAAO,OAAO,OAAO,GAAG,YAAY"}
|
|
1
|
+
{"version":3,"file":"state.mjs","names":["Schema"],"sources":["../../src/client/state.ts"],"sourcesContent":["import {\n type AgentError,\n type AgentEvent,\n type AgentMessage,\n type AgentRetry,\n type HitlRequest,\n type InputRequest,\n type InputResponse,\n type QuestionRequest,\n type QuestionResponse,\n type ToolCall,\n type ToolApprovalRequest,\n type ToolResult,\n type UserMessage\n} from '@yolk-sdk/agent/protocol'\nimport { Data, Match, Predicate } from 'effect'\nimport * as Schema from 'effect/Schema'\n\nexport type AgentRunStatus = 'idle' | 'running' | 'waiting' | 'done' | 'error' | 'aborted'\n\nexport type AgentToolRun =\n | {\n readonly _tag: 'InputStreaming'\n readonly id: string\n readonly name?: string\n readonly input: string\n }\n | { readonly _tag: 'InputReady'; readonly call: ToolCall }\n | {\n readonly _tag: 'ApprovalRequested'\n readonly call: ToolCall\n readonly request?: ToolApprovalRequest\n }\n | { readonly _tag: 'Denied'; readonly toolCallId: string; readonly reason: string }\n | { readonly _tag: 'QuestionRequested'; readonly request: QuestionRequest }\n | {\n readonly _tag: 'QuestionAnswered'\n readonly response: QuestionResponse\n readonly request?: QuestionRequest\n }\n | {\n readonly _tag: 'QuestionCancelled'\n readonly response: QuestionResponse\n readonly request?: QuestionRequest\n }\n | { readonly _tag: 'InputRequested'; readonly request: InputRequest }\n | {\n readonly _tag: 'InputSubmitted'\n readonly response: InputResponse\n readonly request?: InputRequest\n }\n | {\n readonly _tag: 'InputCancelled'\n readonly response: InputResponse\n readonly request?: InputRequest\n }\n | { readonly _tag: 'Executing'; readonly call: ToolCall; readonly startedAtMs: number }\n | {\n readonly _tag: 'Completed'\n readonly call: ToolCall\n readonly result: ToolResult\n readonly startedAtMs: number\n readonly endedAtMs: number\n }\n | {\n readonly _tag: 'Accepted'\n readonly call: ToolCall\n readonly result: ToolResult\n readonly startedAtMs: number\n readonly endedAtMs: number\n }\n | {\n readonly _tag: 'Errored'\n readonly call: ToolCall\n readonly message: string\n readonly endedAtMs: number\n }\n | { readonly _tag: 'ProviderCompleted'; readonly call: ToolCall; readonly result: ToolResult }\n\nexport const AgentToolRun = Data.taggedEnum<AgentToolRun>()\n\ntype StartedAgentToolRun = Extract<\n AgentToolRun,\n { readonly _tag: 'Executing' | 'Accepted' | 'Completed' }\n>\n\nexport type AgentClientState = {\n readonly status: AgentRunStatus\n readonly messages: ReadonlyArray<AgentMessage>\n readonly liveMessages: ReadonlyArray<AgentMessage>\n readonly text: string\n readonly reasoning: string\n readonly toolRuns: ReadonlyArray<AgentToolRun>\n readonly error: string | null\n readonly errorInfo: AgentError | null\n readonly retryInfo: AgentRetry | null\n readonly seenEventIds: ReadonlyArray<string>\n}\n\nexport type ApplyAgentEventOptions = {\n readonly nowMs?: number\n}\n\nconst AgentToolRunInputStreaming = Schema.TaggedStruct('InputStreaming', {\n id: Schema.String,\n name: Schema.UndefinedOr(Schema.String),\n input: Schema.String\n})\n\nconst AgentToolRunDenied = Schema.TaggedStruct('Denied', {\n toolCallId: Schema.String,\n reason: Schema.String\n})\n\nexport type AgentTranscript = readonly [AgentMessage, ...Array<AgentMessage>]\n\nexport const initialAgentClientState: AgentClientState = {\n status: 'idle',\n messages: [],\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: [],\n error: null,\n errorInfo: null,\n retryInfo: null,\n seenEventIds: []\n}\n\nconst clearRetryInfo = (state: AgentClientState): AgentClientState =>\n state.retryInfo === null ? state : { ...state, retryInfo: null }\n\nconst hasSeenEvent = (state: AgentClientState, event: AgentEvent) =>\n event.eventId !== undefined && state.seenEventIds.includes(event.eventId)\n\nconst rememberEvent = (state: AgentClientState, event: AgentEvent): AgentClientState =>\n event.eventId === undefined\n ? state\n : { ...state, seenEventIds: [...state.seenEventIds, event.eventId] }\n\nconst toolRunId = (run: AgentToolRun) =>\n Match.value(run).pipe(\n Match.tag('InputStreaming', current => current.id),\n Match.tag('Denied', current => current.toolCallId),\n Match.tag('QuestionRequested', current => current.request.toolCallId),\n Match.tag('QuestionAnswered', 'QuestionCancelled', current => current.response.toolCallId),\n Match.tag('InputRequested', current => current.request.toolCallId),\n Match.tag('InputSubmitted', 'InputCancelled', current => current.response.toolCallId),\n Match.tag(\n 'InputReady',\n 'ApprovalRequested',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n current => current.call.id\n ),\n Match.exhaustive\n )\n\nexport const isActiveToolRun = (run: AgentToolRun) =>\n !Predicate.isTagged(run, 'Accepted') &&\n !Predicate.isTagged(run, 'Completed') &&\n !Predicate.isTagged(run, 'Errored') &&\n !Predicate.isTagged(run, 'Denied') &&\n !Predicate.isTagged(run, 'QuestionAnswered') &&\n !Predicate.isTagged(run, 'QuestionCancelled') &&\n !Predicate.isTagged(run, 'InputSubmitted') &&\n !Predicate.isTagged(run, 'InputCancelled') &&\n !Predicate.isTagged(run, 'ProviderCompleted')\n\nexport const completedToolRuns = (runs: ReadonlyArray<AgentToolRun>) =>\n runs.filter(run => Predicate.isTagged(run, 'Completed'))\n\n// Retention is not completion: an acknowledgement remains replay-fenced between turns.\nconst retainedSettledToolRuns = (runs: ReadonlyArray<AgentToolRun>) =>\n runs.filter(run => Predicate.isTagged(run, 'Completed') || Predicate.isTagged(run, 'Accepted'))\n\nexport const toolRunsFromHitlRequests = (\n requests: ReadonlyArray<HitlRequest>\n): ReadonlyArray<AgentToolRun> =>\n requests.map(request =>\n Match.value(request).pipe(\n Match.tag('QuestionRequest', current => AgentToolRun.QuestionRequested({ request: current })),\n Match.tag('ToolApprovalRequest', current =>\n AgentToolRun.ApprovalRequested({\n call: current.call,\n request: current\n })\n ),\n Match.tag('InputRequest', current => AgentToolRun.InputRequested({ request: current })),\n Match.exhaustive\n )\n )\n\nconst replaceToolRun = (\n runs: ReadonlyArray<AgentToolRun>,\n run: AgentToolRun\n): ReadonlyArray<AgentToolRun> => {\n const id = toolRunId(run)\n const replaceIndex = runs.findIndex(current => toolRunId(current) === id)\n\n // Input/approval/Started replays without event ids cannot reopen an acknowledged call.\n if (runs[replaceIndex]?._tag === 'Accepted' && isActiveToolRun(run)) return runs\n\n if (replaceIndex === -1) {\n return [...runs, run]\n }\n\n return runs.flatMap((current, index) => {\n if (toolRunId(current) !== id) {\n return [current]\n }\n\n return index === replaceIndex ? [run] : []\n })\n}\n\nconst isStartedToolRun = (run: AgentToolRun): run is StartedAgentToolRun =>\n Predicate.isTagged(run, 'Executing') ||\n Predicate.isTagged(run, 'Accepted') ||\n Predicate.isTagged(run, 'Completed')\n\nconst startedAtMsFor = (runs: ReadonlyArray<AgentToolRun>, toolCallId: string) =>\n runs.filter(isStartedToolRun).find(run => run.call.id === toolCallId)?.startedAtMs\n\nconst appendToolInputDelta = (\n runs: ReadonlyArray<AgentToolRun>,\n id: string,\n delta: string\n): ReadonlyArray<AgentToolRun> =>\n runs.map(run =>\n Predicate.isTagged(run, 'InputStreaming') && run.id === id\n ? { ...run, input: `${run.input}${delta}` }\n : run\n )\n\nconst questionRequestForToolCall = (\n runs: ReadonlyArray<AgentToolRun>,\n toolCallId: string\n): QuestionRequest | undefined =>\n runs.flatMap(run => {\n if (toolRunId(run) !== toolCallId) {\n return []\n }\n\n return Match.value(run).pipe(\n Match.tag('QuestionRequested', current => [current.request]),\n Match.tag('QuestionAnswered', 'QuestionCancelled', current =>\n current.request === undefined ? [] : [current.request]\n ),\n Match.tag(\n 'InputStreaming',\n 'InputReady',\n 'InputRequested',\n 'InputSubmitted',\n 'InputCancelled',\n 'ApprovalRequested',\n 'Denied',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n () => []\n ),\n Match.exhaustive\n )\n })[0]\n\nconst inputRequestForToolCall = (\n runs: ReadonlyArray<AgentToolRun>,\n toolCallId: string\n): InputRequest | undefined =>\n runs.flatMap(run => {\n if (toolRunId(run) !== toolCallId) {\n return []\n }\n\n return Match.value(run).pipe(\n Match.tag('InputRequested', current => [current.request]),\n Match.tag('InputSubmitted', 'InputCancelled', current =>\n current.request === undefined ? [] : [current.request]\n ),\n Match.tag(\n 'InputStreaming',\n 'InputReady',\n 'ApprovalRequested',\n 'Denied',\n 'Executing',\n 'Accepted',\n 'Completed',\n 'Errored',\n 'ProviderCompleted',\n 'QuestionRequested',\n 'QuestionAnswered',\n 'QuestionCancelled',\n () => []\n ),\n Match.exhaustive\n )\n })[0]\n\nconst inputSubmittedRun = (\n response: InputResponse,\n request: InputRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.InputSubmitted({ response })\n : AgentToolRun.InputSubmitted({ response, request })\n\nconst inputCancelledRun = (\n response: InputResponse,\n request: InputRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.InputCancelled({ response })\n : AgentToolRun.InputCancelled({ response, request })\n\nconst questionAnsweredRun = (\n response: QuestionResponse,\n request: QuestionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.QuestionAnswered({ response })\n : AgentToolRun.QuestionAnswered({ response, request })\n\nconst questionCancelledRun = (\n response: QuestionResponse,\n request: QuestionRequest | undefined\n): AgentToolRun =>\n request === undefined\n ? AgentToolRun.QuestionCancelled({ response })\n : AgentToolRun.QuestionCancelled({ response, request })\n\nexport const appendAgentMessage = (\n messages: ReadonlyArray<AgentMessage>,\n message: AgentMessage\n): AgentTranscript => {\n const first = messages[0]\n\n if (first === undefined) {\n return [message]\n }\n\n return [first, ...messages.slice(1), message]\n}\n\nexport const applyAgentEvent = (state: AgentClientState, event: AgentEvent): AgentClientState => {\n const nowMs = 0\n\n return applyAgentEventWithOptions(state, event, { nowMs })\n}\n\nexport const applyAgentEventWithOptions = (\n state: AgentClientState,\n event: AgentEvent,\n options: ApplyAgentEventOptions = {}\n): AgentClientState => {\n const nowMs = options.nowMs ?? 0\n\n if (hasSeenEvent(state, event)) {\n return state\n }\n\n return rememberEvent(applyAgentEventUnchecked(state, event, nowMs), event)\n}\n\nconst activeEventToolCallId = (event: AgentEvent): string | undefined =>\n Match.value(event).pipe(\n Match.tag('ToolInputStart', 'ToolInputDelta', current => current.id),\n Match.tag(\n 'ToolInputEnd',\n 'ToolExecutionStarted',\n 'ToolApprovalRequested',\n current => current.call.id\n ),\n Match.tag('QuestionRequested', current => current.request.toolCallId),\n Match.tag('InputRequested', current => current.request.toolCallId),\n Match.orElse(() => undefined)\n )\n\nconst applyAgentEventUnchecked = (\n state: AgentClientState,\n event: AgentEvent,\n nowMs: number\n): AgentClientState => {\n const activeCallId = activeEventToolCallId(event)\n\n const acknowledgesActiveCall = (message: AgentMessage) =>\n Predicate.isTagged(message, 'ToolResult') &&\n message.toolCallId === activeCallId &&\n message.acceptance !== undefined\n\n if (\n activeCallId !== undefined &&\n (state.messages.some(acknowledgesActiveCall) || state.liveMessages.some(acknowledgesActiveCall))\n ) {\n // Hydration need not restore transient runs; the transcript itself is a replay fence.\n return {\n ...state,\n toolRuns: state.toolRuns.filter(\n run => toolRunId(run) !== activeCallId || !isActiveToolRun(run)\n )\n }\n }\n\n return Match.value(event)\n .pipe(\n Match.withReturnType<AgentClientState>(),\n Match.tag('AgentStart', () => ({\n ...state,\n status: 'running',\n text: '',\n reasoning: '',\n liveMessages: [],\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null\n })),\n Match.tag('AgentError', current => markAgentError(state, current.message, current)),\n Match.tag('LLMTextDelta', current =>\n clearRetryInfo({ ...state, text: `${state.text}${current.text}` })\n ),\n Match.tag('LLMReasoningDelta', current =>\n clearRetryInfo({ ...state, reasoning: `${state.reasoning}${current.text}` })\n ),\n Match.tag('ToolInputStart', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRunInputStreaming.make({ id: current.id, name: current.name, input: '' })\n )\n })\n ),\n Match.tag('ToolInputDelta', current =>\n clearRetryInfo({\n ...state,\n toolRuns: appendToolInputDelta(state.toolRuns, current.id, current.delta)\n })\n ),\n Match.tag('ToolInputEnd', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(state.toolRuns, AgentToolRun.InputReady({ call: current.call }))\n })\n ),\n Match.tag('ToolApprovalRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.ApprovalRequested({\n call: current.call,\n request: current.request\n })\n )\n })),\n Match.tag('ToolApprovalGranted', () => state),\n Match.tag('ToolApprovalDenied', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRunDenied.make({ toolCallId: current.toolCallId, reason: current.reason })\n )\n })),\n Match.tag('QuestionRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.QuestionRequested({ request: current.request })\n )\n })),\n Match.tag('InputRequested', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.InputRequested({ request: current.request })\n )\n }))\n )\n .pipe(\n Match.tag('QuestionAnswered', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n questionAnsweredRun(\n current.response,\n questionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('QuestionCancelled', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n questionCancelledRun(\n current.response,\n questionRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('InputSubmitted', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n inputSubmittedRun(\n current.response,\n inputRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('InputCancelled', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n inputCancelledRun(\n current.response,\n inputRequestForToolCall(state.toolRuns, current.response.toolCallId)\n )\n )\n })),\n Match.tag('ToolExecutionStarted', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.Executing({ call: current.call, startedAtMs: nowMs })\n )\n })),\n Match.tag('ToolExecutionAccepted', 'ToolExecutionCompleted', current => {\n const endedAtMs = nowMs\n const startedAtMs = startedAtMsFor(state.toolRuns, current.call.id) ?? endedAtMs\n\n return {\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n Predicate.isTagged(current, 'ToolExecutionAccepted')\n ? AgentToolRun.Accepted({\n call: current.call,\n result: current.result,\n startedAtMs,\n endedAtMs\n })\n : AgentToolRun.Completed({\n call: current.call,\n result: current.result,\n startedAtMs,\n endedAtMs\n })\n )\n }\n }),\n Match.tag('ToolExecutionError', current => ({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.Errored({\n call: current.call,\n message: current.message,\n endedAtMs: nowMs\n })\n )\n })),\n Match.tag('ProviderToolResult', current =>\n clearRetryInfo({\n ...state,\n toolRuns: replaceToolRun(\n state.toolRuns,\n AgentToolRun.ProviderCompleted({ call: current.call, result: current.result })\n )\n })\n ),\n Match.tag('UserMessage', 'AssistantMessage', current =>\n clearRetryInfo({\n ...state,\n liveMessages: [...state.liveMessages, current.message],\n text: '',\n reasoning: ''\n })\n ),\n Match.tag('AgentEnd', current => ({\n ...state,\n status: 'done',\n messages: [...state.messages, ...current.messages],\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n retryInfo: null\n })),\n Match.tag('AgentAwaitingInput', current => ({\n ...state,\n status: 'waiting',\n messages: [...state.messages, ...current.messages],\n liveMessages: [],\n text: '',\n reasoning: '',\n error: null,\n errorInfo: null,\n retryInfo: null\n })),\n Match.tag('AgentRetry', current => ({ ...state, retryInfo: current })),\n Match.tag(\n 'CompactionEnd',\n 'CompactionStart',\n 'LLMStreamEnd',\n 'LLMStreamStart',\n 'SubagentCompleted',\n 'SubagentStarted',\n 'TurnEnd',\n 'TurnStart',\n 'UsageUpdate',\n () => state\n ),\n Match.exhaustive\n )\n}\n\nexport const submitAgentUserMessage = (\n state: AgentClientState,\n message: UserMessage\n): AgentClientState => ({\n ...state,\n status: 'running',\n messages: appendAgentMessage(state.messages, message),\n liveMessages: [],\n text: '',\n reasoning: '',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null,\n seenEventIds: []\n})\n\nexport const markAgentError = (\n state: AgentClientState,\n message = 'Agent request failed',\n errorInfo: AgentError | null = null\n): AgentClientState => ({\n ...state,\n status: 'error',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: message,\n errorInfo,\n retryInfo: null\n})\n\nexport const markAgentAborted = (state: AgentClientState): AgentClientState => ({\n ...state,\n status: 'aborted',\n toolRuns: retainedSettledToolRuns(state.toolRuns),\n error: null,\n errorInfo: null,\n retryInfo: null\n})\n\nexport const reduceAgentEvents = (\n events: ReadonlyArray<AgentEvent>,\n initialState: AgentClientState = initialAgentClientState,\n options: ApplyAgentEventOptions = {}\n) =>\n events.reduce((state, event) => applyAgentEventWithOptions(state, event, options), initialState)\n"],"mappings":";;;AA+EA,MAAa,eAAe,KAAK,WAAyB;AAwB1D,MAAM,6BAA6BA,SAAO,aAAa,kBAAkB;CACvE,IAAIA,SAAO;CACX,MAAMA,SAAO,YAAYA,SAAO,MAAM;CACtC,OAAOA,SAAO;AAChB,CAAC;AAED,MAAM,qBAAqBA,SAAO,aAAa,UAAU;CACvD,YAAYA,SAAO;CACnB,QAAQA,SAAO;AACjB,CAAC;AAID,MAAa,0BAA4C;CACvD,QAAQ;CACR,UAAU,CAAC;CACX,cAAc,CAAC;CACf,MAAM;CACN,WAAW;CACX,UAAU,CAAC;CACX,OAAO;CACP,WAAW;CACX,WAAW;CACX,cAAc,CAAC;AACjB;AAEA,MAAM,kBAAkB,UACtB,MAAM,cAAc,OAAO,QAAQ;CAAE,GAAG;CAAO,WAAW;AAAK;AAEjE,MAAM,gBAAgB,OAAyB,UAC7C,MAAM,YAAY,KAAA,KAAa,MAAM,aAAa,SAAS,MAAM,OAAO;AAE1E,MAAM,iBAAiB,OAAyB,UAC9C,MAAM,YAAY,KAAA,IACd,QACA;CAAE,GAAG;CAAO,cAAc,CAAC,GAAG,MAAM,cAAc,MAAM,OAAO;AAAE;AAEvE,MAAM,aAAa,QACjB,MAAM,MAAM,GAAG,EAAE,KACf,MAAM,IAAI,mBAAkB,YAAW,QAAQ,EAAE,GACjD,MAAM,IAAI,WAAU,YAAW,QAAQ,UAAU,GACjD,MAAM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