@opencode/ai 2.1.2 → 2.1.4

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 (140) hide show
  1. package/dist/cache-policy.js +6 -5
  2. package/dist/experimental/evaluation.d.ts +7 -6
  3. package/dist/experimental/evaluation.js +3 -11
  4. package/dist/experimental/realtime.d.ts +59 -0
  5. package/dist/experimental/realtime.js +21 -13
  6. package/dist/experimental.d.ts +1 -1
  7. package/dist/generation.js +1 -1
  8. package/dist/image-client.d.ts +11 -9
  9. package/dist/image.d.ts +158 -150
  10. package/dist/image.js +2 -2
  11. package/dist/llm.d.ts +2 -4
  12. package/dist/llm.js +2 -2
  13. package/dist/media-model.d.ts +2 -2
  14. package/dist/media-model.js +1 -1
  15. package/dist/promise.d.ts +121 -121
  16. package/dist/promise.js +3 -5
  17. package/dist/protocols/alibaba-chat.d.ts +18 -18
  18. package/dist/protocols/alibaba-chat.js +3 -3
  19. package/dist/protocols/alibaba-messages.d.ts +12 -12
  20. package/dist/protocols/alibaba-messages.js +1 -1
  21. package/dist/protocols/alibaba-responses.d.ts +38 -38
  22. package/dist/protocols/anthropic-messages.d.ts +40 -44
  23. package/dist/protocols/anthropic-messages.js +13 -15
  24. package/dist/protocols/bedrock-converse.d.ts +36 -85
  25. package/dist/protocols/bedrock-converse.js +6 -6
  26. package/dist/protocols/bedrock-event-stream.d.ts +6 -1
  27. package/dist/protocols/bedrock-event-stream.js +9 -8
  28. package/dist/protocols/cartesia-speech.d.ts +32 -32
  29. package/dist/protocols/cohere-chat.d.ts +13 -10
  30. package/dist/protocols/cohere-chat.js +2 -2
  31. package/dist/protocols/deepgram-speech.d.ts +32 -32
  32. package/dist/protocols/elevenlabs-speech.d.ts +32 -32
  33. package/dist/protocols/gemini.d.ts +46 -36
  34. package/dist/protocols/gemini.js +12 -15
  35. package/dist/protocols/google-interactions.d.ts +14 -13
  36. package/dist/protocols/google-interactions.js +16 -11
  37. package/dist/protocols/google-speech.d.ts +32 -32
  38. package/dist/protocols/google-transcription.d.ts +32 -32
  39. package/dist/protocols/meta-messages.d.ts +23 -23
  40. package/dist/protocols/meta-responses.d.ts +84 -84
  41. package/dist/protocols/mistral-chat.d.ts +81 -78
  42. package/dist/protocols/mistral-chat.js +3 -5
  43. package/dist/protocols/open-responses-channel.js +47 -46
  44. package/dist/protocols/open-responses-continuation.d.ts +8 -2
  45. package/dist/protocols/open-responses-continuation.js +3 -1
  46. package/dist/protocols/open-responses.d.ts +419 -419
  47. package/dist/protocols/open-responses.js +11 -10
  48. package/dist/protocols/openai-chat.d.ts +68 -67
  49. package/dist/protocols/openai-chat.js +7 -8
  50. package/dist/protocols/openai-compatible-chat.d.ts +13 -14
  51. package/dist/protocols/openai-compatible-responses.d.ts +39 -40
  52. package/dist/protocols/openai-images.d.ts +32 -32
  53. package/dist/protocols/openai-responses.d.ts +253 -253
  54. package/dist/protocols/openai-responses.js +1 -1
  55. package/dist/protocols/openai-speech.d.ts +32 -32
  56. package/dist/protocols/openai-transcription.d.ts +32 -32
  57. package/dist/protocols/openai-transcription.js +12 -7
  58. package/dist/protocols/utils/open-responses-options.d.ts +8 -8
  59. package/dist/protocols/utils/open-responses-options.js +4 -6
  60. package/dist/protocols/utils/partial-json-options.d.ts +0 -1
  61. package/dist/protocols/utils/partial-json-options.js +0 -1
  62. package/dist/protocols/utils/partial-json.js +5 -4
  63. package/dist/protocols/utils/tool-schema.d.ts +0 -3
  64. package/dist/protocols/utils/tool-schema.js +0 -4
  65. package/dist/protocols/utils/tool-stream.d.ts +1 -1
  66. package/dist/protocols/venice-chat.d.ts +52 -53
  67. package/dist/protocols/venice-chat.js +6 -5
  68. package/dist/protocols/xai-images.js +3 -4
  69. package/dist/protocols/xai-responses.d.ts +81 -81
  70. package/dist/protocols/zai-chat.d.ts +33 -30
  71. package/dist/protocols/zai-chat.js +8 -3
  72. package/dist/protocols/zai-messages.d.ts +21 -19
  73. package/dist/protocols/zai-messages.js +3 -2
  74. package/dist/provider-error.js +8 -7
  75. package/dist/providers/alibaba.d.ts +74 -74
  76. package/dist/providers/amazon-bedrock-mantle.d.ts +202 -202
  77. package/dist/providers/amazon-bedrock.d.ts +16 -13
  78. package/dist/providers/anthropic-compatible.d.ts +13 -13
  79. package/dist/providers/anthropic.d.ts +13 -13
  80. package/dist/providers/azure.d.ts +112 -112
  81. package/dist/providers/baseten.d.ts +24 -24
  82. package/dist/providers/cerebras.d.ts +24 -24
  83. package/dist/providers/cloudflare-ai-gateway.d.ts +237 -234
  84. package/dist/providers/cloudflare-ai-gateway.js +3 -6
  85. package/dist/providers/cloudflare-workers-ai.d.ts +24 -24
  86. package/dist/providers/cohere.d.ts +78 -74
  87. package/dist/providers/deepinfra.d.ts +24 -24
  88. package/dist/providers/deepseek.d.ts +24 -24
  89. package/dist/providers/digitalocean.d.ts +36 -36
  90. package/dist/providers/fireworks.d.ts +24 -24
  91. package/dist/providers/google-vertex-chat.d.ts +12 -12
  92. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  93. package/dist/providers/google-vertex-messages.d.ts +20 -20
  94. package/dist/providers/google-vertex-mistral.d.ts +14 -14
  95. package/dist/providers/google-vertex-responses.d.ts +38 -38
  96. package/dist/providers/google-vertex.d.ts +17 -17
  97. package/dist/providers/google-vertex.js +2 -2
  98. package/dist/providers/google.d.ts +79 -79
  99. package/dist/providers/groq.d.ts +24 -24
  100. package/dist/providers/meta.d.ts +189 -189
  101. package/dist/providers/minimax.d.ts +202 -202
  102. package/dist/providers/mistral.d.ts +28 -28
  103. package/dist/providers/moonshot.d.ts +202 -202
  104. package/dist/providers/open-responses-options.d.ts +0 -1
  105. package/dist/providers/open-responses-options.js +1 -1
  106. package/dist/providers/openai-compatible-responses.d.ts +38 -38
  107. package/dist/providers/openai-compatible.d.ts +12 -12
  108. package/dist/providers/openai-compatible.js +1 -1
  109. package/dist/providers/openai-options.d.ts +3 -4
  110. package/dist/providers/openai-options.js +0 -1
  111. package/dist/providers/openai.d.ts +103 -103
  112. package/dist/providers/openrouter.d.ts +171 -112
  113. package/dist/providers/openrouter.js +40 -33
  114. package/dist/providers/togetherai.d.ts +24 -24
  115. package/dist/providers/venice.d.ts +195 -20
  116. package/dist/providers/xai.d.ts +12 -12
  117. package/dist/providers/zai-coding-plan.d.ts +152 -72
  118. package/dist/providers/zai.d.ts +84 -19
  119. package/dist/route/auth-options.d.ts +0 -3
  120. package/dist/route/auth.d.ts +0 -2
  121. package/dist/route/auth.js +0 -2
  122. package/dist/route/client.d.ts +0 -218
  123. package/dist/route/client.js +3 -7
  124. package/dist/route/executor-service.js +1 -1
  125. package/dist/route/transport/http.js +5 -8
  126. package/dist/schema/errors.d.ts +1 -1
  127. package/dist/schema/errors.js +1 -1
  128. package/dist/schema/messages.js +4 -7
  129. package/dist/speech-client.d.ts +11 -9
  130. package/dist/speech.d.ts +158 -150
  131. package/dist/speech.js +2 -2
  132. package/dist/transcription-client.d.ts +11 -9
  133. package/dist/transcription.d.ts +158 -150
  134. package/dist/transcription.js +2 -2
  135. package/dist/video-client.d.ts +11 -9
  136. package/dist/video.d.ts +124 -116
  137. package/dist/video.js +2 -2
  138. package/package.json +7 -6
  139. package/dist/protocols/utils/openai-options.d.ts +0 -16
  140. package/dist/protocols/utils/openai-options.js +0 -15
