agents 0.10.2 → 0.11.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/dist/browser/ai.d.ts +31 -0
- package/dist/browser/ai.js +54 -0
- package/dist/browser/ai.js.map +1 -0
- package/dist/browser/index.d.ts +51 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/tanstack-ai.d.ts +31 -0
- package/dist/browser/tanstack-ai.js +51 -0
- package/dist/browser/tanstack-ai.js.map +1 -0
- package/dist/classPrivateFieldGet2-BVdP0e3Z.js +27 -0
- package/dist/client.d.ts +2 -2
- package/dist/{compaction-helpers-BPE1_ziA.js → compaction-helpers-C_cN3z55.js} +1 -1
- package/dist/{compaction-helpers-BPE1_ziA.js.map → compaction-helpers-C_cN3z55.js.map} +1 -1
- package/dist/{compaction-helpers-BdQbZiML.d.ts → compaction-helpers-YzCLvunJ.d.ts} +1 -1
- package/dist/{do-oauth-client-provider-31gqR33H.d.ts → do-oauth-client-provider-C38aWbFV.d.ts} +1 -1
- package/dist/{email-Cql45SKP.d.ts → email-X72-zjuq.d.ts} +1 -1
- package/dist/email.d.ts +2 -2
- package/dist/experimental/memory/session/index.d.ts +1 -1
- package/dist/experimental/memory/session/index.js +1 -1
- package/dist/experimental/memory/utils/index.d.ts +1 -1
- package/dist/experimental/memory/utils/index.js +1 -1
- package/dist/{index-D2lfljd3.d.ts → index-CrOzHA2T.d.ts} +8 -8
- package/dist/{index-DDSX-g7W.d.ts → index-Cubsi2Qv.d.ts} +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3188 -2
- package/dist/index.js.map +1 -0
- package/dist/{internal_context-DuQZFvWI.d.ts → internal_context-BvuGZieY.d.ts} +1 -1
- package/dist/internal_context.d.ts +1 -1
- package/dist/mcp/client.d.ts +1 -1
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/observability/index.d.ts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/{retries-B_CN5KM9.d.ts → retries-JlwH9mnV.d.ts} +1 -1
- package/dist/retries.d.ts +1 -1
- package/dist/{serializable-DGdO8CDh.d.ts → serializable-Bg8ARWlN.d.ts} +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/shared-BUHZFGTk.d.ts +34 -0
- package/dist/shared-BtPEbm_U.js +437 -0
- package/dist/shared-BtPEbm_U.js.map +1 -0
- package/dist/{types-B9A8AU7B.d.ts → types-DAHCZC_W.d.ts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{workflow-types-XmOkuI7A.d.ts → workflow-types-DHs0L0KP.d.ts} +1 -1
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +2 -2
- package/dist/workflows.js +1 -1
- package/package.json +26 -9
- package/dist/src-f7-4oW_C.js +0 -3217
- package/dist/src-f7-4oW_C.js.map +0 -1
package/dist/mcp/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MessageType } from "../types.js";
|
|
2
|
-
import { o as getAgentByName, s as getCurrentAgent, t as Agent } from "../src-f7-4oW_C.js";
|
|
3
2
|
import { a as RPCServerTransport, i as RPCClientTransport, o as RPC_DO_PREFIX } from "../client-QBjFV5de.js";
|
|
3
|
+
import { Agent, getAgentByName, getCurrentAgent } from "../index.js";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
6
6
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as genericObservability, i as channels, n as Observability, o as subscribe, r as ObservabilityEvent, t as ChannelEventMap } from "../index-
|
|
1
|
+
import { a as genericObservability, i as channels, n as Observability, o as subscribe, r as ObservabilityEvent, t as ChannelEventMap } from "../index-Cubsi2Qv.js";
|
|
2
2
|
export { ChannelEventMap, Observability, ObservabilityEvent, channels, genericObservability, subscribe };
|
package/dist/react.d.ts
CHANGED
package/dist/retries.d.ts
CHANGED
package/dist/serializable.d.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/browser/shared.d.ts
|
|
2
|
+
interface BrowserToolsOptions {
|
|
3
|
+
/** Browser Rendering binding (Fetcher) — used in production */
|
|
4
|
+
browser?: Fetcher;
|
|
5
|
+
/** Optional CDP base URL override (e.g. http://localhost:9222) */
|
|
6
|
+
cdpUrl?: string;
|
|
7
|
+
/** Headers to send with CDP URL discovery requests (e.g. Access headers) */
|
|
8
|
+
cdpHeaders?: Record<string, string>;
|
|
9
|
+
/** Loader binding for sandboxed code execution */
|
|
10
|
+
loader: WorkerLoader;
|
|
11
|
+
/** Execution timeout in milliseconds (default: 30000) */
|
|
12
|
+
timeout?: number;
|
|
13
|
+
}
|
|
14
|
+
declare const SEARCH_DESCRIPTION =
|
|
15
|
+
'Search the Chrome DevTools Protocol spec using JavaScript code.\n\nAvailable in your code:\n\ndeclare const spec: {\n get(): Promise<{\n domains: Array<{\n name: string;\n description?: string;\n commands: Array<{ name: string; method: string; description?: string }>;\n events: Array<{ name: string; event: string; description?: string }>;\n types: Array<{ id: string; name: string; description?: string }>;\n }>;\n }>;\n};\n\nWrite an async arrow function in JavaScript. Do NOT use TypeScript syntax.\n\nExample:\nasync () => {\n const s = await spec.get();\n return s.domains\n .find(d => d.name === "Network")\n .commands.filter(c => c.description?.toLowerCase().includes("intercept"))\n .map(c => ({ method: c.method, description: c.description }));\n}';
|
|
16
|
+
declare const EXECUTE_DESCRIPTION =
|
|
17
|
+
'Execute CDP commands against a live browser session using JavaScript code.\n\nAvailable in your code:\n\ndeclare const cdp: {\n send(method: string, params?: unknown, options?: {\n timeoutMs?: number;\n sessionId?: string;\n }): Promise<unknown>;\n attachToTarget(targetId: string, options?: {\n timeoutMs?: number;\n }): Promise<string>;\n getDebugLog(limit?: number): Promise<unknown[]>;\n clearDebugLog(): Promise<void>;\n};\n\nWrite an async arrow function in JavaScript. Do NOT use TypeScript syntax.\n\nFor page-scoped commands such as Page.*, Runtime.*, and DOM.*, first create or select a target, call cdp.attachToTarget(targetId), and pass the returned sessionId in command options.\n\nExample:\nasync () => {\n return await cdp.send("Browser.getVersion");\n}\n\nPage example:\nasync () => {\n const { targetId } = await cdp.send("Target.createTarget", {\n url: "about:blank"\n });\n const sessionId = await cdp.attachToTarget(targetId);\n await cdp.send("Page.enable", {}, { sessionId });\n await cdp.send(\n "Page.navigate",\n { url: "https://example.com" },\n { sessionId }\n );\n const { result } = await cdp.send(\n "Runtime.evaluate",\n { expression: "document.title" },\n { sessionId }\n );\n return result.value;\n}';
|
|
18
|
+
interface ToolResult {
|
|
19
|
+
text: string;
|
|
20
|
+
isError?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare function createBrowserToolHandlers(options: BrowserToolsOptions): {
|
|
23
|
+
search: (code: string) => Promise<ToolResult>;
|
|
24
|
+
execute: (code: string) => Promise<ToolResult>;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export {
|
|
28
|
+
createBrowserToolHandlers as a,
|
|
29
|
+
ToolResult as i,
|
|
30
|
+
EXECUTE_DESCRIPTION as n,
|
|
31
|
+
SEARCH_DESCRIPTION as r,
|
|
32
|
+
BrowserToolsOptions as t
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=shared-BUHZFGTk.d.ts.map
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { a as _checkPrivateRedeclaration, i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "./classPrivateFieldGet2-BVdP0e3Z.js";
|
|
2
|
+
import { DynamicWorkerExecutor } from "@cloudflare/codemode";
|
|
3
|
+
//#region \0@oxc-project+runtime@0.124.0/helpers/classPrivateMethodInitSpec.js
|
|
4
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
5
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/browser/cdp-session.ts
|
|
9
|
+
const DEFAULT_TIMEOUT_MS = 1e4;
|
|
10
|
+
const MAX_DEBUG_ENTRIES = 400;
|
|
11
|
+
var _socket = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
var _nextId = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
var _pending = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
var _debugLog = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
var _defaultTimeoutMs = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
var _dispose = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
var _CdpSession_brand = /* @__PURE__ */ new WeakSet();
|
|
18
|
+
/**
|
|
19
|
+
* A CDP session over an open WebSocket. Manages command correlation,
|
|
20
|
+
* timeouts, target sessions, and a debug event ring buffer.
|
|
21
|
+
*
|
|
22
|
+
* Used host-side (not in the sandbox) — the sandbox calls into this
|
|
23
|
+
* via DynamicWorkerExecutor's ToolDispatcher RPC.
|
|
24
|
+
*/
|
|
25
|
+
var CdpSession = class {
|
|
26
|
+
constructor(socket, defaultTimeoutMs = DEFAULT_TIMEOUT_MS, dispose) {
|
|
27
|
+
_classPrivateMethodInitSpec(this, _CdpSession_brand);
|
|
28
|
+
_classPrivateFieldInitSpec(this, _socket, void 0);
|
|
29
|
+
_classPrivateFieldInitSpec(this, _nextId, 1);
|
|
30
|
+
_classPrivateFieldInitSpec(this, _pending, /* @__PURE__ */ new Map());
|
|
31
|
+
_classPrivateFieldInitSpec(this, _debugLog, []);
|
|
32
|
+
_classPrivateFieldInitSpec(this, _defaultTimeoutMs, void 0);
|
|
33
|
+
_classPrivateFieldInitSpec(this, _dispose, void 0);
|
|
34
|
+
_classPrivateFieldSet2(_socket, this, socket);
|
|
35
|
+
_classPrivateFieldSet2(_defaultTimeoutMs, this, defaultTimeoutMs);
|
|
36
|
+
_classPrivateFieldSet2(_dispose, this, dispose);
|
|
37
|
+
socket.addEventListener("message", (event) => _assertClassBrand(_CdpSession_brand, this, _handleMessage).call(this, event));
|
|
38
|
+
socket.addEventListener("error", () => {
|
|
39
|
+
_assertClassBrand(_CdpSession_brand, this, _rejectAll).call(this, /* @__PURE__ */ new Error("CDP socket error"));
|
|
40
|
+
});
|
|
41
|
+
socket.addEventListener("close", () => {
|
|
42
|
+
_assertClassBrand(_CdpSession_brand, this, _rejectAll).call(this, /* @__PURE__ */ new Error("CDP connection closed"));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
send(method, params, options = {}) {
|
|
46
|
+
var _this$nextId, _this$nextId2;
|
|
47
|
+
const id = (_classPrivateFieldSet2(_nextId, this, (_this$nextId = _classPrivateFieldGet2(_nextId, this), _this$nextId2 = _this$nextId++, _this$nextId)), _this$nextId2);
|
|
48
|
+
const timeoutMs = options.timeoutMs ?? _classPrivateFieldGet2(_defaultTimeoutMs, this);
|
|
49
|
+
const sessionId = typeof options.sessionId === "string" && options.sessionId.length > 0 ? options.sessionId : void 0;
|
|
50
|
+
const domain = typeof method === "string" ? method.split(".")[0] : "";
|
|
51
|
+
if (!sessionId && domain && !["Browser", "Target"].includes(domain)) _assertClassBrand(_CdpSession_brand, this, _recordDebug).call(this, "warning", {
|
|
52
|
+
id,
|
|
53
|
+
method,
|
|
54
|
+
reason: "target-scoped method sent without sessionId"
|
|
55
|
+
});
|
|
56
|
+
const result = new Promise((resolve, reject) => {
|
|
57
|
+
const startedAt = performance.now();
|
|
58
|
+
const timeoutId = setTimeout(() => {
|
|
59
|
+
_classPrivateFieldGet2(_pending, this).delete(id);
|
|
60
|
+
reject(/* @__PURE__ */ new Error(`CDP command timed out after ${timeoutMs}ms: ${method}`));
|
|
61
|
+
}, timeoutMs);
|
|
62
|
+
_classPrivateFieldGet2(_pending, this).set(id, {
|
|
63
|
+
resolve,
|
|
64
|
+
reject,
|
|
65
|
+
timeoutId,
|
|
66
|
+
method,
|
|
67
|
+
sessionId,
|
|
68
|
+
startedAt
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
_assertClassBrand(_CdpSession_brand, this, _recordDebug).call(this, "send", {
|
|
72
|
+
id,
|
|
73
|
+
method,
|
|
74
|
+
sessionId,
|
|
75
|
+
timeoutMs
|
|
76
|
+
});
|
|
77
|
+
_classPrivateFieldGet2(_socket, this).send(JSON.stringify({
|
|
78
|
+
id,
|
|
79
|
+
method,
|
|
80
|
+
params,
|
|
81
|
+
sessionId
|
|
82
|
+
}));
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
async attachToTarget(targetId, options = {}) {
|
|
86
|
+
if (typeof targetId !== "string" || !targetId) throw new Error("attachToTarget requires a targetId");
|
|
87
|
+
const sessionId = (await this.send("Target.attachToTarget", {
|
|
88
|
+
targetId,
|
|
89
|
+
flatten: true
|
|
90
|
+
}, { timeoutMs: options.timeoutMs }))?.sessionId ?? "";
|
|
91
|
+
if (!sessionId) throw new Error(`Target.attachToTarget did not return a sessionId for target ${targetId}`);
|
|
92
|
+
_assertClassBrand(_CdpSession_brand, this, _recordDebug).call(this, "attach", {
|
|
93
|
+
targetId,
|
|
94
|
+
sessionId
|
|
95
|
+
});
|
|
96
|
+
return sessionId;
|
|
97
|
+
}
|
|
98
|
+
getDebugLog(limit = 50) {
|
|
99
|
+
const normalized = Number.isFinite(limit) ? Math.max(1, Math.floor(limit)) : 50;
|
|
100
|
+
return _classPrivateFieldGet2(_debugLog, this).slice(-normalized);
|
|
101
|
+
}
|
|
102
|
+
clearDebugLog() {
|
|
103
|
+
_classPrivateFieldSet2(_debugLog, this, []);
|
|
104
|
+
}
|
|
105
|
+
close() {
|
|
106
|
+
_assertClassBrand(_CdpSession_brand, this, _rejectAll).call(this, /* @__PURE__ */ new Error("CDP session closed"));
|
|
107
|
+
try {
|
|
108
|
+
_classPrivateFieldGet2(_socket, this).close(1e3, "Done");
|
|
109
|
+
} catch {}
|
|
110
|
+
_classPrivateFieldGet2(_dispose, this)?.call(this);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
function _rejectAll(error) {
|
|
114
|
+
for (const [id, pending] of _classPrivateFieldGet2(_pending, this).entries()) {
|
|
115
|
+
clearTimeout(pending.timeoutId);
|
|
116
|
+
_classPrivateFieldGet2(_pending, this).delete(id);
|
|
117
|
+
pending.reject(error);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function _handleMessage(event) {
|
|
121
|
+
if (typeof event.data !== "string") return;
|
|
122
|
+
let payload;
|
|
123
|
+
try {
|
|
124
|
+
payload = JSON.parse(event.data);
|
|
125
|
+
} catch {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
_assertClassBrand(_CdpSession_brand, this, _recordDebug).call(this, "receive", {
|
|
129
|
+
id: payload.id,
|
|
130
|
+
method: payload.method,
|
|
131
|
+
sessionId: payload.sessionId,
|
|
132
|
+
hasError: !!payload.error
|
|
133
|
+
});
|
|
134
|
+
if (typeof payload.id !== "number") return;
|
|
135
|
+
const pending = _classPrivateFieldGet2(_pending, this).get(payload.id);
|
|
136
|
+
if (!pending) return;
|
|
137
|
+
clearTimeout(pending.timeoutId);
|
|
138
|
+
_classPrivateFieldGet2(_pending, this).delete(payload.id);
|
|
139
|
+
if (payload.error) {
|
|
140
|
+
const err = payload.error;
|
|
141
|
+
const code = err.code ?? "unknown";
|
|
142
|
+
const message = err.message ?? "CDP error";
|
|
143
|
+
pending.reject(/* @__PURE__ */ new Error(`CDP error ${code}: ${message} for ${pending.method}`));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
pending.resolve(payload.result);
|
|
147
|
+
}
|
|
148
|
+
function _recordDebug(type, data) {
|
|
149
|
+
_classPrivateFieldGet2(_debugLog, this).push({
|
|
150
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
151
|
+
type,
|
|
152
|
+
...data
|
|
153
|
+
});
|
|
154
|
+
if (_classPrivateFieldGet2(_debugLog, this).length > MAX_DEBUG_ENTRIES) _classPrivateFieldGet2(_debugLog, this).splice(0, _classPrivateFieldGet2(_debugLog, this).length - MAX_DEBUG_ENTRIES);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Connect to a browser via the Browser Rendering binding (Fetcher).
|
|
158
|
+
* Establishes a CDP WebSocket through the binding's fetch interface.
|
|
159
|
+
*/
|
|
160
|
+
async function connectBrowser(browser, timeoutMs) {
|
|
161
|
+
const response = await browser.fetch("https://localhost/v1/devtools/browser", { headers: { Upgrade: "websocket" } });
|
|
162
|
+
const ws = response.webSocket;
|
|
163
|
+
if (!ws) throw new Error("Browser Rendering binding did not return a WebSocket. Ensure the 'browser' binding is configured in wrangler.jsonc.");
|
|
164
|
+
const sessionId = response.headers.get("cf-browser-session-id");
|
|
165
|
+
if (!sessionId) throw new Error("Browser Rendering binding did not include a session ID when opening the CDP WebSocket");
|
|
166
|
+
ws.accept();
|
|
167
|
+
return new CdpSession(ws, timeoutMs, () => {
|
|
168
|
+
browser.fetch(`https://localhost/v1/devtools/browser/${sessionId}`, { method: "DELETE" });
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const LOCALHOST_HOSTS = new Set([
|
|
172
|
+
"localhost",
|
|
173
|
+
"127.0.0.1",
|
|
174
|
+
"0.0.0.0",
|
|
175
|
+
"::1",
|
|
176
|
+
"[::1]"
|
|
177
|
+
]);
|
|
178
|
+
/**
|
|
179
|
+
* Connect to a browser via a CDP base URL (e.g. http://localhost:9222).
|
|
180
|
+
* Discovers the WebSocket debugger URL via /json/version,
|
|
181
|
+
* rewrites localhost URLs to the base URL host, and opens the WebSocket.
|
|
182
|
+
*
|
|
183
|
+
* Useful for local development with `chrome --remote-debugging-port=9222`
|
|
184
|
+
* or when connecting through a tunnel.
|
|
185
|
+
*/
|
|
186
|
+
async function connectUrl(baseUrl, options) {
|
|
187
|
+
const endpoint = new URL("/json/version", baseUrl).toString();
|
|
188
|
+
const response = await fetch(endpoint, { headers: options?.headers });
|
|
189
|
+
if (!response.ok) throw new Error(`Failed to discover CDP endpoint at ${endpoint}: ${response.status}`);
|
|
190
|
+
const payload = await response.json();
|
|
191
|
+
if (!payload.webSocketDebuggerUrl) throw new Error("CDP /json/version did not include webSocketDebuggerUrl");
|
|
192
|
+
let wsUrl = payload.webSocketDebuggerUrl;
|
|
193
|
+
const parsed = new URL(wsUrl);
|
|
194
|
+
if (LOCALHOST_HOSTS.has(parsed.hostname)) {
|
|
195
|
+
const base = new URL(baseUrl);
|
|
196
|
+
parsed.hostname = base.hostname;
|
|
197
|
+
parsed.port = base.port;
|
|
198
|
+
parsed.protocol = base.protocol;
|
|
199
|
+
} else parsed.protocol = parsed.protocol === "wss:" ? "https:" : "http:";
|
|
200
|
+
const fetchUrl = parsed.toString();
|
|
201
|
+
const wsResponse = await fetch(fetchUrl, { headers: {
|
|
202
|
+
...options?.headers,
|
|
203
|
+
Upgrade: "websocket"
|
|
204
|
+
} });
|
|
205
|
+
const ws = wsResponse.webSocket;
|
|
206
|
+
if (!ws) throw new Error(`Failed to establish CDP WebSocket at ${fetchUrl} (status ${wsResponse.status})`);
|
|
207
|
+
ws.accept();
|
|
208
|
+
return new CdpSession(ws, options?.timeoutMs);
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/browser/truncate.ts
|
|
212
|
+
const CHARS_PER_TOKEN = 4;
|
|
213
|
+
const MAX_TOKENS = 6e3;
|
|
214
|
+
const MAX_CHARS = CHARS_PER_TOKEN * MAX_TOKENS;
|
|
215
|
+
function truncateResponse(content) {
|
|
216
|
+
const text = typeof content === "string" ? content : JSON.stringify(content, null, 2) ?? "null";
|
|
217
|
+
if (text.length <= MAX_CHARS) return text;
|
|
218
|
+
const estimatedTokens = Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
219
|
+
return `${text.slice(0, MAX_CHARS)}\n\n--- TRUNCATED ---\nResponse was ~${estimatedTokens.toLocaleString()} tokens (limit: ${MAX_TOKENS.toLocaleString()}). Use more specific queries to reduce response size.`;
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/browser/shared.ts
|
|
223
|
+
const specCache = /* @__PURE__ */ new Map();
|
|
224
|
+
const CACHE_TTL_MS = 300 * 1e3;
|
|
225
|
+
const SEARCH_DESCRIPTION = `Search the Chrome DevTools Protocol spec using JavaScript code.
|
|
226
|
+
|
|
227
|
+
Available in your code:
|
|
228
|
+
|
|
229
|
+
declare const spec: {
|
|
230
|
+
get(): Promise<{
|
|
231
|
+
domains: Array<{
|
|
232
|
+
name: string;
|
|
233
|
+
description?: string;
|
|
234
|
+
commands: Array<{ name: string; method: string; description?: string }>;
|
|
235
|
+
events: Array<{ name: string; event: string; description?: string }>;
|
|
236
|
+
types: Array<{ id: string; name: string; description?: string }>;
|
|
237
|
+
}>;
|
|
238
|
+
}>;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
Write an async arrow function in JavaScript. Do NOT use TypeScript syntax.
|
|
242
|
+
|
|
243
|
+
Example:
|
|
244
|
+
async () => {
|
|
245
|
+
const s = await spec.get();
|
|
246
|
+
return s.domains
|
|
247
|
+
.find(d => d.name === "Network")
|
|
248
|
+
.commands.filter(c => c.description?.toLowerCase().includes("intercept"))
|
|
249
|
+
.map(c => ({ method: c.method, description: c.description }));
|
|
250
|
+
}`;
|
|
251
|
+
function normalizeCdpSpec(spec) {
|
|
252
|
+
return { domains: (spec.domains ?? []).map((domain) => ({
|
|
253
|
+
name: domain.domain,
|
|
254
|
+
description: domain.description,
|
|
255
|
+
commands: (domain.commands ?? []).map((command) => ({
|
|
256
|
+
name: command.name,
|
|
257
|
+
method: `${domain.domain}.${command.name}`,
|
|
258
|
+
description: command.description
|
|
259
|
+
})),
|
|
260
|
+
events: (domain.events ?? []).map((event) => ({
|
|
261
|
+
name: event.name,
|
|
262
|
+
event: `${domain.domain}.${event.name}`,
|
|
263
|
+
description: event.description
|
|
264
|
+
})),
|
|
265
|
+
types: (domain.types ?? []).map((type) => ({
|
|
266
|
+
id: type.id,
|
|
267
|
+
name: `${domain.domain}.${type.id}`,
|
|
268
|
+
description: type.description
|
|
269
|
+
}))
|
|
270
|
+
})) };
|
|
271
|
+
}
|
|
272
|
+
function getSpecCacheKey(source, headers) {
|
|
273
|
+
const headerEntries = Object.entries(headers ?? {}).sort(([a], [b]) => a.localeCompare(b));
|
|
274
|
+
return `${source}:${JSON.stringify(headerEntries)}`;
|
|
275
|
+
}
|
|
276
|
+
async function getCachedSpec(key, load) {
|
|
277
|
+
const cached = specCache.get(key);
|
|
278
|
+
if (cached && Date.now() - cached.cachedAt < CACHE_TTL_MS) return cached.spec;
|
|
279
|
+
const spec = normalizeCdpSpec(await load());
|
|
280
|
+
specCache.set(key, {
|
|
281
|
+
spec,
|
|
282
|
+
cachedAt: Date.now()
|
|
283
|
+
});
|
|
284
|
+
return spec;
|
|
285
|
+
}
|
|
286
|
+
async function fetchCdpSpecFromUrl(cdpBaseUrl, headers) {
|
|
287
|
+
const endpoint = new URL("/json/protocol", cdpBaseUrl).toString();
|
|
288
|
+
return getCachedSpec(getSpecCacheKey(endpoint, headers), async () => {
|
|
289
|
+
const response = await fetch(endpoint, { headers });
|
|
290
|
+
if (!response.ok) throw new Error(`Failed to fetch CDP spec from ${endpoint}: ${response.status}`);
|
|
291
|
+
return await response.json();
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
async function fetchCdpSpecFromBrowser(browser) {
|
|
295
|
+
return getCachedSpec("browser-binding", async () => {
|
|
296
|
+
const createResponse = await browser.fetch("https://localhost/v1/devtools/browser", { method: "POST" });
|
|
297
|
+
if (!createResponse.ok) throw new Error(`Failed to create Browser Rendering session for protocol fetch: ${createResponse.status}`);
|
|
298
|
+
const sessionId = (await createResponse.json()).sessionId;
|
|
299
|
+
if (!sessionId) throw new Error("Browser Rendering session response did not include a sessionId");
|
|
300
|
+
try {
|
|
301
|
+
const response = await browser.fetch(`https://localhost/v1/devtools/browser/${sessionId}/json/protocol`);
|
|
302
|
+
if (!response.ok) throw new Error(`Failed to fetch CDP spec from Browser Rendering: ${response.status}`);
|
|
303
|
+
return await response.json();
|
|
304
|
+
} finally {
|
|
305
|
+
try {
|
|
306
|
+
await browser.fetch(`https://localhost/v1/devtools/browser/${sessionId}`, { method: "DELETE" });
|
|
307
|
+
} catch {}
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
const EXECUTE_DESCRIPTION = `Execute CDP commands against a live browser session using JavaScript code.
|
|
312
|
+
|
|
313
|
+
Available in your code:
|
|
314
|
+
|
|
315
|
+
declare const cdp: {
|
|
316
|
+
send(method: string, params?: unknown, options?: {
|
|
317
|
+
timeoutMs?: number;
|
|
318
|
+
sessionId?: string;
|
|
319
|
+
}): Promise<unknown>;
|
|
320
|
+
attachToTarget(targetId: string, options?: {
|
|
321
|
+
timeoutMs?: number;
|
|
322
|
+
}): Promise<string>;
|
|
323
|
+
getDebugLog(limit?: number): Promise<unknown[]>;
|
|
324
|
+
clearDebugLog(): Promise<void>;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
Write an async arrow function in JavaScript. Do NOT use TypeScript syntax.
|
|
328
|
+
|
|
329
|
+
For page-scoped commands such as Page.*, Runtime.*, and DOM.*, first create or select a target, call cdp.attachToTarget(targetId), and pass the returned sessionId in command options.
|
|
330
|
+
|
|
331
|
+
Example:
|
|
332
|
+
async () => {
|
|
333
|
+
return await cdp.send("Browser.getVersion");
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
Page example:
|
|
337
|
+
async () => {
|
|
338
|
+
const { targetId } = await cdp.send("Target.createTarget", {
|
|
339
|
+
url: "about:blank"
|
|
340
|
+
});
|
|
341
|
+
const sessionId = await cdp.attachToTarget(targetId);
|
|
342
|
+
await cdp.send("Page.enable", {}, { sessionId });
|
|
343
|
+
await cdp.send(
|
|
344
|
+
"Page.navigate",
|
|
345
|
+
{ url: "https://example.com" },
|
|
346
|
+
{ sessionId }
|
|
347
|
+
);
|
|
348
|
+
const { result } = await cdp.send(
|
|
349
|
+
"Runtime.evaluate",
|
|
350
|
+
{ expression: "document.title" },
|
|
351
|
+
{ sessionId }
|
|
352
|
+
);
|
|
353
|
+
return result.value;
|
|
354
|
+
}`;
|
|
355
|
+
function formatError(error) {
|
|
356
|
+
return error instanceof Error ? error.message : String(error);
|
|
357
|
+
}
|
|
358
|
+
let didWarnExperimental = false;
|
|
359
|
+
function createBrowserToolHandlers(options) {
|
|
360
|
+
if (!didWarnExperimental) {
|
|
361
|
+
didWarnExperimental = true;
|
|
362
|
+
console.warn("[agents/browser] Browser tools are experimental and may change in a future release.");
|
|
363
|
+
}
|
|
364
|
+
const executor = new DynamicWorkerExecutor({
|
|
365
|
+
loader: options.loader,
|
|
366
|
+
timeout: options.timeout
|
|
367
|
+
});
|
|
368
|
+
async function search(code) {
|
|
369
|
+
try {
|
|
370
|
+
let specSource;
|
|
371
|
+
if (options.cdpUrl) specSource = await fetchCdpSpecFromUrl(options.cdpUrl, options.cdpHeaders);
|
|
372
|
+
else if (options.browser) specSource = await fetchCdpSpecFromBrowser(options.browser);
|
|
373
|
+
else return {
|
|
374
|
+
text: "Either 'browser' (Fetcher binding) or 'cdpUrl' must be provided",
|
|
375
|
+
isError: true
|
|
376
|
+
};
|
|
377
|
+
const result = await executor.execute(code, [{
|
|
378
|
+
name: "spec",
|
|
379
|
+
fns: { get: async () => specSource }
|
|
380
|
+
}]);
|
|
381
|
+
if (result.error) return {
|
|
382
|
+
text: result.error,
|
|
383
|
+
isError: true
|
|
384
|
+
};
|
|
385
|
+
return { text: truncateResponse(result.result) };
|
|
386
|
+
} catch (error) {
|
|
387
|
+
return {
|
|
388
|
+
text: formatError(error),
|
|
389
|
+
isError: true
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
async function execute(code) {
|
|
394
|
+
let session;
|
|
395
|
+
try {
|
|
396
|
+
if (options.cdpUrl) session = await connectUrl(options.cdpUrl, {
|
|
397
|
+
timeoutMs: options.timeout,
|
|
398
|
+
headers: options.cdpHeaders
|
|
399
|
+
});
|
|
400
|
+
else if (options.browser) session = await connectBrowser(options.browser, options.timeout);
|
|
401
|
+
else return {
|
|
402
|
+
text: "Either 'browser' (Fetcher binding) or 'cdpUrl' must be provided",
|
|
403
|
+
isError: true
|
|
404
|
+
};
|
|
405
|
+
const result = await executor.execute(code, [{
|
|
406
|
+
name: "cdp",
|
|
407
|
+
fns: {
|
|
408
|
+
send: async (method, params, opts) => session.send(method, params, opts),
|
|
409
|
+
attachToTarget: async (targetId, opts) => session.attachToTarget(targetId, opts),
|
|
410
|
+
getDebugLog: async (limit) => session.getDebugLog(limit),
|
|
411
|
+
clearDebugLog: async () => session.clearDebugLog()
|
|
412
|
+
},
|
|
413
|
+
positionalArgs: true
|
|
414
|
+
}]);
|
|
415
|
+
if (result.error) return {
|
|
416
|
+
text: result.error,
|
|
417
|
+
isError: true
|
|
418
|
+
};
|
|
419
|
+
return { text: truncateResponse(result.result) };
|
|
420
|
+
} catch (error) {
|
|
421
|
+
return {
|
|
422
|
+
text: formatError(error),
|
|
423
|
+
isError: true
|
|
424
|
+
};
|
|
425
|
+
} finally {
|
|
426
|
+
session?.close();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return {
|
|
430
|
+
search,
|
|
431
|
+
execute
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
//#endregion
|
|
435
|
+
export { connectBrowser as a, CdpSession as i, SEARCH_DESCRIPTION as n, connectUrl as o, createBrowserToolHandlers as r, EXECUTE_DESCRIPTION as t };
|
|
436
|
+
|
|
437
|
+
//# sourceMappingURL=shared-BtPEbm_U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-BtPEbm_U.js","names":[],"sources":["../src/browser/cdp-session.ts","../src/browser/truncate.ts","../src/browser/shared.ts"],"sourcesContent":["interface PendingCommand {\n resolve: (result: unknown) => void;\n reject: (error: Error) => void;\n timeoutId: ReturnType<typeof setTimeout>;\n method: string;\n sessionId?: string;\n startedAt: number;\n}\n\ninterface DebugEntry {\n at: string;\n type: string;\n [key: string]: unknown;\n}\n\nexport interface CdpSendOptions {\n timeoutMs?: number;\n sessionId?: string;\n}\n\nexport interface CdpAttachOptions {\n timeoutMs?: number;\n}\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\nconst MAX_DEBUG_ENTRIES = 400;\n\n/**\n * A CDP session over an open WebSocket. Manages command correlation,\n * timeouts, target sessions, and a debug event ring buffer.\n *\n * Used host-side (not in the sandbox) — the sandbox calls into this\n * via DynamicWorkerExecutor's ToolDispatcher RPC.\n */\nexport class CdpSession {\n #socket: WebSocket;\n #nextId = 1;\n #pending = new Map<number, PendingCommand>();\n #debugLog: DebugEntry[] = [];\n #defaultTimeoutMs: number;\n #dispose?: () => void;\n\n constructor(\n socket: WebSocket,\n defaultTimeoutMs = DEFAULT_TIMEOUT_MS,\n dispose?: () => void\n ) {\n this.#socket = socket;\n this.#defaultTimeoutMs = defaultTimeoutMs;\n this.#dispose = dispose;\n\n socket.addEventListener(\"message\", (event) => this.#handleMessage(event));\n socket.addEventListener(\"error\", () => {\n this.#rejectAll(new Error(\"CDP socket error\"));\n });\n socket.addEventListener(\"close\", () => {\n this.#rejectAll(new Error(\"CDP connection closed\"));\n });\n }\n\n send(\n method: string,\n params?: unknown,\n options: CdpSendOptions = {}\n ): Promise<unknown> {\n const id = this.#nextId++;\n const timeoutMs = options.timeoutMs ?? this.#defaultTimeoutMs;\n const sessionId =\n typeof options.sessionId === \"string\" && options.sessionId.length > 0\n ? options.sessionId\n : undefined;\n\n const domain = typeof method === \"string\" ? method.split(\".\")[0] : \"\";\n if (!sessionId && domain && ![\"Browser\", \"Target\"].includes(domain)) {\n this.#recordDebug(\"warning\", {\n id,\n method,\n reason: \"target-scoped method sent without sessionId\"\n });\n }\n\n const result = new Promise<unknown>((resolve, reject) => {\n const startedAt = performance.now();\n const timeoutId = setTimeout(() => {\n this.#pending.delete(id);\n reject(\n new Error(`CDP command timed out after ${timeoutMs}ms: ${method}`)\n );\n }, timeoutMs);\n this.#pending.set(id, {\n resolve,\n reject,\n timeoutId,\n method,\n sessionId,\n startedAt\n });\n });\n\n this.#recordDebug(\"send\", { id, method, sessionId, timeoutMs });\n this.#socket.send(JSON.stringify({ id, method, params, sessionId }));\n return result;\n }\n\n async attachToTarget(\n targetId: string,\n options: CdpAttachOptions = {}\n ): Promise<string> {\n if (typeof targetId !== \"string\" || !targetId) {\n throw new Error(\"attachToTarget requires a targetId\");\n }\n\n const result = (await this.send(\n \"Target.attachToTarget\",\n {\n targetId,\n flatten: true\n },\n { timeoutMs: options.timeoutMs }\n )) as { sessionId?: string };\n\n const sessionId = result?.sessionId ?? \"\";\n if (!sessionId) {\n throw new Error(\n `Target.attachToTarget did not return a sessionId for target ${targetId}`\n );\n }\n\n this.#recordDebug(\"attach\", { targetId, sessionId });\n return sessionId;\n }\n\n getDebugLog(limit = 50): DebugEntry[] {\n const normalized = Number.isFinite(limit)\n ? Math.max(1, Math.floor(limit))\n : 50;\n return this.#debugLog.slice(-normalized);\n }\n\n clearDebugLog(): void {\n this.#debugLog = [];\n }\n\n close(): void {\n this.#rejectAll(new Error(\"CDP session closed\"));\n try {\n this.#socket.close(1000, \"Done\");\n } catch {\n // socket may already be closed\n }\n this.#dispose?.();\n }\n\n #rejectAll(error: Error): void {\n for (const [id, pending] of this.#pending.entries()) {\n clearTimeout(pending.timeoutId);\n this.#pending.delete(id);\n pending.reject(error);\n }\n }\n\n #handleMessage(event: MessageEvent): void {\n if (typeof event.data !== \"string\") {\n return;\n }\n\n let payload: Record<string, unknown>;\n try {\n payload = JSON.parse(event.data) as Record<string, unknown>;\n } catch {\n return;\n }\n\n this.#recordDebug(\"receive\", {\n id: payload.id,\n method: payload.method,\n sessionId: payload.sessionId,\n hasError: !!payload.error\n });\n\n if (typeof payload.id !== \"number\") {\n return;\n }\n\n const pending = this.#pending.get(payload.id);\n if (!pending) {\n return;\n }\n\n clearTimeout(pending.timeoutId);\n this.#pending.delete(payload.id);\n\n if (payload.error) {\n const err = payload.error as { code?: unknown; message?: string };\n const code = err.code ?? \"unknown\";\n const message = err.message ?? \"CDP error\";\n pending.reject(\n new Error(`CDP error ${code}: ${message} for ${pending.method}`)\n );\n return;\n }\n\n pending.resolve(payload.result);\n }\n\n #recordDebug(type: string, data: Record<string, unknown>): void {\n this.#debugLog.push({\n at: new Date().toISOString(),\n type,\n ...data\n });\n if (this.#debugLog.length > MAX_DEBUG_ENTRIES) {\n this.#debugLog.splice(0, this.#debugLog.length - MAX_DEBUG_ENTRIES);\n }\n }\n}\n\n/**\n * Connect to a browser via the Browser Rendering binding (Fetcher).\n * Establishes a CDP WebSocket through the binding's fetch interface.\n */\nexport async function connectBrowser(\n browser: Fetcher,\n timeoutMs?: number\n): Promise<CdpSession> {\n const response = await browser.fetch(\n \"https://localhost/v1/devtools/browser\",\n {\n headers: { Upgrade: \"websocket\" }\n }\n );\n\n const ws = response.webSocket;\n if (!ws) {\n throw new Error(\n \"Browser Rendering binding did not return a WebSocket. \" +\n \"Ensure the 'browser' binding is configured in wrangler.jsonc.\"\n );\n }\n\n const sessionId = response.headers.get(\"cf-browser-session-id\");\n if (!sessionId) {\n throw new Error(\n \"Browser Rendering binding did not include a session ID when opening the CDP WebSocket\"\n );\n }\n\n ws.accept();\n return new CdpSession(ws, timeoutMs, () => {\n void browser.fetch(`https://localhost/v1/devtools/browser/${sessionId}`, {\n method: \"DELETE\"\n });\n });\n}\n\nconst LOCALHOST_HOSTS = new Set([\n \"localhost\",\n \"127.0.0.1\",\n \"0.0.0.0\",\n \"::1\",\n \"[::1]\"\n]);\n\n/**\n * Connect to a browser via a CDP base URL (e.g. http://localhost:9222).\n * Discovers the WebSocket debugger URL via /json/version,\n * rewrites localhost URLs to the base URL host, and opens the WebSocket.\n *\n * Useful for local development with `chrome --remote-debugging-port=9222`\n * or when connecting through a tunnel.\n */\nexport async function connectUrl(\n baseUrl: string,\n options?: { timeoutMs?: number; headers?: Record<string, string> }\n): Promise<CdpSession> {\n const endpoint = new URL(\"/json/version\", baseUrl).toString();\n const response = await fetch(endpoint, {\n headers: options?.headers\n });\n if (!response.ok) {\n throw new Error(\n `Failed to discover CDP endpoint at ${endpoint}: ${response.status}`\n );\n }\n\n const payload = (await response.json()) as {\n webSocketDebuggerUrl?: string;\n };\n if (!payload.webSocketDebuggerUrl) {\n throw new Error(\"CDP /json/version did not include webSocketDebuggerUrl\");\n }\n\n let wsUrl = payload.webSocketDebuggerUrl;\n const parsed = new URL(wsUrl);\n if (LOCALHOST_HOSTS.has(parsed.hostname)) {\n const base = new URL(baseUrl);\n parsed.hostname = base.hostname;\n parsed.port = base.port;\n parsed.protocol = base.protocol;\n } else {\n // Workers runtime requires fetch + Upgrade header for outbound WebSockets\n parsed.protocol = parsed.protocol === \"wss:\" ? \"https:\" : \"http:\";\n }\n const fetchUrl = parsed.toString();\n\n const wsResponse = await fetch(fetchUrl, {\n headers: { ...options?.headers, Upgrade: \"websocket\" }\n });\n const ws = wsResponse.webSocket;\n if (!ws) {\n throw new Error(\n `Failed to establish CDP WebSocket at ${fetchUrl} (status ${wsResponse.status})`\n );\n }\n ws.accept();\n\n return new CdpSession(ws, options?.timeoutMs);\n}\n","const CHARS_PER_TOKEN = 4;\nconst MAX_TOKENS = 6000;\nconst MAX_CHARS = CHARS_PER_TOKEN * MAX_TOKENS;\n\nexport function truncateResponse(content: unknown): string {\n const text =\n typeof content === \"string\"\n ? content\n : (JSON.stringify(content, null, 2) ?? \"null\");\n if (text.length <= MAX_CHARS) {\n return text;\n }\n\n const estimatedTokens = Math.ceil(text.length / CHARS_PER_TOKEN);\n return `${text.slice(0, MAX_CHARS)}\\n\\n--- TRUNCATED ---\\nResponse was ~${estimatedTokens.toLocaleString()} tokens (limit: ${MAX_TOKENS.toLocaleString()}). Use more specific queries to reduce response size.`;\n}\n","import type { ResolvedProvider } from \"@cloudflare/codemode\";\nimport { DynamicWorkerExecutor } from \"@cloudflare/codemode\";\nimport { CdpSession, connectBrowser, connectUrl } from \"./cdp-session\";\nimport { truncateResponse } from \"./truncate\";\n\nexport interface BrowserToolsOptions {\n /** Browser Rendering binding (Fetcher) — used in production */\n browser?: Fetcher;\n /** Optional CDP base URL override (e.g. http://localhost:9222) */\n cdpUrl?: string;\n /** Headers to send with CDP URL discovery requests (e.g. Access headers) */\n cdpHeaders?: Record<string, string>;\n /** Loader binding for sandboxed code execution */\n loader: WorkerLoader;\n /** Execution timeout in milliseconds (default: 30000) */\n timeout?: number;\n}\n\ninterface RawCdpCommand {\n name: string;\n description?: string;\n}\n\ninterface RawCdpEvent {\n name: string;\n description?: string;\n}\n\ninterface RawCdpType {\n id: string;\n description?: string;\n}\n\n/** Raw CDP protocol domain from `/json/protocol` */\ninterface RawCdpDomain {\n domain: string;\n description?: string;\n commands?: RawCdpCommand[];\n events?: RawCdpEvent[];\n types?: RawCdpType[];\n}\n\ninterface SearchableCdpSpec {\n domains: Array<{\n name: string;\n description?: string;\n commands: Array<{ name: string; method: string; description?: string }>;\n events: Array<{ name: string; event: string; description?: string }>;\n types: Array<{ id: string; name: string; description?: string }>;\n }>;\n}\n\nconst specCache = new Map<\n string,\n { spec: SearchableCdpSpec; cachedAt: number }\n>();\n\nconst CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes\n\nexport const SEARCH_DESCRIPTION = `Search the Chrome DevTools Protocol spec using JavaScript code.\n\nAvailable in your code:\n\ndeclare const spec: {\n get(): Promise<{\n domains: Array<{\n name: string;\n description?: string;\n commands: Array<{ name: string; method: string; description?: string }>;\n events: Array<{ name: string; event: string; description?: string }>;\n types: Array<{ id: string; name: string; description?: string }>;\n }>;\n }>;\n};\n\nWrite an async arrow function in JavaScript. Do NOT use TypeScript syntax.\n\nExample:\nasync () => {\n const s = await spec.get();\n return s.domains\n .find(d => d.name === \"Network\")\n .commands.filter(c => c.description?.toLowerCase().includes(\"intercept\"))\n .map(c => ({ method: c.method, description: c.description }));\n}`;\n\nfunction normalizeCdpSpec(spec: {\n domains?: RawCdpDomain[];\n}): SearchableCdpSpec {\n return {\n domains: (spec.domains ?? []).map((domain) => ({\n name: domain.domain,\n description: domain.description,\n commands: (domain.commands ?? []).map((command) => ({\n name: command.name,\n method: `${domain.domain}.${command.name}`,\n description: command.description\n })),\n events: (domain.events ?? []).map((event) => ({\n name: event.name,\n event: `${domain.domain}.${event.name}`,\n description: event.description\n })),\n types: (domain.types ?? []).map((type) => ({\n id: type.id,\n name: `${domain.domain}.${type.id}`,\n description: type.description\n }))\n }))\n };\n}\n\nfunction getSpecCacheKey(\n source: string,\n headers?: Record<string, string>\n): string {\n const headerEntries = Object.entries(headers ?? {}).sort(([a], [b]) =>\n a.localeCompare(b)\n );\n return `${source}:${JSON.stringify(headerEntries)}`;\n}\n\nasync function getCachedSpec(\n key: string,\n load: () => Promise<{ domains?: RawCdpDomain[] }>\n): Promise<SearchableCdpSpec> {\n const cached = specCache.get(key);\n if (cached && Date.now() - cached.cachedAt < CACHE_TTL_MS) {\n return cached.spec;\n }\n\n const spec = normalizeCdpSpec(await load());\n specCache.set(key, { spec, cachedAt: Date.now() });\n return spec;\n}\n\nasync function fetchCdpSpecFromUrl(\n cdpBaseUrl: string,\n headers?: Record<string, string>\n): Promise<SearchableCdpSpec> {\n const endpoint = new URL(\"/json/protocol\", cdpBaseUrl).toString();\n\n return getCachedSpec(getSpecCacheKey(endpoint, headers), async () => {\n const response = await fetch(endpoint, { headers });\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch CDP spec from ${endpoint}: ${response.status}`\n );\n }\n\n return (await response.json()) as { domains?: RawCdpDomain[] };\n });\n}\n\nasync function fetchCdpSpecFromBrowser(\n browser: Fetcher\n): Promise<SearchableCdpSpec> {\n return getCachedSpec(\"browser-binding\", async () => {\n const createResponse = await browser.fetch(\n \"https://localhost/v1/devtools/browser\",\n {\n method: \"POST\"\n }\n );\n\n if (!createResponse.ok) {\n throw new Error(\n \"Failed to create Browser Rendering session for protocol fetch: \" +\n `${createResponse.status}`\n );\n }\n\n const payload = (await createResponse.json()) as { sessionId?: string };\n const sessionId = payload.sessionId;\n if (!sessionId) {\n throw new Error(\n \"Browser Rendering session response did not include a sessionId\"\n );\n }\n\n try {\n const response = await browser.fetch(\n `https://localhost/v1/devtools/browser/${sessionId}/json/protocol`\n );\n\n if (!response.ok) {\n throw new Error(\n \"Failed to fetch CDP spec from Browser Rendering: \" +\n `${response.status}`\n );\n }\n\n return (await response.json()) as { domains?: RawCdpDomain[] };\n } finally {\n try {\n await browser.fetch(\n `https://localhost/v1/devtools/browser/${sessionId}`,\n {\n method: \"DELETE\"\n }\n );\n } catch {\n // Cleanup failure should not mask the original result or error\n }\n }\n });\n}\n\nexport const EXECUTE_DESCRIPTION = `Execute CDP commands against a live browser session using JavaScript code.\n\nAvailable in your code:\n\ndeclare const cdp: {\n send(method: string, params?: unknown, options?: {\n timeoutMs?: number;\n sessionId?: string;\n }): Promise<unknown>;\n attachToTarget(targetId: string, options?: {\n timeoutMs?: number;\n }): Promise<string>;\n getDebugLog(limit?: number): Promise<unknown[]>;\n clearDebugLog(): Promise<void>;\n};\n\nWrite an async arrow function in JavaScript. Do NOT use TypeScript syntax.\n\nFor page-scoped commands such as Page.*, Runtime.*, and DOM.*, first create or select a target, call cdp.attachToTarget(targetId), and pass the returned sessionId in command options.\n\nExample:\nasync () => {\n return await cdp.send(\"Browser.getVersion\");\n}\n\nPage example:\nasync () => {\n const { targetId } = await cdp.send(\"Target.createTarget\", {\n url: \"about:blank\"\n });\n const sessionId = await cdp.attachToTarget(targetId);\n await cdp.send(\"Page.enable\", {}, { sessionId });\n await cdp.send(\n \"Page.navigate\",\n { url: \"https://example.com\" },\n { sessionId }\n );\n const { result } = await cdp.send(\n \"Runtime.evaluate\",\n { expression: \"document.title\" },\n { sessionId }\n );\n return result.value;\n}`;\n\nfunction formatError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport interface ToolResult {\n text: string;\n isError?: boolean;\n}\n\nlet didWarnExperimental = false;\n\nexport function createBrowserToolHandlers(options: BrowserToolsOptions) {\n if (!didWarnExperimental) {\n didWarnExperimental = true;\n console.warn(\n \"[agents/browser] Browser tools are experimental and may change in a future release.\"\n );\n }\n const executor = new DynamicWorkerExecutor({\n loader: options.loader,\n timeout: options.timeout\n });\n\n async function search(code: string): Promise<ToolResult> {\n try {\n let specSource: SearchableCdpSpec;\n\n if (options.cdpUrl) {\n specSource = await fetchCdpSpecFromUrl(\n options.cdpUrl,\n options.cdpHeaders\n );\n } else if (options.browser) {\n specSource = await fetchCdpSpecFromBrowser(options.browser);\n } else {\n return {\n text: \"Either 'browser' (Fetcher binding) or 'cdpUrl' must be provided\",\n isError: true\n };\n }\n\n const providers: ResolvedProvider[] = [\n {\n name: \"spec\",\n fns: { get: async () => specSource }\n }\n ];\n const result = await executor.execute(code, providers);\n if (result.error) {\n return { text: result.error, isError: true };\n }\n return { text: truncateResponse(result.result) };\n } catch (error) {\n return { text: formatError(error), isError: true };\n }\n }\n\n async function execute(code: string): Promise<ToolResult> {\n let session: CdpSession | undefined;\n try {\n if (options.cdpUrl) {\n session = await connectUrl(options.cdpUrl, {\n timeoutMs: options.timeout,\n headers: options.cdpHeaders\n });\n } else if (options.browser) {\n session = await connectBrowser(options.browser, options.timeout);\n } else {\n return {\n text: \"Either 'browser' (Fetcher binding) or 'cdpUrl' must be provided\",\n isError: true\n };\n }\n\n const providers: ResolvedProvider[] = [\n {\n name: \"cdp\",\n fns: {\n send: async (method: unknown, params: unknown, opts: unknown) =>\n session!.send(\n method as string,\n params,\n opts as { timeoutMs?: number; sessionId?: string }\n ),\n attachToTarget: async (targetId: unknown, opts: unknown) =>\n session!.attachToTarget(\n targetId as string,\n opts as { timeoutMs?: number }\n ),\n getDebugLog: async (limit: unknown) =>\n session!.getDebugLog(limit as number | undefined),\n clearDebugLog: async () => session!.clearDebugLog()\n },\n positionalArgs: true\n }\n ];\n\n const result = await executor.execute(code, providers);\n if (result.error) {\n return { text: result.error, isError: true };\n }\n return { text: truncateResponse(result.result) };\n } catch (error) {\n return { text: formatError(error), isError: true };\n } finally {\n session?.close();\n }\n }\n\n return { search, execute };\n}\n"],"mappings":";;;;;;;;AAwBA,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;;;;;;;;;;;;;;;AAS1B,IAAa,aAAb,MAAwB;CAQtB,YACE,QACA,mBAAmB,oBACnB,SACA;;mDAXiB;4CACT,EAAE;6DACD,IAAI,KAA6B,CAAC;8CACnB,EAAE,CAAC;6DACH;oDACJ;AAOpB,yBAAA,SAAA,MAAe,OAAM;AACrB,yBAAA,mBAAA,MAAyB,iBAAgB;AACzC,yBAAA,UAAA,MAAgB,QAAO;AAEvB,SAAO,iBAAiB,YAAY,UAAA,kBAAA,mBAAU,MAAA,eAAmB,CAAA,KAAA,MAAC,MAAM,CAAC;AACzE,SAAO,iBAAiB,eAAe;AACrC,qBAAA,mBAAA,MAAA,WAAe,CAAA,KAAA,sBAAC,IAAI,MAAM,mBAAmB,CAAC;IAC9C;AACF,SAAO,iBAAiB,eAAe;AACrC,qBAAA,mBAAA,MAAA,WAAe,CAAA,KAAA,sBAAC,IAAI,MAAM,wBAAwB,CAAC;IACnD;;CAGJ,KACE,QACA,QACA,UAA0B,EAAE,EACV;;EAClB,MAAM,MAAA,uBAAA,SAAK,OAAA,eAAA,uBAAA,SAAA,KAAA,EAAA,gBAAA,gBAAA,cAAc,EAAA;EACzB,MAAM,YAAY,QAAQ,aAAA,uBAAA,mBAAa,KAAsB;EAC7D,MAAM,YACJ,OAAO,QAAQ,cAAc,YAAY,QAAQ,UAAU,SAAS,IAChE,QAAQ,YACR,KAAA;EAEN,MAAM,SAAS,OAAO,WAAW,WAAW,OAAO,MAAM,IAAI,CAAC,KAAK;AACnE,MAAI,CAAC,aAAa,UAAU,CAAC,CAAC,WAAW,SAAS,CAAC,SAAS,OAAO,CACjE,mBAAA,mBAAA,MAAA,aAAiB,CAAA,KAAA,MAAC,WAAW;GAC3B;GACA;GACA,QAAQ;GACT,CAAC;EAGJ,MAAM,SAAS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;IACN,KAAK;KACH,MAAM,OAAO,QAAiB,QAAiB,SAC7C,QAAS,KACP,QACA,QACA,KACD;KACH,gBAAgB,OAAO,UAAmB,SACxC,QAAS,eACP,UACA,KACD;KACH,aAAa,OAAO,UAClB,QAAS,YAAY,MAA4B;KACnD,eAAe,YAAY,QAAS,eAAe;KACpD;IACD,gBAAgB;IACjB,CACF,CAEqD;AACtD,OAAI,OAAO,MACT,QAAO;IAAE,MAAM,OAAO;IAAO,SAAS;IAAM;AAE9C,UAAO,EAAE,MAAM,iBAAiB,OAAO,OAAO,EAAE;WACzC,OAAO;AACd,UAAO;IAAE,MAAM,YAAY,MAAM;IAAE,SAAS;IAAM;YAC1C;AACR,YAAS,OAAO;;;AAIpB,QAAO;EAAE;EAAQ;EAAS"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as MessageType } from "./types-
|
|
1
|
+
import { t as MessageType } from "./types-DAHCZC_W.js";
|
|
2
2
|
export { MessageType };
|
package/dist/workflow-types.d.ts
CHANGED
package/dist/workflows.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as Agent } from "./index-
|
|
1
|
+
import { r as Agent } from "./index-CrOzHA2T.js";
|
|
2
2
|
import {
|
|
3
3
|
S as WorkflowTrackingRow,
|
|
4
4
|
_ as WorkflowPage,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
v as WorkflowProgressCallback,
|
|
21
21
|
x as WorkflowStatus,
|
|
22
22
|
y as WorkflowQueryCriteria
|
|
23
|
-
} from "./workflow-types-
|
|
23
|
+
} from "./workflow-types-DHs0L0KP.js";
|
|
24
24
|
import { WorkflowEntrypoint } from "cloudflare:workers";
|
|
25
25
|
|
|
26
26
|
//#region src/workflows.d.ts
|
package/dist/workflows.js
CHANGED