@opencode/ai 2.1.3 → 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 (106) hide show
  1. package/dist/experimental/evaluation.js +3 -10
  2. package/dist/image-client.d.ts +8 -8
  3. package/dist/image.d.ts +148 -148
  4. package/dist/promise.d.ts +120 -120
  5. package/dist/protocols/alibaba-chat.d.ts +12 -12
  6. package/dist/protocols/alibaba-messages.d.ts +11 -11
  7. package/dist/protocols/alibaba-responses.d.ts +35 -35
  8. package/dist/protocols/anthropic-messages.d.ts +40 -44
  9. package/dist/protocols/anthropic-messages.js +3 -3
  10. package/dist/protocols/bedrock-converse.d.ts +30 -32
  11. package/dist/protocols/bedrock-converse.js +2 -3
  12. package/dist/protocols/cartesia-speech.d.ts +32 -32
  13. package/dist/protocols/cohere-chat.d.ts +7 -8
  14. package/dist/protocols/deepgram-speech.d.ts +32 -32
  15. package/dist/protocols/elevenlabs-speech.d.ts +32 -32
  16. package/dist/protocols/gemini.d.ts +34 -34
  17. package/dist/protocols/gemini.js +2 -2
  18. package/dist/protocols/google-interactions.d.ts +14 -14
  19. package/dist/protocols/google-interactions.js +2 -2
  20. package/dist/protocols/google-speech.d.ts +32 -32
  21. package/dist/protocols/google-transcription.d.ts +32 -32
  22. package/dist/protocols/meta-messages.d.ts +23 -23
  23. package/dist/protocols/meta-responses.d.ts +78 -78
  24. package/dist/protocols/mistral-chat.d.ts +81 -78
  25. package/dist/protocols/mistral-chat.js +2 -1
  26. package/dist/protocols/open-responses-channel.js +47 -46
  27. package/dist/protocols/open-responses-continuation.d.ts +8 -2
  28. package/dist/protocols/open-responses-continuation.js +3 -1
  29. package/dist/protocols/open-responses.d.ts +398 -398
  30. package/dist/protocols/open-responses.js +8 -7
  31. package/dist/protocols/openai-chat.d.ts +60 -60
  32. package/dist/protocols/openai-chat.js +3 -3
  33. package/dist/protocols/openai-compatible-chat.d.ts +13 -14
  34. package/dist/protocols/openai-compatible-responses.d.ts +36 -37
  35. package/dist/protocols/openai-images.d.ts +32 -32
  36. package/dist/protocols/openai-responses.d.ts +235 -235
  37. package/dist/protocols/openai-responses.js +1 -1
  38. package/dist/protocols/openai-speech.d.ts +32 -32
  39. package/dist/protocols/openai-transcription.d.ts +32 -32
  40. package/dist/protocols/openai-transcription.js +12 -7
  41. package/dist/protocols/utils/partial-json-options.d.ts +0 -1
  42. package/dist/protocols/utils/partial-json-options.js +0 -1
  43. package/dist/protocols/utils/tool-stream.d.ts +1 -1
  44. package/dist/protocols/venice-chat.d.ts +52 -53
  45. package/dist/protocols/venice-chat.js +6 -5
  46. package/dist/protocols/xai-responses.d.ts +78 -78
  47. package/dist/protocols/zai-chat.d.ts +33 -30
  48. package/dist/protocols/zai-chat.js +8 -3
  49. package/dist/protocols/zai-messages.d.ts +21 -19
  50. package/dist/protocols/zai-messages.js +3 -2
  51. package/dist/provider-error.js +5 -3
  52. package/dist/providers/alibaba.d.ts +69 -69
  53. package/dist/providers/amazon-bedrock-mantle.d.ts +202 -202
  54. package/dist/providers/amazon-bedrock.d.ts +15 -15
  55. package/dist/providers/anthropic-compatible.d.ts +13 -13
  56. package/dist/providers/anthropic.d.ts +13 -13
  57. package/dist/providers/azure.d.ts +106 -106
  58. package/dist/providers/baseten.d.ts +24 -24
  59. package/dist/providers/cerebras.d.ts +24 -24
  60. package/dist/providers/cloudflare-ai-gateway.d.ts +230 -227
  61. package/dist/providers/cloudflare-ai-gateway.js +1 -2
  62. package/dist/providers/cloudflare-workers-ai.d.ts +24 -24
  63. package/dist/providers/cohere.d.ts +75 -75
  64. package/dist/providers/deepinfra.d.ts +24 -24
  65. package/dist/providers/deepseek.d.ts +24 -24
  66. package/dist/providers/digitalocean.d.ts +36 -36
  67. package/dist/providers/fireworks.d.ts +24 -24
  68. package/dist/providers/google-vertex-chat.d.ts +12 -12
  69. package/dist/providers/google-vertex-messages.d.ts +13 -13
  70. package/dist/providers/google-vertex-mistral.d.ts +17 -17
  71. package/dist/providers/google-vertex-responses.d.ts +35 -35
  72. package/dist/providers/google-vertex.d.ts +17 -17
  73. package/dist/providers/google-vertex.js +2 -2
  74. package/dist/providers/google.d.ts +17 -17
  75. package/dist/providers/groq.d.ts +24 -24
  76. package/dist/providers/meta.d.ts +179 -179
  77. package/dist/providers/minimax.d.ts +71 -71
  78. package/dist/providers/mistral.d.ts +28 -28
  79. package/dist/providers/moonshot.d.ts +202 -202
  80. package/dist/providers/open-responses-options.d.ts +0 -1
  81. package/dist/providers/open-responses-options.js +1 -1
  82. package/dist/providers/openai-compatible-responses.d.ts +35 -35
  83. package/dist/providers/openai-compatible.d.ts +12 -12
  84. package/dist/providers/openai-compatible.js +1 -1
  85. package/dist/providers/openai-options.d.ts +0 -1
  86. package/dist/providers/openai-options.js +0 -1
  87. package/dist/providers/openai.d.ts +100 -100
  88. package/dist/providers/openrouter.d.ts +36 -36
  89. package/dist/providers/togetherai.d.ts +24 -24
  90. package/dist/providers/venice.d.ts +195 -20
  91. package/dist/providers/xai.d.ts +12 -12
  92. package/dist/providers/zai-coding-plan.d.ts +149 -69
  93. package/dist/providers/zai.d.ts +84 -19
  94. package/dist/route/auth-options.d.ts +0 -3
  95. package/dist/route/auth.d.ts +0 -2
  96. package/dist/route/auth.js +0 -2
  97. package/dist/route/client.d.ts +0 -2
  98. package/dist/route/client.js +3 -4
  99. package/dist/route/executor-service.js +1 -1
  100. package/dist/speech-client.d.ts +8 -8
  101. package/dist/speech.d.ts +148 -148
  102. package/dist/transcription-client.d.ts +8 -8
  103. package/dist/transcription.d.ts +148 -148
  104. package/dist/video-client.d.ts +8 -8
  105. package/dist/video.d.ts +114 -114
  106. package/package.json +6 -5
