@opencode/ai 2.0.30 → 2.0.32

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 (60) hide show
  1. package/dist/experimental/realtime.d.ts +55 -0
  2. package/dist/experimental/realtime.js +74 -0
  3. package/dist/experimental.d.ts +2 -0
  4. package/dist/experimental.js +1 -0
  5. package/dist/protocols/alibaba-chat.d.ts +1 -1
  6. package/dist/protocols/alibaba-messages.d.ts +1 -1
  7. package/dist/protocols/alibaba-responses.d.ts +1 -1
  8. package/dist/protocols/anthropic-messages.d.ts +2 -2
  9. package/dist/protocols/bedrock-converse.d.ts +2 -2
  10. package/dist/protocols/bedrock-converse.js +1 -1
  11. package/dist/protocols/cohere-chat.d.ts +2 -2
  12. package/dist/protocols/gemini.js +11 -1
  13. package/dist/protocols/meta-messages.d.ts +1 -1
  14. package/dist/protocols/meta-responses.d.ts +2 -2
  15. package/dist/protocols/mistral-chat.d.ts +3 -3
  16. package/dist/protocols/open-responses.d.ts +2 -2
  17. package/dist/protocols/openai-chat.d.ts +3 -3
  18. package/dist/protocols/openai-compatible-chat.d.ts +1 -1
  19. package/dist/protocols/openai-compatible-responses.d.ts +1 -1
  20. package/dist/protocols/openai-responses.d.ts +5 -5
  21. package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
  22. package/dist/protocols/utils/bedrock-cache.js +5 -3
  23. package/dist/protocols/venice-chat.d.ts +1 -1
  24. package/dist/protocols/xai-responses.d.ts +1 -1
  25. package/dist/protocols/zai-chat.d.ts +1 -1
  26. package/dist/protocols/zai-messages.d.ts +1 -1
  27. package/dist/providers/alibaba.d.ts +3 -3
  28. package/dist/providers/amazon-bedrock-mantle.d.ts +3 -3
  29. package/dist/providers/amazon-bedrock.d.ts +1 -1
  30. package/dist/providers/anthropic-compatible.d.ts +1 -1
  31. package/dist/providers/anthropic.d.ts +1 -1
  32. package/dist/providers/azure.d.ts +3 -3
  33. package/dist/providers/baseten.d.ts +2 -2
  34. package/dist/providers/cerebras.d.ts +2 -2
  35. package/dist/providers/cloudflare-ai-gateway.d.ts +6 -6
  36. package/dist/providers/cloudflare-workers-ai.d.ts +2 -2
  37. package/dist/providers/cohere.d.ts +4 -4
  38. package/dist/providers/deepinfra.d.ts +2 -2
  39. package/dist/providers/deepseek.d.ts +2 -2
  40. package/dist/providers/digitalocean.d.ts +3 -3
  41. package/dist/providers/fireworks.d.ts +2 -2
  42. package/dist/providers/google-vertex-chat.d.ts +1 -1
  43. package/dist/providers/google-vertex-messages.d.ts +1 -1
  44. package/dist/providers/google-vertex-mistral.d.ts +1 -1
  45. package/dist/providers/google-vertex-responses.d.ts +1 -1
  46. package/dist/providers/groq.d.ts +2 -2
  47. package/dist/providers/meta.d.ts +3 -3
  48. package/dist/providers/minimax.d.ts +3 -3
  49. package/dist/providers/mistral.d.ts +2 -2
  50. package/dist/providers/moonshot.d.ts +3 -3
  51. package/dist/providers/openai-compatible-responses.d.ts +1 -1
  52. package/dist/providers/openai-compatible.d.ts +1 -1
  53. package/dist/providers/openai.d.ts +2 -2
  54. package/dist/providers/openrouter.d.ts +3 -3
  55. package/dist/providers/togetherai.d.ts +2 -2
  56. package/dist/providers/venice.d.ts +1 -1
  57. package/dist/providers/xai.d.ts +1 -1
  58. package/dist/providers/zai-coding-plan.d.ts +3 -3
  59. package/dist/providers/zai.d.ts +1 -1
  60. package/package.json +3 -3