@@ -170,7 +170,7 @@ const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request)
170
170
  tools: request.tools.length === 0 ? undefined : yield* lowerTools(request),
171
171
  tool_choice: request.tools.length === 0
172
172
  ? undefined
173
- : (OpenResponses.allowedToolChoice(request) ??
173
+ : (OpenResponses.allowedToolChoice(request, options) ??
174
174
  (request.toolChoice ? yield* lowerToolChoice(request.toolChoice, request.tools) : undefined)),
175
175
  };
176
176
  });
@@ -16,14 +16,6 @@ interface State extends SpeechStream.Audio {
16
16
  readonly usage?: MediaUsage;
17
17
  }
18
18
  export declare const protocol: MediaProtocol.Streamed<Request, {
19
- readonly type: "generation-queued";
20
- readonly id: string;
21
- readonly position?: number | undefined;
22
- } | {
23
- readonly type: "generation-progress";
24
- readonly id: string;
25
- readonly progress?: number | undefined;
26
- } | {
27
19
  readonly type: "audio-delta";
28
20
  readonly chunk: Uint8Array<ArrayBufferLike>;
29
21
  } | {
@@ -33,18 +25,18 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
33
25
  readonly startSeconds: number;
34
26
  readonly endSeconds: number;
35
27
  }[];
