agents 0.23.0 → 0.25.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.
Files changed (187) hide show
  1. package/dist/{agent-routing-DE5zmCQ8.d.ts → agent-routing-0DR0Tk2v.d.ts} +270 -190
  2. package/dist/agent-routing.d.ts +1 -1
  3. package/dist/agent-routing.js.map +1 -1
  4. package/dist/agent-tool-types.d.ts +13 -7
  5. package/dist/agent-tool-types.js +23 -1
  6. package/dist/agent-tool-types.js.map +1 -1
  7. package/dist/{agent-tools-y7zLfw4Q.js → agent-tools-CdJC-8Dc.js} +72 -9
  8. package/dist/agent-tools-CdJC-8Dc.js.map +1 -0
  9. package/dist/{agent-tools-DtXMTDGM.d.ts → agent-tools-YrATZJu2.d.ts} +29 -15
  10. package/dist/agent-tools.d.ts +6 -4
  11. package/dist/agent-tools.js.map +1 -1
  12. package/dist/ai-fm7xx1BK.js +312 -0
  13. package/dist/ai-fm7xx1BK.js.map +1 -0
  14. package/dist/base64-redaction-C1Uu29t5.js +59 -0
  15. package/dist/base64-redaction-C1Uu29t5.js.map +1 -0
  16. package/dist/browser/ai-sdk.d.ts +90 -0
  17. package/dist/browser/ai-sdk.js +51 -0
  18. package/dist/browser/ai-sdk.js.map +1 -0
  19. package/dist/browser/ai.d.ts +4 -4
  20. package/dist/browser/ai.js +1 -347
  21. package/dist/browser/index.d.ts +81 -79
  22. package/dist/browser/index.js +361 -2
  23. package/dist/browser/index.js.map +1 -0
  24. package/dist/browser/tanstack-ai.d.ts +96 -1
  25. package/dist/browser/tanstack-ai.js +62 -2
  26. package/dist/browser/tanstack-ai.js.map +1 -1
  27. package/dist/browser-DE3d-RLk.d.ts +275 -0
  28. package/dist/browser-tool-CQ10e6Kj.js +480 -0
  29. package/dist/browser-tool-CQ10e6Kj.js.map +1 -0
  30. package/dist/browser-tool-DuNdlwZ9.d.ts +73 -0
  31. package/dist/{capability-BjSKYpzg.js → capability-B4WbF81e.js} +2 -1
  32. package/dist/capability-B4WbF81e.js.map +1 -0
  33. package/dist/{capability-runner-Be_-PLR1.d.ts → capability-runner-DBAnGr6L.d.ts} +45 -15
  34. package/dist/chat/index.d.ts +341 -232
  35. package/dist/chat/index.js +602 -72
  36. package/dist/chat/index.js.map +1 -1
  37. package/dist/chat/react.d.ts +42 -2
  38. package/dist/chat/react.js +191 -35
  39. package/dist/chat/react.js.map +1 -1
  40. package/dist/chat/transport.d.ts +1 -1
  41. package/dist/chat/transport.js +1 -1
  42. package/dist/chat-sdk/index.d.ts +17 -3
  43. package/dist/chat-sdk/index.js +28 -2
  44. package/dist/chat-sdk/index.js.map +1 -1
  45. package/dist/client-4OlMIJx-.js +591 -0
  46. package/dist/client-4OlMIJx-.js.map +1 -0
  47. package/dist/{client-jagG8a9_.js → client-fyQrLGkD.js} +2 -2
  48. package/dist/{client-jagG8a9_.js.map → client-fyQrLGkD.js.map} +1 -1
  49. package/dist/client-je3koD9Z.d.ts +446 -0
  50. package/dist/client.d.ts +29 -283
  51. package/dist/client.js +2 -274
  52. package/dist/{connector-CptFKzRh.js → connector-58XDGvc3.js} +251 -120
  53. package/dist/connector-58XDGvc3.js.map +1 -0
  54. package/dist/{connector-CkQD4MK3.d.ts → connector-Cl-VqPmA.d.ts} +244 -146
  55. package/dist/context/index.d.ts +29 -0
  56. package/dist/context/index.js +64 -17
  57. package/dist/context/index.js.map +1 -1
  58. package/dist/current-agent-DhoDkSnH.js.map +1 -1
  59. package/dist/current-agent-vAk_5JMt.d.ts +93 -0
  60. package/dist/{current-agent-Da_C9a3b.d.ts → durable-object-lifecycle-HhgOMWq9.d.ts} +26 -127
  61. package/dist/harnesses/pi/index.d.ts +348 -0
  62. package/dist/harnesses/pi/index.js +754 -0
  63. package/dist/harnesses/pi/index.js.map +1 -0
  64. package/dist/images-iiTDSyRu.js +1631 -0
  65. package/dist/images-iiTDSyRu.js.map +1 -0
  66. package/dist/index-BreL0YrQ.d.ts +78 -0
  67. package/dist/index-kbSUIer3.d.ts +343 -0
  68. package/dist/index.d.ts +43 -41
  69. package/dist/index.js +2 -2
  70. package/dist/internal_context.d.ts +1 -1
  71. package/dist/lifecycle/index.d.ts +19 -17
  72. package/dist/lifecycle/index.js +2 -2
  73. package/dist/{lifecycle-CMRGjZdw.js → lifecycle-CFu6OV03.js} +73 -29
  74. package/dist/lifecycle-CFu6OV03.js.map +1 -0
  75. package/dist/mcp/client/index.d.ts +20 -20
  76. package/dist/mcp/client/index.js +1 -1
  77. package/dist/mcp/client/x402.js +21 -19
  78. package/dist/mcp/client/x402.js.map +1 -1
  79. package/dist/mcp/index.d.ts +35 -35
  80. package/dist/mcp/index.js +2 -2
  81. package/dist/{message-builder-BymO4N_D.js → message-builder-DAl9AhHH.js} +89 -4
  82. package/dist/message-builder-DAl9AhHH.js.map +1 -0
  83. package/dist/models/ai-sdk/index.d.ts +353 -0
  84. package/dist/models/ai-sdk/index.js +2443 -0
  85. package/dist/models/ai-sdk/index.js.map +1 -0
  86. package/dist/models/pi-ai/index.d.ts +313 -0
  87. package/dist/models/pi-ai/index.js +1795 -0
  88. package/dist/models/pi-ai/index.js.map +1 -0
  89. package/dist/observability/ai/index.js +20 -4
  90. package/dist/observability/ai/index.js.map +1 -1
  91. package/dist/{protocol-B0nh6KNf.js → protocol-kHsr-f0X.js} +26 -12
  92. package/dist/{protocol-B0nh6KNf.js.map → protocol-kHsr-f0X.js.map} +1 -1
  93. package/dist/queue/index.d.ts +123 -0
  94. package/dist/queue/index.js +2 -0
  95. package/dist/queue-BB-zfIYF.js +406 -0
  96. package/dist/queue-BB-zfIYF.js.map +1 -0
  97. package/dist/react.d.ts +31 -13
  98. package/dist/react.js +190 -71
  99. package/dist/react.js.map +1 -1
  100. package/dist/{retries-D9Ds-1lz.d.ts → retries-CV6AkXmQ.d.ts} +23 -8
  101. package/dist/retries.d.ts +12 -8
  102. package/dist/retries.js +19 -1
  103. package/dist/retries.js.map +1 -1
  104. package/dist/routing/index.d.ts +2 -2
  105. package/dist/routing/index.js +1 -1
  106. package/dist/{scheduler-DD9NdYbF.js → scheduler-DZ3xQfeK.js} +4 -11
  107. package/dist/scheduler-DZ3xQfeK.js.map +1 -0
  108. package/dist/{scheduler-Dwh85ZGl.d.ts → scheduler-RdACNXDP.d.ts} +6 -6
  109. package/dist/schedules/index.d.ts +1 -1
  110. package/dist/schedules/index.js +1 -1
  111. package/dist/serializable.d.ts +1 -1
  112. package/dist/sessions/index.d.ts +70 -3
  113. package/dist/sessions/index.js +276 -67
  114. package/dist/sessions/index.js.map +1 -1
  115. package/dist/skills/index.d.ts +29 -314
  116. package/dist/socket-address.d.ts +16 -0
  117. package/dist/socket-address.js +19 -0
  118. package/dist/socket-address.js.map +1 -0
  119. package/dist/{src-DlSHshb2.js → src-BZeu-SCD.js} +541 -500
  120. package/dist/src-BZeu-SCD.js.map +1 -0
  121. package/dist/state/index.d.ts +6 -0
  122. package/dist/state/index.js +137 -0
  123. package/dist/state/index.js.map +1 -0
  124. package/dist/streams/index.d.ts +1 -1
  125. package/dist/streams/index.js +1 -1
  126. package/dist/{streams-D6tJ0NN9.d.ts → streams-Cmkj9QfW.d.ts} +4 -2
  127. package/dist/{streams-DZKgAj9b.js → streams-DW-UCOUc.js} +9 -2
  128. package/dist/streams-DW-UCOUc.js.map +1 -0
  129. package/dist/sub-routing.d.ts +12 -12
  130. package/dist/tasks/index.d.ts +1 -1
  131. package/dist/tasks/index.js +1 -1
  132. package/dist/{tasks-ylZgBjhj.js → tasks-68DESxf0.js} +3 -3
  133. package/dist/{tasks-ylZgBjhj.js.map → tasks-68DESxf0.js.map} +1 -1
  134. package/dist/{tasks-BRJ5zgya.d.ts → tasks-9YxYtByh.d.ts} +5 -5
  135. package/dist/transport-PfFnt-Ld.d.ts +525 -0
  136. package/dist/transport-protocol-BxyngQ_R.js +25 -0
  137. package/dist/transport-protocol-BxyngQ_R.js.map +1 -0
  138. package/dist/transport-protocol-ZTew5Wso.d.ts +27 -0
  139. package/dist/types-BA4anrjI.d.ts +70 -0
  140. package/dist/voice/index.d.ts +2 -2
  141. package/dist/websockets/index.d.ts +195 -69
  142. package/dist/websockets/index.js +3 -2
  143. package/dist/websockets-Ci-LZFHH.js +1030 -0
  144. package/dist/websockets-Ci-LZFHH.js.map +1 -0
  145. package/dist/wire-types-CnMt6_HR.js.map +1 -1
  146. package/dist/wire-types-CrjKvDyi.d.ts +300 -0
  147. package/dist/workflow-types.d.ts +25 -25
  148. package/dist/workflows.d.ts +21 -21
  149. package/dist/workflows.js +1 -1
  150. package/dist/{ws-chat-transport-UNRIS2xl.d.ts → ws-chat-transport-BbT1A5Lc.d.ts} +51 -2
  151. package/dist/{ws-chat-transport-rWwta645.js → ws-chat-transport-cqMKq3IY.js} +143 -16
  152. package/dist/ws-chat-transport-cqMKq3IY.js.map +1 -0
  153. package/docs/agent-class.md +2 -2
  154. package/docs/agent-tools.md +29 -4
  155. package/docs/browse-the-web.md +87 -5
  156. package/docs/chat-agents.md +124 -16
  157. package/docs/client-sdk.md +30 -0
  158. package/docs/context.md +27 -0
  159. package/docs/durable-execution.md +2 -0
  160. package/docs/harnesses/pi.md +91 -0
  161. package/docs/human-in-the-loop.md +4 -0
  162. package/docs/index.md +4 -1
  163. package/docs/lifecycle.md +114 -23
  164. package/docs/models-pi-ai.md +325 -0
  165. package/docs/models.md +504 -0
  166. package/docs/queue.md +135 -241
  167. package/docs/resumable-streaming.md +2 -0
  168. package/docs/retries.md +1 -1
  169. package/docs/routing.md +13 -13
  170. package/docs/sessions.md +36 -1
  171. package/docs/state.md +1 -0
  172. package/docs/sub-agents.md +12 -3
  173. package/package.json +51 -3
  174. package/dist/agent-tools-y7zLfw4Q.js.map +0 -1
  175. package/dist/browser/ai.js.map +0 -1
  176. package/dist/capability-BjSKYpzg.js.map +0 -1
  177. package/dist/client-tools-aIBO0Fk7.d.ts +0 -53
  178. package/dist/client.js.map +0 -1
  179. package/dist/connector-CptFKzRh.js.map +0 -1
  180. package/dist/lifecycle-CMRGjZdw.js.map +0 -1
  181. package/dist/message-builder-BymO4N_D.js.map +0 -1
  182. package/dist/scheduler-DD9NdYbF.js.map +0 -1
  183. package/dist/src-DlSHshb2.js.map +0 -1
  184. package/dist/streams-DZKgAj9b.js.map +0 -1
  185. package/dist/websockets-DUfRHPRq.js +0 -502
  186. package/dist/websockets-DUfRHPRq.js.map +0 -1
  187. package/dist/ws-chat-transport-rWwta645.js.map +0 -1
