agents 0.13.2 → 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-Dn9n-3SI.d.ts → agent-tool-types-LInzZfLo.d.ts} +511 -124
- package/dist/agent-tool-types.d.ts +13 -11
- package/dist/{agent-tools-B1ttU-pq.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 +194 -22
- package/dist/chat/index.js +144 -11
- 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-DvcZnvQ1.js → compaction-helpers-BjT2NKRZ.js} +37 -9
- package/dist/compaction-helpers-BjT2NKRZ.js.map +1 -0
- package/dist/{compaction-helpers-DAe-xiVY.d.ts → compaction-helpers-DpP_XP9J.d.ts} +86 -29
- 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 +58 -23
- package/dist/experimental/memory/session/index.js +98 -9
- package/dist/experimental/memory/session/index.js.map +1 -1
- package/dist/experimental/memory/utils/index.d.ts +13 -11
- 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 +607 -97
- 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-DvcZnvQ1.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
|
|
|
@@ -317,17 +317,38 @@ type SaveMessagesOptions = {
|
|
|
317
317
|
* completion, either by `MSG_CHAT_CANCEL` over the chat WebSocket or
|
|
318
318
|
* by an external `AbortSignal` passed via {@link SaveMessagesOptions}.
|
|
319
319
|
* Partial chunks streamed before the abort are still persisted.
|
|
320
|
+
* - `"error"` — the turn ran but ended with a stream error. Partial chunks
|
|
321
|
+
* streamed before the error are still persisted.
|
|
320
322
|
*/
|
|
321
323
|
type SaveMessagesResult = {
|
|
322
|
-
/** Server-generated request ID for the chat turn. */ requestId: string /** Whether the turn
|
|
323
|
-
status:
|
|
324
|
+
/** Server-generated request ID for the chat turn. */ requestId: string /** Whether the turn completed, errored, was skipped, or was aborted. */;
|
|
325
|
+
status:
|
|
326
|
+
| "completed"
|
|
327
|
+
| "error"
|
|
328
|
+
| "skipped"
|
|
329
|
+
| "aborted" /** Error message when `status` is `"error"`. */;
|
|
330
|
+
error?: string;
|
|
324
331
|
};
|
|
325
332
|
/**
|
|
326
333
|
* Context passed to the `onChatRecovery` hook when an interrupted chat
|
|
327
334
|
* stream is detected after DO restart.
|
|
328
335
|
*/
|
|
329
336
|
type ChatRecoveryContext = {
|
|
330
|
-
/**
|
|
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. */;
|
|
331
352
|
requestId: string /** Partial text extracted from stored chunks. */;
|
|
332
353
|
partialText: string /** Partial message parts reconstructed from chunks. */;
|
|
333
354
|
partialParts: MessagePart[] /** Checkpoint data from `this.stash()` during the interrupted stream. */;
|
|
@@ -352,6 +373,59 @@ type ChatRecoveryOptions = {
|
|
|
352
373
|
/** Save the partial response from stored chunks. Default: true. */ persist?: boolean /** Schedule a continuation via `continueLastTurn()`. Default: true. */;
|
|
353
374
|
continue?: boolean;
|
|
354
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
|
+
};
|
|
355
429
|
/**
|
|
356
430
|
* Controls how overlapping user submit requests behave while another
|
|
357
431
|
* chat turn is already active or queued.
|
|
@@ -624,6 +698,7 @@ declare const CHAT_MESSAGE_TYPES: {
|
|
|
624
698
|
readonly TOOL_RESULT: "cf_agent_tool_result";
|
|
625
699
|
readonly TOOL_APPROVAL: "cf_agent_tool_approval";
|
|
626
700
|
readonly MESSAGE_UPDATED: "cf_agent_message_updated";
|
|
701
|
+
readonly CHAT_RECOVERING: "cf_agent_chat_recovering";
|
|
627
702
|
};
|
|
628
703
|
//#endregion
|
|
629
704
|
//#region src/chat/continuation-state.d.ts
|
|
@@ -637,9 +712,11 @@ interface ContinuationConnection {
|
|
|
637
712
|
readonly id: string;
|
|
638
713
|
send(message: string): void;
|
|
639
714
|
}
|
|
640
|
-
interface ContinuationPending
|
|
641
|
-
|
|
642
|
-
|
|
715
|
+
interface ContinuationPending<
|
|
716
|
+
TConnection extends ContinuationConnection = ContinuationConnection
|
|
717
|
+
> {
|
|
718
|
+
connection: TConnection;
|
|
719
|
+
connectionId: string | null;
|
|
643
720
|
requestId: string;
|
|
644
721
|
clientTools?: ClientToolSchema[];
|
|
645
722
|
body?: Record<string, unknown>;
|
|
@@ -647,24 +724,33 @@ interface ContinuationPending {
|
|
|
647
724
|
prerequisite: Promise<boolean> | null;
|
|
648
725
|
pastCoalesce: boolean;
|
|
649
726
|
}
|
|
650
|
-
interface ContinuationDeferred
|
|
651
|
-
|
|
652
|
-
|
|
727
|
+
interface ContinuationDeferred<
|
|
728
|
+
TConnection extends ContinuationConnection = ContinuationConnection
|
|
729
|
+
> {
|
|
730
|
+
connection: TConnection;
|
|
731
|
+
connectionId: string | null;
|
|
653
732
|
clientTools?: ClientToolSchema[];
|
|
654
733
|
body?: Record<string, unknown>;
|
|
655
734
|
errorPrefix: string;
|
|
656
735
|
prerequisite: Promise<boolean> | null;
|
|
657
736
|
}
|
|
658
|
-
declare class ContinuationState
|
|
659
|
-
|
|
660
|
-
|
|
737
|
+
declare class ContinuationState<
|
|
738
|
+
TConnection extends ContinuationConnection = ContinuationConnection
|
|
739
|
+
> {
|
|
740
|
+
pending: ContinuationPending<TConnection> | null;
|
|
741
|
+
deferred: ContinuationDeferred<TConnection> | null;
|
|
661
742
|
activeRequestId: string | null;
|
|
662
743
|
activeConnectionId: string | null;
|
|
663
|
-
awaitingConnections: Map<string,
|
|
744
|
+
awaitingConnections: Map<string, TConnection>;
|
|
664
745
|
/** Clear pending state and awaiting connections (without sending RESUME_NONE). */
|
|
665
746
|
clearPending(): void;
|
|
666
747
|
clearDeferred(): void;
|
|
667
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;
|
|
668
754
|
/**
|
|
669
755
|
* Send STREAM_RESUME_NONE to all connections waiting for a
|
|
670
756
|
* continuation stream to start, then clear the map.
|
|
@@ -674,9 +760,7 @@ declare class ContinuationState {
|
|
|
674
760
|
* Flush awaiting connections by notifying each one via the provided
|
|
675
761
|
* callback (typically sends STREAM_RESUMING), then clear.
|
|
676
762
|
*/
|
|
677
|
-
flushAwaitingConnections(
|
|
678
|
-
notify: (conn: ContinuationConnection) => void
|
|
679
|
-
): void;
|
|
763
|
+
flushAwaitingConnections(notify: (conn: TConnection) => void): void;
|
|
680
764
|
/**
|
|
681
765
|
* Transition pending → active. Called when the continuation stream
|
|
682
766
|
* actually starts. Moves request/connection IDs to active slots,
|
|
@@ -690,7 +774,9 @@ declare class ContinuationState {
|
|
|
690
774
|
* Returns the new pending state (so the host can enqueue the turn),
|
|
691
775
|
* or null if there was nothing deferred.
|
|
692
776
|
*/
|
|
693
|
-
activateDeferred(
|
|
777
|
+
activateDeferred(
|
|
778
|
+
generateRequestId: () => string
|
|
779
|
+
): ContinuationPending<TConnection> | null;
|
|
694
780
|
}
|
|
695
781
|
//#endregion
|
|
696
782
|
//#region src/chat/abort-registry.d.ts
|
|
@@ -803,6 +889,39 @@ declare function toolResultUpdate(
|
|
|
803
889
|
overrideState?: "output-error",
|
|
804
890
|
errorText?: string
|
|
805
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;
|
|
806
925
|
/**
|
|
807
926
|
* Build an update descriptor for applying a tool approval.
|
|
808
927
|
*
|
|
@@ -933,6 +1052,51 @@ declare function assistantContentKey(
|
|
|
933
1052
|
sanitize?: (message: UIMessage) => UIMessage
|
|
934
1053
|
): string | undefined;
|
|
935
1054
|
//#endregion
|
|
1055
|
+
//#region src/chat/recovery.d.ts
|
|
1056
|
+
type ChatFiberSnapshot<Kind extends string = string> = {
|
|
1057
|
+
kind: Kind;
|
|
1058
|
+
version: 1;
|
|
1059
|
+
requestId: string;
|
|
1060
|
+
recoveryRootRequestId?: string;
|
|
1061
|
+
continuation: boolean;
|
|
1062
|
+
latestMessageId?: string;
|
|
1063
|
+
latestMessageRole?: string;
|
|
1064
|
+
latestUserMessageId?: string;
|
|
1065
|
+
startedAt: number;
|
|
1066
|
+
lastBody?: Record<string, unknown>;
|
|
1067
|
+
lastClientTools?: ClientToolSchema[];
|
|
1068
|
+
};
|
|
1069
|
+
declare function createChatFiberSnapshot<Kind extends string>({
|
|
1070
|
+
kind,
|
|
1071
|
+
requestId,
|
|
1072
|
+
recoveryRootRequestId,
|
|
1073
|
+
continuation,
|
|
1074
|
+
messages,
|
|
1075
|
+
lastBody,
|
|
1076
|
+
lastClientTools
|
|
1077
|
+
}: {
|
|
1078
|
+
kind: Kind;
|
|
1079
|
+
requestId: string;
|
|
1080
|
+
recoveryRootRequestId?: string;
|
|
1081
|
+
continuation: boolean;
|
|
1082
|
+
messages: UIMessage[];
|
|
1083
|
+
lastBody?: Record<string, unknown>;
|
|
1084
|
+
lastClientTools?: ClientToolSchema[];
|
|
1085
|
+
}): ChatFiberSnapshot<Kind>;
|
|
1086
|
+
declare function wrapChatFiberSnapshot<Kind extends string>(
|
|
1087
|
+
key: string,
|
|
1088
|
+
snapshot: ChatFiberSnapshot<Kind>,
|
|
1089
|
+
user: unknown | null
|
|
1090
|
+
): Record<string, unknown>;
|
|
1091
|
+
declare function unwrapChatFiberSnapshot<Kind extends string>(
|
|
1092
|
+
key: string,
|
|
1093
|
+
value: unknown,
|
|
1094
|
+
expectedKind?: Kind
|
|
1095
|
+
): {
|
|
1096
|
+
snapshot: ChatFiberSnapshot<Kind> | null;
|
|
1097
|
+
user: unknown | null;
|
|
1098
|
+
};
|
|
1099
|
+
//#endregion
|
|
936
1100
|
export {
|
|
937
1101
|
AbortRegistry,
|
|
938
1102
|
type AgentToolEvent,
|
|
@@ -943,8 +1107,11 @@ export {
|
|
|
943
1107
|
type BroadcastStreamState,
|
|
944
1108
|
type TransitionResult as BroadcastTransitionResult,
|
|
945
1109
|
CHAT_MESSAGE_TYPES,
|
|
1110
|
+
type ChatFiberSnapshot,
|
|
946
1111
|
type ChatProtocolEvent,
|
|
1112
|
+
type ChatRecoveryConfig,
|
|
947
1113
|
type ChatRecoveryContext,
|
|
1114
|
+
type ChatRecoveryExhaustedContext,
|
|
948
1115
|
type ChatRecoveryOptions,
|
|
949
1116
|
type ChatResponseResult,
|
|
950
1117
|
type ChunkAction,
|
|
@@ -960,6 +1127,7 @@ export {
|
|
|
960
1127
|
type MessageParts,
|
|
961
1128
|
type NormalizedMessageConcurrency,
|
|
962
1129
|
ROW_MAX_BYTES,
|
|
1130
|
+
type ResolvedChatRecoveryConfig,
|
|
963
1131
|
ResumableStream,
|
|
964
1132
|
type SaveMessagesOptions,
|
|
965
1133
|
type SaveMessagesResult,
|
|
@@ -979,7 +1147,9 @@ export {
|
|
|
979
1147
|
transition as broadcastTransition,
|
|
980
1148
|
byteLength,
|
|
981
1149
|
createAgentToolEventState,
|
|
1150
|
+
createChatFiberSnapshot,
|
|
982
1151
|
createToolsFromClientSchemas,
|
|
1152
|
+
crossMessageToolResultUpdate,
|
|
983
1153
|
enforceRowSizeLimit,
|
|
984
1154
|
isReplayChunk,
|
|
985
1155
|
parseProtocolMessage,
|
|
@@ -987,6 +1157,8 @@ export {
|
|
|
987
1157
|
resolveToolMergeId,
|
|
988
1158
|
sanitizeMessage,
|
|
989
1159
|
toolApprovalUpdate,
|
|
990
|
-
toolResultUpdate
|
|
1160
|
+
toolResultUpdate,
|
|
1161
|
+
unwrapChatFiberSnapshot,
|
|
1162
|
+
wrapChatFiberSnapshot
|
|
991
1163
|
};
|
|
992
1164
|
//# sourceMappingURL=index.d.ts.map
|