agents 0.15.0 → 0.16.1

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.
Files changed (53) hide show
  1. package/dist/{agent-tool-types-VPsjVYL0.d.ts → agent-tool-types-NofdbL9X.d.ts} +57 -4
  2. package/dist/agent-tool-types.d.ts +1 -1
  3. package/dist/{agent-tools-BGpgfpJT.d.ts → agent-tools-DLquv-dp.d.ts} +2 -2
  4. package/dist/agent-tools.d.ts +1 -1
  5. package/dist/browser/ai.d.ts +211 -7
  6. package/dist/browser/ai.js +236 -25
  7. package/dist/browser/ai.js.map +1 -1
  8. package/dist/browser/index.d.ts +133 -69
  9. package/dist/browser/index.js +3 -2
  10. package/dist/browser/tanstack-ai.d.ts +17 -7
  11. package/dist/browser/tanstack-ai.js +25 -19
  12. package/dist/browser/tanstack-ai.js.map +1 -1
  13. package/dist/chat/index.d.ts +111 -5
  14. package/dist/chat/index.js +207 -35
  15. package/dist/chat/index.js.map +1 -1
  16. package/dist/chat-sdk/index.d.ts +1 -1
  17. package/dist/{classPrivateFieldGet2-Beqsfu2Z.js → classPrivateFieldGet2-CZ7QjTXN.js} +5 -5
  18. package/dist/{classPrivateMethodInitSpec-B5ko1s2R.js → classPrivateMethodInitSpec-D-0__zd9.js} +2 -2
  19. package/dist/client.d.ts +19 -2
  20. package/dist/client.js +31 -11
  21. package/dist/client.js.map +1 -1
  22. package/dist/{compaction-helpers-BEUILPss.d.ts → compaction-helpers-DVcu5lPN.d.ts} +91 -12
  23. package/dist/connector-CrKhowfD.js +1291 -0
  24. package/dist/connector-CrKhowfD.js.map +1 -0
  25. package/dist/connector-v2M1zlZp.d.ts +659 -0
  26. package/dist/experimental/memory/session/index.d.ts +75 -12
  27. package/dist/experimental/memory/session/index.js +226 -21
  28. package/dist/experimental/memory/session/index.js.map +1 -1
  29. package/dist/experimental/memory/utils/index.d.ts +2 -2
  30. package/dist/{index-CPe1OtI0.d.ts → index-B7IbEeze.d.ts} +32 -1
  31. package/dist/index.d.ts +8 -2
  32. package/dist/index.js +119 -45
  33. package/dist/index.js.map +1 -1
  34. package/dist/mcp/client.d.ts +1 -1
  35. package/dist/mcp/index.d.ts +1 -1
  36. package/dist/mcp/index.js +1 -1
  37. package/dist/mcp/index.js.map +1 -1
  38. package/dist/observability/index.d.ts +1 -1
  39. package/dist/react.d.ts +12 -1
  40. package/dist/react.js +101 -30
  41. package/dist/react.js.map +1 -1
  42. package/dist/{retries-CF_HKSlJ.d.ts → retries-CwlpAGet.d.ts} +35 -5
  43. package/dist/retries.d.ts +9 -5
  44. package/dist/retries.js +87 -1
  45. package/dist/retries.js.map +1 -1
  46. package/dist/serializable.d.ts +1 -1
  47. package/dist/skills/index.js +2 -2
  48. package/dist/sub-routing.d.ts +1 -1
  49. package/dist/workflows.d.ts +1 -1
  50. package/package.json +11 -11
  51. package/dist/shared-4CAYLCTO.d.ts +0 -34
  52. package/dist/shared-wyII629d.js +0 -432
  53. package/dist/shared-wyII629d.js.map +0 -1