@@ -0,0 +1,55 @@
1
+ import { Effect, type Redacted } from "effect";
2
+ import { AIError } from "../schema/index.js";
3
+ export type RealtimeTransportInput = {
4
+ readonly type: "webrtc";
5
+ readonly sdp: string;
6
+ readonly dcid?: number;
7
+ } | {
8
+ readonly type: "websocket";
9
+ };
10
+ export type RealtimeTransport = {
11
+ readonly type: "webrtc";
12
+ readonly sdp: string;
13
+ } | {
14
+ readonly type: "websocket";
15
+ readonly url: string;
16
+ readonly token: string;
17
+ readonly expiresAt: number;
18
+ };
19
+ export type RealtimeSession = Readonly<Record<string, unknown>>;
20
+ export interface RealtimeConnectInput {
21
+ readonly model: string;
22
+ readonly apiKey: Redacted.Redacted;
23
+ readonly session?: RealtimeSession;
24
+ readonly transport: RealtimeTransportInput;
25
+ }
26
+ export declare const engine: (model: string) => {
27
+ readonly family: "gpt-live";
28
+ readonly id: "openai-live";
29
+ readonly provider: "openai";
30
+ } | {
31
+ readonly family: "gpt-realtime";
32
+ readonly id: "openai-realtime";
33
+ readonly provider: "openai";
34
+ } | {
35
+ readonly family: "grok-voice";
36
+ readonly id: "xai-realtime";
37
+ readonly provider: "xai";
38
+ } | undefined;
39
+ export declare const connect: (input: RealtimeConnectInput) => Effect.Effect<RealtimeTransport, AIError, import("../route/executor-service.js").RequestExecutorService>;
40
+ export declare const Realtime: {
41
+ readonly engine: (model: string) => {
42
+ readonly family: "gpt-live";
43
+ readonly id: "openai-live";
44
+ readonly provider: "openai";
45
+ } | {
46
+ readonly family: "gpt-realtime";
47
+ readonly id: "openai-realtime";
48
+ readonly provider: "openai";
49
+ } | {
50
+ readonly family: "grok-voice";
51
+ readonly id: "xai-realtime";
52
+ readonly provider: "xai";
53
+ } | undefined;
54
+ readonly connect: (input: RealtimeConnectInput) => Effect.Effect<RealtimeTransport, AIError, import("../route/executor-service.js").RequestExecutorService>;
55
+ };
@@ -0,0 +1,74 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { HttpClientRequest } from "effect/http";
3
+ import { RequestExecutor } from "../route/executor.js";
4
+ import { AIError, HttpContext, InvalidProviderOutputError, InvalidRequestError } from "../schema/index.js";
5
+ import { encodeJson } from "../utils/json.js";
6
+ const OPENAI_BASE_URL = "https://api.openai.com/v1";
7
+ const XAI_BASE_URL = "https://api.x.ai/v1";
8
+ const engines = [
9
+ { family: "gpt-live", id: "openai-live", provider: "openai" },
10
+ { family: "gpt-realtime", id: "openai-realtime", provider: "openai" },
11
+ { family: "grok-voice", id: "xai-realtime", provider: "xai" },
12
+ ];
13
+ // Matches the bare family name (`gpt-realtime`) and its versions (`gpt-realtime-2.1`, `gpt-realtime-mini`).
14
+ export const engine = (model) => engines.find((item) => model === item.family || model.startsWith(`${item.family}-`));
15
+ export const connect = Effect.fn("Realtime.connect")(function* (input) {
16
+ const resolved = engine(input.model);
17
+ if (!resolved)
18
+ return yield* invalidRequest(`Unsupported voice model: ${input.model}`);
19
+ const session = { ...input.session, model: input.model };
20
+ switch (resolved.id) {
21
+ case "openai-live": {
22
+ if (input.transport.type !== "webrtc")
23
+ return yield* invalidRequest("OpenAI GPT-Live only supports WebRTC transport");
24
+ const data = yield* post(resolved.id, `${OPENAI_BASE_URL}/live/sessions`, input.apiKey, { session, transport: input.transport }, LiveSessionResponse);
25
+ return { type: "webrtc", sdp: data.transport.sdp };
26
+ }
27
+ case "openai-realtime": {
28
+ if (input.transport.type === "websocket")
29
+ return yield* clientSecret(resolved.id, OPENAI_BASE_URL, input.model, input.apiKey, session);
30
+ const form = new FormData();
31
+ form.append("sdp", input.transport.sdp);
32
+ form.append("session", encodeJson(session));
33
+ const query = input.transport.dcid === undefined ? "" : `?dcid=${input.transport.dcid}`;
34
+ const sdp = yield* post(resolved.id, `${OPENAI_BASE_URL}/realtime/calls${query}`, input.apiKey, form, Schema.String);
35
+ return { type: "webrtc", sdp };
36
+ }
37
+ case "xai-realtime": {
38
+ if (input.transport.type !== "websocket")
39
+ return yield* invalidRequest("xAI Grok Voice only supports WebSocket transport");
40
+ return yield* clientSecret(resolved.id, XAI_BASE_URL, input.model, input.apiKey);
41
+ }
42
+ }
43
+ });
44
+ export const Realtime = {
45
+ engine,
46
+ connect,
47
+ };
48
+ const LiveSessionResponse = Schema.fromJsonString(Schema.Struct({
49
+ transport: Schema.Struct({ sdp: Schema.String }),
50
+ }));
51
+ // xAI's ephemeral-token docs (https://docs.x.ai/developers/model-capabilities/audio/ephemeral-tokens)
52
+ // document the request body (`{ expires_after: { seconds } }`) but not the response payload; we assume
53
+ // it mirrors OpenAI's `{ value, expires_at }` response shape.
54
+ const ClientSecretResponse = Schema.fromJsonString(Schema.Struct({
55
+ value: Schema.String,
56
+ expires_at: Schema.Number,
57
+ }));
58
+ const invalidRequest = (message) => new AIError({ reason: new InvalidRequestError({ message }) });
59
+ const post = (route, url, apiKey, body, response) => Effect.gen(function* () {
60
+ const executor = yield* RequestExecutor.Service;
61
+ const res = yield* executor.execute(HttpClientRequest.post(url).pipe(HttpClientRequest.bearerToken(apiKey), body instanceof FormData
62
+ ? HttpClientRequest.bodyFormData(body)
63
+ : HttpClientRequest.bodyText(encodeJson(body), "application/json")));
64
+ const http = new HttpContext({ url: res.request.url, status: res.status, headers: res.headers });
65
+ const fail = (message, cause, raw) => new AIError({ reason: new InvalidProviderOutputError({ route, message, body: raw, http, cause }) });
66
+ const text = yield* res.text.pipe(Effect.mapError((cause) => fail(`Failed to read ${route} response`, cause)));
67
+ return yield* Schema.decodeEffect(response)(text).pipe(Effect.mapError((cause) => fail(`${route} returned an invalid response`, cause, text)));
68
+ });
69
+ const clientSecret = (route, baseURL, model, apiKey, session) => post(route, `${baseURL}/realtime/client_secrets`, apiKey, { expires_after: { seconds: 60 }, session }, ClientSecretResponse).pipe(Effect.map((data) => ({
70
+ type: "websocket",
71
+ url: `${baseURL.replace(/^http/, "ws")}/realtime?model=${encodeURIComponent(model)}`,
72
+ token: data.value,
73
+ expiresAt: data.expires_at,
74
+ })));
@@ -1,3 +1,5 @@
1
1
  export { EvaluationClient } from "./experimental/evaluation-client.js";