28
+ } | {
29
+ readonly type: "generation-queued";
30
+ readonly id: string;
31
+ readonly position?: number | undefined;
32
+ } | {
33
+ readonly type: "generation-progress";
34
+ readonly id: string;
35
+ readonly progress?: number | undefined;
36
36
  } | {
37
37
  readonly type: "finish";
38
38
  readonly audio: import("../media.js").Asset;
39
39
  readonly usage?: {
40
- readonly type: "tokens";
41
- readonly input?: number | undefined;
42
- readonly output?: number | undefined;
43
- readonly total?: number | undefined;
44
- readonly details?: {
45
- readonly [x: string]: unknown;
46
- } | undefined;
47
- } | {
48
40
  readonly type: "seconds";
49
41
  readonly seconds: number;
50
42
  } | {
@@ -56,6 +48,14 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
56
48
  } | {
57
49
  readonly type: "compute";
58
50
  readonly seconds: number;
51
+ } | {
52
+ readonly type: "tokens";
53
+ readonly input?: number | undefined;
54
+ readonly output?: number | undefined;
55
+ readonly total?: number | undefined;
56
+ readonly details?: {
57
+ readonly [x: string]: unknown;
58
+ } | undefined;
59
59
  } | undefined;
60
60
  readonly notices?: readonly {
61
61
  readonly type: "filtered" | "moderated" | "other";
@@ -75,14 +75,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
75
75
  export declare const model: (input: MediaRoute.ModelInput) => SpeechModel<OpenAISpeechOptions>;
76
76
  export declare const OpenAISpeech: {
77
77
  readonly protocol: MediaProtocol.Streamed<Request, {
78
- readonly type: "generation-queued";
79
- readonly id: string;
80
- readonly position?: number | undefined;
81
- } | {
82
- readonly type: "generation-progress";
83
- readonly id: string;
84
- readonly progress?: number | undefined;
85
- } | {
86
78
  readonly type: "audio-delta";
87
79
  readonly chunk: Uint8Array<ArrayBufferLike>;
88
80
  } | {
@@ -92,18 +84,18 @@ export declare const OpenAISpeech: {
92
84
  readonly startSeconds: number;
93
85
  readonly endSeconds: number;
94
86
  }[];
87
+ } | {
88
+ readonly type: "generation-queued";
89
+ readonly id: string;
90
+ readonly position?: number | undefined;
91
+ } | {
92
+ readonly type: "generation-progress";
93
+ readonly id: string;
94
+ readonly progress?: number | undefined;
95
95
  } | {
96
96
  readonly type: "finish";
97
97
  readonly audio: import("../media.js").Asset;
98
98
  readonly usage?: {
99
- readonly type: "tokens";
100
- readonly input?: number | undefined;
101
- readonly output?: number | undefined;
102
- readonly total?: number | undefined;
103
- readonly details?: {
104
- readonly [x: string]: unknown;
105
- } | undefined;
106
- } | {
107
99
  readonly type: "seconds";
108
100
  readonly seconds: number;
109
101
  } | {
@@ -115,6 +107,14 @@ export declare const OpenAISpeech: {
115
107
  } | {
116
108
  readonly type: "compute";
117
109
  readonly seconds: number;
110
+ } | {
111
+ readonly type: "tokens";
112
+ readonly input?: number | undefined;
113
+ readonly output?: number | undefined;
114
+ readonly total?: number | undefined;
115
+ readonly details?: {
116
+ readonly [x: string]: unknown;
117
+ } | undefined;
118
118
  } | undefined;
119
119
  readonly notices?: readonly {
120
120
  readonly type: "filtered" | "moderated" | "other";
@@ -59,14 +59,6 @@ interface State {
59
59
  readonly transcript?: Transcript;
60
60
  }
61
61
  export declare const protocol: MediaProtocol.Streamed<Request, {
62
- readonly type: "generation-queued";
63
- readonly id: string;
64
- readonly position?: number | undefined;
65
- } | {
66
- readonly type: "generation-progress";
67
- readonly id: string;
68
- readonly progress?: number | undefined;
69
- } | {
70
62
  readonly type: "text-delta";
71
63
  readonly delta: string;
72
64
  } | {
@@ -77,6 +69,14 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
77
69
  readonly endSeconds: number;
78
70
  readonly speaker?: string | undefined;
79
71
  };
72
+ } | {
73
+ readonly type: "generation-queued";
74
+ readonly id: string;
75
+ readonly position?: number | undefined;
76
+ } | {
77
+ readonly type: "generation-progress";
78
+ readonly id: string;
79
+ readonly progress?: number | undefined;
80
80
  } | {
81
81
  readonly text: string;
82
82
  readonly segments?: readonly {
@@ -95,14 +95,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
95
95
  readonly language?: string | undefined;
96
96
  readonly durationSeconds?: number | undefined;
97
97
  readonly usage?: {
98
- readonly type: "tokens";
99
- readonly input?: number | undefined;
100
- readonly output?: number | undefined;
101
- readonly total?: number | undefined;
102
- readonly details?: {
103
- readonly [x: string]: unknown;
104
- } | undefined;
105
- } | {
106
98
  readonly type: "seconds";
107
99
  readonly seconds: number;
108
100
  } | {
@@ -114,6 +106,14 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
114
106
  } | {
115
107
  readonly type: "compute";
116
108
  readonly seconds: number;
109
+ } | {
110
+ readonly type: "tokens";
111
+ readonly input?: number | undefined;
112
+ readonly output?: number | undefined;
113
+ readonly total?: number | undefined;
114
+ readonly details?: {
115
+ readonly [x: string]: unknown;
116
+ } | undefined;
117
117
  } | undefined;
118
118
  readonly notices?: readonly {
119
119
  readonly type: "filtered" | "moderated" | "other";
@@ -134,14 +134,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
134
134
  export declare const model: (input: MediaRoute.ModelInput) => TranscriptionModel<OpenAITranscriptionOptions>;
135
135
  export declare const OpenAITranscription: {
136
136
  readonly protocol: MediaProtocol.Streamed<Request, {
137
- readonly type: "generation-queued";
138
- readonly id: string;
139
- readonly position?: number | undefined;
140
- } | {
141
- readonly type: "generation-progress";
142
- readonly id: string;
143
- readonly progress?: number | undefined;
144
- } | {
145
137
  readonly type: "text-delta";
146
138
  readonly delta: string;
147
139
  } | {
@@ -152,6 +144,14 @@ export declare const OpenAITranscription: {
152
144
  readonly endSeconds: number;
153
145
  readonly speaker?: string | undefined;
154
146
  };
147
+ } | {
148
+ readonly type: "generation-queued";
149
+ readonly id: string;
150
+ readonly position?: number | undefined;
151
+ } | {
152
+ readonly type: "generation-progress";
153
+ readonly id: string;
154
+ readonly progress?: number | undefined;
155
155
  } | {
156
156
  readonly text: string;
157
157
  readonly segments?: readonly {
@@ -170,14 +170,6 @@ export declare const OpenAITranscription: {
170
170
  readonly language?: string | undefined;
171
171
  readonly durationSeconds?: number | undefined;
172
172
  readonly usage?: {
173
- readonly type: "tokens";
174
- readonly input?: number | undefined;
175
- readonly output?: number | undefined;
176
- readonly total?: number | undefined;
177
- readonly details?: {
178
- readonly [x: string]: unknown;
179
- } | undefined;
180
- } | {
181
173
  readonly type: "seconds";
182
174
  readonly seconds: number;
183
175
  } | {
@@ -189,6 +181,14 @@ export declare const OpenAITranscription: {
189
181
  } | {
190
182
  readonly type: "compute";
191
183
  readonly seconds: number;
184
+ } | {
185
+ readonly type: "tokens";
186
+ readonly input?: number | undefined;
187
+ readonly output?: number | undefined;
188
+ readonly total?: number | undefined;
189
+ readonly details?: {
190
+ readonly [x: string]: unknown;
191
+ } | undefined;
192
192
  } | undefined;
193
193
  readonly notices?: readonly {
194
194
  readonly type: "filtered" | "moderated" | "other";
@@ -1,4 +1,4 @@
1
- import { Effect, Schema, Stream } from "effect";
1
+ import { Effect, Schema, SchemaGetter, Stream } from "effect";
2
2
  import { classifyProviderFailure } from "../provider-error.js";
3
3
  import { Framing } from "../route/framing.js";
4
4
  import { MediaProtocol } from "../route/media-protocol.js";
@@ -39,8 +39,14 @@ const transcriptFields = {
39
39
  words: Schema.optional(Schema.Array(Schema.Struct({ word: Schema.String, start: Schema.Number, end: Schema.Number }))),
40
40
  usage: Schema.optional(Usage),
41
41
  };
42
- /** OpenAI may add stream event types; frames outside `EVENT_TYPES` are ignored. */
43
- const EventType = Schema.Struct({ type: Schema.String });
42
+ const EVENT_TYPES = new Set(["transcript.text.delta", "transcript.text.segment", "transcript.text.done", "error"]);
43
+ /** OpenAI may add stream event types; frames outside `EVENT_TYPES` are ignored, while a malformed known type still fails decoding. */
44
+ const UnknownEvent = Schema.Struct({
45
+ type: Schema.String.check(Schema.makeFilter((type) => !EVENT_TYPES.has(type))),
46
+ }).pipe(Schema.decodeTo(Schema.Struct({ type: Schema.Literal("unknown"), rawType: Schema.String }), {
47
+ decode: SchemaGetter.transform((event) => ({ type: "unknown", rawType: event.type })),
48
+ encode: SchemaGetter.forbidden(() => "Unknown OpenAI Transcription stream events are decode-only"),
49
+ }));
44
50
  const Event = Schema.Union([
45
51
  Schema.Struct({ type: Schema.Literal("transcript.text.delta"), delta: Schema.String }),
46
52
  Schema.Struct({ type: Schema.Literal("transcript.text.segment"), ...Segment.fields }),
@@ -50,10 +56,9 @@ const Event = Schema.Union([
50
56
  message: Schema.optional(Schema.String),
51
57
  error: Schema.optional(Schema.Struct({ message: Schema.optional(Schema.String) })),
52
58
  }),
59
+ UnknownEvent,
53
60
  ]);
54
- const EVENT_TYPES = new Set(["transcript.text.delta", "transcript.text.segment", "transcript.text.done", "error"]);
55
61
  const Transcript = Schema.Struct(transcriptFields);
56
- const decodeEventType = route.decodeFrame(EventType);
57
62
  const decodeEvent = route.decodeFrame(Event);
58
63
  const decodeTranscript = route.decodeFrame(Transcript);
59
64
  const TRANSCRIBE = { stream: true, timestamps: [], diarize: false, languageField: "language" };
@@ -132,9 +137,9 @@ const segment = (value) => ({
132
137
  speaker: value.speaker,
133
138
  });
134
139
  const onEvent = Effect.fnUntraced(function* (state, frame) {
135
- if (!EVENT_TYPES.has((yield* decodeEventType(frame)).type))
136
- return [state, []];
137
140
  const event = yield* decodeEvent(frame);
141
+ if (event.type === "unknown")
142
+ return [state, []];
138
143
  if (event.type === "error")
139
144
  return yield* new AIError({
140
145
  reason: classifyProviderFailure({
@@ -3,17 +3,17 @@ import { ReasoningEffort, ReasoningEfforts, type LLMRequest } from "../../schema
3
3
  export { ReasoningEffort, ReasoningEfforts };
4
4
  export declare const TextVerbosities: readonly ["low", "medium", "high"];
5
5
  export type TextVerbosity = (typeof TextVerbosities)[number] | (string & {});
6
- export declare const TextVerbosity: Schema.declare<TextVerbosity, TextVerbosity>;
6
+ export declare const TextVerbosity: Schema.declare<import("../../schema/options.js").OpenString<"high" | "low" | "medium">, import("../../schema/options.js").OpenString<"high" | "low" | "medium">>;
7
7
  export declare const ResponseIncludables: readonly ["file_search_call.results", "web_search_call.results", "web_search_call.action.sources", "message.input_image.image_url", "computer_call_output.output.image_url", "code_interpreter_call.outputs", "reasoning.encrypted_content", "message.output_text.logprobs"];
8
8
  export type ResponseIncludable = (typeof ResponseIncludables)[number] | (string & {});
9
9
  export declare const ServiceTiers: readonly ["auto", "default", "flex", "priority"];
10
10
  export type ServiceTier = (typeof ServiceTiers)[number] | (string & {});
11
- export declare const ServiceTier: Schema.declare<ServiceTier, ServiceTier>;
11
+ export declare const ServiceTier: Schema.declare<import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>;
12
12
  export declare const Truncations: readonly ["auto", "disabled"];
13
13
  export type Truncation = (typeof Truncations)[number];
14
- export declare const TextVerbositySchema: Schema.declare<TextVerbosity, TextVerbosity>;
15
- export declare const ResponseIncludableSchema: Schema.declare<ResponseIncludable, ResponseIncludable>;
16
- export declare const ServiceTierSchema: Schema.declare<ServiceTier, ServiceTier>;
14
+ export declare const TextVerbositySchema: Schema.declare<import("../../schema/options.js").OpenString<"high" | "low" | "medium">, import("../../schema/options.js").OpenString<"high" | "low" | "medium">>;
15
+ export declare const ResponseIncludableSchema: Schema.declare<import("../../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">, import("../../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">>;
16
+ export declare const ServiceTierSchema: Schema.declare<import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>;
17
17
  export declare const TruncationSchema: Schema.Literals<readonly ["auto", "disabled"]>;
18
18
  export declare const AllowedTools: Schema.Struct<{
19
19
  readonly toolNames: Schema.$Array<Schema.String>;
@@ -33,9 +33,9 @@ export declare const Options: Schema.Struct<{
33
33
  readonly topLogprobs: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Int>, never>>;
34
34
  readonly reasoningEffort: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<ReasoningEffort, ReasoningEffort>>, never>>;
35
35
  readonly reasoningSummary: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Literals<readonly ["auto", "concise", "detailed"]>>, never>>;
36
- readonly include: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.$Array<Schema.declare<ResponseIncludable, ResponseIncludable>>>, never>>;
37
- readonly textVerbosity: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<TextVerbosity, TextVerbosity>>, never>>;
38
- readonly serviceTier: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<ServiceTier, ServiceTier>>, never>>;
36
+ readonly include: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.$Array<Schema.declare<import("../../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">, import("../../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">>>>, never>>;
37
+ readonly textVerbosity: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../../schema/options.js").OpenString<"high" | "low" | "medium">, import("../../schema/options.js").OpenString<"high" | "low" | "medium">>>, never>>;
38
+ readonly serviceTier: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">, import("../../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority">>>, never>>;
39
39
  readonly truncation: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Literals<readonly ["auto", "disabled"]>>, never>>;
40
40
  readonly allowedTools: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Struct<{
41
41
  readonly toolNames: Schema.$Array<Schema.String>;
@@ -1,9 +1,9 @@
1
1
  import { Schema } from "effect";
2
2
  import { ReasoningEffort, ReasoningEfforts } from "../../schema/index.js";
3
- import { lenient } from "../shared.js";
3
+ import { lenient, ProviderShared } from "../shared.js";
4
4
  export { ReasoningEffort, ReasoningEfforts };
5
5
  export const TextVerbosities = ["low", "medium", "high"];
6
- export const TextVerbosity = Schema.declare((value) => typeof value === "string", { title: "TextVerbosity" });
6
+ export const TextVerbosity = ProviderShared.knownString();
7
7
  export const ResponseIncludables = [
8
8
  "file_search_call.results",
9
9
  "web_search_call.results",
@@ -15,12 +15,10 @@ export const ResponseIncludables = [
15
15
  "message.output_text.logprobs",
16
16
  ];
17
17
  export const ServiceTiers = ["auto", "default", "flex", "priority"];
18
- export const ServiceTier = Schema.declare((value) => typeof value === "string", {
19
- title: "ServiceTier",
20
- });
18
+ export const ServiceTier = ProviderShared.knownString();
21
19
  export const Truncations = ["auto", "disabled"];
22
20
  export const TextVerbositySchema = TextVerbosity;
23
- export const ResponseIncludableSchema = Schema.declare((value) => typeof value === "string", { title: "ResponseIncludable" });
21
+ export const ResponseIncludableSchema = ProviderShared.knownString();
24
22
  export const ServiceTierSchema = ServiceTier;
25
23
  export const TruncationSchema = Schema.Literals(Truncations);
26
24
  export const AllowedTools = Schema.Struct({
@@ -59,4 +59,3 @@ export declare const Allow: {
59
59
  COLLECTION: number;
60
60
  ALL: number;
61
61
  };
62
- export default Allow;
@@ -49,4 +49,3 @@ export const ALL = ATOM | COLLECTION;
49
49
  * The default is to allow all types to be partially parsed, which in most cases is the best option.
50
50
  */
51
51
  export const Allow = { STR, NUM, ARR, OBJ, NULL, BOOL, NAN, INFINITY, _INFINITY, INF, SPECIAL, ATOM, COLLECTION, ALL };
52
- export default Allow;
@@ -25,13 +25,14 @@
25
25
  * SOFTWARE.
26
26
  */
27
27
  import { Schema } from "effect";
28
+ import { decodeJson } from "../../utils/json.js";
28
29
  import { Allow } from "./partial-json-options.js";
29
30
  export * from "./partial-json-options.js";
30
31
  export class PartialJSON extends Error {
31
32
  }
32
33
  export class MalformedJSON extends Error {
33
34
  }
34
- const decodeJson = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.Unknown));
35
+ const decodeJsonString = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.String));
35
36
  /** Parse complete or incomplete JSON, restricted by the supplied partial-value flags. */
36
37
  export function parseJSON(jsonString, allowPartial = Allow.ALL) {
37
38
  if (typeof jsonString !== "string")
@@ -159,7 +160,7 @@ const _parseJSON = (jsonString, allow) => {
159
160
  }
160
161
  if (jsonString.charAt(index) === '"') {
161
162
  try {
162
- return decodeJson(jsonString.substring(start, ++index - Number(escape)));
163
+ return decodeJsonString(jsonString.substring(start, ++index - Number(escape)));
163
164
  }
164
165
  catch (error) {
165
166
  throwMalformedError(String(error));
@@ -167,10 +168,10 @@ const _parseJSON = (jsonString, allow) => {
167
168
  }
168
169
  if (Allow.STR & allow) {
169
170
  try {
170
- return decodeJson(`${jsonString.substring(start, index - Number(escape))}"`);
171
+ return decodeJsonString(`${jsonString.substring(start, index - Number(escape))}"`);
171
172
  }
172
173
  catch {
173
- return decodeJson(`${jsonString.substring(start, jsonString.lastIndexOf("\\"))}"`);
174
+ return decodeJsonString(`${jsonString.substring(start, jsonString.lastIndexOf("\\"))}"`);
174
175
  }
175
176
  }
176
177
  return markPartialJSON("Unterminated string literal");
@@ -1,13 +1,10 @@
1
1
  import { type JsonSchema, type LanguageModel, type LLMRequest } from "../../schema/index.js";
2
2
  import { GeminiJsonSchema } from "./gemini-json-schema.js";
3
3
  declare const moonshot: (schema: JsonSchema) => JsonSchema;
4
- declare const openAI: (schema: JsonSchema) => JsonSchema;
5
4
  declare const tools: (entries: LLMRequest["tools"], model: LanguageModel) => LLMRequest["tools"];
6
5
  export declare const ToolSchemaProjection: {
7
6
  readonly gemini: typeof GeminiJsonSchema.normalize;
8
7
  readonly moonshot: typeof moonshot;
9
- readonly openAI: typeof openAI;
10
- readonly responses: typeof openAI;
11
8
  readonly tools: typeof tools;
12
9
  };
13
10
  export {};
@@ -48,8 +48,6 @@ const moonshot = (schema) => {
48
48
  const projected = moonshotNode(schema);
49
49
  return isRecord(projected) ? projected : {};
50
50
  };
51
- const openAI = (schema) => schema;
52
- const responses = openAI;
53
51
  const gemini = GeminiJsonSchema.normalize;
54
52
  const MODEL_NAMES = [
55
53
  [/gemini/i, "gemini"],
@@ -97,7 +95,5 @@ const tools = (entries, model) => entries.map((tool) => tool.type === "tool"
97
95
  export const ToolSchemaProjection = {
98
96
  gemini,
99
97
  moonshot,
100
- openAI,
101
- responses,
102
98
  tools,
103
99
  };
@@ -299,8 +299,8 @@ export declare const finish: <K extends StreamKey>(route: string, tools: State<K
299
299
  * arguments on `response.output_item.done`; the final value wins.
300
300
  */
301
301
  export declare const finishWithInput: <K extends StreamKey>(route: string, tools: State<K>, key: K, input: string) => Effect.Effect<{
302
- events?: undefined;
303
302
  tools: Partial<Record<K, PendingTool>>;
303
+ events?: undefined;
304
304
  } | {
305
305
  tools: Partial<Record<K, PendingTool>>;
306
306
  events: readonly ({
@@ -1,44 +1,43 @@
1
1
  import { Schema } from "effect";
2
2
  import { Protocol } from "../route/protocol.js";
3
3
  import { OpenAIChat } from "./openai-chat.js";
4
- export type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | (string & {});
5
- declare const Parameters: Schema.Struct<{
6
- readonly enableWebSearch: Schema.optional<Schema.String>;
7
- readonly enableWebScraping: Schema.optional<Schema.Boolean>;
8
- readonly enableWebCitations: Schema.optional<Schema.Boolean>;
9
- readonly enableXSearch: Schema.optional<Schema.Boolean>;
10
- readonly stripThinkingResponse: Schema.optional<Schema.Boolean>;
11
- readonly disableThinking: Schema.optional<Schema.Boolean>;
12
- readonly includeVeniceSystemPrompt: Schema.optional<Schema.Boolean>;
13
- readonly characterSlug: Schema.optional<Schema.String>;
14
- readonly includeSearchResultsInStream: Schema.optional<Schema.Boolean>;
15
- readonly returnSearchResultsAsDocuments: Schema.optional<Schema.Boolean>;
4
+ import { OpenResponsesOptions } from "./utils/open-responses-options.js";
5
+ export type ReasoningEffort = OpenResponsesOptions.ReasoningEffort;
6
+ declare const Options: Schema.Struct<{
7
+ readonly reasoningEffort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
8
+ readonly reasoning: Schema.optional<Schema.Struct<{
9
+ readonly effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
10
+ readonly enabled: Schema.optional<Schema.Boolean>;
11
+ readonly summary: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "concise" | "detailed">, import("../schema/options.js").OpenString<"auto" | "concise" | "detailed">>>;
12
+ }>>;
13
+ readonly veniceParameters: Schema.optional<Schema.Struct<{
14
+ readonly enableWebSearch: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"auto" | "off" | "on">, import("../schema/options.js").OpenString<"auto" | "off" | "on">>>;
15
+ readonly enableWebScraping: Schema.optional<Schema.Boolean>;
16
+ readonly enableWebCitations: Schema.optional<Schema.Boolean>;
17
+ readonly enableXSearch: Schema.optional<Schema.Boolean>;
18
+ readonly stripThinkingResponse: Schema.optional<Schema.Boolean>;
19
+ readonly disableThinking: Schema.optional<Schema.Boolean>;
20
+ readonly includeVeniceSystemPrompt: Schema.optional<Schema.Boolean>;
21
+ readonly characterSlug: Schema.optional<Schema.String>;
22
+ readonly includeSearchResultsInStream: Schema.optional<Schema.Boolean>;
23
+ readonly returnSearchResultsAsDocuments: Schema.optional<Schema.Boolean>;
24
+ }>>;
25
+ readonly promptCacheKey: Schema.optional<Schema.String>;
26
+ readonly promptCacheRetention: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"24h" | "default" | "extended">, import("../schema/options.js").OpenString<"24h" | "default" | "extended">>>;
27
+ readonly parallelToolCalls: Schema.optional<Schema.Boolean>;
28
+ readonly maxCompletionTokens: Schema.optional<Schema.Number>;
29
+ readonly maxTokens: Schema.optional<Schema.Number>;
30
+ readonly minP: Schema.optional<Schema.Number>;
31
+ readonly repetitionPenalty: Schema.optional<Schema.Number>;
32
+ readonly stopTokenIds: Schema.optional<Schema.$Array<Schema.Number>>;
33
+ readonly logprobs: Schema.optional<Schema.Boolean>;
34
+ readonly topLogprobs: Schema.optional<Schema.Number>;
35
+ readonly maxTemp: Schema.optional<Schema.Number>;
36
+ readonly minTemp: Schema.optional<Schema.Number>;
37
+ readonly responseFormat: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
38
+ readonly user: Schema.optional<Schema.String>;
16
39
  }>;
17
- export type OptionsInput = {
18
- readonly reasoningEffort?: ReasoningEffort;
19
- readonly reasoning?: {
20
- readonly effort?: ReasoningEffort;
21
- readonly enabled?: boolean;
22
- readonly summary?: "auto" | "concise" | "detailed" | (string & {});
23
- };
24
- readonly veniceParameters?: Omit<typeof Parameters.Type, "enableWebSearch"> & {
25
- readonly enableWebSearch?: "off" | "on" | "auto" | (string & {});
26
- };
27
- readonly promptCacheKey?: string;
28
- readonly promptCacheRetention?: "default" | "extended" | "24h" | (string & {});
29
- readonly parallelToolCalls?: boolean;
30
- readonly maxCompletionTokens?: number;
31
- readonly maxTokens?: number;
32
- readonly minP?: number;
33
- readonly repetitionPenalty?: number;
34
- readonly stopTokenIds?: readonly number[];
35
- readonly logprobs?: boolean;
36
- readonly topLogprobs?: number;
37
- readonly maxTemp?: number;
38
- readonly minTemp?: number;
39
- readonly responseFormat?: Readonly<Record<string, unknown>>;
40
- readonly user?: string;
41
- };
40
+ export type OptionsInput = typeof Options.Type;
42
41
  interface State {
43
42
  readonly shared: OpenAIChat.ParserState;
44
43
  readonly pending: string;
@@ -80,7 +79,7 @@ export declare const protocol: Protocol<{
80
79
  } | undefined;
81
80
  readonly store?: boolean | undefined;
82
81
  readonly prompt_cache_key?: string | undefined;
83
- readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
82
+ readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
84
83
  readonly tool_stream?: boolean | undefined;
85
84
  readonly max_completion_tokens?: number | undefined;
86
85
  readonly max_tokens?: number | undefined;
@@ -93,13 +92,6 @@ export declare const protocol: Protocol<{
93
92
  readonly messages: readonly ({
94
93
  readonly role: "system";
95
94
  readonly content: string | readonly ({
96
- readonly type: "text";
97
- readonly text: string;
98
- readonly cache_control?: {
99
- readonly type: "ephemeral";
100
- readonly ttl?: string | undefined;
101
- } | undefined;
102
- } | {
103
95
  readonly type: "image_url";
104
96
  readonly image_url: {
105
97
  readonly url: string;
@@ -110,17 +102,17 @@ export declare const protocol: Protocol<{
110
102
  readonly filename: string;
111
103
  readonly file_data: string;
112
104
  };
113
- })[];
114
- } | {
115
- readonly role: "user";
116
- readonly content: string | readonly ({
105
+ } | {
117
106
  readonly type: "text";
118
107
  readonly text: string;
119
108
  readonly cache_control?: {
120
109
  readonly type: "ephemeral";
121
110
  readonly ttl?: string | undefined;
122
111
  } | undefined;
123
- } | {
112
+ })[];
113
+ } | {
114
+ readonly role: "user";
115
+ readonly content: string | readonly ({
124
116
  readonly type: "image_url";
125
117
  readonly image_url: {
126
118
  readonly url: string;
@@ -131,6 +123,13 @@ export declare const protocol: Protocol<{
131
123
  readonly filename: string;
132
124
  readonly file_data: string;
133
125
  };
126
+ } | {
127
+ readonly type: "text";
128
+ readonly text: string;
129
+ readonly cache_control?: {
130
+ readonly type: "ephemeral";
131
+ readonly ttl?: string | undefined;
132
+ } | undefined;
134
133
  })[];
135
134
  } | {
136
135
  readonly role: "tool";
@@ -175,14 +174,14 @@ export declare const protocol: Protocol<{
175
174
  readonly thought_signature?: string | undefined;
176
175
  })[];
177
176
  readonly reasoning?: {
178
- readonly effort?: string | undefined;
177
+ readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
179
178
  readonly enabled?: boolean | undefined;
180
- readonly summary?: string | undefined;
179
+ readonly summary?: import("../schema/options.js").OpenString<"auto" | "concise" | "detailed"> | undefined;
181
180
  } | undefined;
182
181
  readonly venice_parameters: {
183
182
  readonly [x: string]: string | boolean;
184
183
  };
185
- readonly prompt_cache_retention?: string | undefined;
184
+ readonly prompt_cache_retention?: import("../schema/options.js").OpenString<"24h" | "default" | "extended"> | undefined;
186
185
  readonly parallel_tool_calls?: boolean | undefined;
187
186
  readonly min_p?: number | undefined;
188
187
  readonly top_k?: number | undefined;
@@ -5,8 +5,9 @@ import { classifyProviderFailure } from "../provider-error.js";
5
5
  import { OpenAIChat } from "./openai-chat.js";
6
6
  import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
7
7
  import { cacheControl } from "./utils/cache.js";
8
+ import { OpenResponsesOptions } from "./utils/open-responses-options.js";
8
9
  const Parameters = Schema.Struct({
9
- enableWebSearch: Schema.optional(Schema.String),
10
+ enableWebSearch: Schema.optional(ProviderShared.knownString()),
10
11
  enableWebScraping: Schema.optional(Schema.Boolean),
11
12
  enableWebCitations: Schema.optional(Schema.Boolean),
12
13
  enableXSearch: Schema.optional(Schema.Boolean),
@@ -18,16 +19,16 @@ const Parameters = Schema.Struct({
18
19
  returnSearchResultsAsDocuments: Schema.optional(Schema.Boolean),
19
20
  });
20
21
  const Reasoning = Schema.Struct({
21
- effort: Schema.optional(Schema.String),
22
+ effort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
22
23
  enabled: Schema.optional(Schema.Boolean),
23
- summary: Schema.optional(Schema.String),
24
+ summary: Schema.optional(ProviderShared.knownString()),
24
25
  });
25
26
  const Options = Schema.Struct({
26
- reasoningEffort: Schema.optional(Schema.String),
27
+ reasoningEffort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
27
28
  reasoning: Schema.optional(Reasoning),
28
29
  veniceParameters: Schema.optional(Parameters),
29
30
  promptCacheKey: Schema.optional(Schema.String),
30
- promptCacheRetention: Schema.optional(Schema.String),
31
+ promptCacheRetention: Schema.optional(ProviderShared.knownString()),
31
32
  parallelToolCalls: Schema.optional(Schema.Boolean),
32
33
  maxCompletionTokens: Schema.optional(Schema.Number),
33
34
  maxTokens: Schema.optional(Schema.Number),