@opencode-ai/ai 0.0.0-beta-18219 → 0.0.0-beta-18269

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 (32) hide show
  1. package/dist/cache-policy.js +1 -1
  2. package/dist/protocols/anthropic-messages.js +8 -4
  3. package/dist/protocols/open-responses.d.ts +231 -25
  4. package/dist/protocols/open-responses.js +98 -79
  5. package/dist/protocols/openai-chat.d.ts +1 -0
  6. package/dist/protocols/openai-chat.js +36 -17
  7. package/dist/protocols/openai-compatible-responses.d.ts +37 -3
  8. package/dist/protocols/openai-responses.d.ts +403 -50
  9. package/dist/protocols/openai-responses.js +30 -21
  10. package/dist/protocols/shared.d.ts +3 -4
  11. package/dist/protocols/shared.js +18 -5
  12. package/dist/protocols/utils/open-responses-options.d.ts +0 -1
  13. package/dist/protocols/utils/open-responses-options.js +0 -1
  14. package/dist/protocols/xai-responses.d.ts +52 -3
  15. package/dist/protocols/xai-responses.js +31 -1
  16. package/dist/provider-error.js +4 -2
  17. package/dist/providers/amazon-bedrock-mantle.d.ts +65 -3
  18. package/dist/providers/azure.d.ts +65 -3
  19. package/dist/providers/cerebras.d.ts +228 -0
  20. package/dist/providers/cerebras.js +35 -0
  21. package/dist/providers/deepinfra.d.ts +228 -0
  22. package/dist/providers/deepinfra.js +38 -0
  23. package/dist/providers/google-vertex-responses.d.ts +37 -3
  24. package/dist/providers/index.d.ts +3 -0
  25. package/dist/providers/index.js +3 -0
  26. package/dist/providers/openai-compatible-responses.d.ts +37 -3
  27. package/dist/providers/openai.d.ts +65 -3
  28. package/dist/providers/togetherai.d.ts +228 -0
  29. package/dist/providers/togetherai.js +35 -0
  30. package/dist/schema/options.d.ts +2 -0
  31. package/dist/schema/options.js +2 -0
  32. package/package.json +3 -3