2
2
  export { BooleanAnswer, BooleanQuestion, ChoiceAnswer, ChoiceQuestion, Evaluation, EvaluationAnswer, EvaluationInput, EvaluationModel, EvaluationModelSchema, EvaluationQuestion, EvaluationRequest, EvaluationResponse, EvaluationRounding, ScoreAnswer, ScoreQuestion, } from "./experimental/evaluation.js";
3
3
  export type { AnswerFor, AnswersFor, EvaluationModelOptions, EvaluationOptions, EvaluationQuestions, EvaluationRequestFor, EvaluationRequestInput, EvaluationResponseFor, EvaluationRoute, } from "./experimental/evaluation.js";
4
+ export { Realtime } from "./experimental/realtime.js";
5
+ export type { RealtimeConnectInput, RealtimeSession, RealtimeTransport, RealtimeTransportInput, } from "./experimental/realtime.js";
@@ -1,2 +1,3 @@
1
1
  export { EvaluationClient } from "./experimental/evaluation-client.js";
2
2
  export { BooleanAnswer, BooleanQuestion, ChoiceAnswer, ChoiceQuestion, Evaluation, EvaluationAnswer, EvaluationInput, EvaluationModel, EvaluationModelSchema, EvaluationQuestion, EvaluationRequest, EvaluationResponse, EvaluationRounding, ScoreAnswer, ScoreQuestion, } from "./experimental/evaluation.js";