@@ -0,0 +1,659 @@
1
+ import {
2
+ CodemodeConnector,
3
+ ConnectorTools,
4
+ ExecutionEndStatus,
5
+ PassEndStatus
6
+ } from "@cloudflare/codemode";
7
+
8
+ //#region src/browser/cdp-session.d.ts
9
+ interface DebugEntry {
10
+ at: string;
11
+ type: string;
12
+ [key: string]: unknown;
13
+ }
14
+ interface CdpSendOptions {
15
+ timeoutMs?: number;
16
+ sessionId?: string;
17
+ }
18
+ interface CdpAttachOptions {
19
+ timeoutMs?: number;
20
+ }
21
+ /**
22
+ * A CDP session over an open WebSocket. Manages command correlation,
23
+ * timeouts, target sessions, and a debug event ring buffer.
24
+ *
25
+ * Used host-side (not in the sandbox) — the sandbox calls into this
26
+ * via DynamicWorkerExecutor's ToolDispatcher RPC.
27
+ */
28
+ declare class CdpSession {
29
+ #private;
30
+ readonly sessionId?: string;
31
+ constructor(
32
+ socket: WebSocket,
33
+ defaultTimeoutMs?: number,
34
+ dispose?: () => void,
35
+ sessionId?: string
36
+ );
37
+ send(
38
+ method: string,
39
+ params?: unknown,
40
+ options?: CdpSendOptions
41
+ ): Promise<unknown>;
42
+ attachToTarget(targetId: string, options?: CdpAttachOptions): Promise<string>;
43
+ getDebugLog(limit?: number): DebugEntry[];
44
+ clearDebugLog(): void;
45
+ disconnect(): void;
46
+ close(): void;
47
+ }
48
+ /**
49
+ * Connect to a browser via a CDP base URL (e.g. http://localhost:9222).
50
+ * Discovers the WebSocket debugger URL via /json/version,
51
+ * rewrites localhost URLs to the base URL host, and opens the WebSocket.
52
+ *
53
+ * Useful for local development with `chrome --remote-debugging-port=9222`
54
+ * or when connecting through a tunnel.
55
+ */
56
+ declare function connectUrl(
57
+ baseUrl: string,
58
+ options?: {
59
+ timeoutMs?: number;
60
+ headers?: Record<string, string>;
61
+ }
62
+ ): Promise<CdpSession>;
63
+ //#endregion
64
+ //#region src/browser/browser-run.d.ts
65
+ /**
66
+ * A Browser Rendering binding. Structural so it accepts both the classic
67
+ * `Fetcher`-typed binding and the newer `BrowserRun` type generated by
68
+ * `wrangler types` — we only ever use its `fetch` surface.
69
+ */
70
+ interface BrowserBinding {
71
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
72
+ }
73
+ interface BrowserTargetInfo {
74
+ id: string;
75
+ type?: string;
76
+ url?: string;
77
+ title?: string;
78
+ description?: string;
79
+ devtoolsFrontendUrl?: string;
80
+ webSocketDebuggerUrl?: string;
81
+ }
82
+ interface BrowserSessionInfo {
83
+ sessionId: string;
84
+ targets?: BrowserTargetInfo[];
85
+ webSocketDebuggerUrl?: string;
86
+ }
87
+ interface ConnectBrowserOptions {
88
+ timeoutMs?: number;
89
+ keepAliveMs?: number;
90
+ includeTargets?: boolean;
91
+ /**
92
+ * Opt into Browser Run [session recording](https://developers.cloudflare.com/browser-run/features/session-recording/):
93
+ * an rrweb capture of DOM changes, input, and navigation, finalized when the
94
+ * session closes. Set at session-launch time. Retrieve later with
95
+ * {@link getBrowserRecording}.
96
+ */
97
+ recording?: boolean;
98
+ }
99
+ /** An rrweb session recording for a closed Browser Run session. */
100
+ interface BrowserRecording {
101
+ sessionId: string;
102
+ /** Recording length in milliseconds. */
103
+ duration: number;
104
+ /**
105
+ * rrweb event arrays keyed by CDP target id (one per tab). Each value can be
106
+ * passed directly to `rrweb-player` to replay that tab.
107
+ */
108
+ events: Record<string, unknown[]>;
109
+ }
110
+ declare class BrowserRenderingError extends Error {
111
+ readonly status: number;
112
+ constructor(message: string, status: number);
113
+ }
114
+ declare function createBrowserSession(
115
+ browser: BrowserBinding,
116
+ options?: {
117
+ keepAliveMs?: number;
118
+ includeTargets?: boolean;
119
+ recording?: boolean;
120
+ }
121
+ ): Promise<BrowserSessionInfo>;
122
+ declare function listBrowserTargets(
123
+ browser: BrowserBinding,
124
+ sessionId: string
125
+ ): Promise<BrowserTargetInfo[]>;
126
+ declare function deleteBrowserSession(
127
+ browser: BrowserBinding,
128
+ sessionId: string
129
+ ): Promise<void>;
130
+ /**
131
+ * Connect to a Browser Rendering session and delete it when closed.
132
+ */
133
+ declare function connectBrowser(
134
+ browser: BrowserBinding,
135
+ options?: number | ConnectBrowserOptions
136
+ ): Promise<CdpSession>;
137
+ /**
138
+ * Fetch a Browser Run [session recording](https://developers.cloudflare.com/browser-run/features/session-recording/)
139
+ * by session id, via the Browser Rendering REST API.
140
+ *
141
+ * A recording is only available **after** the session closes (explicit
142
+ * `closeSession()`, idle `keep_alive` expiry, or sweep) and is retained for 30
143
+ * days. Capture the session id while the session is alive — e.g. from
144
+ * `connector.liveView()`/`sessionInfo()` — then call this once it has ended.
145
+ *
146
+ * Unlike the binding-based helpers, this hits `api.cloudflare.com` directly, so
147
+ * it needs an account id and an API token with `Browser Rendering` read access
148
+ * (the Workers Browser Run binding cannot read recordings).
149
+ */
150
+ declare function getBrowserRecording(options: {
151
+ accountId: string;
152
+ apiToken: string;
153
+ sessionId: string /** Override for testing; defaults to the global `fetch`. */;
154
+ fetchImpl?: typeof fetch;
155
+ }): Promise<BrowserRecording>;
156
+ /**
157
+ * Connect to an existing Browser Rendering session without deleting it on close.
158
+ */
159
+ declare function connectBrowserSession(
160
+ browser: BrowserBinding,
161
+ sessionId: string,
162
+ timeoutMs?: number
163
+ ): Promise<CdpSession>;
164
+ //#endregion
165
+ //#region src/browser/quick-actions.d.ts
166
+ /**
167
+ * A Browser Run binding that supports [Quick Actions](https://developers.cloudflare.com/browser-run/quick-actions/).
168
+ *
169
+ * This is the `quickAction()` surface of the `BrowserRun` binding generated by
170
+ * `wrangler types`. Quick Actions are stateless one-shot tasks (screenshot,
171
+ * PDF, markdown, structured extraction, …) — no session, no token, just the
172
+ * binding.
173
+ *
174
+ * Requires a Worker `compatibility_date` of `2026-03-24` or later, and
175
+ * `remote: true` on the browser binding for local `wrangler dev`.
176
+ */
177
+ interface QuickActionBinding {
178
+ quickAction(action: string, options: unknown): Promise<Response>;
179
+ }
180
+ /** The Quick Action endpoints exposed by Browser Run. */
181
+ type QuickAction =
182
+ | "content"
183
+ | "screenshot"
184
+ | "pdf"
185
+ | "markdown"
186
+ | "snapshot"
187
+ | "scrape"
188
+ | "json"
189
+ | "links"
190
+ | "crawl";
191
+ type GotoOptions = {
192
+ waitUntil?: "load" | "domcontentloaded" | "networkidle0" | "networkidle2";
193
+ timeout?: number;
194
+ };
195
+ /** Options accepted by every Quick Action endpoint. */
196
+ interface QuickActionCommonOptions {
197
+ gotoOptions?: GotoOptions;
198
+ viewport?: {
199
+ width: number;
200
+ height: number;
201
+ deviceScaleFactor?: number;
202
+ };
203
+ cookies?: unknown[];
204
+ authenticate?: {
205
+ username: string;
206
+ password: string;
207
+ };
208
+ setExtraHTTPHeaders?: Record<string, string>;
209
+ userAgent?: string;
210
+ /** Regex strings for requests to drop before render (e.g. `["/\\.css$/"]`). */
211
+ rejectRequestPattern?: string[];
212
+ }
213
+ /**
214
+ * The page a Quick Action operates on: a `url` to load, or raw `html` to
215
+ * render. Exactly one is required.
216
+ */
217
+ type QuickActionPage =
218
+ | ({
219
+ url: string;
220
+ html?: never;
221
+ } & QuickActionCommonOptions)
222
+ | ({
223
+ html: string;
224
+ url?: never;
225
+ } & QuickActionCommonOptions);
226
+ /** Input for the AI-powered `/json` extraction endpoint. */
227
+ type QuickActionExtractInput = QuickActionPage & {
228
+ /** Natural-language instruction for what to extract. */ prompt?: string /** A JSON Schema describing the desired output shape. */;
229
+ response_format?: {
230
+ type: "json_schema";
231
+ schema: unknown;
232
+ } /** Bring-your-own model(s), tried in order, for extraction. */;
233
+ custom_ai?: {
234
+ model: string;
235
+ authorization: string;
236
+ }[];
237
+ };
238
+ /** Input for the `/scrape` endpoint. */
239
+ type QuickActionScrapeInput = QuickActionPage & {
240
+ elements: {
241
+ selector: string;
242
+ }[];
243
+ };
244
+ /** Input for the `/screenshot` endpoint. */
245
+ type QuickActionScreenshotInput = QuickActionPage & {
246
+ screenshotOptions?: Record<string, unknown>;
247
+ selector?: string;
248
+ };
249
+ /** Binary output (screenshot or PDF) with its reported content type. */
250
+ interface QuickActionBinary {
251
+ data: Uint8Array;
252
+ contentType: string;
253
+ }
254
+ /** Any Quick Action input accepted by the typed helpers. */
255
+ type QuickActionInput =
256
+ | QuickActionPage
257
+ | QuickActionExtractInput
258
+ | QuickActionScrapeInput
259
+ | QuickActionScreenshotInput;
260
+ /** Elements matched by one selector via `/scrape`. */
261
+ interface QuickActionScrapeResult {
262
+ selector: string;
263
+ results: {
264
+ html: string;
265
+ text: string;
266
+ width: number;
267
+ height: number;
268
+ top: number;
269
+ left: number;
270
+ attributes: {
271
+ name: string;
272
+ value: string;
273
+ }[];
274
+ }[];
275
+ }
276
+ /** Result of a `/snapshot` request: rendered HTML plus a base64 screenshot. */
277
+ interface QuickActionSnapshot {
278
+ /** HTML content of the page. */
279
+ content: string;
280
+ /** Base64-encoded screenshot image. */
281
+ screenshot: string;
282
+ }
283
+ /**
284
+ * Run a Quick Action and return the raw {@link Response} from the binding.
285
+ *
286
+ * Most callers want a typed helper ({@link browserMarkdown},
287
+ * {@link browserExtract}, …) instead; reach for this only when you need an
288
+ * endpoint or option not yet wrapped. The per-action overloads type `params`
289
+ * against the action when it is a string literal (e.g. `"json"` requires a
290
+ * {@link QuickActionExtractInput}); any {@link QuickActionInput} is accepted
291
+ * otherwise.
292
+ */
293
+ declare function runQuickAction(
294
+ browser: QuickActionBinding,
295
+ action: "json",
296
+ params: QuickActionExtractInput
297
+ ): Promise<Response>;
298
+ declare function runQuickAction(
299
+ browser: QuickActionBinding,
300
+ action: "scrape",
301
+ params: QuickActionScrapeInput
302
+ ): Promise<Response>;
303
+ declare function runQuickAction(
304
+ browser: QuickActionBinding,
305
+ action: "screenshot",
306
+ params: QuickActionScreenshotInput
307
+ ): Promise<Response>;
308
+ declare function runQuickAction(
309
+ browser: QuickActionBinding,
310
+ action: QuickAction,
311
+ params: QuickActionInput
312
+ ): Promise<Response>;
313
+ /** Fetch a page's fully rendered HTML via `/content`. */
314
+ declare function browserContent(
315
+ browser: QuickActionBinding,
316
+ input: QuickActionPage
317
+ ): Promise<string>;
318
+ /** Convert a page (or raw HTML) to Markdown via `/markdown`. */
319
+ declare function browserMarkdown(
320
+ browser: QuickActionBinding,
321
+ input: QuickActionPage
322
+ ): Promise<string>;
323
+ /**
324
+ * Extract structured data from a page with AI via `/json`. Provide a `prompt`,
325
+ * a `response_format` JSON Schema, or both.
326
+ */
327
+ declare function browserExtract<T = unknown>(
328
+ browser: QuickActionBinding,
329
+ input: QuickActionExtractInput
330
+ ): Promise<T>;
331
+ /** Retrieve every link on a page via `/links`. */
332
+ declare function browserLinks(
333
+ browser: QuickActionBinding,
334
+ input: QuickActionPage
335
+ ): Promise<string[]>;
336
+ /** Scrape specific elements (by CSS selector) via `/scrape`. */
337
+ declare function browserScrape(
338
+ browser: QuickActionBinding,
339
+ input: QuickActionScrapeInput
340
+ ): Promise<QuickActionScrapeResult[]>;
341
+ /** Capture rendered HTML plus a base64 screenshot in one request via `/snapshot`. */
342
+ declare function browserSnapshot(
343
+ browser: QuickActionBinding,
344
+ input: QuickActionPage
345
+ ): Promise<QuickActionSnapshot>;
346
+ /**
347
+ * Render a screenshot via `/screenshot`. Returns the raw bytes and their
348
+ * content type — by default a PNG (`image/png`). Note that passing
349
+ * `screenshotOptions.encoding: "base64"` makes the service return a `text/plain`
350
+ * data-URI string instead of binary, which this helper hands back verbatim.
351
+ */
352
+ declare function browserScreenshot(
353
+ browser: QuickActionBinding,
354
+ input: QuickActionScreenshotInput
355
+ ): Promise<QuickActionBinary>;
356
+ /** Render a PDF via `/pdf`. Returns the PDF bytes. */
357
+ declare function browserPdf(
358
+ browser: QuickActionBinding,
359
+ input: QuickActionPage
360
+ ): Promise<QuickActionBinary>;
361
+ //#endregion
362
+ //#region src/browser/session-manager.d.ts
363
+ type MaybePromise<T> = T | Promise<T>;
364
+ interface StoredBrowserSession {
365
+ sessionId: string;
366
+ createdAt: number;
367
+ updatedAt: number;
368
+ /**
369
+ * Set when a sweep closed this entry's Browser Run session but kept the
370
+ * entry as a tombstone, so a later resume of the owning execution fails
371
+ * loudly instead of silently continuing in a fresh browser.
372
+ */
373
+ closedAt?: number;
374
+ }
375
+ interface BrowserSessionLock {
376
+ release(): MaybePromise<void>;
377
+ }
378
+ interface BrowserSessionStore {
379
+ /**
380
+ * Acquire an exclusive lock for this session key. The lock must serialize
381
+ * all holders using the same key. Held only around storage reads/writes —
382
+ * never across Browser Rendering network calls.
383
+ */
384
+ acquireLock(key: string): MaybePromise<BrowserSessionLock>;
385
+ get(key: string): MaybePromise<StoredBrowserSession | undefined>;
386
+ set(key: string, session: StoredBrowserSession): MaybePromise<void>;
387
+ delete(key: string): MaybePromise<void>;
388
+ /**
389
+ * List stored sessions by key prefix. Optional — used by sweeps to find
390
+ * orphaned per-execution sessions; without it only the shared session key
391
+ * is swept.
392
+ */
393
+ list?(prefix: string): MaybePromise<Map<string, StoredBrowserSession>>;
394
+ }
395
+ declare class DurableBrowserSessionStore implements BrowserSessionStore {
396
+ #private;
397
+ private readonly storage;
398
+ constructor(storage: DurableObjectStorage);
399
+ acquireLock(key: string): Promise<BrowserSessionLock>;
400
+ get(key: string): Promise<StoredBrowserSession | undefined>;
401
+ set(key: string, session: StoredBrowserSession): Promise<void>;
402
+ delete(key: string): Promise<void>;
403
+ list(prefix: string): Promise<Map<string, StoredBrowserSession>>;
404
+ }
405
+ /**
406
+ * Default idle window used by {@link BrowserConnector.sweep} for the shared
407
+ * (reuse/promoted) session entry.
408
+ */
409
+ declare const DEFAULT_SWEEP_IDLE_MS: number;
410
+ //#endregion
411
+ //#region src/browser/connector.d.ts
412
+ /** Browser session lifecycle for the connector (binding-backed only). */
413
+ interface BrowserConnectorSessionOptions {
414
+ /**
415
+ * - `"one-shot"` (default) — one Browser Run session per codemode
416
+ * execution, deleted when the execution ends.
417
+ * - `"reuse"` — all executions share one stored session under `key`.
418
+ * - `"dynamic"` — per-execution sessions by default; the model can call
419
+ * `cdp.startSession()` to promote the current session into the shared
420
+ * slot so later executions reuse it.
421
+ */
422
+ mode?: "one-shot" | "reuse" | "dynamic";
423
+ /** Logical owner key for the shared (reuse/promoted) session. Default `"default"`. */
424
+ key?: string;
425
+ /** Browser Run inactivity timeout. Browser Run currently caps this server-side. */
426
+ keepAliveMs?: number;
427
+ /**
428
+ * Opt into Browser Run [session recording](https://developers.cloudflare.com/browser-run/features/session-recording/)
429
+ * for sessions this connector creates: an rrweb capture of everything the
430
+ * agent did, finalized when the session closes. Retrieve it afterward with
431
+ * {@link getBrowserRecording} using the session id from
432
+ * {@link BrowserConnector.liveView}/`sessionInfo()`.
433
+ */
434
+ recording?: boolean;
435
+ }
436
+ type BrowserConnectorOptions = (
437
+ | {
438
+ /** Browser Rendering binding (Fetcher) — used in production. */ browser: BrowserBinding;
439
+ /**
440
+ * Durable store for Browser Run session ids. Required with the binding:
441
+ * a session must survive a pause (approval) and resume on a fresh
442
+ * instance, so its id cannot live in connector memory.
443
+ */
444
+ store: BrowserSessionStore;
445
+ session?: BrowserConnectorSessionOptions;
446
+ cdpUrl?: never;
447
+ cdpHeaders?: never;
448
+ }
449
+ | {
450
+ /**
451
+ * CDP base URL override (e.g. http://localhost:9222). The browser is
452
+ * externally managed: no Browser Run sessions are created or deleted,
453
+ * and session modes don't apply.
454
+ */
455
+ cdpUrl: string /** Headers to send with CDP URL discovery requests (e.g. Access headers). */;
456
+ cdpHeaders?: Record<string, string>;
457
+ browser?: never;
458
+ store?: never;
459
+ session?: never;
460
+ }
461
+ ) & {
462
+ /** CDP command timeout in milliseconds (default: 10000). */ timeout?: number;
463
+ };
464
+ interface BrowserConnectorSweepOptions {
465
+ /**
466
+ * Close the shared (reuse/promoted) session when idle for at least this
467
+ * many milliseconds. Defaults to the connector's `keepAliveMs`, or
468
+ * {@link DEFAULT_SWEEP_IDLE_MS}.
469
+ */
470
+ maxIdleMs?: number;
471
+ /**
472
+ * Close *per-execution* sessions when idle for at least this many
473
+ * milliseconds. Defaults to {@link DEFAULT_EXEC_SWEEP_IDLE_MS} (24h) —
474
+ * deliberately at least as long as the codemode runtime's default paused
475
+ * TTL, so a run awaiting approval is normally expired (and disposed) by
476
+ * `expirePaused` before the sweep backstop ever touches its browser.
477
+ */
478
+ maxExecIdleMs?: number;
479
+ }
480
+ interface BrowserConnectorSweepResult {
481
+ /** Store keys (and their Browser Run session ids) closed by this sweep. */
482
+ swept: Array<{
483
+ key: string;
484
+ sessionId: string;
485
+ }>;
486
+ }
487
+ /**
488
+ * Live View rendering mode (the `mode` query param the hosted UI at
489
+ * `live.browser.run` understands):
490
+ *
491
+ * - `"tab"` — a standalone, interactive page view (best for handing control
492
+ * to a human).
493
+ * - `"devtools"` — the full DevTools inspector panel (Elements, Console,
494
+ * Network, …).
495
+ *
496
+ * Omit it to use whatever mode the binding's `devtoolsFrontendUrl` defaults
497
+ * to.
498
+ */
499
+ type LiveViewMode = "tab" | "devtools";
500
+ /** A single tab's Live View URL. */
501
+ interface BrowserLiveViewUrl {
502
+ /** Open this in a browser to watch/control the tab in real time. */
503
+ url: string;
504
+ /** CDP target (tab) id the URL points at. */
505
+ targetId: string;
506
+ /** Milliseconds the URL stays valid from when it was generated (~5 min). */
507
+ expiresInMs: number;
508
+ }
509
+ interface BrowserLiveViewTarget {
510
+ targetId: string;
511
+ /** Embeddable Live View URL (the `devtoolsFrontendUrl`) for this tab. */
512
+ url: string;
513
+ /** The page the tab is currently showing (e.g. `https://example.com`). */
514
+ pageUrl?: string;
515
+ title?: string;
516
+ type?: string;
517
+ }
518
+ /** Live View URLs for every tab in a (shared) session. */
519
+ interface BrowserLiveView {
520
+ sessionId: string;
521
+ targets: BrowserLiveViewTarget[];
522
+ /** Milliseconds the URLs stay valid from when they were generated (~5 min). */
523
+ expiresInMs: number;
524
+ }
525
+ /**
526
+ * Default idle window before {@link BrowserConnector.sweep} reclaims a
527
+ * per-execution session. Matches the codemode runtime's default paused TTL
528
+ * (24h): an execution paused for approval keeps its browser until the run
529
+ * itself is expired.
530
+ */
531
+ declare const DEFAULT_EXEC_SWEEP_IDLE_MS: number;
532
+ /**
533
+ * Codemode connector exposing a live browser over the Chrome DevTools
534
+ * Protocol as the `cdp` global.
535
+ *
536
+ * Per-execution resources are keyed by the codemode `executionId`:
537
+ *
538
+ * - The Browser Run session id is stored durably under `cdp:exec:<id>`, so a
539
+ * run that pauses for approval reconnects to the *same* browser when it
540
+ * resumes — even on a fresh instance.
541
+ * - The CDP WebSocket is per-pass: `onPassEnd` disconnects it (a paused run
542
+ * holds no socket), and the next pass reconnects from the stored id.
543
+ * - `disposeExecution` deletes the session unless it was promoted to the
544
+ * shared slot via `cdp.startSession()` (dynamic mode).
545
+ *
546
+ * Locks on the session store are held only around store reads/writes, never
547
+ * across network calls to Browser Run or while a socket is open.
548
+ */
549
+ declare class BrowserConnector extends CodemodeConnector {
550
+ #private;
551
+ constructor(
552
+ ctx: DurableObjectState | ExecutionContext,
553
+ options: BrowserConnectorOptions
554
+ );
555
+ name(): string;
556
+ protected instructions(): string;
557
+ protected tools(): ConnectorTools;
558
+ /**
559
+ * A pass is over (completed, errored, or paused awaiting approval) — drop
560
+ * the CDP socket. The Browser Run session itself stays alive; a resume
561
+ * reconnects from the durably stored session id.
562
+ */
563
+ onPassEnd(executionId: string, _status: PassEndStatus): Promise<void>;
564
+ /**
565
+ * The execution is terminal — delete its Browser Run session unless it was
566
+ * promoted to the shared slot via `cdp.startSession()`.
567
+ */
568
+ disposeExecution(
569
+ executionId: string,
570
+ _status: ExecutionEndStatus
571
+ ): Promise<void>;
572
+ /** Info about the shared (reuse/promoted) session, if one exists. */
573
+ sessionInfo(): Promise<BrowserSessionInfo | undefined>;
574
+ /**
575
+ * Live View URLs for the shared (reuse/promoted) session's tabs, or
576
+ * `undefined` when no shared session exists. Each URL opens an interactive,
577
+ * real-time view of the browser — surface them in your UI (or send them via
578
+ * Slack/email) to let a human watch or take over a running session
579
+ * (human-in-the-loop). URLs are valid for ~5 minutes; call again for fresh
580
+ * ones. Only meaningful with the Browser Rendering binding in
581
+ * `reuse`/`dynamic` mode.
582
+ */
583
+ liveView(options?: {
584
+ mode?: LiveViewMode;
585
+ }): Promise<BrowserLiveView | undefined>;
586
+ /** Close the shared (reuse/promoted) session, if one exists. */
587
+ closeSession(): Promise<void>;
588
+ /**
589
+ * Close stored sessions (shared and per-execution) idle past the threshold.
590
+ * Per-execution entries normally die with `disposeExecution` (or the
591
+ * codemode runtime's `expirePaused`); the sweep is the backstop for crashed
592
+ * hosts. Call it from a recurring alarm/scheduled task.
593
+ *
594
+ * Active executions bump their entry's `updatedAt` on use, so only runs
595
+ * idle past `maxExecIdleMs` (default 24h) are reclaimed. A swept
596
+ * per-execution entry is kept as a tombstone (`closedAt`) rather than
597
+ * deleted, so a later resume fails with a clear "session expired" error
598
+ * instead of silently continuing in a fresh browser; tombstones are
599
+ * deleted once they age past the threshold again.
600
+ */
601
+ sweep(
602
+ options?: BrowserConnectorSweepOptions
603
+ ): Promise<BrowserConnectorSweepResult>;
604
+ }
605
+ //#endregion
606
+ export {
607
+ browserMarkdown as A,
608
+ BrowserTargetInfo as B,
609
+ QuickActionScrapeInput as C,
610
+ browserContent as D,
611
+ QuickActionSnapshot as E,
612
+ runQuickAction as F,
613
+ deleteBrowserSession as G,
614
+ connectBrowser as H,
615
+ BrowserBinding as I,
616
+ CdpAttachOptions as J,
617
+ getBrowserRecording as K,
618
+ BrowserRecording as L,
619
+ browserScrape as M,
620
+ browserScreenshot as N,
621
+ browserExtract as O,
622
+ browserSnapshot as P,
623
+ BrowserRenderingError as R,
624
+ QuickActionPage as S,
625
+ QuickActionScreenshotInput as T,
626
+ connectBrowserSession as U,
627
+ ConnectBrowserOptions as V,
628
+ createBrowserSession as W,
629
+ CdpSession as X,
630
+ CdpSendOptions as Y,
631
+ connectUrl as Z,
632
+ QuickActionBinary as _,
633
+ BrowserConnectorSweepResult as a,
634
+ QuickActionExtractInput as b,
635
+ BrowserLiveViewUrl as c,
636
+ BrowserSessionLock as d,
637
+ BrowserSessionStore as f,
638
+ QuickAction as g,
639
+ StoredBrowserSession as h,
640
+ BrowserConnectorSweepOptions as i,
641
+ browserPdf as j,
642
+ browserLinks as k,
643
+ DEFAULT_EXEC_SWEEP_IDLE_MS as l,
644
+ DurableBrowserSessionStore as m,
645
+ BrowserConnectorOptions as n,
646
+ BrowserLiveView as o,
647
+ DEFAULT_SWEEP_IDLE_MS as p,
648
+ listBrowserTargets as q,
649
+ BrowserConnectorSessionOptions as r,
650
+ BrowserLiveViewTarget as s,
651
+ BrowserConnector as t,
652
+ LiveViewMode as u,
653
+ QuickActionBinding as v,
654
+ QuickActionScrapeResult as w,
655
+ QuickActionInput as x,
656
+ QuickActionCommonOptions as y,
657
+ BrowserSessionInfo as z
658
+ };
659
+ //# sourceMappingURL=connector-v2M1zlZp.d.ts.map