@workers-community/workers-types 4.20260131.0 → 4.20260329.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +1853 -81
  2. package/index.ts +1851 -80
  3. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -477,54 +477,69 @@ interface ExecutionContext<Props = unknown> {
477
477
  passThroughOnException(): void;
478
478
  readonly props: Props;
479
479
  }
480
- type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (
480
+ type ExportedHandlerFetchHandler<
481
+ Env = unknown,
482
+ CfHostMetadata = unknown,
483
+ Props = unknown,
484
+ > = (
481
485
  request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
482
486
  env: Env,
483
- ctx: ExecutionContext,
487
+ ctx: ExecutionContext<Props>,
484
488
  ) => Response | Promise<Response>;
485
- type ExportedHandlerTailHandler<Env = unknown> = (
489
+ type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
490
+ socket: Socket,
491
+ env: Env,
492
+ ctx: ExecutionContext<Props>,
493
+ ) => void | Promise<void>;
494
+ type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
486
495
  events: TraceItem[],
487
496
  env: Env,
488
- ctx: ExecutionContext,
497
+ ctx: ExecutionContext<Props>,
489
498
  ) => void | Promise<void>;
490
- type ExportedHandlerTraceHandler<Env = unknown> = (
499
+ type ExportedHandlerTraceHandler<Env = unknown, Props = unknown> = (
491
500
  traces: TraceItem[],
492
501
  env: Env,
493
- ctx: ExecutionContext,
502
+ ctx: ExecutionContext<Props>,
494
503
  ) => void | Promise<void>;
495
- type ExportedHandlerTailStreamHandler<Env = unknown> = (
504
+ type ExportedHandlerTailStreamHandler<Env = unknown, Props = unknown> = (
496
505
  event: TailStream.TailEvent<TailStream.Onset>,
497
506
  env: Env,
498
- ctx: ExecutionContext,
507
+ ctx: ExecutionContext<Props>,
499
508
  ) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
500
- type ExportedHandlerScheduledHandler<Env = unknown> = (
509
+ type ExportedHandlerScheduledHandler<Env = unknown, Props = unknown> = (
501
510
  controller: ScheduledController,
502
511
  env: Env,
503
- ctx: ExecutionContext,
512
+ ctx: ExecutionContext<Props>,
504
513
  ) => void | Promise<void>;
505
- type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (
514
+ type ExportedHandlerQueueHandler<
515
+ Env = unknown,
516
+ Message = unknown,
517
+ Props = unknown,
518
+ > = (
506
519
  batch: MessageBatch<Message>,
507
520
  env: Env,
508
- ctx: ExecutionContext,
521
+ ctx: ExecutionContext<Props>,
509
522
  ) => void | Promise<void>;
510
- type ExportedHandlerTestHandler<Env = unknown> = (
523
+ type ExportedHandlerTestHandler<Env = unknown, Props = unknown> = (
511
524
  controller: TestController,
512
525
  env: Env,
513
- ctx: ExecutionContext,
526
+ ctx: ExecutionContext<Props>,
514
527
  ) => void | Promise<void>;
515
528
  interface ExportedHandler<
516
529
  Env = unknown,
517
530
  QueueHandlerMessage = unknown,
518
531
  CfHostMetadata = unknown,
532
+ Props = unknown,
519
533
  > {
520
- fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
521
- tail?: ExportedHandlerTailHandler<Env>;
522
- trace?: ExportedHandlerTraceHandler<Env>;
523
- tailStream?: ExportedHandlerTailStreamHandler<Env>;
524
- scheduled?: ExportedHandlerScheduledHandler<Env>;
525
- test?: ExportedHandlerTestHandler<Env>;
526
- email?: EmailExportedHandler<Env>;
527
- queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
534
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
535
+ connect?: ExportedHandlerConnectHandler<Env, Props>;
536
+ tail?: ExportedHandlerTailHandler<Env, Props>;
537
+ trace?: ExportedHandlerTraceHandler<Env, Props>;
538
+ tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
539
+ scheduled?: ExportedHandlerScheduledHandler<Env, Props>;
540
+ test?: ExportedHandlerTestHandler<Env, Props>;
541
+ email?: EmailExportedHandler<Env, Props>;
542
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
528
543
  }
529
544
  interface StructuredSerializeOptions {
530
545
  transfer?: any[];
@@ -537,12 +552,14 @@ declare abstract class Navigator {
537
552
  interface AlarmInvocationInfo {
538
553
  readonly isRetry: boolean;
539
554
  readonly retryCount: number;
555
+ readonly scheduledTime: number;
540
556
  }
541
557
  interface Cloudflare {
542
558
  readonly compatibilityFlags: Record<string, boolean>;
543
559
  }
544
560
  interface DurableObject {
545
561
  fetch(request: Request): Response | Promise<Response>;
562
+ connect?(socket: Socket): void | Promise<void>;
546
563
  alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
547
564
  webSocketMessage?(
548
565
  ws: WebSocket,
@@ -560,7 +577,7 @@ type DurableObjectStub<
560
577
  T extends Rpc.DurableObjectBranded | undefined = undefined,
561
578
  > = Fetcher<
562
579
  T,
563
- "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
580
+ "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
564
581
  > & {
565
582
  readonly id: DurableObjectId;
566
583
  readonly name?: string;
@@ -569,6 +586,7 @@ interface DurableObjectId {
569
586
  toString(): string;
570
587
  equals(other: DurableObjectId): boolean;
571
588
  readonly name?: string;
589
+ readonly jurisdiction?: string;
572
590
  }
573
591
  declare abstract class DurableObjectNamespace<
574
592
  T extends Rpc.DurableObjectBranded | undefined = undefined,
@@ -3099,6 +3117,7 @@ interface TraceItem {
3099
3117
  | (
3100
3118
  | TraceItemFetchEventInfo
3101
3119
  | TraceItemJsRpcEventInfo
3120
+ | TraceItemConnectEventInfo
3102
3121
  | TraceItemScheduledEventInfo
3103
3122
  | TraceItemAlarmEventInfo
3104
3123
  | TraceItemQueueEventInfo
@@ -3117,6 +3136,7 @@ interface TraceItem {
3117
3136
  readonly scriptVersion?: ScriptVersion;
3118
3137
  readonly dispatchNamespace?: string;
3119
3138
  readonly scriptTags?: string[];
3139
+ readonly tailAttributes?: Record<string, boolean | number | string>;
3120
3140
  readonly durableObjectId?: string;
3121
3141
  readonly outcome: string;
3122
3142
  readonly executionModel: string;
@@ -3127,6 +3147,7 @@ interface TraceItem {
3127
3147
  interface TraceItemAlarmEventInfo {
3128
3148
  readonly scheduledTime: Date;
3129
3149
  }
3150
+ interface TraceItemConnectEventInfo {}
3130
3151
  interface TraceItemCustomEventInfo {}
3131
3152
  interface TraceItemScheduledEventInfo {
3132
3153
  readonly scheduledTime: number;
@@ -3561,7 +3582,7 @@ declare var WebSocket: {
3561
3582
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3562
3583
  */
3563
3584
  interface WebSocket extends EventTarget<WebSocketEventMap> {
3564
- accept(): void;
3585
+ accept(options?: WebSocketAcceptOptions): void;
3565
3586
  /**
3566
3587
  * 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.
3567
3588
  *
@@ -3600,6 +3621,22 @@ interface WebSocket extends EventTarget<WebSocketEventMap> {
3600
3621
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
3601
3622
  */
3602
3623
  extensions: string | null;
3624
+ /**
3625
+ * The **`WebSocket.binaryType`** property controls the type of binary data being received over the WebSocket connection.
3626
+ *
3627
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)
3628
+ */
3629
+ binaryType: "blob" | "arraybuffer";
3630
+ }
3631
+ interface WebSocketAcceptOptions {
3632
+ /**
3633
+ * When set to `true`, receiving a server-initiated WebSocket Close frame will not
3634
+ * automatically send a reciprocal Close frame, leaving the connection in a half-open
3635
+ * state. This is useful for proxying scenarios where you need to coordinate closing
3636
+ * both sides independently. Defaults to `false` when the
3637
+ * `no_web_socket_half_open_by_default` compatibility flag is enabled.
3638
+ */
3639
+ allowHalfOpen?: boolean;
3603
3640
  }
3604
3641
  declare const WebSocketPair: {
3605
3642
  new (): {
@@ -3724,19 +3761,21 @@ interface Container {
3724
3761
  signal(signo: number): void;
3725
3762
  getTcpPort(port: number): Fetcher;
3726
3763
  setInactivityTimeout(durationMs: number | bigint): Promise<void>;
3764
+ interceptOutboundHttp(addr: string, binding: Fetcher): Promise<void>;
3765
+ interceptAllOutboundHttp(binding: Fetcher): Promise<void>;
3727
3766
  }
3728
3767
  interface ContainerStartupOptions {
3729
3768
  entrypoint?: string[];
3730
3769
  enableInternet: boolean;
3731
3770
  env?: Record<string, string>;
3732
- hardTimeout?: number | bigint;
3771
+ labels?: Record<string, string>;
3733
3772
  }
3734
3773
  /**
3735
3774
  * 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.
3736
3775
  *
3737
3776
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
3738
3777
  */
3739
- interface MessagePort extends EventTarget {
3778
+ declare abstract class MessagePort extends EventTarget {
3740
3779
  /**
3741
3780
  * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts.
3742
3781
  *
@@ -3816,6 +3855,7 @@ interface WorkerLoader {
3816
3855
  name: string | null,
3817
3856
  getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
3818
3857
  ): WorkerStub;
3858
+ load(code: WorkerLoaderWorkerCode): WorkerStub;
3819
3859
  }
3820
3860
  interface WorkerLoaderModule {
3821
3861
  js?: string;
@@ -3848,6 +3888,180 @@ declare abstract class Performance {
3848
3888
  get timeOrigin(): number;
3849
3889
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
3850
3890
  now(): number;
3891
+ /**
3892
+ * The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object.
3893
+ *
3894
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)
3895
+ */
3896
+ toJSON(): object;
3897
+ }
3898
+ // AI Search V2 API Error Interfaces
3899
+ interface AiSearchInternalError extends Error {}
3900
+ interface AiSearchNotFoundError extends Error {}
3901
+ interface AiSearchNameNotSetError extends Error {}
3902
+ // AI Search V2 Request Types
3903
+ type AiSearchSearchRequest = {
3904
+ messages: Array<{
3905
+ role: "system" | "developer" | "user" | "assistant" | "tool";
3906
+ content: string | null;
3907
+ }>;
3908
+ ai_search_options?: {
3909
+ retrieval?: {
3910
+ retrieval_type?: "vector" | "keyword" | "hybrid";
3911
+ /** Match threshold (0-1, default 0.4) */
3912
+ match_threshold?: number;
3913
+ /** Maximum number of results (1-50, default 10) */
3914
+ max_num_results?: number;
3915
+ filters?: VectorizeVectorMetadataFilter;
3916
+ /** Context expansion (0-3, default 0) */
3917
+ context_expansion?: number;
3918
+ [key: string]: unknown;
3919
+ };
3920
+ query_rewrite?: {
3921
+ enabled?: boolean;
3922
+ model?: string;
3923
+ rewrite_prompt?: string;
3924
+ [key: string]: unknown;
3925
+ };
3926
+ reranking?: {
3927
+ /** Enable reranking (default false) */
3928
+ enabled?: boolean;
3929
+ model?: "@cf/baai/bge-reranker-base" | "";
3930
+ /** Match threshold (0-1, default 0.4) */
3931
+ match_threshold?: number;
3932
+ [key: string]: unknown;
3933
+ };
3934
+ [key: string]: unknown;
3935
+ };
3936
+ };
3937
+ type AiSearchChatCompletionsRequest = {
3938
+ messages: Array<{
3939
+ role: "system" | "developer" | "user" | "assistant" | "tool";
3940
+ content: string | null;
3941
+ }>;
3942
+ model?: string;
3943
+ stream?: boolean;
3944
+ ai_search_options?: {
3945
+ retrieval?: {
3946
+ retrieval_type?: "vector" | "keyword" | "hybrid";
3947
+ match_threshold?: number;
3948
+ max_num_results?: number;
3949
+ filters?: VectorizeVectorMetadataFilter;
3950
+ context_expansion?: number;
3951
+ [key: string]: unknown;
3952
+ };
3953
+ query_rewrite?: {
3954
+ enabled?: boolean;
3955
+ model?: string;
3956
+ rewrite_prompt?: string;
3957
+ [key: string]: unknown;
3958
+ };
3959
+ reranking?: {
3960
+ enabled?: boolean;
3961
+ model?: "@cf/baai/bge-reranker-base" | "";
3962
+ match_threshold?: number;
3963
+ [key: string]: unknown;
3964
+ };
3965
+ [key: string]: unknown;
3966
+ };
3967
+ [key: string]: unknown;
3968
+ };
3969
+ // AI Search V2 Response Types
3970
+ type AiSearchSearchResponse = {
3971
+ search_query: string;
3972
+ chunks: Array<{
3973
+ id: string;
3974
+ type: string;
3975
+ /** Match score (0-1) */
3976
+ score: number;
3977
+ text: string;
3978
+ item: {
3979
+ timestamp?: number;
3980
+ key: string;
3981
+ metadata?: Record<string, unknown>;
3982
+ };
3983
+ scoring_details?: {
3984
+ /** Keyword match score (0-1) */
3985
+ keyword_score?: number;
3986
+ /** Vector similarity score (0-1) */
3987
+ vector_score?: number;
3988
+ };
3989
+ }>;
3990
+ };
3991
+ type AiSearchListResponse = Array<{
3992
+ id: string;
3993
+ internal_id?: string;
3994
+ account_id?: string;
3995
+ account_tag?: string;
3996
+ /** Whether the instance is enabled (default true) */
3997
+ enable?: boolean;
3998
+ type?: "r2" | "web-crawler";
3999
+ source?: string;
4000
+ [key: string]: unknown;
4001
+ }>;
4002
+ type AiSearchConfig = {
4003
+ /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
4004
+ id: string;
4005
+ type: "r2" | "web-crawler";
4006
+ source: string;
4007
+ source_params?: object;
4008
+ /** Token ID (UUID format) */
4009
+ token_id?: string;
4010
+ ai_gateway_id?: string;
4011
+ /** Enable query rewriting (default false) */
4012
+ rewrite_query?: boolean;
4013
+ /** Enable reranking (default false) */
4014
+ reranking?: boolean;
4015
+ embedding_model?: string;
4016
+ ai_search_model?: string;
4017
+ };
4018
+ type AiSearchInstance = {
4019
+ id: string;
4020
+ enable?: boolean;
4021
+ type?: "r2" | "web-crawler";
4022
+ source?: string;
4023
+ [key: string]: unknown;
4024
+ };
4025
+ // AI Search Instance Service - Instance-level operations
4026
+ declare abstract class AiSearchInstanceService {
4027
+ /**
4028
+ * Search the AI Search instance for relevant chunks.
4029
+ * @param params Search request with messages and AI search options
4030
+ * @returns Search response with matching chunks
4031
+ */
4032
+ search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
4033
+ /**
4034
+ * Generate chat completions with AI Search context.
4035
+ * @param params Chat completions request with optional streaming
4036
+ * @returns Response object (if streaming) or chat completion result
4037
+ */
4038
+ chatCompletions(
4039
+ params: AiSearchChatCompletionsRequest,
4040
+ ): Promise<Response | object>;
4041
+ /**
4042
+ * Delete this AI Search instance.
4043
+ */
4044
+ delete(): Promise<void>;
4045
+ }
4046
+ // AI Search Account Service - Account-level operations
4047
+ declare abstract class AiSearchAccountService {
4048
+ /**
4049
+ * List all AI Search instances in the account.
4050
+ * @returns Array of AI Search instances
4051
+ */
4052
+ list(): Promise<AiSearchListResponse>;
4053
+ /**
4054
+ * Get an AI Search instance by ID.
4055
+ * @param name Instance ID
4056
+ * @returns Instance service for performing operations
4057
+ */
4058
+ get(name: string): AiSearchInstanceService;
4059
+ /**
4060
+ * Create a new AI Search instance.
4061
+ * @param config Instance configuration
4062
+ * @returns Instance service for performing operations
4063
+ */
4064
+ create(config: AiSearchConfig): Promise<AiSearchInstanceService>;
3851
4065
  }
3852
4066
  type AiImageClassificationInput = {
3853
4067
  image: number[];
@@ -4123,6 +4337,400 @@ declare abstract class BaseAiTranslation {
4123
4337
  inputs: AiTranslationInput;
4124
4338
  postProcessedOutputs: AiTranslationOutput;
4125
4339
  }
4340
+ /**
4341
+ * Workers AI support for OpenAI's Chat Completions API
4342
+ */
4343
+ type ChatCompletionContentPartText = {
4344
+ type: "text";
4345
+ text: string;
4346
+ };
4347
+ type ChatCompletionContentPartImage = {
4348
+ type: "image_url";
4349
+ image_url: {
4350
+ url: string;
4351
+ detail?: "auto" | "low" | "high";
4352
+ };
4353
+ };
4354
+ type ChatCompletionContentPartInputAudio = {
4355
+ type: "input_audio";
4356
+ input_audio: {
4357
+ /** Base64 encoded audio data. */
4358
+ data: string;
4359
+ format: "wav" | "mp3";
4360
+ };
4361
+ };
4362
+ type ChatCompletionContentPartFile = {
4363
+ type: "file";
4364
+ file: {
4365
+ /** Base64 encoded file data. */
4366
+ file_data?: string;
4367
+ /** The ID of an uploaded file. */
4368
+ file_id?: string;
4369
+ filename?: string;
4370
+ };
4371
+ };
4372
+ type ChatCompletionContentPartRefusal = {
4373
+ type: "refusal";
4374
+ refusal: string;
4375
+ };
4376
+ type ChatCompletionContentPart =
4377
+ | ChatCompletionContentPartText
4378
+ | ChatCompletionContentPartImage
4379
+ | ChatCompletionContentPartInputAudio
4380
+ | ChatCompletionContentPartFile;
4381
+ type FunctionDefinition = {
4382
+ name: string;
4383
+ description?: string;
4384
+ parameters?: Record<string, unknown>;
4385
+ strict?: boolean | null;
4386
+ };
4387
+ type ChatCompletionFunctionTool = {
4388
+ type: "function";
4389
+ function: FunctionDefinition;
4390
+ };
4391
+ type ChatCompletionCustomToolGrammarFormat = {
4392
+ type: "grammar";
4393
+ grammar: {
4394
+ definition: string;
4395
+ syntax: "lark" | "regex";
4396
+ };
4397
+ };
4398
+ type ChatCompletionCustomToolTextFormat = {
4399
+ type: "text";
4400
+ };
4401
+ type ChatCompletionCustomToolFormat =
4402
+ | ChatCompletionCustomToolTextFormat
4403
+ | ChatCompletionCustomToolGrammarFormat;
4404
+ type ChatCompletionCustomTool = {
4405
+ type: "custom";
4406
+ custom: {
4407
+ name: string;
4408
+ description?: string;
4409
+ format?: ChatCompletionCustomToolFormat;
4410
+ };
4411
+ };
4412
+ type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
4413
+ type ChatCompletionMessageFunctionToolCall = {
4414
+ id: string;
4415
+ type: "function";
4416
+ function: {
4417
+ name: string;
4418
+ /** JSON-encoded arguments string. */
4419
+ arguments: string;
4420
+ };
4421
+ };
4422
+ type ChatCompletionMessageCustomToolCall = {
4423
+ id: string;
4424
+ type: "custom";
4425
+ custom: {
4426
+ name: string;
4427
+ input: string;
4428
+ };
4429
+ };
4430
+ type ChatCompletionMessageToolCall =
4431
+ | ChatCompletionMessageFunctionToolCall
4432
+ | ChatCompletionMessageCustomToolCall;
4433
+ type ChatCompletionToolChoiceFunction = {
4434
+ type: "function";
4435
+ function: {
4436
+ name: string;
4437
+ };
4438
+ };
4439
+ type ChatCompletionToolChoiceCustom = {
4440
+ type: "custom";
4441
+ custom: {
4442
+ name: string;
4443
+ };
4444
+ };
4445
+ type ChatCompletionToolChoiceAllowedTools = {
4446
+ type: "allowed_tools";
4447
+ allowed_tools: {
4448
+ mode: "auto" | "required";
4449
+ tools: Array<Record<string, unknown>>;
4450
+ };
4451
+ };
4452
+ type ChatCompletionToolChoiceOption =
4453
+ | "none"
4454
+ | "auto"
4455
+ | "required"
4456
+ | ChatCompletionToolChoiceFunction
4457
+ | ChatCompletionToolChoiceCustom
4458
+ | ChatCompletionToolChoiceAllowedTools;
4459
+ type DeveloperMessage = {
4460
+ role: "developer";
4461
+ content:
4462
+ | string
4463
+ | Array<{
4464
+ type: "text";
4465
+ text: string;
4466
+ }>;
4467
+ name?: string;
4468
+ };
4469
+ type SystemMessage = {
4470
+ role: "system";
4471
+ content:
4472
+ | string
4473
+ | Array<{
4474
+ type: "text";
4475
+ text: string;
4476
+ }>;
4477
+ name?: string;
4478
+ };
4479
+ /**
4480
+ * Permissive merged content part used inside UserMessage arrays.
4481
+ *
4482
+ * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
4483
+ * inside nested array items does not correctly match different branches for
4484
+ * different array elements, so the schema uses a single merged object.
4485
+ */
4486
+ type UserMessageContentPart = {
4487
+ type: "text" | "image_url" | "input_audio" | "file";
4488
+ text?: string;
4489
+ image_url?: {
4490
+ url?: string;
4491
+ detail?: "auto" | "low" | "high";
4492
+ };
4493
+ input_audio?: {
4494
+ data?: string;
4495
+ format?: "wav" | "mp3";
4496
+ };
4497
+ file?: {
4498
+ file_data?: string;
4499
+ file_id?: string;
4500
+ filename?: string;
4501
+ };
4502
+ };
4503
+ type UserMessage = {
4504
+ role: "user";
4505
+ content: string | Array<UserMessageContentPart>;
4506
+ name?: string;
4507
+ };
4508
+ type AssistantMessageContentPart = {
4509
+ type: "text" | "refusal";
4510
+ text?: string;
4511
+ refusal?: string;
4512
+ };
4513
+ type AssistantMessage = {
4514
+ role: "assistant";
4515
+ content?: string | null | Array<AssistantMessageContentPart>;
4516
+ refusal?: string | null;
4517
+ name?: string;
4518
+ audio?: {
4519
+ id: string;
4520
+ };
4521
+ tool_calls?: Array<ChatCompletionMessageToolCall>;
4522
+ function_call?: {
4523
+ name: string;
4524
+ arguments: string;
4525
+ };
4526
+ };
4527
+ type ToolMessage = {
4528
+ role: "tool";
4529
+ content:
4530
+ | string
4531
+ | Array<{
4532
+ type: "text";
4533
+ text: string;
4534
+ }>;
4535
+ tool_call_id: string;
4536
+ };
4537
+ type FunctionMessage = {
4538
+ role: "function";
4539
+ content: string;
4540
+ name: string;
4541
+ };
4542
+ type ChatCompletionMessageParam =
4543
+ | DeveloperMessage
4544
+ | SystemMessage
4545
+ | UserMessage
4546
+ | AssistantMessage
4547
+ | ToolMessage
4548
+ | FunctionMessage;
4549
+ type ChatCompletionsResponseFormatText = {
4550
+ type: "text";
4551
+ };
4552
+ type ChatCompletionsResponseFormatJSONObject = {
4553
+ type: "json_object";
4554
+ };
4555
+ type ResponseFormatJSONSchema = {
4556
+ type: "json_schema";
4557
+ json_schema: {
4558
+ name: string;
4559
+ description?: string;
4560
+ schema?: Record<string, unknown>;
4561
+ strict?: boolean | null;
4562
+ };
4563
+ };
4564
+ type ResponseFormat =
4565
+ | ChatCompletionsResponseFormatText
4566
+ | ChatCompletionsResponseFormatJSONObject
4567
+ | ResponseFormatJSONSchema;
4568
+ type ChatCompletionsStreamOptions = {
4569
+ include_usage?: boolean;
4570
+ include_obfuscation?: boolean;
4571
+ };
4572
+ type PredictionContent = {
4573
+ type: "content";
4574
+ content:
4575
+ | string
4576
+ | Array<{
4577
+ type: "text";
4578
+ text: string;
4579
+ }>;
4580
+ };
4581
+ type AudioParams = {
4582
+ voice:
4583
+ | string
4584
+ | {
4585
+ id: string;
4586
+ };
4587
+ format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
4588
+ };
4589
+ type WebSearchUserLocation = {
4590
+ type: "approximate";
4591
+ approximate: {
4592
+ city?: string;
4593
+ country?: string;
4594
+ region?: string;
4595
+ timezone?: string;
4596
+ };
4597
+ };
4598
+ type WebSearchOptions = {
4599
+ search_context_size?: "low" | "medium" | "high";
4600
+ user_location?: WebSearchUserLocation;
4601
+ };
4602
+ type ChatTemplateKwargs = {
4603
+ /** Whether to enable reasoning, enabled by default. */
4604
+ enable_thinking?: boolean;
4605
+ /** If false, preserves reasoning context between turns. */
4606
+ clear_thinking?: boolean;
4607
+ };
4608
+ /** Shared optional properties used by both Prompt and Messages input branches. */
4609
+ type ChatCompletionsCommonOptions = {
4610
+ model?: string;
4611
+ audio?: AudioParams;
4612
+ frequency_penalty?: number | null;
4613
+ logit_bias?: Record<string, unknown> | null;
4614
+ logprobs?: boolean | null;
4615
+ top_logprobs?: number | null;
4616
+ max_tokens?: number | null;
4617
+ max_completion_tokens?: number | null;
4618
+ metadata?: Record<string, unknown> | null;
4619
+ modalities?: Array<"text" | "audio"> | null;
4620
+ n?: number | null;
4621
+ parallel_tool_calls?: boolean;
4622
+ prediction?: PredictionContent;
4623
+ presence_penalty?: number | null;
4624
+ reasoning_effort?: "low" | "medium" | "high" | null;
4625
+ chat_template_kwargs?: ChatTemplateKwargs;
4626
+ response_format?: ResponseFormat;
4627
+ seed?: number | null;
4628
+ service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
4629
+ stop?: string | Array<string> | null;
4630
+ store?: boolean | null;
4631
+ stream?: boolean | null;
4632
+ stream_options?: ChatCompletionsStreamOptions;
4633
+ temperature?: number | null;
4634
+ tool_choice?: ChatCompletionToolChoiceOption;
4635
+ tools?: Array<ChatCompletionTool>;
4636
+ top_p?: number | null;
4637
+ user?: string;
4638
+ web_search_options?: WebSearchOptions;
4639
+ function_call?:
4640
+ | "none"
4641
+ | "auto"
4642
+ | {
4643
+ name: string;
4644
+ };
4645
+ functions?: Array<FunctionDefinition>;
4646
+ };
4647
+ type PromptTokensDetails = {
4648
+ cached_tokens?: number;
4649
+ audio_tokens?: number;
4650
+ };
4651
+ type CompletionTokensDetails = {
4652
+ reasoning_tokens?: number;
4653
+ audio_tokens?: number;
4654
+ accepted_prediction_tokens?: number;
4655
+ rejected_prediction_tokens?: number;
4656
+ };
4657
+ type CompletionUsage = {
4658
+ prompt_tokens: number;
4659
+ completion_tokens: number;
4660
+ total_tokens: number;
4661
+ prompt_tokens_details?: PromptTokensDetails;
4662
+ completion_tokens_details?: CompletionTokensDetails;
4663
+ };
4664
+ type ChatCompletionTopLogprob = {
4665
+ token: string;
4666
+ logprob: number;
4667
+ bytes: Array<number> | null;
4668
+ };
4669
+ type ChatCompletionTokenLogprob = {
4670
+ token: string;
4671
+ logprob: number;
4672
+ bytes: Array<number> | null;
4673
+ top_logprobs: Array<ChatCompletionTopLogprob>;
4674
+ };
4675
+ type ChatCompletionAudio = {
4676
+ id: string;
4677
+ /** Base64 encoded audio bytes. */
4678
+ data: string;
4679
+ expires_at: number;
4680
+ transcript: string;
4681
+ };
4682
+ type ChatCompletionUrlCitation = {
4683
+ type: "url_citation";
4684
+ url_citation: {
4685
+ url: string;
4686
+ title: string;
4687
+ start_index: number;
4688
+ end_index: number;
4689
+ };
4690
+ };
4691
+ type ChatCompletionResponseMessage = {
4692
+ role: "assistant";
4693
+ content: string | null;
4694
+ refusal: string | null;
4695
+ annotations?: Array<ChatCompletionUrlCitation>;
4696
+ audio?: ChatCompletionAudio;
4697
+ tool_calls?: Array<ChatCompletionMessageToolCall>;
4698
+ function_call?: {
4699
+ name: string;
4700
+ arguments: string;
4701
+ } | null;
4702
+ };
4703
+ type ChatCompletionLogprobs = {
4704
+ content: Array<ChatCompletionTokenLogprob> | null;
4705
+ refusal?: Array<ChatCompletionTokenLogprob> | null;
4706
+ };
4707
+ type ChatCompletionChoice = {
4708
+ index: number;
4709
+ message: ChatCompletionResponseMessage;
4710
+ finish_reason:
4711
+ | "stop"
4712
+ | "length"
4713
+ | "tool_calls"
4714
+ | "content_filter"
4715
+ | "function_call";
4716
+ logprobs: ChatCompletionLogprobs | null;
4717
+ };
4718
+ type ChatCompletionsPromptInput = {
4719
+ prompt: string;
4720
+ } & ChatCompletionsCommonOptions;
4721
+ type ChatCompletionsMessagesInput = {
4722
+ messages: Array<ChatCompletionMessageParam>;
4723
+ } & ChatCompletionsCommonOptions;
4724
+ type ChatCompletionsOutput = {
4725
+ id: string;
4726
+ object: string;
4727
+ created: number;
4728
+ model: string;
4729
+ choices: Array<ChatCompletionChoice>;
4730
+ usage?: CompletionUsage;
4731
+ system_fingerprint?: string | null;
4732
+ service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
4733
+ };
4126
4734
  /**
4127
4735
  * Workers AI support for OpenAI's Responses API
4128
4736
  * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
@@ -4544,6 +5152,12 @@ type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
4544
5152
  type StreamOptions = {
4545
5153
  include_obfuscation?: boolean;
4546
5154
  };
5155
+ /** Marks keys from T that aren't in U as optional never */
5156
+ type Without<T, U> = {
5157
+ [P in Exclude<keyof T, keyof U>]?: never;
5158
+ };
5159
+ /** Either T or U, but not both (mutually exclusive) */
5160
+ type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
4547
5161
  type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
4548
5162
  | {
4549
5163
  text: string | string[];
@@ -4836,10 +5450,12 @@ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
4836
5450
  postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
4837
5451
  }
4838
5452
  interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
4839
- /**
4840
- * Base64 encoded value of the audio data.
4841
- */
4842
- audio: string;
5453
+ audio:
5454
+ | string
5455
+ | {
5456
+ body?: object;
5457
+ contentType?: string;
5458
+ };
4843
5459
  /**
4844
5460
  * Supported tasks are 'translate' or 'transcribe'.
4845
5461
  */
@@ -4857,9 +5473,33 @@ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
4857
5473
  */
4858
5474
  initial_prompt?: string;
4859
5475
  /**
4860
- * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
5476
+ * The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
4861
5477
  */
4862
5478
  prefix?: string;
5479
+ /**
5480
+ * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
5481
+ */
5482
+ beam_size?: number;
5483
+ /**
5484
+ * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
5485
+ */
5486
+ condition_on_previous_text?: boolean;
5487
+ /**
5488
+ * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
5489
+ */
5490
+ no_speech_threshold?: number;
5491
+ /**
5492
+ * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
5493
+ */
5494
+ compression_ratio_threshold?: number;
5495
+ /**
5496
+ * Threshold for filtering out segments with low average log probability, indicating low confidence.
5497
+ */
5498
+ log_prob_threshold?: number;
5499
+ /**
5500
+ * Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
5501
+ */
5502
+ hallucination_silence_threshold?: number;
4863
5503
  }
4864
5504
  interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
4865
5505
  transcription_info?: {
@@ -5006,11 +5646,11 @@ interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
5006
5646
  truncate_inputs?: boolean;
5007
5647
  }
5008
5648
  type Ai_Cf_Baai_Bge_M3_Output =
5009
- | Ai_Cf_Baai_Bge_M3_Ouput_Query
5649
+ | Ai_Cf_Baai_Bge_M3_Output_Query
5010
5650
  | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
5011
- | Ai_Cf_Baai_Bge_M3_Ouput_Embedding
5651
+ | Ai_Cf_Baai_Bge_M3_Output_Embedding
5012
5652
  | Ai_Cf_Baai_Bge_M3_AsyncResponse;
5013
- interface Ai_Cf_Baai_Bge_M3_Ouput_Query {
5653
+ interface Ai_Cf_Baai_Bge_M3_Output_Query {
5014
5654
  response?: {
5015
5655
  /**
5016
5656
  * Index of the context in the request
@@ -5030,7 +5670,7 @@ interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
5030
5670
  */
5031
5671
  pooling?: "mean" | "cls";
5032
5672
  }
5033
- interface Ai_Cf_Baai_Bge_M3_Ouput_Embedding {
5673
+ interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
5034
5674
  shape?: number[];
5035
5675
  /**
5036
5676
  * Embeddings of the requested text values
@@ -5135,7 +5775,7 @@ interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
5135
5775
  */
5136
5776
  role?: string;
5137
5777
  /**
5138
- * 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
5778
+ * The tool call id. If you don't know what to put here you can fall back to 000000001
5139
5779
  */
5140
5780
  tool_call_id?: string;
5141
5781
  content?:
@@ -5390,10 +6030,18 @@ interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
5390
6030
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5391
6031
  */
5392
6032
  role: string;
5393
- /**
5394
- * The content of the message as a string.
5395
- */
5396
- content: string;
6033
+ content:
6034
+ | string
6035
+ | {
6036
+ /**
6037
+ * Type of the content (text)
6038
+ */
6039
+ type?: string;
6040
+ /**
6041
+ * Text content
6042
+ */
6043
+ text?: string;
6044
+ }[];
5397
6045
  }[];
5398
6046
  functions?: {
5399
6047
  name: string;
@@ -6049,7 +6697,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
6049
6697
  */
6050
6698
  role?: string;
6051
6699
  /**
6052
- * 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
6700
+ * The tool call id. If you don't know what to put here you can fall back to 000000001
6053
6701
  */
6054
6702
  tool_call_id?: string;
6055
6703
  content?:
@@ -6176,7 +6824,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
6176
6824
  }
6177
6825
  )[];
6178
6826
  /**
6179
- * JSON schema that should be fulfilled for the response.
6827
+ * JSON schema that should be fufilled for the response.
6180
6828
  */
6181
6829
  guided_json?: object;
6182
6830
  /**
@@ -6450,7 +7098,7 @@ interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
6450
7098
  }
6451
7099
  )[];
6452
7100
  /**
6453
- * JSON schema that should be fulfilled for the response.
7101
+ * JSON schema that should be fufilled for the response.
6454
7102
  */
6455
7103
  guided_json?: object;
6456
7104
  /**
@@ -6543,7 +7191,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
6543
7191
  */
6544
7192
  prompt: string;
6545
7193
  /**
6546
- * JSON schema that should be fulfilled for the response.
7194
+ * JSON schema that should be fufilled for the response.
6547
7195
  */
6548
7196
  guided_json?: object;
6549
7197
  /**
@@ -6707,7 +7355,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
6707
7355
  }
6708
7356
  )[];
6709
7357
  /**
6710
- * JSON schema that should be fulfilled for the response.
7358
+ * JSON schema that should be fufilled for the response.
6711
7359
  */
6712
7360
  guided_json?: object;
6713
7361
  /**
@@ -6988,7 +7636,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
6988
7636
  )[];
6989
7637
  response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
6990
7638
  /**
6991
- * JSON schema that should be fulfilled for the response.
7639
+ * JSON schema that should be fufilled for the response.
6992
7640
  */
6993
7641
  guided_json?: object;
6994
7642
  /**
@@ -7227,7 +7875,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
7227
7875
  )[];
7228
7876
  response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7229
7877
  /**
7230
- * JSON schema that should be fulfilled for the response.
7878
+ * JSON schema that should be fufilled for the response.
7231
7879
  */
7232
7880
  guided_json?: object;
7233
7881
  /**
@@ -7392,10 +8040,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
7392
8040
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7393
8041
  */
7394
8042
  role: string;
7395
- /**
7396
- * The content of the message as a string.
7397
- */
7398
- content: string;
8043
+ content:
8044
+ | string
8045
+ | {
8046
+ /**
8047
+ * Type of the content (text)
8048
+ */
8049
+ type?: string;
8050
+ /**
8051
+ * Text content
8052
+ */
8053
+ text?: string;
8054
+ }[];
7399
8055
  }[];
7400
8056
  functions?: {
7401
8057
  name: string;
@@ -7607,10 +8263,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
7607
8263
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7608
8264
  */
7609
8265
  role: string;
7610
- /**
7611
- * The content of the message as a string.
7612
- */
7613
- content: string;
8266
+ content:
8267
+ | string
8268
+ | {
8269
+ /**
8270
+ * Type of the content (text)
8271
+ */
8272
+ type?: string;
8273
+ /**
8274
+ * Text content
8275
+ */
8276
+ text?: string;
8277
+ }[];
7614
8278
  }[];
7615
8279
  functions?: {
7616
8280
  name: string;
@@ -8178,12 +8842,12 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
8178
8842
  postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
8179
8843
  }
8180
8844
  declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
8181
- inputs: ResponsesInput;
8182
- postProcessedOutputs: ResponsesOutput;
8845
+ inputs: XOR<ResponsesInput, ChatCompletionsInput>;
8846
+ postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
8183
8847
  }
8184
8848
  declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
8185
- inputs: ResponsesInput;
8186
- postProcessedOutputs: ResponsesOutput;
8849
+ inputs: XOR<ResponsesInput, ChatCompletionsInput>;
8850
+ postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
8187
8851
  }
8188
8852
  interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
8189
8853
  /**
@@ -8315,7 +8979,7 @@ interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
8315
8979
  */
8316
8980
  text: string | string[];
8317
8981
  /**
8318
- * Target language to translate to
8982
+ * Target langauge to translate to
8319
8983
  */
8320
8984
  target_language:
8321
8985
  | "asm_Beng"
@@ -8431,10 +9095,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
8431
9095
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8432
9096
  */
8433
9097
  role: string;
8434
- /**
8435
- * The content of the message as a string.
8436
- */
8437
- content: string;
9098
+ content:
9099
+ | string
9100
+ | {
9101
+ /**
9102
+ * Type of the content (text)
9103
+ */
9104
+ type?: string;
9105
+ /**
9106
+ * Text content
9107
+ */
9108
+ text?: string;
9109
+ }[];
8438
9110
  }[];
8439
9111
  functions?: {
8440
9112
  name: string;
@@ -8646,10 +9318,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
8646
9318
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8647
9319
  */
8648
9320
  role: string;
8649
- /**
8650
- * The content of the message as a string.
8651
- */
8652
- content: string;
9321
+ content:
9322
+ | string
9323
+ | {
9324
+ /**
9325
+ * Type of the content (text)
9326
+ */
9327
+ type?: string;
9328
+ /**
9329
+ * Text content
9330
+ */
9331
+ text?: string;
9332
+ }[];
8653
9333
  }[];
8654
9334
  functions?: {
8655
9335
  name: string;
@@ -9204,6 +9884,66 @@ declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
9204
9884
  inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
9205
9885
  postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
9206
9886
  }
9887
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
9888
+ multipart: {
9889
+ body?: object;
9890
+ contentType?: string;
9891
+ };
9892
+ }
9893
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
9894
+ /**
9895
+ * Generated image as Base64 string.
9896
+ */
9897
+ image?: string;
9898
+ }
9899
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
9900
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
9901
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
9902
+ }
9903
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
9904
+ multipart: {
9905
+ body?: object;
9906
+ contentType?: string;
9907
+ };
9908
+ }
9909
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
9910
+ /**
9911
+ * Generated image as Base64 string.
9912
+ */
9913
+ image?: string;
9914
+ }
9915
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
9916
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
9917
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
9918
+ }
9919
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
9920
+ multipart: {
9921
+ body?: object;
9922
+ contentType?: string;
9923
+ };
9924
+ }
9925
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
9926
+ /**
9927
+ * Generated image as Base64 string.
9928
+ */
9929
+ image?: string;
9930
+ }
9931
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
9932
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
9933
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
9934
+ }
9935
+ declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
9936
+ inputs: ChatCompletionsInput;
9937
+ postProcessedOutputs: ChatCompletionsOutput;
9938
+ }
9939
+ declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
9940
+ inputs: ChatCompletionsInput;
9941
+ postProcessedOutputs: ChatCompletionsOutput;
9942
+ }
9943
+ declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
9944
+ inputs: ChatCompletionsInput;
9945
+ postProcessedOutputs: ChatCompletionsOutput;
9946
+ }
9207
9947
  interface AiModels {
9208
9948
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
9209
9949
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -9222,7 +9962,6 @@ interface AiModels {
9222
9962
  "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
9223
9963
  "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
9224
9964
  "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
9225
- "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
9226
9965
  "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
9227
9966
  "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
9228
9967
  "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
@@ -9289,6 +10028,12 @@ interface AiModels {
9289
10028
  "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
9290
10029
  "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
9291
10030
  "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
10031
+ "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
10032
+ "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
10033
+ "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
10034
+ "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
10035
+ "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
10036
+ "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
9292
10037
  }
9293
10038
  type AiOptions = {
9294
10039
  /**
@@ -9340,12 +10085,64 @@ type AiModelsSearchObject = {
9340
10085
  value: string;
9341
10086
  }[];
9342
10087
  };
10088
+ type ChatCompletionsBase = XOR<
10089
+ ChatCompletionsPromptInput,
10090
+ ChatCompletionsMessagesInput
10091
+ >;
10092
+ type ChatCompletionsInput = XOR<
10093
+ ChatCompletionsBase,
10094
+ {
10095
+ requests: ChatCompletionsBase[];
10096
+ }
10097
+ >;
9343
10098
  interface InferenceUpstreamError extends Error {}
9344
10099
  interface AiInternalError extends Error {}
9345
10100
  type AiModelListType = Record<string, any>;
9346
10101
  declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
9347
10102
  aiGatewayLogId: string | null;
9348
10103
  gateway(gatewayId: string): AiGateway;
10104
+ /**
10105
+ * Access the AI Search API for managing AI-powered search instances.
10106
+ *
10107
+ * This is the new API that replaces AutoRAG with better namespace separation:
10108
+ * - Account-level operations: `list()`, `create()`
10109
+ * - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
10110
+ *
10111
+ * @example
10112
+ * ```typescript
10113
+ * // List all AI Search instances
10114
+ * const instances = await env.AI.aiSearch.list();
10115
+ *
10116
+ * // Search an instance
10117
+ * const results = await env.AI.aiSearch.get('my-search').search({
10118
+ * messages: [{ role: 'user', content: 'What is the policy?' }],
10119
+ * ai_search_options: {
10120
+ * retrieval: { max_num_results: 10 }
10121
+ * }
10122
+ * });
10123
+ *
10124
+ * // Generate chat completions with AI Search context
10125
+ * const response = await env.AI.aiSearch.get('my-search').chatCompletions({
10126
+ * messages: [{ role: 'user', content: 'What is the policy?' }],
10127
+ * model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
10128
+ * });
10129
+ * ```
10130
+ */
10131
+ aiSearch(): AiSearchAccountService;
10132
+ /**
10133
+ * @deprecated AutoRAG has been replaced by AI Search.
10134
+ * Use `env.AI.aiSearch` instead for better API design and new features.
10135
+ *
10136
+ * Migration guide:
10137
+ * - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
10138
+ * - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
10139
+ * - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
10140
+ *
10141
+ * Note: The old API continues to work for backwards compatibility, but new projects should use AI Search.
10142
+ *
10143
+ * @see AiSearchAccountService
10144
+ * @param autoragId Optional instance ID (omit for account-level operations)
10145
+ */
9349
10146
  autorag(autoragId: string): AutoRAG;
9350
10147
  run<
9351
10148
  Name extends keyof AiModelList,
@@ -9502,9 +10299,24 @@ declare abstract class AiGateway {
9502
10299
  ): Promise<Response>;
9503
10300
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
9504
10301
  }
10302
+ /**
10303
+ * @deprecated AutoRAG has been replaced by AI Search. Use AiSearchInternalError instead.
10304
+ * @see AiSearchInternalError
10305
+ */
9505
10306
  interface AutoRAGInternalError extends Error {}
10307
+ /**
10308
+ * @deprecated AutoRAG has been replaced by AI Search. Use AiSearchNotFoundError instead.
10309
+ * @see AiSearchNotFoundError
10310
+ */
9506
10311
  interface AutoRAGNotFoundError extends Error {}
10312
+ /**
10313
+ * @deprecated This error type is no longer used in the AI Search API.
10314
+ */
9507
10315
  interface AutoRAGUnauthorizedError extends Error {}
10316
+ /**
10317
+ * @deprecated AutoRAG has been replaced by AI Search. Use AiSearchNameNotSetError instead.
10318
+ * @see AiSearchNameNotSetError
10319
+ */
9508
10320
  interface AutoRAGNameNotSetError extends Error {}
9509
10321
  type ComparisonFilter = {
9510
10322
  key: string;
@@ -9515,6 +10327,11 @@ type CompoundFilter = {
9515
10327
  type: "and" | "or";
9516
10328
  filters: ComparisonFilter[];
9517
10329
  };
10330
+ /**
10331
+ * @deprecated AutoRAG has been replaced by AI Search.
10332
+ * Use AiSearchSearchRequest with the new API instead.
10333
+ * @see AiSearchSearchRequest
10334
+ */
9518
10335
  type AutoRagSearchRequest = {
9519
10336
  query: string;
9520
10337
  filters?: CompoundFilter | ComparisonFilter;
@@ -9529,16 +10346,31 @@ type AutoRagSearchRequest = {
9529
10346
  };
9530
10347
  rewrite_query?: boolean;
9531
10348
  };
10349
+ /**
10350
+ * @deprecated AutoRAG has been replaced by AI Search.
10351
+ * Use AiSearchChatCompletionsRequest with the new API instead.
10352
+ * @see AiSearchChatCompletionsRequest
10353
+ */
9532
10354
  type AutoRagAiSearchRequest = AutoRagSearchRequest & {
9533
10355
  stream?: boolean;
9534
10356
  system_prompt?: string;
9535
10357
  };
10358
+ /**
10359
+ * @deprecated AutoRAG has been replaced by AI Search.
10360
+ * Use AiSearchChatCompletionsRequest with stream: true instead.
10361
+ * @see AiSearchChatCompletionsRequest
10362
+ */
9536
10363
  type AutoRagAiSearchRequestStreaming = Omit<
9537
10364
  AutoRagAiSearchRequest,
9538
10365
  "stream"
9539
10366
  > & {
9540
10367
  stream: true;
9541
10368
  };
10369
+ /**
10370
+ * @deprecated AutoRAG has been replaced by AI Search.
10371
+ * Use AiSearchSearchResponse with the new API instead.
10372
+ * @see AiSearchSearchResponse
10373
+ */
9542
10374
  type AutoRagSearchResponse = {
9543
10375
  object: "vector_store.search_results.page";
9544
10376
  search_query: string;
@@ -9555,6 +10387,11 @@ type AutoRagSearchResponse = {
9555
10387
  has_more: boolean;
9556
10388
  next_page: string | null;
9557
10389
  };
10390
+ /**
10391
+ * @deprecated AutoRAG has been replaced by AI Search.
10392
+ * Use AiSearchListResponse with the new API instead.
10393
+ * @see AiSearchListResponse
10394
+ */
9558
10395
  type AutoRagListResponse = {
9559
10396
  id: string;
9560
10397
  enable: boolean;
@@ -9564,14 +10401,51 @@ type AutoRagListResponse = {
9564
10401
  paused: boolean;
9565
10402
  status: string;
9566
10403
  }[];
10404
+ /**
10405
+ * @deprecated AutoRAG has been replaced by AI Search.
10406
+ * The new API returns different response formats for chat completions.
10407
+ */
9567
10408
  type AutoRagAiSearchResponse = AutoRagSearchResponse & {
9568
10409
  response: string;
9569
10410
  };
10411
+ /**
10412
+ * @deprecated AutoRAG has been replaced by AI Search.
10413
+ * Use the new AI Search API instead: `env.AI.aiSearch`
10414
+ *
10415
+ * Migration guide:
10416
+ * - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
10417
+ * - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
10418
+ * - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
10419
+ *
10420
+ * @see AiSearchAccountService
10421
+ * @see AiSearchInstanceService
10422
+ */
9570
10423
  declare abstract class AutoRAG {
10424
+ /**
10425
+ * @deprecated Use `env.AI.aiSearch.list()` instead.
10426
+ * @see AiSearchAccountService.list
10427
+ */
9571
10428
  list(): Promise<AutoRagListResponse>;
10429
+ /**
10430
+ * @deprecated Use `env.AI.aiSearch.get(id).search(...)` instead.
10431
+ * Note: The new API uses a messages array instead of a query string.
10432
+ * @see AiSearchInstanceService.search
10433
+ */
9572
10434
  search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
10435
+ /**
10436
+ * @deprecated Use `env.AI.aiSearch.get(id).chatCompletions(...)` instead.
10437
+ * @see AiSearchInstanceService.chatCompletions
10438
+ */
9573
10439
  aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
10440
+ /**
10441
+ * @deprecated Use `env.AI.aiSearch.get(id).chatCompletions(...)` instead.
10442
+ * @see AiSearchInstanceService.chatCompletions
10443
+ */
9574
10444
  aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
10445
+ /**
10446
+ * @deprecated Use `env.AI.aiSearch.get(id).chatCompletions(...)` instead.
10447
+ * @see AiSearchInstanceService.chatCompletions
10448
+ */
9575
10449
  aiSearch(
9576
10450
  params: AutoRagAiSearchRequest,
9577
10451
  ): Promise<AutoRagAiSearchResponse | Response>;
@@ -9695,6 +10569,41 @@ interface RequestInitCfProperties extends Record<string, unknown> {
9695
10569
  * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
9696
10570
  */
9697
10571
  cacheTtlByStatus?: Record<string, number>;
10572
+ /**
10573
+ * Explicit Cache-Control header value to set on the response stored in cache.
10574
+ * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
10575
+ *
10576
+ * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
10577
+ * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
10578
+ *
10579
+ * Can be used together with `cacheTtlByStatus`.
10580
+ */
10581
+ cacheControl?: string;
10582
+ /**
10583
+ * Whether the response should be eligible for Cache Reserve storage.
10584
+ */
10585
+ cacheReserveEligible?: boolean;
10586
+ /**
10587
+ * Whether to respect strong ETags (as opposed to weak ETags) from the origin.
10588
+ */
10589
+ respectStrongEtag?: boolean;
10590
+ /**
10591
+ * Whether to strip ETag headers from the origin response before caching.
10592
+ */
10593
+ stripEtags?: boolean;
10594
+ /**
10595
+ * Whether to strip Last-Modified headers from the origin response before caching.
10596
+ */
10597
+ stripLastModified?: boolean;
10598
+ /**
10599
+ * Whether to enable Cache Deception Armor, which protects against web cache
10600
+ * deception attacks by verifying the Content-Type matches the URL extension.
10601
+ */
10602
+ cacheDeceptionArmor?: boolean;
10603
+ /**
10604
+ * Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
10605
+ */
10606
+ cacheReserveMinimumFileSize?: number;
9698
10607
  scrapeShield?: boolean;
9699
10608
  apps?: boolean;
9700
10609
  image?: RequestInitCfPropertiesImage;
@@ -10799,10 +11708,10 @@ interface SendEmail {
10799
11708
  declare abstract class EmailEvent extends ExtendableEvent {
10800
11709
  readonly message: ForwardableEmailMessage;
10801
11710
  }
10802
- declare type EmailExportedHandler<Env = unknown> = (
11711
+ declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
10803
11712
  message: ForwardableEmailMessage,
10804
11713
  env: Env,
10805
- ctx: ExecutionContext,
11714
+ ctx: ExecutionContext<Props>,
10806
11715
  ) => void | Promise<void>;
10807
11716
  declare module "cloudflare:email" {
10808
11717
  let _EmailMessage: {
@@ -10968,6 +11877,86 @@ type ImageOutputOptions = {
10968
11877
  background?: string;
10969
11878
  anim?: boolean;
10970
11879
  };
11880
+ interface ImageMetadata {
11881
+ id: string;
11882
+ filename?: string;
11883
+ uploaded?: string;
11884
+ requireSignedURLs: boolean;
11885
+ meta?: Record<string, unknown>;
11886
+ variants: string[];
11887
+ draft?: boolean;
11888
+ creator?: string;
11889
+ }
11890
+ interface ImageUploadOptions {
11891
+ id?: string;
11892
+ filename?: string;
11893
+ requireSignedURLs?: boolean;
11894
+ metadata?: Record<string, unknown>;
11895
+ creator?: string;
11896
+ encoding?: "base64";
11897
+ }
11898
+ interface ImageUpdateOptions {
11899
+ requireSignedURLs?: boolean;
11900
+ metadata?: Record<string, unknown>;
11901
+ creator?: string;
11902
+ }
11903
+ interface ImageListOptions {
11904
+ limit?: number;
11905
+ cursor?: string;
11906
+ sortOrder?: "asc" | "desc";
11907
+ creator?: string;
11908
+ }
11909
+ interface ImageList {
11910
+ images: ImageMetadata[];
11911
+ cursor?: string;
11912
+ listComplete: boolean;
11913
+ }
11914
+ interface HostedImagesBinding {
11915
+ /**
11916
+ * Get detailed metadata for a hosted image
11917
+ * @param imageId The ID of the image (UUID or custom ID)
11918
+ * @returns Image metadata, or null if not found
11919
+ */
11920
+ details(imageId: string): Promise<ImageMetadata | null>;
11921
+ /**
11922
+ * Get the raw image data for a hosted image
11923
+ * @param imageId The ID of the image (UUID or custom ID)
11924
+ * @returns ReadableStream of image bytes, or null if not found
11925
+ */
11926
+ image(imageId: string): Promise<ReadableStream<Uint8Array> | null>;
11927
+ /**
11928
+ * Upload a new hosted image
11929
+ * @param image The image file to upload
11930
+ * @param options Upload configuration
11931
+ * @returns Metadata for the uploaded image
11932
+ * @throws {@link ImagesError} if upload fails
11933
+ */
11934
+ upload(
11935
+ image: ReadableStream<Uint8Array> | ArrayBuffer,
11936
+ options?: ImageUploadOptions,
11937
+ ): Promise<ImageMetadata>;
11938
+ /**
11939
+ * Update hosted image metadata
11940
+ * @param imageId The ID of the image
11941
+ * @param options Properties to update
11942
+ * @returns Updated image metadata
11943
+ * @throws {@link ImagesError} if update fails
11944
+ */
11945
+ update(imageId: string, options: ImageUpdateOptions): Promise<ImageMetadata>;
11946
+ /**
11947
+ * Delete a hosted image
11948
+ * @param imageId The ID of the image
11949
+ * @returns True if deleted, false if not found
11950
+ */
11951
+ delete(imageId: string): Promise<boolean>;
11952
+ /**
11953
+ * List hosted images with pagination
11954
+ * @param options List configuration
11955
+ * @returns List of images with pagination info
11956
+ * @throws {@link ImagesError} if list fails
11957
+ */
11958
+ list(options?: ImageListOptions): Promise<ImageList>;
11959
+ }
10971
11960
  interface ImagesBinding {
10972
11961
  /**
10973
11962
  * Get image metadata (type, width and height)
@@ -10987,6 +11976,10 @@ interface ImagesBinding {
10987
11976
  stream: ReadableStream<Uint8Array>,
10988
11977
  options?: ImageInputOptions,
10989
11978
  ): ImageTransformer;
11979
+ /**
11980
+ * Access hosted images CRUD operations
11981
+ */
11982
+ readonly hosted: HostedImagesBinding;
10990
11983
  }
10991
11984
  interface ImageTransformer {
10992
11985
  /**
@@ -11057,8 +12050,14 @@ interface MediaTransformer {
11057
12050
  * @returns A generator for producing the transformed media output
11058
12051
  */
11059
12052
  transform(
11060
- transform: MediaTransformationInputOptions,
12053
+ transform?: MediaTransformationInputOptions,
11061
12054
  ): MediaTransformationGenerator;
12055
+ /**
12056
+ * Generates the final media output with specified options.
12057
+ * @param output - Configuration for the output format and parameters
12058
+ * @returns The final transformation result containing the transformed media
12059
+ */
12060
+ output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
11062
12061
  }
11063
12062
  /**
11064
12063
  * Generator for producing media transformation results.
@@ -11070,7 +12069,7 @@ interface MediaTransformationGenerator {
11070
12069
  * @param output - Configuration for the output format and parameters
11071
12070
  * @returns The final transformation result containing the transformed media
11072
12071
  */
11073
- output(output: MediaTransformationOutputOptions): MediaTransformationResult;
12072
+ output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
11074
12073
  }
11075
12074
  /**
11076
12075
  * Result of a media transformation operation.
@@ -11079,19 +12078,19 @@ interface MediaTransformationGenerator {
11079
12078
  interface MediaTransformationResult {
11080
12079
  /**
11081
12080
  * Returns the transformed media as a readable stream of bytes.
11082
- * @returns A stream containing the transformed media data
12081
+ * @returns A promise containing a readable stream with the transformed media
11083
12082
  */
11084
- media(): ReadableStream<Uint8Array>;
12083
+ media(): Promise<ReadableStream<Uint8Array>>;
11085
12084
  /**
11086
12085
  * Returns the transformed media as an HTTP response object.
11087
- * @returns The transformed media as a Response, ready to store in cache or return to users
12086
+ * @returns The transformed media as a Promise<Response>, ready to store in cache or return to users
11088
12087
  */
11089
- response(): Response;
12088
+ response(): Promise<Response>;
11090
12089
  /**
11091
12090
  * Returns the MIME type of the transformed media.
11092
- * @returns The content type string (e.g., 'image/jpeg', 'video/mp4')
12091
+ * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4')
11093
12092
  */
11094
- contentType(): string;
12093
+ contentType(): Promise<string>;
11095
12094
  }
11096
12095
  /**
11097
12096
  * Configuration options for transforming media input.
@@ -11517,6 +12516,7 @@ declare namespace CloudflareWorkersModule {
11517
12516
  constructor(ctx: ExecutionContext, env: Env);
11518
12517
  email?(message: ForwardableEmailMessage): void | Promise<void>;
11519
12518
  fetch?(request: Request): Response | Promise<Response>;
12519
+ connect?(socket: Socket): void | Promise<void>;
11520
12520
  queue?(batch: MessageBatch<unknown>): void | Promise<void>;
11521
12521
  scheduled?(controller: ScheduledController): void | Promise<void>;
11522
12522
  tail?(events: TraceItem[]): void | Promise<void>;
@@ -11537,6 +12537,7 @@ declare namespace CloudflareWorkersModule {
11537
12537
  constructor(ctx: DurableObjectState, env: Env);
11538
12538
  alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
11539
12539
  fetch?(request: Request): Response | Promise<Response>;
12540
+ connect?(socket: Socket): void | Promise<void>;
11540
12541
  webSocketMessage?(
11541
12542
  ws: WebSocket,
11542
12543
  message: string | ArrayBuffer,
@@ -11582,15 +12583,18 @@ declare namespace CloudflareWorkersModule {
11582
12583
  timestamp: Date;
11583
12584
  type: string;
11584
12585
  };
12586
+ export type WorkflowStepContext = {
12587
+ attempt: number;
12588
+ };
11585
12589
  export abstract class WorkflowStep {
11586
12590
  do<T extends Rpc.Serializable<T>>(
11587
12591
  name: string,
11588
- callback: () => Promise<T>,
12592
+ callback: (ctx: WorkflowStepContext) => Promise<T>,
11589
12593
  ): Promise<T>;
11590
12594
  do<T extends Rpc.Serializable<T>>(
11591
12595
  name: string,
11592
12596
  config: WorkflowStepConfig,
11593
- callback: () => Promise<T>,
12597
+ callback: (ctx: WorkflowStepContext) => Promise<T>,
11594
12598
  ): Promise<T>;
11595
12599
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
11596
12600
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
@@ -11602,6 +12606,16 @@ declare namespace CloudflareWorkersModule {
11602
12606
  },
11603
12607
  ): Promise<WorkflowStepEvent<T>>;
11604
12608
  }
12609
+ export type WorkflowInstanceStatus =
12610
+ | "queued"
12611
+ | "running"
12612
+ | "paused"
12613
+ | "errored"
12614
+ | "terminated"
12615
+ | "complete"
12616
+ | "waiting"
12617
+ | "waitingForPause"
12618
+ | "unknown";
11605
12619
  export abstract class WorkflowEntrypoint<
11606
12620
  Env = unknown,
11607
12621
  T extends Rpc.Serializable<T> | unknown = unknown,
@@ -11645,12 +12659,763 @@ declare module "cloudflare:sockets" {
11645
12659
  ): Socket;
11646
12660
  export { _connect as connect };
11647
12661
  }
12662
+ /**
12663
+ * Binding entrypoint for Cloudflare Stream.
12664
+ *
12665
+ * Usage:
12666
+ * - Binding-level operations:
12667
+ * `await env.STREAM.videos.upload`
12668
+ * `await env.STREAM.videos.createDirectUpload`
12669
+ * `await env.STREAM.videos.*`
12670
+ * `await env.STREAM.watermarks.*`
12671
+ * - Per-video operations:
12672
+ * `await env.STREAM.video(id).downloads.*`
12673
+ * `await env.STREAM.video(id).captions.*`
12674
+ *
12675
+ * Example usage:
12676
+ * ```ts
12677
+ * await env.STREAM.video(id).downloads.generate();
12678
+ *
12679
+ * const video = env.STREAM.video(id)
12680
+ * const captions = video.captions.list();
12681
+ * const videoDetails = video.details()
12682
+ * ```
12683
+ */
12684
+ interface StreamBinding {
12685
+ /**
12686
+ * Returns a handle scoped to a single video for per-video operations.
12687
+ * @param id The unique identifier for the video.
12688
+ * @returns A handle for per-video operations.
12689
+ */
12690
+ video(id: string): StreamVideoHandle;
12691
+ /**
12692
+ * Uploads a new video from a provided URL.
12693
+ * @param url The URL to upload from.
12694
+ * @param params Optional upload parameters.
12695
+ * @returns The uploaded video details.
12696
+ * @throws {BadRequestError} if the upload parameter is invalid or the URL is invalid
12697
+ * @throws {QuotaReachedError} if the account storage capacity is exceeded
12698
+ * @throws {MaxFileSizeError} if the file size is too large
12699
+ * @throws {RateLimitedError} if the server received too many requests
12700
+ * @throws {AlreadyUploadedError} if a video was already uploaded to this URL
12701
+ * @throws {InternalError} if an unexpected error occurs
12702
+ */
12703
+ upload(url: string, params?: StreamUrlUploadParams): Promise<StreamVideo>;
12704
+ /**
12705
+ * Creates a direct upload that allows video uploads without an API key.
12706
+ * @param params Parameters for the direct upload
12707
+ * @returns The direct upload details.
12708
+ * @throws {BadRequestError} if the parameters are invalid
12709
+ * @throws {RateLimitedError} if the server received too many requests
12710
+ * @throws {InternalError} if an unexpected error occurs
12711
+ */
12712
+ createDirectUpload(
12713
+ params: StreamDirectUploadCreateParams,
12714
+ ): Promise<StreamDirectUpload>;
12715
+ videos: StreamVideos;
12716
+ watermarks: StreamWatermarks;
12717
+ }
12718
+ /**
12719
+ * Handle for operations scoped to a single Stream video.
12720
+ */
12721
+ interface StreamVideoHandle {
12722
+ /**
12723
+ * The unique identifier for the video.
12724
+ */
12725
+ id: string;
12726
+ /**
12727
+ * Get a full videos details
12728
+ * @returns The full video details.
12729
+ * @throws {NotFoundError} if the video is not found
12730
+ * @throws {InternalError} if an unexpected error occurs
12731
+ */
12732
+ details(): Promise<StreamVideo>;
12733
+ /**
12734
+ * Update details for a single video.
12735
+ * @param params The fields to update for the video.
12736
+ * @returns The updated video details.
12737
+ * @throws {NotFoundError} if the video is not found
12738
+ * @throws {BadRequestError} if the parameters are invalid
12739
+ * @throws {InternalError} if an unexpected error occurs
12740
+ */
12741
+ update(params: StreamUpdateVideoParams): Promise<StreamVideo>;
12742
+ /**
12743
+ * Deletes a video and its copies from Cloudflare Stream.
12744
+ * @returns A promise that resolves when deletion completes.
12745
+ * @throws {NotFoundError} if the video is not found
12746
+ * @throws {InternalError} if an unexpected error occurs
12747
+ */
12748
+ delete(): Promise<void>;
12749
+ /**
12750
+ * Creates a signed URL token for a video.
12751
+ * @returns The signed token that was created.
12752
+ * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
12753
+ */
12754
+ generateToken(): Promise<string>;
12755
+ downloads: StreamScopedDownloads;
12756
+ captions: StreamScopedCaptions;
12757
+ }
12758
+ interface StreamVideo {
12759
+ /**
12760
+ * The unique identifier for the video.
12761
+ */
12762
+ id: string;
12763
+ /**
12764
+ * A user-defined identifier for the media creator.
12765
+ */
12766
+ creator: string | null;
12767
+ /**
12768
+ * The thumbnail URL for the video.
12769
+ */
12770
+ thumbnail: string;
12771
+ /**
12772
+ * The thumbnail timestamp percentage.
12773
+ */
12774
+ thumbnailTimestampPct: number;
12775
+ /**
12776
+ * Indicates whether the video is ready to stream.
12777
+ */
12778
+ readyToStream: boolean;
12779
+ /**
12780
+ * The date and time the video became ready to stream.
12781
+ */
12782
+ readyToStreamAt: string | null;
12783
+ /**
12784
+ * Processing status information.
12785
+ */
12786
+ status: StreamVideoStatus;
12787
+ /**
12788
+ * A user modifiable key-value store.
12789
+ */
12790
+ meta: Record<string, string>;
12791
+ /**
12792
+ * The date and time the video was created.
12793
+ */
12794
+ created: string;
12795
+ /**
12796
+ * The date and time the video was last modified.
12797
+ */
12798
+ modified: string;
12799
+ /**
12800
+ * The date and time at which the video will be deleted.
12801
+ */
12802
+ scheduledDeletion: string | null;
12803
+ /**
12804
+ * The size of the video in bytes.
12805
+ */
12806
+ size: number;
12807
+ /**
12808
+ * The preview URL for the video.
12809
+ */
12810
+ preview?: string;
12811
+ /**
12812
+ * Origins allowed to display the video.
12813
+ */
12814
+ allowedOrigins: Array<string>;
12815
+ /**
12816
+ * Indicates whether signed URLs are required.
12817
+ */
12818
+ requireSignedURLs: boolean | null;
12819
+ /**
12820
+ * The date and time the video was uploaded.
12821
+ */
12822
+ uploaded: string | null;
12823
+ /**
12824
+ * The date and time when the upload URL expires.
12825
+ */
12826
+ uploadExpiry: string | null;
12827
+ /**
12828
+ * The maximum size in bytes for direct uploads.
12829
+ */
12830
+ maxSizeBytes: number | null;
12831
+ /**
12832
+ * The maximum duration in seconds for direct uploads.
12833
+ */
12834
+ maxDurationSeconds: number | null;
12835
+ /**
12836
+ * The video duration in seconds. -1 indicates unknown.
12837
+ */
12838
+ duration: number;
12839
+ /**
12840
+ * Input metadata for the original upload.
12841
+ */
12842
+ input: StreamVideoInput;
12843
+ /**
12844
+ * Playback URLs for the video.
12845
+ */
12846
+ hlsPlaybackUrl: string;
12847
+ dashPlaybackUrl: string;
12848
+ /**
12849
+ * The watermark applied to the video, if any.
12850
+ */
12851
+ watermark: StreamWatermark | null;
12852
+ /**
12853
+ * The live input id associated with the video, if any.
12854
+ */
12855
+ liveInputId?: string | null;
12856
+ /**
12857
+ * The source video id if this is a clip.
12858
+ */
12859
+ clippedFromId: string | null;
12860
+ /**
12861
+ * Public details associated with the video.
12862
+ */
12863
+ publicDetails: StreamPublicDetails | null;
12864
+ }
12865
+ type StreamVideoStatus = {
12866
+ /**
12867
+ * The current processing state.
12868
+ */
12869
+ state: string;
12870
+ /**
12871
+ * The current processing step.
12872
+ */
12873
+ step?: string;
12874
+ /**
12875
+ * The percent complete as a string.
12876
+ */
12877
+ pctComplete?: string;
12878
+ /**
12879
+ * An error reason code, if applicable.
12880
+ */
12881
+ errorReasonCode: string;
12882
+ /**
12883
+ * An error reason text, if applicable.
12884
+ */
12885
+ errorReasonText: string;
12886
+ };
12887
+ type StreamVideoInput = {
12888
+ /**
12889
+ * The input width in pixels.
12890
+ */
12891
+ width: number;
12892
+ /**
12893
+ * The input height in pixels.
12894
+ */
12895
+ height: number;
12896
+ };
12897
+ type StreamPublicDetails = {
12898
+ /**
12899
+ * The public title for the video.
12900
+ */
12901
+ title: string | null;
12902
+ /**
12903
+ * The public share link.
12904
+ */
12905
+ share_link: string | null;
12906
+ /**
12907
+ * The public channel link.
12908
+ */
12909
+ channel_link: string | null;
12910
+ /**
12911
+ * The public logo URL.
12912
+ */
12913
+ logo: string | null;
12914
+ };
12915
+ type StreamDirectUpload = {
12916
+ /**
12917
+ * The URL an unauthenticated upload can use for a single multipart request.
12918
+ */
12919
+ uploadURL: string;
12920
+ /**
12921
+ * A Cloudflare-generated unique identifier for a media item.
12922
+ */
12923
+ id: string;
12924
+ /**
12925
+ * The watermark profile applied to the upload.
12926
+ */
12927
+ watermark: StreamWatermark | null;
12928
+ /**
12929
+ * The scheduled deletion time, if any.
12930
+ */
12931
+ scheduledDeletion: string | null;
12932
+ };
12933
+ type StreamDirectUploadCreateParams = {
12934
+ /**
12935
+ * The maximum duration in seconds for a video upload.
12936
+ */
12937
+ maxDurationSeconds: number;
12938
+ /**
12939
+ * The date and time after upload when videos will not be accepted.
12940
+ */
12941
+ expiry?: string;
12942
+ /**
12943
+ * A user-defined identifier for the media creator.
12944
+ */
12945
+ creator?: string;
12946
+ /**
12947
+ * A user modifiable key-value store used to reference other systems of record for
12948
+ * managing videos.
12949
+ */
12950
+ meta?: Record<string, string>;
12951
+ /**
12952
+ * Lists the origins allowed to display the video.
12953
+ */
12954
+ allowedOrigins?: Array<string>;
12955
+ /**
12956
+ * Indicates whether the video can be accessed using the id. When set to `true`,
12957
+ * a signed token must be generated with a signing key to view the video.
12958
+ */
12959
+ requireSignedURLs?: boolean;
12960
+ /**
12961
+ * The thumbnail timestamp percentage.
12962
+ */
12963
+ thumbnailTimestampPct?: number;
12964
+ /**
12965
+ * The date and time at which the video will be deleted. Include `null` to remove
12966
+ * a scheduled deletion.
12967
+ */
12968
+ scheduledDeletion?: string | null;
12969
+ /**
12970
+ * The watermark profile to apply.
12971
+ */
12972
+ watermark?: StreamDirectUploadWatermark;
12973
+ };
12974
+ type StreamDirectUploadWatermark = {
12975
+ /**
12976
+ * The unique identifier for the watermark profile.
12977
+ */
12978
+ id: string;
12979
+ };
12980
+ type StreamUrlUploadParams = {
12981
+ /**
12982
+ * Lists the origins allowed to display the video. Enter allowed origin
12983
+ * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
12984
+ * video to be viewed on any origin.
12985
+ */
12986
+ allowedOrigins?: Array<string>;
12987
+ /**
12988
+ * A user-defined identifier for the media creator.
12989
+ */
12990
+ creator?: string;
12991
+ /**
12992
+ * A user modifiable key-value store used to reference other systems of
12993
+ * record for managing videos.
12994
+ */
12995
+ meta?: Record<string, string>;
12996
+ /**
12997
+ * Indicates whether the video can be a accessed using the id. When
12998
+ * set to `true`, a signed token must be generated with a signing key to view the
12999
+ * video.
13000
+ */
13001
+ requireSignedURLs?: boolean;
13002
+ /**
13003
+ * Indicates the date and time at which the video will be deleted. Omit
13004
+ * the field to indicate no change, or include with a `null` value to remove an
13005
+ * existing scheduled deletion. If specified, must be at least 30 days from upload
13006
+ * time.
13007
+ */
13008
+ scheduledDeletion?: string | null;
13009
+ /**
13010
+ * The timestamp for a thumbnail image calculated as a percentage value
13011
+ * of the video's duration. To convert from a second-wise timestamp to a
13012
+ * percentage, divide the desired timestamp by the total duration of the video. If
13013
+ * this value is not set, the default thumbnail image is taken from 0s of the
13014
+ * video.
13015
+ */
13016
+ thumbnailTimestampPct?: number;
13017
+ /**
13018
+ * The identifier for the watermark profile
13019
+ */
13020
+ watermarkId?: string;
13021
+ };
13022
+ interface StreamScopedCaptions {
13023
+ /**
13024
+ * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
13025
+ * One caption or subtitle file per language is allowed.
13026
+ * @param language The BCP 47 language tag for the caption or subtitle.
13027
+ * @param file The caption or subtitle file to upload.
13028
+ * @returns The created caption entry.
13029
+ * @throws {NotFoundError} if the video is not found
13030
+ * @throws {BadRequestError} if the language or file is invalid
13031
+ * @throws {MaxFileSizeError} if the file size is too large
13032
+ * @throws {InternalError} if an unexpected error occurs
13033
+ */
13034
+ upload(language: string, file: File): Promise<StreamCaption>;
13035
+ /**
13036
+ * Generate captions or subtitles for the provided language via AI.
13037
+ * @param language The BCP 47 language tag to generate.
13038
+ * @returns The generated caption entry.
13039
+ * @throws {NotFoundError} if the video is not found
13040
+ * @throws {BadRequestError} if the language is invalid
13041
+ * @throws {StreamError} if a generated caption already exists
13042
+ * @throws {StreamError} if the video duration is too long
13043
+ * @throws {StreamError} if the video is missing audio
13044
+ * @throws {StreamError} if the requested language is not supported
13045
+ * @throws {InternalError} if an unexpected error occurs
13046
+ */
13047
+ generate(language: string): Promise<StreamCaption>;
13048
+ /**
13049
+ * Lists the captions or subtitles.
13050
+ * Use the language parameter to filter by a specific language.
13051
+ * @param language The optional BCP 47 language tag to filter by.
13052
+ * @returns The list of captions or subtitles.
13053
+ * @throws {NotFoundError} if the video or caption is not found
13054
+ * @throws {InternalError} if an unexpected error occurs
13055
+ */
13056
+ list(language?: string): Promise<StreamCaption[]>;
13057
+ /**
13058
+ * Removes the captions or subtitles from a video.
13059
+ * @param language The BCP 47 language tag to remove.
13060
+ * @returns A promise that resolves when deletion completes.
13061
+ * @throws {NotFoundError} if the video or caption is not found
13062
+ * @throws {InternalError} if an unexpected error occurs
13063
+ */
13064
+ delete(language: string): Promise<void>;
13065
+ }
13066
+ interface StreamScopedDownloads {
13067
+ /**
13068
+ * Generates a download for a video when a video is ready to view. Available
13069
+ * types are `default` and `audio`. Defaults to `default` when omitted.
13070
+ * @param downloadType The download type to create.
13071
+ * @returns The current downloads for the video.
13072
+ * @throws {NotFoundError} if the video is not found
13073
+ * @throws {BadRequestError} if the download type is invalid
13074
+ * @throws {StreamError} if the video duration is too long to generate a download
13075
+ * @throws {StreamError} if the video is not ready to stream
13076
+ * @throws {InternalError} if an unexpected error occurs
13077
+ */
13078
+ generate(
13079
+ downloadType?: StreamDownloadType,
13080
+ ): Promise<StreamDownloadGetResponse>;
13081
+ /**
13082
+ * Lists the downloads created for a video.
13083
+ * @returns The current downloads for the video.
13084
+ * @throws {NotFoundError} if the video or downloads are not found
13085
+ * @throws {InternalError} if an unexpected error occurs
13086
+ */
13087
+ get(): Promise<StreamDownloadGetResponse>;
13088
+ /**
13089
+ * Delete the downloads for a video. Available types are `default` and `audio`.
13090
+ * Defaults to `default` when omitted.
13091
+ * @param downloadType The download type to delete.
13092
+ * @returns A promise that resolves when deletion completes.
13093
+ * @throws {NotFoundError} if the video or downloads are not found
13094
+ * @throws {InternalError} if an unexpected error occurs
13095
+ */
13096
+ delete(downloadType?: StreamDownloadType): Promise<void>;
13097
+ }
13098
+ interface StreamVideos {
13099
+ /**
13100
+ * Lists all videos in a users account.
13101
+ * @returns The list of videos.
13102
+ * @throws {BadRequestError} if the parameters are invalid
13103
+ * @throws {InternalError} if an unexpected error occurs
13104
+ */
13105
+ list(params?: StreamVideosListParams): Promise<StreamVideo[]>;
13106
+ }
13107
+ interface StreamWatermarks {
13108
+ /**
13109
+ * Generate a new watermark profile
13110
+ * @param file The image file to upload
13111
+ * @param params The watermark creation parameters.
13112
+ * @returns The created watermark profile.
13113
+ * @throws {BadRequestError} if the parameters are invalid
13114
+ * @throws {InvalidURLError} if the URL is invalid
13115
+ * @throws {MaxFileSizeError} if the file size is too large
13116
+ * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
13117
+ * @throws {InternalError} if an unexpected error occurs
13118
+ */
13119
+ generate(
13120
+ file: File,
13121
+ params: StreamWatermarkCreateParams,
13122
+ ): Promise<StreamWatermark>;
13123
+ /**
13124
+ * Generate a new watermark profile
13125
+ * @param url The image url to upload
13126
+ * @param params The watermark creation parameters.
13127
+ * @returns The created watermark profile.
13128
+ * @throws {BadRequestError} if the parameters are invalid
13129
+ * @throws {InvalidURLError} if the URL is invalid
13130
+ * @throws {MaxFileSizeError} if the file size is too large
13131
+ * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
13132
+ * @throws {InternalError} if an unexpected error occurs
13133
+ */
13134
+ generate(
13135
+ url: string,
13136
+ params: StreamWatermarkCreateParams,
13137
+ ): Promise<StreamWatermark>;
13138
+ /**
13139
+ * Lists all watermark profiles for an account.
13140
+ * @returns The list of watermark profiles.
13141
+ * @throws {InternalError} if an unexpected error occurs
13142
+ */
13143
+ list(): Promise<StreamWatermark[]>;
13144
+ /**
13145
+ * Retrieves details for a single watermark profile.
13146
+ * @param watermarkId The watermark profile identifier.
13147
+ * @returns The watermark profile details.
13148
+ * @throws {NotFoundError} if the watermark is not found
13149
+ * @throws {InternalError} if an unexpected error occurs
13150
+ */
13151
+ get(watermarkId: string): Promise<StreamWatermark>;
13152
+ /**
13153
+ * Deletes a watermark profile.
13154
+ * @param watermarkId The watermark profile identifier.
13155
+ * @returns A promise that resolves when deletion completes.
13156
+ * @throws {NotFoundError} if the watermark is not found
13157
+ * @throws {InternalError} if an unexpected error occurs
13158
+ */
13159
+ delete(watermarkId: string): Promise<void>;
13160
+ }
13161
+ type StreamUpdateVideoParams = {
13162
+ /**
13163
+ * Lists the origins allowed to display the video. Enter allowed origin
13164
+ * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
13165
+ * video to be viewed on any origin.
13166
+ */
13167
+ allowedOrigins?: Array<string>;
13168
+ /**
13169
+ * A user-defined identifier for the media creator.
13170
+ */
13171
+ creator?: string;
13172
+ /**
13173
+ * The maximum duration in seconds for a video upload. Can be set for a
13174
+ * video that is not yet uploaded to limit its duration. Uploads that exceed the
13175
+ * specified duration will fail during processing. A value of `-1` means the value
13176
+ * is unknown.
13177
+ */
13178
+ maxDurationSeconds?: number;
13179
+ /**
13180
+ * A user modifiable key-value store used to reference other systems of
13181
+ * record for managing videos.
13182
+ */
13183
+ meta?: Record<string, string>;
13184
+ /**
13185
+ * Indicates whether the video can be a accessed using the id. When
13186
+ * set to `true`, a signed token must be generated with a signing key to view the
13187
+ * video.
13188
+ */
13189
+ requireSignedURLs?: boolean;
13190
+ /**
13191
+ * Indicates the date and time at which the video will be deleted. Omit
13192
+ * the field to indicate no change, or include with a `null` value to remove an
13193
+ * existing scheduled deletion. If specified, must be at least 30 days from upload
13194
+ * time.
13195
+ */
13196
+ scheduledDeletion?: string | null;
13197
+ /**
13198
+ * The timestamp for a thumbnail image calculated as a percentage value
13199
+ * of the video's duration. To convert from a second-wise timestamp to a
13200
+ * percentage, divide the desired timestamp by the total duration of the video. If
13201
+ * this value is not set, the default thumbnail image is taken from 0s of the
13202
+ * video.
13203
+ */
13204
+ thumbnailTimestampPct?: number;
13205
+ };
13206
+ type StreamCaption = {
13207
+ /**
13208
+ * Whether the caption was generated via AI.
13209
+ */
13210
+ generated?: boolean;
13211
+ /**
13212
+ * The language label displayed in the native language to users.
13213
+ */
13214
+ label: string;
13215
+ /**
13216
+ * The language tag in BCP 47 format.
13217
+ */
13218
+ language: string;
13219
+ /**
13220
+ * The status of a generated caption.
13221
+ */
13222
+ status?: "ready" | "inprogress" | "error";
13223
+ };
13224
+ type StreamDownloadStatus = "ready" | "inprogress" | "error";
13225
+ type StreamDownloadType = "default" | "audio";
13226
+ type StreamDownload = {
13227
+ /**
13228
+ * Indicates the progress as a percentage between 0 and 100.
13229
+ */
13230
+ percentComplete: number;
13231
+ /**
13232
+ * The status of a generated download.
13233
+ */
13234
+ status: StreamDownloadStatus;
13235
+ /**
13236
+ * The URL to access the generated download.
13237
+ */
13238
+ url?: string;
13239
+ };
13240
+ /**
13241
+ * An object with download type keys. Each key is optional and only present if that
13242
+ * download type has been created.
13243
+ */
13244
+ type StreamDownloadGetResponse = {
13245
+ /**
13246
+ * The audio-only download. Only present if this download type has been created.
13247
+ */
13248
+ audio?: StreamDownload;
13249
+ /**
13250
+ * The default video download. Only present if this download type has been created.
13251
+ */
13252
+ default?: StreamDownload;
13253
+ };
13254
+ type StreamWatermarkPosition =
13255
+ | "upperRight"
13256
+ | "upperLeft"
13257
+ | "lowerLeft"
13258
+ | "lowerRight"
13259
+ | "center";
13260
+ type StreamWatermark = {
13261
+ /**
13262
+ * The unique identifier for a watermark profile.
13263
+ */
13264
+ id: string;
13265
+ /**
13266
+ * The size of the image in bytes.
13267
+ */
13268
+ size: number;
13269
+ /**
13270
+ * The height of the image in pixels.
13271
+ */
13272
+ height: number;
13273
+ /**
13274
+ * The width of the image in pixels.
13275
+ */
13276
+ width: number;
13277
+ /**
13278
+ * The date and a time a watermark profile was created.
13279
+ */
13280
+ created: string;
13281
+ /**
13282
+ * The source URL for a downloaded image. If the watermark profile was created via
13283
+ * direct upload, this field is null.
13284
+ */
13285
+ downloadedFrom: string | null;
13286
+ /**
13287
+ * A short description of the watermark profile.
13288
+ */
13289
+ name: string;
13290
+ /**
13291
+ * The translucency of the image. A value of `0.0` makes the image completely
13292
+ * transparent, and `1.0` makes the image completely opaque. Note that if the image
13293
+ * is already semi-transparent, setting this to `1.0` will not make the image
13294
+ * completely opaque.
13295
+ */
13296
+ opacity: number;
13297
+ /**
13298
+ * The whitespace between the adjacent edges (determined by position) of the video
13299
+ * and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded
13300
+ * video width or length, as determined by the algorithm.
13301
+ */
13302
+ padding: number;
13303
+ /**
13304
+ * The size of the image relative to the overall size of the video. This parameter
13305
+ * will adapt to horizontal and vertical videos automatically. `0.0` indicates no
13306
+ * scaling (use the size of the image as-is), and `1.0 `fills the entire video.
13307
+ */
13308
+ scale: number;
13309
+ /**
13310
+ * The location of the image. Valid positions are: `upperRight`, `upperLeft`,
13311
+ * `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the
13312
+ * `padding` parameter.
13313
+ */
13314
+ position: StreamWatermarkPosition;
13315
+ };
13316
+ type StreamWatermarkCreateParams = {
13317
+ /**
13318
+ * A short description of the watermark profile.
13319
+ */
13320
+ name?: string;
13321
+ /**
13322
+ * The translucency of the image. A value of `0.0` makes the image completely
13323
+ * transparent, and `1.0` makes the image completely opaque. Note that if the
13324
+ * image is already semi-transparent, setting this to `1.0` will not make the
13325
+ * image completely opaque.
13326
+ */
13327
+ opacity?: number;
13328
+ /**
13329
+ * The whitespace between the adjacent edges (determined by position) of the
13330
+ * video and the image. `0.0` indicates no padding, and `1.0` indicates a fully
13331
+ * padded video width or length, as determined by the algorithm.
13332
+ */
13333
+ padding?: number;
13334
+ /**
13335
+ * The size of the image relative to the overall size of the video. This
13336
+ * parameter will adapt to horizontal and vertical videos automatically. `0.0`
13337
+ * indicates no scaling (use the size of the image as-is), and `1.0 `fills the
13338
+ * entire video.
13339
+ */
13340
+ scale?: number;
13341
+ /**
13342
+ * The location of the image.
13343
+ */
13344
+ position?: StreamWatermarkPosition;
13345
+ };
13346
+ type StreamVideosListParams = {
13347
+ /**
13348
+ * The maximum number of videos to return.
13349
+ */
13350
+ limit?: number;
13351
+ /**
13352
+ * Return videos created before this timestamp.
13353
+ * (RFC3339/RFC3339Nano)
13354
+ */
13355
+ before?: string;
13356
+ /**
13357
+ * Comparison operator for the `before` field.
13358
+ * @default 'lt'
13359
+ */
13360
+ beforeComp?: StreamPaginationComparison;
13361
+ /**
13362
+ * Return videos created after this timestamp.
13363
+ * (RFC3339/RFC3339Nano)
13364
+ */
13365
+ after?: string;
13366
+ /**
13367
+ * Comparison operator for the `after` field.
13368
+ * @default 'gte'
13369
+ */
13370
+ afterComp?: StreamPaginationComparison;
13371
+ };
13372
+ type StreamPaginationComparison = "eq" | "gt" | "gte" | "lt" | "lte";
13373
+ /**
13374
+ * Error object for Stream binding operations.
13375
+ */
13376
+ interface StreamError extends Error {
13377
+ readonly code: number;
13378
+ readonly statusCode: number;
13379
+ readonly message: string;
13380
+ readonly stack?: string;
13381
+ }
13382
+ interface InternalError extends StreamError {
13383
+ name: "InternalError";
13384
+ }
13385
+ interface BadRequestError extends StreamError {
13386
+ name: "BadRequestError";
13387
+ }
13388
+ interface NotFoundError extends StreamError {
13389
+ name: "NotFoundError";
13390
+ }
13391
+ interface ForbiddenError extends StreamError {
13392
+ name: "ForbiddenError";
13393
+ }
13394
+ interface RateLimitedError extends StreamError {
13395
+ name: "RateLimitedError";
13396
+ }
13397
+ interface QuotaReachedError extends StreamError {
13398
+ name: "QuotaReachedError";
13399
+ }
13400
+ interface MaxFileSizeError extends StreamError {
13401
+ name: "MaxFileSizeError";
13402
+ }
13403
+ interface InvalidURLError extends StreamError {
13404
+ name: "InvalidURLError";
13405
+ }
13406
+ interface AlreadyUploadedError extends StreamError {
13407
+ name: "AlreadyUploadedError";
13408
+ }
13409
+ interface TooManyWatermarksError extends StreamError {
13410
+ name: "TooManyWatermarksError";
13411
+ }
11648
13412
  type MarkdownDocument = {
11649
13413
  name: string;
11650
13414
  blob: Blob;
11651
13415
  };
11652
13416
  type ConversionResponse =
11653
13417
  | {
13418
+ id: string;
11654
13419
  name: string;
11655
13420
  mimeType: string;
11656
13421
  format: "markdown";
@@ -11658,6 +13423,7 @@ type ConversionResponse =
11658
13423
  data: string;
11659
13424
  }
11660
13425
  | {
13426
+ id: string;
11661
13427
  name: string;
11662
13428
  mimeType: string;
11663
13429
  format: "error";
@@ -11675,6 +13441,8 @@ type ConversionOptions = {
11675
13441
  images?: EmbeddedImageConversionOptions & {
11676
13442
  convertOGImage?: boolean;
11677
13443
  };
13444
+ hostname?: string;
13445
+ cssSelector?: string;
11678
13446
  };
11679
13447
  docx?: {
11680
13448
  images?: EmbeddedImageConversionOptions;
@@ -11769,6 +13537,9 @@ declare namespace TailStream {
11769
13537
  readonly type: "fetch";
11770
13538
  readonly statusCode: number;
11771
13539
  }
13540
+ interface ConnectEventInfo {
13541
+ readonly type: "connect";
13542
+ }
11772
13543
  type EventOutcome =
11773
13544
  | "ok"
11774
13545
  | "canceled"
@@ -11799,6 +13570,7 @@ declare namespace TailStream {
11799
13570
  readonly scriptVersion?: ScriptVersion;
11800
13571
  readonly info:
11801
13572
  | FetchEventInfo
13573
+ | ConnectEventInfo
11802
13574
  | JsRpcEventInfo
11803
13575
  | ScheduledEventInfo
11804
13576
  | AlarmEventInfo