agents 0.14.0 → 0.14.2
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/dist/{agent-tool-types-LInzZfLo.d.ts → agent-tool-types-V25Z_HcX.d.ts} +275 -122
- package/dist/agent-tool-types.d.ts +13 -11
- package/dist/{agent-tools-BAdX1vdI.js → agent-tools-3zLG7MgA.js} +49 -7
- package/dist/agent-tools-3zLG7MgA.js.map +1 -0
- package/dist/{agent-tools-BE9xosUG.d.ts → agent-tools-C-9s151X.d.ts} +2 -2
- package/dist/agent-tools.d.ts +13 -11
- package/dist/agent-tools.js +8 -3
- package/dist/agent-tools.js.map +1 -1
- package/dist/browser/ai.d.ts +1 -1
- package/dist/browser/ai.js +1 -1
- package/dist/browser/ai.js.map +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/tanstack-ai.d.ts +1 -1
- package/dist/browser/tanstack-ai.js +1 -1
- package/dist/browser/tanstack-ai.js.map +1 -1
- package/dist/chat/index.d.ts +115 -8
- package/dist/chat/index.js +10 -6
- package/dist/chat/index.js.map +1 -1
- package/dist/chat-sdk/index.d.ts +5 -5
- package/dist/chat-sdk/index.js +2 -2
- package/dist/chat-sdk/index.js.map +1 -1
- package/dist/{classPrivateFieldGet2-Evpt0SEr.js → classPrivateFieldGet2-Beqsfu2Z.js} +5 -5
- package/dist/{classPrivateMethodInitSpec-bG0tD96O.js → classPrivateMethodInitSpec-B5ko1s2R.js} +2 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-NradHZZz.js → client-FUizKzj2.js} +94 -21
- package/dist/client-FUizKzj2.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/{compaction-helpers-DpP_XP9J.d.ts → compaction-helpers-BEUILPss.d.ts} +1 -1
- package/dist/{compaction-helpers-BjT2NKRZ.js → compaction-helpers-iiKMr2TQ.js} +1 -1
- package/dist/{compaction-helpers-BjT2NKRZ.js.map → compaction-helpers-iiKMr2TQ.js.map} +1 -1
- package/dist/{do-oauth-client-provider-CPm9rK5I.d.ts → do-oauth-client-provider-D4ZwyBDu.d.ts} +21 -1
- package/dist/{email-1fTSJwPm.d.ts → email-CL27preh.d.ts} +1 -1
- package/dist/email.d.ts +2 -2
- package/dist/email.js.map +1 -1
- package/dist/experimental/memory/session/index.d.ts +1 -1
- package/dist/experimental/memory/session/index.js +1 -1
- package/dist/experimental/memory/session/index.js.map +1 -1
- package/dist/experimental/memory/utils/index.d.ts +1 -1
- package/dist/experimental/memory/utils/index.js +2 -2
- package/dist/experimental/webmcp.js.map +1 -1
- package/dist/{index-Brdu5nMI.d.ts → index-CPe1OtI0.d.ts} +17 -1
- package/dist/index.d.ts +71 -69
- package/dist/index.js +288 -84
- package/dist/index.js.map +1 -1
- package/dist/{internal_context-CcZy2Em7.d.ts → internal_context-Dg4Cgjcu.d.ts} +1 -1
- package/dist/internal_context.d.ts +1 -1
- package/dist/mcp/client.d.ts +14 -14
- package/dist/mcp/client.js +1 -1
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/do-oauth-client-provider.js +143 -17
- package/dist/mcp/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/index.d.ts +30 -30
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/x402.js.map +1 -1
- package/dist/observability/index.d.ts +1 -1
- package/dist/observability/index.js.map +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/{retries-ClWwxADl.d.ts → retries-CF_HKSlJ.d.ts} +1 -1
- package/dist/retries.d.ts +1 -1
- package/dist/schedule.js.map +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/{shared-CpY1FLvm.d.ts → shared-4CAYLCTO.d.ts} +1 -1
- package/dist/{shared-DdOn6sp4.js → shared-wyII629d.js} +3 -3
- package/dist/{shared-DdOn6sp4.js.map → shared-wyII629d.js.map} +1 -1
- package/dist/skills/index.js +4 -4
- package/dist/skills/index.js.map +1 -1
- package/dist/sub-routing.d.ts +6 -6
- package/dist/sub-routing.js.map +1 -1
- package/dist/{tool-output-truncation-BF4AZQlw.js → tool-output-truncation-CNnnGZQ3.js} +1 -1
- package/dist/{tool-output-truncation-BF4AZQlw.js.map → tool-output-truncation-CNnnGZQ3.js.map} +1 -1
- package/dist/{types-B0GymtN_.d.ts → types-6Zo2zfoO.d.ts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.js.map +1 -1
- package/dist/vite.d.ts +15 -4
- package/dist/vite.js +37 -7
- package/dist/vite.js.map +1 -1
- package/dist/{workflow-types-DPkuBi--.d.ts → workflow-types-SrZK_o9p.d.ts} +1 -1
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +11 -3
- package/dist/workflows.js +48 -22
- package/dist/workflows.js.map +1 -1
- package/package.json +14 -23
- package/dist/agent-tools-BAdX1vdI.js.map +0 -1
- package/dist/client-NradHZZz.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { n as AgentEmail } from "./internal_context-
|
|
2
|
-
import { t as RetryOptions } from "./retries-
|
|
1
|
+
import { n as AgentEmail } from "./internal_context-Dg4Cgjcu.js";
|
|
2
|
+
import { t as RetryOptions } from "./retries-CF_HKSlJ.js";
|
|
3
3
|
import {
|
|
4
4
|
n as Observability,
|
|
5
5
|
r as ObservabilityEvent,
|
|
6
6
|
s as MCPObservabilityEvent
|
|
7
|
-
} from "./index-
|
|
8
|
-
import { t as AgentMcpOAuthProvider } from "./do-oauth-client-provider-
|
|
7
|
+
} from "./index-CPe1OtI0.js";
|
|
8
|
+
import { t as AgentMcpOAuthProvider } from "./do-oauth-client-provider-D4ZwyBDu.js";
|
|
9
9
|
import {
|
|
10
10
|
_ as WorkflowPage,
|
|
11
11
|
g as WorkflowInfo,
|
|
@@ -13,9 +13,9 @@ import {
|
|
|
13
13
|
l as WorkflowCallback,
|
|
14
14
|
s as RunWorkflowOptions,
|
|
15
15
|
y as WorkflowQueryCriteria
|
|
16
|
-
} from "./workflow-types-
|
|
17
|
-
import { t as MessageType } from "./types-
|
|
18
|
-
import { r as EmailResolver } from "./email-
|
|
16
|
+
} from "./workflow-types-SrZK_o9p.js";
|
|
17
|
+
import { t as MessageType } from "./types-6Zo2zfoO.js";
|
|
18
|
+
import { r as EmailResolver } from "./email-CL27preh.js";
|
|
19
19
|
import { ToolSet, UIMessage } from "ai";
|
|
20
20
|
import { RpcTarget } from "cloudflare:workers";
|
|
21
21
|
import {
|
|
@@ -838,7 +838,12 @@ declare class MCPClientConnection {
|
|
|
838
838
|
/**
|
|
839
839
|
* Complete OAuth authorization
|
|
840
840
|
*/
|
|
841
|
-
completeAuthorization(
|
|
841
|
+
completeAuthorization(
|
|
842
|
+
code: string,
|
|
843
|
+
options?: {
|
|
844
|
+
alreadyAccepted?: boolean;
|
|
845
|
+
}
|
|
846
|
+
): Promise<void>;
|
|
842
847
|
/**
|
|
843
848
|
* Discover server capabilities and register tools, resources, prompts, and templates.
|
|
844
849
|
* This method does the work but does not manage connection state - that's handled by discover().
|
|
@@ -1248,6 +1253,11 @@ declare class MCPClientManager {
|
|
|
1248
1253
|
private clearServerAuthUrl;
|
|
1249
1254
|
private updateStoredSessionId;
|
|
1250
1255
|
private failConnection;
|
|
1256
|
+
private isAuthAcceptedConnection;
|
|
1257
|
+
private oauthCallbackSuccess;
|
|
1258
|
+
private runWithCodeVerifierState;
|
|
1259
|
+
private consumeStaleOAuthState;
|
|
1260
|
+
private completeAuthorizationAndCleanupVerifier;
|
|
1251
1261
|
/**
|
|
1252
1262
|
* Create an auth provider for a server
|
|
1253
1263
|
* @internal
|
|
@@ -2267,6 +2277,26 @@ declare const DEFAULT_AGENT_STATIC_OPTIONS: {
|
|
|
2267
2277
|
* throwing so a poison row cannot re-trigger forever across boots.
|
|
2268
2278
|
*/
|
|
2269
2279
|
fiberRecoveryMaxAgeMs: number;
|
|
2280
|
+
/**
|
|
2281
|
+
* No-progress budget (ms) for re-attaching to a still-running agent-tool
|
|
2282
|
+
* child after a deploy / parent recovery (#1630). Bounds how long the parent
|
|
2283
|
+
* waits with NO forward progress from the child; it resets on every forwarded
|
|
2284
|
+
* chunk, so a child that keeps streaming is never abandoned mid-flight. Only a
|
|
2285
|
+
* genuinely silent/hung child seals `interrupted` after a full window. Raise
|
|
2286
|
+
* for children with long quiet stretches between outputs.
|
|
2287
|
+
*/
|
|
2288
|
+
agentToolReattachNoProgressTimeoutMs: number;
|
|
2289
|
+
/**
|
|
2290
|
+
* Optional hard wall-clock ceiling (ms) on a single agent-tool re-attach
|
|
2291
|
+
* (#1630). Caps the total wait even as the no-progress budget re-arms across
|
|
2292
|
+
* stream-closes. Defaults to `Infinity` (no implicit cap), mirroring
|
|
2293
|
+
* chat-recovery's `maxRecoveryWork` (#1672): a healthy, still-advancing child
|
|
2294
|
+
* is followed for as long as it makes progress — a hung child is bounded by
|
|
2295
|
+
* the no-progress budget, and a content-runaway by the child's own
|
|
2296
|
+
* `maxRecoveryWork` / `shouldKeepRecovering`. Set a finite value to impose a
|
|
2297
|
+
* wall-clock cap (which also tears the child down on `window-exceeded`).
|
|
2298
|
+
*/
|
|
2299
|
+
agentToolReattachMaxWindowMs: number;
|
|
2270
2300
|
};
|
|
2271
2301
|
/**
|
|
2272
2302
|
* Configuration options for the Agent.
|
|
@@ -2299,6 +2329,29 @@ interface AgentStaticOptions {
|
|
|
2299
2329
|
* and discards the row. Set to `0` to retain rows indefinitely.
|
|
2300
2330
|
*/
|
|
2301
2331
|
fiberRecoveryMaxAgeMs?: number;
|
|
2332
|
+
/**
|
|
2333
|
+
* No-progress budget in milliseconds for re-attaching to a still-running
|
|
2334
|
+
* agent-tool child after a deploy / parent recovery (#1630). Resets on every
|
|
2335
|
+
* forwarded chunk, so a steadily-streaming child is never abandoned; only a
|
|
2336
|
+
* genuinely silent child seals `interrupted` after a full window.
|
|
2337
|
+
* Default: 120000 (2 minutes). Set to `0` to skip waiting (collect only an
|
|
2338
|
+
* already-terminal child). Set to `Infinity` to never seal on no-progress —
|
|
2339
|
+
* a silent-but-alive child is then followed until its stream closes (or the
|
|
2340
|
+
* `agentToolReattachMaxWindowMs` ceiling fires), mirroring that knob's
|
|
2341
|
+
* "Infinity = off" convention.
|
|
2342
|
+
*/
|
|
2343
|
+
agentToolReattachNoProgressTimeoutMs?: number;
|
|
2344
|
+
/**
|
|
2345
|
+
* Optional hard wall-clock ceiling in milliseconds on a single agent-tool
|
|
2346
|
+
* re-attach (#1630). Caps the total wait even as the no-progress budget
|
|
2347
|
+
* re-arms across stream-closes. Default: `Infinity` (no implicit cap),
|
|
2348
|
+
* mirroring chat-recovery's `maxRecoveryWork` (#1672) — a healthy,
|
|
2349
|
+
* still-advancing child is followed for as long as it makes progress, exactly
|
|
2350
|
+
* as on the live (never-evicted) path. Set a finite value to impose a
|
|
2351
|
+
* wall-clock cap (which also tears the child down on `window-exceeded`); `0`
|
|
2352
|
+
* also disables the ceiling.
|
|
2353
|
+
*/
|
|
2354
|
+
agentToolReattachMaxWindowMs?: number;
|
|
2302
2355
|
}
|
|
2303
2356
|
declare function getCurrentAgent<
|
|
2304
2357
|
T extends Agent<Cloudflare.Env> = Agent<Cloudflare.Env>
|
|
@@ -2349,13 +2402,6 @@ declare class Agent<
|
|
|
2349
2402
|
private _persistenceHookMode;
|
|
2350
2403
|
/** True when this agent runs as a facet (sub-agent) inside a parent. */
|
|
2351
2404
|
private _isFacet;
|
|
2352
|
-
/**
|
|
2353
|
-
* True only while the internal facet bootstrap RPC runs startup.
|
|
2354
|
-
* Startup may happen while the parent is handling a WebSocket
|
|
2355
|
-
* message, so protocol broadcasts must not touch any ambient
|
|
2356
|
-
* parent-owned WebSocket handles during this window.
|
|
2357
|
-
*/
|
|
2358
|
-
private _suppressProtocolBroadcasts;
|
|
2359
2405
|
private _protocolBroadcastExcludeIds;
|
|
2360
2406
|
private _cf_currentSubAgentBridge?;
|
|
2361
2407
|
private _cf_virtualSubAgentConnections;
|
|
@@ -2377,6 +2423,8 @@ declare class Agent<
|
|
|
2377
2423
|
private _insideOnStart;
|
|
2378
2424
|
/** Tracks callbacks already warned about during this onStart() to avoid log spam. */
|
|
2379
2425
|
private _warnedScheduleInOnStart;
|
|
2426
|
+
/** Warn-once guard: `chatRecovery` reassigned during onStart() (too late for wake recovery). */
|
|
2427
|
+
private _warnedChatRecoveryInOnStart;
|
|
2380
2428
|
/**
|
|
2381
2429
|
* Number of active keepAlive() callers. When > 0, `_scheduleNextAlarm()`
|
|
2382
2430
|
* caps the next alarm at `keepAliveIntervalMs` so the DO stays alive.
|
|
@@ -3591,6 +3639,14 @@ declare class Agent<
|
|
|
3591
3639
|
private _activeAgentToolRunCount;
|
|
3592
3640
|
private _defaultAgentToolPreview;
|
|
3593
3641
|
private _readAgentToolRun;
|
|
3642
|
+
/**
|
|
3643
|
+
* Reconstruct the typed interrupted cause (`reason` / `childStillRunning`,
|
|
3644
|
+
* #1630 follow-up) from a stored row so a row→result/event rebuild — e.g. a
|
|
3645
|
+
* reconnect replay — carries the same fields a live client saw. Only
|
|
3646
|
+
* `interrupted` rows store a cause; everything else yields `{}` (the columns
|
|
3647
|
+
* are cleared whenever a row settles to a hard terminal).
|
|
3648
|
+
*/
|
|
3649
|
+
private _agentToolInterruptedExtrasFromRow;
|
|
3594
3650
|
private _resultFromAgentToolRow;
|
|
3595
3651
|
private _agentToolRunInfoFromRow;
|
|
3596
3652
|
private _terminalResultFromInspection;
|
|
@@ -3630,6 +3686,27 @@ declare class Agent<
|
|
|
3630
3686
|
private _asAgentToolChildAdapter;
|
|
3631
3687
|
private _agentToolClassByName;
|
|
3632
3688
|
private _replayAndInterruptAgentToolRun;
|
|
3689
|
+
/**
|
|
3690
|
+
* Human-readable prose for an `interrupted` seal. Kept in sync with
|
|
3691
|
+
* {@link AgentToolInterruptedReason}; callers branch on the typed `reason`
|
|
3692
|
+
* field, not this string.
|
|
3693
|
+
*/
|
|
3694
|
+
private _interruptedMessageForReason;
|
|
3695
|
+
/**
|
|
3696
|
+
* Tear down a child agent-tool run the parent has genuinely given up on
|
|
3697
|
+
* (#1630 follow-up). Teardown is scoped to `window-exceeded` ONLY — the hard
|
|
3698
|
+
* ceiling, where the child has had its full recovery window and is therefore
|
|
3699
|
+
* truly exhausted, so cancelling it reclaims its fiber / keep-alive. Every
|
|
3700
|
+
* other give-up is deliberately left repairable: `no-progress` seals stay
|
|
3701
|
+
* SOFT (`interrupted`, `childStillRunning: true`) so a re-issue can still
|
|
3702
|
+
* re-attach and collect the child if it self-heals — tearing those down would
|
|
3703
|
+
* defeat the repair-on-re-issue path and convert a retryable interrupt into a
|
|
3704
|
+
* non-retryable `aborted`. Reasons where the child's state is unknown
|
|
3705
|
+
* (`inspect-*`, `recovery-deadline`, `not-tailable`) are also left alone.
|
|
3706
|
+
* Returns whether the child was torn down (so the caller reports
|
|
3707
|
+
* `childStillRunning: false`).
|
|
3708
|
+
*/
|
|
3709
|
+
private _teardownGivenUpAgentToolChild;
|
|
3633
3710
|
/**
|
|
3634
3711
|
* Re-attach to a still-running child agent-tool run and tail it to its real
|
|
3635
3712
|
* terminal result, instead of abandoning it as `interrupted` (#1630). The
|
|
@@ -3638,15 +3715,26 @@ declare class Agent<
|
|
|
3638
3715
|
* its live stream (forwarding chunks to the parent's connections) until it
|
|
3639
3716
|
* reaches terminal, then inspect for the collected result.
|
|
3640
3717
|
*
|
|
3641
|
-
*
|
|
3642
|
-
* advancing
|
|
3643
|
-
*
|
|
3644
|
-
*
|
|
3718
|
+
* The wait is PROGRESS-KEYED, not a flat wall clock (which previously abandoned
|
|
3719
|
+
* healthy, still-advancing children whose recovery simply outran a fixed
|
|
3720
|
+
* budget). `noProgressTimeoutMs` bounds how long the parent waits with NO
|
|
3721
|
+
* forward progress; it is reset on every forwarded chunk. As long as the child
|
|
3722
|
+
* keeps streaming it is followed through to terminal. The loop also RE-ARMS
|
|
3723
|
+
* across stream-closes (a child re-evicted mid-recovery, or a tail that ends
|
|
3724
|
+
* before terminal) as long as the prior attempt made progress, so a child that
|
|
3725
|
+
* dies and recovers again during deploy churn is still collected. A genuinely
|
|
3726
|
+
* silent/hung child can never block recovery forever: it seals `interrupted`
|
|
3727
|
+
* after one `noProgressTimeoutMs` window. `maxWindowMs` is an OPTIONAL hard
|
|
3728
|
+
* wall-clock ceiling (default `Infinity` — uncapped, mirroring #1672's
|
|
3729
|
+
* `maxRecoveryWork`); set it finite to also bound a child that keeps
|
|
3730
|
+
* progressing, which seals `window-exceeded` and tears the child down.
|
|
3645
3731
|
*
|
|
3646
3732
|
* Returns the terminal `result` (and `completedAt`) when the child reaches a
|
|
3647
|
-
* terminal status
|
|
3648
|
-
*
|
|
3649
|
-
*
|
|
3733
|
+
* terminal status, plus the advanced broadcast `sequence`. Returns
|
|
3734
|
+
* `{ result: undefined }` when there is no `tailAgentToolRun` adapter, the
|
|
3735
|
+
* child makes no progress within a full no-progress window, or the ceiling is
|
|
3736
|
+
* reached while the child is still non-terminal — the caller then seals
|
|
3737
|
+
* `interrupted`.
|
|
3650
3738
|
*/
|
|
3651
3739
|
private _reattachAgentToolRunToTerminal;
|
|
3652
3740
|
private _replayAgentToolRuns;
|
|
@@ -4358,6 +4446,30 @@ type AgentToolTerminalStatus = Extract<
|
|
|
4358
4446
|
AgentToolRunStatus,
|
|
4359
4447
|
"completed" | "error" | "aborted" | "interrupted"
|
|
4360
4448
|
>;
|
|
4449
|
+
/**
|
|
4450
|
+
* Machine-readable cause of an `interrupted` seal (#1630 follow-up). Lets a
|
|
4451
|
+
* caller branch on WHY a run was abandoned without parsing the human-readable
|
|
4452
|
+
* `error` prose, which is not a stable contract.
|
|
4453
|
+
*
|
|
4454
|
+
* - `no-progress` — the child went silent for a full no-progress window while
|
|
4455
|
+
* the parent was tailing it (genuinely stalled / hung).
|
|
4456
|
+
* - `window-exceeded` — a finite `agentToolReattachMaxWindowMs` ceiling elapsed
|
|
4457
|
+
* while the child was still non-terminal. Only fires when an integrator opts
|
|
4458
|
+
* into a hard wall-clock cap (the default ceiling is `Infinity`).
|
|
4459
|
+
* - `not-tailable` — the child runtime cannot live-tail, so the parent could
|
|
4460
|
+
* not re-attach to its stream to follow it to terminal.
|
|
4461
|
+
* - `inspect-timeout` — inspecting the child timed out during parent recovery.
|
|
4462
|
+
* - `inspect-failed` — inspecting the child failed during parent recovery.
|
|
4463
|
+
* - `recovery-deadline` — the overall parent-recovery deadline elapsed before
|
|
4464
|
+
* this run could be reconciled.
|
|
4465
|
+
*/
|
|
4466
|
+
type AgentToolInterruptedReason =
|
|
4467
|
+
| "no-progress"
|
|
4468
|
+
| "window-exceeded"
|
|
4469
|
+
| "not-tailable"
|
|
4470
|
+
| "inspect-timeout"
|
|
4471
|
+
| "inspect-failed"
|
|
4472
|
+
| "recovery-deadline";
|
|
4361
4473
|
/**
|
|
4362
4474
|
* Structured failure envelope an `agentTool()` returns when a sub-agent run
|
|
4363
4475
|
* does not complete. Instead of an opaque error string the parent model would
|
|
@@ -4376,7 +4488,15 @@ type AgentToolFailure = {
|
|
|
4376
4488
|
ok: false;
|
|
4377
4489
|
status: Exclude<AgentToolTerminalStatus, "completed">;
|
|
4378
4490
|
error: string;
|
|
4379
|
-
retryable: boolean
|
|
4491
|
+
retryable: boolean /** Present only when `status` is `interrupted` — machine-readable cause. */;
|
|
4492
|
+
reason?: AgentToolInterruptedReason;
|
|
4493
|
+
/**
|
|
4494
|
+
* Present only when `status` is `interrupted`. `true` when the child facet was
|
|
4495
|
+
* still non-terminal (running / advancing) at the moment the parent stopped
|
|
4496
|
+
* waiting; `false` once the parent has torn the child down so it is no longer
|
|
4497
|
+
* doing work. Lets a caller decide between re-dispatching vs. reconnecting.
|
|
4498
|
+
*/
|
|
4499
|
+
childStillRunning?: boolean;
|
|
4380
4500
|
};
|
|
4381
4501
|
type AgentToolDisplayMetadata = {
|
|
4382
4502
|
name?: string;
|
|
@@ -4396,7 +4516,13 @@ type AgentToolRunInfo = {
|
|
|
4396
4516
|
type AgentToolLifecycleResult = {
|
|
4397
4517
|
status: AgentToolTerminalStatus;
|
|
4398
4518
|
summary?: string;
|
|
4399
|
-
error?: string
|
|
4519
|
+
error?: string /** Present only when `status` is `interrupted` — machine-readable cause. */;
|
|
4520
|
+
reason?: AgentToolInterruptedReason;
|
|
4521
|
+
/**
|
|
4522
|
+
* Present only when `status` is `interrupted`. Whether the child facet was
|
|
4523
|
+
* still non-terminal when the parent stopped waiting (before any teardown).
|
|
4524
|
+
*/
|
|
4525
|
+
childStillRunning?: boolean;
|
|
4400
4526
|
};
|
|
4401
4527
|
type RunAgentToolOptions<Input = unknown> = {
|
|
4402
4528
|
input: Input;
|
|
@@ -4414,6 +4540,18 @@ type RunAgentToolResult<Output = unknown> = {
|
|
|
4414
4540
|
output?: Output;
|
|
4415
4541
|
summary?: string;
|
|
4416
4542
|
error?: string;
|
|
4543
|
+
/**
|
|
4544
|
+
* Present only when `status` is `interrupted` — a machine-readable cause so
|
|
4545
|
+
* callers don't pattern-match the `error` prose (#1630 follow-up).
|
|
4546
|
+
*/
|
|
4547
|
+
reason?: AgentToolInterruptedReason;
|
|
4548
|
+
/**
|
|
4549
|
+
* Present only when `status` is `interrupted`. `true` when the child facet was
|
|
4550
|
+
* still non-terminal (running / advancing) at the moment the parent stopped
|
|
4551
|
+
* waiting and before any teardown; `false` once the parent has torn the child
|
|
4552
|
+
* down so it is no longer doing work.
|
|
4553
|
+
*/
|
|
4554
|
+
childStillRunning?: boolean;
|
|
4417
4555
|
};
|
|
4418
4556
|
type ChatCapableAgentClass<T extends Agent = Agent> = SubAgentClass<T>;
|
|
4419
4557
|
type AgentToolRunInspection<Output = unknown> = {
|
|
@@ -4489,7 +4627,14 @@ type AgentToolEvent =
|
|
|
4489
4627
|
| {
|
|
4490
4628
|
kind: "interrupted";
|
|
4491
4629
|
runId: string;
|
|
4492
|
-
error: string
|
|
4630
|
+
error: string /** Machine-readable cause of the interrupt (#1630 follow-up). */;
|
|
4631
|
+
reason?: AgentToolInterruptedReason;
|
|
4632
|
+
/**
|
|
4633
|
+
* Whether the child facet was still non-terminal when the parent stopped
|
|
4634
|
+
* waiting (before any teardown). Lets a UI distinguish a still-running
|
|
4635
|
+
* child from one the parent has torn down.
|
|
4636
|
+
*/
|
|
4637
|
+
childStillRunning?: boolean;
|
|
4493
4638
|
};
|
|
4494
4639
|
type AgentToolEventMessage = {
|
|
4495
4640
|
type: "agent-tool-event";
|
|
@@ -4509,6 +4654,13 @@ type AgentToolRunState = {
|
|
|
4509
4654
|
parts: UIMessage["parts"];
|
|
4510
4655
|
summary?: string;
|
|
4511
4656
|
error?: string;
|
|
4657
|
+
/**
|
|
4658
|
+
* Present only when `status` is `interrupted` — machine-readable cause and
|
|
4659
|
+
* whether the child is still running, mirrored from the wire event so a UI
|
|
4660
|
+
* can render the reason without parsing `error` (#1630 follow-up).
|
|
4661
|
+
*/
|
|
4662
|
+
reason?: AgentToolInterruptedReason;
|
|
4663
|
+
childStillRunning?: boolean;
|
|
4512
4664
|
subAgent: {
|
|
4513
4665
|
agent: string;
|
|
4514
4666
|
name: string;
|
|
@@ -4521,107 +4673,108 @@ type AgentToolEventState = {
|
|
|
4521
4673
|
};
|
|
4522
4674
|
//#endregion
|
|
4523
4675
|
export {
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4676
|
+
StreamingResponse as $,
|
|
4677
|
+
DeleteFibersOptions as A,
|
|
4678
|
+
McpAgent as At,
|
|
4679
|
+
MCPServerMessage as B,
|
|
4680
|
+
WorkerTransportOptions as Bt,
|
|
4681
|
+
AgentNamespace as C,
|
|
4682
|
+
RPCClientTransportOptions as Ct,
|
|
4683
|
+
Connection$1 as D,
|
|
4684
|
+
ElicitRequest$1 as Dt,
|
|
4685
|
+
CallableMetadata as E,
|
|
4686
|
+
RPC_DO_PREFIX as Et,
|
|
4687
|
+
FiberRecoveryContext as F,
|
|
4688
|
+
experimental_createMcpHandler as Ft,
|
|
4689
|
+
RoutingRetryOptions as G,
|
|
4690
|
+
SUB_PREFIX as Gt,
|
|
4691
|
+
QueueItem as H,
|
|
4692
|
+
StreamableHTTPEdgeClientTransport as Ht,
|
|
4693
|
+
FiberRecoveryResult as I,
|
|
4694
|
+
McpAuthContext as It,
|
|
4695
|
+
SendEmailOptions as J,
|
|
4696
|
+
parseSubAgentPath as Jt,
|
|
4697
|
+
Schedule as K,
|
|
4698
|
+
SubAgentPathMatch as Kt,
|
|
4699
|
+
FiberStatus as L,
|
|
4700
|
+
getMcpAuthContext as Lt,
|
|
4701
|
+
EmailSendBinding as M,
|
|
4702
|
+
DurableObjectEventStore as Mt,
|
|
4703
|
+
FiberContext as N,
|
|
4704
|
+
CreateMcpHandlerOptions as Nt,
|
|
4705
|
+
ConnectionContext$1 as O,
|
|
4706
|
+
ElicitRequestSchema$1 as Ot,
|
|
4707
|
+
FiberInspection as P,
|
|
4708
|
+
createMcpHandler as Pt,
|
|
4709
|
+
StateUpdateMessage as Q,
|
|
4710
|
+
ListFibersOptions as R,
|
|
4711
|
+
TransportState as Rt,
|
|
4712
|
+
AgentGetOptions as S,
|
|
4713
|
+
RPCClientTransport as St,
|
|
4714
|
+
AgentStaticOptions as T,
|
|
4715
|
+
RPCServerTransportOptions as Tt,
|
|
4716
|
+
RPCRequest as U,
|
|
4717
|
+
McpClientOptions as Ut,
|
|
4718
|
+
MCPServersState as V,
|
|
4719
|
+
SSEEdgeClientTransport as Vt,
|
|
4720
|
+
RPCResponse as W,
|
|
4721
|
+
TransportType as Wt,
|
|
4722
|
+
StartFiberOptions as X,
|
|
4723
|
+
SqlError as Y,
|
|
4724
|
+
routeSubAgentRequest as Yt,
|
|
4725
|
+
StartFiberResult as Z,
|
|
4726
|
+
RunAgentToolResult as _,
|
|
4727
|
+
MCPServerOptions as _t,
|
|
4575
4728
|
AgentToolEventState as a,
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4729
|
+
getCurrentAgent as at,
|
|
4730
|
+
Agent as b,
|
|
4731
|
+
getNamespacedData as bt,
|
|
4732
|
+
AgentToolLifecycleResult as c,
|
|
4733
|
+
unstable_callable as ct,
|
|
4734
|
+
AgentToolRunState as d,
|
|
4735
|
+
MCPClientOAuthCallbackConfig as dt,
|
|
4736
|
+
SubAgentClass as et,
|
|
4737
|
+
AgentToolRunStatus as f,
|
|
4738
|
+
MCPClientOAuthResult as ft,
|
|
4739
|
+
RunAgentToolOptions as g,
|
|
4740
|
+
MCPServerFilter as gt,
|
|
4741
|
+
ChatCapableAgentClass as h,
|
|
4742
|
+
MCPOAuthCallbackResult as ht,
|
|
4590
4743
|
AgentToolEventMessage as i,
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4744
|
+
getAgentByName as it,
|
|
4745
|
+
EmailRoutingOptions as j,
|
|
4746
|
+
ClearableEventStore as jt,
|
|
4747
|
+
DEFAULT_AGENT_STATIC_OPTIONS as k,
|
|
4748
|
+
ElicitResult$1 as kt,
|
|
4749
|
+
AgentToolRunInfo as l,
|
|
4750
|
+
MCPClientManager as lt,
|
|
4751
|
+
AgentToolTerminalStatus as m,
|
|
4752
|
+
MCPDiscoverResult as mt,
|
|
4600
4753
|
AgentToolDisplayMetadata as n,
|
|
4601
|
-
|
|
4754
|
+
WSMessage$1 as nt,
|
|
4602
4755
|
AgentToolFailure as o,
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4756
|
+
routeAgentEmail as ot,
|
|
4757
|
+
AgentToolStoredChunk as p,
|
|
4758
|
+
MCPConnectionResult as pt,
|
|
4759
|
+
ScheduleCriteria as q,
|
|
4760
|
+
getSubAgentByName as qt,
|
|
4608
4761
|
AgentToolEvent as r,
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4762
|
+
callable as rt,
|
|
4763
|
+
AgentToolInterruptedReason as s,
|
|
4764
|
+
routeAgentRequest as st,
|
|
4612
4765
|
AgentToolChildAdapter as t,
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4766
|
+
SubAgentStub as tt,
|
|
4767
|
+
AgentToolRunInspection as u,
|
|
4768
|
+
MCPClientManagerOptions as ut,
|
|
4769
|
+
AddMcpServerOptions as v,
|
|
4770
|
+
MCP_SERVER_ID_MAX_LENGTH as vt,
|
|
4771
|
+
AgentOptions as w,
|
|
4772
|
+
RPCServerTransport as wt,
|
|
4773
|
+
AgentContext as x,
|
|
4774
|
+
normalizeServerId as xt,
|
|
4775
|
+
AddRpcMcpServerOptions as y,
|
|
4776
|
+
RegisterServerOptions as yt,
|
|
4777
|
+
MCPServer as z,
|
|
4778
|
+
WorkerTransport as zt
|
|
4626
4779
|
};
|
|
4627
|
-
//# sourceMappingURL=agent-tool-types-
|
|
4780
|
+
//# sourceMappingURL=agent-tool-types-V25Z_HcX.d.ts.map
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
+
_ as RunAgentToolResult,
|
|
2
3
|
a as AgentToolEventState,
|
|
3
|
-
c as
|
|
4
|
-
d as
|
|
5
|
-
f as
|
|
6
|
-
g as
|
|
7
|
-
h as
|
|
4
|
+
c as AgentToolLifecycleResult,
|
|
5
|
+
d as AgentToolRunState,
|
|
6
|
+
f as AgentToolRunStatus,
|
|
7
|
+
g as RunAgentToolOptions,
|
|
8
|
+
h as ChatCapableAgentClass,
|
|
8
9
|
i as AgentToolEventMessage,
|
|
9
|
-
l as
|
|
10
|
-
m as
|
|
10
|
+
l as AgentToolRunInfo,
|
|
11
|
+
m as AgentToolTerminalStatus,
|
|
11
12
|
n as AgentToolDisplayMetadata,
|
|
12
13
|
o as AgentToolFailure,
|
|
13
|
-
p as
|
|
14
|
+
p as AgentToolStoredChunk,
|
|
14
15
|
r as AgentToolEvent,
|
|
15
|
-
s as
|
|
16
|
+
s as AgentToolInterruptedReason,
|
|
16
17
|
t as AgentToolChildAdapter,
|
|
17
|
-
u as
|
|
18
|
-
} from "./agent-tool-types-
|
|
18
|
+
u as AgentToolRunInspection
|
|
19
|
+
} from "./agent-tool-types-V25Z_HcX.js";
|
|
19
20
|
export {
|
|
20
21
|
AgentToolChildAdapter,
|
|
21
22
|
AgentToolDisplayMetadata,
|
|
@@ -23,6 +24,7 @@ export {
|
|
|
23
24
|
AgentToolEventMessage,
|
|
24
25
|
AgentToolEventState,
|
|
25
26
|
AgentToolFailure,
|
|
27
|
+
AgentToolInterruptedReason,
|
|
26
28
|
AgentToolLifecycleResult,
|
|
27
29
|
AgentToolRunInfo,
|
|
28
30
|
AgentToolRunInspection,
|
|
@@ -1,4 +1,44 @@
|
|
|
1
1
|
//#region src/chat/message-builder.ts
|
|
2
|
+
/** Whether a value is a plain (non-array, non-null) object. */
|
|
3
|
+
function isPlainObject(value) {
|
|
4
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Coerce a tool part's `input` into a provider-acceptable object.
|
|
8
|
+
*
|
|
9
|
+
* The Anthropic Messages API requires `tool_use.input` to be a JSON **object** —
|
|
10
|
+
* `null`, `undefined`, `""`, a raw string, **or an array** are all rejected with
|
|
11
|
+
* `tool_use.input: Input should be an object` (verified empirically against the
|
|
12
|
+
* live API: `{}` → 200, but `""`, `[]`, and `[{...}]` all → 400). A streamed
|
|
13
|
+
* tool call that finishes with no `input_json_delta` events (the model called
|
|
14
|
+
* the tool with no args), or whose input surfaces as a stringified JSON blob,
|
|
15
|
+
* can persist one of these shapes — and because it lives in durable storage, the
|
|
16
|
+
* session is then wedged across reconnects, redeploys, and DO evictions.
|
|
17
|
+
* Enforcing the invariant at the write boundary (and as a read-side repair
|
|
18
|
+
* backstop) keeps the transcript valid.
|
|
19
|
+
*
|
|
20
|
+
* - A plain (non-array) object is returned untouched (`changed: false`).
|
|
21
|
+
* - A string that parses to a plain object is parsed.
|
|
22
|
+
* - Everything else (`null`, `undefined`, `""`, arrays, primitives, non-object
|
|
23
|
+
* or unparseable JSON) collapses to `{}`.
|
|
24
|
+
*/
|
|
25
|
+
function normalizeToolInput(raw) {
|
|
26
|
+
if (isPlainObject(raw)) return {
|
|
27
|
+
input: raw,
|
|
28
|
+
changed: false
|
|
29
|
+
};
|
|
30
|
+
if (typeof raw === "string" && raw.trim().startsWith("{")) try {
|
|
31
|
+
const parsed = JSON.parse(raw);
|
|
32
|
+
if (isPlainObject(parsed)) return {
|
|
33
|
+
input: parsed,
|
|
34
|
+
changed: true
|
|
35
|
+
};
|
|
36
|
+
} catch {}
|
|
37
|
+
return {
|
|
38
|
+
input: {},
|
|
39
|
+
changed: true
|
|
40
|
+
};
|
|
41
|
+
}
|
|
2
42
|
/**
|
|
3
43
|
* Applies a stream chunk to a mutable parts array, building up the message
|
|
4
44
|
* incrementally. Returns true if the chunk was handled, false if it was
|
|
@@ -120,7 +160,7 @@ function applyChunkToParts(parts, chunk) {
|
|
|
120
160
|
const p = existing;
|
|
121
161
|
if (p.state === "input-streaming") {
|
|
122
162
|
p.state = "input-available";
|
|
123
|
-
p.input = chunk.input;
|
|
163
|
+
p.input = normalizeToolInput(chunk.input).input;
|
|
124
164
|
if (chunk.providerExecuted != null) p.providerExecuted = chunk.providerExecuted;
|
|
125
165
|
if (chunk.providerMetadata != null) p.callProviderMetadata = chunk.providerMetadata;
|
|
126
166
|
if (chunk.title != null) p.title = chunk.title;
|
|
@@ -132,7 +172,7 @@ function applyChunkToParts(parts, chunk) {
|
|
|
132
172
|
toolCallId: chunk.toolCallId,
|
|
133
173
|
toolName: chunk.toolName,
|
|
134
174
|
state: "input-available",
|
|
135
|
-
input: chunk.input,
|
|
175
|
+
input: normalizeToolInput(chunk.input).input,
|
|
136
176
|
...chunk.providerExecuted != null ? { providerExecuted: chunk.providerExecuted } : {},
|
|
137
177
|
...chunk.providerMetadata != null ? { callProviderMetadata: chunk.providerMetadata } : {},
|
|
138
178
|
...chunk.title != null ? { title: chunk.title } : {}
|
|
@@ -146,7 +186,7 @@ function applyChunkToParts(parts, chunk) {
|
|
|
146
186
|
if (p.state === "output-available" || p.state === "output-error" || p.state === "output-denied") return true;
|
|
147
187
|
p.state = "output-error";
|
|
148
188
|
p.errorText = chunk.errorText;
|
|
149
|
-
p.input = chunk.input;
|
|
189
|
+
p.input = normalizeToolInput(chunk.input).input;
|
|
150
190
|
if (chunk.providerExecuted != null) p.providerExecuted = chunk.providerExecuted;
|
|
151
191
|
if (chunk.providerMetadata != null) p.callProviderMetadata = chunk.providerMetadata;
|
|
152
192
|
} else parts.push({
|
|
@@ -154,7 +194,7 @@ function applyChunkToParts(parts, chunk) {
|
|
|
154
194
|
toolCallId: chunk.toolCallId,
|
|
155
195
|
toolName: chunk.toolName,
|
|
156
196
|
state: "output-error",
|
|
157
|
-
input: chunk.input,
|
|
197
|
+
input: normalizeToolInput(chunk.input).input,
|
|
158
198
|
errorText: chunk.errorText,
|
|
159
199
|
...chunk.providerExecuted != null ? { providerExecuted: chunk.providerExecuted } : {},
|
|
160
200
|
...chunk.providerMetadata != null ? { callProviderMetadata: chunk.providerMetadata } : {}
|
|
@@ -394,7 +434,9 @@ function applyToRun(prev, message) {
|
|
|
394
434
|
return {
|
|
395
435
|
...seeded,
|
|
396
436
|
status: "interrupted",
|
|
397
|
-
error: event.error
|
|
437
|
+
error: event.error,
|
|
438
|
+
reason: event.reason,
|
|
439
|
+
childStillRunning: event.childStillRunning
|
|
398
440
|
};
|
|
399
441
|
}
|
|
400
442
|
}
|
|
@@ -420,6 +462,6 @@ function applyAgentToolEvent(state, message) {
|
|
|
420
462
|
};
|
|
421
463
|
}
|
|
422
464
|
//#endregion
|
|
423
|
-
export { isReplayChunk as i, createAgentToolEventState as n, applyChunkToParts as r, applyAgentToolEvent as t };
|
|
465
|
+
export { normalizeToolInput as a, isReplayChunk as i, createAgentToolEventState as n, applyChunkToParts as r, applyAgentToolEvent as t };
|
|
424
466
|
|
|
425
|
-
//# sourceMappingURL=agent-tools-
|
|
467
|
+
//# sourceMappingURL=agent-tools-3zLG7MgA.js.map
|