@cloudflare/workers-types 4.20241216.0 → 4.20241224.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1416,20 +1416,44 @@ interface Element {
1416
1416
  hasAttribute(name: string): boolean;
1417
1417
  setAttribute(name: string, value: string): Element;
1418
1418
  removeAttribute(name: string): Element;
1419
- before(content: string, options?: ContentOptions): Element;
1420
- after(content: string, options?: ContentOptions): Element;
1421
- prepend(content: string, options?: ContentOptions): Element;
1422
- append(content: string, options?: ContentOptions): Element;
1423
- replace(content: string, options?: ContentOptions): Element;
1419
+ before(
1420
+ content: string | ReadableStream | Response,
1421
+ options?: ContentOptions,
1422
+ ): Element;
1423
+ after(
1424
+ content: string | ReadableStream | Response,
1425
+ options?: ContentOptions,
1426
+ ): Element;
1427
+ prepend(
1428
+ content: string | ReadableStream | Response,
1429
+ options?: ContentOptions,
1430
+ ): Element;
1431
+ append(
1432
+ content: string | ReadableStream | Response,
1433
+ options?: ContentOptions,
1434
+ ): Element;
1435
+ replace(
1436
+ content: string | ReadableStream | Response,
1437
+ options?: ContentOptions,
1438
+ ): Element;
1424
1439
  remove(): Element;
1425
1440
  removeAndKeepContent(): Element;
1426
- setInnerContent(content: string, options?: ContentOptions): Element;
1441
+ setInnerContent(
1442
+ content: string | ReadableStream | Response,
1443
+ options?: ContentOptions,
1444
+ ): Element;
1427
1445
  onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1428
1446
  }
1429
1447
  interface EndTag {
1430
1448
  name: string;
1431
- before(content: string, options?: ContentOptions): EndTag;
1432
- after(content: string, options?: ContentOptions): EndTag;
1449
+ before(
1450
+ content: string | ReadableStream | Response,
1451
+ options?: ContentOptions,
1452
+ ): EndTag;
1453
+ after(
1454
+ content: string | ReadableStream | Response,
1455
+ options?: ContentOptions,
1456
+ ): EndTag;
1433
1457
  remove(): EndTag;
1434
1458
  }
