agents 0.28.0 → 0.29.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 (121) hide show
  1. package/dist/{agent-routing-QDcchcQP.d.ts → agent-routing-CDbpVjYq.d.ts} +18 -8
  2. package/dist/agent-routing.d.ts +1 -1
  3. package/dist/agent-tool-types.d.ts +1 -1
  4. package/dist/{agent-tools-DHL2XI7u.d.ts → agent-tools-C8DH8Yii.d.ts} +2 -2
  5. package/dist/agent-tools.d.ts +1 -1
  6. package/dist/{ai-ahruGw7e.d.ts → ai-iXw0uOGj.d.ts} +3 -3
  7. package/dist/{ai-sdk-Bdsf6mSA.js → ai-sdk-DRPh2rRa.js} +218 -132
  8. package/dist/ai-sdk-DRPh2rRa.js.map +1 -0
  9. package/dist/browser/ai.d.ts +1 -1
  10. package/dist/browser/ai.js +2 -2
  11. package/dist/browser/index.d.ts +8 -8
  12. package/dist/browser/index.js +3 -3
  13. package/dist/browser/tools/ai-sdk.d.ts +2 -2
  14. package/dist/browser/tools/ai-sdk.js +1 -1
  15. package/dist/browser/tools/pi.d.ts +1 -1
  16. package/dist/browser/tools/pi.js +3 -3
  17. package/dist/browser/tools/pi.js.map +1 -1
  18. package/dist/browser/tools/tanstack-ai.d.ts +2 -2
  19. package/dist/browser/tools/tanstack-ai.js +1 -1
  20. package/dist/{browser-CEdNlsaD.js → browser-DccPw_wW.js} +130 -79
  21. package/dist/browser-DccPw_wW.js.map +1 -0
  22. package/dist/{browser-D30VlpcA.d.ts → browser-DlXhSAdf.d.ts} +41 -37
  23. package/dist/{browser-tool-4iomavs_.js → browser-tool-B1mhifin.js} +3 -3
  24. package/dist/{browser-tool-4iomavs_.js.map → browser-tool-B1mhifin.js.map} +1 -1
  25. package/dist/{browser-tool-vtrPOV8e.d.ts → browser-tool-Cxjk5sgG.d.ts} +2 -2
  26. package/dist/chat/index.d.ts +143 -71
  27. package/dist/chat/index.js +269 -110
  28. package/dist/chat/index.js.map +1 -1
  29. package/dist/chat-sdk/index.d.ts +1 -1
  30. package/dist/chat-sdk/index.js +1 -1
  31. package/dist/cli.js +33 -33
  32. package/dist/{client-BGIQKJhX.d.ts → client-C27CtRZr.d.ts} +2 -2
  33. package/dist/client.d.ts +1 -1
  34. package/dist/{connector-DEXzVoaY.d.ts → connector-20DJ6p4k.d.ts} +2 -2
  35. package/dist/{connector-CtZylXdk.js → connector-DAXBOIIi.js} +2 -2
  36. package/dist/{connector-CtZylXdk.js.map → connector-DAXBOIIi.js.map} +1 -1
  37. package/dist/experimental/channels/web/index.js +1 -1
  38. package/dist/{handler-stateless-VvrWSAVA.js → handler-stateless-Bly_nSH3.js} +12 -3
  39. package/dist/handler-stateless-Bly_nSH3.js.map +1 -0
  40. package/dist/harness/container/index.js +1 -1
  41. package/dist/harness/container/index.js.map +1 -1
  42. package/dist/harness/opencode/index.d.ts +182 -6
  43. package/dist/harness/opencode/index.js +354 -23
  44. package/dist/harness/opencode/index.js.map +1 -1
  45. package/dist/harness/pi/index.d.ts +13 -5
  46. package/dist/harness/pi/index.js +8 -214
  47. package/dist/harness/pi/index.js.map +1 -1
  48. package/dist/{images-Ce9SCu3X.js → images-xaDv2Fqe.js} +662 -152
  49. package/dist/images-xaDv2Fqe.js.map +1 -0
  50. package/dist/index-DCxk3OSJ.d.ts +378 -0
  51. package/dist/{index-kbSUIer3.d.ts → index-iv9FTXX9.d.ts} +80 -112
  52. package/dist/index.d.ts +1 -1
  53. package/dist/index.js +1 -1
  54. package/dist/{input-schema-D2QAtHZH.js → input-schema-B0Etuo-o.js} +2 -2
  55. package/dist/{input-schema-D2QAtHZH.js.map → input-schema-B0Etuo-o.js.map} +1 -1
  56. package/dist/lifecycle/index.js +1 -1
  57. package/dist/{lifecycle-DGorpAmA.js → lifecycle-ClT4DmF2.js} +11 -3
  58. package/dist/lifecycle-ClT4DmF2.js.map +1 -0
  59. package/dist/mcp/client/index.d.ts +1 -1
  60. package/dist/mcp/index.d.ts +1 -1
  61. package/dist/mcp/index.js +17 -3
  62. package/dist/mcp/index.js.map +1 -1
  63. package/dist/mcp/server/index.js +1 -1
  64. package/dist/models/ai-sdk/index.d.ts +31 -326
  65. package/dist/models/ai-sdk/index.js +1 -1
  66. package/dist/models/opencode/index.d.ts +25 -13
  67. package/dist/models/opencode/index.js +16 -11
  68. package/dist/models/opencode/index.js.map +1 -1
  69. package/dist/models/pi-ai/index.d.ts +17 -13
  70. package/dist/models/pi-ai/index.js +89 -36
  71. package/dist/models/pi-ai/index.js.map +1 -1
  72. package/dist/react.d.ts +2 -2
  73. package/dist/routing/index.d.ts +1 -1
  74. package/dist/serializable.d.ts +1 -1
  75. package/dist/{session-store-DoPY12xM.d.ts → session-store-_IK6dV-w.d.ts} +14 -2
  76. package/dist/{session-store-Do4xkDcf.js → session-store-yvwq1f9x.js} +55 -2
  77. package/dist/session-store-yvwq1f9x.js.map +1 -0
  78. package/dist/{settings-C45hDliX.js → settings-Dk2il2Hf.js} +10 -4
  79. package/dist/settings-Dk2il2Hf.js.map +1 -0
  80. package/dist/skills/index.d.ts +22 -28
  81. package/dist/skills/index.js +183 -143
  82. package/dist/skills/index.js.map +1 -1
  83. package/dist/{src-CQxJFv4l.js → src-6lr7MtM_.js} +3 -3
  84. package/dist/src-6lr7MtM_.js.map +1 -0
  85. package/dist/sub-routing.d.ts +1 -1
  86. package/dist/{tool-cQRkwSZZ.js → tool-DkT_DJBm.js} +2 -2
  87. package/dist/tool-DkT_DJBm.js.map +1 -0
  88. package/dist/transport-CPh7YGiw.d.ts +623 -0
  89. package/dist/voice/index.d.ts +1 -1
  90. package/dist/web/fetch/tools/pi.js +2 -2
  91. package/dist/web/fetch/tools/pi.js.map +1 -1
  92. package/dist/web/search/index.js +1 -1
  93. package/dist/web/search/tools/ai-sdk.js +2 -2
  94. package/dist/web/search/tools/pi.js +3 -3
  95. package/dist/web/search/tools/pi.js.map +1 -1
  96. package/dist/web/search/tools/tanstack-ai.js +2 -2
  97. package/dist/websockets/index.js +1 -1
  98. package/dist/{websockets-C3zy8YR0.js → websockets-CqxnntmE.js} +2 -2
  99. package/dist/{websockets-C3zy8YR0.js.map → websockets-CqxnntmE.js.map} +1 -1
  100. package/dist/workflow-types.d.ts +1 -1
  101. package/dist/workflows.d.ts +1 -1
  102. package/dist/workflows.js +1 -1
  103. package/docs/browse-the-web.md +1 -1
  104. package/docs/chat-agents.md +19 -18
  105. package/docs/harnesses/pi.md +47 -18
  106. package/docs/mcp-client.md +1 -1
  107. package/docs/mcp-servers.md +1 -1
  108. package/docs/models-pi-ai.md +70 -17
  109. package/docs/models.md +219 -152
  110. package/package.json +14 -14
  111. package/dist/ai-sdk-Bdsf6mSA.js.map +0 -1
  112. package/dist/browser-CEdNlsaD.js.map +0 -1
  113. package/dist/handler-stateless-VvrWSAVA.js.map +0 -1
  114. package/dist/images-Ce9SCu3X.js.map +0 -1
  115. package/dist/lifecycle-DGorpAmA.js.map +0 -1
  116. package/dist/session-store-Do4xkDcf.js.map +0 -1
  117. package/dist/settings-C45hDliX.js.map +0 -1
  118. package/dist/settings-NgGwF7Qt.d.ts +0 -331
  119. package/dist/src-CQxJFv4l.js.map +0 -1
  120. package/dist/tool-cQRkwSZZ.js.map +0 -1
  121. package/dist/transport-k2mFrtL8.d.ts +0 -200
