@opencode/ai 0.0.0-dev-21920 → 0.0.0-dev-44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -19
- package/dist/ai-client.d.ts +2 -2
- package/dist/cache-policy.d.ts +4 -0
- package/dist/cache-policy.js +20 -6
- package/dist/decision-client.d.ts +3 -3
- package/dist/decision.d.ts +4 -1
- package/dist/decision.js +3 -0
- package/dist/effect.d.ts +4 -5
- package/dist/effect.js +2 -3
- package/dist/experimental/realtime.d.ts +3 -2
- package/dist/image-client.d.ts +1 -1
- package/dist/image.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/llm.d.ts +3 -0
- package/dist/media-client.d.ts +2 -1
- package/dist/media-model.d.ts +3 -0
- package/dist/media-model.js +4 -1
- package/dist/protocols/alibaba-chat.d.ts +4 -0
- package/dist/protocols/alibaba-messages.d.ts +19 -19
- package/dist/protocols/alibaba-responses.d.ts +3 -3
- package/dist/protocols/anthropic-messages.d.ts +59 -59
- package/dist/protocols/anthropic-messages.js +3 -5
- package/dist/protocols/bedrock-converse.d.ts +110 -15
- package/dist/protocols/bedrock-converse.js +112 -15
- package/dist/protocols/bedrock-event-stream.js +1 -0
- package/dist/protocols/meta-messages.d.ts +19 -19
- package/dist/protocols/meta-messages.js +2 -1
- package/dist/protocols/open-responses.d.ts +3 -0
- package/dist/protocols/openai-chat.d.ts +588 -1
- package/dist/protocols/openai-chat.js +7 -2
- package/dist/protocols/openai-compatible-chat.d.ts +6 -2
- package/dist/protocols/openai-compatible-responses.d.ts +3 -3
- package/dist/protocols/openai-responses.d.ts +24 -0
- package/dist/protocols/openai-responses.js +5 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
- package/dist/protocols/utils/bedrock-cache.js +7 -6
- package/dist/protocols/utils/cache.d.ts +14 -3
- package/dist/protocols/utils/cache.js +11 -4
- package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
- package/dist/protocols/utils/gemini-json-schema.js +3 -3
- package/dist/protocols/utils/tool-schema.js +15 -5
- package/dist/protocols/utils/tool-stream.d.ts +9 -0
- package/dist/protocols/venice-chat.d.ts +3 -0
- package/dist/protocols/venice-chat.js +1 -1
- package/dist/protocols/zai-chat.d.ts +4 -0
- package/dist/protocols/zai-messages.d.ts +19 -19
- package/dist/providers/alibaba/images.d.ts +2 -0
- package/dist/providers/alibaba/images.js +1 -0
- package/dist/providers/alibaba.d.ts +26 -21
- package/dist/providers/alibaba.js +12 -8
- package/dist/providers/amazon-bedrock-mantle.d.ts +23 -19
- package/dist/providers/amazon-bedrock.d.ts +34 -14
- package/dist/providers/amazon-bedrock.js +11 -11
- package/dist/providers/anthropic-compatible.d.ts +19 -19
- package/dist/providers/anthropic.d.ts +19 -19
- package/dist/providers/azure/images.d.ts +2 -0
- package/dist/providers/azure/images.js +1 -0
- package/dist/providers/azure.d.ts +15 -1
- package/dist/providers/azure.js +19 -1
- package/dist/providers/baseten/decisions.d.ts +2 -0
- package/dist/providers/baseten/decisions.js +1 -0
- package/dist/providers/baseten.d.ts +13 -4
- package/dist/providers/baseten.js +15 -8
- package/dist/providers/cerebras.d.ts +8 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +57 -40
- package/dist/providers/cloudflare-ai-gateway.js +11 -6
- package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
- package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/images.js +1 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +13 -3
- package/dist/providers/cloudflare-workers-ai.js +16 -7
- package/dist/providers/cohere.d.ts +8 -0
- package/dist/providers/deepinfra.d.ts +8 -0
- package/dist/providers/deepseek.d.ts +8 -0
- package/dist/providers/digitalocean/decisions.d.ts +2 -0
- package/dist/providers/digitalocean/decisions.js +1 -0
- package/dist/providers/digitalocean/images.d.ts +2 -0
- package/dist/providers/digitalocean/images.js +1 -0
- package/dist/providers/digitalocean.d.ts +21 -4
- package/dist/providers/digitalocean.js +25 -8
- package/dist/providers/fireworks.d.ts +8 -0
- package/dist/providers/google/images.d.ts +2 -0
- package/dist/providers/google/images.js +1 -0
- package/dist/providers/google-vertex/images.d.ts +2 -0
- package/dist/providers/google-vertex/images.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +4 -0
- package/dist/providers/google-vertex-messages.d.ts +19 -19
- package/dist/providers/google-vertex.d.ts +3 -1
- package/dist/providers/google-vertex.js +30 -13
- package/dist/providers/google.d.ts +5 -4
- package/dist/providers/google.js +15 -8
- package/dist/providers/groq.d.ts +8 -0
- package/dist/providers/meta.d.ts +23 -19
- package/dist/providers/minimax.d.ts +23 -19
- package/dist/providers/moonshot.d.ts +23 -19
- package/dist/providers/openai/images.d.ts +2 -0
- package/dist/providers/openai/images.js +1 -0
- package/dist/providers/openai-compatible/images.d.ts +2 -0
- package/dist/providers/openai-compatible/images.js +1 -0
- package/dist/providers/openai-compatible.d.ts +7 -1
- package/dist/providers/openai-compatible.js +21 -9
- package/dist/providers/openai.d.ts +18 -8
- package/dist/providers/openai.js +10 -2
- package/dist/providers/opencode/decisions.d.ts +2 -0
- package/dist/providers/opencode/decisions.js +1 -0
- package/dist/providers/opencode.d.ts +9 -4
- package/dist/providers/opencode.js +2 -1
- package/dist/providers/openrouter/decisions.d.ts +2 -0
- package/dist/providers/openrouter/decisions.js +1 -0
- package/dist/providers/openrouter/images.d.ts +2 -0
- package/dist/providers/openrouter/images.js +1 -0
- package/dist/providers/openrouter.d.ts +25 -4
- package/dist/providers/openrouter.js +31 -9
- package/dist/providers/togetherai.d.ts +8 -0
- package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
- package/dist/providers/typesafe-ai/decisions.js +1 -0
- package/dist/providers/typesafe-ai.d.ts +9 -4
- package/dist/providers/typesafe-ai.js +2 -1
- package/dist/providers/venice.d.ts +3 -0
- package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
- package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/images.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +9 -7
- package/dist/providers/vercel-ai-gateway.js +18 -10
- package/dist/providers/xai/images.d.ts +2 -0
- package/dist/providers/xai/images.js +1 -0
- package/dist/providers/xai.d.ts +9 -4
- package/dist/providers/xai.js +15 -8
- package/dist/providers/zai/images.d.ts +2 -0
- package/dist/providers/zai/images.js +1 -0
- package/dist/providers/zai-coding-plan.d.ts +23 -19
- package/dist/providers/zai.d.ts +9 -4
- package/dist/providers/zai.js +15 -8
- package/dist/route/client.d.ts +2 -2
- package/dist/route/client.js +15 -4
- package/dist/route/decision.d.ts +2 -1
- package/dist/route/decision.js +1 -0
- package/dist/route/executor.d.ts +1 -1
- package/dist/route/framing.d.ts +2 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.js +3 -0
- package/dist/route/media.d.ts +5 -1
- package/dist/route/media.js +6 -2
- package/dist/route/transport/http.js +1 -0
- package/dist/route/transport/index.d.ts +1 -0
- package/dist/schema/events.d.ts +135 -6
- package/dist/schema/events.js +10 -0
- package/dist/schema/messages.d.ts +6 -2
- package/dist/schema/messages.js +3 -0
- package/dist/schema/options.d.ts +5 -3
- package/dist/schema/options.js +8 -3
- package/dist/speech-client.d.ts +1 -1
- package/dist/speech.js +2 -1
- package/dist/testing.d.ts +25 -24
- package/dist/testing.js +3 -21
- package/dist/transcription-client.d.ts +1 -1
- package/dist/transcription.js +1 -0
- package/dist/video-client.d.ts +1 -1
- package/dist/video.js +1 -0
- package/package.json +510 -8
- package/dist/provider.d.ts +0 -23
- package/dist/provider.js +0 -2
|
@@ -273,6 +273,10 @@ export declare const bodyFields: {
|
|
|
273
273
|
}>>;
|
|
274
274
|
store: Schema.optional<Schema.Boolean>;
|
|
275
275
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
276
|
+
prompt_cache_retention: Schema.optional<Schema.String>;
|
|
277
|
+
prompt_cache_options: Schema.optional<Schema.Struct<{
|
|
278
|
+
readonly ttl: Schema.optional<Schema.String>;
|
|
279
|
+
}>>;
|
|
276
280
|
reasoning_effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
277
281
|
verbosity: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium">, import("../schema/options.js").OpenString<"high" | "low" | "medium">>>;
|
|
278
282
|
service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>>;
|
|
@@ -407,6 +411,10 @@ declare const OpenAIChatBody: Schema.Struct<{
|
|
|
407
411
|
}>>;
|
|
408
412
|
store: Schema.optional<Schema.Boolean>;
|
|
409
413
|
prompt_cache_key: Schema.optional<Schema.String>;
|
|
414
|
+
prompt_cache_retention: Schema.optional<Schema.String>;
|
|
415
|
+
prompt_cache_options: Schema.optional<Schema.Struct<{
|
|
416
|
+
readonly ttl: Schema.optional<Schema.String>;
|
|
417
|
+
}>>;
|
|
410
418
|
reasoning_effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
411
419
|
verbosity: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium">, import("../schema/options.js").OpenString<"high" | "low" | "medium">>>;
|
|
412
420
|
service_tier: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>>;
|
|
@@ -604,6 +612,427 @@ interface LoweringOptions {
|
|
|
604
612
|
export declare const fromRequest: (request: LLMRequest<import("../schema/options.js").LanguageModel<{
|
|
605
613
|
readonly [x: string]: unknown;
|
|
606
614
|
}, import("../route/client.js").CompactionOperations | undefined>>, options?: LoweringOptions | undefined) => Effect.Effect<{
|
|
615
|
+
prompt_cache_retention?: undefined;
|
|
616
|
+
prompt_cache_options?: undefined;
|
|
617
|
+
store?: boolean | undefined;
|
|
618
|
+
prompt_cache_key?: string | undefined;
|
|
619
|
+
reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
620
|
+
verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
621
|
+
service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
622
|
+
parallel_tool_calls?: boolean | undefined;
|
|
623
|
+
metadata?: {
|
|
624
|
+
readonly [x: string]: string;
|
|
625
|
+
} | undefined;
|
|
626
|
+
safety_identifier?: string | undefined;
|
|
627
|
+
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
628
|
+
messages: ({
|
|
629
|
+
readonly role: "system";
|
|
630
|
+
readonly content: string | readonly ({
|
|
631
|
+
readonly type: "image_url";
|
|
632
|
+
readonly image_url: {
|
|
633
|
+
readonly url: string;
|
|
634
|
+
};
|
|
635
|
+
} | {
|
|
636
|
+
readonly type: "video_url";
|
|
637
|
+
readonly video_url: {
|
|
638
|
+
readonly url: string;
|
|
639
|
+
};
|
|
640
|
+
} | {
|
|
641
|
+
readonly type: "file";
|
|
642
|
+
readonly file: {
|
|
643
|
+
readonly filename: string;
|
|
644
|
+
readonly file_data: string;
|
|
645
|
+
};
|
|
646
|
+
} | {
|
|
647
|
+
readonly type: "text";
|
|
648
|
+
readonly text: string;
|
|
649
|
+
readonly cache_control?: {
|
|
650
|
+
readonly type: "ephemeral";
|
|
651
|
+
readonly ttl?: string | undefined;
|
|
652
|
+
} | undefined;
|
|
653
|
+
})[];
|
|
654
|
+
} | {
|
|
655
|
+
readonly role: "user";
|
|
656
|
+
readonly content: string | readonly ({
|
|
657
|
+
readonly type: "image_url";
|
|
658
|
+
readonly image_url: {
|
|
659
|
+
readonly url: string;
|
|
660
|
+
};
|
|
661
|
+
} | {
|
|
662
|
+
readonly type: "video_url";
|
|
663
|
+
readonly video_url: {
|
|
664
|
+
readonly url: string;
|
|
665
|
+
};
|
|
666
|
+
} | {
|
|
667
|
+
readonly type: "file";
|
|
668
|
+
readonly file: {
|
|
669
|
+
readonly filename: string;
|
|
670
|
+
readonly file_data: string;
|
|
671
|
+
};
|
|
672
|
+
} | {
|
|
673
|
+
readonly type: "text";
|
|
674
|
+
readonly text: string;
|
|
675
|
+
readonly cache_control?: {
|
|
676
|
+
readonly type: "ephemeral";
|
|
677
|
+
readonly ttl?: string | undefined;
|
|
678
|
+
} | undefined;
|
|
679
|
+
})[];
|
|
680
|
+
} | {
|
|
681
|
+
readonly role: "tool";
|
|
682
|
+
readonly tool_call_id: string;
|
|
683
|
+
readonly content: string | readonly {
|
|
684
|
+
readonly type: "text";
|
|
685
|
+
readonly text: string;
|
|
686
|
+
readonly cache_control?: {
|
|
687
|
+
readonly type: "ephemeral";
|
|
688
|
+
readonly ttl?: string | undefined;
|
|
689
|
+
} | undefined;
|
|
690
|
+
}[];
|
|
691
|
+
} | {
|
|
692
|
+
readonly [x: string]: unknown;
|
|
693
|
+
readonly role: "assistant";
|
|
694
|
+
readonly content: string | readonly {
|
|
695
|
+
readonly type: "text";
|
|
696
|
+
readonly text: string;
|
|
697
|
+
readonly cache_control?: {
|
|
698
|
+
readonly type: "ephemeral";
|
|
699
|
+
readonly ttl?: string | undefined;
|
|
700
|
+
} | undefined;
|
|
701
|
+
}[] | null;
|
|
702
|
+
readonly tool_calls?: readonly {
|
|
703
|
+
readonly id: string;
|
|
704
|
+
readonly type: "function";
|
|
705
|
+
readonly function: {
|
|
706
|
+
readonly name: string;
|
|
707
|
+
readonly arguments: string;
|
|
708
|
+
};
|
|
709
|
+
readonly extra_content?: {
|
|
710
|
+
readonly google: {
|
|
711
|
+
readonly thought_signature: string;
|
|
712
|
+
};
|
|
713
|
+
} | undefined;
|
|
714
|
+
}[] | undefined;
|
|
715
|
+
readonly reasoning_content?: string | undefined;
|
|
716
|
+
readonly reasoning?: string | undefined;
|
|
717
|
+
readonly reasoning_text?: string | undefined;
|
|
718
|
+
readonly reasoning_details?: unknown;
|
|
719
|
+
})[];
|
|
720
|
+
tools: {
|
|
721
|
+
readonly type: "function";
|
|
722
|
+
readonly function: {
|
|
723
|
+
readonly name: string;
|
|
724
|
+
readonly description: string;
|
|
725
|
+
readonly parameters: {
|
|
726
|
+
readonly [x: string]: unknown;
|
|
727
|
+
};
|
|
728
|
+
readonly strict?: boolean | undefined;
|
|
729
|
+
};
|
|
730
|
+
readonly cache_control?: {
|
|
731
|
+
readonly type: "ephemeral";
|
|
732
|
+
readonly ttl?: string | undefined;
|
|
733
|
+
} | undefined;
|
|
734
|
+
}[] | undefined;
|
|
735
|
+
tool_choice: "auto" | "none" | "required" | {
|
|
736
|
+
type: "function";
|
|
737
|
+
function: {
|
|
738
|
+
name: string;
|
|
739
|
+
};
|
|
740
|
+
} | undefined;
|
|
741
|
+
stream: true;
|
|
742
|
+
stream_options?: {
|
|
743
|
+
include_usage: boolean;
|
|
744
|
+
} | undefined;
|
|
745
|
+
tool_stream?: boolean | undefined;
|
|
746
|
+
max_completion_tokens: number | undefined;
|
|
747
|
+
temperature: number | undefined;
|
|
748
|
+
top_p: number | undefined;
|
|
749
|
+
frequency_penalty: number | undefined;
|
|
750
|
+
presence_penalty: number | undefined;
|
|
751
|
+
seed: number | undefined;
|
|
752
|
+
stop: readonly string[] | undefined;
|
|
753
|
+
} | {
|
|
754
|
+
prompt_cache_retention: string;
|
|
755
|
+
prompt_cache_options?: undefined;
|
|
756
|
+
store?: boolean | undefined;
|
|
757
|
+
prompt_cache_key?: string | undefined;
|
|
758
|
+
reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
759
|
+
verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
760
|
+
service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
761
|
+
parallel_tool_calls?: boolean | undefined;
|
|
762
|
+
metadata?: {
|
|
763
|
+
readonly [x: string]: string;
|
|
764
|
+
} | undefined;
|
|
765
|
+
safety_identifier?: string | undefined;
|
|
766
|
+
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
767
|
+
messages: ({
|
|
768
|
+
readonly role: "system";
|
|
769
|
+
readonly content: string | readonly ({
|
|
770
|
+
readonly type: "image_url";
|
|
771
|
+
readonly image_url: {
|
|
772
|
+
readonly url: string;
|
|
773
|
+
};
|
|
774
|
+
} | {
|
|
775
|
+
readonly type: "video_url";
|
|
776
|
+
readonly video_url: {
|
|
777
|
+
readonly url: string;
|
|
778
|
+
};
|
|
779
|
+
} | {
|
|
780
|
+
readonly type: "file";
|
|
781
|
+
readonly file: {
|
|
782
|
+
readonly filename: string;
|
|
783
|
+
readonly file_data: string;
|
|
784
|
+
};
|
|
785
|
+
} | {
|
|
786
|
+
readonly type: "text";
|
|
787
|
+
readonly text: string;
|
|
788
|
+
readonly cache_control?: {
|
|
789
|
+
readonly type: "ephemeral";
|
|
790
|
+
readonly ttl?: string | undefined;
|
|
791
|
+
} | undefined;
|
|
792
|
+
})[];
|
|
793
|
+
} | {
|
|
794
|
+
readonly role: "user";
|
|
795
|
+
readonly content: string | readonly ({
|
|
796
|
+
readonly type: "image_url";
|
|
797
|
+
readonly image_url: {
|
|
798
|
+
readonly url: string;
|
|
799
|
+
};
|
|
800
|
+
} | {
|
|
801
|
+
readonly type: "video_url";
|
|
802
|
+
readonly video_url: {
|
|
803
|
+
readonly url: string;
|
|
804
|
+
};
|
|
805
|
+
} | {
|
|
806
|
+
readonly type: "file";
|
|
807
|
+
readonly file: {
|
|
808
|
+
readonly filename: string;
|
|
809
|
+
readonly file_data: string;
|
|
810
|
+
};
|
|
811
|
+
} | {
|
|
812
|
+
readonly type: "text";
|
|
813
|
+
readonly text: string;
|
|
814
|
+
readonly cache_control?: {
|
|
815
|
+
readonly type: "ephemeral";
|
|
816
|
+
readonly ttl?: string | undefined;
|
|
817
|
+
} | undefined;
|
|
818
|
+
})[];
|
|
819
|
+
} | {
|
|
820
|
+
readonly role: "tool";
|
|
821
|
+
readonly tool_call_id: string;
|
|
822
|
+
readonly content: string | readonly {
|
|
823
|
+
readonly type: "text";
|
|
824
|
+
readonly text: string;
|
|
825
|
+
readonly cache_control?: {
|
|
826
|
+
readonly type: "ephemeral";
|
|
827
|
+
readonly ttl?: string | undefined;
|
|
828
|
+
} | undefined;
|
|
829
|
+
}[];
|
|
830
|
+
} | {
|
|
831
|
+
readonly [x: string]: unknown;
|
|
832
|
+
readonly role: "assistant";
|
|
833
|
+
readonly content: string | readonly {
|
|
834
|
+
readonly type: "text";
|
|
835
|
+
readonly text: string;
|
|
836
|
+
readonly cache_control?: {
|
|
837
|
+
readonly type: "ephemeral";
|
|
838
|
+
readonly ttl?: string | undefined;
|
|
839
|
+
} | undefined;
|
|
840
|
+
}[] | null;
|
|
841
|
+
readonly tool_calls?: readonly {
|
|
842
|
+
readonly id: string;
|
|
843
|
+
readonly type: "function";
|
|
844
|
+
readonly function: {
|
|
845
|
+
readonly name: string;
|
|
846
|
+
readonly arguments: string;
|
|
847
|
+
};
|
|
848
|
+
readonly extra_content?: {
|
|
849
|
+
readonly google: {
|
|
850
|
+
readonly thought_signature: string;
|
|
851
|
+
};
|
|
852
|
+
} | undefined;
|
|
853
|
+
}[] | undefined;
|
|
854
|
+
readonly reasoning_content?: string | undefined;
|
|
855
|
+
readonly reasoning?: string | undefined;
|
|
856
|
+
readonly reasoning_text?: string | undefined;
|
|
857
|
+
readonly reasoning_details?: unknown;
|
|
858
|
+
})[];
|
|
859
|
+
tools: {
|
|
860
|
+
readonly type: "function";
|
|
861
|
+
readonly function: {
|
|
862
|
+
readonly name: string;
|
|
863
|
+
readonly description: string;
|
|
864
|
+
readonly parameters: {
|
|
865
|
+
readonly [x: string]: unknown;
|
|
866
|
+
};
|
|
867
|
+
readonly strict?: boolean | undefined;
|
|
868
|
+
};
|
|
869
|
+
readonly cache_control?: {
|
|
870
|
+
readonly type: "ephemeral";
|
|
871
|
+
readonly ttl?: string | undefined;
|
|
872
|
+
} | undefined;
|
|
873
|
+
}[] | undefined;
|
|
874
|
+
tool_choice: "auto" | "none" | "required" | {
|
|
875
|
+
type: "function";
|
|
876
|
+
function: {
|
|
877
|
+
name: string;
|
|
878
|
+
};
|
|
879
|
+
} | undefined;
|
|
880
|
+
stream: true;
|
|
881
|
+
stream_options?: {
|
|
882
|
+
include_usage: boolean;
|
|
883
|
+
} | undefined;
|
|
884
|
+
tool_stream?: boolean | undefined;
|
|
885
|
+
max_completion_tokens: number | undefined;
|
|
886
|
+
temperature: number | undefined;
|
|
887
|
+
top_p: number | undefined;
|
|
888
|
+
frequency_penalty: number | undefined;
|
|
889
|
+
presence_penalty: number | undefined;
|
|
890
|
+
seed: number | undefined;
|
|
891
|
+
stop: readonly string[] | undefined;
|
|
892
|
+
} | {
|
|
893
|
+
prompt_cache_retention?: undefined;
|
|
894
|
+
prompt_cache_options: {
|
|
895
|
+
ttl: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s`;
|
|
896
|
+
};
|
|
897
|
+
store?: boolean | undefined;
|
|
898
|
+
prompt_cache_key?: string | undefined;
|
|
899
|
+
reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
900
|
+
verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
901
|
+
service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
902
|
+
parallel_tool_calls?: boolean | undefined;
|
|
903
|
+
metadata?: {
|
|
904
|
+
readonly [x: string]: string;
|
|
905
|
+
} | undefined;
|
|
906
|
+
safety_identifier?: string | undefined;
|
|
907
|
+
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
908
|
+
messages: ({
|
|
909
|
+
readonly role: "system";
|
|
910
|
+
readonly content: string | readonly ({
|
|
911
|
+
readonly type: "image_url";
|
|
912
|
+
readonly image_url: {
|
|
913
|
+
readonly url: string;
|
|
914
|
+
};
|
|
915
|
+
} | {
|
|
916
|
+
readonly type: "video_url";
|
|
917
|
+
readonly video_url: {
|
|
918
|
+
readonly url: string;
|
|
919
|
+
};
|
|
920
|
+
} | {
|
|
921
|
+
readonly type: "file";
|
|
922
|
+
readonly file: {
|
|
923
|
+
readonly filename: string;
|
|
924
|
+
readonly file_data: string;
|
|
925
|
+
};
|
|
926
|
+
} | {
|
|
927
|
+
readonly type: "text";
|
|
928
|
+
readonly text: string;
|
|
929
|
+
readonly cache_control?: {
|
|
930
|
+
readonly type: "ephemeral";
|
|
931
|
+
readonly ttl?: string | undefined;
|
|
932
|
+
} | undefined;
|
|
933
|
+
})[];
|
|
934
|
+
} | {
|
|
935
|
+
readonly role: "user";
|
|
936
|
+
readonly content: string | readonly ({
|
|
937
|
+
readonly type: "image_url";
|
|
938
|
+
readonly image_url: {
|
|
939
|
+
readonly url: string;
|
|
940
|
+
};
|
|
941
|
+
} | {
|
|
942
|
+
readonly type: "video_url";
|
|
943
|
+
readonly video_url: {
|
|
944
|
+
readonly url: string;
|
|
945
|
+
};
|
|
946
|
+
} | {
|
|
947
|
+
readonly type: "file";
|
|
948
|
+
readonly file: {
|
|
949
|
+
readonly filename: string;
|
|
950
|
+
readonly file_data: string;
|
|
951
|
+
};
|
|
952
|
+
} | {
|
|
953
|
+
readonly type: "text";
|
|
954
|
+
readonly text: string;
|
|
955
|
+
readonly cache_control?: {
|
|
956
|
+
readonly type: "ephemeral";
|
|
957
|
+
readonly ttl?: string | undefined;
|
|
958
|
+
} | undefined;
|
|
959
|
+
})[];
|
|
960
|
+
} | {
|
|
961
|
+
readonly role: "tool";
|
|
962
|
+
readonly tool_call_id: string;
|
|
963
|
+
readonly content: string | readonly {
|
|
964
|
+
readonly type: "text";
|
|
965
|
+
readonly text: string;
|
|
966
|
+
readonly cache_control?: {
|
|
967
|
+
readonly type: "ephemeral";
|
|
968
|
+
readonly ttl?: string | undefined;
|
|
969
|
+
} | undefined;
|
|
970
|
+
}[];
|
|
971
|
+
} | {
|
|
972
|
+
readonly [x: string]: unknown;
|
|
973
|
+
readonly role: "assistant";
|
|
974
|
+
readonly content: string | readonly {
|
|
975
|
+
readonly type: "text";
|
|
976
|
+
readonly text: string;
|
|
977
|
+
readonly cache_control?: {
|
|
978
|
+
readonly type: "ephemeral";
|
|
979
|
+
readonly ttl?: string | undefined;
|
|
980
|
+
} | undefined;
|
|
981
|
+
}[] | null;
|
|
982
|
+
readonly tool_calls?: readonly {
|
|
983
|
+
readonly id: string;
|
|
984
|
+
readonly type: "function";
|
|
985
|
+
readonly function: {
|
|
986
|
+
readonly name: string;
|
|
987
|
+
readonly arguments: string;
|
|
988
|
+
};
|
|
989
|
+
readonly extra_content?: {
|
|
990
|
+
readonly google: {
|
|
991
|
+
readonly thought_signature: string;
|
|
992
|
+
};
|
|
993
|
+
} | undefined;
|
|
994
|
+
}[] | undefined;
|
|
995
|
+
readonly reasoning_content?: string | undefined;
|
|
996
|
+
readonly reasoning?: string | undefined;
|
|
997
|
+
readonly reasoning_text?: string | undefined;
|
|
998
|
+
readonly reasoning_details?: unknown;
|
|
999
|
+
})[];
|
|
1000
|
+
tools: {
|
|
1001
|
+
readonly type: "function";
|
|
1002
|
+
readonly function: {
|
|
1003
|
+
readonly name: string;
|
|
1004
|
+
readonly description: string;
|
|
1005
|
+
readonly parameters: {
|
|
1006
|
+
readonly [x: string]: unknown;
|
|
1007
|
+
};
|
|
1008
|
+
readonly strict?: boolean | undefined;
|
|
1009
|
+
};
|
|
1010
|
+
readonly cache_control?: {
|
|
1011
|
+
readonly type: "ephemeral";
|
|
1012
|
+
readonly ttl?: string | undefined;
|
|
1013
|
+
} | undefined;
|
|
1014
|
+
}[] | undefined;
|
|
1015
|
+
tool_choice: "auto" | "none" | "required" | {
|
|
1016
|
+
type: "function";
|
|
1017
|
+
function: {
|
|
1018
|
+
name: string;
|
|
1019
|
+
};
|
|
1020
|
+
} | undefined;
|
|
1021
|
+
stream: true;
|
|
1022
|
+
stream_options?: {
|
|
1023
|
+
include_usage: boolean;
|
|
1024
|
+
} | undefined;
|
|
1025
|
+
tool_stream?: boolean | undefined;
|
|
1026
|
+
max_completion_tokens: number | undefined;
|
|
1027
|
+
temperature: number | undefined;
|
|
1028
|
+
top_p: number | undefined;
|
|
1029
|
+
frequency_penalty: number | undefined;
|
|
1030
|
+
presence_penalty: number | undefined;
|
|
1031
|
+
seed: number | undefined;
|
|
1032
|
+
stop: readonly string[] | undefined;
|
|
1033
|
+
} | {
|
|
1034
|
+
prompt_cache_retention?: undefined;
|
|
1035
|
+
prompt_cache_options?: undefined;
|
|
607
1036
|
store?: boolean | undefined;
|
|
608
1037
|
prompt_cache_key?: string | undefined;
|
|
609
1038
|
reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
@@ -733,7 +1162,146 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
733
1162
|
include_usage: boolean;
|
|
734
1163
|
} | undefined;
|
|
735
1164
|
tool_stream?: boolean | undefined;
|
|
736
|
-
|
|
1165
|
+
max_tokens: number | undefined;
|
|
1166
|
+
temperature: number | undefined;
|
|
1167
|
+
top_p: number | undefined;
|
|
1168
|
+
frequency_penalty: number | undefined;
|
|
1169
|
+
presence_penalty: number | undefined;
|
|
1170
|
+
seed: number | undefined;
|
|
1171
|
+
stop: readonly string[] | undefined;
|
|
1172
|
+
} | {
|
|
1173
|
+
prompt_cache_retention: string;
|
|
1174
|
+
prompt_cache_options?: undefined;
|
|
1175
|
+
store?: boolean | undefined;
|
|
1176
|
+
prompt_cache_key?: string | undefined;
|
|
1177
|
+
reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1178
|
+
verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1179
|
+
service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
1180
|
+
parallel_tool_calls?: boolean | undefined;
|
|
1181
|
+
metadata?: {
|
|
1182
|
+
readonly [x: string]: string;
|
|
1183
|
+
} | undefined;
|
|
1184
|
+
safety_identifier?: string | undefined;
|
|
1185
|
+
model: string & import("effect/Brand").Brand<"AI.ModelID">;
|
|
1186
|
+
messages: ({
|
|
1187
|
+
readonly role: "system";
|
|
1188
|
+
readonly content: string | readonly ({
|
|
1189
|
+
readonly type: "image_url";
|
|
1190
|
+
readonly image_url: {
|
|
1191
|
+
readonly url: string;
|
|
1192
|
+
};
|
|
1193
|
+
} | {
|
|
1194
|
+
readonly type: "video_url";
|
|
1195
|
+
readonly video_url: {
|
|
1196
|
+
readonly url: string;
|
|
1197
|
+
};
|
|
1198
|
+
} | {
|
|
1199
|
+
readonly type: "file";
|
|
1200
|
+
readonly file: {
|
|
1201
|
+
readonly filename: string;
|
|
1202
|
+
readonly file_data: string;
|
|
1203
|
+
};
|
|
1204
|
+
} | {
|
|
1205
|
+
readonly type: "text";
|
|
1206
|
+
readonly text: string;
|
|
1207
|
+
readonly cache_control?: {
|
|
1208
|
+
readonly type: "ephemeral";
|
|
1209
|
+
readonly ttl?: string | undefined;
|
|
1210
|
+
} | undefined;
|
|
1211
|
+
})[];
|
|
1212
|
+
} | {
|
|
1213
|
+
readonly role: "user";
|
|
1214
|
+
readonly content: string | readonly ({
|
|
1215
|
+
readonly type: "image_url";
|
|
1216
|
+
readonly image_url: {
|
|
1217
|
+
readonly url: string;
|
|
1218
|
+
};
|
|
1219
|
+
} | {
|
|
1220
|
+
readonly type: "video_url";
|
|
1221
|
+
readonly video_url: {
|
|
1222
|
+
readonly url: string;
|
|
1223
|
+
};
|
|
1224
|
+
} | {
|
|
1225
|
+
readonly type: "file";
|
|
1226
|
+
readonly file: {
|
|
1227
|
+
readonly filename: string;
|
|
1228
|
+
readonly file_data: string;
|
|
1229
|
+
};
|
|
1230
|
+
} | {
|
|
1231
|
+
readonly type: "text";
|
|
1232
|
+
readonly text: string;
|
|
1233
|
+
readonly cache_control?: {
|
|
1234
|
+
readonly type: "ephemeral";
|
|
1235
|
+
readonly ttl?: string | undefined;
|
|
1236
|
+
} | undefined;
|
|
1237
|
+
})[];
|
|
1238
|
+
} | {
|
|
1239
|
+
readonly role: "tool";
|
|
1240
|
+
readonly tool_call_id: string;
|
|
1241
|
+
readonly content: string | readonly {
|
|
1242
|
+
readonly type: "text";
|
|
1243
|
+
readonly text: string;
|
|
1244
|
+
readonly cache_control?: {
|
|
1245
|
+
readonly type: "ephemeral";
|
|
1246
|
+
readonly ttl?: string | undefined;
|
|
1247
|
+
} | undefined;
|
|
1248
|
+
}[];
|
|
1249
|
+
} | {
|
|
1250
|
+
readonly [x: string]: unknown;
|
|
1251
|
+
readonly role: "assistant";
|
|
1252
|
+
readonly content: string | readonly {
|
|
1253
|
+
readonly type: "text";
|
|
1254
|
+
readonly text: string;
|
|
1255
|
+
readonly cache_control?: {
|
|
1256
|
+
readonly type: "ephemeral";
|
|
1257
|
+
readonly ttl?: string | undefined;
|
|
1258
|
+
} | undefined;
|
|
1259
|
+
}[] | null;
|
|
1260
|
+
readonly tool_calls?: readonly {
|
|
1261
|
+
readonly id: string;
|
|
1262
|
+
readonly type: "function";
|
|
1263
|
+
readonly function: {
|
|
1264
|
+
readonly name: string;
|
|
1265
|
+
readonly arguments: string;
|
|
1266
|
+
};
|
|
1267
|
+
readonly extra_content?: {
|
|
1268
|
+
readonly google: {
|
|
1269
|
+
readonly thought_signature: string;
|
|
1270
|
+
};
|
|
1271
|
+
} | undefined;
|
|
1272
|
+
}[] | undefined;
|
|
1273
|
+
readonly reasoning_content?: string | undefined;
|
|
1274
|
+
readonly reasoning?: string | undefined;
|
|
1275
|
+
readonly reasoning_text?: string | undefined;
|
|
1276
|
+
readonly reasoning_details?: unknown;
|
|
1277
|
+
})[];
|
|
1278
|
+
tools: {
|
|
1279
|
+
readonly type: "function";
|
|
1280
|
+
readonly function: {
|
|
1281
|
+
readonly name: string;
|
|
1282
|
+
readonly description: string;
|
|
1283
|
+
readonly parameters: {
|
|
1284
|
+
readonly [x: string]: unknown;
|
|
1285
|
+
};
|
|
1286
|
+
readonly strict?: boolean | undefined;
|
|
1287
|
+
};
|
|
1288
|
+
readonly cache_control?: {
|
|
1289
|
+
readonly type: "ephemeral";
|
|
1290
|
+
readonly ttl?: string | undefined;
|
|
1291
|
+
} | undefined;
|
|
1292
|
+
}[] | undefined;
|
|
1293
|
+
tool_choice: "auto" | "none" | "required" | {
|
|
1294
|
+
type: "function";
|
|
1295
|
+
function: {
|
|
1296
|
+
name: string;
|
|
1297
|
+
};
|
|
1298
|
+
} | undefined;
|
|
1299
|
+
stream: true;
|
|
1300
|
+
stream_options?: {
|
|
1301
|
+
include_usage: boolean;
|
|
1302
|
+
} | undefined;
|
|
1303
|
+
tool_stream?: boolean | undefined;
|
|
1304
|
+
max_tokens: number | undefined;
|
|
737
1305
|
temperature: number | undefined;
|
|
738
1306
|
top_p: number | undefined;
|
|
739
1307
|
frequency_penalty: number | undefined;
|
|
@@ -741,6 +1309,10 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
741
1309
|
seed: number | undefined;
|
|
742
1310
|
stop: readonly string[] | undefined;
|
|
743
1311
|
} | {
|
|
1312
|
+
prompt_cache_retention?: undefined;
|
|
1313
|
+
prompt_cache_options: {
|
|
1314
|
+
ttl: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s`;
|
|
1315
|
+
};
|
|
744
1316
|
store?: boolean | undefined;
|
|
745
1317
|
prompt_cache_key?: string | undefined;
|
|
746
1318
|
reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
@@ -881,6 +1453,9 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
|
|
|
881
1453
|
export declare const finishEvents: (state: ParserState) => Effect.Effect<({
|
|
882
1454
|
readonly type: "step-start";
|
|
883
1455
|
readonly index: number;
|
|
1456
|
+
} | {
|
|
1457
|
+
readonly type: "raw";
|
|
1458
|
+
readonly data: unknown;
|
|
884
1459
|
} | {
|
|
885
1460
|
readonly type: "text-start";
|
|
886
1461
|
readonly id: string;
|
|
@@ -1221,6 +1796,10 @@ export declare const protocol: Protocol<{
|
|
|
1221
1796
|
} | undefined;
|
|
1222
1797
|
readonly store?: boolean | undefined;
|
|
1223
1798
|
readonly prompt_cache_key?: string | undefined;
|
|
1799
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
1800
|
+
readonly prompt_cache_options?: {
|
|
1801
|
+
readonly ttl?: string | undefined;
|
|
1802
|
+
} | undefined;
|
|
1224
1803
|
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1225
1804
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1226
1805
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
@@ -1433,6 +2012,10 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
1433
2012
|
} | undefined;
|
|
1434
2013
|
readonly store?: boolean | undefined;
|
|
1435
2014
|
readonly prompt_cache_key?: string | undefined;
|
|
2015
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
2016
|
+
readonly prompt_cache_options?: {
|
|
2017
|
+
readonly ttl?: string | undefined;
|
|
2018
|
+
} | undefined;
|
|
1436
2019
|
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1437
2020
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1438
2021
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
@@ -1572,6 +2155,10 @@ export declare const route: Route<{
|
|
|
1572
2155
|
} | undefined;
|
|
1573
2156
|
readonly store?: boolean | undefined;
|
|
1574
2157
|
readonly prompt_cache_key?: string | undefined;
|
|
2158
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
2159
|
+
readonly prompt_cache_options?: {
|
|
2160
|
+
readonly ttl?: string | undefined;
|
|
2161
|
+
} | undefined;
|
|
1575
2162
|
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1576
2163
|
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
1577
2164
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
@@ -9,7 +9,8 @@ import { Protocol } from "../route/protocol.js";
|
|
|
9
9
|
import { AIError, AIErrorReason, InvalidProviderOutputError, LLMEvent, ProviderInternalError, UnknownProviderError, Usage, } from "../schema/index.js";
|
|
10
10
|
import { classifyProviderFailure } from "../provider-error.js";
|
|
11
11
|
import { isRecord, JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
12
|
-
import {
|
|
12
|
+
import { placesMarkers, requestTTL } from "../cache-policy.js";
|
|
13
|
+
import * as Cache from "./utils/cache.js";
|
|
13
14
|
import { resolveParallelToolCalls } from "./open-responses.js";
|
|
14
15
|
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
15
16
|
import { Lifecycle } from "./utils/lifecycle.js";
|
|
@@ -140,6 +141,8 @@ export const bodyFields = {
|
|
|
140
141
|
stream_options: Schema.optional(Schema.Struct({ include_usage: Schema.Boolean })),
|
|
141
142
|
store: Schema.optional(Schema.Boolean),
|
|
142
143
|
prompt_cache_key: Schema.optional(Schema.String),
|
|
144
|
+
prompt_cache_retention: Schema.optional(Schema.String),
|
|
145
|
+
prompt_cache_options: Schema.optional(Schema.Struct({ ttl: Schema.optional(Schema.String) })),
|
|
143
146
|
reasoning_effort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
|
|
144
147
|
verbosity: Schema.optional(OpenResponsesOptions.TextVerbositySchema),
|
|
145
148
|
service_tier: Schema.optional(OpenResponsesOptions.ServiceTierSchema),
|
|
@@ -610,6 +613,8 @@ const lowerOptions = (request, supportsStore, hasActiveTools) => {
|
|
|
610
613
|
return {
|
|
611
614
|
...(supportsStore ? { store: options.store ?? false } : {}),
|
|
612
615
|
...(cacheKey ? { prompt_cache_key: cacheKey } : {}),
|
|
616
|
+
// Inline markers carry the lifetime when the policy places them.
|
|
617
|
+
...(placesMarkers(request) ? {} : Cache.openAIRequestTTL(requestTTL(request))),
|
|
613
618
|
...(options.reasoningEffort ? { reasoning_effort: options.reasoningEffort } : {}),
|
|
614
619
|
...(options.textVerbosity ? { verbosity: options.textVerbosity } : {}),
|
|
615
620
|
...(options.serviceTier ? { service_tier: options.serviceTier } : {}),
|
|
@@ -661,7 +666,7 @@ export const fromRequest = Effect.fn("OpenAIChat.fromRequest")(function* (reques
|
|
|
661
666
|
};
|
|
662
667
|
});
|
|
663
668
|
// Provider wrappers that pass their own marker writer keep it; otherwise a declared cache format adds one.
|
|
664
|
-
const declaredCacheControl = (request) => request.model.compatibility?.cacheFormat === undefined ? undefined : cacheControl();
|
|
669
|
+
const declaredCacheControl = (request) => request.model.compatibility?.cacheFormat === undefined ? undefined : Cache.cacheControl();
|
|
665
670
|
// =============================================================================
|
|
666
671
|
// Stream Parsing
|
|
667
672
|
// =============================================================================
|