@opencode/ai 0.0.0-beta-19507 → 0.0.0-dev-19276

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 (114) hide show
  1. package/README.md +0 -200
  2. package/dist/protocols/anthropic-messages.d.ts +1 -24
  3. package/dist/protocols/anthropic-messages.js +12 -58
  4. package/dist/protocols/meta-messages.d.ts +0 -6
  5. package/dist/protocols/open-responses-channel.d.ts +0 -2
  6. package/dist/protocols/open-responses-channel.js +2 -2
  7. package/dist/protocols/open-responses-continuation.d.ts +3 -7
  8. package/dist/protocols/open-responses-continuation.js +7 -16
  9. package/dist/protocols/open-responses.d.ts +9 -141
  10. package/dist/protocols/open-responses.js +7 -29
  11. package/dist/provider-package.d.ts +0 -4
  12. package/dist/providers/amazon-bedrock-mantle.d.ts +62 -4
  13. package/dist/providers/amazon-bedrock-mantle.js +20 -23
  14. package/dist/providers/amazon-bedrock.js +3 -3
  15. package/dist/providers/anthropic-compatible.d.ts +2 -7
  16. package/dist/providers/anthropic-compatible.js +12 -18
  17. package/dist/providers/anthropic.d.ts +2 -7
  18. package/dist/providers/anthropic.js +9 -12
  19. package/dist/providers/azure.d.ts +2 -1
  20. package/dist/providers/azure.js +14 -14
  21. package/dist/providers/baseten.d.ts +3 -2
  22. package/dist/providers/baseten.js +6 -6
  23. package/dist/providers/cerebras.d.ts +3 -2
  24. package/dist/providers/cerebras.js +6 -6
  25. package/dist/providers/cloudflare-ai-gateway.d.ts +2 -1
  26. package/dist/providers/cloudflare-ai-gateway.js +10 -16
  27. package/dist/providers/cloudflare-workers-ai.d.ts +2 -1
  28. package/dist/providers/cloudflare-workers-ai.js +9 -15
  29. package/dist/providers/deepinfra.d.ts +3 -2
  30. package/dist/providers/deepinfra.js +6 -6
  31. package/dist/providers/deepseek.d.ts +3 -2
  32. package/dist/providers/deepseek.js +6 -6
  33. package/dist/providers/fireworks.d.ts +3 -2
  34. package/dist/providers/fireworks.js +6 -6
  35. package/dist/providers/google-vertex-chat.d.ts +3 -2
  36. package/dist/providers/google-vertex-chat.js +12 -12
  37. package/dist/providers/google-vertex-messages.d.ts +3 -8
  38. package/dist/providers/google-vertex-messages.js +12 -12
  39. package/dist/providers/google-vertex-responses.d.ts +3 -2
  40. package/dist/providers/google-vertex-responses.js +12 -12
  41. package/dist/providers/google-vertex-shared.js +3 -14
  42. package/dist/providers/google-vertex.d.ts +2 -1
  43. package/dist/providers/google-vertex.js +12 -18
  44. package/dist/providers/google.d.ts +3 -2
  45. package/dist/providers/google.js +6 -6
  46. package/dist/providers/groq.d.ts +3 -2
  47. package/dist/providers/groq.js +6 -6
  48. package/dist/providers/index.d.ts +0 -3
  49. package/dist/providers/index.js +0 -3
  50. package/dist/providers/meta.d.ts +3 -8
  51. package/dist/providers/meta.js +6 -6
  52. package/dist/providers/minimax/chat.js +6 -6
  53. package/dist/providers/minimax/responses.js +6 -6
  54. package/dist/providers/minimax.d.ts +3 -8
  55. package/dist/providers/minimax.js +6 -6
  56. package/dist/providers/mistral.d.ts +3 -2
  57. package/dist/providers/mistral.js +6 -6
  58. package/dist/providers/openai-compatible-responses.d.ts +3 -2
  59. package/dist/providers/openai-compatible-responses.js +7 -7
  60. package/dist/providers/openai-compatible.d.ts +3 -2
  61. package/dist/providers/openai-compatible.js +7 -7
  62. package/dist/providers/openai.d.ts +3 -2
  63. package/dist/providers/openai.js +9 -9
  64. package/dist/providers/openrouter.d.ts +3 -2
  65. package/dist/providers/openrouter.js +6 -6
  66. package/dist/providers/togetherai.d.ts +3 -2
  67. package/dist/providers/togetherai.js +6 -6
  68. package/dist/providers/xai.d.ts +3 -2
  69. package/dist/providers/xai.js +6 -10
  70. package/dist/providers/zai.d.ts +8 -133
  71. package/dist/providers/zai.js +0 -32
  72. package/dist/route/client.js +2 -5
  73. package/dist/route/transport/websocket.js +2 -6
  74. package/dist/schema/errors.d.ts +0 -12
  75. package/dist/schema/errors.js +0 -11
  76. package/dist/schema/options.d.ts +0 -2
  77. package/dist/schema/options.js +0 -2
  78. package/package.json +3 -3
  79. package/dist/protocols/alibaba-chat.d.ts +0 -225
  80. package/dist/protocols/alibaba-chat.js +0 -75
  81. package/dist/protocols/alibaba-messages.d.ts +0 -350
  82. package/dist/protocols/alibaba-messages.js +0 -40
  83. package/dist/protocols/alibaba-responses.d.ts +0 -255
  84. package/dist/protocols/alibaba-responses.js +0 -80
  85. package/dist/protocols/zai-chat.d.ts +0 -202
  86. package/dist/protocols/zai-chat.js +0 -49
  87. package/dist/protocols/zai-messages.d.ts +0 -344
  88. package/dist/protocols/zai-messages.js +0 -27
  89. package/dist/providers/alibaba/chat.d.ts +0 -1
  90. package/dist/providers/alibaba/chat.js +0 -1
  91. package/dist/providers/alibaba/messages.d.ts +0 -3
  92. package/dist/providers/alibaba/messages.js +0 -1
  93. package/dist/providers/alibaba/responses.d.ts +0 -3
  94. package/dist/providers/alibaba/responses.js +0 -1
  95. package/dist/providers/alibaba.d.ts +0 -711
  96. package/dist/providers/alibaba.js +0 -94
  97. package/dist/providers/moonshot/chat.d.ts +0 -1
  98. package/dist/providers/moonshot/chat.js +0 -1
  99. package/dist/providers/moonshot/messages.d.ts +0 -4
  100. package/dist/providers/moonshot/messages.js +0 -8
  101. package/dist/providers/moonshot/responses.d.ts +0 -4
  102. package/dist/providers/moonshot/responses.js +0 -8
  103. package/dist/providers/moonshot.d.ts +0 -596
  104. package/dist/providers/moonshot.js +0 -90
  105. package/dist/providers/zai/chat.d.ts +0 -1
  106. package/dist/providers/zai/chat.js +0 -1
  107. package/dist/providers/zai-coding-plan/chat.d.ts +0 -1
  108. package/dist/providers/zai-coding-plan/chat.js +0 -1
  109. package/dist/providers/zai-coding-plan/messages.d.ts +0 -4
  110. package/dist/providers/zai-coding-plan/messages.js +0 -8
  111. package/dist/providers/zai-coding-plan/responses.d.ts +0 -4
  112. package/dist/providers/zai-coding-plan/responses.js +0 -8
  113. package/dist/providers/zai-coding-plan.d.ts +0 -577
  114. package/dist/providers/zai-coding-plan.js +0 -63