3
+ export { Realtime } from "./experimental/realtime.js";
@@ -121,6 +121,7 @@ export declare const protocol: Protocol<{
121
121
  readonly stream: true;
122
122
  readonly max_completion_tokens?: number | undefined;
123
123
  readonly max_tokens?: number | undefined;
124
+ readonly temperature?: number | undefined;
124
125
  readonly tools?: readonly {
125
126
  readonly function: {
126
127
  readonly description: string;
@@ -137,7 +138,6 @@ export declare const protocol: Protocol<{
137
138
  } | undefined;
138
139
  }[] | undefined;
139
140
  readonly stop?: readonly string[] | undefined;
140
- readonly temperature?: number | undefined;
141
141
  readonly seed?: number | undefined;
142
142
  readonly thinking?: {
143
143
  readonly type: (string & {}) | "disabled" | "adaptive";
@@ -204,6 +204,7 @@ export declare const protocol: Protocol<{
204
204
  readonly metadata?: {
205
205
  readonly user_id?: string | null | undefined;
206
206
  } | undefined;
207
+ readonly temperature?: number | undefined;
207
208
  readonly tools?: readonly {
208
209
  readonly description: string;
209
210
  readonly name: string;
@@ -223,7 +224,6 @@ export declare const protocol: Protocol<{
223
224
  readonly ttl?: "1h" | "5m" | undefined;
224
225
  } | undefined;
225
226
  }[] | undefined;
226
- readonly temperature?: number | undefined;
227
227
  readonly thinking?: {
228
228
  readonly type: string;
229
229
  readonly budget_tokens?: number | undefined;
@@ -144,6 +144,7 @@ export declare const protocol: Protocol<{
144
144
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
145
145
  readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
146
146
  } | undefined;
147
+ readonly temperature?: number | undefined;
147
148
  readonly tools?: readonly ({
148
149
  readonly [x: string]: unknown;
149
150
  readonly type: string;
@@ -159,7 +160,6 @@ export declare const protocol: Protocol<{
159
160
  readonly text?: {
160
161
  readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
161
162
  } | undefined;
162
- readonly temperature?: number | undefined;
163
163
  readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
164
164
  readonly tool_choice?: "required" | "auto" | "none" | {
165
165
  readonly type: "function";
@@ -604,6 +604,7 @@ export declare const protocol: Protocol<{
604
604
  readonly metadata?: {
605
605
  readonly user_id?: string | null | undefined;
606
606
  } | undefined;
607
+ readonly temperature?: number | undefined;
607
608
  readonly tools?: readonly {
608
609
  readonly description: string;
609
610
  readonly name: string;
@@ -623,7 +624,6 @@ export declare const protocol: Protocol<{
623
624
  readonly ttl?: "1h" | "5m" | undefined;
624
625
  } | undefined;
625
626
  }[] | undefined;
626
- readonly temperature?: number | undefined;
627
627
  readonly thinking?: {
628
628
  readonly type: "enabled";
629
629
  readonly budget_tokens: number;
@@ -964,6 +964,7 @@ export declare const route: Route<{
964
964
  readonly metadata?: {
965
965
  readonly user_id?: string | null | undefined;
966
966
  } | undefined;
967
+ readonly temperature?: number | undefined;
967
968
  readonly tools?: readonly {
968
969
  readonly description: string;
969
970
  readonly name: string;
@@ -983,7 +984,6 @@ export declare const route: Route<{
983
984
  readonly ttl?: "1h" | "5m" | undefined;
984
985
  } | undefined;
985
986
  }[] | undefined;
986
- readonly temperature?: number | undefined;
987
987
  readonly thinking?: {
988
988
  readonly type: "enabled";
989
989
  readonly budget_tokens: number;
@@ -234,8 +234,8 @@ export declare const protocol: Protocol<{
234
234
  readonly text: string;
235
235
  })[] | undefined;
236
236
  readonly inferenceConfig?: {
237
- readonly maxTokens?: number | undefined;
238
237
  readonly temperature?: number | undefined;
238
+ readonly maxTokens?: number | undefined;
239
239
  readonly topP?: number | undefined;
240
240
  readonly stopSequences?: readonly string[] | undefined;
241
241
  } | undefined;
@@ -463,8 +463,8 @@ export declare const route: Route<{
463
463
  readonly text: string;
464
464
  })[] | undefined;
465
465
  readonly inferenceConfig?: {
466
- readonly maxTokens?: number | undefined;
467
466
  readonly temperature?: number | undefined;
467
+ readonly maxTokens?: number | undefined;
468
468
  readonly topP?: number | undefined;
469
469
  readonly stopSequences?: readonly string[] | undefined;
470
470
  } | undefined;
@@ -413,7 +413,7 @@ const fromRequest = Effect.fn("BedrockConverse.fromRequest")(function* (request)
413
413
  });
414
414
  // Bedrock-Claude shares Anthropic's 4-breakpoint cap. Spend the budget in
415
415
  // tools → system → messages order to favour the highest-impact prefixes.
416
- const breakpoints = BedrockCache.breakpoints(request.model.id);
416
+ const breakpoints = BedrockCache.breakpoints(request.model);
417
417
  const toolConfig = (() => {
418
418
  if (flattened.tools.length === 0)
419
419
  return undefined;
@@ -40,6 +40,7 @@ export declare const protocol: Protocol<{
40
40
  }[];
41
41
  readonly stream: true;
42
42
  readonly max_tokens?: number | undefined;
43
+ readonly temperature?: number | undefined;
43
44
  readonly tools?: readonly {
44
45
  readonly type: "function";
45
46
  readonly function: {
@@ -48,7 +49,6 @@ export declare const protocol: Protocol<{
48
49
  readonly description?: string | undefined;
49
50
  };
50
51
  }[] | undefined;
51
- readonly temperature?: number | undefined;
52
52
  readonly seed?: number | undefined;
53
53
  readonly thinking?: {
54
54
  readonly type: string;
@@ -154,6 +154,7 @@ export declare const route: Route<{
154
154
  }[];
155
155
  readonly stream: true;
156
156
  readonly max_tokens?: number | undefined;
157
+ readonly temperature?: number | undefined;
157
158
  readonly tools?: readonly {
158
159
  readonly type: "function";
159
160
  readonly function: {
@@ -162,7 +163,6 @@ export declare const route: Route<{
162
163
  readonly description?: string | undefined;
163
164
  };
164
165
  }[] | undefined;
165
- readonly temperature?: number | undefined;
166
166
  readonly seed?: number | undefined;
167
167
  readonly thinking?: {
168
168
  readonly type: string;
@@ -5,7 +5,7 @@ import { Auth } from "../route/auth.js";
5
5
  import { Endpoint } from "../route/endpoint.js";
6
6
  import { Protocol } from "../route/protocol.js";
7
7
  import { HttpTransport, } from "../route/transport/index.js";
8
- import { AIError, LLMEvent, Usage, } from "../schema/index.js";
8
+ import { AIError, InvalidProviderOutputError, LLMEvent, Usage, } from "../schema/index.js";
9
9
  import { classifyProviderFailure } from "../provider-error.js";
10
10
  import { Media } from "../media.js";
11
11
  import { JsonObject, knownString, lenient, optionalArray, optionalNull, ProviderShared } from "./shared.js";
@@ -534,6 +534,16 @@ const step = (state, event) => {
534
534
  usage: event.usageMetadata ?? state.usage,
535
535
  finishReason: candidate?.finishReason ?? state.finishReason,
536
536
  };
537
+ // Gemini sporadically ends a valid request with MALFORMED_RESPONSE; continuing or resending it recovers.
538
+ if (candidate?.finishReason === "MALFORMED_RESPONSE")
539
+ return Effect.fail(new AIError({
540
+ reason: new InvalidProviderOutputError({
541
+ route: state.route,
542
+ message: `Gemini stopped with ${candidate.finishReason}`,
543
+ body: ProviderShared.encodeJson(event),
544
+ classification: "incomplete-stream",
545
+ }),
546
+ }));
537
547
  if (candidate?.finishReason && mapFinishReason(candidate.finishReason, state.hasToolCalls) === "error")
538
548
  return Effect.fail(ProviderShared.eventError(state.route, `Gemini stopped with ${candidate.finishReason}`, ProviderShared.encodeJson(event)));
539
549
  if (!candidate?.content)
@@ -192,6 +192,7 @@ export declare const protocol: Protocol<{
192
192
  readonly metadata?: {
193
193
  readonly user_id?: string | null | undefined;
194
194
  } | undefined;
195
+ readonly temperature?: number | undefined;
195
196
  readonly tools?: readonly ({
196
197
  readonly type: "web_search";
197
198
  readonly name: "web_search";
@@ -221,7 +222,6 @@ export declare const protocol: Protocol<{
221
222
  readonly ttl?: "1h" | "5m" | undefined;
222
223
  } | undefined;
223
224
  }[] | undefined;
224
- readonly temperature?: number | undefined;
225
225
  readonly thinking?: {
226
226
  readonly type: "enabled";
227
227
  readonly budget_tokens: number;
@@ -158,6 +158,7 @@ export declare const protocol: Protocol<{
158
158
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
159
159
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
160
160
  } | undefined;
161
+ readonly temperature?: number | undefined;
161
162
  readonly tools?: readonly ({
162
163
  readonly [x: string]: unknown;
163
164
  readonly type: string;
@@ -173,7 +174,6 @@ export declare const protocol: Protocol<{
173
174
  readonly text?: {
174
175
  readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
175
176
  } | undefined;
176
- readonly temperature?: number | undefined;
177
177
  readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined;
178
178
  readonly tool_choice?: "required" | "auto" | "none" | {
179
179
  readonly type: "function";
@@ -394,6 +394,7 @@ export declare const httpTransport: import("../route/transport/http.js").HttpJso
394
394
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
395
395
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
396
396
  } | undefined;
397
+ readonly temperature?: number | undefined;
397
398
  readonly tools?: readonly ({
398
399
  readonly [x: string]: unknown;
399
400
  readonly type: string;
@@ -409,7 +410,6 @@ export declare const httpTransport: import("../route/transport/http.js").HttpJso
409
410
  readonly text?: {
410
411
  readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
411
412
  } | undefined;
412
- readonly temperature?: number | undefined;
413
413
  readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined;
414
414
  readonly tool_choice?: "required" | "auto" | "none" | {
415
415
  readonly type: "function";
@@ -299,6 +299,7 @@ export declare const protocol: Protocol<{
299
299
  })[];
300
300
  readonly stream: true;
301
301
  readonly max_tokens?: number | undefined;
302
+ readonly temperature?: number | undefined;
302
303
  readonly tools?: readonly {
303
304
  readonly type: "function";
304
305
  readonly function: {
@@ -311,7 +312,6 @@ export declare const protocol: Protocol<{
311
312
  };
312
313
  }[] | undefined;
313
314
  readonly stop?: readonly string[] | undefined;
314
- readonly temperature?: number | undefined;
315
315
  readonly tool_choice?: "auto" | "none" | "any" | {
316
316
  readonly type: "function";
317
317
  readonly function: {
@@ -436,6 +436,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
436
436
  })[];
437
437
  readonly stream: true;
438
438
  readonly max_tokens?: number | undefined;
439
+ readonly temperature?: number | undefined;
439
440
  readonly tools?: readonly {
440
441
  readonly type: "function";
441
442
  readonly function: {
@@ -448,7 +449,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
448
449
  };
449
450
  }[] | undefined;
450
451
  readonly stop?: readonly string[] | undefined;
451
- readonly temperature?: number | undefined;
452
452
  readonly tool_choice?: "auto" | "none" | "any" | {
453
453
  readonly type: "function";
454
454
  readonly function: {
@@ -527,6 +527,7 @@ export declare const route: Route<{
527
527
  })[];
528
528
  readonly stream: true;
529
529
  readonly max_tokens?: number | undefined;
530
+ readonly temperature?: number | undefined;
530
531
  readonly tools?: readonly {
531
532
  readonly type: "function";
532
533
  readonly function: {
@@ -539,7 +540,6 @@ export declare const route: Route<{
539
540
  };
540
541
  }[] | undefined;
541
542
  readonly stop?: readonly string[] | undefined;
542
- readonly temperature?: number | undefined;
543
543
  readonly tool_choice?: "auto" | "none" | "any" | {
544
544
  readonly type: "function";
545
545
  readonly function: {
@@ -1659,6 +1659,7 @@ export declare const protocol: Protocol<{
1659
1659
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
1660
1660
  readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
1661
1661
  } | undefined;
1662
+ readonly temperature?: number | undefined;
1662
1663
  readonly tools?: readonly ({
1663
1664
  readonly [x: string]: unknown;
1664
1665
  readonly type: string;
@@ -1674,7 +1675,6 @@ export declare const protocol: Protocol<{
1674
1675
  readonly text?: {
1675
1676
  readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
1676
1677
  } | undefined;
1677
- readonly temperature?: number | undefined;
1678
1678
  readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
1679
1679
  readonly tool_choice?: "required" | "auto" | "none" | {
1680
1680
  readonly type: "function";
@@ -1895,6 +1895,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
1895
1895
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
1896
1896
  readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
1897
1897
  } | undefined;
1898
+ readonly temperature?: number | undefined;
1898
1899
  readonly tools?: readonly ({
1899
1900
  readonly [x: string]: unknown;
1900
1901
  readonly type: string;
@@ -1910,7 +1911,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
1910
1911
  readonly text?: {
1911
1912
  readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
1912
1913
  } | undefined;
1913
- readonly temperature?: number | undefined;
1914
1914
  readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
1915
1915
  readonly tool_choice?: "required" | "auto" | "none" | {
1916
1916
  readonly type: "function";
@@ -1112,6 +1112,7 @@ export declare const protocol: Protocol<{
1112
1112
  readonly stream: true;
1113
1113
  readonly max_completion_tokens?: number | undefined;
1114
1114
  readonly max_tokens?: number | undefined;
1115
+ readonly temperature?: number | undefined;
1115
1116
  readonly tools?: readonly {
1116
1117
  readonly function: {
1117
1118
  readonly description: string;
@@ -1128,7 +1129,6 @@ export declare const protocol: Protocol<{
1128
1129
  } | undefined;
1129
1130
  }[] | undefined;
1130
1131
  readonly stop?: readonly string[] | undefined;
1131
- readonly temperature?: number | undefined;
1132
1132
  readonly seed?: number | undefined;
1133
1133
  readonly tool_choice?: "required" | "auto" | "none" | {
1134
1134
  readonly type: "function";
@@ -1307,6 +1307,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
1307
1307
  readonly stream: true;
1308
1308
  readonly max_completion_tokens?: number | undefined;
1309
1309
  readonly max_tokens?: number | undefined;
1310
+ readonly temperature?: number | undefined;
1310
1311
  readonly tools?: readonly {
1311
1312
  readonly function: {
1312
1313
  readonly description: string;
@@ -1323,7 +1324,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
1323
1324
  } | undefined;
1324
1325
  }[] | undefined;
1325
1326
  readonly stop?: readonly string[] | undefined;
1326
- readonly temperature?: number | undefined;
1327
1327
  readonly seed?: number | undefined;
1328
1328
  readonly tool_choice?: "required" | "auto" | "none" | {
1329
1329
  readonly type: "function";
@@ -1429,6 +1429,7 @@ export declare const route: Route<{
1429
1429
  readonly stream: true;
1430
1430
  readonly max_completion_tokens?: number | undefined;
1431
1431
  readonly max_tokens?: number | undefined;
1432
+ readonly temperature?: number | undefined;
1432
1433
  readonly tools?: readonly {
1433
1434
  readonly function: {
1434
1435
  readonly description: string;
@@ -1445,7 +1446,6 @@ export declare const route: Route<{
1445
1446
  } | undefined;
1446
1447
  }[] | undefined;
1447
1448
  readonly stop?: readonly string[] | undefined;
1448
- readonly temperature?: number | undefined;
1449
1449
  readonly seed?: number | undefined;
1450
1450
  readonly tool_choice?: "required" | "auto" | "none" | {
1451
1451
  readonly type: "function";
@@ -94,6 +94,7 @@ export declare const route: Route<{
94
94
  readonly stream: true;
95
95
  readonly max_completion_tokens?: number | undefined;
96
96
  readonly max_tokens?: number | undefined;
97
+ readonly temperature?: number | undefined;
97
98
  readonly tools?: readonly {
98
99
  readonly function: {
99
100
  readonly description: string;
@@ -110,7 +111,6 @@ export declare const route: Route<{
110
111
  } | undefined;
111
112
  }[] | undefined;
112
113
  readonly stop?: readonly string[] | undefined;
113
- readonly temperature?: number | undefined;
114
114
  readonly seed?: number | undefined;
115
115
  readonly tool_choice?: "required" | "auto" | "none" | {
116
116
  readonly type: "function";
@@ -139,6 +139,7 @@ export declare const route: Route<{
139
139
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
140
140
  readonly effort?: import("../index.js").ReasoningEffort | undefined;
141
141
  } | undefined;
142
+ readonly temperature?: number | undefined;
142
143
  readonly tools?: readonly ({
143
144
  readonly [x: string]: unknown;
144
145
  readonly type: string;
@@ -154,7 +155,6 @@ export declare const route: Route<{
154
155
  readonly text?: {
155
156
  readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
156
157
  } | undefined;
157
- readonly temperature?: number | undefined;
158
158
  readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined;
159
159
  readonly tool_choice?: "required" | "auto" | "none" | {
160
160
  readonly type: "function";
@@ -337,6 +337,7 @@ export declare const protocol: Protocol<{
337
337
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
338
338
  readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
339
339
  } | undefined;
340
+ readonly temperature?: number | undefined;
340
341
  readonly tools?: readonly ({
341
342
  readonly type: "function";
342
343
  readonly description: string;
@@ -372,7 +373,6 @@ export declare const protocol: Protocol<{
372
373
  readonly text?: {
373
374
  readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
374
375
  } | undefined;
375
- readonly temperature?: number | undefined;
376
376
  readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
377
377
  readonly context_management?: readonly {
378
378
  readonly type: "compaction";
@@ -599,6 +599,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
599
599
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
600
600
  readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
601
601
  } | undefined;
602
+ readonly temperature?: number | undefined;
602
603
  readonly tools?: readonly ({
603
604
  readonly type: "function";
604
605
  readonly description: string;
@@ -634,7 +635,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
634
635
  readonly text?: {
635
636
  readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
636
637
  } | undefined;
637
- readonly temperature?: number | undefined;
638
638
  readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
639
639
  readonly context_management?: readonly {
640
640
  readonly type: "compaction";
@@ -803,6 +803,7 @@ export declare const channelTransport: (options: import("./open-responses-channe
803
803
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
804
804
  readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
805
805
  } | undefined;
806
+ readonly temperature?: number | undefined;
806
807
  readonly tools?: readonly ({
807
808
  readonly type: "function";
808
809
  readonly description: string;
@@ -838,7 +839,6 @@ export declare const channelTransport: (options: import("./open-responses-channe
838
839
  readonly text?: {
839
840
  readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
840
841
  } | undefined;
841
- readonly temperature?: number | undefined;
842
842
  readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
843
843
  readonly context_management?: readonly {
844
844
  readonly type: "compaction";
@@ -1007,6 +1007,7 @@ export declare const transport: import("../route/transport/index.js").Transport<
1007
1007
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
1008
1008
  readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
1009
1009
  } | undefined;
1010
+ readonly temperature?: number | undefined;
1010
1011
  readonly tools?: readonly ({
1011
1012
  readonly type: "function";
1012
1013
  readonly description: string;
@@ -1042,7 +1043,6 @@ export declare const transport: import("../route/transport/index.js").Transport<
1042
1043
  readonly text?: {
1043
1044
  readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
1044
1045
  } | undefined;
1045
- readonly temperature?: number | undefined;
1046
1046
  readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
1047
1047
  readonly context_management?: readonly {
1048
1048
  readonly type: "compaction";
@@ -1211,6 +1211,7 @@ export declare const route: Route<{
1211
1211
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
1212
1212
  readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
1213
1213
  } | undefined;
1214
+ readonly temperature?: number | undefined;
1214
1215
  readonly tools?: readonly ({
1215
1216
  readonly type: "function";
1216
1217
  readonly description: string;
@@ -1246,7 +1247,6 @@ export declare const route: Route<{
1246
1247
  readonly text?: {
1247
1248
  readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
1248
1249
  } | undefined;
1249
- readonly temperature?: number | undefined;
1250
1250
  readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
1251
1251
  readonly context_management?: readonly {
1252
1252
  readonly type: "compaction";
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import type { CacheHint } from "../../schema/index.js";
2
+ import type { CacheHint, LLMRequest } from "../../schema/index.js";
3
3
  export declare const CachePointBlock: Schema.Struct<{
4
4
  readonly cachePoint: Schema.Struct<{
5
5
  readonly type: Schema.tag<"default">;
@@ -8,7 +8,7 @@ export declare const CachePointBlock: Schema.Struct<{
8
8
  }>;
9
9
  export type CachePointBlock = Schema.Schema.Type<typeof CachePointBlock>;
10
10
  export declare const BEDROCK_BREAKPOINT_CAP = 4;
11
- export declare const breakpoints: (modelID: string) => {
11
+ export declare const breakpoints: (model: LLMRequest["model"]) => {
12
12
  supported: boolean;
13
13
  ttl1h: boolean;
14
14
  remaining: number;
@@ -21,14 +21,16 @@ const CLAUDE_5M = [
21
21
  ];
22
22
  // Callers share the four-breakpoint budget across system, messages, and tools.
23
23
  export const BEDROCK_BREAKPOINT_CAP = 4;
24
- export const breakpoints = (modelID) => {
24
+ export const breakpoints = (model) => {
25
25
  // Substring matching also handles regional prefixes and model-bearing ARNs.
26
- const short = CLAUDE_5M.some((id) => modelID.includes(id));
26
+ const short = CLAUDE_5M.some((id) => model.id.includes(id));
27
27
  return {
28
28
  ...newBreakpoints(BEDROCK_BREAKPOINT_CAP),
29
+ // An explicit Anthropic cache format opts opaque IDs such as application inference profile ARNs in.
29
30
  // Assume modern Claude releases retain caching support; older generations need an explicit exception.
30
31
  // Other model families use implicit caching where available.
31
- supported: modelID.includes("anthropic.claude-") && (short || !LEGACY_CLAUDE.some((id) => modelID.includes(id))),
32
+ supported: model.compatibility?.cacheFormat === "anthropic" ||
33
+ (model.id.includes("anthropic.claude-") && (short || !LEGACY_CLAUDE.some((id) => model.id.includes(id)))),
32
34
  ttl1h: !short,
33
35
  };
34
36
  };
@@ -149,6 +149,7 @@ export declare const protocol: Protocol<{
149
149
  } | undefined;
150
150
  readonly max_completion_tokens?: number | undefined;
151
151
  readonly max_tokens?: number | undefined;
152
+ readonly temperature?: number | undefined;
152
153
  readonly tools?: readonly {
153
154
  readonly function: {
154
155
  readonly description: string;
@@ -166,7 +167,6 @@ export declare const protocol: Protocol<{
166
167
  }[] | undefined;
167
168
  readonly stop?: readonly string[] | undefined;
168
169
  readonly user?: string | undefined;
169
- readonly temperature?: number | undefined;
170
170
  readonly seed?: number | undefined;
171
171
  readonly tool_choice?: "required" | "auto" | "none" | {
172
172
  readonly type: "function";