@@ -0,0 +1,275 @@
1
+ import { s as LifecycleCapability } from "./capability-runner-DBAnGr6L.js";
2
+ import {
3
+ $ as CdpConnection,
4
+ F as LiveViewMode,
5
+ I as BrowserBinding,
6
+ M as BrowserLiveView,
7
+ O as BrowserSessionStore,
8
+ z as BrowserSessionGuardrails
9
+ } from "./connector-Cl-VqPmA.js";
10
+
11
+ //#region src/browser/spec.d.ts
12
+ /**
13
+ * The element type of an array field or type. `$ref` is always
14
+ * domain-qualified (`"Network.Cookie"`), matching a type's `name`.
15
+ */
16
+ interface CdpItems {
17
+ type?: string;
18
+ $ref?: string;
19
+ enum?: string[];
20
+ }
21
+ /**
22
+ * A command parameter, return value, event parameter, or type property.
23
+ * Either `type` (a JSON type such as `"string"` or `"array"`) or `$ref`
24
+ * (a domain-qualified type name matching a type's `name`) is set.
25
+ */
26
+ interface CdpField {
27
+ name: string;
28
+ description?: string;
29
+ optional?: boolean;
30
+ experimental?: boolean;
31
+ deprecated?: boolean;
32
+ type?: string;
33
+ $ref?: string;
34
+ enum?: string[];
35
+ items?: CdpItems;
36
+ }
37
+ interface SearchableCdpSpec {
38
+ domains: Array<{
39
+ name: string;
40
+ description?: string;
41
+ experimental?: boolean;
42
+ deprecated?: boolean;
43
+ commands: Array<{
44
+ name: string;
45
+ method: string;
46
+ description?: string;
47
+ experimental?: boolean;
48
+ deprecated?: boolean;
49
+ parameters: CdpField[];
50
+ returns: CdpField[];
51
+ }>;
52
+ events: Array<{
53
+ name: string;
54
+ event: string;
55
+ description?: string;
56
+ experimental?: boolean;
57
+ deprecated?: boolean;
58
+ parameters: CdpField[];
59
+ }>;
60
+ types: Array<{
61
+ id: string;
62
+ name: string;
63
+ description?: string;
64
+ experimental?: boolean;
65
+ deprecated?: boolean /** JSON type of the value, e.g. `"string"`, `"object"`, `"array"`. */;
66
+ type?: string;
67
+ enum?: string[];
68
+ properties: CdpField[];
69
+ items?: CdpItems;
70
+ }>;
71
+ }>;
72
+ }
73
+ interface CdpSpecSource {
74
+ /** Browser Rendering binding (Fetcher) — used in production */
75
+ browser?: BrowserBinding;
76
+ /** CDP base URL override (e.g. http://localhost:9222) */
77
+ cdpUrl?: string;
78
+ /** Headers to send with CDP URL discovery requests */
79
+ cdpHeaders?: Record<string, string>;
80
+ /**
81
+ * An existing Browser Run session to read the protocol from. Without it,
82
+ * loading through the binding creates (and deletes) a throwaway session.
83
+ */
84
+ sessionId?: string;
85
+ }
86
+ /** Load the (cached) searchable CDP spec for a browser source. */
87
+ declare function loadCdpSpec(source: CdpSpecSource): Promise<SearchableCdpSpec>;
88
+ //#endregion
89
+ //#region src/browser/browser.d.ts
90
+ /**
91
+ * Browser Run settings applied every time a browser is created — including
92
+ * when a lost browser is replaced — so options like guardrails survive a
93
+ * restart.
94
+ */
95
+ interface BrowserRunOptions {
96
+ /**
97
+ * Platform `keep_alive` in milliseconds: how long an idle browser lives.
98
+ * Defaults to {@link BROWSER_SESSION_KEEP_ALIVE_MAX_MS} (the platform
99
+ * maximum).
100
+ */
101
+ keepAliveMs?: number;
102
+ /** Opt into Browser Run session recording (rrweb capture). */
103
+ recording?: boolean;
104
+ /** Hostname guardrails, fixed at launch for every connection. */
105
+ guardrails?: BrowserSessionGuardrails;
106
+ }
107
+ /** A {@link Browser} provider backed by Cloudflare Browser Run. */
108
+ interface BrowserRunProvider {
109
+ readonly kind: "browser-run";
110
+ readonly binding: BrowserBinding;
111
+ readonly options: BrowserRunOptions;
112
+ }
113
+ /** Where a {@link Browser} gets its browser from. */
114
+ type BrowserProvider = BrowserRunProvider;
115
+ /**
116
+ * Run the browser on Cloudflare Browser Run.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * new Browser({ provider: browserRun(env.BROWSER, { recording: true }) });
121
+ * ```
122
+ */
123
+ declare function browserRun(
124
+ binding: BrowserBinding,
125
+ options?: BrowserRunOptions
126
+ ): BrowserRunProvider;
127
+ interface BrowserOptions {
128
+ /** Where the browser runs. Create one with {@link browserRun}. */
129
+ provider: BrowserProvider;
130
+ /**
131
+ * Which browser this is. Two `Browser` objects on the same Durable Object
132
+ * need different names. Defaults to {@link DEFAULT_BROWSER_NAME}.
133
+ */
134
+ name?: string;
135
+ /**
136
+ * Where the browser's record lives. Defaults to a
137
+ * {@link DurableBrowserSessionStore} over the host object's storage, which
138
+ * requires installing the `Browser` with `Lifecycle.use()`. Passing a store
139
+ * lets the `Browser` work without Lifecycle.
140
+ */
141
+ store?: BrowserSessionStore;
142
+ /** Default CDP command timeout for {@link Browser.connect}. */
143
+ timeoutMs?: number;
144
+ /**
145
+ * Minimum interval between activity-driven `updatedAt` refreshes.
146
+ * Defaults to {@link SESSION_TOUCH_INTERVAL_MS}, capped at half the
147
+ * keep-alive window.
148
+ *
149
+ * @internal For tests.
150
+ */
151
+ touchIntervalMs?: number;
152
+ }
153
+ interface ResolvedBrowser {
154
+ name: string;
155
+ /** The Browser Run session id — host-side only, never model-visible. */
156
+ sessionId: string;
157
+ /**
158
+ * `true` when this resolution had to create a fresh browser to replace one
159
+ * that previously existed (was closed, or expired or died upstream). Page
160
+ * state from the prior browser is gone; surface this loudly to the model.
161
+ * `false` only on first-ever use of the name — nothing was lost.
162
+ */
163
+ restarted: boolean;
164
+ createdAt: number;
165
+ updatedAt: number;
166
+ /**
167
+ * The tab the agent last worked in, when one was recorded for this
168
+ * browser. Absent on a browser this resolution created; a replacement a
169
+ * concurrent caller already created and used may carry one.
170
+ */
171
+ activeTargetId?: string;
172
+ }
173
+ interface BrowserConnection {
174
+ name: string;
175
+ sessionId: string;
176
+ /**
177
+ * `true` when the browser this caller resolved is gone, even if a
178
+ * concurrent caller already replaced it. See
179
+ * {@link ResolvedBrowser.restarted}.
180
+ */
181
+ restarted: boolean;
182
+ /** See {@link ResolvedBrowser.activeTargetId}. */
183
+ activeTargetId?: string;
184
+ /** Closing this connection does NOT close the browser. */
185
+ cdp: CdpConnection;
186
+ /**
187
+ * Record the tab the agent is working in (or clear it with `undefined`).
188
+ * Never resurrects: returns `false` when the browser was closed or
189
+ * replaced since this connection resolved it.
190
+ */
191
+ setActiveTarget(targetId: string | undefined): Promise<boolean>;
192
+ /**
193
+ * The Chrome DevTools Protocol description this browser serves, read from
194
+ * the browser itself (cached per binding).
195
+ */
196
+ spec(): Promise<SearchableCdpSpec>;
197
+ }
198
+ /**
199
+ * One named, persistent browser.
200
+ *
201
+ * Install it with `Lifecycle.use()` — on an Agent subclass or any Durable
202
+ * Object that composes `Lifecycle` — and it stores its record in the
203
+ * object's own storage. It schedules nothing: Browser Run reclaims idle
204
+ * browsers itself once `keep_alive` elapses, and the next use replaces the
205
+ * lost browser with `restarted: true`.
206
+ *
207
+ * Everything here is host-side. Models never see browser names, Browser Run
208
+ * ids, or Live View URLs through this surface.
209
+ *
210
+ * Store discipline: locks wrap storage operations only — liveness probes and
211
+ * Browser Run create/delete calls always happen outside any lock, with a
212
+ * commit re-check to detect concurrent swaps.
213
+ *
214
+ * @experimental The API surface may change before stabilizing.
215
+ */
216
+ declare class Browser extends LifecycleCapability {
217
+ #private;
218
+ /** Which browser this is; see {@link BrowserOptions.name}. */
219
+ readonly name: string;
220
+ constructor(options: BrowserOptions);
221
+ /**
222
+ * Reattach to the browser when it is still alive, otherwise create a fresh
223
+ * one. See {@link ResolvedBrowser.restarted} for the mortality signal.
224
+ */
225
+ resolve(): Promise<ResolvedBrowser>;
226
+ /**
227
+ * Resolve the browser and open a CDP connection to it. Commands sent over
228
+ * the connection refresh the record's `updatedAt` (throttled to
229
+ * {@link SESSION_TOUCH_INTERVAL_MS}), so hosts can tell an actively used
230
+ * browser from one the platform has likely reclaimed.
231
+ *
232
+ * If the browser expires between the liveness probe and the WebSocket
233
+ * upgrade, the record is retired and the browser resolved once more, so
234
+ * the caller gets a fresh browser with `restarted: true` instead of an
235
+ * error.
236
+ */
237
+ connect(): Promise<BrowserConnection>;
238
+ /**
239
+ * Close the browser: retire the record (so the next resolve reports
240
+ * `restarted: true`) and delete its Browser Run session. Returns `false`
241
+ * when there was nothing to close.
242
+ *
243
+ * The platform delete is best-effort: the retired record is the durable
244
+ * outcome, and a browser whose delete failed is unreachable through this
245
+ * store, so the pinned `keep_alive` (≤600s) reclaims it.
246
+ */
247
+ close(): Promise<boolean>;
248
+ /**
249
+ * Mint Live View URLs for the browser's open tabs, fresh from a target
250
+ * listing. `undefined` when the browser was never created, is closed, or
251
+ * is gone. The URLs are bearer credentials with a short connect window
252
+ * (~5 min) — hand them to a trusted human, never to the model, and never
253
+ * store them: re-mint instead.
254
+ */
255
+ liveView(options?: {
256
+ mode?: LiveViewMode;
257
+ }): Promise<BrowserLiveView | undefined>;
258
+ }
259
+ //#endregion
260
+ export {
261
+ BrowserRunOptions as a,
262
+ browserRun as c,
263
+ CdpSpecSource as d,
264
+ SearchableCdpSpec as f,
265
+ BrowserProvider as i,
266
+ CdpField as l,
267
+ BrowserConnection as n,
268
+ BrowserRunProvider as o,
269
+ loadCdpSpec as p,
270
+ BrowserOptions as r,
271
+ ResolvedBrowser as s,
272
+ Browser as t,
273
+ CdpItems as u
274
+ };
275
+ //# sourceMappingURL=browser-DE3d-RLk.d.ts.map