1435
1459
  interface Comment {
@@ -1444,9 +1468,18 @@ interface Text {
1444
1468
  readonly text: string;
1445
1469
  readonly lastInTextNode: boolean;
1446
1470
  readonly removed: boolean;
1447
- before(content: string, options?: ContentOptions): Text;
1448
- after(content: string, options?: ContentOptions): Text;
1449
- replace(content: string, options?: ContentOptions): Text;
1471
+ before(
1472
+ content: string | ReadableStream | Response,
1473
+ options?: ContentOptions,
1474
+ ): Text;
1475
+ after(
1476
+ content: string | ReadableStream | Response,
1477
+ options?: ContentOptions,
1478
+ ): Text;
1479
+ replace(
1480
+ content: string | ReadableStream | Response,
1481
+ options?: ContentOptions,
1482
+ ): Text;
1450
1483
  remove(): Text;
1451
1484
  }
1452
1485
  interface DocumentEnd {
@@ -3420,10 +3453,10 @@ declare abstract class BaseAiSentenceSimilarity {
3420
3453
  inputs: AiSentenceSimilarityInput;
3421
3454
  postProcessedOutputs: AiSentenceSimilarityOutput;
3422
3455
  }
3423
- type AiSpeechRecognitionInput = {
3456
+ type AiAutomaticSpeechRecognitionInput = {
3424
3457
  audio: number[];
3425
3458
  };
3426
- type AiSpeechRecognitionOutput = {
3459
+ type AiAutomaticSpeechRecognitionOutput = {
3427
3460
  text?: string;
3428
3461
  words?: {
3429
3462
  word: string;
@@ -3432,9 +3465,9 @@ type AiSpeechRecognitionOutput = {
3432
3465
  }[];
3433
3466
  vtt?: string;
3434
3467
  };
3435
- declare abstract class BaseAiSpeechRecognition {
3436
- inputs: AiSpeechRecognitionInput;
3437
- postProcessedOutputs: AiSpeechRecognitionOutput;
3468
+ declare abstract class BaseAiAutomaticSpeechRecognition {
3469
+ inputs: AiAutomaticSpeechRecognitionInput;
3470
+ postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
3438
3471
  }
3439
3472
  type AiSummarizationInput = {
3440
3473
  input_text: string;
@@ -3470,16 +3503,36 @@ declare abstract class BaseAiTextEmbeddings {
3470
3503
  postProcessedOutputs: AiTextEmbeddingsOutput;
3471
3504
  }
3472
3505
  type RoleScopedChatInput = {
3473
- role: "user" | "assistant" | "system" | "tool";
3506
+ role:
3507
+ | "user"
3508
+ | "assistant"
3509
+ | "system"
3510
+ | "tool"
3511
+ | (string & NonNullable<unknown>);
3474
3512
  content: string;
3513
+ name?: string;
3514
+ };
3515
+ type AiTextGenerationToolLegacyInput = {
3516
+ name: string;
3517
+ description: string;
3518
+ parameters?: {
3519
+ type: "object" | (string & NonNullable<unknown>);
3520
+ properties: {
3521
+ [key: string]: {
3522
+ type: string;
3523
+ description?: string;
3524
+ };
3525
+ };
3526
+ required: string[];
3527
+ };
3475
3528
  };
3476
3529
  type AiTextGenerationToolInput = {
3477
- type: "function";
3530
+ type: "function" | (string & NonNullable<unknown>);
3478
3531
  function: {
3479
3532
  name: string;
3480
3533
  description: string;
3481
3534
  parameters?: {
3482
- type: "object";
3535
+ type: "object" | (string & NonNullable<unknown>);
3483
3536
  properties: {
3484
3537
  [key: string]: {
3485
3538
  type: string;
@@ -3490,6 +3543,10 @@ type AiTextGenerationToolInput = {
3490
3543
  };
3491
3544
  };
3492
3545
  };
3546
+ type AiTextGenerationFunctionsInput = {
3547
+ name: string;
3548
+ code: string;
3549
+ };
3493
3550
  type AiTextGenerationInput = {
3494
3551
  prompt?: string;
3495
3552
  raw?: boolean;
@@ -3503,7 +3560,8 @@ type AiTextGenerationInput = {
3503
3560
  frequency_penalty?: number;
3504
3561
  presence_penalty?: number;
3505
3562
  messages?: RoleScopedChatInput[];
3506
- tools?: AiTextGenerationToolInput[];
3563
+ tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[];
3564
+ functions?: AiTextGenerationFunctionsInput[];
3507
3565
  };
3508
3566
  type AiTextGenerationOutput =
3509
3567
  | {
@@ -3518,13 +3576,31 @@ declare abstract class BaseAiTextGeneration {
3518
3576
  inputs: AiTextGenerationInput;
3519
3577
  postProcessedOutputs: AiTextGenerationOutput;
3520
3578
  }
3579
+ type AiTextToSpeechInput = {
3580
+ prompt: string;
3581
+ lang?: string;
3582
+ };
3583
+ type AiTextToSpeechOutput =
3584
+ | Uint8Array
3585
+ | {
3586
+ audio: string;
3587
+ };
3588
+ declare abstract class BaseAiTextToSpeech {
3589
+ inputs: AiTextToSpeechInput;
3590
+ postProcessedOutputs: AiTextToSpeechOutput;
3591
+ }
3521
3592
  type AiTextToImageInput = {
3522
3593
  prompt: string;
3594
+ negative_prompt?: string;
3595
+ height?: number;
3596
+ width?: number;
3523
3597
  image?: number[];
3598
+ image_b64?: string;
3524
3599
  mask?: number[];
3525
3600
  num_steps?: number;
3526
3601
  strength?: number;
3527
3602
  guidance?: number;
3603
+ seed?: number;
3528
3604
  };
3529
3605
  type AiTextToImageOutput = ReadableStream<Uint8Array>;
3530
3606
  declare abstract class BaseAiTextToImage {
@@ -3548,118 +3624,73 @@ type AiOptions = {
3548
3624
  prefix?: string;
3549
3625
  extraHeaders?: object;
3550
3626
  };
3551
- type BaseAiTextClassificationModels = "@cf/huggingface/distilbert-sst-2-int8";
3552
- type BaseAiTextToImageModels =
3553
- | "@cf/stabilityai/stable-diffusion-xl-base-1.0"
3554
- | "@cf/runwayml/stable-diffusion-v1-5-inpainting"
3555
- | "@cf/runwayml/stable-diffusion-v1-5-img2img"
3556
- | "@cf/lykon/dreamshaper-8-lcm"
3557
- | "@cf/bytedance/stable-diffusion-xl-lightning";
3558
- type BaseAiTextEmbeddingsModels =
3559
- | "@cf/baai/bge-small-en-v1.5"
3560
- | "@cf/baai/bge-base-en-v1.5"
3561
- | "@cf/baai/bge-large-en-v1.5";
3562
- type BaseAiSpeechRecognitionModels =
3563
- | "@cf/openai/whisper"
3564
- | "@cf/openai/whisper-tiny-en"
3565
- | "@cf/openai/whisper-sherpa";
3566
- type BaseAiImageClassificationModels = "@cf/microsoft/resnet-50";
3567
- type BaseAiObjectDetectionModels = "@cf/facebook/detr-resnet-50";
3568
- type BaseAiTextGenerationModels =
3569
- | "@cf/meta/llama-3.1-8b-instruct"
3570
- | "@cf/meta/llama-3-8b-instruct"
3571
- | "@cf/meta/llama-3-8b-instruct-awq"
3572
- | "@cf/meta/llama-2-7b-chat-int8"
3573
- | "@cf/mistral/mistral-7b-instruct-v0.1"
3574
- | "@cf/mistral/mistral-7b-instruct-v0.2-lora"
3575
- | "@cf/meta/llama-2-7b-chat-fp16"
3576
- | "@hf/thebloke/llama-2-13b-chat-awq"
3577
- | "@hf/thebloke/zephyr-7b-beta-awq"
3578
- | "@hf/thebloke/mistral-7b-instruct-v0.1-awq"
3579
- | "@hf/thebloke/codellama-7b-instruct-awq"
3580
- | "@hf/thebloke/openhermes-2.5-mistral-7b-awq"
3581
- | "@hf/thebloke/neural-chat-7b-v3-1-awq"
3582
- | "@hf/thebloke/llamaguard-7b-awq"
3583
- | "@hf/thebloke/deepseek-coder-6.7b-base-awq"
3584
- | "@hf/thebloke/deepseek-coder-6.7b-instruct-awq"
3585
- | "@hf/nousresearch/hermes-2-pro-mistral-7b"
3586
- | "@hf/mistral/mistral-7b-instruct-v0.2"
3587
- | "@hf/google/gemma-7b-it"
3588
- | "@hf/nexusflow/starling-lm-7b-beta"
3589
- | "@cf/deepseek-ai/deepseek-math-7b-instruct"
3590
- | "@cf/defog/sqlcoder-7b-2"
3591
- | "@cf/openchat/openchat-3.5-0106"
3592
- | "@cf/tiiuae/falcon-7b-instruct"
3593
- | "@cf/thebloke/discolm-german-7b-v1-awq"
3594
- | "@cf/qwen/qwen1.5-0.5b-chat"
3595
- | "@cf/qwen/qwen1.5-1.8b-chat"
3596
- | "@cf/qwen/qwen1.5-7b-chat-awq"
3597
- | "@cf/qwen/qwen1.5-14b-chat-awq"
3598
- | "@cf/tinyllama/tinyllama-1.1b-chat-v1.0"
3599
- | "@cf/microsoft/phi-2"
3600
- | "@cf/google/gemma-2b-it-lora"
3601
- | "@cf/google/gemma-7b-it-lora"
3602
- | "@cf/meta-llama/llama-2-7b-chat-hf-lora"
3603
- | "@cf/fblgit/una-cybertron-7b-v2-bf16"
3604
- | "@cf/fblgit/una-cybertron-7b-v2-awq";
3605
- type BaseAiTranslationModels = "@cf/meta/m2m100-1.2b";
3606
- type BaseAiSummarizationModels = "@cf/facebook/bart-large-cnn";
3607
- type BaseAiImageToTextModels =
3608
- | "@cf/unum/uform-gen2-qwen-500m"
3609
- | "@cf/llava-hf/llava-1.5-7b-hf";
3610
- declare abstract class Ai {
3611
- public aiGatewayLogId: string | null;
3612
- public gateway(gatewayId: string): AiGateway;
3613
- run(
3614
- model: BaseAiTextClassificationModels,
3615
- inputs: BaseAiTextClassification["inputs"],
3616
- options?: AiOptions,
3617
- ): Promise<BaseAiTextClassification["postProcessedOutputs"]>;
3618
- run(
3619
- model: BaseAiTextToImageModels,
3620
- inputs: BaseAiTextToImage["inputs"],
3621
- options?: AiOptions,
3622
- ): Promise<BaseAiTextToImage["postProcessedOutputs"]>;
3623
- run(
3624
- model: BaseAiTextEmbeddingsModels,
3625
- inputs: BaseAiTextEmbeddings["inputs"],
3626
- options?: AiOptions,
3627
- ): Promise<BaseAiTextEmbeddings["postProcessedOutputs"]>;
3628
- run(
3629
- model: BaseAiSpeechRecognitionModels,
3630
- inputs: BaseAiSpeechRecognition["inputs"],
3631
- options?: AiOptions,
3632
- ): Promise<BaseAiSpeechRecognition["postProcessedOutputs"]>;
3633
- run(
3634
- model: BaseAiImageClassificationModels,
3635
- inputs: BaseAiImageClassification["inputs"],
3636
- options?: AiOptions,
3637
- ): Promise<BaseAiImageClassification["postProcessedOutputs"]>;
3638
- run(
3639
- model: BaseAiObjectDetectionModels,
3640
- inputs: BaseAiObjectDetection["inputs"],
3641
- options?: AiOptions,
3642
- ): Promise<BaseAiObjectDetection["postProcessedOutputs"]>;
3643
- run(
3644
- model: BaseAiTextGenerationModels,
3645
- inputs: BaseAiTextGeneration["inputs"],
3646
- options?: AiOptions,
3647
- ): Promise<BaseAiTextGeneration["postProcessedOutputs"]>;
3648
- run(
3649
- model: BaseAiTranslationModels,
3650
- inputs: BaseAiTranslation["inputs"],
3651
- options?: AiOptions,
3652
- ): Promise<BaseAiTranslation["postProcessedOutputs"]>;
3653
- run(
3654
- model: BaseAiSummarizationModels,
3655
- inputs: BaseAiSummarization["inputs"],
3656
- options?: AiOptions,
3657
- ): Promise<BaseAiSummarization["postProcessedOutputs"]>;
3658
- run(
3659
- model: BaseAiImageToTextModels,
3660
- inputs: BaseAiImageToText["inputs"],
3627
+ type ModelType<Name extends keyof AiModels> = AiModels[Name];
3628
+ interface AiModels {
3629
+ "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
3630
+ "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
3631
+ "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
3632
+ "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
3633
+ "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
3634
+ "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
3635
+ "@cf/baai/bge-base-en-v1.5": BaseAiTextEmbeddings;
3636
+ "@cf/baai/bge-small-en-v1.5": BaseAiTextEmbeddings;
3637
+ "@cf/baai/bge-large-en-v1.5": BaseAiTextEmbeddings;
3638
+ "@cf/microsoft/resnet-50": BaseAiImageClassification;
3639
+ "@cf/facebook/detr-resnet-50": BaseAiObjectDetection;
3640
+ "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
3641
+ "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
3642
+ "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
3643
+ "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
3644
+ "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
3645
+ "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
3646
+ "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
3647
+ "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
3648
+ "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
3649
+ "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
3650
+ "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
3651
+ "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
3652
+ "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
3653
+ "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
3654
+ "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
3655
+ "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
3656
+ "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
3657
+ "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
3658
+ "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
3659
+ "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
3660
+ "@cf/microsoft/phi-2": BaseAiTextGeneration;
3661
+ "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
3662
+ "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
3663
+ "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
3664
+ "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
3665
+ "@hf/google/gemma-7b-it": BaseAiTextGeneration;
3666
+ "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
3667
+ "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
3668
+ "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
3669
+ "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
3670
+ "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
3671
+ "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
3672
+ "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
3673
+ "@hf/meta-llama/meta-llama-3-8b-instruct": BaseAiTextGeneration;
3674
+ "@cf/meta/llama-3.1-8b-instruct": BaseAiTextGeneration;
3675
+ "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
3676
+ "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
3677
+ "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
3678
+ "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
3679
+ "@cf/meta/llama-3.3-70b-instruct-fp8-fast": BaseAiTextGeneration;
3680
+ "@cf/meta/m2m100-1.2b": BaseAiTranslation;
3681
+ "@cf/facebook/bart-large-cnn": BaseAiSummarization;
3682
+ "@cf/unum/uform-gen2-qwen-500m": BaseAiImageToText;
3683
+ "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
3684
+ }
3685
+ type ModelListType = Record<string, any>;
3686
+ declare abstract class Ai<ModelList extends ModelListType = AiModels> {
3687
+ aiGatewayLogId: string | null;
3688
+ gateway(gatewayId: string): AiGateway;
3689
+ run<Name extends keyof ModelList>(
3690
+ model: Name,
3691
+ inputs: ModelList[Name]["inputs"],
3661
3692
  options?: AiOptions,
3662
- ): Promise<BaseAiImageToText["postProcessedOutputs"]>;
3693
+ ): Promise<ModelList[Name]["postProcessedOutputs"]>;
3663
3694
  }
3664
3695
  type GatewayOptions = {
3665
3696
  id: string;
@@ -5357,6 +5388,7 @@ declare module "cloudflare:workers" {
5357
5388
  export type WorkflowEvent<T> = {
5358
5389
  payload: Readonly<T>;
5359
5390
  timestamp: Date;
5391
+ instanceId: string;
5360
5392
  };
5361
5393
  export abstract class WorkflowStep {
5362
5394
  do<T extends Rpc.Serializable<T>>(