@workers-community/workers-types 4.20260317.1 → 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 +639 -56
  2. package/index.ts +641 -56
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -486,6 +486,11 @@ type ExportedHandlerFetchHandler<
486
486
  env: Env,
487
487
  ctx: ExecutionContext<Props>,
488
488
  ) => Response | Promise<Response>;
489
+ type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
490
+ socket: Socket,
491
+ env: Env,
492
+ ctx: ExecutionContext<Props>,
493
+ ) => void | Promise<void>;
489
494
  type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
490
495
  events: TraceItem[],
491
496
  env: Env,
@@ -527,6 +532,7 @@ interface ExportedHandler<
527
532
  Props = unknown,
528
533
  > {
529
534
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
535
+ connect?: ExportedHandlerConnectHandler<Env, Props>;
530
536
  tail?: ExportedHandlerTailHandler<Env, Props>;
531
537
  trace?: ExportedHandlerTraceHandler<Env, Props>;
532
538
  tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
@@ -546,12 +552,14 @@ declare abstract class Navigator {
546
552
  interface AlarmInvocationInfo {
547
553
  readonly isRetry: boolean;
548
554
  readonly retryCount: number;
555
+ readonly scheduledTime: number;
549
556
  }
550
557
  interface Cloudflare {
551
558
  readonly compatibilityFlags: Record<string, boolean>;
552
559
  }
553
560
  interface DurableObject {
554
561
  fetch(request: Request): Response | Promise<Response>;
562
+ connect?(socket: Socket): void | Promise<void>;
555
563
  alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
556
564
  webSocketMessage?(
557
565
  ws: WebSocket,
@@ -569,7 +577,7 @@ type DurableObjectStub<
569
577
  T extends Rpc.DurableObjectBranded | undefined = undefined,
570
578
  > = Fetcher<
571
579
  T,
572
- "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
580
+ "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
573
581
  > & {
574
582
  readonly id: DurableObjectId;
575
583
  readonly name?: string;
@@ -578,6 +586,7 @@ interface DurableObjectId {
578
586
  toString(): string;
579
587
  equals(other: DurableObjectId): boolean;
580
588
  readonly name?: string;
589
+ readonly jurisdiction?: string;
581
590
  }
582
591
  declare abstract class DurableObjectNamespace<
583
592
  T extends Rpc.DurableObjectBranded | undefined = undefined,
@@ -3108,6 +3117,7 @@ interface TraceItem {
3108
3117
  | (
3109
3118
  | TraceItemFetchEventInfo
3110
3119
  | TraceItemJsRpcEventInfo
3120
+ | TraceItemConnectEventInfo
3111
3121
  | TraceItemScheduledEventInfo
3112
3122
  | TraceItemAlarmEventInfo
3113
3123
  | TraceItemQueueEventInfo
@@ -3126,6 +3136,7 @@ interface TraceItem {
3126
3136
  readonly scriptVersion?: ScriptVersion;
3127
3137
  readonly dispatchNamespace?: string;
3128
3138
  readonly scriptTags?: string[];
3139
+ readonly tailAttributes?: Record<string, boolean | number | string>;
3129
3140
  readonly durableObjectId?: string;
3130
3141
  readonly outcome: string;
3131
3142
  readonly executionModel: string;
@@ -3136,6 +3147,7 @@ interface TraceItem {
3136
3147
  interface TraceItemAlarmEventInfo {
3137
3148
  readonly scheduledTime: Date;
3138
3149
  }
3150
+ interface TraceItemConnectEventInfo {}
3139
3151
  interface TraceItemCustomEventInfo {}
3140
3152
  interface TraceItemScheduledEventInfo {
3141
3153
  readonly scheduledTime: number;
@@ -3756,7 +3768,7 @@ interface ContainerStartupOptions {
3756
3768
  entrypoint?: string[];
3757
3769
  enableInternet: boolean;
3758
3770
  env?: Record<string, string>;
3759
- hardTimeout?: number | bigint;
3771
+ labels?: Record<string, string>;
3760
3772
  }
3761
3773
  /**
3762
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.
@@ -4325,6 +4337,400 @@ declare abstract class BaseAiTranslation {
4325
4337
  inputs: AiTranslationInput;
4326
4338
  postProcessedOutputs: AiTranslationOutput;
4327
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
+ };
4328
4734
  /**
4329
4735
  * Workers AI support for OpenAI's Responses API
4330
4736
  * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
@@ -4746,6 +5152,12 @@ type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
4746
5152
  type StreamOptions = {
4747
5153
  include_obfuscation?: boolean;
4748
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>);
4749
5161
  type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
4750
5162
  | {
4751
5163
  text: string | string[];
@@ -5038,10 +5450,12 @@ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
5038
5450
  postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
5039
5451
  }
5040
5452
  interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
5041
- /**
5042
- * Base64 encoded value of the audio data.
5043
- */
5044
- audio: string;
5453
+ audio:
5454
+ | string
5455
+ | {
5456
+ body?: object;
5457
+ contentType?: string;
5458
+ };
5045
5459
  /**
5046
5460
  * Supported tasks are 'translate' or 'transcribe'.
5047
5461
  */
@@ -5059,9 +5473,33 @@ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
5059
5473
  */
5060
5474
  initial_prompt?: string;
5061
5475
  /**
5062
- * 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.
5063
5477
  */
5064
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;
5065
5503
  }
5066
5504
  interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
5067
5505
  transcription_info?: {
@@ -5208,11 +5646,11 @@ interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
5208
5646
  truncate_inputs?: boolean;
5209
5647
  }
5210
5648
  type Ai_Cf_Baai_Bge_M3_Output =
5211
- | Ai_Cf_Baai_Bge_M3_Ouput_Query
5649
+ | Ai_Cf_Baai_Bge_M3_Output_Query
5212
5650
  | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
5213
- | Ai_Cf_Baai_Bge_M3_Ouput_Embedding
5651
+ | Ai_Cf_Baai_Bge_M3_Output_Embedding
5214
5652
  | Ai_Cf_Baai_Bge_M3_AsyncResponse;
5215
- interface Ai_Cf_Baai_Bge_M3_Ouput_Query {
5653
+ interface Ai_Cf_Baai_Bge_M3_Output_Query {
5216
5654
  response?: {
5217
5655
  /**
5218
5656
  * Index of the context in the request
@@ -5232,7 +5670,7 @@ interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
5232
5670
  */
5233
5671
  pooling?: "mean" | "cls";
5234
5672
  }
5235
- interface Ai_Cf_Baai_Bge_M3_Ouput_Embedding {
5673
+ interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
5236
5674
  shape?: number[];
5237
5675
  /**
5238
5676
  * Embeddings of the requested text values
@@ -5337,7 +5775,7 @@ interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
5337
5775
  */
5338
5776
  role?: string;
5339
5777
  /**
5340
- * 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
5341
5779
  */
5342
5780
  tool_call_id?: string;
5343
5781
  content?:
@@ -5592,10 +6030,18 @@ interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
5592
6030
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5593
6031
  */
5594
6032
  role: string;
5595
- /**
5596
- * The content of the message as a string.
5597
- */
5598
- 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
+ }[];
5599
6045
  }[];
5600
6046
  functions?: {
5601
6047
  name: string;
@@ -6251,7 +6697,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
6251
6697
  */
6252
6698
  role?: string;
6253
6699
  /**
6254
- * 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
6255
6701
  */
6256
6702
  tool_call_id?: string;
6257
6703
  content?:
@@ -6378,7 +6824,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
6378
6824
  }
6379
6825
  )[];
6380
6826
  /**
6381
- * JSON schema that should be fulfilled for the response.
6827
+ * JSON schema that should be fufilled for the response.
6382
6828
  */
6383
6829
  guided_json?: object;
6384
6830
  /**
@@ -6652,7 +7098,7 @@ interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
6652
7098
  }
6653
7099
  )[];
6654
7100
  /**
6655
- * JSON schema that should be fulfilled for the response.
7101
+ * JSON schema that should be fufilled for the response.
6656
7102
  */
6657
7103
  guided_json?: object;
6658
7104
  /**
@@ -6745,7 +7191,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
6745
7191
  */
6746
7192
  prompt: string;
6747
7193
  /**
6748
- * JSON schema that should be fulfilled for the response.
7194
+ * JSON schema that should be fufilled for the response.
6749
7195
  */
6750
7196
  guided_json?: object;
6751
7197
  /**
@@ -6909,7 +7355,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
6909
7355
  }
6910
7356
  )[];
6911
7357
  /**
6912
- * JSON schema that should be fulfilled for the response.
7358
+ * JSON schema that should be fufilled for the response.
6913
7359
  */
6914
7360
  guided_json?: object;
6915
7361
  /**
@@ -7190,7 +7636,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
7190
7636
  )[];
7191
7637
  response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7192
7638
  /**
7193
- * JSON schema that should be fulfilled for the response.
7639
+ * JSON schema that should be fufilled for the response.
7194
7640
  */
7195
7641
  guided_json?: object;
7196
7642
  /**
@@ -7429,7 +7875,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
7429
7875
  )[];
7430
7876
  response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7431
7877
  /**
7432
- * JSON schema that should be fulfilled for the response.
7878
+ * JSON schema that should be fufilled for the response.
7433
7879
  */
7434
7880
  guided_json?: object;
7435
7881
  /**
@@ -7594,10 +8040,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
7594
8040
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7595
8041
  */
7596
8042
  role: string;
7597
- /**
7598
- * The content of the message as a string.
7599
- */
7600
- 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
+ }[];
7601
8055
  }[];
7602
8056
  functions?: {
7603
8057
  name: string;
@@ -7809,10 +8263,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
7809
8263
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7810
8264
  */
7811
8265
  role: string;
7812
- /**
7813
- * The content of the message as a string.
7814
- */
7815
- 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
+ }[];
7816
8278
  }[];
7817
8279
  functions?: {
7818
8280
  name: string;
@@ -8380,12 +8842,12 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
8380
8842
  postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
8381
8843
  }
8382
8844
  declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
8383
- inputs: ResponsesInput;
8384
- postProcessedOutputs: ResponsesOutput;
8845
+ inputs: XOR<ResponsesInput, ChatCompletionsInput>;
8846
+ postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
8385
8847
  }
8386
8848
  declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
8387
- inputs: ResponsesInput;
8388
- postProcessedOutputs: ResponsesOutput;
8849
+ inputs: XOR<ResponsesInput, ChatCompletionsInput>;
8850
+ postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
8389
8851
  }
8390
8852
  interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
8391
8853
  /**
@@ -8517,7 +8979,7 @@ interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
8517
8979
  */
8518
8980
  text: string | string[];
8519
8981
  /**
8520
- * Target language to translate to
8982
+ * Target langauge to translate to
8521
8983
  */
8522
8984
  target_language:
8523
8985
  | "asm_Beng"
@@ -8633,10 +9095,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
8633
9095
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8634
9096
  */
8635
9097
  role: string;
8636
- /**
8637
- * The content of the message as a string.
8638
- */
8639
- 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
+ }[];
8640
9110
  }[];
8641
9111
  functions?: {
8642
9112
  name: string;
@@ -8848,10 +9318,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
8848
9318
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8849
9319
  */
8850
9320
  role: string;
8851
- /**
8852
- * The content of the message as a string.
8853
- */
8854
- 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
+ }[];
8855
9333
  }[];
8856
9334
  functions?: {
8857
9335
  name: string;
@@ -9406,6 +9884,66 @@ declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
9406
9884
  inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
9407
9885
  postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
9408
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
+ }
9409
9947
  interface AiModels {
9410
9948
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
9411
9949
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -9424,7 +9962,6 @@ interface AiModels {
9424
9962
  "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
9425
9963
  "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
9426
9964
  "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
9427
- "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
9428
9965
  "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
9429
9966
  "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
9430
9967
  "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
@@ -9491,6 +10028,12 @@ interface AiModels {
9491
10028
  "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
9492
10029
  "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
9493
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;
9494
10037
  }
9495
10038
  type AiOptions = {
9496
10039
  /**
@@ -9542,6 +10085,16 @@ type AiModelsSearchObject = {
9542
10085
  value: string;
9543
10086
  }[];
9544
10087
  };
10088
+ type ChatCompletionsBase = XOR<
10089
+ ChatCompletionsPromptInput,
10090
+ ChatCompletionsMessagesInput
10091
+ >;
10092
+ type ChatCompletionsInput = XOR<
10093
+ ChatCompletionsBase,
10094
+ {
10095
+ requests: ChatCompletionsBase[];
10096
+ }
10097
+ >;
9545
10098
  interface InferenceUpstreamError extends Error {}
9546
10099
  interface AiInternalError extends Error {}
9547
10100
  type AiModelListType = Record<string, any>;
@@ -10016,6 +10569,41 @@ interface RequestInitCfProperties extends Record<string, unknown> {
10016
10569
  * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
10017
10570
  */
10018
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;
10019
10607
  scrapeShield?: boolean;
10020
10608
  apps?: boolean;
10021
10609
  image?: RequestInitCfPropertiesImage;
@@ -11928,6 +12516,7 @@ declare namespace CloudflareWorkersModule {
11928
12516
  constructor(ctx: ExecutionContext, env: Env);
11929
12517
  email?(message: ForwardableEmailMessage): void | Promise<void>;
11930
12518
  fetch?(request: Request): Response | Promise<Response>;
12519
+ connect?(socket: Socket): void | Promise<void>;
11931
12520
  queue?(batch: MessageBatch<unknown>): void | Promise<void>;
11932
12521
  scheduled?(controller: ScheduledController): void | Promise<void>;
11933
12522
  tail?(events: TraceItem[]): void | Promise<void>;
@@ -11948,6 +12537,7 @@ declare namespace CloudflareWorkersModule {
11948
12537
  constructor(ctx: DurableObjectState, env: Env);
11949
12538
  alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
11950
12539
  fetch?(request: Request): Response | Promise<Response>;
12540
+ connect?(socket: Socket): void | Promise<void>;
11951
12541
  webSocketMessage?(
11952
12542
  ws: WebSocket,
11953
12543
  message: string | ArrayBuffer,
@@ -12098,17 +12688,6 @@ interface StreamBinding {
12098
12688
  * @returns A handle for per-video operations.
12099
12689
  */
12100
12690
  video(id: string): StreamVideoHandle;
12101
- /**
12102
- * Uploads a new video from a File.
12103
- * @param file The video file to upload.
12104
- * @returns The uploaded video details.
12105
- * @throws {BadRequestError} if the upload parameter is invalid
12106
- * @throws {QuotaReachedError} if the account storage capacity is exceeded
12107
- * @throws {MaxFileSizeError} if the file size is too large
12108
- * @throws {RateLimitedError} if the server received too many requests
12109
- * @throws {InternalError} if an unexpected error occurs
12110
- */
12111
- upload(file: File): Promise<StreamVideo>;
12112
12691
  /**
12113
12692
  * Uploads a new video from a provided URL.
12114
12693
  * @param url The URL to upload from.
@@ -12958,6 +13537,9 @@ declare namespace TailStream {
12958
13537
  readonly type: "fetch";
12959
13538
  readonly statusCode: number;
12960
13539
  }
13540
+ interface ConnectEventInfo {
13541
+ readonly type: "connect";
13542
+ }
12961
13543
  type EventOutcome =
12962
13544
  | "ok"
12963
13545
  | "canceled"
@@ -12988,6 +13570,7 @@ declare namespace TailStream {
12988
13570
  readonly scriptVersion?: ScriptVersion;
12989
13571
  readonly info:
12990
13572
  | FetchEventInfo
13573
+ | ConnectEventInfo
12991
13574
  | JsRpcEventInfo
12992
13575
  | ScheduledEventInfo
12993
13576
  | AlarmEventInfo