agents 0.28.1 → 0.30.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/{agent-routing-BMvWTFEp.d.ts → agent-routing-CDbpVjYq.d.ts} +7 -8
- package/dist/agent-routing.d.ts +1 -1
- package/dist/agent-tool-types.d.ts +1 -1
- package/dist/{agent-tools-ohoewW-B.d.ts → agent-tools-C8DH8Yii.d.ts} +2 -2
- package/dist/agent-tools.d.ts +1 -1
- package/dist/{ai-ahruGw7e.d.ts → ai-iXw0uOGj.d.ts} +3 -3
- package/dist/{ai-sdk-C2iTAwUd.js → ai-sdk-DRPh2rRa.js} +185 -125
- package/dist/ai-sdk-DRPh2rRa.js.map +1 -0
- package/dist/browser/ai.d.ts +1 -1
- package/dist/browser/ai.js +2 -2
- package/dist/browser/index.d.ts +8 -8
- package/dist/browser/index.js +3 -3
- package/dist/browser/tools/ai-sdk.d.ts +2 -2
- package/dist/browser/tools/ai-sdk.js +1 -1
- package/dist/browser/tools/pi.d.ts +7 -3
- package/dist/browser/tools/pi.js +9 -5
- package/dist/browser/tools/pi.js.map +1 -1
- package/dist/browser/tools/tanstack-ai.d.ts +2 -2
- package/dist/browser/tools/tanstack-ai.js +1 -1
- package/dist/{browser-CEdNlsaD.js → browser-DccPw_wW.js} +130 -79
- package/dist/browser-DccPw_wW.js.map +1 -0
- package/dist/{browser-D30VlpcA.d.ts → browser-DlXhSAdf.d.ts} +41 -37
- package/dist/{browser-tool-4iomavs_.js → browser-tool-B1mhifin.js} +3 -3
- package/dist/{browser-tool-4iomavs_.js.map → browser-tool-B1mhifin.js.map} +1 -1
- package/dist/{browser-tool-vtrPOV8e.d.ts → browser-tool-Cxjk5sgG.d.ts} +2 -2
- package/dist/chat/index.d.ts +143 -71
- package/dist/chat/index.js +269 -110
- package/dist/chat/index.js.map +1 -1
- package/dist/chat-sdk/index.d.ts +1 -1
- package/dist/chat-sdk/index.js +1 -1
- package/dist/cli.js +53 -52
- package/dist/{client-Bp-JwL3p.d.ts → client-C27CtRZr.d.ts} +2 -2
- package/dist/client.d.ts +1 -1
- package/dist/{connector-DEXzVoaY.d.ts → connector-20DJ6p4k.d.ts} +2 -2
- package/dist/{connector-CtZylXdk.js → connector-DAXBOIIi.js} +2 -2
- package/dist/{connector-CtZylXdk.js.map → connector-DAXBOIIi.js.map} +1 -1
- package/dist/experimental/channels/web/index.js +1 -1
- package/dist/harness/container/index.js +1 -1
- package/dist/harness/container/index.js.map +1 -1
- package/dist/harness/opencode/index.js +1 -1
- package/dist/harness/pi/index.d.ts +70 -40
- package/dist/harness/pi/index.js +266 -330
- package/dist/harness/pi/index.js.map +1 -1
- package/dist/{images-C4hiIexM.js → images-xaDv2Fqe.js} +636 -168
- package/dist/images-xaDv2Fqe.js.map +1 -0
- package/dist/index-DCxk3OSJ.d.ts +378 -0
- package/dist/{index-kbSUIer3.d.ts → index-iv9FTXX9.d.ts} +80 -112
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{input-schema-xBofjBKC.js → input-schema-B0Etuo-o.js} +2 -2
- package/dist/{input-schema-xBofjBKC.js.map → input-schema-B0Etuo-o.js.map} +1 -1
- package/dist/lifecycle/index.js +1 -1
- package/dist/{lifecycle-DGorpAmA.js → lifecycle-v1rKHV2C.js} +67 -19
- package/dist/lifecycle-v1rKHV2C.js.map +1 -0
- package/dist/mcp/client/index.d.ts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/models/ai-sdk/index.d.ts +29 -352
- package/dist/models/ai-sdk/index.js +1 -1
- package/dist/models/opencode/index.d.ts +25 -13
- package/dist/models/opencode/index.js +16 -11
- package/dist/models/opencode/index.js.map +1 -1
- package/dist/models/pi-ai/index.d.ts +13 -14
- package/dist/models/pi-ai/index.js +87 -34
- package/dist/models/pi-ai/index.js.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/routing/index.d.ts +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/{session-store-DoPY12xM.d.ts → session-store-_IK6dV-w.d.ts} +14 -2
- package/dist/{session-store-Do4xkDcf.js → session-store-yvwq1f9x.js} +55 -2
- package/dist/session-store-yvwq1f9x.js.map +1 -0
- package/dist/{settings-BjAiPd6Z.js → settings-Dk2il2Hf.js} +4 -1
- package/dist/settings-Dk2il2Hf.js.map +1 -0
- package/dist/skills/index.d.ts +22 -28
- package/dist/skills/index.js +183 -143
- package/dist/skills/index.js.map +1 -1
- package/dist/{src-CQxJFv4l.js → src-DfLzdwlK.js} +3 -3
- package/dist/src-DfLzdwlK.js.map +1 -0
- package/dist/sub-routing.d.ts +1 -1
- package/dist/{tool-VF0qiO7q.js → tool-DkT_DJBm.js} +2 -2
- package/dist/tool-DkT_DJBm.js.map +1 -0
- package/dist/transport-CPh7YGiw.d.ts +623 -0
- package/dist/voice/index.d.ts +1 -1
- package/dist/web/fetch/tools/pi.d.ts +10 -6
- package/dist/web/fetch/tools/pi.js +12 -8
- package/dist/web/fetch/tools/pi.js.map +1 -1
- package/dist/web/search/index.js +1 -1
- package/dist/web/search/tools/ai-sdk.js +2 -2
- package/dist/web/search/tools/pi.d.ts +10 -6
- package/dist/web/search/tools/pi.js +13 -9
- package/dist/web/search/tools/pi.js.map +1 -1
- package/dist/web/search/tools/tanstack-ai.js +2 -2
- package/dist/websockets/index.js +1 -1
- package/dist/{websockets-C3zy8YR0.js → websockets-CyoeosdO.js} +2 -2
- package/dist/{websockets-C3zy8YR0.js.map → websockets-CyoeosdO.js.map} +1 -1
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.js +1 -1
- package/docs/browse-the-web.md +1 -1
- package/docs/chat-agents.md +19 -18
- package/docs/harnesses/pi.md +101 -38
- package/docs/lifecycle.md +7 -1
- package/docs/models-pi-ai.md +66 -20
- package/docs/models.md +197 -172
- package/package.json +12 -7
- package/dist/ai-sdk-C2iTAwUd.js.map +0 -1
- package/dist/browser-CEdNlsaD.js.map +0 -1
- package/dist/images-C4hiIexM.js.map +0 -1
- package/dist/lifecycle-DGorpAmA.js.map +0 -1
- package/dist/session-store-Do4xkDcf.js.map +0 -1
- package/dist/settings-BjAiPd6Z.js.map +0 -1
- package/dist/settings-DnD__xuE.d.ts +0 -349
- package/dist/src-CQxJFv4l.js.map +0 -1
- package/dist/tool-VF0qiO7q.js.map +0 -1
- package/dist/transport-DCyarnwm.d.ts +0 -200
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import {
|
|
2
|
+
_ as DynamicRouteId,
|
|
3
|
+
a as CloudflareAIError$1,
|
|
4
|
+
b as WorkersAIModelId,
|
|
5
|
+
d as CatalogModelId,
|
|
6
|
+
f as CloudflareEmbeddingModelId,
|
|
7
|
+
g as CloudflareTranscriptionModelId,
|
|
8
|
+
h as CloudflareSpeechModelId,
|
|
9
|
+
i as CloudflareAIAttempt,
|
|
10
|
+
l as ModelOptions$1,
|
|
11
|
+
m as CloudflareRerankingModelId,
|
|
12
|
+
o as CloudflareAIErrorCode,
|
|
13
|
+
p as CloudflareImageModelId,
|
|
14
|
+
s as AISettings,
|
|
15
|
+
t as Transport$1,
|
|
16
|
+
u as ProviderGatewaySettings
|
|
17
|
+
} from "./transport-CPh7YGiw.js";
|
|
18
|
+
import {
|
|
19
|
+
APICallError,
|
|
20
|
+
EmbeddingModelV4,
|
|
21
|
+
ImageModelV4,
|
|
22
|
+
LanguageModelV4,
|
|
23
|
+
LanguageModelV4CallOptions,
|
|
24
|
+
LanguageModelV4GenerateResult,
|
|
25
|
+
LanguageModelV4StreamResult,
|
|
26
|
+
RerankingModelV4,
|
|
27
|
+
SpeechModelV4,
|
|
28
|
+
TranscriptionModelV4
|
|
29
|
+
} from "@ai-sdk/provider";
|
|
30
|
+
|
|
31
|
+
//#region src/models/ai-sdk/settings.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* A language model id: a Workers AI id, an AI Gateway catalog id
|
|
34
|
+
* (`<author>/<model>`), or a dynamic route (`dynamic/<route>`). All three run
|
|
35
|
+
* on `env.AI.run`.
|
|
36
|
+
*
|
|
37
|
+
* @experimental This surface is experimental and may change.
|
|
38
|
+
*/
|
|
39
|
+
type CloudflareLanguageModelId =
|
|
40
|
+
| WorkersAIModelId
|
|
41
|
+
| DynamicRouteId
|
|
42
|
+
| (CatalogModelId & {});
|
|
43
|
+
/**
|
|
44
|
+
* One leg of a fallback chain: a language model id, or any AI SDK language
|
|
45
|
+
* model — which is routed through AI Gateway like `ai(model)`.
|
|
46
|
+
*
|
|
47
|
+
* @experimental This surface is experimental and may change.
|
|
48
|
+
*/
|
|
49
|
+
type FallbackLeg = CloudflareLanguageModelId | LanguageModelV4;
|
|
50
|
+
/**
|
|
51
|
+
* Per-model and per-call options: the framework-neutral options, with the
|
|
52
|
+
* fallback leg type this module accepts.
|
|
53
|
+
*
|
|
54
|
+
* @experimental This surface is experimental and may change.
|
|
55
|
+
*/
|
|
56
|
+
type ModelOptions = ModelOptions$1<FallbackLeg>;
|
|
57
|
+
/**
|
|
58
|
+
* Which key authenticates a vendor model object routed through AI Gateway.
|
|
59
|
+
*
|
|
60
|
+
* @experimental This surface is experimental and may change.
|
|
61
|
+
*/
|
|
62
|
+
interface VendorKeyOptions {
|
|
63
|
+
/**
|
|
64
|
+
* `"gateway"` (the default) strips the key the vendor's provider put on the
|
|
65
|
+
* request, so the gateway supplies one: Unified Billing, or a BYOK key
|
|
66
|
+
* stored on the gateway. `"request"` forwards that key to the vendor, for a
|
|
67
|
+
* key you hold yourself, e.g. `createAnthropic({ apiKey: env.ANTHROPIC_KEY })`.
|
|
68
|
+
*
|
|
69
|
+
* It belongs to the model it is set on, so a fallback leg keeps its own.
|
|
70
|
+
*/
|
|
71
|
+
vendorKey?: "gateway" | "request";
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The options accepted next to a model object — `ai(anthropic("…"), { … })`.
|
|
75
|
+
* {@link ModelOptions} plus {@link VendorKeyOptions.vendorKey}; the
|
|
76
|
+
* Workers-AI-only knobs (`reasoningEffort`, `chatTemplateKwargs`) are ignored
|
|
77
|
+
* with a warning.
|
|
78
|
+
*
|
|
79
|
+
* @experimental This surface is experimental and may change.
|
|
80
|
+
*/
|
|
81
|
+
type GatewayModelOptions = ModelOptions & VendorKeyOptions;
|
|
82
|
+
/**
|
|
83
|
+
* The options `ai.routed()` takes: the gateway options, `headers`,
|
|
84
|
+
* `sessionAffinity` and `vendorKey`.
|
|
85
|
+
*
|
|
86
|
+
* A routed embedding, image, speech or transcription model is the vendor's
|
|
87
|
+
* own, and only its transport is ours — there is no chain to fall back through
|
|
88
|
+
* and no Workers AI reasoning knob to apply. They are absent from the type
|
|
89
|
+
* rather than dropped at runtime, so the mistake is a compile error naming the
|
|
90
|
+
* option.
|
|
91
|
+
*
|
|
92
|
+
* @experimental This surface is experimental and may change.
|
|
93
|
+
*/
|
|
94
|
+
type RoutedModelOptions = Omit<
|
|
95
|
+
ModelOptions,
|
|
96
|
+
"fallback" | "reasoningEffort" | "chatTemplateKwargs"
|
|
97
|
+
> &
|
|
98
|
+
VendorKeyOptions;
|
|
99
|
+
/**
|
|
100
|
+
* The options the Workers-AI-only methods take — `ai.embedding`, `ai.image`,
|
|
101
|
+
* `ai.speech`, `ai.transcription`, `ai.reranking`.
|
|
102
|
+
*
|
|
103
|
+
* Their fallback legs are ids: those models run through the Workers AI run
|
|
104
|
+
* path, which resolves a leg by id, so a model object would type-check and
|
|
105
|
+
* then be silently dropped.
|
|
106
|
+
*
|
|
107
|
+
* @experimental This surface is experimental and may change.
|
|
108
|
+
*/
|
|
109
|
+
type ModalityOptions = ModelOptions$1<WorkersAIModelId>;
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/models/ai-sdk/errors.d.ts
|
|
112
|
+
/**
|
|
113
|
+
* Error thrown for every failed Cloudflare AI call, whether it came back as a
|
|
114
|
+
* non-2xx `Response` or as a thrown Workers AI binding error.
|
|
115
|
+
*
|
|
116
|
+
* Extends the AI SDK's `APICallError` so `ai`'s built-in retry loop honours
|
|
117
|
+
* {@link CloudflareAIError.isRetryable} without any extra wiring.
|
|
118
|
+
*
|
|
119
|
+
* @experimental This surface is experimental and may change.
|
|
120
|
+
*/
|
|
121
|
+
declare class CloudflareAIError extends APICallError {
|
|
122
|
+
/** HTTP status, when the failure carried one. */
|
|
123
|
+
readonly status: number | undefined;
|
|
124
|
+
/** Coarse classification used for routing and fallback decisions. */
|
|
125
|
+
readonly code: CloudflareAIErrorCode;
|
|
126
|
+
/** `cf-aig-log-id` of the failed request, when the response carried one. */
|
|
127
|
+
readonly logId: string | undefined;
|
|
128
|
+
/** The model id that produced this error. */
|
|
129
|
+
readonly model: string;
|
|
130
|
+
/** Every leg tried, when this error ends a fallback chain. */
|
|
131
|
+
readonly attempts: CloudflareAIAttempt[] | undefined;
|
|
132
|
+
constructor(options: {
|
|
133
|
+
message: string;
|
|
134
|
+
model: string;
|
|
135
|
+
url: string;
|
|
136
|
+
requestBodyValues: unknown;
|
|
137
|
+
status?: number;
|
|
138
|
+
code: CloudflareAIErrorCode;
|
|
139
|
+
logId?: string;
|
|
140
|
+
responseHeaders?: Record<string, string>;
|
|
141
|
+
responseBody?: string;
|
|
142
|
+
isRetryable?: boolean;
|
|
143
|
+
data?: unknown;
|
|
144
|
+
cause?: unknown;
|
|
145
|
+
attempts?: CloudflareAIAttempt[];
|
|
146
|
+
});
|
|
147
|
+
/** Lifts the framework-neutral core error into the AI SDK error type. */
|
|
148
|
+
static fromCore(error: CloudflareAIError$1): CloudflareAIError;
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/models/ai-sdk/transport.d.ts
|
|
152
|
+
/**
|
|
153
|
+
* The transport this module uses: the run path for a model id, and the
|
|
154
|
+
* provider-native path for a vendor's own model object, through the binding
|
|
155
|
+
* or over HTTP.
|
|
156
|
+
*
|
|
157
|
+
* @experimental This surface is experimental and may change.
|
|
158
|
+
*/
|
|
159
|
+
type Transport = Transport$1;
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/models/ai-sdk/models/language.d.ts
|
|
162
|
+
/**
|
|
163
|
+
* Typed observability attached to every result under
|
|
164
|
+
* `providerMetadata.cloudflare`, so consumers never have to walk response
|
|
165
|
+
* objects looking for a gateway log id.
|
|
166
|
+
*
|
|
167
|
+
* @experimental This surface is experimental and may change.
|
|
168
|
+
*/
|
|
169
|
+
interface CloudflareMetadata {
|
|
170
|
+
/** The model that actually answered — the fallback leg, when one was used. */
|
|
171
|
+
model: string;
|
|
172
|
+
/** The gateway id the request went through. Absent when none handled it. */
|
|
173
|
+
gateway?: string;
|
|
174
|
+
/**
|
|
175
|
+
* The gateway provider slug, for a vendor's model object sent to the
|
|
176
|
+
* provider-native path. Absent for a model id.
|
|
177
|
+
*/
|
|
178
|
+
provider?: string;
|
|
179
|
+
/** `cf-aig-log-id`, or the binding's last log id. */
|
|
180
|
+
logId?: string;
|
|
181
|
+
/** `cf-aig-event-id` — correlates the requests of one gateway event. */
|
|
182
|
+
eventId?: string;
|
|
183
|
+
/** `cf-aig-request-id` — the gateway's id for this request. */
|
|
184
|
+
requestId?: string;
|
|
185
|
+
/** `cf-aig-trace-id` — the trace this request belongs to. */
|
|
186
|
+
traceId?: string;
|
|
187
|
+
/** `cf-aig-run-id`, when the gateway sends one. */
|
|
188
|
+
runId?: string;
|
|
189
|
+
/** `cf-aig-cache-status`, e.g. `HIT` or `MISS`. */
|
|
190
|
+
cacheStatus?: string;
|
|
191
|
+
/** `cf-aig-step` — which step of a gateway route answered. */
|
|
192
|
+
step?: number;
|
|
193
|
+
}
|
|
194
|
+
/** Everything a language model needs from the provider that created it. */
|
|
195
|
+
interface LanguageModelConfig {
|
|
196
|
+
transport: Transport;
|
|
197
|
+
/**
|
|
198
|
+
* The provider-wide gateway defaults, in any of the spellings `createAI`
|
|
199
|
+
* takes: a bare id, a `gateway` object, or the whole settings object with
|
|
200
|
+
* the flat gateway keys on it.
|
|
201
|
+
*/
|
|
202
|
+
providerGateway: string | ProviderGatewaySettings | undefined;
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/models/ai-sdk/models/gateway.d.ts
|
|
206
|
+
/**
|
|
207
|
+
* A `LanguageModelV4` that is the user's own vendor model, routed through AI
|
|
208
|
+
* Gateway. Generation, parsing, tool handling and error shapes stay the
|
|
209
|
+
* vendor's; only the transport is Cloudflare's.
|
|
210
|
+
*
|
|
211
|
+
* @experimental This surface is experimental and may change.
|
|
212
|
+
*/
|
|
213
|
+
declare class GatewayLanguageModel implements LanguageModelV4 {
|
|
214
|
+
#private;
|
|
215
|
+
readonly specificationVersion: "v4";
|
|
216
|
+
constructor(
|
|
217
|
+
model: LanguageModelV4,
|
|
218
|
+
options: GatewayModelOptions | undefined,
|
|
219
|
+
config: LanguageModelConfig
|
|
220
|
+
);
|
|
221
|
+
/** The vendor's own provider name — `anthropic.messages`, `openai.responses`. */
|
|
222
|
+
get provider(): string;
|
|
223
|
+
/** The vendor's own id spelling, which the gateway requires verbatim. */
|
|
224
|
+
get modelId(): string;
|
|
225
|
+
get supportedUrls(): LanguageModelV4["supportedUrls"];
|
|
226
|
+
/** The model this wraps, for callers that need the vendor object back. */
|
|
227
|
+
get model(): LanguageModelV4;
|
|
228
|
+
doGenerate(
|
|
229
|
+
options: LanguageModelV4CallOptions
|
|
230
|
+
): Promise<LanguageModelV4GenerateResult>;
|
|
231
|
+
doStream(
|
|
232
|
+
options: LanguageModelV4CallOptions
|
|
233
|
+
): Promise<LanguageModelV4StreamResult>;
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/models/ai-sdk/index.d.ts
|
|
237
|
+
/**
|
|
238
|
+
* The provider `createAI` returns. Call it with a model id — a Workers AI id,
|
|
239
|
+
* an AI Gateway catalog id, or a dynamic route — or with a model another
|
|
240
|
+
* provider built.
|
|
241
|
+
*
|
|
242
|
+
* It satisfies `ProviderV4`, so it drops into
|
|
243
|
+
* `createProviderRegistry({ cloudflare: ai })` and into
|
|
244
|
+
* `globalThis.AI_SDK_DEFAULT_PROVIDER`, where the AI SDK resolves a bare
|
|
245
|
+
* `model: "@cf/…"` or `"openai/gpt-5.5"` string through it.
|
|
246
|
+
*
|
|
247
|
+
* @experimental This surface is experimental and may change.
|
|
248
|
+
*/
|
|
249
|
+
interface AI {
|
|
250
|
+
/**
|
|
251
|
+
* A language model: `@cf/…` (Workers AI), `<author>/<model>` (the AI
|
|
252
|
+
* Gateway catalog, in its spelling), or `dynamic/<route>`.
|
|
253
|
+
*/
|
|
254
|
+
(modelId: CloudflareLanguageModelId, options?: ModelOptions): LanguageModelV4;
|
|
255
|
+
/**
|
|
256
|
+
* Any AI SDK v4 language model, sent to AI Gateway's provider-native path
|
|
257
|
+
* with its own request and parser.
|
|
258
|
+
*/
|
|
259
|
+
(model: LanguageModelV4, options?: GatewayModelOptions): LanguageModelV4;
|
|
260
|
+
/** The AI SDK provider specification this implements. */
|
|
261
|
+
readonly specificationVersion: "v4";
|
|
262
|
+
/** Same as calling the provider directly. */
|
|
263
|
+
languageModel(
|
|
264
|
+
modelId: CloudflareLanguageModelId,
|
|
265
|
+
options?: ModelOptions
|
|
266
|
+
): LanguageModelV4;
|
|
267
|
+
languageModel(
|
|
268
|
+
model: LanguageModelV4,
|
|
269
|
+
options?: GatewayModelOptions
|
|
270
|
+
): LanguageModelV4;
|
|
271
|
+
/** The `ProviderV4` shape: a registry resolves models by string alone. */
|
|
272
|
+
languageModel(modelId: string, options?: ModelOptions): LanguageModelV4;
|
|
273
|
+
/**
|
|
274
|
+
* Any other v4 model a vendor built — embedding, image, speech,
|
|
275
|
+
* transcription — sent to AI Gateway's provider-native path with its own
|
|
276
|
+
* code intact.
|
|
277
|
+
*/
|
|
278
|
+
routed<T extends object>(model: T, options?: RoutedModelOptions): T;
|
|
279
|
+
/** A text-embedding model from the Workers AI catalog. */
|
|
280
|
+
embedding(
|
|
281
|
+
modelId: CloudflareEmbeddingModelId,
|
|
282
|
+
options?: ModalityOptions
|
|
283
|
+
): EmbeddingModelV4;
|
|
284
|
+
/** Alias of {@link AI.embedding}, the `ProviderV4` method name. */
|
|
285
|
+
embeddingModel(
|
|
286
|
+
modelId: CloudflareEmbeddingModelId,
|
|
287
|
+
options?: ModalityOptions
|
|
288
|
+
): EmbeddingModelV4;
|
|
289
|
+
/**
|
|
290
|
+
* Alias of {@link AI.embedding}.
|
|
291
|
+
*
|
|
292
|
+
* @deprecated `embeddingModel` is the `ProviderV4` name; this is the older
|
|
293
|
+
* `ProviderV2`/`ProviderV3` spelling, kept for one release.
|
|
294
|
+
*/
|
|
295
|
+
textEmbeddingModel(
|
|
296
|
+
modelId: CloudflareEmbeddingModelId,
|
|
297
|
+
options?: ModalityOptions
|
|
298
|
+
): EmbeddingModelV4;
|
|
299
|
+
/** A text-to-image model from the Workers AI catalog. */
|
|
300
|
+
image(
|
|
301
|
+
modelId: CloudflareImageModelId,
|
|
302
|
+
options?: ModalityOptions
|
|
303
|
+
): ImageModelV4;
|
|
304
|
+
/** Alias of {@link AI.image}, the `ProviderV4` method name. */
|
|
305
|
+
imageModel(
|
|
306
|
+
modelId: CloudflareImageModelId,
|
|
307
|
+
options?: ModalityOptions
|
|
308
|
+
): ImageModelV4;
|
|
309
|
+
/** A speech-recognition model from the Workers AI catalog. */
|
|
310
|
+
transcription(
|
|
311
|
+
modelId: CloudflareTranscriptionModelId,
|
|
312
|
+
options?: ModalityOptions
|
|
313
|
+
): TranscriptionModelV4;
|
|
314
|
+
/** Alias of {@link AI.transcription}, the `ProviderV4` method name. */
|
|
315
|
+
transcriptionModel(
|
|
316
|
+
modelId: CloudflareTranscriptionModelId,
|
|
317
|
+
options?: ModalityOptions
|
|
318
|
+
): TranscriptionModelV4;
|
|
319
|
+
/** A text-to-speech model from the Workers AI catalog. */
|
|
320
|
+
speech(
|
|
321
|
+
modelId: CloudflareSpeechModelId,
|
|
322
|
+
options?: ModalityOptions
|
|
323
|
+
): SpeechModelV4;
|
|
324
|
+
/** Alias of {@link AI.speech}, the `ProviderV4` method name. */
|
|
325
|
+
speechModel(
|
|
326
|
+
modelId: CloudflareSpeechModelId,
|
|
327
|
+
options?: ModalityOptions
|
|
328
|
+
): SpeechModelV4;
|
|
329
|
+
/** A reranking model from the Workers AI catalog. */
|
|
330
|
+
reranking(
|
|
331
|
+
modelId: CloudflareRerankingModelId,
|
|
332
|
+
options?: ModalityOptions
|
|
333
|
+
): RerankingModelV4;
|
|
334
|
+
/** Alias of {@link AI.reranking}, the `ProviderV4` method name. */
|
|
335
|
+
rerankingModel(
|
|
336
|
+
modelId: CloudflareRerankingModelId,
|
|
337
|
+
options?: ModalityOptions
|
|
338
|
+
): RerankingModelV4;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Creates a provider over Workers AI and the AI Gateway catalog.
|
|
342
|
+
*
|
|
343
|
+
* A Workers AI id goes to Workers AI and a catalog id or dynamic route to AI
|
|
344
|
+
* Gateway's `/run`, both on `env.AI.run`; a vendor's model object goes to AI
|
|
345
|
+
* Gateway's provider-native path. With `{ accountId, apiToken }` instead of
|
|
346
|
+
* `binding`, the same requests go to the REST API and to
|
|
347
|
+
* `gateway.ai.cloudflare.com`. Gateway
|
|
348
|
+
* options are flat (`id`, `cacheTtl`, …) or nested under `gateway`; per-model
|
|
349
|
+
* options and per-call `providerOptions.cloudflare` override them in that
|
|
350
|
+
* order.
|
|
351
|
+
*
|
|
352
|
+
* ```ts
|
|
353
|
+
* const ai = createAI({ binding: env.AI, id: "prod", cacheTtl: 60 });
|
|
354
|
+
*
|
|
355
|
+
* ai("@cf/zai-org/glm-4.7-flash");
|
|
356
|
+
* ai("anthropic/claude-opus-4.8", { fallback: ["openai/gpt-5.5"] });
|
|
357
|
+
* ai.embedding("@cf/baai/bge-base-en-v1.5");
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @experimental This surface is experimental and may change.
|
|
361
|
+
*/
|
|
362
|
+
declare function createAI(settings: AISettings): AI;
|
|
363
|
+
//#endregion
|
|
364
|
+
export {
|
|
365
|
+
CloudflareAIError as a,
|
|
366
|
+
GatewayModelOptions as c,
|
|
367
|
+
RoutedModelOptions as d,
|
|
368
|
+
VendorKeyOptions as f,
|
|
369
|
+
CloudflareMetadata as i,
|
|
370
|
+
ModalityOptions as l,
|
|
371
|
+
createAI as n,
|
|
372
|
+
CloudflareLanguageModelId as o,
|
|
373
|
+
GatewayLanguageModel as r,
|
|
374
|
+
FallbackLeg as s,
|
|
375
|
+
AI as t,
|
|
376
|
+
ModelOptions as u
|
|
377
|
+
};
|
|
378
|
+
//# sourceMappingURL=index-DCxk3OSJ.d.ts.map
|
|
@@ -144,22 +144,65 @@ declare function r2(
|
|
|
144
144
|
options?: R2SkillSourceOptions
|
|
145
145
|
): SkillSource;
|
|
146
146
|
//#endregion
|
|
147
|
-
//#region src/skills/
|
|
147
|
+
//#region src/skills/workspace.d.ts
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* structurally, so the runner does not depend on a filesystem package.
|
|
149
|
+
* The Workspace Agent Skills read and write: a `Workspace` from
|
|
150
|
+
* `@cloudflare/computer`, or anything with the same `fs` methods.
|
|
152
151
|
*/
|
|
153
152
|
interface SkillWorkspace {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
153
|
+
readonly fs: {
|
|
154
|
+
stat(path: string): Promise<{
|
|
155
|
+
size: number;
|
|
156
|
+
isDirectory: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
readFile(path: string): Promise<ReadableStream<Uint8Array>>;
|
|
159
|
+
writeFile(path: string, content: Uint8Array): Promise<void>;
|
|
160
|
+
mkdir(
|
|
161
|
+
path: string,
|
|
162
|
+
options?: {
|
|
163
|
+
recursive?: boolean;
|
|
164
|
+
}
|
|
165
|
+
): Promise<void>;
|
|
166
|
+
readdir(path: string): Promise<
|
|
167
|
+
Array<{
|
|
168
|
+
name: string;
|
|
169
|
+
size: number;
|
|
170
|
+
isDirectory: boolean;
|
|
171
|
+
}>
|
|
172
|
+
>;
|
|
173
|
+
find(
|
|
174
|
+
directory: string,
|
|
175
|
+
pattern?: string
|
|
176
|
+
): Promise<
|
|
177
|
+
Array<{
|
|
178
|
+
path: string;
|
|
179
|
+
type: "file" | "dir";
|
|
180
|
+
}>
|
|
181
|
+
>;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/** Options for projecting Agent Skills into a Workspace. */
|
|
185
|
+
interface SkillWorkspaceSeedOptions {
|
|
186
|
+
/** Destination directory. Defaults to `/workspace/.agents/skills`. */
|
|
187
|
+
readonly root?: string;
|
|
188
|
+
/** Existing-file policy. Default `"preserve"` keeps Workspace edits. */
|
|
189
|
+
readonly onConflict?: "preserve" | "replace";
|
|
190
|
+
}
|
|
191
|
+
/** Summary returned after projecting Agent Skills into a Workspace. */
|
|
192
|
+
interface SkillWorkspaceSeedResult {
|
|
193
|
+
/** Files written from source content. */
|
|
194
|
+
readonly written: number;
|
|
195
|
+
/** Existing files preserved without a write. */
|
|
196
|
+
readonly preserved: number;
|
|
197
|
+
/** Files skipped because their source content could not be read or written. */
|
|
198
|
+
readonly skipped: number;
|
|
199
|
+
/** Non-fatal per-file diagnostics. */
|
|
200
|
+
readonly warnings: readonly string[];
|
|
201
|
+
/** Absolute Workspace directory containing the projected skills. */
|
|
202
|
+
readonly root: string;
|
|
162
203
|
}
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/skills/runner.d.ts
|
|
163
206
|
/**
|
|
164
207
|
* Options for {@link runner}.
|
|
165
208
|
*
|
|
@@ -190,78 +233,6 @@ declare function runner(
|
|
|
190
233
|
options: WorkerSkillScriptRunnerOptions
|
|
191
234
|
): SkillScriptRunner;
|
|
192
235
|
//#endregion
|
|
193
|
-
//#region src/skills/workspace.d.ts
|
|
194
|
-
/**
|
|
195
|
-
* Computer-style Workspace shape used for Agent Skills projection.
|
|
196
|
-
* `@cloudflare/computer.Workspace` satisfies this through `workspace.fs`.
|
|
197
|
-
*/
|
|
198
|
-
interface ComputerSkillWorkspace {
|
|
199
|
-
readonly fs: {
|
|
200
|
-
stat(path: string): Promise<unknown>;
|
|
201
|
-
readFile(
|
|
202
|
-
path: string,
|
|
203
|
-
options?: {
|
|
204
|
-
byteOffset?: number;
|
|
205
|
-
byteLength?: number;
|
|
206
|
-
}
|
|
207
|
-
): Promise<ReadableStream<Uint8Array>>;
|
|
208
|
-
readFile(path: string, encoding: "utf8"): Promise<string>;
|
|
209
|
-
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
210
|
-
mkdir(
|
|
211
|
-
path: string,
|
|
212
|
-
options?: {
|
|
213
|
-
recursive?: boolean;
|
|
214
|
-
}
|
|
215
|
-
): Promise<void>;
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Legacy direct filesystem shape used for Agent Skills projection.
|
|
220
|
-
* `@cloudflare/shell.Workspace` and Think `WorkspaceLike` satisfy this shape.
|
|
221
|
-
*/
|
|
222
|
-
interface LegacySkillWorkspace {
|
|
223
|
-
stat(path: string): Promise<unknown | null>;
|
|
224
|
-
readFile(path: string): Promise<string | null>;
|
|
225
|
-
readFileBytes(path: string): Promise<Uint8Array | null>;
|
|
226
|
-
writeFile(path: string, content: string): Promise<void>;
|
|
227
|
-
writeFileBytes(
|
|
228
|
-
path: string,
|
|
229
|
-
content: Uint8Array | ArrayBuffer,
|
|
230
|
-
mediaType?: string
|
|
231
|
-
): Promise<void>;
|
|
232
|
-
mkdir(
|
|
233
|
-
path: string,
|
|
234
|
-
options?: {
|
|
235
|
-
recursive?: boolean;
|
|
236
|
-
}
|
|
237
|
-
): Promise<void>;
|
|
238
|
-
}
|
|
239
|
-
/** Workspace accepted by `SkillRegistry.seedWorkspace()`. */
|
|
240
|
-
type SkillProjectionWorkspace = ComputerSkillWorkspace | LegacySkillWorkspace;
|
|
241
|
-
/** Options for projecting Agent Skills into a Workspace. */
|
|
242
|
-
interface SkillWorkspaceSeedOptions {
|
|
243
|
-
/**
|
|
244
|
-
* Destination directory. Defaults to `/workspace/.agents/skills` for a
|
|
245
|
-
* Computer Workspace and `/.agents/skills` for a legacy Shell Workspace.
|
|
246
|
-
*/
|
|
247
|
-
readonly root?: string;
|
|
248
|
-
/** Existing-file policy. Default `"preserve"` keeps Workspace edits. */
|
|
249
|
-
readonly onConflict?: "preserve" | "replace";
|
|
250
|
-
}
|
|
251
|
-
/** Summary returned after projecting Agent Skills into a Workspace. */
|
|
252
|
-
interface SkillWorkspaceSeedResult {
|
|
253
|
-
/** Files written from source content. */
|
|
254
|
-
readonly written: number;
|
|
255
|
-
/** Existing files preserved without a write. */
|
|
256
|
-
readonly preserved: number;
|
|
257
|
-
/** Files skipped because their source content could not be read or written. */
|
|
258
|
-
readonly skipped: number;
|
|
259
|
-
/** Non-fatal per-file diagnostics. */
|
|
260
|
-
readonly warnings: readonly string[];
|
|
261
|
-
/** Absolute Workspace directory containing the projected skills. */
|
|
262
|
-
readonly root: string;
|
|
263
|
-
}
|
|
264
|
-
//#endregion
|
|
265
236
|
//#region src/skills/registry.d.ts
|
|
266
237
|
declare class SkillRegistry {
|
|
267
238
|
readonly contextLabel = "think_skills";
|
|
@@ -284,12 +255,12 @@ declare class SkillRegistry {
|
|
|
284
255
|
load(): Promise<void>;
|
|
285
256
|
refresh(): Promise<void>;
|
|
286
257
|
/**
|
|
287
|
-
* Seed resolved Agent Skills into
|
|
258
|
+
* Seed resolved Agent Skills into a Workspace.
|
|
288
259
|
* Existing files are preserved by default, and become authoritative for
|
|
289
260
|
* activation, resource reads, and script execution.
|
|
290
261
|
*/
|
|
291
262
|
seedWorkspace(
|
|
292
|
-
workspace:
|
|
263
|
+
workspace: SkillWorkspace,
|
|
293
264
|
options?: SkillWorkspaceSeedOptions
|
|
294
265
|
): Promise<SkillWorkspaceSeedResult>;
|
|
295
266
|
/**
|
|
@@ -298,7 +269,7 @@ declare class SkillRegistry {
|
|
|
298
269
|
* matches the recorded projection fingerprint.
|
|
299
270
|
*/
|
|
300
271
|
useWorkspace(
|
|
301
|
-
workspace:
|
|
272
|
+
workspace: SkillWorkspace,
|
|
302
273
|
options?: SkillWorkspaceSeedOptions
|
|
303
274
|
): Promise<void>;
|
|
304
275
|
private writeSeedFile;
|
|
@@ -312,32 +283,29 @@ declare class SkillRegistry {
|
|
|
312
283
|
}
|
|
313
284
|
//#endregion
|
|
314
285
|
export {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
SkillScriptContext as S,
|
|
319
|
-
SkillSource as T,
|
|
320
|
-
SkillManifestResource as _,
|
|
286
|
+
parseSkillFrontmatter as C,
|
|
287
|
+
SkillSource as S,
|
|
288
|
+
SkillResourceDescriptor as _,
|
|
321
289
|
SkillWorkspaceSeedOptions as a,
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
290
|
+
SkillScriptRequest as b,
|
|
291
|
+
r2 as c,
|
|
292
|
+
SkillDescriptor as d,
|
|
293
|
+
SkillManifest as f,
|
|
294
|
+
SkillResource as g,
|
|
295
|
+
SkillRegistrySnapshot as h,
|
|
296
|
+
SkillWorkspace as i,
|
|
297
|
+
fromManifest as l,
|
|
298
|
+
SkillManifestResource as m,
|
|
299
|
+
WorkerSkillScriptRunnerOptions as n,
|
|
332
300
|
SkillWorkspaceSeedResult as o,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
301
|
+
SkillManifestEntry as p,
|
|
302
|
+
runner as r,
|
|
303
|
+
R2SkillSourceOptions as s,
|
|
336
304
|
SkillRegistry as t,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
305
|
+
SkillContent as u,
|
|
306
|
+
SkillRunContext as v,
|
|
307
|
+
parseSkillMarkdown as w,
|
|
308
|
+
SkillScriptRunner as x,
|
|
309
|
+
SkillScriptContext as y
|
|
342
310
|
};
|
|
343
|
-
//# sourceMappingURL=index-
|
|
311
|
+
//# sourceMappingURL=index-iv9FTXX9.d.ts.map
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { MessageType } from "./types.js";
|
|
|
7
7
|
import { createHeaderBasedEmailResolver } from "./email.js";
|
|
8
8
|
import { n as withInvocationScope } from "./cloudflare-Dzvc7V2N.js";
|
|
9
9
|
import { SUB_PREFIX, buildAgentPath, buildAgentUrl, getSubAgentByName, parseSubAgentPath, routeSubAgentRequest } from "./sub-routing.js";
|
|
10
|
-
import { a as routeAgentEmail, i as getCurrentAgent, n as DEFAULT_AGENT_STATIC_OPTIONS, r as StreamingResponse, t as Agent } from "./src-
|
|
10
|
+
import { a as routeAgentEmail, i as getCurrentAgent, n as DEFAULT_AGENT_STATIC_OPTIONS, r as StreamingResponse, t as Agent } from "./src-DfLzdwlK.js";
|
|
11
11
|
import { isDurableObjectCodeUpdateReset, isDurableObjectMemoryLimitReset, isDurableObjectStorageReset, isPlatformTransientError } from "./retries.js";
|
|
12
12
|
import { SqlError } from "./sql-error.js";
|
|
13
13
|
import { i as normalizeServerId, n as MCP_SERVER_ID_MAX_LENGTH } from "./client-BnYbNT3z.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as MAX_WEB_SEARCH_QUERY_LENGTH } from "./tool-
|
|
1
|
+
import { u as MAX_WEB_SEARCH_QUERY_LENGTH } from "./tool-DkT_DJBm.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/web/search/tools/input-schema.ts
|
|
4
4
|
/**
|
|
@@ -20,4 +20,4 @@ function webSearchInputSchema(maxLimit) {
|
|
|
20
20
|
//#endregion
|
|
21
21
|
export { webSearchInputSchema as t };
|
|
22
22
|
|
|
23
|
-
//# sourceMappingURL=input-schema-
|
|
23
|
+
//# sourceMappingURL=input-schema-B0Etuo-o.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-schema-
|
|
1
|
+
{"version":3,"file":"input-schema-B0Etuo-o.js","names":[],"sources":["../src/web/search/tools/input-schema.ts"],"sourcesContent":["/**\n * The zod input schema shared by the AI SDK and TanStack AI adapters. Kept\n * out of the core so the pi adapter, which uses TypeBox, does not need zod.\n * Internal — not an entry point.\n */\nimport { z } from \"zod\";\nimport {\n MAX_WEB_SEARCH_QUERY_LENGTH,\n type WebSearchToolInput\n} from \"../contract\";\n\n/**\n * The model's input schema. The description tells the model the host's\n * `limit`; a larger value is not rejected (which would cost a validation\n * round trip) but capped by the core.\n */\nexport function webSearchInputSchema(maxLimit: number) {\n return z.object({\n query: z\n .string()\n .min(1)\n .max(MAX_WEB_SEARCH_QUERY_LENGTH)\n .describe(\"What to search for.\"),\n limit: z\n .number()\n .int()\n .min(1)\n .optional()\n .describe(`How many results to return (at most ${maxLimit}).`)\n }) satisfies z.ZodType<WebSearchToolInput>;\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAgB,qBAAqB,UAAkB;CACrD,OAAO,EAAE,OAAO;EACd,OAAO,EACJ,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,2BAA2B,CAAC,CAChC,SAAS,qBAAqB;EACjC,OAAO,EACJ,OAAO,CAAC,CACR,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,SAAS,CAAC,CACV,SAAS,uCAAuC,SAAS,GAAG;CACjE,CAAC;AACH"}
|
package/dist/lifecycle/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { n as getCurrentAgent } from "../current-agent-DhoDkSnH.js";
|
|
2
2
|
import { t as LifecycleCapability } from "../capability-DBAKc6UZ.js";
|
|
3
|
-
import { t as Lifecycle } from "../lifecycle-
|
|
3
|
+
import { t as Lifecycle } from "../lifecycle-v1rKHV2C.js";
|
|
4
4
|
export { Lifecycle, LifecycleCapability, getCurrentAgent };
|