agents 0.13.3 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/{agent-tool-types-l98LCbBl.d.ts → agent-tool-types-LInzZfLo.d.ts} +463 -116
- package/dist/agent-tool-types.d.ts +13 -11
- package/dist/{agent-tools-Bg5ilERh.d.ts → agent-tools-BE9xosUG.d.ts} +2 -2
- package/dist/agent-tools.d.ts +14 -20
- package/dist/agent-tools.js +10 -6
- 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/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/chat/index.d.ts +138 -19
- package/dist/chat/index.js +96 -12
- package/dist/chat/index.js.map +1 -1
- package/dist/chat-sdk/index.d.ts +4 -4
- package/dist/classPrivateMethodInitSpec-bG0tD96O.js +7 -0
- package/dist/{client-D1kFXo80.js → client-NradHZZz.js} +206 -75
- package/dist/client-NradHZZz.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/{compaction-helpers-fJyf8j4m.js → compaction-helpers-BjT2NKRZ.js} +22 -3
- package/dist/compaction-helpers-BjT2NKRZ.js.map +1 -0
- package/dist/{compaction-helpers-B-pG5J22.d.ts → compaction-helpers-DpP_XP9J.d.ts} +59 -33
- package/dist/{do-oauth-client-provider-4OKQU9rT.d.ts → do-oauth-client-provider-CPm9rK5I.d.ts} +1 -1
- package/dist/{email-J0GGS3sa.d.ts → email-1fTSJwPm.d.ts} +1 -1
- package/dist/email.d.ts +2 -2
- package/dist/experimental/memory/session/index.d.ts +30 -25
- package/dist/experimental/memory/session/index.js +7 -2
- package/dist/experimental/memory/session/index.js.map +1 -1
- package/dist/experimental/memory/utils/index.d.ts +12 -10
- package/dist/experimental/memory/utils/index.js +2 -2
- package/dist/{index-DKey3P4s.d.ts → index-Brdu5nMI.d.ts} +270 -1
- package/dist/index.d.ts +74 -67
- package/dist/index.js +467 -63
- package/dist/index.js.map +1 -1
- package/dist/{internal_context-BZrMS0B5.d.ts → internal_context-CcZy2Em7.d.ts} +1 -1
- package/dist/internal_context.d.ts +1 -1
- package/dist/mcp/client.d.ts +17 -13
- package/dist/mcp/client.js +2 -2
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/index.d.ts +35 -27
- package/dist/mcp/index.js +402 -69
- package/dist/mcp/index.js.map +1 -1
- package/dist/observability/index.d.ts +1 -1
- package/dist/observability/index.js +15 -1
- package/dist/observability/index.js.map +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/{retries-BVdRl5ZE.d.ts → retries-ClWwxADl.d.ts} +1 -1
- package/dist/retries.d.ts +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/{shared-Cvj92byG.d.ts → shared-CpY1FLvm.d.ts} +1 -1
- package/dist/{shared-CiKaIK4h.js → shared-DdOn6sp4.js} +3 -7
- package/dist/{shared-CiKaIK4h.js.map → shared-DdOn6sp4.js.map} +1 -1
- package/dist/skills/index.d.ts +236 -0
- package/dist/skills/index.js +1326 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/sub-routing.d.ts +6 -6
- package/dist/{tool-output-truncation-CH-khbZ3.js → tool-output-truncation-BF4AZQlw.js} +1 -1
- package/dist/{tool-output-truncation-CH-khbZ3.js.map → tool-output-truncation-BF4AZQlw.js.map} +1 -1
- package/dist/{types-_JjKmv-l.d.ts → types-B0GymtN_.d.ts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +248 -2
- package/dist/vite.js.map +1 -1
- package/dist/{workflow-types-Dkzg4hAx.d.ts → workflow-types-DPkuBi--.d.ts} +1 -1
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +13 -3
- package/dist/workflows.js +10 -1
- package/dist/workflows.js.map +1 -1
- package/package.json +21 -3
- package/skills-module.d.ts +22 -0
- package/dist/client-D1kFXo80.js.map +0 -1
- package/dist/compaction-helpers-fJyf8j4m.js.map +0 -1
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
a as AgentToolEventState,
|
|
3
|
-
c as
|
|
4
|
-
d as
|
|
5
|
-
f as
|
|
6
|
-
|
|
3
|
+
c as AgentToolRunInfo,
|
|
4
|
+
d as AgentToolRunStatus,
|
|
5
|
+
f as AgentToolStoredChunk,
|
|
6
|
+
g as RunAgentToolResult,
|
|
7
|
+
h as RunAgentToolOptions,
|
|
7
8
|
i as AgentToolEventMessage,
|
|
8
|
-
l as
|
|
9
|
-
m as
|
|
9
|
+
l as AgentToolRunInspection,
|
|
10
|
+
m as ChatCapableAgentClass,
|
|
10
11
|
n as AgentToolDisplayMetadata,
|
|
11
|
-
o as
|
|
12
|
-
p as
|
|
12
|
+
o as AgentToolFailure,
|
|
13
|
+
p as AgentToolTerminalStatus,
|
|
13
14
|
r as AgentToolEvent,
|
|
14
|
-
s as
|
|
15
|
+
s as AgentToolLifecycleResult,
|
|
15
16
|
t as AgentToolChildAdapter,
|
|
16
|
-
u as
|
|
17
|
-
} from "./agent-tool-types-
|
|
17
|
+
u as AgentToolRunState
|
|
18
|
+
} from "./agent-tool-types-LInzZfLo.js";
|
|
18
19
|
export {
|
|
19
20
|
AgentToolChildAdapter,
|
|
20
21
|
AgentToolDisplayMetadata,
|
|
21
22
|
AgentToolEvent,
|
|
22
23
|
AgentToolEventMessage,
|
|
23
24
|
AgentToolEventState,
|
|
25
|
+
AgentToolFailure,
|
|
24
26
|
AgentToolLifecycleResult,
|
|
25
27
|
AgentToolRunInfo,
|
|
26
28
|
AgentToolRunInspection,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
a as AgentToolEventState,
|
|
3
3
|
i as AgentToolEventMessage
|
|
4
|
-
} from "./agent-tool-types-
|
|
4
|
+
} from "./agent-tool-types-LInzZfLo.js";
|
|
5
5
|
|
|
6
6
|
//#region src/chat/agent-tools.d.ts
|
|
7
7
|
declare function createAgentToolEventState(): AgentToolEventState;
|
|
@@ -11,4 +11,4 @@ declare function applyAgentToolEvent(
|
|
|
11
11
|
): AgentToolEventState;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { createAgentToolEventState as n, applyAgentToolEvent as t };
|
|
14
|
-
//# sourceMappingURL=agent-tools-
|
|
14
|
+
//# sourceMappingURL=agent-tools-BE9xosUG.d.ts.map
|
package/dist/agent-tools.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
a as AgentToolEventState,
|
|
3
|
-
c as
|
|
4
|
-
d as
|
|
5
|
-
f as
|
|
6
|
-
|
|
3
|
+
c as AgentToolRunInfo,
|
|
4
|
+
d as AgentToolRunStatus,
|
|
5
|
+
f as AgentToolStoredChunk,
|
|
6
|
+
g as RunAgentToolResult,
|
|
7
|
+
h as RunAgentToolOptions,
|
|
7
8
|
i as AgentToolEventMessage,
|
|
8
|
-
l as
|
|
9
|
-
m as
|
|
9
|
+
l as AgentToolRunInspection,
|
|
10
|
+
m as ChatCapableAgentClass,
|
|
10
11
|
n as AgentToolDisplayMetadata,
|
|
11
|
-
o as
|
|
12
|
-
p as
|
|
12
|
+
o as AgentToolFailure,
|
|
13
|
+
p as AgentToolTerminalStatus,
|
|
13
14
|
r as AgentToolEvent,
|
|
14
|
-
s as
|
|
15
|
+
s as AgentToolLifecycleResult,
|
|
15
16
|
t as AgentToolChildAdapter,
|
|
16
|
-
u as
|
|
17
|
-
} from "./agent-tool-types-
|
|
17
|
+
u as AgentToolRunState
|
|
18
|
+
} from "./agent-tool-types-LInzZfLo.js";
|
|
18
19
|
import { Tool } from "ai";
|
|
19
20
|
|
|
20
21
|
//#region src/agent-tools.d.ts
|
|
@@ -36,15 +37,7 @@ type AgentToolFactoryOptions<Output = unknown> = {
|
|
|
36
37
|
declare function agentTool<Input = unknown, Output = unknown>(
|
|
37
38
|
cls: ChatCapableAgentClass,
|
|
38
39
|
options: AgentToolFactoryOptions<Output>
|
|
39
|
-
): Tool<
|
|
40
|
-
Input,
|
|
41
|
-
| string
|
|
42
|
-
| Output
|
|
43
|
-
| {
|
|
44
|
-
ok: false;
|
|
45
|
-
error: string;
|
|
46
|
-
}
|
|
47
|
-
>;
|
|
40
|
+
): Tool<Input, string | Output | AgentToolFailure>;
|
|
48
41
|
//#endregion
|
|
49
42
|
export {
|
|
50
43
|
type AgentToolChildAdapter,
|
|
@@ -53,6 +46,7 @@ export {
|
|
|
53
46
|
type AgentToolEventMessage,
|
|
54
47
|
type AgentToolEventState,
|
|
55
48
|
type AgentToolFactoryOptions,
|
|
49
|
+
type AgentToolFailure,
|
|
56
50
|
type AgentToolLifecycleResult,
|
|
57
51
|
type AgentToolRunInfo,
|
|
58
52
|
type AgentToolRunInspection,
|
package/dist/agent-tools.js
CHANGED
|
@@ -6,10 +6,12 @@ function currentAgentToolRunner() {
|
|
|
6
6
|
if (agent === null || typeof agent !== "object" || typeof agent.runAgentTool !== "function") throw new Error("agentTool() can only run inside an Agent turn. Use it from getTools() on an Agent subclass.");
|
|
7
7
|
return agent;
|
|
8
8
|
}
|
|
9
|
-
function failure(error) {
|
|
9
|
+
function failure(status, error, retryable) {
|
|
10
10
|
return {
|
|
11
11
|
ok: false,
|
|
12
|
-
|
|
12
|
+
status,
|
|
13
|
+
error,
|
|
14
|
+
retryable
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
@@ -26,22 +28,24 @@ function agentTool(cls, options) {
|
|
|
26
28
|
...options.displayName ? { name: options.displayName } : {},
|
|
27
29
|
...options.icon ? { icon: options.icon } : {}
|
|
28
30
|
} : void 0;
|
|
31
|
+
const runId = executeOptions?.toolCallId ? `agent-tool:${executeOptions.toolCallId}` : void 0;
|
|
29
32
|
const result = await currentAgentToolRunner().runAgentTool(cls, {
|
|
30
33
|
input,
|
|
34
|
+
runId,
|
|
31
35
|
parentToolCallId: executeOptions?.toolCallId,
|
|
32
36
|
signal: executeOptions?.abortSignal,
|
|
33
37
|
display
|
|
34
38
|
});
|
|
35
39
|
if (result.status === "completed") {
|
|
36
40
|
if (options.outputSchema) {
|
|
37
|
-
if (result.output === void 0) return failure("agent tool completed without structured output required by outputSchema");
|
|
41
|
+
if (result.output === void 0) return failure("error", "agent tool completed without structured output required by outputSchema", false);
|
|
38
42
|
return options.outputSchema.parse(result.output);
|
|
39
43
|
}
|
|
40
44
|
return result.summary ?? "";
|
|
41
45
|
}
|
|
42
|
-
if (result.status === "aborted") return failure("agent tool run was cancelled");
|
|
43
|
-
if (result.status === "interrupted") return failure("agent tool run was interrupted;
|
|
44
|
-
return failure(result.error ?? "agent tool run failed");
|
|
46
|
+
if (result.status === "aborted") return failure("aborted", result.error ?? "agent tool run was cancelled", false);
|
|
47
|
+
if (result.status === "interrupted") return failure("interrupted", result.error ?? "agent tool run was interrupted before it finished; it can be retried", true);
|
|
48
|
+
return failure("error", result.error ?? "agent tool run failed", false);
|
|
45
49
|
}
|
|
46
50
|
});
|
|
47
51
|
}
|
package/dist/agent-tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-tools.js","names":["agentContext","createTool"],"sources":["../src/agent-tools.ts"],"sourcesContent":["import { tool, type Tool } from \"ai\";\nimport { __DO_NOT_USE_WILL_BREAK__agentContext as agentContext } from \"./internal_context\";\nimport type {\n ChatCapableAgentClass,\n RunAgentToolOptions,\n RunAgentToolResult,\n AgentToolDisplayMetadata\n} from \"./agent-tool-types\";\n\ntype SchemaLike<T = unknown> = {\n parse(value: unknown): T;\n};\n\ntype AgentToolFactoryOptions<Output = unknown> = {\n description: string;\n inputSchema: unknown;\n outputSchema?: SchemaLike<Output>;\n displayName?: string;\n icon?: string;\n display?: AgentToolDisplayMetadata;\n};\n\ntype ToolExecutionOptions = {\n toolCallId?: string;\n abortSignal?: AbortSignal;\n};\n\ntype AgentToolRunner = {\n runAgentTool<Input, Output>(\n cls: ChatCapableAgentClass,\n options: RunAgentToolOptions<Input>\n ): Promise<RunAgentToolResult<Output>>;\n};\n\nfunction currentAgentToolRunner(): AgentToolRunner {\n const agent = agentContext.getStore()?.agent;\n if (\n agent === null ||\n typeof agent !== \"object\" ||\n typeof (agent as { runAgentTool?: unknown }).runAgentTool !== \"function\"\n ) {\n throw new Error(\n \"agentTool() can only run inside an Agent turn. Use it from getTools() on an Agent subclass.\"\n );\n }\n return agent as AgentToolRunner;\n}\n\nfunction failure(error: string
|
|
1
|
+
{"version":3,"file":"agent-tools.js","names":["agentContext","createTool"],"sources":["../src/agent-tools.ts"],"sourcesContent":["import { tool, type Tool } from \"ai\";\nimport { __DO_NOT_USE_WILL_BREAK__agentContext as agentContext } from \"./internal_context\";\nimport type {\n ChatCapableAgentClass,\n RunAgentToolOptions,\n RunAgentToolResult,\n AgentToolDisplayMetadata,\n AgentToolFailure\n} from \"./agent-tool-types\";\n\ntype SchemaLike<T = unknown> = {\n parse(value: unknown): T;\n};\n\ntype AgentToolFactoryOptions<Output = unknown> = {\n description: string;\n inputSchema: unknown;\n outputSchema?: SchemaLike<Output>;\n displayName?: string;\n icon?: string;\n display?: AgentToolDisplayMetadata;\n};\n\ntype ToolExecutionOptions = {\n toolCallId?: string;\n abortSignal?: AbortSignal;\n};\n\ntype AgentToolRunner = {\n runAgentTool<Input, Output>(\n cls: ChatCapableAgentClass,\n options: RunAgentToolOptions<Input>\n ): Promise<RunAgentToolResult<Output>>;\n};\n\nfunction currentAgentToolRunner(): AgentToolRunner {\n const agent = agentContext.getStore()?.agent;\n if (\n agent === null ||\n typeof agent !== \"object\" ||\n typeof (agent as { runAgentTool?: unknown }).runAgentTool !== \"function\"\n ) {\n throw new Error(\n \"agentTool() can only run inside an Agent turn. Use it from getTools() on an Agent subclass.\"\n );\n }\n return agent as AgentToolRunner;\n}\n\nfunction failure(\n status: AgentToolFailure[\"status\"],\n error: string,\n retryable: boolean\n): AgentToolFailure {\n return { ok: false, status, error, retryable };\n}\n\n/**\n * Create an AI SDK tool that dispatches a chat-capable sub-agent through\n * `Agent.runAgentTool`.\n */\nexport function agentTool<Input = unknown, Output = unknown>(\n cls: ChatCapableAgentClass,\n options: AgentToolFactoryOptions<Output>\n): Tool<Input, string | Output | AgentToolFailure> {\n const createTool = tool as unknown as <I, O>(config: {\n description: string;\n inputSchema: unknown;\n execute: (input: I, options?: ToolExecutionOptions) => Promise<O>;\n }) => Tool<I, O>;\n\n return createTool<Input, string | Output | AgentToolFailure>({\n description: options.description,\n inputSchema: options.inputSchema,\n execute: async (input: Input, executeOptions?: ToolExecutionOptions) => {\n const display: AgentToolDisplayMetadata | undefined =\n options.displayName || options.icon || options.display\n ? {\n ...options.display,\n ...(options.displayName ? { name: options.displayName } : {}),\n ...(options.icon ? { icon: options.icon } : {})\n }\n : undefined;\n\n // Derive a STABLE runId from the tool call id (#1630). A tool call's id is\n // preserved in the transcript, so when a parent turn is re-run by chat\n // recovery after a deploy / eviction, the same `agentTool()` call resolves\n // to the same runId — turning the re-issue into a duplicate that\n // `runAgentTool` re-attaches to the still-running child, instead of a\n // fresh `nanoid` that spawns a brand-new child and re-runs already-\n // completed work (\"the agent went all the way back\"). Falls back to a\n // fresh id only when there is no tool call id (rare; preserves prior\n // behavior).\n const runId = executeOptions?.toolCallId\n ? `agent-tool:${executeOptions.toolCallId}`\n : undefined;\n\n const result = await currentAgentToolRunner().runAgentTool<Input, Output>(\n cls,\n {\n input,\n runId,\n parentToolCallId: executeOptions?.toolCallId,\n signal: executeOptions?.abortSignal,\n display\n }\n );\n\n if (result.status === \"completed\") {\n if (options.outputSchema) {\n if (result.output === undefined) {\n return failure(\n \"error\",\n \"agent tool completed without structured output required by outputSchema\",\n false\n );\n }\n return options.outputSchema.parse(result.output);\n }\n return result.summary ?? \"\";\n }\n\n if (result.status === \"aborted\") {\n // Intentional cancellation (parent/user stopped the run) — not retryable.\n return failure(\n \"aborted\",\n result.error ?? \"agent tool run was cancelled\",\n false\n );\n }\n if (result.status === \"interrupted\") {\n // The child was reset/superseded by a deploy or parent recovery before\n // it reached a logical outcome. Re-dispatching the run can succeed, so\n // surface it as retryable rather than a terminal failure the parent\n // would report to the user as final.\n return failure(\n \"interrupted\",\n result.error ??\n \"agent tool run was interrupted before it finished; it can be retried\",\n true\n );\n }\n return failure(\"error\", result.error ?? \"agent tool run failed\", false);\n }\n });\n}\n\nexport type { AgentToolFactoryOptions };\nexport type {\n AgentToolChildAdapter,\n AgentToolDisplayMetadata,\n AgentToolEvent,\n AgentToolEventMessage,\n AgentToolEventState,\n AgentToolFailure,\n AgentToolLifecycleResult,\n AgentToolRunInfo,\n AgentToolRunInspection,\n AgentToolRunState,\n AgentToolRunStatus,\n AgentToolStoredChunk,\n AgentToolTerminalStatus,\n ChatCapableAgentClass,\n RunAgentToolOptions,\n RunAgentToolResult\n} from \"./agent-tool-types\";\n"],"mappings":";;;AAmCA,SAAS,yBAA0C;CACjD,MAAM,QAAQA,sCAAa,SAAS,GAAG;CACvC,IACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAQ,MAAqC,iBAAiB,YAE9D,MAAM,IAAI,MACR,6FACF;CAEF,OAAO;AACT;AAEA,SAAS,QACP,QACA,OACA,WACkB;CAClB,OAAO;EAAE,IAAI;EAAO;EAAQ;EAAO;CAAU;AAC/C;;;;;AAMA,SAAgB,UACd,KACA,SACiD;CAOjD,OAAOC,KAAsD;EAC3D,aAAa,QAAQ;EACrB,aAAa,QAAQ;EACrB,SAAS,OAAO,OAAc,mBAA0C;GACtE,MAAM,UACJ,QAAQ,eAAe,QAAQ,QAAQ,QAAQ,UAC3C;IACE,GAAG,QAAQ;IACX,GAAI,QAAQ,cAAc,EAAE,MAAM,QAAQ,YAAY,IAAI,CAAC;IAC3D,GAAI,QAAQ,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;GAC/C,IACA,KAAA;GAWN,MAAM,QAAQ,gBAAgB,aAC1B,cAAc,eAAe,eAC7B,KAAA;GAEJ,MAAM,SAAS,MAAM,uBAAuB,EAAE,aAC5C,KACA;IACE;IACA;IACA,kBAAkB,gBAAgB;IAClC,QAAQ,gBAAgB;IACxB;GACF,CACF;GAEA,IAAI,OAAO,WAAW,aAAa;IACjC,IAAI,QAAQ,cAAc;KACxB,IAAI,OAAO,WAAW,KAAA,GACpB,OAAO,QACL,SACA,2EACA,KACF;KAEF,OAAO,QAAQ,aAAa,MAAM,OAAO,MAAM;IACjD;IACA,OAAO,OAAO,WAAW;GAC3B;GAEA,IAAI,OAAO,WAAW,WAEpB,OAAO,QACL,WACA,OAAO,SAAS,gCAChB,KACF;GAEF,IAAI,OAAO,WAAW,eAKpB,OAAO,QACL,eACA,OAAO,SACL,wEACF,IACF;GAEF,OAAO,QAAQ,SAAS,OAAO,SAAS,yBAAyB,KAAK;EACxE;CACF,CAAC;AACH"}
|
package/dist/browser/ai.d.ts
CHANGED
package/dist/browser/ai.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as SEARCH_DESCRIPTION, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-
|
|
1
|
+
import { n as SEARCH_DESCRIPTION, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-DdOn6sp4.js";
|
|
2
2
|
import { tool } from "ai";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/browser/ai.ts
|
package/dist/browser/index.d.ts
CHANGED
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as connectBrowser, i as CdpSession, n as SEARCH_DESCRIPTION, o as connectUrl, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-
|
|
1
|
+
import { a as connectBrowser, i as CdpSession, n as SEARCH_DESCRIPTION, o as connectUrl, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-DdOn6sp4.js";
|
|
2
2
|
export { CdpSession, EXECUTE_DESCRIPTION, SEARCH_DESCRIPTION, connectBrowser, connectUrl, createBrowserToolHandlers };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as SEARCH_DESCRIPTION, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-
|
|
1
|
+
import { n as SEARCH_DESCRIPTION, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-DdOn6sp4.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { toolDefinition } from "@tanstack/ai";
|
|
4
4
|
//#region src/browser/tanstack-ai.ts
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
a as AgentToolEventState,
|
|
3
3
|
i as AgentToolEventMessage,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "../agent-tool-types-
|
|
4
|
+
r as AgentToolEvent,
|
|
5
|
+
u as AgentToolRunState
|
|
6
|
+
} from "../agent-tool-types-LInzZfLo.js";
|
|
7
7
|
import {
|
|
8
8
|
n as createAgentToolEventState,
|
|
9
9
|
t as applyAgentToolEvent
|
|
10
|
-
} from "../agent-tools-
|
|
10
|
+
} from "../agent-tools-BE9xosUG.js";
|
|
11
11
|
import { JSONSchema7, Tool, ToolSet, UIMessage } from "ai";
|
|
12
12
|
import { Connection } from "agents";
|
|
13
13
|
|
|
@@ -334,7 +334,21 @@ type SaveMessagesResult = {
|
|
|
334
334
|
* stream is detected after DO restart.
|
|
335
335
|
*/
|
|
336
336
|
type ChatRecoveryContext = {
|
|
337
|
-
/**
|
|
337
|
+
/** Stable identifier for this recovery incident. */ incidentId: string;
|
|
338
|
+
/**
|
|
339
|
+
* Stable request ID for the whole continuation chain (the recovery "root").
|
|
340
|
+
* Unlike `requestId` — which changes on every chained continuation — this is
|
|
341
|
+
* constant for the lifetime of the incident, so it's the right key for
|
|
342
|
+
* per-incident budget tracking or fresh-incident detection without
|
|
343
|
+
* re-deriving identity from message IDs.
|
|
344
|
+
*/
|
|
345
|
+
recoveryRootRequestId: string /** Attempt number for this recovery incident, starting at 1. */;
|
|
346
|
+
attempt: number /** Maximum attempts before the framework terminalizes recovery. */;
|
|
347
|
+
maxAttempts: number /** Whether this recovery is retrying an unanswered user turn or continuing a partial assistant turn. */;
|
|
348
|
+
recoveryKind:
|
|
349
|
+
| "retry"
|
|
350
|
+
| "continue" /** Stream ID from the interrupted stream. */;
|
|
351
|
+
streamId: string /** Request ID from the interrupted stream. */;
|
|
338
352
|
requestId: string /** Partial text extracted from stored chunks. */;
|
|
339
353
|
partialText: string /** Partial message parts reconstructed from chunks. */;
|
|
340
354
|
partialParts: MessagePart[] /** Checkpoint data from `this.stash()` during the interrupted stream. */;
|
|
@@ -359,6 +373,59 @@ type ChatRecoveryOptions = {
|
|
|
359
373
|
/** Save the partial response from stored chunks. Default: true. */ persist?: boolean /** Schedule a continuation via `continueLastTurn()`. Default: true. */;
|
|
360
374
|
continue?: boolean;
|
|
361
375
|
};
|
|
376
|
+
/**
|
|
377
|
+
* Context passed when framework-owned chat recovery exhausts its retry budget.
|
|
378
|
+
*
|
|
379
|
+
* Carries enough to render/persist a user-facing terminal banner without
|
|
380
|
+
* re-deriving anything: the `terminalMessage` that was shown, the
|
|
381
|
+
* `recoveryRootRequestId` (stable incident identity), and the partial the turn
|
|
382
|
+
* produced before it was given up on.
|
|
383
|
+
*/
|
|
384
|
+
type ChatRecoveryExhaustedContext = Pick<
|
|
385
|
+
ChatRecoveryContext,
|
|
386
|
+
| "incidentId"
|
|
387
|
+
| "requestId"
|
|
388
|
+
| "recoveryRootRequestId"
|
|
389
|
+
| "attempt"
|
|
390
|
+
| "maxAttempts"
|
|
391
|
+
| "recoveryKind"
|
|
392
|
+
| "streamId"
|
|
393
|
+
| "createdAt"
|
|
394
|
+
| "partialText"
|
|
395
|
+
| "partialParts"
|
|
396
|
+
> & {
|
|
397
|
+
/**
|
|
398
|
+
* Why recovery stopped. One of:
|
|
399
|
+
* - `max_attempts_exceeded` — the per-incident attempt budget was spent.
|
|
400
|
+
* - `no_progress_timeout` — no forward progress within the no-progress window.
|
|
401
|
+
* - `max_recovery_window_exceeded` — the absolute incident-age ceiling was hit.
|
|
402
|
+
* - `stable_timeout` — a recovery attempt kept timing out waiting for the
|
|
403
|
+
* isolate to reach stable state until the budget drained (extreme churn).
|
|
404
|
+
*
|
|
405
|
+
* Treat this as an open string: new reasons may be added.
|
|
406
|
+
*/
|
|
407
|
+
reason: string /** The terminal message shown to the user (from the `chatRecovery` config). */;
|
|
408
|
+
terminalMessage: string;
|
|
409
|
+
};
|
|
410
|
+
/**
|
|
411
|
+
* Configuration for durable chat recovery. `true` uses these defaults:
|
|
412
|
+
* `maxAttempts: 6`, `stableTimeoutMs: 10_000`, and a generic terminal message.
|
|
413
|
+
*/
|
|
414
|
+
type ChatRecoveryConfig =
|
|
415
|
+
| boolean
|
|
416
|
+
| {
|
|
417
|
+
maxAttempts?: number;
|
|
418
|
+
stableTimeoutMs?: number;
|
|
419
|
+
terminalMessage?: string;
|
|
420
|
+
onExhausted?(ctx: ChatRecoveryExhaustedContext): void | Promise<void>;
|
|
421
|
+
};
|
|
422
|
+
type ResolvedChatRecoveryConfig = {
|
|
423
|
+
enabled: boolean;
|
|
424
|
+
maxAttempts: number;
|
|
425
|
+
stableTimeoutMs: number;
|
|
426
|
+
terminalMessage: string;
|
|
427
|
+
onExhausted?: (ctx: ChatRecoveryExhaustedContext) => void | Promise<void>;
|
|
428
|
+
};
|
|
362
429
|
/**
|
|
363
430
|
* Controls how overlapping user submit requests behave while another
|
|
364
431
|
* chat turn is already active or queued.
|
|
@@ -631,6 +698,7 @@ declare const CHAT_MESSAGE_TYPES: {
|
|
|
631
698
|
readonly TOOL_RESULT: "cf_agent_tool_result";
|
|
632
699
|
readonly TOOL_APPROVAL: "cf_agent_tool_approval";
|
|
633
700
|
readonly MESSAGE_UPDATED: "cf_agent_message_updated";
|
|
701
|
+
readonly CHAT_RECOVERING: "cf_agent_chat_recovering";
|
|
634
702
|
};
|
|
635
703
|
//#endregion
|
|
636
704
|
//#region src/chat/continuation-state.d.ts
|
|
@@ -644,9 +712,11 @@ interface ContinuationConnection {
|
|
|
644
712
|
readonly id: string;
|
|
645
713
|
send(message: string): void;
|
|
646
714
|
}
|
|
647
|
-
interface ContinuationPending
|
|
648
|
-
|
|
649
|
-
|
|
715
|
+
interface ContinuationPending<
|
|
716
|
+
TConnection extends ContinuationConnection = ContinuationConnection
|
|
717
|
+
> {
|
|
718
|
+
connection: TConnection;
|
|
719
|
+
connectionId: string | null;
|
|
650
720
|
requestId: string;
|
|
651
721
|
clientTools?: ClientToolSchema[];
|
|
652
722
|
body?: Record<string, unknown>;
|
|
@@ -654,24 +724,33 @@ interface ContinuationPending {
|
|
|
654
724
|
prerequisite: Promise<boolean> | null;
|
|
655
725
|
pastCoalesce: boolean;
|
|
656
726
|
}
|
|
657
|
-
interface ContinuationDeferred
|
|
658
|
-
|
|
659
|
-
|
|
727
|
+
interface ContinuationDeferred<
|
|
728
|
+
TConnection extends ContinuationConnection = ContinuationConnection
|
|
729
|
+
> {
|
|
730
|
+
connection: TConnection;
|
|
731
|
+
connectionId: string | null;
|
|
660
732
|
clientTools?: ClientToolSchema[];
|
|
661
733
|
body?: Record<string, unknown>;
|
|
662
734
|
errorPrefix: string;
|
|
663
735
|
prerequisite: Promise<boolean> | null;
|
|
664
736
|
}
|
|
665
|
-
declare class ContinuationState
|
|
666
|
-
|
|
667
|
-
|
|
737
|
+
declare class ContinuationState<
|
|
738
|
+
TConnection extends ContinuationConnection = ContinuationConnection
|
|
739
|
+
> {
|
|
740
|
+
pending: ContinuationPending<TConnection> | null;
|
|
741
|
+
deferred: ContinuationDeferred<TConnection> | null;
|
|
668
742
|
activeRequestId: string | null;
|
|
669
743
|
activeConnectionId: string | null;
|
|
670
|
-
awaitingConnections: Map<string,
|
|
744
|
+
awaitingConnections: Map<string, TConnection>;
|
|
671
745
|
/** Clear pending state and awaiting connections (without sending RESUME_NONE). */
|
|
672
746
|
clearPending(): void;
|
|
673
747
|
clearDeferred(): void;
|
|
674
748
|
clearAll(): void;
|
|
749
|
+
/**
|
|
750
|
+
* Mark a connection as no longer available without canceling the
|
|
751
|
+
* continuation it initiated.
|
|
752
|
+
*/
|
|
753
|
+
releaseConnection(connectionId: string): void;
|
|
675
754
|
/**
|
|
676
755
|
* Send STREAM_RESUME_NONE to all connections waiting for a
|
|
677
756
|
* continuation stream to start, then clear the map.
|
|
@@ -681,9 +760,7 @@ declare class ContinuationState {
|
|
|
681
760
|
* Flush awaiting connections by notifying each one via the provided
|
|
682
761
|
* callback (typically sends STREAM_RESUMING), then clear.
|
|
683
762
|
*/
|
|
684
|
-
flushAwaitingConnections(
|
|
685
|
-
notify: (conn: ContinuationConnection) => void
|
|
686
|
-
): void;
|
|
763
|
+
flushAwaitingConnections(notify: (conn: TConnection) => void): void;
|
|
687
764
|
/**
|
|
688
765
|
* Transition pending → active. Called when the continuation stream
|
|
689
766
|
* actually starts. Moves request/connection IDs to active slots,
|
|
@@ -697,7 +774,9 @@ declare class ContinuationState {
|
|
|
697
774
|
* Returns the new pending state (so the host can enqueue the turn),
|
|
698
775
|
* or null if there was nothing deferred.
|
|
699
776
|
*/
|
|
700
|
-
activateDeferred(
|
|
777
|
+
activateDeferred(
|
|
778
|
+
generateRequestId: () => string
|
|
779
|
+
): ContinuationPending<TConnection> | null;
|
|
701
780
|
}
|
|
702
781
|
//#endregion
|
|
703
782
|
//#region src/chat/abort-registry.d.ts
|
|
@@ -810,6 +889,39 @@ declare function toolResultUpdate(
|
|
|
810
889
|
overrideState?: "output-error",
|
|
811
890
|
errorText?: string
|
|
812
891
|
): ToolPartUpdate;
|
|
892
|
+
/**
|
|
893
|
+
* Build an update descriptor for a terminal tool result that belongs to a
|
|
894
|
+
* tool part in a *different* (earlier) assistant message than the one
|
|
895
|
+
* currently being streamed.
|
|
896
|
+
*
|
|
897
|
+
* This is the "cross-message" case: an approved server tool executes during a
|
|
898
|
+
* continuation stream, but its tool part lives in the assistant message that
|
|
899
|
+
* originally requested it. `StreamAccumulator` surfaces this as a
|
|
900
|
+
* `cross-message-tool-update` action because the accumulator only owns the
|
|
901
|
+
* current turn's new content and cannot mutate a part from a prior message.
|
|
902
|
+
*
|
|
903
|
+
* Compared to {@link toolResultUpdate} this builder is deliberately more
|
|
904
|
+
* defensive, mirroring the equivalent fallback in `@cloudflare/ai-chat`:
|
|
905
|
+
*
|
|
906
|
+
* - It matches the broad set of pre-terminal **and** terminal states, so a
|
|
907
|
+
* provider that replays the entire prior tool round-trip during a
|
|
908
|
+
* continuation (notably the OpenAI Responses API — issue #1404) still
|
|
909
|
+
* resolves to the same part instead of silently missing it.
|
|
910
|
+
* - It is **first-write-wins**: a chunk arriving for a tool that already holds
|
|
911
|
+
* a terminal result is treated as a replay and the existing output is never
|
|
912
|
+
* overwritten. In that case `apply` returns the *same part reference*, which
|
|
913
|
+
* callers use as an idempotent-no-op signal to skip the durable write and a
|
|
914
|
+
* redundant `MESSAGE_UPDATED` broadcast.
|
|
915
|
+
* - It preserves a streamed `preliminary` flag when one is present, otherwise
|
|
916
|
+
* marks the result final (`preliminary: false`).
|
|
917
|
+
*/
|
|
918
|
+
declare function crossMessageToolResultUpdate(
|
|
919
|
+
toolCallId: string,
|
|
920
|
+
updateType: "output-available" | "output-error",
|
|
921
|
+
output?: unknown,
|
|
922
|
+
errorText?: string,
|
|
923
|
+
preliminary?: boolean
|
|
924
|
+
): ToolPartUpdate;
|
|
813
925
|
/**
|
|
814
926
|
* Build an update descriptor for applying a tool approval.
|
|
815
927
|
*
|
|
@@ -945,6 +1057,7 @@ type ChatFiberSnapshot<Kind extends string = string> = {
|
|
|
945
1057
|
kind: Kind;
|
|
946
1058
|
version: 1;
|
|
947
1059
|
requestId: string;
|
|
1060
|
+
recoveryRootRequestId?: string;
|
|
948
1061
|
continuation: boolean;
|
|
949
1062
|
latestMessageId?: string;
|
|
950
1063
|
latestMessageRole?: string;
|
|
@@ -956,6 +1069,7 @@ type ChatFiberSnapshot<Kind extends string = string> = {
|
|
|
956
1069
|
declare function createChatFiberSnapshot<Kind extends string>({
|
|
957
1070
|
kind,
|
|
958
1071
|
requestId,
|
|
1072
|
+
recoveryRootRequestId,
|
|
959
1073
|
continuation,
|
|
960
1074
|
messages,
|
|
961
1075
|
lastBody,
|
|
@@ -963,6 +1077,7 @@ declare function createChatFiberSnapshot<Kind extends string>({
|
|
|
963
1077
|
}: {
|
|
964
1078
|
kind: Kind;
|
|
965
1079
|
requestId: string;
|
|
1080
|
+
recoveryRootRequestId?: string;
|
|
966
1081
|
continuation: boolean;
|
|
967
1082
|
messages: UIMessage[];
|
|
968
1083
|
lastBody?: Record<string, unknown>;
|
|
@@ -994,7 +1109,9 @@ export {
|
|
|
994
1109
|
CHAT_MESSAGE_TYPES,
|
|
995
1110
|
type ChatFiberSnapshot,
|
|
996
1111
|
type ChatProtocolEvent,
|
|
1112
|
+
type ChatRecoveryConfig,
|
|
997
1113
|
type ChatRecoveryContext,
|
|
1114
|
+
type ChatRecoveryExhaustedContext,
|
|
998
1115
|
type ChatRecoveryOptions,
|
|
999
1116
|
type ChatResponseResult,
|
|
1000
1117
|
type ChunkAction,
|
|
@@ -1010,6 +1127,7 @@ export {
|
|
|
1010
1127
|
type MessageParts,
|
|
1011
1128
|
type NormalizedMessageConcurrency,
|
|
1012
1129
|
ROW_MAX_BYTES,
|
|
1130
|
+
type ResolvedChatRecoveryConfig,
|
|
1013
1131
|
ResumableStream,
|
|
1014
1132
|
type SaveMessagesOptions,
|
|
1015
1133
|
type SaveMessagesResult,
|
|
@@ -1031,6 +1149,7 @@ export {
|
|
|
1031
1149
|
createAgentToolEventState,
|
|
1032
1150
|
createChatFiberSnapshot,
|
|
1033
1151
|
createToolsFromClientSchemas,
|
|
1152
|
+
crossMessageToolResultUpdate,
|
|
1034
1153
|
enforceRowSizeLimit,
|
|
1035
1154
|
isReplayChunk,
|
|
1036
1155
|
parseProtocolMessage,
|