the universal sandbox runtime for agents and humans. pocketenv.io
sandbox openclaw agent claude-code vercel-sandbox deno-sandbox cloudflare-sandbox atproto sprites daytona
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add BACKUP_BUCKET and update Cloudflare types

+2099 -77
+4
apps/cf-sandbox/deploy/amp/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/claude/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/codex/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/copilot/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/crush/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/cursor/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/docker/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/gemini/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/kilo/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/kiro/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/mise/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/nanoclaw/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/nix/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/nullclaw/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/openclaw/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/opencode/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/opencrust/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/picoclaw/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/pkgx/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/wasmer/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+4
apps/cf-sandbox/deploy/zeroclaw/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement
+2011 -77
apps/cf-sandbox/worker-configuration.d.ts
··· 1 1 /* eslint-disable */ 2 - // Generated by Wrangler by running `wrangler types` (hash: 06221635abc1d93b65545951625446ab) 3 - // Runtime types generated with workerd@1.20260205.0 2025-05-06 nodejs_compat 2 + // Generated by Wrangler by running `wrangler types` (hash: 007951150813dda1c7519cd16fb68047) 3 + // Runtime types generated with workerd@1.20260401.1 2025-05-06 nodejs_compat 4 4 declare namespace Cloudflare { 5 5 interface GlobalProps { 6 6 mainModule: typeof import("./src/index"); ··· 8 8 } 9 9 interface Env { 10 10 POCKETENV_COPY: R2Bucket; 11 + BACKUP_BUCKET: R2Bucket; 11 12 HYPERDRIVE: Hyperdrive; 12 13 SANDBOX_TRANSPORT: "websocket"; 13 14 PREVIEW_TOKEN: "sandbox"; ··· 450 451 passThroughOnException(): void; 451 452 readonly props: Props; 452 453 } 453 - type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext) => Response | Promise<Response>; 454 - type ExportedHandlerTailHandler<Env = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>; 455 - type ExportedHandlerTraceHandler<Env = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>; 456 - type ExportedHandlerTailStreamHandler<Env = unknown> = (event: TailStream.TailEvent<TailStream.Onset>, env: Env, ctx: ExecutionContext) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>; 457 - type ExportedHandlerScheduledHandler<Env = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise<void>; 458 - type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext) => void | Promise<void>; 459 - type ExportedHandlerTestHandler<Env = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext) => void | Promise<void>; 460 - interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown> { 461 - fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>; 462 - tail?: ExportedHandlerTailHandler<Env>; 463 - trace?: ExportedHandlerTraceHandler<Env>; 464 - tailStream?: ExportedHandlerTailStreamHandler<Env>; 465 - scheduled?: ExportedHandlerScheduledHandler<Env>; 466 - test?: ExportedHandlerTestHandler<Env>; 467 - email?: EmailExportedHandler<Env>; 468 - queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>; 454 + type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown, Props = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext<Props>) => Response | Promise<Response>; 455 + type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (socket: Socket, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 456 + type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 457 + type ExportedHandlerTraceHandler<Env = unknown, Props = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 458 + type ExportedHandlerTailStreamHandler<Env = unknown, Props = unknown> = (event: TailStream.TailEvent<TailStream.Onset>, env: Env, ctx: ExecutionContext<Props>) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>; 459 + type ExportedHandlerScheduledHandler<Env = unknown, Props = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 460 + type ExportedHandlerQueueHandler<Env = unknown, Message = unknown, Props = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 461 + type ExportedHandlerTestHandler<Env = unknown, Props = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 462 + interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown, Props = unknown> { 463 + fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>; 464 + connect?: ExportedHandlerConnectHandler<Env, Props>; 465 + tail?: ExportedHandlerTailHandler<Env, Props>; 466 + trace?: ExportedHandlerTraceHandler<Env, Props>; 467 + tailStream?: ExportedHandlerTailStreamHandler<Env, Props>; 468 + scheduled?: ExportedHandlerScheduledHandler<Env, Props>; 469 + test?: ExportedHandlerTestHandler<Env, Props>; 470 + email?: EmailExportedHandler<Env, Props>; 471 + queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>; 469 472 } 470 473 interface StructuredSerializeOptions { 471 474 transfer?: any[]; ··· 478 481 interface AlarmInvocationInfo { 479 482 readonly isRetry: boolean; 480 483 readonly retryCount: number; 484 + readonly scheduledTime: number; 481 485 } 482 486 interface Cloudflare { 483 487 readonly compatibilityFlags: Record<string, boolean>; 484 488 } 485 489 interface DurableObject { 486 490 fetch(request: Request): Response | Promise<Response>; 491 + connect?(socket: Socket): void | Promise<void>; 487 492 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>; 488 493 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>; 489 494 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>; 490 495 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>; 491 496 } 492 - type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & { 497 + type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & { 493 498 readonly id: DurableObjectId; 494 499 readonly name?: string; 495 500 }; ··· 497 502 toString(): string; 498 503 equals(other: DurableObjectId): boolean; 499 504 readonly name?: string; 505 + readonly jurisdiction?: string; 500 506 } 501 507 declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> { 502 508 newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId; ··· 2606 2612 */ 2607 2613 highWaterMark: number; 2608 2614 } 2615 + interface TracePreviewInfo { 2616 + id: string; 2617 + slug: string; 2618 + name: string; 2619 + } 2609 2620 interface ScriptVersion { 2610 2621 id?: string; 2611 2622 tag?: string; ··· 2616 2627 readonly traces: TraceItem[]; 2617 2628 } 2618 2629 interface TraceItem { 2619 - readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null; 2630 + readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemConnectEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null; 2620 2631 readonly eventTimestamp: number | null; 2621 2632 readonly logs: TraceLog[]; 2622 2633 readonly exceptions: TraceException[]; ··· 2626 2637 readonly scriptVersion?: ScriptVersion; 2627 2638 readonly dispatchNamespace?: string; 2628 2639 readonly scriptTags?: string[]; 2640 + readonly tailAttributes?: Record<string, boolean | number | string>; 2641 + readonly preview?: TracePreviewInfo; 2629 2642 readonly durableObjectId?: string; 2630 2643 readonly outcome: string; 2631 2644 readonly executionModel: string; ··· 2635 2648 } 2636 2649 interface TraceItemAlarmEventInfo { 2637 2650 readonly scheduledTime: Date; 2651 + } 2652 + interface TraceItemConnectEventInfo { 2638 2653 } 2639 2654 interface TraceItemCustomEventInfo { 2640 2655 } ··· 3058 3073 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket) 3059 3074 */ 3060 3075 interface WebSocket extends EventTarget<WebSocketEventMap> { 3061 - accept(): void; 3076 + accept(options?: WebSocketAcceptOptions): void; 3062 3077 /** 3063 3078 * The **`WebSocket.send()`** method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of `bufferedAmount` by the number of bytes needed to contain the data. 3064 3079 * ··· 3097 3112 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions) 3098 3113 */ 3099 3114 extensions: string | null; 3115 + /** 3116 + * The **`WebSocket.binaryType`** property controls the type of binary data being received over the WebSocket connection. 3117 + * 3118 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType) 3119 + */ 3120 + binaryType: "blob" | "arraybuffer"; 3121 + } 3122 + interface WebSocketAcceptOptions { 3123 + /** 3124 + * When set to `true`, receiving a server-initiated WebSocket Close frame will not 3125 + * automatically send a reciprocal Close frame, leaving the connection in a half-open 3126 + * state. This is useful for proxying scenarios where you need to coordinate closing 3127 + * both sides independently. Defaults to `false` when the 3128 + * `no_web_socket_half_open_by_default` compatibility flag is enabled. 3129 + */ 3130 + allowHalfOpen?: boolean; 3100 3131 } 3101 3132 declare const WebSocketPair: { 3102 3133 new (): { ··· 3215 3246 signal(signo: number): void; 3216 3247 getTcpPort(port: number): Fetcher; 3217 3248 setInactivityTimeout(durationMs: number | bigint): Promise<void>; 3249 + interceptOutboundHttp(addr: string, binding: Fetcher): Promise<void>; 3250 + interceptAllOutboundHttp(binding: Fetcher): Promise<void>; 3251 + snapshotDirectory(options: ContainerDirectorySnapshotOptions): Promise<ContainerDirectorySnapshot>; 3252 + snapshotContainer(options: ContainerSnapshotOptions): Promise<ContainerSnapshot>; 3253 + } 3254 + interface ContainerDirectorySnapshot { 3255 + id: string; 3256 + size: number; 3257 + dir: string; 3258 + name?: string; 3259 + } 3260 + interface ContainerDirectorySnapshotOptions { 3261 + dir: string; 3262 + name?: string; 3263 + } 3264 + interface ContainerDirectorySnapshotRestoreParams { 3265 + snapshot: ContainerDirectorySnapshot; 3266 + mountPoint?: string; 3267 + } 3268 + interface ContainerSnapshot { 3269 + id: string; 3270 + size: number; 3271 + name?: string; 3272 + } 3273 + interface ContainerSnapshotOptions { 3274 + name?: string; 3218 3275 } 3219 3276 interface ContainerStartupOptions { 3220 3277 entrypoint?: string[]; 3221 3278 enableInternet: boolean; 3222 3279 env?: Record<string, string>; 3223 - hardTimeout?: (number | bigint); 3280 + labels?: Record<string, string>; 3281 + directorySnapshots?: ContainerDirectorySnapshotRestoreParams[]; 3282 + containerSnapshot?: ContainerSnapshot; 3224 3283 } 3225 3284 /** 3226 3285 * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other. 3227 3286 * 3228 3287 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort) 3229 3288 */ 3230 - interface MessagePort extends EventTarget { 3289 + declare abstract class MessagePort extends EventTarget { 3231 3290 /** 3232 3291 * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts. 3233 3292 * ··· 3288 3347 } 3289 3348 interface WorkerLoader { 3290 3349 get(name: string | null, getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>): WorkerStub; 3350 + load(code: WorkerLoaderWorkerCode): WorkerStub; 3291 3351 } 3292 3352 interface WorkerLoaderModule { 3293 3353 js?: string; ··· 3320 3380 get timeOrigin(): number; 3321 3381 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */ 3322 3382 now(): number; 3383 + /** 3384 + * The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object. 3385 + * 3386 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON) 3387 + */ 3388 + toJSON(): object; 3389 + } 3390 + // ============ AI Search Error Interfaces ============ 3391 + interface AiSearchInternalError extends Error { 3392 + } 3393 + interface AiSearchNotFoundError extends Error { 3394 + } 3395 + // ============ AI Search Request Types ============ 3396 + type AiSearchSearchRequest = { 3397 + messages: Array<{ 3398 + role: 'system' | 'developer' | 'user' | 'assistant' | 'tool'; 3399 + content: string | null; 3400 + }>; 3401 + ai_search_options?: { 3402 + retrieval?: { 3403 + retrieval_type?: 'vector' | 'keyword' | 'hybrid'; 3404 + /** Match threshold (0-1, default 0.4) */ 3405 + match_threshold?: number; 3406 + /** Maximum number of results (1-50, default 10) */ 3407 + max_num_results?: number; 3408 + filters?: VectorizeVectorMetadataFilter; 3409 + /** Context expansion (0-3, default 0) */ 3410 + context_expansion?: number; 3411 + [key: string]: unknown; 3412 + }; 3413 + query_rewrite?: { 3414 + enabled?: boolean; 3415 + model?: string; 3416 + rewrite_prompt?: string; 3417 + [key: string]: unknown; 3418 + }; 3419 + reranking?: { 3420 + enabled?: boolean; 3421 + model?: '@cf/baai/bge-reranker-base' | string; 3422 + /** Match threshold (0-1, default 0.4) */ 3423 + match_threshold?: number; 3424 + [key: string]: unknown; 3425 + }; 3426 + [key: string]: unknown; 3427 + }; 3428 + }; 3429 + type AiSearchChatCompletionsRequest = { 3430 + messages: Array<{ 3431 + role: 'system' | 'developer' | 'user' | 'assistant' | 'tool'; 3432 + content: string | null; 3433 + [key: string]: unknown; 3434 + }>; 3435 + model?: string; 3436 + stream?: boolean; 3437 + ai_search_options?: { 3438 + retrieval?: { 3439 + retrieval_type?: 'vector' | 'keyword' | 'hybrid'; 3440 + match_threshold?: number; 3441 + max_num_results?: number; 3442 + filters?: VectorizeVectorMetadataFilter; 3443 + context_expansion?: number; 3444 + [key: string]: unknown; 3445 + }; 3446 + query_rewrite?: { 3447 + enabled?: boolean; 3448 + model?: string; 3449 + rewrite_prompt?: string; 3450 + [key: string]: unknown; 3451 + }; 3452 + reranking?: { 3453 + enabled?: boolean; 3454 + model?: '@cf/baai/bge-reranker-base' | string; 3455 + match_threshold?: number; 3456 + [key: string]: unknown; 3457 + }; 3458 + [key: string]: unknown; 3459 + }; 3460 + [key: string]: unknown; 3461 + }; 3462 + // ============ AI Search Response Types ============ 3463 + type AiSearchSearchResponse = { 3464 + search_query: string; 3465 + chunks: Array<{ 3466 + id: string; 3467 + type: string; 3468 + /** Match score (0-1) */ 3469 + score: number; 3470 + text: string; 3471 + item: { 3472 + timestamp?: number; 3473 + key: string; 3474 + metadata?: Record<string, unknown>; 3475 + }; 3476 + scoring_details?: { 3477 + /** Keyword match score (0-1) */ 3478 + keyword_score?: number; 3479 + /** Vector similarity score (0-1) */ 3480 + vector_score?: number; 3481 + [key: string]: unknown; 3482 + }; 3483 + }>; 3484 + }; 3485 + type AiSearchChatCompletionsResponse = { 3486 + id?: string; 3487 + object?: string; 3488 + model?: string; 3489 + choices: Array<{ 3490 + index?: number; 3491 + message: { 3492 + role: 'system' | 'developer' | 'user' | 'assistant' | 'tool'; 3493 + content: string | null; 3494 + [key: string]: unknown; 3495 + }; 3496 + [key: string]: unknown; 3497 + }>; 3498 + chunks: AiSearchSearchResponse['chunks']; 3499 + [key: string]: unknown; 3500 + }; 3501 + type AiSearchStatsResponse = { 3502 + queued?: number; 3503 + running?: number; 3504 + completed?: number; 3505 + error?: number; 3506 + skipped?: number; 3507 + outdated?: number; 3508 + last_activity?: string; 3509 + }; 3510 + // ============ AI Search Instance Info Types ============ 3511 + type AiSearchInstanceInfo = { 3512 + id: string; 3513 + type?: 'r2' | 'web-crawler' | string; 3514 + source?: string; 3515 + paused?: boolean; 3516 + status?: string; 3517 + namespace?: string; 3518 + created_at?: string; 3519 + modified_at?: string; 3520 + [key: string]: unknown; 3521 + }; 3522 + type AiSearchListResponse = { 3523 + result: AiSearchInstanceInfo[]; 3524 + result_info?: { 3525 + count: number; 3526 + page: number; 3527 + per_page: number; 3528 + total_count: number; 3529 + }; 3530 + }; 3531 + // ============ AI Search Config Types ============ 3532 + type AiSearchConfig = { 3533 + /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */ 3534 + id: string; 3535 + /** Instance type. Omit to create with built-in storage. */ 3536 + type?: 'r2' | 'web-crawler' | string; 3537 + /** Source URL (required for web-crawler type). */ 3538 + source?: string; 3539 + source_params?: unknown; 3540 + /** Token ID (UUID format) */ 3541 + token_id?: string; 3542 + ai_gateway_id?: string; 3543 + /** Enable query rewriting (default false) */ 3544 + rewrite_query?: boolean; 3545 + /** Enable reranking (default false) */ 3546 + reranking?: boolean; 3547 + embedding_model?: string; 3548 + ai_search_model?: string; 3549 + [key: string]: unknown; 3550 + }; 3551 + // ============ AI Search Item Types ============ 3552 + type AiSearchItemInfo = { 3553 + id: string; 3554 + key: string; 3555 + status: 'completed' | 'error' | 'skipped' | 'queued' | 'processing' | 'outdated'; 3556 + metadata?: Record<string, unknown>; 3557 + [key: string]: unknown; 3558 + }; 3559 + type AiSearchItemContentResult = { 3560 + body: ReadableStream; 3561 + contentType: string; 3562 + filename: string; 3563 + size: number; 3564 + }; 3565 + type AiSearchUploadItemOptions = { 3566 + metadata?: Record<string, unknown>; 3567 + }; 3568 + type AiSearchListItemsParams = { 3569 + page?: number; 3570 + per_page?: number; 3571 + }; 3572 + type AiSearchListItemsResponse = { 3573 + result: AiSearchItemInfo[]; 3574 + result_info?: { 3575 + count: number; 3576 + page: number; 3577 + per_page: number; 3578 + total_count: number; 3579 + }; 3580 + }; 3581 + // ============ AI Search Job Types ============ 3582 + type AiSearchJobInfo = { 3583 + id: string; 3584 + source: 'user' | 'schedule'; 3585 + description?: string; 3586 + last_seen_at?: string; 3587 + started_at?: string; 3588 + ended_at?: string; 3589 + end_reason?: string; 3590 + }; 3591 + type AiSearchJobLog = { 3592 + id: number; 3593 + message: string; 3594 + message_type: number; 3595 + created_at: number; 3596 + }; 3597 + type AiSearchCreateJobParams = { 3598 + description?: string; 3599 + }; 3600 + type AiSearchListJobsParams = { 3601 + page?: number; 3602 + per_page?: number; 3603 + }; 3604 + type AiSearchListJobsResponse = { 3605 + result: AiSearchJobInfo[]; 3606 + result_info?: { 3607 + count: number; 3608 + page: number; 3609 + per_page: number; 3610 + total_count: number; 3611 + }; 3612 + }; 3613 + type AiSearchJobLogsParams = { 3614 + page?: number; 3615 + per_page?: number; 3616 + }; 3617 + type AiSearchJobLogsResponse = { 3618 + result: AiSearchJobLog[]; 3619 + result_info?: { 3620 + count: number; 3621 + page: number; 3622 + per_page: number; 3623 + total_count: number; 3624 + }; 3625 + }; 3626 + // ============ AI Search Sub-Service Classes ============ 3627 + /** 3628 + * Single item service for an AI Search instance. 3629 + * Provides info, delete, and download operations on a specific item. 3630 + */ 3631 + declare abstract class AiSearchItem { 3632 + /** Get metadata about this item. */ 3633 + info(): Promise<AiSearchItemInfo>; 3634 + /** 3635 + * Download the item's content. 3636 + * @returns Object with body stream, content type, filename, and size. 3637 + */ 3638 + download(): Promise<AiSearchItemContentResult>; 3639 + } 3640 + /** 3641 + * Items collection service for an AI Search instance. 3642 + * Provides list, upload, and access to individual items. 3643 + */ 3644 + declare abstract class AiSearchItems { 3645 + /** List items in this instance. */ 3646 + list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>; 3647 + /** 3648 + * Upload a file as an item. 3649 + * @param name Filename for the uploaded item. 3650 + * @param content File content as a ReadableStream, ArrayBuffer, or string. 3651 + * @param options Optional metadata to attach to the item. 3652 + * @returns The created item info. 3653 + */ 3654 + upload(name: string, content: ReadableStream | ArrayBuffer | string, options?: AiSearchUploadItemOptions): Promise<AiSearchItemInfo>; 3655 + /** 3656 + * Upload a file and poll until processing completes. 3657 + * @param name Filename for the uploaded item. 3658 + * @param content File content as a ReadableStream, ArrayBuffer, or string. 3659 + * @param options Optional metadata to attach to the item. 3660 + * @returns The item info after processing completes (or timeout). 3661 + */ 3662 + uploadAndPoll(name: string, content: ReadableStream | ArrayBuffer | string, options?: AiSearchUploadItemOptions): Promise<AiSearchItemInfo>; 3663 + /** 3664 + * Get an item by ID. 3665 + * @param itemId The item identifier. 3666 + * @returns Item service for info, delete, and download operations. 3667 + */ 3668 + get(itemId: string): AiSearchItem; 3669 + /** Delete this item from the instance. 3670 + * @param itemId The item identifier. 3671 + */ 3672 + delete(itemId: string): Promise<void>; 3673 + } 3674 + /** 3675 + * Single job service for an AI Search instance. 3676 + * Provides info and logs for a specific job. 3677 + */ 3678 + declare abstract class AiSearchJob { 3679 + /** Get metadata about this job. */ 3680 + info(): Promise<AiSearchJobInfo>; 3681 + /** Get logs for this job. */ 3682 + logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>; 3683 + } 3684 + /** 3685 + * Jobs collection service for an AI Search instance. 3686 + * Provides list, create, and access to individual jobs. 3687 + */ 3688 + declare abstract class AiSearchJobs { 3689 + /** List jobs for this instance. */ 3690 + list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>; 3691 + /** 3692 + * Create a new indexing job. 3693 + * @param params Optional job parameters. 3694 + * @returns The created job info. 3695 + */ 3696 + create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>; 3697 + /** 3698 + * Get a job by ID. 3699 + * @param jobId The job identifier. 3700 + * @returns Job service for info and logs operations. 3701 + */ 3702 + get(jobId: string): AiSearchJob; 3703 + } 3704 + // ============ AI Search Binding Classes ============ 3705 + /** 3706 + * Instance-level AI Search service. 3707 + * 3708 + * Used as: 3709 + * - The return type of `AiSearchNamespace.get(name)` (namespace binding) 3710 + * - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`) 3711 + * 3712 + * Provides search, chat, update, stats, items, and jobs operations. 3713 + * 3714 + * @example 3715 + * ```ts 3716 + * // Via namespace binding 3717 + * const instance = env.AI_SEARCH.get("blog"); 3718 + * const results = await instance.search({ 3719 + * messages: [{ role: "user", content: "How does caching work?" }], 3720 + * }); 3721 + * 3722 + * // Via single instance binding 3723 + * const results = await env.BLOG_SEARCH.search({ 3724 + * messages: [{ role: "user", content: "How does caching work?" }], 3725 + * }); 3726 + * ``` 3727 + */ 3728 + declare abstract class AiSearchInstance { 3729 + /** 3730 + * Search the AI Search instance for relevant chunks. 3731 + * @param params Search request with messages and optional AI search options. 3732 + * @returns Search response with matching chunks and search query. 3733 + */ 3734 + search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>; 3735 + /** 3736 + * Generate chat completions with AI Search context (streaming). 3737 + * @param params Chat completions request with stream: true. 3738 + * @returns ReadableStream of server-sent events. 3739 + */ 3740 + chatCompletions(params: AiSearchChatCompletionsRequest & { 3741 + stream: true; 3742 + }): Promise<ReadableStream>; 3743 + /** 3744 + * Generate chat completions with AI Search context. 3745 + * @param params Chat completions request. 3746 + * @returns Chat completion response with choices and RAG chunks. 3747 + */ 3748 + chatCompletions(params: AiSearchChatCompletionsRequest): Promise<AiSearchChatCompletionsResponse>; 3749 + /** 3750 + * Update the instance configuration. 3751 + * @param config Partial configuration to update. 3752 + * @returns Updated instance info. 3753 + */ 3754 + update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>; 3755 + /** Get metadata about this instance. */ 3756 + info(): Promise<AiSearchInstanceInfo>; 3757 + /** 3758 + * Get instance statistics (item count, indexing status, etc.). 3759 + * @returns Statistics with counts per status and last activity time. 3760 + */ 3761 + stats(): Promise<AiSearchStatsResponse>; 3762 + /** Items collection — list, upload, and manage items in this instance. */ 3763 + get items(): AiSearchItems; 3764 + /** Jobs collection — list, create, and inspect indexing jobs. */ 3765 + get jobs(): AiSearchJobs; 3766 + } 3767 + /** 3768 + * Namespace-level AI Search service. 3769 + * 3770 + * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`). 3771 + * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion. 3772 + * 3773 + * @example 3774 + * ```ts 3775 + * // Access an instance within the namespace 3776 + * const blog = env.AI_SEARCH.get("blog"); 3777 + * const results = await blog.search({ 3778 + * messages: [{ role: "user", content: "How does caching work?" }], 3779 + * }); 3780 + * 3781 + * // List all instances in the namespace 3782 + * const instances = await env.AI_SEARCH.list(); 3783 + * 3784 + * // Create a new instance with built-in storage 3785 + * const tenant = await env.AI_SEARCH.create({ 3786 + * id: "tenant-123", 3787 + * }); 3788 + * 3789 + * // Upload items into the instance 3790 + * await tenant.items.upload("doc.pdf", fileContent); 3791 + * 3792 + * // Delete an instance 3793 + * await env.AI_SEARCH.delete("tenant-123"); 3794 + * ``` 3795 + */ 3796 + declare abstract class AiSearchNamespace { 3797 + /** 3798 + * Get an instance by name within the bound namespace. 3799 + * @param name Instance name. 3800 + * @returns Instance service for search, chat, update, stats, items, and jobs. 3801 + */ 3802 + get(name: string): AiSearchInstance; 3803 + /** 3804 + * List all instances in the bound namespace. 3805 + * @returns Array of instance metadata. 3806 + */ 3807 + list(): Promise<AiSearchListResponse>; 3808 + /** 3809 + * Create a new instance within the bound namespace. 3810 + * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage. 3811 + * @returns Instance service for the newly created instance. 3812 + * 3813 + * @example 3814 + * ```ts 3815 + * // Create with built-in storage (upload items manually) 3816 + * const instance = await env.AI_SEARCH.create({ id: "my-search" }); 3817 + * 3818 + * // Create with web crawler source 3819 + * const instance = await env.AI_SEARCH.create({ 3820 + * id: "docs-search", 3821 + * type: "web-crawler", 3822 + * source: "https://developers.cloudflare.com", 3823 + * }); 3824 + * ``` 3825 + */ 3826 + create(config: AiSearchConfig): Promise<AiSearchInstance>; 3827 + /** 3828 + * Delete an instance from the bound namespace. 3829 + * @param name Instance name to delete. 3830 + */ 3831 + delete(name: string): Promise<void>; 3323 3832 } 3324 3833 type AiImageClassificationInput = { 3325 3834 image: number[]; ··· 3585 4094 postProcessedOutputs: AiTranslationOutput; 3586 4095 } 3587 4096 /** 4097 + * Workers AI support for OpenAI's Chat Completions API 4098 + */ 4099 + type ChatCompletionContentPartText = { 4100 + type: "text"; 4101 + text: string; 4102 + }; 4103 + type ChatCompletionContentPartImage = { 4104 + type: "image_url"; 4105 + image_url: { 4106 + url: string; 4107 + detail?: "auto" | "low" | "high"; 4108 + }; 4109 + }; 4110 + type ChatCompletionContentPartInputAudio = { 4111 + type: "input_audio"; 4112 + input_audio: { 4113 + /** Base64 encoded audio data. */ 4114 + data: string; 4115 + format: "wav" | "mp3"; 4116 + }; 4117 + }; 4118 + type ChatCompletionContentPartFile = { 4119 + type: "file"; 4120 + file: { 4121 + /** Base64 encoded file data. */ 4122 + file_data?: string; 4123 + /** The ID of an uploaded file. */ 4124 + file_id?: string; 4125 + filename?: string; 4126 + }; 4127 + }; 4128 + type ChatCompletionContentPartRefusal = { 4129 + type: "refusal"; 4130 + refusal: string; 4131 + }; 4132 + type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage | ChatCompletionContentPartInputAudio | ChatCompletionContentPartFile; 4133 + type FunctionDefinition = { 4134 + name: string; 4135 + description?: string; 4136 + parameters?: Record<string, unknown>; 4137 + strict?: boolean | null; 4138 + }; 4139 + type ChatCompletionFunctionTool = { 4140 + type: "function"; 4141 + function: FunctionDefinition; 4142 + }; 4143 + type ChatCompletionCustomToolGrammarFormat = { 4144 + type: "grammar"; 4145 + grammar: { 4146 + definition: string; 4147 + syntax: "lark" | "regex"; 4148 + }; 4149 + }; 4150 + type ChatCompletionCustomToolTextFormat = { 4151 + type: "text"; 4152 + }; 4153 + type ChatCompletionCustomToolFormat = ChatCompletionCustomToolTextFormat | ChatCompletionCustomToolGrammarFormat; 4154 + type ChatCompletionCustomTool = { 4155 + type: "custom"; 4156 + custom: { 4157 + name: string; 4158 + description?: string; 4159 + format?: ChatCompletionCustomToolFormat; 4160 + }; 4161 + }; 4162 + type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool; 4163 + type ChatCompletionMessageFunctionToolCall = { 4164 + id: string; 4165 + type: "function"; 4166 + function: { 4167 + name: string; 4168 + /** JSON-encoded arguments string. */ 4169 + arguments: string; 4170 + }; 4171 + }; 4172 + type ChatCompletionMessageCustomToolCall = { 4173 + id: string; 4174 + type: "custom"; 4175 + custom: { 4176 + name: string; 4177 + input: string; 4178 + }; 4179 + }; 4180 + type ChatCompletionMessageToolCall = ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall; 4181 + type ChatCompletionToolChoiceFunction = { 4182 + type: "function"; 4183 + function: { 4184 + name: string; 4185 + }; 4186 + }; 4187 + type ChatCompletionToolChoiceCustom = { 4188 + type: "custom"; 4189 + custom: { 4190 + name: string; 4191 + }; 4192 + }; 4193 + type ChatCompletionToolChoiceAllowedTools = { 4194 + type: "allowed_tools"; 4195 + allowed_tools: { 4196 + mode: "auto" | "required"; 4197 + tools: Array<Record<string, unknown>>; 4198 + }; 4199 + }; 4200 + type ChatCompletionToolChoiceOption = "none" | "auto" | "required" | ChatCompletionToolChoiceFunction | ChatCompletionToolChoiceCustom | ChatCompletionToolChoiceAllowedTools; 4201 + type DeveloperMessage = { 4202 + role: "developer"; 4203 + content: string | Array<{ 4204 + type: "text"; 4205 + text: string; 4206 + }>; 4207 + name?: string; 4208 + }; 4209 + type SystemMessage = { 4210 + role: "system"; 4211 + content: string | Array<{ 4212 + type: "text"; 4213 + text: string; 4214 + }>; 4215 + name?: string; 4216 + }; 4217 + /** 4218 + * Permissive merged content part used inside UserMessage arrays. 4219 + * 4220 + * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination 4221 + * inside nested array items does not correctly match different branches for 4222 + * different array elements, so the schema uses a single merged object. 4223 + */ 4224 + type UserMessageContentPart = { 4225 + type: "text" | "image_url" | "input_audio" | "file"; 4226 + text?: string; 4227 + image_url?: { 4228 + url?: string; 4229 + detail?: "auto" | "low" | "high"; 4230 + }; 4231 + input_audio?: { 4232 + data?: string; 4233 + format?: "wav" | "mp3"; 4234 + }; 4235 + file?: { 4236 + file_data?: string; 4237 + file_id?: string; 4238 + filename?: string; 4239 + }; 4240 + }; 4241 + type UserMessage = { 4242 + role: "user"; 4243 + content: string | Array<UserMessageContentPart>; 4244 + name?: string; 4245 + }; 4246 + type AssistantMessageContentPart = { 4247 + type: "text" | "refusal"; 4248 + text?: string; 4249 + refusal?: string; 4250 + }; 4251 + type AssistantMessage = { 4252 + role: "assistant"; 4253 + content?: string | null | Array<AssistantMessageContentPart>; 4254 + refusal?: string | null; 4255 + name?: string; 4256 + audio?: { 4257 + id: string; 4258 + }; 4259 + tool_calls?: Array<ChatCompletionMessageToolCall>; 4260 + function_call?: { 4261 + name: string; 4262 + arguments: string; 4263 + }; 4264 + }; 4265 + type ToolMessage = { 4266 + role: "tool"; 4267 + content: string | Array<{ 4268 + type: "text"; 4269 + text: string; 4270 + }>; 4271 + tool_call_id: string; 4272 + }; 4273 + type FunctionMessage = { 4274 + role: "function"; 4275 + content: string; 4276 + name: string; 4277 + }; 4278 + type ChatCompletionMessageParam = DeveloperMessage | SystemMessage | UserMessage | AssistantMessage | ToolMessage | FunctionMessage; 4279 + type ChatCompletionsResponseFormatText = { 4280 + type: "text"; 4281 + }; 4282 + type ChatCompletionsResponseFormatJSONObject = { 4283 + type: "json_object"; 4284 + }; 4285 + type ResponseFormatJSONSchema = { 4286 + type: "json_schema"; 4287 + json_schema: { 4288 + name: string; 4289 + description?: string; 4290 + schema?: Record<string, unknown>; 4291 + strict?: boolean | null; 4292 + }; 4293 + }; 4294 + type ResponseFormat = ChatCompletionsResponseFormatText | ChatCompletionsResponseFormatJSONObject | ResponseFormatJSONSchema; 4295 + type ChatCompletionsStreamOptions = { 4296 + include_usage?: boolean; 4297 + include_obfuscation?: boolean; 4298 + }; 4299 + type PredictionContent = { 4300 + type: "content"; 4301 + content: string | Array<{ 4302 + type: "text"; 4303 + text: string; 4304 + }>; 4305 + }; 4306 + type AudioParams = { 4307 + voice: string | { 4308 + id: string; 4309 + }; 4310 + format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16"; 4311 + }; 4312 + type WebSearchUserLocation = { 4313 + type: "approximate"; 4314 + approximate: { 4315 + city?: string; 4316 + country?: string; 4317 + region?: string; 4318 + timezone?: string; 4319 + }; 4320 + }; 4321 + type WebSearchOptions = { 4322 + search_context_size?: "low" | "medium" | "high"; 4323 + user_location?: WebSearchUserLocation; 4324 + }; 4325 + type ChatTemplateKwargs = { 4326 + /** Whether to enable reasoning, enabled by default. */ 4327 + enable_thinking?: boolean; 4328 + /** If false, preserves reasoning context between turns. */ 4329 + clear_thinking?: boolean; 4330 + }; 4331 + /** Shared optional properties used by both Prompt and Messages input branches. */ 4332 + type ChatCompletionsCommonOptions = { 4333 + model?: string; 4334 + audio?: AudioParams; 4335 + frequency_penalty?: number | null; 4336 + logit_bias?: Record<string, unknown> | null; 4337 + logprobs?: boolean | null; 4338 + top_logprobs?: number | null; 4339 + max_tokens?: number | null; 4340 + max_completion_tokens?: number | null; 4341 + metadata?: Record<string, unknown> | null; 4342 + modalities?: Array<"text" | "audio"> | null; 4343 + n?: number | null; 4344 + parallel_tool_calls?: boolean; 4345 + prediction?: PredictionContent; 4346 + presence_penalty?: number | null; 4347 + reasoning_effort?: "low" | "medium" | "high" | null; 4348 + chat_template_kwargs?: ChatTemplateKwargs; 4349 + response_format?: ResponseFormat; 4350 + seed?: number | null; 4351 + service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null; 4352 + stop?: string | Array<string> | null; 4353 + store?: boolean | null; 4354 + stream?: boolean | null; 4355 + stream_options?: ChatCompletionsStreamOptions; 4356 + temperature?: number | null; 4357 + tool_choice?: ChatCompletionToolChoiceOption; 4358 + tools?: Array<ChatCompletionTool>; 4359 + top_p?: number | null; 4360 + user?: string; 4361 + web_search_options?: WebSearchOptions; 4362 + function_call?: "none" | "auto" | { 4363 + name: string; 4364 + }; 4365 + functions?: Array<FunctionDefinition>; 4366 + }; 4367 + type PromptTokensDetails = { 4368 + cached_tokens?: number; 4369 + audio_tokens?: number; 4370 + }; 4371 + type CompletionTokensDetails = { 4372 + reasoning_tokens?: number; 4373 + audio_tokens?: number; 4374 + accepted_prediction_tokens?: number; 4375 + rejected_prediction_tokens?: number; 4376 + }; 4377 + type CompletionUsage = { 4378 + prompt_tokens: number; 4379 + completion_tokens: number; 4380 + total_tokens: number; 4381 + prompt_tokens_details?: PromptTokensDetails; 4382 + completion_tokens_details?: CompletionTokensDetails; 4383 + }; 4384 + type ChatCompletionTopLogprob = { 4385 + token: string; 4386 + logprob: number; 4387 + bytes: Array<number> | null; 4388 + }; 4389 + type ChatCompletionTokenLogprob = { 4390 + token: string; 4391 + logprob: number; 4392 + bytes: Array<number> | null; 4393 + top_logprobs: Array<ChatCompletionTopLogprob>; 4394 + }; 4395 + type ChatCompletionAudio = { 4396 + id: string; 4397 + /** Base64 encoded audio bytes. */ 4398 + data: string; 4399 + expires_at: number; 4400 + transcript: string; 4401 + }; 4402 + type ChatCompletionUrlCitation = { 4403 + type: "url_citation"; 4404 + url_citation: { 4405 + url: string; 4406 + title: string; 4407 + start_index: number; 4408 + end_index: number; 4409 + }; 4410 + }; 4411 + type ChatCompletionResponseMessage = { 4412 + role: "assistant"; 4413 + content: string | null; 4414 + refusal: string | null; 4415 + annotations?: Array<ChatCompletionUrlCitation>; 4416 + audio?: ChatCompletionAudio; 4417 + tool_calls?: Array<ChatCompletionMessageToolCall>; 4418 + function_call?: { 4419 + name: string; 4420 + arguments: string; 4421 + } | null; 4422 + }; 4423 + type ChatCompletionLogprobs = { 4424 + content: Array<ChatCompletionTokenLogprob> | null; 4425 + refusal?: Array<ChatCompletionTokenLogprob> | null; 4426 + }; 4427 + type ChatCompletionChoice = { 4428 + index: number; 4429 + message: ChatCompletionResponseMessage; 4430 + finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call"; 4431 + logprobs: ChatCompletionLogprobs | null; 4432 + }; 4433 + type ChatCompletionsPromptInput = { 4434 + prompt: string; 4435 + } & ChatCompletionsCommonOptions; 4436 + type ChatCompletionsMessagesInput = { 4437 + messages: Array<ChatCompletionMessageParam>; 4438 + } & ChatCompletionsCommonOptions; 4439 + type ChatCompletionsOutput = { 4440 + id: string; 4441 + object: string; 4442 + created: number; 4443 + model: string; 4444 + choices: Array<ChatCompletionChoice>; 4445 + usage?: CompletionUsage; 4446 + system_fingerprint?: string | null; 4447 + service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null; 4448 + }; 4449 + /** 3588 4450 * Workers AI support for OpenAI's Responses API 3589 4451 * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts 3590 4452 * ··· 3941 4803 type StreamOptions = { 3942 4804 include_obfuscation?: boolean; 3943 4805 }; 4806 + /** Marks keys from T that aren't in U as optional never */ 4807 + type Without<T, U> = { 4808 + [P in Exclude<keyof T, keyof U>]?: never; 4809 + }; 4810 + /** Either T or U, but not both (mutually exclusive) */ 4811 + type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>); 3944 4812 type Ai_Cf_Baai_Bge_Base_En_V1_5_Input = { 3945 4813 text: string | string[]; 3946 4814 /** ··· 4211 5079 postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output; 4212 5080 } 4213 5081 interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input { 4214 - /** 4215 - * Base64 encoded value of the audio data. 4216 - */ 4217 - audio: string; 5082 + audio: string | { 5083 + body?: object; 5084 + contentType?: string; 5085 + }; 4218 5086 /** 4219 5087 * Supported tasks are 'translate' or 'transcribe'. 4220 5088 */ ··· 4232 5100 */ 4233 5101 initial_prompt?: string; 4234 5102 /** 4235 - * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result. 5103 + * The prefix appended to the beginning of the output of the transcription and can guide the transcription result. 4236 5104 */ 4237 5105 prefix?: string; 5106 + /** 5107 + * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed. 5108 + */ 5109 + beam_size?: number; 5110 + /** 5111 + * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops. 5112 + */ 5113 + condition_on_previous_text?: boolean; 5114 + /** 5115 + * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped. 5116 + */ 5117 + no_speech_threshold?: number; 5118 + /** 5119 + * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text. 5120 + */ 5121 + compression_ratio_threshold?: number; 5122 + /** 5123 + * Threshold for filtering out segments with low average log probability, indicating low confidence. 5124 + */ 5125 + log_prob_threshold?: number; 5126 + /** 5127 + * Optional threshold (in seconds) to skip silent periods that may cause hallucinations. 5128 + */ 5129 + hallucination_silence_threshold?: number; 4238 5130 } 4239 5131 interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output { 4240 5132 transcription_info?: { ··· 4374 5266 */ 4375 5267 truncate_inputs?: boolean; 4376 5268 } 4377 - type Ai_Cf_Baai_Bge_M3_Output = Ai_Cf_Baai_Bge_M3_Ouput_Query | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts | Ai_Cf_Baai_Bge_M3_Ouput_Embedding | Ai_Cf_Baai_Bge_M3_AsyncResponse; 4378 - interface Ai_Cf_Baai_Bge_M3_Ouput_Query { 5269 + type Ai_Cf_Baai_Bge_M3_Output = Ai_Cf_Baai_Bge_M3_Output_Query | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts | Ai_Cf_Baai_Bge_M3_Output_Embedding | Ai_Cf_Baai_Bge_M3_AsyncResponse; 5270 + interface Ai_Cf_Baai_Bge_M3_Output_Query { 4379 5271 response?: { 4380 5272 /** 4381 5273 * Index of the context in the request ··· 4395 5287 */ 4396 5288 pooling?: "mean" | "cls"; 4397 5289 } 4398 - interface Ai_Cf_Baai_Bge_M3_Ouput_Embedding { 5290 + interface Ai_Cf_Baai_Bge_M3_Output_Embedding { 4399 5291 shape?: number[]; 4400 5292 /** 4401 5293 * Embeddings of the requested text values ··· 4498 5390 */ 4499 5391 role?: string; 4500 5392 /** 4501 - * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001 5393 + * The tool call id. If you don't know what to put here you can fall back to 000000001 4502 5394 */ 4503 5395 tool_call_id?: string; 4504 5396 content?: string | { ··· 4744 5636 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 4745 5637 */ 4746 5638 role: string; 4747 - /** 4748 - * The content of the message as a string. 4749 - */ 4750 - content: string; 5639 + content: string | { 5640 + /** 5641 + * Type of the content (text) 5642 + */ 5643 + type?: string; 5644 + /** 5645 + * Text content 5646 + */ 5647 + text?: string; 5648 + }[]; 4751 5649 }[]; 4752 5650 functions?: { 4753 5651 name: string; ··· 5388 6286 */ 5389 6287 role?: string; 5390 6288 /** 5391 - * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001 6289 + * The tool call id. If you don't know what to put here you can fall back to 000000001 5392 6290 */ 5393 6291 tool_call_id?: string; 5394 6292 content?: string | { ··· 5509 6407 }; 5510 6408 })[]; 5511 6409 /** 5512 - * JSON schema that should be fulfilled for the response. 6410 + * JSON schema that should be fufilled for the response. 5513 6411 */ 5514 6412 guided_json?: object; 5515 6413 /** ··· 5775 6673 }; 5776 6674 })[]; 5777 6675 /** 5778 - * JSON schema that should be fulfilled for the response. 6676 + * JSON schema that should be fufilled for the response. 5779 6677 */ 5780 6678 guided_json?: object; 5781 6679 /** ··· 5866 6764 */ 5867 6765 prompt: string; 5868 6766 /** 5869 - * JSON schema that should be fulfilled for the response. 6767 + * JSON schema that should be fufilled for the response. 5870 6768 */ 5871 6769 guided_json?: object; 5872 6770 /** ··· 6025 6923 }; 6026 6924 })[]; 6027 6925 /** 6028 - * JSON schema that should be fulfilled for the response. 6926 + * JSON schema that should be fufilled for the response. 6029 6927 */ 6030 6928 guided_json?: object; 6031 6929 /** ··· 6297 7195 })[]; 6298 7196 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode; 6299 7197 /** 6300 - * JSON schema that should be fulfilled for the response. 7198 + * JSON schema that should be fufilled for the response. 6301 7199 */ 6302 7200 guided_json?: object; 6303 7201 /** ··· 6527 7425 })[]; 6528 7426 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode; 6529 7427 /** 6530 - * JSON schema that should be fulfilled for the response. 7428 + * JSON schema that should be fufilled for the response. 6531 7429 */ 6532 7430 guided_json?: object; 6533 7431 /** ··· 6689 7587 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 6690 7588 */ 6691 7589 role: string; 6692 - /** 6693 - * The content of the message as a string. 6694 - */ 6695 - content: string; 7590 + content: string | { 7591 + /** 7592 + * Type of the content (text) 7593 + */ 7594 + type?: string; 7595 + /** 7596 + * Text content 7597 + */ 7598 + text?: string; 7599 + }[]; 6696 7600 }[]; 6697 7601 functions?: { 6698 7602 name: string; ··· 6898 7802 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 6899 7803 */ 6900 7804 role: string; 6901 - /** 6902 - * The content of the message as a string. 6903 - */ 6904 - content: string; 7805 + content: string | { 7806 + /** 7807 + * Type of the content (text) 7808 + */ 7809 + type?: string; 7810 + /** 7811 + * Text content 7812 + */ 7813 + text?: string; 7814 + }[]; 6905 7815 }[]; 6906 7816 functions?: { 6907 7817 name: string; ··· 7452 8362 postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output; 7453 8363 } 7454 8364 declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B { 7455 - inputs: ResponsesInput; 7456 - postProcessedOutputs: ResponsesOutput; 8365 + inputs: XOR<ResponsesInput, ChatCompletionsInput>; 8366 + postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>; 7457 8367 } 7458 8368 declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B { 7459 - inputs: ResponsesInput; 7460 - postProcessedOutputs: ResponsesOutput; 8369 + inputs: XOR<ResponsesInput, ChatCompletionsInput>; 8370 + postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>; 7461 8371 } 7462 8372 interface Ai_Cf_Leonardo_Phoenix_1_0_Input { 7463 8373 /** ··· 7577 8487 */ 7578 8488 text: string | string[]; 7579 8489 /** 7580 - * Target language to translate to 8490 + * Target langauge to translate to 7581 8491 */ 7582 8492 target_language: "asm_Beng" | "awa_Deva" | "ben_Beng" | "bho_Deva" | "brx_Deva" | "doi_Deva" | "eng_Latn" | "gom_Deva" | "gon_Deva" | "guj_Gujr" | "hin_Deva" | "hne_Deva" | "kan_Knda" | "kas_Arab" | "kas_Deva" | "kha_Latn" | "lus_Latn" | "mag_Deva" | "mai_Deva" | "mal_Mlym" | "mar_Deva" | "mni_Beng" | "mni_Mtei" | "npi_Deva" | "ory_Orya" | "pan_Guru" | "san_Deva" | "sat_Olck" | "snd_Arab" | "snd_Deva" | "tam_Taml" | "tel_Telu" | "urd_Arab" | "unr_Deva"; 7583 8493 } ··· 7656 8566 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 7657 8567 */ 7658 8568 role: string; 7659 - /** 7660 - * The content of the message as a string. 7661 - */ 7662 - content: string; 8569 + content: string | { 8570 + /** 8571 + * Type of the content (text) 8572 + */ 8573 + type?: string; 8574 + /** 8575 + * Text content 8576 + */ 8577 + text?: string; 8578 + }[]; 7663 8579 }[]; 7664 8580 functions?: { 7665 8581 name: string; ··· 7865 8781 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 7866 8782 */ 7867 8783 role: string; 7868 - /** 7869 - * The content of the message as a string. 7870 - */ 7871 - content: string; 8784 + content: string | { 8785 + /** 8786 + * Type of the content (text) 8787 + */ 8788 + type?: string; 8789 + /** 8790 + * Text content 8791 + */ 8792 + text?: string; 8793 + }[]; 7872 8794 }[]; 7873 8795 functions?: { 7874 8796 name: string; ··· 8364 9286 inputs: Ai_Cf_Deepgram_Aura_2_Es_Input; 8365 9287 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output; 8366 9288 } 9289 + interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input { 9290 + multipart: { 9291 + body?: object; 9292 + contentType?: string; 9293 + }; 9294 + } 9295 + interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output { 9296 + /** 9297 + * Generated image as Base64 string. 9298 + */ 9299 + image?: string; 9300 + } 9301 + declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev { 9302 + inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input; 9303 + postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output; 9304 + } 9305 + interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input { 9306 + multipart: { 9307 + body?: object; 9308 + contentType?: string; 9309 + }; 9310 + } 9311 + interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output { 9312 + /** 9313 + * Generated image as Base64 string. 9314 + */ 9315 + image?: string; 9316 + } 9317 + declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B { 9318 + inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input; 9319 + postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output; 9320 + } 9321 + interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input { 9322 + multipart: { 9323 + body?: object; 9324 + contentType?: string; 9325 + }; 9326 + } 9327 + interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output { 9328 + /** 9329 + * Generated image as Base64 string. 9330 + */ 9331 + image?: string; 9332 + } 9333 + declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B { 9334 + inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input; 9335 + postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output; 9336 + } 9337 + declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash { 9338 + inputs: ChatCompletionsInput; 9339 + postProcessedOutputs: ChatCompletionsOutput; 9340 + } 9341 + declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 { 9342 + inputs: ChatCompletionsInput; 9343 + postProcessedOutputs: ChatCompletionsOutput; 9344 + } 9345 + declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B { 9346 + inputs: ChatCompletionsInput; 9347 + postProcessedOutputs: ChatCompletionsOutput; 9348 + } 8367 9349 interface AiModels { 8368 9350 "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification; 8369 9351 "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage; ··· 8382 9364 "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration; 8383 9365 "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration; 8384 9366 "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration; 8385 - "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration; 8386 9367 "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration; 8387 9368 "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration; 8388 9369 "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration; ··· 8449 9430 "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux; 8450 9431 "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En; 8451 9432 "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es; 9433 + "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev; 9434 + "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B; 9435 + "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B; 9436 + "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash; 9437 + "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5; 9438 + "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B; 8452 9439 } 8453 9440 type AiOptions = { 8454 9441 /** ··· 8474 9461 returnRawResponse?: boolean; 8475 9462 prefix?: string; 8476 9463 extraHeaders?: object; 9464 + signal?: AbortSignal; 8477 9465 }; 8478 9466 type AiModelsSearchParams = { 8479 9467 author?: string; ··· 8500 9488 value: string; 8501 9489 }[]; 8502 9490 }; 9491 + type ChatCompletionsBase = XOR<ChatCompletionsPromptInput, ChatCompletionsMessagesInput>; 9492 + type ChatCompletionsInput = XOR<ChatCompletionsBase, { 9493 + requests: ChatCompletionsBase[]; 9494 + }>; 8503 9495 interface InferenceUpstreamError extends Error { 8504 9496 } 8505 9497 interface AiInternalError extends Error { ··· 8508 9500 declare abstract class Ai<AiModelList extends AiModelListType = AiModels> { 8509 9501 aiGatewayLogId: string | null; 8510 9502 gateway(gatewayId: string): AiGateway; 9503 + /** 9504 + * @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead. 9505 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9506 + */ 9507 + aiSearch(): AiSearchNamespace; 9508 + /** 9509 + * @deprecated AutoRAG has been replaced by AI Search. 9510 + * Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead. 9511 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9512 + * 9513 + * @param autoragId Instance ID 9514 + */ 8511 9515 autorag(autoragId: string): AutoRAG; 8512 9516 run<Name extends keyof AiModelList, Options extends AiOptions, InputOptions extends AiModelList[Name]["inputs"]>(model: Name, inputs: InputOptions, options?: Options): Promise<Options extends { 8513 9517 returnRawResponse: true; ··· 8616 9620 }): Promise<Response>; 8617 9621 getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line 8618 9622 } 9623 + /** 9624 + * @deprecated Use the standalone AI Search Workers binding instead. 9625 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9626 + */ 8619 9627 interface AutoRAGInternalError extends Error { 8620 9628 } 9629 + /** 9630 + * @deprecated Use the standalone AI Search Workers binding instead. 9631 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9632 + */ 8621 9633 interface AutoRAGNotFoundError extends Error { 8622 9634 } 9635 + /** 9636 + * @deprecated Use the standalone AI Search Workers binding instead. 9637 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9638 + */ 8623 9639 interface AutoRAGUnauthorizedError extends Error { 8624 9640 } 9641 + /** 9642 + * @deprecated Use the standalone AI Search Workers binding instead. 9643 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9644 + */ 8625 9645 interface AutoRAGNameNotSetError extends Error { 8626 9646 } 8627 9647 type ComparisonFilter = { ··· 8633 9653 type: 'and' | 'or'; 8634 9654 filters: ComparisonFilter[]; 8635 9655 }; 9656 + /** 9657 + * @deprecated Use the standalone AI Search Workers binding instead. 9658 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9659 + */ 8636 9660 type AutoRagSearchRequest = { 8637 9661 query: string; 8638 9662 filters?: CompoundFilter | ComparisonFilter; ··· 8647 9671 }; 8648 9672 rewrite_query?: boolean; 8649 9673 }; 9674 + /** 9675 + * @deprecated Use the standalone AI Search Workers binding instead. 9676 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9677 + */ 8650 9678 type AutoRagAiSearchRequest = AutoRagSearchRequest & { 8651 9679 stream?: boolean; 8652 9680 system_prompt?: string; 8653 9681 }; 9682 + /** 9683 + * @deprecated Use the standalone AI Search Workers binding instead. 9684 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9685 + */ 8654 9686 type AutoRagAiSearchRequestStreaming = Omit<AutoRagAiSearchRequest, 'stream'> & { 8655 9687 stream: true; 8656 9688 }; 9689 + /** 9690 + * @deprecated Use the standalone AI Search Workers binding instead. 9691 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9692 + */ 8657 9693 type AutoRagSearchResponse = { 8658 9694 object: 'vector_store.search_results.page'; 8659 9695 search_query: string; ··· 8670 9706 has_more: boolean; 8671 9707 next_page: string | null; 8672 9708 }; 9709 + /** 9710 + * @deprecated Use the standalone AI Search Workers binding instead. 9711 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9712 + */ 8673 9713 type AutoRagListResponse = { 8674 9714 id: string; 8675 9715 enable: boolean; ··· 8679 9719 paused: boolean; 8680 9720 status: string; 8681 9721 }[]; 9722 + /** 9723 + * @deprecated Use the standalone AI Search Workers binding instead. 9724 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9725 + */ 8682 9726 type AutoRagAiSearchResponse = AutoRagSearchResponse & { 8683 9727 response: string; 8684 9728 }; 9729 + /** 9730 + * @deprecated Use the standalone AI Search Workers binding instead. 9731 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9732 + */ 8685 9733 declare abstract class AutoRAG { 9734 + /** 9735 + * @deprecated Use the standalone AI Search Workers binding instead. 9736 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9737 + */ 8686 9738 list(): Promise<AutoRagListResponse>; 9739 + /** 9740 + * @deprecated Use the standalone AI Search Workers binding instead. 9741 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9742 + */ 8687 9743 search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>; 9744 + /** 9745 + * @deprecated Use the standalone AI Search Workers binding instead. 9746 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9747 + */ 8688 9748 aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>; 9749 + /** 9750 + * @deprecated Use the standalone AI Search Workers binding instead. 9751 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9752 + */ 8689 9753 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>; 9754 + /** 9755 + * @deprecated Use the standalone AI Search Workers binding instead. 9756 + * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 9757 + */ 8690 9758 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse | Response>; 8691 9759 } 8692 9760 interface BasicImageTransformations { ··· 8799 9867 * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 }) 8800 9868 */ 8801 9869 cacheTtlByStatus?: Record<string, number>; 9870 + /** 9871 + * Explicit Cache-Control header value to set on the response stored in cache. 9872 + * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400'). 9873 + * 9874 + * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`), 9875 + * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError. 9876 + * 9877 + * Can be used together with `cacheTtlByStatus`. 9878 + */ 9879 + cacheControl?: string; 9880 + /** 9881 + * Whether the response should be eligible for Cache Reserve storage. 9882 + */ 9883 + cacheReserveEligible?: boolean; 9884 + /** 9885 + * Whether to respect strong ETags (as opposed to weak ETags) from the origin. 9886 + */ 9887 + respectStrongEtag?: boolean; 9888 + /** 9889 + * Whether to strip ETag headers from the origin response before caching. 9890 + */ 9891 + stripEtags?: boolean; 9892 + /** 9893 + * Whether to strip Last-Modified headers from the origin response before caching. 9894 + */ 9895 + stripLastModified?: boolean; 9896 + /** 9897 + * Whether to enable Cache Deception Armor, which protects against web cache 9898 + * deception attacks by verifying the Content-Type matches the URL extension. 9899 + */ 9900 + cacheDeceptionArmor?: boolean; 9901 + /** 9902 + * Minimum file size in bytes for a response to be eligible for Cache Reserve storage. 9903 + */ 9904 + cacheReserveMinimumFileSize?: number; 8802 9905 scrapeShield?: boolean; 8803 9906 apps?: boolean; 8804 9907 image?: RequestInitCfPropertiesImage; ··· 9627 10730 declare abstract class EmailEvent extends ExtendableEvent { 9628 10731 readonly message: ForwardableEmailMessage; 9629 10732 } 9630 - declare type EmailExportedHandler<Env = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) => void | Promise<void>; 10733 + declare type EmailExportedHandler<Env = unknown, Props = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 9631 10734 declare module "cloudflare:email" { 9632 10735 let _EmailMessage: { 9633 10736 prototype: EmailMessage; ··· 9768 10871 background?: string; 9769 10872 anim?: boolean; 9770 10873 }; 10874 + interface ImageMetadata { 10875 + id: string; 10876 + filename?: string; 10877 + uploaded?: string; 10878 + requireSignedURLs: boolean; 10879 + meta?: Record<string, unknown>; 10880 + variants: string[]; 10881 + draft?: boolean; 10882 + creator?: string; 10883 + } 10884 + interface ImageUploadOptions { 10885 + id?: string; 10886 + filename?: string; 10887 + requireSignedURLs?: boolean; 10888 + metadata?: Record<string, unknown>; 10889 + creator?: string; 10890 + encoding?: 'base64'; 10891 + } 10892 + interface ImageUpdateOptions { 10893 + requireSignedURLs?: boolean; 10894 + metadata?: Record<string, unknown>; 10895 + creator?: string; 10896 + } 10897 + interface ImageListOptions { 10898 + limit?: number; 10899 + cursor?: string; 10900 + sortOrder?: 'asc' | 'desc'; 10901 + creator?: string; 10902 + } 10903 + interface ImageList { 10904 + images: ImageMetadata[]; 10905 + cursor?: string; 10906 + listComplete: boolean; 10907 + } 10908 + interface HostedImagesBinding { 10909 + /** 10910 + * Get detailed metadata for a hosted image 10911 + * @param imageId The ID of the image (UUID or custom ID) 10912 + * @returns Image metadata, or null if not found 10913 + */ 10914 + details(imageId: string): Promise<ImageMetadata | null>; 10915 + /** 10916 + * Get the raw image data for a hosted image 10917 + * @param imageId The ID of the image (UUID or custom ID) 10918 + * @returns ReadableStream of image bytes, or null if not found 10919 + */ 10920 + image(imageId: string): Promise<ReadableStream<Uint8Array> | null>; 10921 + /** 10922 + * Upload a new hosted image 10923 + * @param image The image file to upload 10924 + * @param options Upload configuration 10925 + * @returns Metadata for the uploaded image 10926 + * @throws {@link ImagesError} if upload fails 10927 + */ 10928 + upload(image: ReadableStream<Uint8Array> | ArrayBuffer, options?: ImageUploadOptions): Promise<ImageMetadata>; 10929 + /** 10930 + * Update hosted image metadata 10931 + * @param imageId The ID of the image 10932 + * @param options Properties to update 10933 + * @returns Updated image metadata 10934 + * @throws {@link ImagesError} if update fails 10935 + */ 10936 + update(imageId: string, options: ImageUpdateOptions): Promise<ImageMetadata>; 10937 + /** 10938 + * Delete a hosted image 10939 + * @param imageId The ID of the image 10940 + * @returns True if deleted, false if not found 10941 + */ 10942 + delete(imageId: string): Promise<boolean>; 10943 + /** 10944 + * List hosted images with pagination 10945 + * @param options List configuration 10946 + * @returns List of images with pagination info 10947 + * @throws {@link ImagesError} if list fails 10948 + */ 10949 + list(options?: ImageListOptions): Promise<ImageList>; 10950 + } 9771 10951 interface ImagesBinding { 9772 10952 /** 9773 10953 * Get image metadata (type, width and height) ··· 9781 10961 * @returns A transform handle 9782 10962 */ 9783 10963 input(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): ImageTransformer; 10964 + /** 10965 + * Access hosted images CRUD operations 10966 + */ 10967 + readonly hosted: HostedImagesBinding; 9784 10968 } 9785 10969 interface ImageTransformer { 9786 10970 /** ··· 9847 11031 * @param transform - Configuration for how the media should be transformed 9848 11032 * @returns A generator for producing the transformed media output 9849 11033 */ 9850 - transform(transform: MediaTransformationInputOptions): MediaTransformationGenerator; 11034 + transform(transform?: MediaTransformationInputOptions): MediaTransformationGenerator; 11035 + /** 11036 + * Generates the final media output with specified options. 11037 + * @param output - Configuration for the output format and parameters 11038 + * @returns The final transformation result containing the transformed media 11039 + */ 11040 + output(output?: MediaTransformationOutputOptions): MediaTransformationResult; 9851 11041 } 9852 11042 /** 9853 11043 * Generator for producing media transformation results. ··· 9859 11049 * @param output - Configuration for the output format and parameters 9860 11050 * @returns The final transformation result containing the transformed media 9861 11051 */ 9862 - output(output: MediaTransformationOutputOptions): MediaTransformationResult; 11052 + output(output?: MediaTransformationOutputOptions): MediaTransformationResult; 9863 11053 } 9864 11054 /** 9865 11055 * Result of a media transformation operation. ··· 9868 11058 interface MediaTransformationResult { 9869 11059 /** 9870 11060 * Returns the transformed media as a readable stream of bytes. 9871 - * @returns A stream containing the transformed media data 11061 + * @returns A promise containing a readable stream with the transformed media 9872 11062 */ 9873 - media(): ReadableStream<Uint8Array>; 11063 + media(): Promise<ReadableStream<Uint8Array>>; 9874 11064 /** 9875 11065 * Returns the transformed media as an HTTP response object. 9876 - * @returns The transformed media as a Response, ready to store in cache or return to users 11066 + * @returns The transformed media as a Promise<Response>, ready to store in cache or return to users 9877 11067 */ 9878 - response(): Response; 11068 + response(): Promise<Response>; 9879 11069 /** 9880 11070 * Returns the MIME type of the transformed media. 9881 - * @returns The content type string (e.g., 'image/jpeg', 'video/mp4') 11071 + * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4') 9882 11072 */ 9883 - contentType(): string; 11073 + contentType(): Promise<string>; 9884 11074 } 9885 11075 /** 9886 11076 * Configuration options for transforming media input. ··· 10217 11407 constructor(ctx: ExecutionContext, env: Env); 10218 11408 email?(message: ForwardableEmailMessage): void | Promise<void>; 10219 11409 fetch?(request: Request): Response | Promise<Response>; 11410 + connect?(socket: Socket): void | Promise<void>; 10220 11411 queue?(batch: MessageBatch<unknown>): void | Promise<void>; 10221 11412 scheduled?(controller: ScheduledController): void | Promise<void>; 10222 11413 tail?(events: TraceItem[]): void | Promise<void>; ··· 10231 11422 constructor(ctx: DurableObjectState, env: Env); 10232 11423 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>; 10233 11424 fetch?(request: Request): Response | Promise<Response>; 11425 + connect?(socket: Socket): void | Promise<void>; 10234 11426 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>; 10235 11427 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>; 10236 11428 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>; ··· 10259 11451 timestamp: Date; 10260 11452 type: string; 10261 11453 }; 11454 + export type WorkflowStepContext = { 11455 + attempt: number; 11456 + }; 10262 11457 export abstract class WorkflowStep { 10263 - do<T extends Rpc.Serializable<T>>(name: string, callback: () => Promise<T>): Promise<T>; 10264 - do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: () => Promise<T>): Promise<T>; 11458 + do<T extends Rpc.Serializable<T>>(name: string, callback: (ctx: WorkflowStepContext) => Promise<T>): Promise<T>; 11459 + do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise<T>): Promise<T>; 10265 11460 sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>; 10266 11461 sleepUntil: (name: string, timestamp: Date | number) => Promise<void>; 10267 11462 waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: { ··· 10298 11493 function _connect(address: string | SocketAddress, options?: SocketOptions): Socket; 10299 11494 export { _connect as connect }; 10300 11495 } 11496 + /** 11497 + * Binding entrypoint for Cloudflare Stream. 11498 + * 11499 + * Usage: 11500 + * - Binding-level operations: 11501 + * `await env.STREAM.videos.upload` 11502 + * `await env.STREAM.videos.createDirectUpload` 11503 + * `await env.STREAM.videos.*` 11504 + * `await env.STREAM.watermarks.*` 11505 + * - Per-video operations: 11506 + * `await env.STREAM.video(id).downloads.*` 11507 + * `await env.STREAM.video(id).captions.*` 11508 + * 11509 + * Example usage: 11510 + * ```ts 11511 + * await env.STREAM.video(id).downloads.generate(); 11512 + * 11513 + * const video = env.STREAM.video(id) 11514 + * const captions = video.captions.list(); 11515 + * const videoDetails = video.details() 11516 + * ``` 11517 + */ 11518 + interface StreamBinding { 11519 + /** 11520 + * Returns a handle scoped to a single video for per-video operations. 11521 + * @param id The unique identifier for the video. 11522 + * @returns A handle for per-video operations. 11523 + */ 11524 + video(id: string): StreamVideoHandle; 11525 + /** 11526 + * Uploads a new video from a provided URL. 11527 + * @param url The URL to upload from. 11528 + * @param params Optional upload parameters. 11529 + * @returns The uploaded video details. 11530 + * @throws {BadRequestError} if the upload parameter is invalid or the URL is invalid 11531 + * @throws {QuotaReachedError} if the account storage capacity is exceeded 11532 + * @throws {MaxFileSizeError} if the file size is too large 11533 + * @throws {RateLimitedError} if the server received too many requests 11534 + * @throws {AlreadyUploadedError} if a video was already uploaded to this URL 11535 + * @throws {InternalError} if an unexpected error occurs 11536 + */ 11537 + upload(url: string, params?: StreamUrlUploadParams): Promise<StreamVideo>; 11538 + /** 11539 + * Creates a direct upload that allows video uploads without an API key. 11540 + * @param params Parameters for the direct upload 11541 + * @returns The direct upload details. 11542 + * @throws {BadRequestError} if the parameters are invalid 11543 + * @throws {RateLimitedError} if the server received too many requests 11544 + * @throws {InternalError} if an unexpected error occurs 11545 + */ 11546 + createDirectUpload(params: StreamDirectUploadCreateParams): Promise<StreamDirectUpload>; 11547 + videos: StreamVideos; 11548 + watermarks: StreamWatermarks; 11549 + } 11550 + /** 11551 + * Handle for operations scoped to a single Stream video. 11552 + */ 11553 + interface StreamVideoHandle { 11554 + /** 11555 + * The unique identifier for the video. 11556 + */ 11557 + id: string; 11558 + /** 11559 + * Get a full videos details 11560 + * @returns The full video details. 11561 + * @throws {NotFoundError} if the video is not found 11562 + * @throws {InternalError} if an unexpected error occurs 11563 + */ 11564 + details(): Promise<StreamVideo>; 11565 + /** 11566 + * Update details for a single video. 11567 + * @param params The fields to update for the video. 11568 + * @returns The updated video details. 11569 + * @throws {NotFoundError} if the video is not found 11570 + * @throws {BadRequestError} if the parameters are invalid 11571 + * @throws {InternalError} if an unexpected error occurs 11572 + */ 11573 + update(params: StreamUpdateVideoParams): Promise<StreamVideo>; 11574 + /** 11575 + * Deletes a video and its copies from Cloudflare Stream. 11576 + * @returns A promise that resolves when deletion completes. 11577 + * @throws {NotFoundError} if the video is not found 11578 + * @throws {InternalError} if an unexpected error occurs 11579 + */ 11580 + delete(): Promise<void>; 11581 + /** 11582 + * Creates a signed URL token for a video. 11583 + * @returns The signed token that was created. 11584 + * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed 11585 + */ 11586 + generateToken(): Promise<string>; 11587 + downloads: StreamScopedDownloads; 11588 + captions: StreamScopedCaptions; 11589 + } 11590 + interface StreamVideo { 11591 + /** 11592 + * The unique identifier for the video. 11593 + */ 11594 + id: string; 11595 + /** 11596 + * A user-defined identifier for the media creator. 11597 + */ 11598 + creator: string | null; 11599 + /** 11600 + * The thumbnail URL for the video. 11601 + */ 11602 + thumbnail: string; 11603 + /** 11604 + * The thumbnail timestamp percentage. 11605 + */ 11606 + thumbnailTimestampPct: number; 11607 + /** 11608 + * Indicates whether the video is ready to stream. 11609 + */ 11610 + readyToStream: boolean; 11611 + /** 11612 + * The date and time the video became ready to stream. 11613 + */ 11614 + readyToStreamAt: string | null; 11615 + /** 11616 + * Processing status information. 11617 + */ 11618 + status: StreamVideoStatus; 11619 + /** 11620 + * A user modifiable key-value store. 11621 + */ 11622 + meta: Record<string, string>; 11623 + /** 11624 + * The date and time the video was created. 11625 + */ 11626 + created: string; 11627 + /** 11628 + * The date and time the video was last modified. 11629 + */ 11630 + modified: string; 11631 + /** 11632 + * The date and time at which the video will be deleted. 11633 + */ 11634 + scheduledDeletion: string | null; 11635 + /** 11636 + * The size of the video in bytes. 11637 + */ 11638 + size: number; 11639 + /** 11640 + * The preview URL for the video. 11641 + */ 11642 + preview?: string; 11643 + /** 11644 + * Origins allowed to display the video. 11645 + */ 11646 + allowedOrigins: Array<string>; 11647 + /** 11648 + * Indicates whether signed URLs are required. 11649 + */ 11650 + requireSignedURLs: boolean | null; 11651 + /** 11652 + * The date and time the video was uploaded. 11653 + */ 11654 + uploaded: string | null; 11655 + /** 11656 + * The date and time when the upload URL expires. 11657 + */ 11658 + uploadExpiry: string | null; 11659 + /** 11660 + * The maximum size in bytes for direct uploads. 11661 + */ 11662 + maxSizeBytes: number | null; 11663 + /** 11664 + * The maximum duration in seconds for direct uploads. 11665 + */ 11666 + maxDurationSeconds: number | null; 11667 + /** 11668 + * The video duration in seconds. -1 indicates unknown. 11669 + */ 11670 + duration: number; 11671 + /** 11672 + * Input metadata for the original upload. 11673 + */ 11674 + input: StreamVideoInput; 11675 + /** 11676 + * Playback URLs for the video. 11677 + */ 11678 + hlsPlaybackUrl: string; 11679 + dashPlaybackUrl: string; 11680 + /** 11681 + * The watermark applied to the video, if any. 11682 + */ 11683 + watermark: StreamWatermark | null; 11684 + /** 11685 + * The live input id associated with the video, if any. 11686 + */ 11687 + liveInputId?: string | null; 11688 + /** 11689 + * The source video id if this is a clip. 11690 + */ 11691 + clippedFromId: string | null; 11692 + /** 11693 + * Public details associated with the video. 11694 + */ 11695 + publicDetails: StreamPublicDetails | null; 11696 + } 11697 + type StreamVideoStatus = { 11698 + /** 11699 + * The current processing state. 11700 + */ 11701 + state: string; 11702 + /** 11703 + * The current processing step. 11704 + */ 11705 + step?: string; 11706 + /** 11707 + * The percent complete as a string. 11708 + */ 11709 + pctComplete?: string; 11710 + /** 11711 + * An error reason code, if applicable. 11712 + */ 11713 + errorReasonCode: string; 11714 + /** 11715 + * An error reason text, if applicable. 11716 + */ 11717 + errorReasonText: string; 11718 + }; 11719 + type StreamVideoInput = { 11720 + /** 11721 + * The input width in pixels. 11722 + */ 11723 + width: number; 11724 + /** 11725 + * The input height in pixels. 11726 + */ 11727 + height: number; 11728 + }; 11729 + type StreamPublicDetails = { 11730 + /** 11731 + * The public title for the video. 11732 + */ 11733 + title: string | null; 11734 + /** 11735 + * The public share link. 11736 + */ 11737 + share_link: string | null; 11738 + /** 11739 + * The public channel link. 11740 + */ 11741 + channel_link: string | null; 11742 + /** 11743 + * The public logo URL. 11744 + */ 11745 + logo: string | null; 11746 + }; 11747 + type StreamDirectUpload = { 11748 + /** 11749 + * The URL an unauthenticated upload can use for a single multipart request. 11750 + */ 11751 + uploadURL: string; 11752 + /** 11753 + * A Cloudflare-generated unique identifier for a media item. 11754 + */ 11755 + id: string; 11756 + /** 11757 + * The watermark profile applied to the upload. 11758 + */ 11759 + watermark: StreamWatermark | null; 11760 + /** 11761 + * The scheduled deletion time, if any. 11762 + */ 11763 + scheduledDeletion: string | null; 11764 + }; 11765 + type StreamDirectUploadCreateParams = { 11766 + /** 11767 + * The maximum duration in seconds for a video upload. 11768 + */ 11769 + maxDurationSeconds: number; 11770 + /** 11771 + * The date and time after upload when videos will not be accepted. 11772 + */ 11773 + expiry?: string; 11774 + /** 11775 + * A user-defined identifier for the media creator. 11776 + */ 11777 + creator?: string; 11778 + /** 11779 + * A user modifiable key-value store used to reference other systems of record for 11780 + * managing videos. 11781 + */ 11782 + meta?: Record<string, string>; 11783 + /** 11784 + * Lists the origins allowed to display the video. 11785 + */ 11786 + allowedOrigins?: Array<string>; 11787 + /** 11788 + * Indicates whether the video can be accessed using the id. When set to `true`, 11789 + * a signed token must be generated with a signing key to view the video. 11790 + */ 11791 + requireSignedURLs?: boolean; 11792 + /** 11793 + * The thumbnail timestamp percentage. 11794 + */ 11795 + thumbnailTimestampPct?: number; 11796 + /** 11797 + * The date and time at which the video will be deleted. Include `null` to remove 11798 + * a scheduled deletion. 11799 + */ 11800 + scheduledDeletion?: string | null; 11801 + /** 11802 + * The watermark profile to apply. 11803 + */ 11804 + watermark?: StreamDirectUploadWatermark; 11805 + }; 11806 + type StreamDirectUploadWatermark = { 11807 + /** 11808 + * The unique identifier for the watermark profile. 11809 + */ 11810 + id: string; 11811 + }; 11812 + type StreamUrlUploadParams = { 11813 + /** 11814 + * Lists the origins allowed to display the video. Enter allowed origin 11815 + * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the 11816 + * video to be viewed on any origin. 11817 + */ 11818 + allowedOrigins?: Array<string>; 11819 + /** 11820 + * A user-defined identifier for the media creator. 11821 + */ 11822 + creator?: string; 11823 + /** 11824 + * A user modifiable key-value store used to reference other systems of 11825 + * record for managing videos. 11826 + */ 11827 + meta?: Record<string, string>; 11828 + /** 11829 + * Indicates whether the video can be a accessed using the id. When 11830 + * set to `true`, a signed token must be generated with a signing key to view the 11831 + * video. 11832 + */ 11833 + requireSignedURLs?: boolean; 11834 + /** 11835 + * Indicates the date and time at which the video will be deleted. Omit 11836 + * the field to indicate no change, or include with a `null` value to remove an 11837 + * existing scheduled deletion. If specified, must be at least 30 days from upload 11838 + * time. 11839 + */ 11840 + scheduledDeletion?: string | null; 11841 + /** 11842 + * The timestamp for a thumbnail image calculated as a percentage value 11843 + * of the video's duration. To convert from a second-wise timestamp to a 11844 + * percentage, divide the desired timestamp by the total duration of the video. If 11845 + * this value is not set, the default thumbnail image is taken from 0s of the 11846 + * video. 11847 + */ 11848 + thumbnailTimestampPct?: number; 11849 + /** 11850 + * The identifier for the watermark profile 11851 + */ 11852 + watermarkId?: string; 11853 + }; 11854 + interface StreamScopedCaptions { 11855 + /** 11856 + * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language. 11857 + * One caption or subtitle file per language is allowed. 11858 + * @param language The BCP 47 language tag for the caption or subtitle. 11859 + * @param input The caption or subtitle stream to upload. 11860 + * @returns The created caption entry. 11861 + * @throws {NotFoundError} if the video is not found 11862 + * @throws {BadRequestError} if the language or file is invalid 11863 + * @throws {InternalError} if an unexpected error occurs 11864 + */ 11865 + upload(language: string, input: ReadableStream): Promise<StreamCaption>; 11866 + /** 11867 + * Generate captions or subtitles for the provided language via AI. 11868 + * @param language The BCP 47 language tag to generate. 11869 + * @returns The generated caption entry. 11870 + * @throws {NotFoundError} if the video is not found 11871 + * @throws {BadRequestError} if the language is invalid 11872 + * @throws {StreamError} if a generated caption already exists 11873 + * @throws {StreamError} if the video duration is too long 11874 + * @throws {StreamError} if the video is missing audio 11875 + * @throws {StreamError} if the requested language is not supported 11876 + * @throws {InternalError} if an unexpected error occurs 11877 + */ 11878 + generate(language: string): Promise<StreamCaption>; 11879 + /** 11880 + * Lists the captions or subtitles. 11881 + * Use the language parameter to filter by a specific language. 11882 + * @param language The optional BCP 47 language tag to filter by. 11883 + * @returns The list of captions or subtitles. 11884 + * @throws {NotFoundError} if the video or caption is not found 11885 + * @throws {InternalError} if an unexpected error occurs 11886 + */ 11887 + list(language?: string): Promise<StreamCaption[]>; 11888 + /** 11889 + * Removes the captions or subtitles from a video. 11890 + * @param language The BCP 47 language tag to remove. 11891 + * @returns A promise that resolves when deletion completes. 11892 + * @throws {NotFoundError} if the video or caption is not found 11893 + * @throws {InternalError} if an unexpected error occurs 11894 + */ 11895 + delete(language: string): Promise<void>; 11896 + } 11897 + interface StreamScopedDownloads { 11898 + /** 11899 + * Generates a download for a video when a video is ready to view. Available 11900 + * types are `default` and `audio`. Defaults to `default` when omitted. 11901 + * @param downloadType The download type to create. 11902 + * @returns The current downloads for the video. 11903 + * @throws {NotFoundError} if the video is not found 11904 + * @throws {BadRequestError} if the download type is invalid 11905 + * @throws {StreamError} if the video duration is too long to generate a download 11906 + * @throws {StreamError} if the video is not ready to stream 11907 + * @throws {InternalError} if an unexpected error occurs 11908 + */ 11909 + generate(downloadType?: StreamDownloadType): Promise<StreamDownloadGetResponse>; 11910 + /** 11911 + * Lists the downloads created for a video. 11912 + * @returns The current downloads for the video. 11913 + * @throws {NotFoundError} if the video or downloads are not found 11914 + * @throws {InternalError} if an unexpected error occurs 11915 + */ 11916 + get(): Promise<StreamDownloadGetResponse>; 11917 + /** 11918 + * Delete the downloads for a video. Available types are `default` and `audio`. 11919 + * Defaults to `default` when omitted. 11920 + * @param downloadType The download type to delete. 11921 + * @returns A promise that resolves when deletion completes. 11922 + * @throws {NotFoundError} if the video or downloads are not found 11923 + * @throws {InternalError} if an unexpected error occurs 11924 + */ 11925 + delete(downloadType?: StreamDownloadType): Promise<void>; 11926 + } 11927 + interface StreamVideos { 11928 + /** 11929 + * Lists all videos in a users account. 11930 + * @returns The list of videos. 11931 + * @throws {BadRequestError} if the parameters are invalid 11932 + * @throws {InternalError} if an unexpected error occurs 11933 + */ 11934 + list(params?: StreamVideosListParams): Promise<StreamVideo[]>; 11935 + } 11936 + interface StreamWatermarks { 11937 + /** 11938 + * Generate a new watermark profile 11939 + * @param input The image stream to upload 11940 + * @param params The watermark creation parameters. 11941 + * @returns The created watermark profile. 11942 + * @throws {BadRequestError} if the parameters are invalid 11943 + * @throws {InvalidURLError} if the URL is invalid 11944 + * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached 11945 + * @throws {InternalError} if an unexpected error occurs 11946 + */ 11947 + generate(input: ReadableStream, params: StreamWatermarkCreateParams): Promise<StreamWatermark>; 11948 + /** 11949 + * Generate a new watermark profile 11950 + * @param url The image url to upload 11951 + * @param params The watermark creation parameters. 11952 + * @returns The created watermark profile. 11953 + * @throws {BadRequestError} if the parameters are invalid 11954 + * @throws {InvalidURLError} if the URL is invalid 11955 + * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached 11956 + * @throws {InternalError} if an unexpected error occurs 11957 + */ 11958 + generate(url: string, params: StreamWatermarkCreateParams): Promise<StreamWatermark>; 11959 + /** 11960 + * Lists all watermark profiles for an account. 11961 + * @returns The list of watermark profiles. 11962 + * @throws {InternalError} if an unexpected error occurs 11963 + */ 11964 + list(): Promise<StreamWatermark[]>; 11965 + /** 11966 + * Retrieves details for a single watermark profile. 11967 + * @param watermarkId The watermark profile identifier. 11968 + * @returns The watermark profile details. 11969 + * @throws {NotFoundError} if the watermark is not found 11970 + * @throws {InternalError} if an unexpected error occurs 11971 + */ 11972 + get(watermarkId: string): Promise<StreamWatermark>; 11973 + /** 11974 + * Deletes a watermark profile. 11975 + * @param watermarkId The watermark profile identifier. 11976 + * @returns A promise that resolves when deletion completes. 11977 + * @throws {NotFoundError} if the watermark is not found 11978 + * @throws {InternalError} if an unexpected error occurs 11979 + */ 11980 + delete(watermarkId: string): Promise<void>; 11981 + } 11982 + type StreamUpdateVideoParams = { 11983 + /** 11984 + * Lists the origins allowed to display the video. Enter allowed origin 11985 + * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the 11986 + * video to be viewed on any origin. 11987 + */ 11988 + allowedOrigins?: Array<string>; 11989 + /** 11990 + * A user-defined identifier for the media creator. 11991 + */ 11992 + creator?: string; 11993 + /** 11994 + * The maximum duration in seconds for a video upload. Can be set for a 11995 + * video that is not yet uploaded to limit its duration. Uploads that exceed the 11996 + * specified duration will fail during processing. A value of `-1` means the value 11997 + * is unknown. 11998 + */ 11999 + maxDurationSeconds?: number; 12000 + /** 12001 + * A user modifiable key-value store used to reference other systems of 12002 + * record for managing videos. 12003 + */ 12004 + meta?: Record<string, string>; 12005 + /** 12006 + * Indicates whether the video can be a accessed using the id. When 12007 + * set to `true`, a signed token must be generated with a signing key to view the 12008 + * video. 12009 + */ 12010 + requireSignedURLs?: boolean; 12011 + /** 12012 + * Indicates the date and time at which the video will be deleted. Omit 12013 + * the field to indicate no change, or include with a `null` value to remove an 12014 + * existing scheduled deletion. If specified, must be at least 30 days from upload 12015 + * time. 12016 + */ 12017 + scheduledDeletion?: string | null; 12018 + /** 12019 + * The timestamp for a thumbnail image calculated as a percentage value 12020 + * of the video's duration. To convert from a second-wise timestamp to a 12021 + * percentage, divide the desired timestamp by the total duration of the video. If 12022 + * this value is not set, the default thumbnail image is taken from 0s of the 12023 + * video. 12024 + */ 12025 + thumbnailTimestampPct?: number; 12026 + }; 12027 + type StreamCaption = { 12028 + /** 12029 + * Whether the caption was generated via AI. 12030 + */ 12031 + generated?: boolean; 12032 + /** 12033 + * The language label displayed in the native language to users. 12034 + */ 12035 + label: string; 12036 + /** 12037 + * The language tag in BCP 47 format. 12038 + */ 12039 + language: string; 12040 + /** 12041 + * The status of a generated caption. 12042 + */ 12043 + status?: 'ready' | 'inprogress' | 'error'; 12044 + }; 12045 + type StreamDownloadStatus = 'ready' | 'inprogress' | 'error'; 12046 + type StreamDownloadType = 'default' | 'audio'; 12047 + type StreamDownload = { 12048 + /** 12049 + * Indicates the progress as a percentage between 0 and 100. 12050 + */ 12051 + percentComplete: number; 12052 + /** 12053 + * The status of a generated download. 12054 + */ 12055 + status: StreamDownloadStatus; 12056 + /** 12057 + * The URL to access the generated download. 12058 + */ 12059 + url?: string; 12060 + }; 12061 + /** 12062 + * An object with download type keys. Each key is optional and only present if that 12063 + * download type has been created. 12064 + */ 12065 + type StreamDownloadGetResponse = { 12066 + /** 12067 + * The audio-only download. Only present if this download type has been created. 12068 + */ 12069 + audio?: StreamDownload; 12070 + /** 12071 + * The default video download. Only present if this download type has been created. 12072 + */ 12073 + default?: StreamDownload; 12074 + }; 12075 + type StreamWatermarkPosition = 'upperRight' | 'upperLeft' | 'lowerLeft' | 'lowerRight' | 'center'; 12076 + type StreamWatermark = { 12077 + /** 12078 + * The unique identifier for a watermark profile. 12079 + */ 12080 + id: string; 12081 + /** 12082 + * The size of the image in bytes. 12083 + */ 12084 + size: number; 12085 + /** 12086 + * The height of the image in pixels. 12087 + */ 12088 + height: number; 12089 + /** 12090 + * The width of the image in pixels. 12091 + */ 12092 + width: number; 12093 + /** 12094 + * The date and a time a watermark profile was created. 12095 + */ 12096 + created: string; 12097 + /** 12098 + * The source URL for a downloaded image. If the watermark profile was created via 12099 + * direct upload, this field is null. 12100 + */ 12101 + downloadedFrom: string | null; 12102 + /** 12103 + * A short description of the watermark profile. 12104 + */ 12105 + name: string; 12106 + /** 12107 + * The translucency of the image. A value of `0.0` makes the image completely 12108 + * transparent, and `1.0` makes the image completely opaque. Note that if the image 12109 + * is already semi-transparent, setting this to `1.0` will not make the image 12110 + * completely opaque. 12111 + */ 12112 + opacity: number; 12113 + /** 12114 + * The whitespace between the adjacent edges (determined by position) of the video 12115 + * and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded 12116 + * video width or length, as determined by the algorithm. 12117 + */ 12118 + padding: number; 12119 + /** 12120 + * The size of the image relative to the overall size of the video. This parameter 12121 + * will adapt to horizontal and vertical videos automatically. `0.0` indicates no 12122 + * scaling (use the size of the image as-is), and `1.0 `fills the entire video. 12123 + */ 12124 + scale: number; 12125 + /** 12126 + * The location of the image. Valid positions are: `upperRight`, `upperLeft`, 12127 + * `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the 12128 + * `padding` parameter. 12129 + */ 12130 + position: StreamWatermarkPosition; 12131 + }; 12132 + type StreamWatermarkCreateParams = { 12133 + /** 12134 + * A short description of the watermark profile. 12135 + */ 12136 + name?: string; 12137 + /** 12138 + * The translucency of the image. A value of `0.0` makes the image completely 12139 + * transparent, and `1.0` makes the image completely opaque. Note that if the 12140 + * image is already semi-transparent, setting this to `1.0` will not make the 12141 + * image completely opaque. 12142 + */ 12143 + opacity?: number; 12144 + /** 12145 + * The whitespace between the adjacent edges (determined by position) of the 12146 + * video and the image. `0.0` indicates no padding, and `1.0` indicates a fully 12147 + * padded video width or length, as determined by the algorithm. 12148 + */ 12149 + padding?: number; 12150 + /** 12151 + * The size of the image relative to the overall size of the video. This 12152 + * parameter will adapt to horizontal and vertical videos automatically. `0.0` 12153 + * indicates no scaling (use the size of the image as-is), and `1.0 `fills the 12154 + * entire video. 12155 + */ 12156 + scale?: number; 12157 + /** 12158 + * The location of the image. 12159 + */ 12160 + position?: StreamWatermarkPosition; 12161 + }; 12162 + type StreamVideosListParams = { 12163 + /** 12164 + * The maximum number of videos to return. 12165 + */ 12166 + limit?: number; 12167 + /** 12168 + * Return videos created before this timestamp. 12169 + * (RFC3339/RFC3339Nano) 12170 + */ 12171 + before?: string; 12172 + /** 12173 + * Comparison operator for the `before` field. 12174 + * @default 'lt' 12175 + */ 12176 + beforeComp?: StreamPaginationComparison; 12177 + /** 12178 + * Return videos created after this timestamp. 12179 + * (RFC3339/RFC3339Nano) 12180 + */ 12181 + after?: string; 12182 + /** 12183 + * Comparison operator for the `after` field. 12184 + * @default 'gte' 12185 + */ 12186 + afterComp?: StreamPaginationComparison; 12187 + }; 12188 + type StreamPaginationComparison = 'eq' | 'gt' | 'gte' | 'lt' | 'lte'; 12189 + /** 12190 + * Error object for Stream binding operations. 12191 + */ 12192 + interface StreamError extends Error { 12193 + readonly code: number; 12194 + readonly statusCode: number; 12195 + readonly message: string; 12196 + readonly stack?: string; 12197 + } 12198 + interface InternalError extends StreamError { 12199 + name: 'InternalError'; 12200 + } 12201 + interface BadRequestError extends StreamError { 12202 + name: 'BadRequestError'; 12203 + } 12204 + interface NotFoundError extends StreamError { 12205 + name: 'NotFoundError'; 12206 + } 12207 + interface ForbiddenError extends StreamError { 12208 + name: 'ForbiddenError'; 12209 + } 12210 + interface RateLimitedError extends StreamError { 12211 + name: 'RateLimitedError'; 12212 + } 12213 + interface QuotaReachedError extends StreamError { 12214 + name: 'QuotaReachedError'; 12215 + } 12216 + interface MaxFileSizeError extends StreamError { 12217 + name: 'MaxFileSizeError'; 12218 + } 12219 + interface InvalidURLError extends StreamError { 12220 + name: 'InvalidURLError'; 12221 + } 12222 + interface AlreadyUploadedError extends StreamError { 12223 + name: 'AlreadyUploadedError'; 12224 + } 12225 + interface TooManyWatermarksError extends StreamError { 12226 + name: 'TooManyWatermarksError'; 12227 + } 10301 12228 type MarkdownDocument = { 10302 12229 name: string; 10303 12230 blob: Blob; 10304 12231 }; 10305 12232 type ConversionResponse = { 12233 + id: string; 10306 12234 name: string; 10307 12235 mimeType: string; 10308 12236 format: 'markdown'; 10309 12237 tokens: number; 10310 12238 data: string; 10311 12239 } | { 12240 + id: string; 10312 12241 name: string; 10313 12242 mimeType: string; 10314 12243 format: 'error'; ··· 10326 12255 images?: EmbeddedImageConversionOptions & { 10327 12256 convertOGImage?: boolean; 10328 12257 }; 12258 + hostname?: string; 12259 + cssSelector?: string; 10329 12260 }; 10330 12261 docx?: { 10331 12262 images?: EmbeddedImageConversionOptions; ··· 10411 12342 readonly type: "fetch"; 10412 12343 readonly statusCode: number; 10413 12344 } 12345 + interface ConnectEventInfo { 12346 + readonly type: "connect"; 12347 + } 10414 12348 type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound"; 10415 12349 interface ScriptVersion { 10416 12350 readonly id: string; ··· 10428 12362 readonly scriptName?: string; 10429 12363 readonly scriptTags?: string[]; 10430 12364 readonly scriptVersion?: ScriptVersion; 10431 - readonly info: FetchEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | CustomEventInfo; 12365 + readonly info: FetchEventInfo | ConnectEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | CustomEventInfo; 10432 12366 } 10433 12367 interface Outcome { 10434 12368 readonly type: "outcome";
+4
apps/cf-sandbox/wrangler.jsonc
··· 20 20 "binding": "POCKETENV_COPY", 21 21 "bucket_name": "pocketenv-copy", 22 22 }, 23 + { 24 + "binding": "BACKUP_BUCKET", 25 + "bucket_name": "pocketenv-backup", 26 + }, 23 27 ], 24 28 /** 25 29 * Smart Placement