@@ -585,7 +585,7 @@ export declare const decodeKnownErrorEvent: (event: Event) => Effect.Effect<{
585
585
  readonly param?: string | null | undefined;
586
586
  readonly status_code?: number | undefined;
587
587
  }, Schema.SchemaError, never>;
588
- export declare const Event: Schema.decodeTo<Schema.toType<Schema.StructWithRest<Schema.Struct<{
588
+ export declare const Event: Schema.StructWithRest<Schema.Struct<{
589
589
  readonly type: Schema.String;
590
590
  readonly delta: Schema.optional<Schema.String>;
591
591
  readonly arguments: Schema.optional<Schema.String>;
@@ -648,152 +648,14 @@ export declare const Event: Schema.decodeTo<Schema.toType<Schema.StructWithRest<
648
648
  readonly status: Schema.optional<Schema.Unknown>;
649
649
  readonly status_code: Schema.optional<Schema.Unknown>;
650
650
  readonly headers: Schema.optional<Schema.Unknown>;
651
- }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>, Schema.StructWithRest<Schema.Struct<{
652
- readonly type: Schema.String;
653
- readonly delta: Schema.optional<Schema.String>;
654
- readonly arguments: Schema.optional<Schema.String>;
655
- readonly text: Schema.optional<Schema.String>;
656
- readonly item_id: Schema.optional<Schema.String>;
657
- readonly output_index: Schema.optional<Schema.Number>;
658
- readonly summary_index: Schema.optional<Schema.Number>;
659
- readonly item: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
660
- readonly type: Schema.String;
661
- readonly id: Schema.optional<Schema.String>;
662
- readonly call_id: Schema.optional<Schema.String>;
663
- readonly name: Schema.optional<Schema.String>;
664
- readonly namespace: Schema.optional<Schema.String>;
665
- readonly arguments: Schema.optional<Schema.String>;
666
- readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
667
- }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
668
- readonly response: Schema.optional<Schema.StructWithRest<Schema.Struct<{
669
- readonly id: Schema.optional<Schema.String>;
670
- readonly service_tier: Schema.optional<Schema.NullOr<Schema.String>>;
671
- readonly incomplete_details: Schema.optional<Schema.NullOr<Schema.Struct<{
672
- readonly reason: Schema.optional<Schema.String>;
673
- }>>>;
674
- readonly output: Schema.optional<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
675
- readonly type: Schema.String;
676
- readonly id: Schema.optional<Schema.String>;
677
- readonly call_id: Schema.optional<Schema.String>;
678
- readonly name: Schema.optional<Schema.String>;
679
- readonly namespace: Schema.optional<Schema.String>;
680
- readonly arguments: Schema.optional<Schema.String>;
681
- readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
682
- }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
683
- readonly usage: Schema.optional<Schema.NullOr<Schema.Struct<{
684
- readonly input_tokens: Schema.optional<Schema.Number>;
685
- readonly input_tokens_details: Schema.optional<Schema.NullOr<Schema.Struct<{
686
- readonly cached_tokens: Schema.optional<Schema.Number>;
687
- readonly cache_write_tokens: Schema.optional<Schema.Number>;
688
- }>>>;
689
- readonly output_tokens: Schema.optional<Schema.Number>;
690
- readonly output_tokens_details: Schema.optional<Schema.NullOr<Schema.Struct<{
691
- readonly reasoning_tokens: Schema.optional<Schema.Number>;
692
- }>>>;
693
- readonly total_tokens: Schema.optional<Schema.Number>;
694
- }>>>;
695
- readonly error: Schema.optional<Schema.NullOr<Schema.Struct<{
696
- readonly type: Schema.optional<Schema.NullOr<Schema.String>>;
697
- readonly code: Schema.optional<Schema.NullOr<Schema.String>>;
698
- readonly message: Schema.optional<Schema.NullOr<Schema.String>>;
699
- readonly param: Schema.optional<Schema.NullOr<Schema.String>>;
700
- }>>>;
701
- }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
702
- readonly code: Schema.optional<Schema.NullOr<Schema.String>>;
703
- readonly message: Schema.optional<Schema.String>;
704
- readonly param: Schema.optional<Schema.NullOr<Schema.String>>;
705
- readonly error: Schema.optional<Schema.NullOr<Schema.Struct<{
706
- readonly type: Schema.optional<Schema.NullOr<Schema.String>>;
707
- readonly code: Schema.optional<Schema.NullOr<Schema.String>>;
708
- readonly message: Schema.optional<Schema.NullOr<Schema.String>>;
709
- readonly param: Schema.optional<Schema.NullOr<Schema.String>>;
710
- }>>>;
711
- readonly status: Schema.optional<Schema.Unknown>;
712
- readonly status_code: Schema.optional<Schema.Unknown>;
713
- readonly headers: Schema.optional<Schema.Unknown>;
714
- }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, never, never>;
651
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>;
715
652
  export type Event = Schema.Schema.Type<typeof Event>;
