agents 0.16.0 → 0.16.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-NofdbL9X.d.ts → agent-tool-types-CTw3UJUP.d.ts} +9 -1
- package/dist/agent-tool-types.d.ts +1 -1
- package/dist/{agent-tools-DLquv-dp.d.ts → agent-tools-DZhI5F6Q.d.ts} +2 -2
- package/dist/agent-tools.d.ts +1 -1
- package/dist/browser/ai.d.ts +91 -6
- package/dist/browser/ai.js +174 -7
- package/dist/browser/ai.js.map +1 -1
- package/dist/browser/index.d.ts +74 -22
- package/dist/browser/index.js +2 -2
- package/dist/browser/tanstack-ai.d.ts +4 -0
- package/dist/browser/tanstack-ai.js +8 -1
- package/dist/browser/tanstack-ai.js.map +1 -1
- package/dist/chat/index.d.ts +7 -6
- package/dist/chat/index.js +35 -14
- package/dist/chat/index.js.map +1 -1
- package/dist/chat-sdk/index.d.ts +1 -1
- package/dist/{client-FUizKzj2.js → client-BXJ9n2f7.js} +18 -2
- package/dist/client-BXJ9n2f7.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/{compaction-helpers-DVcu5lPN.d.ts → compaction-helpers-wUz6M3us.d.ts} +20 -1
- package/dist/{connector-D6yYzYHg.js → connector-CrKhowfD.js} +216 -5
- package/dist/connector-CrKhowfD.js.map +1 -0
- package/dist/connector-v2M1zlZp.d.ts +659 -0
- package/dist/experimental/memory/session/index.d.ts +1 -1
- package/dist/experimental/memory/session/index.js +20 -2
- package/dist/experimental/memory/session/index.js.map +1 -1
- package/dist/experimental/memory/utils/index.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/client.d.ts +1 -1
- package/dist/mcp/client.js +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/sub-routing.d.ts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/package.json +9 -4
- package/dist/client-FUizKzj2.js.map +0 -1
- package/dist/connector-D6yYzYHg.js.map +0 -1
- package/dist/connector-DXursxV5.d.ts +0 -340
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tanstack-ai.js","names":[],"sources":["../../src/browser/tanstack-ai.ts"],"sourcesContent":["import { toolDefinition } from \"@tanstack/ai\";\nimport type { ServerTool } from \"@tanstack/ai\";\nimport type { ProxyToolOutput } from \"@cloudflare/codemode\";\nimport { z } from \"zod\";\nimport { createBrowserRuntime, type CreateBrowserToolsOptions } from \"./ai\";\n\nexport type { CreateBrowserToolsOptions } from \"./ai\";\n\n/**\n * Create TanStack AI tools for browser automation via CDP code mode.\n *\n * Returns an array with a single durable `browser_execute` `ServerTool`\n * backed by the same codemode runtime as `agents/browser/ai` — the model\n * writes TypeScript against the `cdp` connector and browser sessions\n * survive pauses.\n *\n * @example\n * ```ts\n * import { createBrowserTools } from \"agents/browser/tanstack-ai\";\n * import { chat } from \"@tanstack/ai\";\n *\n * // inside a Durable Object / Agent:\n * const browserTools = createBrowserTools({\n * ctx: this.ctx,\n * browser: this.env.BROWSER,\n * loader: this.env.LOADER,\n * });\n *\n * const stream = chat({\n * adapter: openaiText(\"gpt-4o\"),\n * tools: [...browserTools, ...otherTools],\n * messages,\n * });\n * ```\n */\nexport function createBrowserTools(\n options: CreateBrowserToolsOptions\n): ServerTool[] {\n const { tools } = createBrowserRuntime(options);\n const executeTool = tools.browser_execute;\n\n const execute = toolDefinition({\n name: \"browser_execute\" as const,\n description: executeTool.description ?? \"\",\n inputSchema: z.object({\n code: z.string().meta({\n description:\n \"TypeScript async arrow function that uses the cdp connector\"\n })\n })\n }).server(async ({ code }) => {\n if (!executeTool.execute) {\n throw new Error(\"browser_execute tool is not executable\");\n }\n const result = (await executeTool.execute(\n { code },\n { toolCallId: crypto.randomUUID(), messages: [] }\n )) as ProxyToolOutput;\n return result;\n });\n\n return [execute];\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tanstack-ai.js","names":[],"sources":["../../src/browser/tanstack-ai.ts"],"sourcesContent":["import { toolDefinition } from \"@tanstack/ai\";\nimport type { ServerTool } from \"@tanstack/ai\";\nimport type { ProxyToolOutput } from \"@cloudflare/codemode\";\nimport { z } from \"zod\";\nimport { createBrowserRuntime, type CreateBrowserToolsOptions } from \"./ai\";\n\nexport type { CreateBrowserToolsOptions } from \"./ai\";\n\n/**\n * Create TanStack AI tools for browser automation via CDP code mode.\n *\n * Returns an array with a single durable `browser_execute` `ServerTool`\n * backed by the same codemode runtime as `agents/browser/ai` — the model\n * writes TypeScript against the `cdp` connector and browser sessions\n * survive pauses.\n *\n * The stateless Quick Action tools are not surfaced through this TanStack\n * wrapper (it exposes only `browser_execute`); use `createQuickActionTools`\n * from `agents/browser/ai` if you want them.\n *\n * @example\n * ```ts\n * import { createBrowserTools } from \"agents/browser/tanstack-ai\";\n * import { chat } from \"@tanstack/ai\";\n *\n * // inside a Durable Object / Agent:\n * const browserTools = createBrowserTools({\n * ctx: this.ctx,\n * browser: this.env.BROWSER,\n * loader: this.env.LOADER,\n * });\n *\n * const stream = chat({\n * adapter: openaiText(\"gpt-4o\"),\n * tools: [...browserTools, ...otherTools],\n * messages,\n * });\n * ```\n */\nexport function createBrowserTools(\n options: CreateBrowserToolsOptions\n): ServerTool[] {\n // This wrapper only surfaces `browser_execute`, so don't build the default-on\n // Quick Action tools just to discard them.\n const { tools } = createBrowserRuntime({ ...options, quickActions: false });\n const executeTool = tools.browser_execute;\n\n const execute = toolDefinition({\n name: \"browser_execute\" as const,\n description: executeTool.description ?? \"\",\n inputSchema: z.object({\n code: z.string().meta({\n description:\n \"TypeScript async arrow function that uses the cdp connector\"\n })\n })\n }).server(async ({ code }) => {\n if (!executeTool.execute) {\n throw new Error(\"browser_execute tool is not executable\");\n }\n const result = (await executeTool.execute(\n { code },\n { toolCallId: crypto.randomUUID(), messages: [] }\n )) as ProxyToolOutput;\n return result;\n });\n\n return [execute];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,mBACd,SACc;CAGd,MAAM,EAAE,UAAU,qBAAqB;EAAE,GAAG;EAAS,cAAc;CAAM,CAAC;CAC1E,MAAM,cAAc,MAAM;CAsB1B,OAAO,CApBS,eAAe;EAC7B,MAAM;EACN,aAAa,YAAY,eAAe;EACxC,aAAa,EAAE,OAAO,EACpB,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,EACpB,aACE,8DACJ,CAAC,EACH,CAAC;CACH,CAAC,CAAC,CAAC,OAAO,OAAO,EAAE,WAAW;EAC5B,IAAI,CAAC,YAAY,SACf,MAAM,IAAI,MAAM,wCAAwC;EAM1D,OAAO,MAJe,YAAY,QAChC,EAAE,KAAK,GACP;GAAE,YAAY,OAAO,WAAW;GAAG,UAAU,CAAC;EAAE,CAClD;CAEF,CAEc,CAAC;AACjB"}
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
d as AgentToolRunState,
|
|
4
4
|
i as AgentToolEventMessage,
|
|
5
5
|
r as AgentToolEvent
|
|
6
|
-
} from "../agent-tool-types-
|
|
6
|
+
} from "../agent-tool-types-CTw3UJUP.js";
|
|
7
7
|
import {
|
|
8
8
|
n as createAgentToolEventState,
|
|
9
9
|
t as applyAgentToolEvent
|
|
10
|
-
} from "../agent-tools-
|
|
10
|
+
} from "../agent-tools-DZhI5F6Q.js";
|
|
11
11
|
import { JSONSchema7, Tool, ToolSet, UIMessage } from "ai";
|
|
12
12
|
import { Connection } from "agents";
|
|
13
13
|
|
|
@@ -705,10 +705,11 @@ declare class ResumableStream {
|
|
|
705
705
|
private _lastCleanupTime;
|
|
706
706
|
constructor(sql: SqlTaggedTemplate);
|
|
707
707
|
/**
|
|
708
|
-
* Add
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
708
|
+
* Add metadata columns for rows created before they existed. Constructors
|
|
709
|
+
* intentionally do not run this: most wakes never start a stream, so paying a
|
|
710
|
+
* schema-introspection read every time is wasteful. New tables include these
|
|
711
|
+
* columns in CREATE TABLE; legacy tables migrate lazily only if a write/read
|
|
712
|
+
* discovers the columns are missing.
|
|
712
713
|
*/
|
|
713
714
|
private _migrateMetadataColumns;
|
|
714
715
|
get activeStreamId(): string | null;
|
package/dist/chat/index.js
CHANGED
|
@@ -602,6 +602,10 @@ function sendIfOpen$1(connection, message) {
|
|
|
602
602
|
function isWebSocketClosedSendError$1(error) {
|
|
603
603
|
return error instanceof TypeError && error.message.includes("WebSocket send() after close");
|
|
604
604
|
}
|
|
605
|
+
function isMissingMetadataColumnError(error) {
|
|
606
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
607
|
+
return (message.includes("message_id") || message.includes("is_continuation")) && (message.toLowerCase().includes("no such column") || message.toLowerCase().includes("has no column named"));
|
|
608
|
+
}
|
|
605
609
|
var ResumableStream = class ResumableStream {
|
|
606
610
|
constructor(sql) {
|
|
607
611
|
this.sql = sql;
|
|
@@ -626,18 +630,20 @@ var ResumableStream = class ResumableStream {
|
|
|
626
630
|
request_id text not null,
|
|
627
631
|
status text not null,
|
|
628
632
|
created_at integer not null,
|
|
629
|
-
completed_at integer
|
|
633
|
+
completed_at integer,
|
|
634
|
+
message_id text,
|
|
635
|
+
is_continuation integer
|
|
630
636
|
)`;
|
|
631
|
-
this._migrateMetadataColumns();
|
|
632
637
|
this.sql`create index if not exists idx_stream_chunks_stream_id
|
|
633
638
|
on cf_ai_chat_stream_chunks(stream_id, chunk_index)`;
|
|
634
639
|
this.restore();
|
|
635
640
|
}
|
|
636
641
|
/**
|
|
637
|
-
* Add
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
642
|
+
* Add metadata columns for rows created before they existed. Constructors
|
|
643
|
+
* intentionally do not run this: most wakes never start a stream, so paying a
|
|
644
|
+
* schema-introspection read every time is wasteful. New tables include these
|
|
645
|
+
* columns in CREATE TABLE; legacy tables migrate lazily only if a write/read
|
|
646
|
+
* discovers the columns are missing.
|
|
641
647
|
*/
|
|
642
648
|
_migrateMetadataColumns() {
|
|
643
649
|
const columns = this.sql`
|
|
@@ -677,10 +683,19 @@ var ResumableStream = class ResumableStream {
|
|
|
677
683
|
this._isLive = true;
|
|
678
684
|
this._activeIsContinuation = options.continuation ?? false;
|
|
679
685
|
const messageId = options.messageId ?? null;
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
686
|
+
try {
|
|
687
|
+
this.sql`
|
|
688
|
+
insert into cf_ai_chat_stream_metadata (id, request_id, status, created_at, message_id, is_continuation)
|
|
689
|
+
values (${streamId}, ${requestId}, 'streaming', ${Date.now()}, ${messageId}, ${this._activeIsContinuation ? 1 : 0})
|
|
690
|
+
`;
|
|
691
|
+
} catch (error) {
|
|
692
|
+
if (!isMissingMetadataColumnError(error)) throw error;
|
|
693
|
+
this._migrateMetadataColumns();
|
|
694
|
+
this.sql`
|
|
695
|
+
insert into cf_ai_chat_stream_metadata (id, request_id, status, created_at, message_id, is_continuation)
|
|
696
|
+
values (${streamId}, ${requestId}, 'streaming', ${Date.now()}, ${messageId}, ${this._activeIsContinuation ? 1 : 0})
|
|
697
|
+
`;
|
|
698
|
+
}
|
|
684
699
|
return streamId;
|
|
685
700
|
}
|
|
686
701
|
/**
|
|
@@ -690,10 +705,16 @@ var ResumableStream = class ResumableStream {
|
|
|
690
705
|
* is a legacy row written before the `message_id` column existed.
|
|
691
706
|
*/
|
|
692
707
|
getStreamMessageId(streamId) {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
708
|
+
let rows;
|
|
709
|
+
try {
|
|
710
|
+
rows = this.sql`
|
|
711
|
+
select message_id from cf_ai_chat_stream_metadata
|
|
712
|
+
where id = ${streamId}
|
|
713
|
+
`;
|
|
714
|
+
} catch (error) {
|
|
715
|
+
if (!isMissingMetadataColumnError(error)) throw error;
|
|
716
|
+
return null;
|
|
717
|
+
}
|
|
697
718
|
if (!rows || rows.length === 0) return null;
|
|
698
719
|
return rows[0].message_id ?? null;
|
|
699
720
|
}
|