@@ -0,0 +1,228 @@
1
+ import type { ProviderPackage } from "../provider-package.js";
2
+ import { type ProviderAuthOption } from "../route/auth-options.js";
3
+ import type { RouteDefaultsInput } from "../route/client.js";
4
+ import { type ModelID } from "../schema/index.js";
5
+ import type { OpenAIProviderOptionsInput } from "./openai-options.js";
6
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
+ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
8
+ readonly baseURL?: string;
9
+ readonly providerOptions?: OpenAIProviderOptionsInput;
10
+ };
11
+ export interface Settings extends ProviderPackage.Settings {
12
+ readonly apiKey?: string;
13
+ readonly baseURL?: string;
14
+ readonly providerOptions?: OpenAIProviderOptionsInput;
15
+ }
16
+ export declare const route: import("../route/client.js").Route<{
17
+ readonly model: string;
18
+ readonly messages: readonly ({
19
+ readonly role: "system";
20
+ readonly content: string | readonly ({
21
+ readonly type: "text";
22
+ readonly text: string;
23
+ readonly cache_control?: {
24
+ readonly type: "ephemeral";
25
+ readonly ttl?: string | undefined;
26
+ } | undefined;
27
+ } | {
28
+ readonly type: "image_url";
29
+ readonly image_url: {
30
+ readonly url: string;
31
+ };
32
+ })[];
33
+ } | {
34
+ readonly role: "user";
35
+ readonly content: string | readonly ({
36
+ readonly type: "text";
37
+ readonly text: string;
38
+ readonly cache_control?: {
39
+ readonly type: "ephemeral";
40
+ readonly ttl?: string | undefined;
41
+ } | undefined;
42
+ } | {
43
+ readonly type: "image_url";
44
+ readonly image_url: {
45
+ readonly url: string;
46
+ };
47
+ })[];
48
+ } | {
49
+ readonly [x: string]: unknown;
50
+ readonly content: string | null;
51
+ readonly role: "assistant";
52
+ readonly reasoning?: string | undefined;
53
+ readonly reasoning_content?: string | undefined;
54
+ readonly reasoning_text?: string | undefined;
55
+ readonly cache_control?: {
56
+ readonly type: "ephemeral";
57
+ readonly ttl?: string | undefined;
58
+ } | undefined;
59
+ readonly tool_calls?: readonly {
60
+ readonly id: string;
61
+ readonly type: "function";
62
+ readonly function: {
63
+ readonly name: string;
64
+ readonly arguments: string;
65
+ };
66
+ }[] | undefined;
67
+ readonly reasoning_details?: unknown;
68
+ } | {
69
+ readonly content: string;
70
+ readonly role: "tool";
71
+ readonly tool_call_id: string;
72
+ readonly cache_control?: {
73
+ readonly type: "ephemeral";
74
+ readonly ttl?: string | undefined;
75
+ } | undefined;
76
+ })[];
77
+ readonly stream: true;
78
+ readonly max_completion_tokens?: number | undefined;
79
+ readonly max_tokens?: number | undefined;
80
+ readonly tools?: readonly {
81
+ readonly function: {
82
+ readonly description: string;
83
+ readonly name: string;
84
+ readonly parameters: {
85
+ readonly [x: string]: unknown;
86
+ };
87
+ readonly strict?: boolean | undefined;
88
+ };
89
+ readonly type: "function";
90
+ readonly cache_control?: {
91
+ readonly type: "ephemeral";
92
+ readonly ttl?: string | undefined;
93
+ } | undefined;
94
+ }[] | undefined;
95
+ readonly stop?: readonly string[] | undefined;
96
+ readonly temperature?: number | undefined;
97
+ readonly seed?: number | undefined;
98
+ readonly tool_choice?: "required" | "auto" | "none" | {
99
+ readonly type: "function";
100
+ readonly function: {
101
+ readonly name: string;
102
+ };
103
+ } | undefined;
104
+ readonly top_p?: number | undefined;
105
+ readonly store?: boolean | undefined;
106
+ readonly stream_options?: {
107
+ readonly include_usage: boolean;
108
+ } | undefined;
109
+ readonly prompt_cache_key?: string | undefined;
110
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
111
+ readonly tool_stream?: boolean | undefined;
112
+ readonly frequency_penalty?: number | undefined;
113
+ readonly presence_penalty?: number | undefined;
114
+ }, import("../route/transport/http.js").HttpPrepared<string>>;
115
+ export declare const routes: import("../route/client.js").Route<{
116
+ readonly model: string;
117
+ readonly messages: readonly ({
118
+ readonly role: "system";
119
+ readonly content: string | readonly ({
120
+ readonly type: "text";
121
+ readonly text: string;
122
+ readonly cache_control?: {
123
+ readonly type: "ephemeral";
124
+ readonly ttl?: string | undefined;
125
+ } | undefined;
126
+ } | {
127
+ readonly type: "image_url";
128
+ readonly image_url: {
129
+ readonly url: string;
130
+ };
131
+ })[];
132
+ } | {
133
+ readonly role: "user";
134
+ readonly content: string | readonly ({
135
+ readonly type: "text";
136
+ readonly text: string;
137
+ readonly cache_control?: {
138
+ readonly type: "ephemeral";
139
+ readonly ttl?: string | undefined;
140
+ } | undefined;
141
+ } | {
142
+ readonly type: "image_url";
143
+ readonly image_url: {
144
+ readonly url: string;
145
+ };
146
+ })[];
147
+ } | {
148
+ readonly [x: string]: unknown;
149
+ readonly content: string | null;
150
+ readonly role: "assistant";
151
+ readonly reasoning?: string | undefined;
152
+ readonly reasoning_content?: string | undefined;
153
+ readonly reasoning_text?: string | undefined;
154
+ readonly cache_control?: {
155
+ readonly type: "ephemeral";
156
+ readonly ttl?: string | undefined;
157
+ } | undefined;
158
+ readonly tool_calls?: readonly {
159
+ readonly id: string;
160
+ readonly type: "function";
161
+ readonly function: {
162
+ readonly name: string;
163
+ readonly arguments: string;
164
+ };
165
+ }[] | undefined;
166
+ readonly reasoning_details?: unknown;
167
+ } | {
168
+ readonly content: string;
169
+ readonly role: "tool";
170
+ readonly tool_call_id: string;
171
+ readonly cache_control?: {
172
+ readonly type: "ephemeral";
173
+ readonly ttl?: string | undefined;
174
+ } | undefined;
175
+ })[];
176
+ readonly stream: true;
177
+ readonly max_completion_tokens?: number | undefined;
178
+ readonly max_tokens?: number | undefined;
179
+ readonly tools?: readonly {
180
+ readonly function: {
181
+ readonly description: string;
182
+ readonly name: string;
183
+ readonly parameters: {
184
+ readonly [x: string]: unknown;
185
+ };
186
+ readonly strict?: boolean | undefined;
187
+ };
188
+ readonly type: "function";
189
+ readonly cache_control?: {
190
+ readonly type: "ephemeral";
191
+ readonly ttl?: string | undefined;
192
+ } | undefined;
193
+ }[] | undefined;
194
+ readonly stop?: readonly string[] | undefined;
195
+ readonly temperature?: number | undefined;
196
+ readonly seed?: number | undefined;
197
+ readonly tool_choice?: "required" | "auto" | "none" | {
198
+ readonly type: "function";
199
+ readonly function: {
200
+ readonly name: string;
201
+ };
202
+ } | undefined;
203
+ readonly top_p?: number | undefined;
204
+ readonly store?: boolean | undefined;
205
+ readonly stream_options?: {
206
+ readonly include_usage: boolean;
207
+ } | undefined;
208
+ readonly prompt_cache_key?: string | undefined;
209
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
210
+ readonly tool_stream?: boolean | undefined;
211
+ readonly frequency_penalty?: number | undefined;
212
+ readonly presence_penalty?: number | undefined;
213
+ }, import("../route/transport/http.js").HttpPrepared<string>>[];
214
+ export declare const configure: (input?: LanguageModelOptions) => {
215
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
216
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
217
+ configure: (input?: LanguageModelOptions) => /*elided*/ any;
218
+ };
219
+ export declare const provider: {
220
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
221
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
222
+ configure: (input?: LanguageModelOptions) => {
223
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
224
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
225
+ configure: /*elided*/ any;
226
+ };
227
+ };
228
+ export declare const model: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
@@ -0,0 +1,35 @@
1
+ import { OpenAICompatibleChat } from "../protocols/openai-compatible-chat.js";
2
+ import { AuthOptions } from "../route/auth-options.js";
3
+ import { ProviderID } from "../schema/index.js";
4
+ import { profiles } from "./openai-compatible-profile.js";
5
+ export const id = ProviderID.make("togetherai");
6
+ export const route = OpenAICompatibleChat.route.with({
7
+ id: "togetherai-chat",
8
+ provider: id,
9
+ endpoint: { baseURL: profiles.togetherai.baseURL },
10
+ });
11
+ export const routes = [route];
12
+ export const configure = (input = {}) => {
13
+ const { apiKey: _apiKey, auth: _auth, baseURL, ...defaults } = input;
14
+ const configured = route.with({
15
+ ...defaults,
16
+ endpoint: { baseURL: baseURL ?? profiles.togetherai.baseURL },
17
+ auth: AuthOptions.bearer(input, ["TOGETHER_API_KEY", "TOGETHER_AI_API_KEY"]),
18
+ });
19
+ return {
20
+ id,
21
+ model: (modelID) => configured.model({
22
+ id: modelID,
23
+ compatibility: { maxTokensField: "max_tokens", supportsStore: false, supportsStrictMode: false },
24
+ }),
25
+ configure,
26
+ };
27
+ };
28
+ export const provider = configure();
29
+ export const model = (modelID, settings) => configure({
30
+ apiKey: settings.apiKey,
31
+ baseURL: settings.baseURL,
32
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
33
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
34
+ providerOptions: settings.providerOptions,
35
+ }).model(modelID);
@@ -72,6 +72,8 @@ export type LanguageModelMaxTokensFieldCompatibility = Schema.Schema.Type<typeof
72
72
  declare const LanguageModelCompatibility_base: Schema.Class<LanguageModelCompatibility, Schema.Struct<{
73
73
  readonly toolSchema: Schema.optional<Schema.Literals<readonly ["gemini", "moonshot"]>>;
74
74
  readonly reasoningField: Schema.optional<Schema.String>;
75
+ /** Require every assistant message to include its reasoning field, even when empty. */
76
+ readonly requireReasoning: Schema.optional<Schema.Boolean>;
75
77
  readonly maxTokensField: Schema.optional<Schema.Literals<readonly ["max_completion_tokens", "max_tokens"]>>;
76
78
  readonly requireFinishReason: Schema.optional<Schema.Boolean>;
77
79
  readonly requireAssistantAfterTool: Schema.optional<Schema.Boolean>;
@@ -99,6 +99,8 @@ export const LanguageModelMaxTokensFieldCompatibility = Schema.Literals(["max_co
99
99
  export class LanguageModelCompatibility extends Schema.Class("LLM.LanguageModelCompatibility")({
100
100
  toolSchema: Schema.optional(LanguageModelToolSchemaCompatibility),
101
101
  reasoningField: Schema.optional(Schema.String),
102
+ /** Require every assistant message to include its reasoning field, even when empty. */
103
+ requireReasoning: Schema.optional(Schema.Boolean),
102
104
  maxTokensField: Schema.optional(LanguageModelMaxTokensFieldCompatibility),
103
105
  requireFinishReason: Schema.optional(Schema.Boolean),
104
106
  requireAssistantAfterTool: Schema.optional(Schema.Boolean),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-beta-18219",
3
+ "version": "0.0.0-beta-18269",
4
4
  "name": "@opencode-ai/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "@clack/prompts": "1.0.0-alpha.1",
32
32
  "@effect/platform-node": "4.0.0-rc.111",
33
- "@opencode-ai/http-recorder": "0.0.0-beta-18219",
33
+ "@opencode-ai/http-recorder": "0.0.0-beta-18269",
34
34
  "@tsconfig/bun": "1.0.9",
35
35
  "@types/bun": "1.3.13",
36
36
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@smithy/eventstream-codec": "4.2.14",
41
41
  "@smithy/util-utf8": "4.2.2",
42
- "@opencode-ai/schema": "0.0.0-beta-18219",
42
+ "@opencode-ai/schema": "0.0.0-beta-18269",
43
43
  "aws4fetch": "1.0.20",
44
44
  "effect": "4.0.0-rc.111",
45
45
  "google-auth-library": "10.5.0"