716
653
  export type NormalizedEvent = Event & {
717
654
  readonly item?: OutputItem | null;
718
655
  };
719
- /**
720
- * Decodes one WebSocket frame. xAI answers a rejected `response.create` with `{ "error": { "message", "type" } }` and no
721
- * event type; that envelope reads as an error event so the failure classifies instead of failing decoding.
722
- */
723
- export declare const decodeChannelEvent: (frame: string) => Effect.Effect<{
724
- readonly [x: string]: unknown;
725
- readonly type: string;
726
- readonly status?: unknown;
727
- readonly code?: string | null | undefined;
728
- readonly message?: string | undefined;
729
- readonly headers?: unknown;
730
- readonly text?: string | undefined;
731
- readonly error?: {
732
- readonly type?: string | null | undefined;
733
- readonly code?: string | null | undefined;
734
- readonly message?: string | null | undefined;
735
- readonly param?: string | null | undefined;
736
- } | null | undefined;
737
- readonly item?: {
738
- readonly [x: string]: unknown;
739
- readonly type: string;
740
- readonly id?: string | undefined;
741
- readonly name?: string | undefined;
742
- readonly namespace?: string | undefined;
743
- readonly arguments?: string | undefined;
744
- readonly encrypted_content?: string | null | undefined;
745
- readonly call_id?: string | undefined;
746
- } | null | undefined;
747
- readonly delta?: string | undefined;
748
- readonly response?: {
749
- readonly [x: string]: unknown;
750
- readonly id?: string | undefined;
751
- readonly output?: readonly {
752
- readonly [x: string]: unknown;
753
- readonly type: string;
754
- readonly id?: string | undefined;
755
- readonly name?: string | undefined;
756
- readonly namespace?: string | undefined;
757
- readonly arguments?: string | undefined;
758
- readonly encrypted_content?: string | null | undefined;
759
- readonly call_id?: string | undefined;
760
- }[] | undefined;
761
- readonly error?: {
762
- readonly type?: string | null | undefined;
763
- readonly code?: string | null | undefined;
764
- readonly message?: string | null | undefined;
765
- readonly param?: string | null | undefined;
766
- } | null | undefined;
767
- readonly usage?: {
768
- readonly input_tokens?: number | undefined;
769
- readonly output_tokens?: number | undefined;
770
- readonly output_tokens_details?: {
771
- readonly reasoning_tokens?: number | undefined;
772
- } | null | undefined;
773
- readonly total_tokens?: number | undefined;
774
- readonly input_tokens_details?: {
775
- readonly cached_tokens?: number | undefined;
776
- readonly cache_write_tokens?: number | undefined;
777
- } | null | undefined;
778
- } | null | undefined;
779
- readonly service_tier?: string | null | undefined;
780
- readonly incomplete_details?: {
781
- readonly reason?: string | undefined;
782
- } | null | undefined;
783
- } | undefined;
784
- readonly arguments?: string | undefined;
785
- readonly param?: string | null | undefined;
786
- readonly status_code?: unknown;
787
- readonly item_id?: string | undefined;
788
- readonly output_index?: number | undefined;
789
- readonly summary_index?: number | undefined;
790
- }, Schema.SchemaError, never>;
791
656
  export interface ProviderAdapter {
792
657
  readonly id: string;
793
658
  readonly name: string;
794
- readonly nativeTool?: (native: NonNullable<ToolDefinition["native"]>) => Effect.Effect<{
795
- readonly type: string;
796
- }, AIError>;
797
659
  readonly lowerMedia?: (input: {
798
660
  readonly part: MediaPart;
799
661
  readonly media: ProviderShared.NormalizedMedia;
@@ -888,7 +750,13 @@ export declare const fromRequestWithAdapter: (request: LLMRequest<import("../sch
888
750
  readonly [x: string]: unknown;
889
751
  }, import("../route.js").CompactionOperations | undefined>>, adapter: ProviderAdapter) => Effect.Effect<{
890
752
  tools: {
891
- readonly type: string;
753
+ type: "function";
754
+ name: string;
755
+ description: string;
756
+ parameters: {
757
+ readonly [x: string]: unknown;
758
+ };
759
+ strict: boolean;
892
760
  }[] | undefined;
893
761
  tool_choice: "required" | "auto" | "none" | {
894
762
  type: "allowed_tools";
@@ -1,4 +1,4 @@
1
- import { Effect, Option, Schema, SchemaGetter } from "effect";
1
+ import { Effect, Option, Schema } from "effect";
2
2
  import { HttpTransport } from "../route/transport/index.js";
3
3
  import { Protocol } from "../route/protocol.js";
4
4
  import { AIError, LLMEvent, ProviderInternalError, Usage, } from "../schema/index.js";
@@ -232,8 +232,9 @@ export const StreamItem = Schema.StructWithRest(Schema.Struct({
232
232
  arguments: Schema.optional(Schema.String),
233
233
  encrypted_content: optionalNull(Schema.String),
234
234
  }), [Schema.Record(Schema.String, Schema.Unknown)]);
235
- // Responses-compatible providers put streaming error details at the top level or
236
- // under `error`, and response failures under `response.error`. Accept all three shapes.
235
+ // The Responses schema puts streaming error details at the top level and
236
+ // response failures under `response.error`. WebSocket failures use an
237
+ // event-level `error` envelope, so accept all three shapes here.
237
238
  // https://www.openresponses.org/specification
238
239
  const OpenResponsesErrorPayload = Schema.Struct({
239
240
  type: optionalNull(Schema.String),
@@ -286,27 +287,7 @@ export const Event = Schema.StructWithRest(Schema.Struct({
286
287
  status: Schema.optional(Schema.Unknown),
287
288
  status_code: Schema.optional(Schema.Unknown),
288
289
  headers: Schema.optional(Schema.Unknown),
289
- }), [Schema.Record(Schema.String, Schema.Unknown)]).pipe(Schema.decode({
290
- decode: SchemaGetter.transform((event) => {
291
- if (event.type !== "error" || event.error != null)
292
- return event;
293
- const { code, message, param, ...rest } = event;
294
- if (code === undefined && message === undefined && param === undefined)
295
- return event;
296
- // Flat errors (for example, Meta's) can also arrive through generic Responses endpoints.
297
- return { ...rest, error: { code, message, param } };
298
- }),
299
- encode: SchemaGetter.passthrough(),
300
- }));
301
- const decodeEventValue = Schema.decodeUnknownEffect(Event);
302
- const decodeFrame = Schema.decodeUnknownEffect(ProviderShared.Json);
303
- /**
304
- * Decodes one WebSocket frame. xAI answers a rejected `response.create` with `{ "error": { "message", "type" } }` and no
305
- * event type; that envelope reads as an error event so the failure classifies instead of failing decoding.
306
- */
307
- export const decodeChannelEvent = (frame) => decodeFrame(frame).pipe(Effect.flatMap((value) => decodeEventValue(ProviderShared.isRecord(value) && value.type === undefined && ProviderShared.isRecord(value.error)
308
- ? { ...value, type: "error" }
309
- : value)));
290
+ }), [Schema.Record(Schema.String, Schema.Unknown)]);
310
291
  const BASE_ADAPTER = { id: ADAPTER, name: NAME };
311
292
  // =============================================================================
312
293
  // Request Lowering
@@ -464,8 +445,7 @@ const lowerMessages = Effect.fn("OpenResponses.lowerMessages")(function* (reques
464
445
  type: "message",
465
446
  ...(group.id === undefined ? {} : { id: group.id }),
466
447
  role: "assistant",
467
- // Replayed text is a finished input item, even if generation was cut short.
468
- status: "completed",
448
+ status: metadata?.status,
469
449
  content: group.parts.map((part) => ({ type: "output_text", text: part.text })),
470
450
  ...(group.phase === undefined ? {} : { phase: group.phase }),
471
451
  })));
@@ -617,9 +597,7 @@ export const fromRequestWithAdapter = Effect.fn("OpenResponses.fromRequestWithAd
617
597
  ...lowerGeneration(request),
618
598
  tools: projected.tools.length === 0
619
599
  ? undefined
620
- : yield* Effect.forEach(projected.tools, (tool) => tool.native !== undefined && adapter.nativeTool
621
- ? adapter.nativeTool(tool.native)
622
- : lowerTool(adapter.name, tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility))),
600
+ : yield* Effect.forEach(projected.tools, (tool) => lowerTool(adapter.name, tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility))),
623
601
  tool_choice: allowedToolChoice(request) ??
624
602
  (request.toolChoice ? yield* lowerToolChoice(adapter.name, request.toolChoice) : undefined),
625
603
  };