@@ -19,13 +19,6 @@ export declare const routes: Route<{
19
19
  readonly messages: readonly ({
20
20
  readonly role: "system";
21
21
  readonly content: string | readonly ({
22
- readonly type: "text";
23
- readonly text: string;
24
- readonly cache_control?: {
25
- readonly type: "ephemeral";
26
- readonly ttl?: string | undefined;
27
- } | undefined;
28
- } | {
29
22
  readonly type: "image_url";
30
23
  readonly image_url: {
31
24
  readonly url: string;
@@ -36,17 +29,17 @@ export declare const routes: Route<{
36
29
  readonly filename: string;
37
30
  readonly file_data: string;
38
31
  };
39
- })[];
40
- } | {
41
- readonly role: "user";
42
- readonly content: string | readonly ({
32
+ } | {
43
33
  readonly type: "text";
44
34
  readonly text: string;
45
35
  readonly cache_control?: {
46
36
  readonly type: "ephemeral";
47
37
  readonly ttl?: string | undefined;
48
38
  } | undefined;
49
- } | {
39
+ })[];
40
+ } | {
41
+ readonly role: "user";
42
+ readonly content: string | readonly ({
50
43
  readonly type: "image_url";
51
44
  readonly image_url: {
52
45
  readonly url: string;
@@ -57,6 +50,13 @@ export declare const routes: Route<{
57
50
  readonly filename: string;
58
51
  readonly file_data: string;
59
52
  };
53
+ } | {
54
+ readonly type: "text";
55
+ readonly text: string;
56
+ readonly cache_control?: {
57
+ readonly type: "ephemeral";
58
+ readonly ttl?: string | undefined;
59
+ } | undefined;
60
60
  })[];
61
61
  } | {
62
62
  readonly role: "tool";
@@ -136,31 +136,96 @@ export declare const routes: Route<{
136
136
  readonly seed?: number | undefined;
137
137
  readonly stop?: readonly string[] | undefined;
138
138
  readonly thinking?: {
139
- readonly type?: string | undefined;
139
+ readonly type?: import("../schema/options.js").OpenString<"disabled" | "enabled"> | undefined;
140
140
  readonly clear_thinking?: boolean | undefined;
141
141
  } | undefined;
142
142
  readonly do_sample?: boolean | undefined;
143
143
  readonly response_format?: {
144
- readonly type: string;
144
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "text">;
145
145
  } | undefined;
146
146
  readonly request_id?: string | undefined;
147
147
  readonly user_id?: string | undefined;
148
148
  }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
149
149
  export declare const configure: (input?: Config) => {
150
150
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
151
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ZAIChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
152
- chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ZAIChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
151
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
152
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
153
+ readonly thinking?: {
154
+ readonly type?: import("../schema/options.js").OpenString<"disabled" | "enabled"> | undefined;
155
+ readonly clear_thinking?: boolean | undefined;
156
+ } | undefined;
157
+ readonly toolStream?: boolean | undefined;
158
+ readonly doSample?: boolean | undefined;
159
+ readonly responseFormat?: {
160
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "text">;
161
+ } | undefined;
162
+ readonly requestID?: string | undefined;
163
+ readonly userID?: string | undefined;
164
+ }, import("../route/client.js").CompactionOperations | undefined>;
165
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
166
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
167
+ readonly thinking?: {
168
+ readonly type?: import("../schema/options.js").OpenString<"disabled" | "enabled"> | undefined;
169
+ readonly clear_thinking?: boolean | undefined;
170
+ } | undefined;
171
+ readonly toolStream?: boolean | undefined;
172
+ readonly doSample?: boolean | undefined;
173
+ readonly responseFormat?: {
174
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "text">;
175
+ } | undefined;
176
+ readonly requestID?: string | undefined;
177
+ readonly userID?: string | undefined;
178
+ }, import("../route/client.js").CompactionOperations | undefined>;
153
179
  image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
154
180
  configure: typeof configure;
155
181
  };
156
182
  export declare const provider: {
157
183
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
158
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ZAIChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
159
- chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ZAIChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
184
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
185
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
186
+ readonly thinking?: {
187
+ readonly type?: import("../schema/options.js").OpenString<"disabled" | "enabled"> | undefined;
188
+ readonly clear_thinking?: boolean | undefined;
189
+ } | undefined;
190
+ readonly toolStream?: boolean | undefined;
191
+ readonly doSample?: boolean | undefined;
192
+ readonly responseFormat?: {
193
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "text">;
194
+ } | undefined;
195
+ readonly requestID?: string | undefined;
196
+ readonly userID?: string | undefined;
197
+ }, import("../route/client.js").CompactionOperations | undefined>;
198
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
199
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
200
+ readonly thinking?: {
201
+ readonly type?: import("../schema/options.js").OpenString<"disabled" | "enabled"> | undefined;
202
+ readonly clear_thinking?: boolean | undefined;
203
+ } | undefined;
204
+ readonly toolStream?: boolean | undefined;
205
+ readonly doSample?: boolean | undefined;
206
+ readonly responseFormat?: {
207
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "text">;
208
+ } | undefined;
209
+ readonly requestID?: string | undefined;
210
+ readonly userID?: string | undefined;
211
+ }, import("../route/client.js").CompactionOperations | undefined>;
160
212
  image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
161
213
  configure: typeof configure;
162
214
  };
163
215
  export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
164
- export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ZAIChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
216
+ export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
217
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
218
+ readonly thinking?: {
219
+ readonly type?: import("../schema/options.js").OpenString<"disabled" | "enabled"> | undefined;
220
+ readonly clear_thinking?: boolean | undefined;
221
+ } | undefined;
222
+ readonly toolStream?: boolean | undefined;
223
+ readonly doSample?: boolean | undefined;
224
+ readonly responseFormat?: {
225
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "text">;
226
+ } | undefined;
227
+ readonly requestID?: string | undefined;
228
+ readonly userID?: string | undefined;
229
+ }, import("../route/client.js").CompactionOperations | undefined>;
165
230
  export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