@@ -1,331 +0,0 @@
1
- //#region src/models/core/catalog.d.ts
2
- /**
3
- * Keys of the ambient `AiModels` interface (from `@cloudflare/workers-types`)
4
- * whose model type extends `T`. Kept in step with the installed workers-types
5
- * version rather than hand-maintained here.
6
- */
7
- type WorkersAIModelIdsExtending<T> = {
8
- [K in keyof AiModels]: AiModels[K] extends T ? K : never;
9
- }[keyof AiModels];
10
- /** The `inputs` shape a catalog entry declares. */
11
- type InputsOf<K extends keyof AiModels> = AiModels[K] extends {
12
- inputs: infer I;
13
- }
14
- ? I
15
- : never;
16
- /** The `postProcessedOutputs` shape a catalog entry declares. */
17
- type OutputsOf<K extends keyof AiModels> = AiModels[K] extends {
18
- postProcessedOutputs: infer O;
19
- }
20
- ? O
21
- : never;
22
- /**
23
- * Catalog keys whose input takes a required `messages` array — every current
24
- * chat model. Newer entries get their own generated class rather than
25
- * extending `BaseAiTextGeneration`, so the base-class arm alone misses them.
26
- */
27
- type ChatCatalogId = {
28
- [K in keyof AiModels]: Extract<
29
- InputsOf<K>,
30
- {
31
- messages: unknown;
32
- }
33
- > extends never
34
- ? never
35
- : K;
36
- }[keyof AiModels];
37
- /**
38
- * Catalog keys that take text and answer with embedding vectors. Both halves
39
- * matter: the input test alone also matches translation, classification and
40
- * speech models, which take `text` but return something else entirely.
41
- */
42
- type EmbeddingCatalogId = {
43
- [K in keyof AiModels]: Extract<
44
- InputsOf<K>,
45
- {
46
- text: unknown;
47
- }
48
- > extends never
49
- ? never
50
- : Extract<
51
- OutputsOf<K>,
52
- {
53
- data?: number[][];
54
- }
55
- > extends never
56
- ? never
57
- : K;
58
- }[keyof AiModels];
59
- /**
60
- * Catalog keys that take audio to transcribe. The `audio` key is required on
61
- * every speech-recognition input and on no other input shape, so the test is
62
- * exact rather than heuristic.
63
- */
64
- type TranscriptionCatalogId = {
65
- [K in keyof AiModels]: Extract<
66
- InputsOf<K>,
67
- {
68
- audio: unknown;
69
- }
70
- > extends never
71
- ? never
72
- : K;
73
- }[keyof AiModels];
74
- /**
75
- * Catalog keys that score a list of contexts against a query — rerankers.
76
- * `contexts` is required on exactly those inputs.
77
- */
78
- type RerankingCatalogId = {
79
- [K in keyof AiModels]: Extract<
80
- InputsOf<K>,
81
- {
82
- contexts: unknown;
83
- }
84
- > extends never
85
- ? never
86
- : K;
87
- }[keyof AiModels];
88
- /**
89
- * A Workers AI model id.
90
- *
91
- * Workers AI is the one catalog this package keeps up with, so this is the
92
- * only id shape it accepts: `@cf/<author>/<model>`. Autocomplete covers the
93
- * text-generation catalog from the installed `@cloudflare/workers-types`; the
94
- * template arm keeps every other `@cf/` slug assignable, because the catalog
95
- * lives server-side and moves independently of these types.
96
- *
97
- * Third-party models are not ids here — they are model objects built by their
98
- * own provider package and routed through AI Gateway.
99
- *
100
- * @experimental This surface is experimental and may change.
101
- */
102
- type WorkersAIModelId =
103
- | Extract<
104
- | ChatCatalogId
105
- | Exclude<
106
- WorkersAIModelIdsExtending<BaseAiTextGeneration>,
107
- WorkersAIModelIdsExtending<BaseAiTextToImage>
108
- >,
109
- `@cf/${string}`
110
- >
111
- | (`@cf/${string}` & {});
112
- /**
113
- * A text-embedding model id accepted by `ai.embedding()`.
114
- *
115
- * The modality methods are Workers AI only — there is no vendor route for them
116
- * — so, like {@link WorkersAIModelId}, they take `@cf/` ids and nothing else.
117
- *
118
- * @experimental This surface is experimental and may change.
119
- */
120
- type CloudflareEmbeddingModelId =
121
- | Extract<
122
- EmbeddingCatalogId | WorkersAIModelIdsExtending<BaseAiTextEmbeddings>,
123
- `@cf/${string}`
124
- >
125
- | (`@cf/${string}` & {});
126
- /**
127
- * Workers AI text-to-image ids that the generated `AiModels` entries do not
128
- * classify as {@link BaseAiTextToImage} — the newer partner models get their
129
- * own generated class instead. Curated for autocomplete only; the catalog
130
- * lives server-side and any slug is accepted.
131
- *
132
- * The FLUX.2 family (`flux-2-dev`, `flux-2-klein-4b`, `flux-2-klein-9b`) is
133
- * deliberately absent, for the reason {@link UnsupportedTranscriptionId}
134
- * records for the Deepgram recognisers: its generated input takes a required
135
- * `multipart` object body (`{ multipart: { body, contentType } }`) and no
136
- * `prompt`, which the JSON run path cannot carry — live, the run path answers
137
- * `400 Bad input: required properties at "/" are 'multipart'`. Suggesting an
138
- * id that always 400s is worse than not suggesting it.
139
- *
140
- * @experimental This surface is experimental and may change.
141
- */
142
- type KnownImageModelId =
143
- | "@cf/black-forest-labs/flux-1-schnell"
144
- | "@cf/leonardo/lucid-origin"
145
- | "@cf/leonardo/phoenix-1.0";
146
- /**
147
- * An image model id accepted by `ai.image()`.
148
- *
149
- * @experimental This surface is experimental and may change.
150
- */
151
- type CloudflareImageModelId =
152
- | Extract<
153
- WorkersAIModelIdsExtending<BaseAiTextToImage> | KnownImageModelId,
154
- `@cf/${string}`
155
- >
156
- | (`@cf/${string}` & {});
157
- /**
158
- * Workers AI text-to-speech ids without a {@link BaseAiTextToSpeech} entry.
159
- * Curated for autocomplete only.
160
- *
161
- * @experimental This surface is experimental and may change.
162
- */
163
- type KnownSpeechModelId =
164
- | "@cf/deepgram/aura-1"
165
- | "@cf/deepgram/aura-2-en"
166
- | "@cf/deepgram/aura-2-es";
167
- /**
168
- * A text-to-speech model id accepted by `ai.speech()`.
169
- *
170
- * @experimental This surface is experimental and may change.
171
- */
172
- type CloudflareSpeechModelId =
173
- | Extract<
174
- WorkersAIModelIdsExtending<BaseAiTextToSpeech> | KnownSpeechModelId,
175
- `@cf/${string}`
176
- >
177
- | (`@cf/${string}` & {});
178
- /**
179
- * Deepgram's recognition models want the audio as an object body
180
- * (`audio: { body, contentType }`) rather than as base64, which the JSON run
181
- * path cannot carry — every documented variant answered `400` live. They stay
182
- * out of the suggested arm, and the transcription model answers a clear error
183
- * for them.
184
- */
185
- type UnsupportedTranscriptionId = "@cf/deepgram/nova-3" | "@cf/deepgram/flux";
186
- /**
187
- * A speech-recognition model id accepted by `ai.transcription()`.
188
- *
189
- * Deepgram's recognition models (`@cf/deepgram/nova-3`, `@cf/deepgram/flux`)
190
- * are deliberately not suggested: the run path rejects their documented input
191
- * shape, so this provider answers a clear error for them rather than a 400.
192
- *
193
- * @experimental This surface is experimental and may change.
194
- */
195
- type CloudflareTranscriptionModelId =
196
- | Extract<
197
- | Exclude<TranscriptionCatalogId, UnsupportedTranscriptionId>
198
- | Exclude<
199
- WorkersAIModelIdsExtending<BaseAiAutomaticSpeechRecognition>,
200
- UnsupportedTranscriptionId
201
- >,
202
- `@cf/${string}`
203
- >
204
- | (`@cf/${string}` & {});
205
- /**
206
- * A reranking model id accepted by `ai.reranking()`.
207
- *
208
- * @experimental This surface is experimental and may change.
209
- */
210
- type CloudflareRerankingModelId =
211
- | Extract<RerankingCatalogId, `@cf/${string}`>
212
- | (`@cf/${string}` & {});
213
- //#endregion
214
- //#region src/models/core/settings.d.ts
215
- /**
216
- * AI Gateway settings for a request. The gateway is an option, not a separate
217
- * product: every call goes through one, and `id` defaults to `"default"`,
218
- * which Cloudflare creates on first use.
219
- *
220
- * @experimental This surface is experimental and may change.
221
- */
222
- interface GatewayOptions {
223
- /** Gateway id. Defaults to `"default"` (auto-created on first use). */
224
- id?: string;
225
- /** Bypass the cache for this request. */
226
- skipCache?: boolean;
227
- /** Cache lifetime in seconds. */
228
- cacheTtl?: number;
229
- /** Explicit cache key, instead of the request-derived one. */
230
- cacheKey?: string;
231
- /** Whether the gateway stores the request/response in its log. */
232
- collectLog?: boolean;
233
- /** Arbitrary key/values attached to the gateway log entry. */
234
- metadata?: Record<string, string | number | boolean | null>;
235
- /** Correlates several requests into one gateway event. */
236
- eventId?: string;
237
- /** Upstream request timeout in milliseconds. */
238
- requestTimeoutMs?: number;
239
- /** Server-side retry policy for the upstream provider call. */
240
- retries?: {
241
- maxAttempts?: 1 | 2 | 3 | 4 | 5;
242
- retryDelayMs?: number;
243
- backoff?: "constant" | "linear" | "exponential";
244
- };
245
- }
246
- /**
247
- * How `createAI` reaches Cloudflare: the Workers AI binding, and nothing else.
248
- * Workers AI models go through `env.AI.run`, vendor models through
249
- * `env.AI.gateway(id).run` — both are the binding, so there is no HTTP
250
- * transport, no account id and no API token to hold.
251
- *
252
- * @experimental This surface is experimental and may change.
253
- */
254
- type AISettings = {
255
- /** The `AI` binding from a Worker's env. */ binding: Ai;
256
- } & ProviderGatewaySettings;
257
- /**
258
- * Provider-wide gateway defaults, in either spelling: nested under `gateway`,
259
- * or flat (`{ id: "prod", cacheTtl: 60 }`). Both merge, the flat key winning.
260
- *
261
- * @experimental This surface is experimental and may change.
262
- */
263
- interface ProviderGatewaySettings extends GatewayOptions {
264
- /** Gateway id or full gateway options. */
265
- gateway?: string | GatewayOptions;
266
- }
267
- /**
268
- * Per-model and per-call options. The flat gateway keys are sugar for
269
- * `gateway: { ... }`; both forms merge, with the flat key winning.
270
- *
271
- * The same shape is accepted per call under
272
- * `providerOptions.cloudflare`, where it takes precedence over the per-model
273
- * options, which in turn take precedence over the `createAI` settings.
274
- *
275
- * `Leg` is what a framework module accepts as a fallback leg. Workers AI ids
276
- * are the only kind this module can resolve on its own, so they are the
277
- * default; a module whose legs may also be model objects says so
278
- * (`ModelOptions<WorkersAIModelId | LanguageModelV4>`) rather than rebuilding
279
- * the type.
280
- *
281
- * @experimental This surface is experimental and may change.
282
- */
283
- interface ModelOptions<Leg = WorkersAIModelId> extends ProviderGatewaySettings {
284
- /**
285
- * Models to try, in order, if the primary fails before any output is
286
- * produced. A leg travels with the chain's gateway options — those win over
287
- * a leg's own, and `metadata` merges — while everything a leg was built with
288
- * itself stays its own. Client-side today; becomes server-side when the
289
- * platform ships model-first routing.
290
- */
291
- fallback?: Leg[];
292
- /** Extra request headers, merged last. */
293
- headers?: Record<string, string>;
294
- /**
295
- * Workers AI only: route same-key requests to the same replica for
296
- * prefix-cache hits. Sent as the `x-session-affinity` header.
297
- */
298
- sessionAffinity?: string;
299
- /**
300
- * Explicit reasoning effort. `null` disables reasoning on models that
301
- * support toggling it. The unified AI SDK `reasoning` call option maps onto
302
- * this when this is not set.
303
- */
304
- reasoningEffort?: "low" | "medium" | "high" | null;
305
- /**
306
- * Workers AI only: forwarded verbatim as `chat_template_kwargs`, e.g.
307
- * `{ enable_thinking: false }`.
308
- */
309
- chatTemplateKwargs?: Record<string, unknown>;
310
- }
311
- /** A gateway config with the id filled in. */
312
- interface ResolvedGateway extends GatewayOptions {
313
- id: string;
314
- }
315
- //#endregion
316
- export {
317
- ResolvedGateway as a,
318
- CloudflareRerankingModelId as c,
319
- KnownImageModelId as d,
320
- KnownSpeechModelId as f,
321
- ProviderGatewaySettings as i,
322
- CloudflareSpeechModelId as l,
323
- GatewayOptions as n,
324
- CloudflareEmbeddingModelId as o,
325
- WorkersAIModelId as p,
326
- ModelOptions as r,
327
- CloudflareImageModelId as s,
328
- AISettings as t,
329
- CloudflareTranscriptionModelId as u
330
- };
331
- //# sourceMappingURL=settings-NgGwF7Qt.d.ts.map