@@ -1,9 +1,5 @@
1
1
  import type { LanguageModel, ProviderOptions } from "./schema/index.js";
2
2
  import type { CompactionOperations } from "./route/client.js";
3
- /**
4
- * Flat, serializable settings for `model(modelID, settings)`. Each entrypoint declares the connection keys it
5
- * reads; every other key is a request option for the route's protocol.
6
- */
7
3
  export interface Settings extends Readonly<Record<string, unknown>> {
8
4
  readonly baseURL?: string;
9
5
  readonly headers?: Readonly<Record<string, string>>;
@@ -17,7 +17,7 @@ export type Config = RouteDefaultsInput & {
17
17
  readonly region?: string;
18
18
  readonly providerOptions?: OpenAIProviderOptionsInput;
19
19
  };
20
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
20
+ export interface Settings extends ProviderPackage.Settings {
21
21
  readonly apiKey?: string;
22
22
  readonly auth?: "bearer" | "sigv4";
23
23
  readonly baseURL?: string;
@@ -25,7 +25,8 @@ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
25
25
  readonly profile?: string;
26
26
  readonly region?: string;
27
27
  readonly topP?: number;
28
- };
28
+ readonly providerOptions?: OpenAIProviderOptionsInput;
29
+ }
29
30
  export declare const routes: (Route<{
30
31
  readonly model: string;
31
32
  readonly messages: readonly ({
@@ -236,6 +237,34 @@ export declare const routes: (Route<{
236
237
  readonly type: "input_video";
237
238
  readonly video_url: string;
238
239
  })[];
240
+ } | {
241
+ readonly [x: string]: unknown;
242
+ readonly id: string;
243
+ readonly type: "computer_call";
244
+ readonly status?: string | undefined;
245
+ readonly action?: {
246
+ readonly [x: string]: unknown;
247
+ } | null | undefined;
248
+ readonly call_id?: string | undefined;
249
+ readonly pending_safety_checks?: readonly {
250
+ readonly [x: string]: unknown;
251
+ }[] | undefined;
252
+ } | {
253
+ readonly [x: string]: unknown;
254
+ readonly id: string;
255
+ readonly type: "web_search_preview_call";
256
+ readonly status?: string | undefined;
257
+ readonly action?: {
258
+ readonly [x: string]: unknown;
259
+ } | null | undefined;
260
+ } | {
261
+ readonly [x: string]: unknown;
262
+ readonly id: string;
263
+ readonly type: "image_generation_call";
264
+ readonly status?: string | undefined;
265
+ readonly result?: string | null | undefined;
266
+ readonly revised_prompt?: string | null | undefined;
267
+ readonly output_format?: "png" | "jpeg" | "webp" | undefined;
239
268
  })[];
240
269
  readonly model: string;
241
270
  readonly stream: true;
@@ -247,7 +276,7 @@ export declare const routes: (Route<{
247
276
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
248
277
  readonly effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
249
278
  } | undefined;
250
- readonly tools?: readonly {
279
+ readonly tools?: readonly ({
251
280
  readonly type: "function";
252
281
  readonly description: string;
253
282
  readonly name: string;
@@ -255,12 +284,39 @@ export declare const routes: (Route<{
255
284
  readonly [x: string]: unknown;
256
285
  };
257
286
  readonly strict?: boolean | undefined;
258
- }[] | undefined;
287
+ } | {
288
+ readonly type: "image_generation";
289
+ readonly size?: string | undefined;
290
+ readonly action?: "generate" | "auto" | "edit" | undefined;
291
+ readonly output_format?: "png" | "jpeg" | "webp" | undefined;
292
+ readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
293
+ readonly background?: "auto" | "opaque" | "transparent" | undefined;
294
+ readonly output_compression?: number | undefined;
295
+ readonly input_fidelity?: "low" | "high" | undefined;
296
+ readonly partial_images?: number | undefined;
297
+ } | {
298
+ readonly type: "namespace";
299
+ readonly name: string;
300
+ readonly description: string;
301
+ readonly tools: readonly {
302
+ readonly type: "function";
303
+ readonly description: string;
304
+ readonly name: string;
305
+ readonly parameters: {
306
+ readonly [x: string]: unknown;
307
+ };
308
+ readonly strict?: boolean | undefined;
309
+ }[];
310
+ })[] | undefined;
259
311
  readonly text?: {
260
312
  readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
261
313
  } | undefined;
262
314
  readonly temperature?: number | undefined;
263
315
  readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
316
+ readonly context_management?: readonly {
317
+ readonly type: "compaction";
318
+ readonly compact_threshold?: number | undefined;
319
+ }[] | undefined;
264
320
  readonly tool_choice?: "required" | "auto" | "none" | {
265
321
  readonly type: "function";
266
322
  readonly name: string;
@@ -271,6 +327,8 @@ export declare const routes: (Route<{
271
327
  readonly type: "function";
272
328
  readonly name: string;
273
329
  }[];
330
+ } | {
331
+ readonly type: "image_generation";
274
332
  } | undefined;
275
333
  readonly top_p?: number | undefined;
276
334
  readonly frequency_penalty?: number | undefined;
@@ -1,19 +1,19 @@
1
1
  import { Route } from "../route/client.js";
2
- import { Endpoint } from "../route/endpoint.js";
3
2
  import { OpenAIChat } from "../protocols/openai-chat.js";
4
- import { OpenResponses } from "../protocols/open-responses.js";
3
+ import { OpenAIResponses } from "../protocols/openai-responses.js";
5
4
  import { BedrockAuth } from "../protocols/utils/bedrock-auth.js";
6
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
5
+ import { ProviderID } from "../schema/index.js";
7
6
  import { withOpenAIOptions } from "./openai-options.js";
8
7
  export const id = ProviderID.make("amazon-bedrock");
9
8
  const responsesRoute = Route.make({
10
9
  id: "bedrock-mantle-responses",
11
10
  provider: id,
12
11
  providerMetadataKey: "mantle",
13
- protocol: OpenResponses.protocol,
14
- endpoint: Endpoint.path(OpenResponses.PATH),
15
- transport: OpenResponses.httpTransport,
16
- defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
12
+ protocol: OpenAIResponses.protocol,
13
+ endpoint: OpenAIResponses.route.endpoint,
14
+ auth: OpenAIResponses.route.auth,
15
+ transport: OpenAIResponses.httpTransport,
16
+ defaults: OpenAIResponses.route.defaults,
17
17
  });
18
18
  const chatRoute = OpenAIChat.route.with({
19
19
  id: "bedrock-mantle-chat",
@@ -38,12 +38,9 @@ const defaults = (input) => {
38
38
  };
39
39
  export const configure = (input = {}) => {
40
40
  if (input.auth === "bearer" && input.apiKey === undefined && process.env.AWS_BEARER_TOKEN_BEDROCK === undefined)
41
- throw new ProviderConfigurationError({ provider: id, message: "Amazon Bedrock Mantle bearer auth requires apiKey" });
41
+ throw new Error("Amazon Bedrock Mantle bearer auth requires apiKey");
42
42
  if (input.auth === "sigv4" && input.apiKey !== undefined)
43
- throw new ProviderConfigurationError({
44
- provider: id,
45
- message: "Amazon Bedrock Mantle SigV4 auth does not accept apiKey",
46
- });
43
+ throw new Error("Amazon Bedrock Mantle SigV4 auth does not accept apiKey");
47
44
  const configuredResponsesRoute = configuredRoute(responsesRoute, input);
48
45
  const configuredChatRoute = configuredRoute(chatRoute, input);
49
46
  const modelDefaults = defaults(input);
@@ -62,17 +59,17 @@ export const configure = (input = {}) => {
62
59
  };
63
60
  };
64
61
  export const provider = configure();
65
- const fromSettings = ({ apiKey, auth, baseURL, body, credentials, headers, profile, region, topP, ...providerOptions }) => configure({
66
- apiKey,
67
- auth,
68
- baseURL,
69
- credentials,
70
- generation: topP === undefined ? undefined : { topP },
71
- headers: headers === undefined ? undefined : { ...headers },
72
- http: body === undefined ? undefined : { body: { ...body } },
73
- profile,
74
- providerOptions,
75
- region,
62
+ const fromSettings = (settings) => configure({
63
+ apiKey: settings.apiKey,
64
+ auth: settings.auth,
65
+ baseURL: settings.baseURL,
66
+ credentials: settings.credentials,
67
+ generation: settings.topP === undefined ? undefined : { topP: settings.topP },
68
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
69
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
70
+ profile: settings.profile,
71
+ providerOptions: settings.providerOptions,
72
+ region: settings.region,
76
73
  });
77
74
  export const chatModel = (modelID, settings) => fromSettings(settings).chat(modelID);
78
75
  export const responsesModel = (modelID, settings) => fromSettings(settings).responses(modelID);
@@ -1,4 +1,4 @@
1
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
1
+ import { ProviderID } from "../schema/index.js";
2
2
  import * as BedrockConverse from "../protocols/bedrock-converse.js";
3
3
  import { BedrockAuth } from "../protocols/utils/bedrock-auth.js";
4
4
  export const id = ProviderID.make("amazon-bedrock");
@@ -7,9 +7,9 @@ const bedrockBaseURL = (region) => `https://bedrock-runtime.${region}.amazonaws.
7
7
  const configuredRoute = (input) => {
8
8
  const { apiKey, auth, credentials, profile, region, baseURL, ...rest } = input;
9
9
  if (auth === "bearer" && apiKey === undefined && process.env.AWS_BEARER_TOKEN_BEDROCK === undefined)
10
- throw new ProviderConfigurationError({ provider: id, message: "Amazon Bedrock bearer auth requires apiKey" });
10
+ throw new Error("Amazon Bedrock bearer auth requires apiKey");
11
11
  if (auth === "sigv4" && apiKey !== undefined)
12
- throw new ProviderConfigurationError({ provider: id, message: "Amazon Bedrock SigV4 auth does not accept apiKey" });
12
+ throw new Error("Amazon Bedrock SigV4 auth does not accept apiKey");
13
13
  const resolvedRegion = BedrockAuth.resolveRegion(input);
14
14
  return BedrockConverse.route.with({
15
15
  ...rest,
@@ -12,7 +12,7 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
12
12
  readonly baseURL: string;
13
13
  readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
14
14
  };
15
- export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOptionsInput & ({
15
+ export type Settings = ProviderPackage.Settings & ({
16
16
  readonly apiKey?: string;
17
17
  readonly authToken?: never;
18
18
  } | {
@@ -21,6 +21,7 @@ export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOpti
21
21
  }) & {
22
22
  readonly baseURL: string;
23
23
  readonly provider?: string;
24
+ readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
24
25
  };
25
26
  export declare const routes: import("../route/client.js").Route<{
26
27
  readonly max_tokens: number;
@@ -236,15 +237,9 @@ export declare const routes: import("../route/client.js").Route<{
236
237
  readonly type: "enabled";
237
238
  readonly budget_tokens: number;
238
239
  readonly display?: "summarized" | "omitted" | undefined;
239
- readonly block_binding?: {
240
- readonly prefix_mismatch_behavior?: string | undefined;
241
- } | undefined;
242
240
  } | {
243
241
  readonly type: "adaptive";
244
242
  readonly display?: "summarized" | "omitted" | undefined;
245
- readonly block_binding?: {
246
- readonly prefix_mismatch_behavior?: string | undefined;
247
- } | undefined;
248
243
  } | {
249
244
  readonly type: "disabled";
250
245
  } | undefined;
@@ -1,6 +1,6 @@
1
1
  import { AnthropicMessages } from "../protocols/anthropic-messages.js";
2
2
  import { Auth } from "../route/auth.js";
3
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
3
+ import { ProviderID } from "../schema/index.js";
4
4
  export const id = ProviderID.make("anthropic-compatible");
5
5
  export const routes = [AnthropicMessages.route];
6
6
  const auth = (input) => {
@@ -9,12 +9,9 @@ const auth = (input) => {
9
9
  return Auth.optional("apiKey" in input ? input.apiKey : undefined, "apiKey").pipe(Auth.header("x-api-key"));
10
10
  };
11
11
  export const configure = (input) => {
12
- const provider = input.provider ?? "anthropic-compatible";
13
12
  if (!input.baseURL)
14
- throw new ProviderConfigurationError({
15
- provider: ProviderID.make(provider),
16
- message: "Anthropic-compatible providers require a baseURL",
17
- });
13
+ throw new Error("Anthropic-compatible providers require a baseURL");
14
+ const provider = input.provider ?? "anthropic-compatible";
18
15
  const { provider: _, baseURL, apiKey: _apiKey, auth: _auth, ...rest } = input;
19
16
  const route = AnthropicMessages.route.with({
20
17
  ...rest,
@@ -32,19 +29,16 @@ export const provider = {
32
29
  id,
33
30
  configure,
34
31
  };
35
- export const model = (modelID, { apiKey, authToken, baseURL, body, headers, provider, ...providerOptions }) => {
36
- if (apiKey !== undefined && authToken !== undefined)
37
- throw new ProviderConfigurationError({
38
- provider: ProviderID.make(provider ?? id),
39
- message: "Anthropic-compatible apiKey cannot be combined with authToken",
40
- });
32
+ export const model = (modelID, settings) => {
33
+ if (settings.apiKey !== undefined && settings.authToken !== undefined)
34
+ throw new Error("Anthropic-compatible apiKey cannot be combined with authToken");
41
35
  return configure({
42
- ...(authToken === undefined ? { apiKey: apiKey } : { auth: Auth.bearer(authToken) }),
43
- baseURL,
44
- headers: headers === undefined ? undefined : { ...headers },
45
- http: body === undefined ? undefined : { body: { ...body } },
46
- provider,
47
- providerOptions,
36
+ ...(settings.authToken === undefined ? { apiKey: settings.apiKey } : { auth: Auth.bearer(settings.authToken) }),
37
+ baseURL: settings.baseURL,
38
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
39
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
40
+ provider: settings.provider,
41
+ providerOptions: settings.providerOptions,
48
42
  }).model(modelID);
49
43
  };
50
44
  export * as AnthropicCompatible from "./anthropic-compatible.js";
@@ -221,15 +221,9 @@ export declare const routes: import("../route/client.js").Route<{
221
221
  readonly type: "enabled";
222
222
  readonly budget_tokens: number;
223
223
  readonly display?: "summarized" | "omitted" | undefined;
224
- readonly block_binding?: {
225
- readonly prefix_mismatch_behavior?: string | undefined;
226
- } | undefined;
227
224
  } | {
228
225
  readonly type: "adaptive";
229
226
  readonly display?: "summarized" | "omitted" | undefined;
230
- readonly block_binding?: {
231
- readonly prefix_mismatch_behavior?: string | undefined;
232
- } | undefined;
233
227
  } | {
234
228
  readonly type: "disabled";
235
229
  } | undefined;
@@ -281,7 +275,7 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
281
275
  readonly baseURL?: string;
282
276
  readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
283
277
  };
284
- export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOptionsInput & ({
278
+ export type Settings = ProviderPackage.Settings & ({
285
279
  readonly apiKey?: string;
286
280
  readonly authToken?: never;
287
281
  } | {
@@ -289,6 +283,7 @@ export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOpti
289
283
  readonly authToken?: string;
290
284
  }) & {
291
285
  readonly baseURL?: string;
286
+ readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
292
287
  };
293
288
  export declare const configure: (input?: Config) => {
294
289
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -1,5 +1,5 @@
1
1
  import { Auth } from "../route/auth.js";
2
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
2
+ import { ProviderID } from "../schema/index.js";
3
3
  import { AnthropicMessages } from "../protocols/anthropic-messages.js";
4
4
  import { AnthropicCompatible } from "./anthropic-compatible.js";
5
5
  export const id = ProviderID.make("anthropic");
@@ -26,17 +26,14 @@ export const configure = (input = {}) => {
26
26
  };
27
27
  };
28
28
  export const provider = configure();
29
- export const model = (modelID, { apiKey, authToken, baseURL, body, headers, ...providerOptions }) => {
30
- if (apiKey !== undefined && authToken !== undefined)
31
- throw new ProviderConfigurationError({
32
- provider: id,
33
- message: "Anthropic apiKey cannot be combined with authToken",
34
- });
29
+ export const model = (modelID, settings) => {
30
+ if (settings.apiKey !== undefined && settings.authToken !== undefined)
31
+ throw new Error("Anthropic apiKey cannot be combined with authToken");
35
32
  return configure({
36
- ...(authToken === undefined ? { apiKey: apiKey } : { auth: Auth.bearer(authToken) }),
37
- baseURL,
38
- headers: headers === undefined ? undefined : { ...headers },
39
- http: body === undefined ? undefined : { body: { ...body } },
40
- providerOptions,
33
+ ...(settings.authToken === undefined ? { apiKey: settings.apiKey } : { auth: Auth.bearer(settings.authToken) }),
34
+ baseURL: settings.baseURL,
35
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
36
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
37
+ providerOptions: settings.providerOptions,
41
38
  }).model(modelID);
42
39
  };
@@ -15,11 +15,12 @@ export type LanguageModelOptions = AzureURL & RouteDefaultsInput & ProviderAuthO
15
15
  readonly providerOptions?: OpenAIProviderOptionsInput;
16
16
  };
17
17
  export type Config = LanguageModelOptions;
18
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & AzureURL & {
18
+ export type Settings = ProviderPackage.Settings & AzureURL & {
19
19
  readonly apiKey?: string;
20
20
  readonly apiVersion?: string;
21
21
  readonly queryParams?: Readonly<Record<string, string>>;
22
22
  readonly useDeploymentBasedUrls?: boolean;
23
+ readonly providerOptions?: OpenAIProviderOptionsInput;
23
24
  };
24
25
  declare const responsesRoute: Route<{
25
26
  readonly input: readonly ({