166
231
  export * as ZAI from "./zai.js";
@@ -14,9 +14,6 @@ export type RequiredApiKeyAuth = {
14
14
  readonly auth?: never;
15
15
  };
16
16
  export type ProviderAuthOption<Mode extends ApiKeyMode> = AuthOverride | (Mode extends "optional" ? OptionalApiKeyAuth : RequiredApiKeyAuth);
17
- export type LanguageModelOptions<Base, Mode extends ApiKeyMode> = Omit<Base, "apiKey" | "auth"> & ProviderAuthOption<Mode>;
18
- export type LanguageModelArgs<Base, Mode extends ApiKeyMode> = Mode extends "optional" ? readonly [options?: LanguageModelOptions<Base, Mode>] : readonly [options: LanguageModelOptions<Base, Mode>];
19
- export type LanguageModelFactory<Base, Mode extends ApiKeyMode, LanguageModel> = (id: string, ...args: LanguageModelArgs<Base, Mode>) => LanguageModel;
20
17
  /**
21
18
  * Require at least one of the keys in `T`. Use for option shapes where any
22
19
  * subset of fields is acceptable but at least one must be present (e.g. Azure
@@ -31,7 +31,6 @@ export interface Definition {
31
31
  readonly orElse: (that: Definition) => Definition;
32
32
  readonly pipe: <A>(f: (self: Definition) => A) => A;
33
33
  }
34
- export declare const isAuth: (input: unknown) => input is Definition;
35
34
  export declare const value: (secret: string, source?: string) => Credential;
36
35
  export declare const optional: (secret: Secret | undefined, source?: string) => Credential;
37
36
  export declare const config: (name: string) => Credential;
@@ -42,7 +41,6 @@ export declare const remove: (name: string) => Definition;
42
41
  export declare const custom: (apply: (input: AuthInput) => Effect.Effect<Headers.Headers, AIError>) => Definition;
43
42
  export declare const passthrough: Definition;
44
43
  export declare function bearer(source: Secret | Credential): Definition;
45
- export declare const apiKey: typeof bearer;
46
44
  export declare function header(name: string): (source: Secret | Credential) => Definition;
47
45
  export declare function header(name: string, source: Secret | Credential): Definition;
48
46
  export declare function bearerHeader(name: string): (source: Secret | Credential) => Definition;
@@ -9,7 +9,6 @@ export class MissingCredentialError extends Error {
9
9
  this.source = source;
10
10
  }
11
11
  }
12
- export const isAuth = (input) => typeof input === "object" && input !== null && "apply" in input && typeof input.apply === "function";
13
12
  const credential = (load) => {
14
13
  const self = {
15
14
  load,
@@ -65,7 +64,6 @@ const credentialInput = (source) => typeof source === "string" || Redacted.isRed
65
64
  export function bearer(source) {
66
65
  return credentialInput(source).bearer();
67
66
  }
68
- export const apiKey = bearer;
69
67
  export function header(name, source) {
70
68
  if (source === undefined) {
71
69
  return (next) => credentialInput(next).header(name);
@@ -46,7 +46,6 @@ export interface Route<Body, Prepared = unknown, Compact extends CompactionOpera
46
46
  readonly streamPrepared: (prepared: Prepared, request: LLMRequest, runtime: TransportRuntime, options?: StreamOptions) => Stream.Stream<LLMEvent, AIError>;
47
47
  }
48
48
  export type AnyRoute<Compact extends CompactionOperations | undefined = CompactionOperations | undefined> = Route<any, any, Compact>;
49
- export type HttpOptionsInput = HttpOptions.Input;
50
49
  export type RouteLanguageModelInput = Omit<LanguageModel.Input, "provider" | "route">;
51
50
  export type RouteRoutedLanguageModelInput = Omit<LanguageModel.Input, "route">;
52
51
  export interface RouteDefaults {
@@ -71,7 +70,6 @@ export interface RoutePatch<Body, Prepared> extends RouteDefaultsInput {
71
70
  readonly endpoint?: EndpointPatch<Body>;
72
71
  }
73
72
  type RouteMappedLanguageModelInput = RouteLanguageModelInput | RouteRoutedLanguageModelInput;
74
- export declare const generationOptions: (input: GenerationOptions.Input | undefined) => GenerationOptions | undefined;
75
73
  export interface Interface {
76
74
  readonly compact: CompactMethod;
77
75
  readonly stream: StreamMethod;
@@ -32,7 +32,7 @@ const mergeRouteDefaults = (base, patch) => {
32
32
  ...base,
33
33
  ...patch,
34
34
  headers,
35
- generation: mergeGenerationOptions(generationOptions(base?.generation), generationOptions(patch.generation)),
35
+ generation: mergeGenerationOptions(base?.generation, patch.generation),
36
36
  providerOptions: mergeProviderOptions(base?.providerOptions, patch.providerOptions),
37
37
  http: mergeHttpOptions(base?.http, HttpOptions.make(patch.http), headers === undefined ? undefined : new HttpOptions({ headers })),
38
38
  };
@@ -43,7 +43,6 @@ const mergeHeaders = (...items) => {
43
43
  return undefined;
44
44
  return Object.fromEntries(entries);
45
45
  };
46
- export const generationOptions = (input) => input === undefined ? undefined : GenerationOptions.make(input);
47
46
  export function canCompact(request, options) {
48
47
  if (options?.mechanism === "trigger")
49
48
  return request.model.route.compact?.trigger !== undefined;
@@ -126,8 +125,8 @@ function makeFromTransport(input) {
126
125
  id: id ?? routeInput.id,
127
126
  provider: provider ?? routeInput.provider,
128
127
  providerMetadataKey: providerMetadataKey ??
129
- (provider !== undefined && String(provider) !== String(routeInput.provider)
130
- ? String(provider)
128
+ (provider !== undefined && provider !== routeInput.provider
129
+ ? provider
131
130
  : routeInput.providerMetadataKey),
132
131
  auth: auth ?? routeInput.auth,
133
132
  endpoint: endpoint ? Endpoint.merge(routeInput.endpoint, endpoint) : routeInput.endpoint,
@@ -3,7 +3,7 @@ import { HttpContext } from "../schema/errors.js";
3
3
  export class RequestExecutorService extends Context.Service()("@opencode/AI/RequestExecutor") {
4
4
  }
5
5
  export const Service = RequestExecutorService;
6
- export const headerDetails = (headers) => Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, String(value)]));
6
+ export const headerDetails = (headers) => Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, value]));
7
7
  export const responseHttp = (response) => new HttpContext({
8
8
  url: response.request.url,
9
9
  status: response.status,
@@ -24,14 +24,6 @@ export declare const SpeechClient: {
24
24
  readonly type: "finish";
25
25
  readonly audio: import("./media.js").Asset;
26
26
  readonly usage?: {
27
- readonly type: "tokens";
28
- readonly input?: number | undefined;
29
- readonly output?: number | undefined;
30
- readonly total?: number | undefined;
31
- readonly details?: {
32
- readonly [x: string]: unknown;
33
- } | undefined;
34
- } | {
35
27
  readonly type: "seconds";
36
28
  readonly seconds: number;
37
29
  } | {
@@ -43,6 +35,14 @@ export declare const SpeechClient: {
43
35
  } | {
44
36
  readonly type: "compute";
45
37
  readonly seconds: number;
38
+ } | {
39
+ readonly type: "tokens";
40
+ readonly input?: number | undefined;
41
+ readonly output?: number | undefined;
42
+ readonly total?: number | undefined;
43
+ readonly details?: {
44
+ readonly [x: string]: unknown;
45
+ } | undefined;
46
46
  } | undefined;
47
47
  readonly notices?: readonly {
48
48
  readonly type: "filtered" | "moderated" | "other";