@opencode-ai/ai 0.0.0-dev-17711 → 0.0.0-dev-17717
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.
- package/README.md +1 -2
- package/dist/protocols/anthropic-messages.d.ts +1 -0
- package/dist/protocols/anthropic-messages.js +2 -2
- package/dist/protocols/open-responses.js +20 -0
- package/dist/protocols/openai-chat.d.ts +2 -0
- package/dist/protocols/openai-chat.js +8 -2
- package/dist/provider-package.d.ts +0 -5
- package/dist/providers/amazon-bedrock-mantle.js +0 -1
- package/dist/providers/amazon-bedrock.js +0 -1
- package/dist/providers/anthropic-compatible.js +0 -1
- package/dist/providers/anthropic.js +0 -1
- package/dist/providers/azure.js +0 -1
- package/dist/providers/google-vertex-chat.js +0 -1
- package/dist/providers/google-vertex-messages.js +0 -1
- package/dist/providers/google-vertex-responses.js +0 -1
- package/dist/providers/google-vertex.js +0 -1
- package/dist/providers/google.js +0 -1
- package/dist/providers/openai-compatible-responses.js +0 -1
- package/dist/providers/openai-compatible.js +0 -1
- package/dist/providers/openai.js +0 -1
- package/dist/providers/openrouter.d.ts +1 -0
- package/dist/providers/openrouter.js +0 -1
- package/dist/providers/xai.js +0 -1
- package/dist/route/client.d.ts +1 -3
- package/dist/route/client.js +1 -2
- package/dist/schema/options.d.ts +0 -14
- package/dist/schema/options.js +0 -12
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -309,7 +309,7 @@ Included providers: OpenAI, Anthropic, Google (Gemini), Google Vertex Gemini and
|
|
|
309
309
|
|
|
310
310
|
### Package-like entrypoints
|
|
311
311
|
|
|
312
|
-
Native catalog integrations load provider behavior through package-like entrypoints. These are export paths from the same `@opencode-ai/ai` npm package, not independently published packages. Each entrypoint exports the same `model(modelID, settings)` contract, and `settings` contains serializable provider configuration plus common `headers
|
|
312
|
+
Native catalog integrations load provider behavior through package-like entrypoints. These are export paths from the same `@opencode-ai/ai` npm package, not independently published packages. Each entrypoint exports the same `model(modelID, settings)` contract, and `settings` contains serializable provider configuration plus common `headers` and `body` overlays.
|
|
313
313
|
|
|
314
314
|
```ts
|
|
315
315
|
import { model } from "@opencode-ai/ai/providers/openai/responses"
|
|
@@ -317,7 +317,6 @@ import { model } from "@opencode-ai/ai/providers/openai/responses"
|
|
|
317
317
|
const selected = model("gpt-5", {
|
|
318
318
|
apiKey: process.env.OPENAI_API_KEY,
|
|
319
319
|
headers: { "x-application": "opencode" },
|
|
320
|
-
limits: { context: 200_000, output: 64_000 },
|
|
321
320
|
})
|
|
322
321
|
```
|
|
323
322
|
|
|
@@ -5,6 +5,7 @@ import { Lifecycle } from "./utils/lifecycle.js";
|
|
|
5
5
|
import { ToolStream } from "./utils/tool-stream.js";
|
|
6
6
|
export declare const DEFAULT_BASE_URL = "https://api.anthropic.com/v1";
|
|
7
7
|
export declare const PATH = "/messages";
|
|
8
|
+
export declare const DEFAULT_MAX_TOKENS = 32000;
|
|
8
9
|
export type ThinkingInput = {
|
|
9
10
|
readonly type: "adaptive";
|
|
10
11
|
readonly display?: "summarized" | "omitted";
|
|
@@ -15,6 +15,7 @@ import { ToolStream } from "./utils/tool-stream.js";
|
|
|
15
15
|
const ADAPTER = "anthropic-messages";
|
|
16
16
|
export const DEFAULT_BASE_URL = "https://api.anthropic.com/v1";
|
|
17
17
|
export const PATH = "/messages";
|
|
18
|
+
export const DEFAULT_MAX_TOKENS = 32_000;
|
|
18
19
|
// =============================================================================
|
|
19
20
|
// Request Body Schema
|
|
20
21
|
// =============================================================================
|
|
@@ -501,7 +502,6 @@ const resolveThinking = Effect.fn("AnthropicMessages.resolveThinking")(function*
|
|
|
501
502
|
const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (request) {
|
|
502
503
|
const generation = request.generation;
|
|
503
504
|
const toolSchemaCompatibility = request.model.compatibility?.toolSchema;
|
|
504
|
-
const outputLimit = request.model.defaults?.limits?.output ?? request.model.route.defaults.limits?.output ?? 4096;
|
|
505
505
|
// Allocate the 4-breakpoint budget in invalidation order: tools → system →
|
|
506
506
|
// messages. Tools live highest in the cache hierarchy, so when callers
|
|
507
507
|
// over-mark we keep their tool hints and shed the message-tail ones first.
|
|
@@ -530,7 +530,7 @@ const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (reques
|
|
|
530
530
|
tools,
|
|
531
531
|
tool_choice: toolChoice,
|
|
532
532
|
stream: true,
|
|
533
|
-
max_tokens: generation?.maxTokens ??
|
|
533
|
+
max_tokens: generation?.maxTokens ?? DEFAULT_MAX_TOKENS,
|
|
534
534
|
temperature: generation?.temperature,
|
|
535
535
|
top_p: generation?.topP,
|
|
536
536
|
top_k: generation?.topK,
|
|
@@ -210,6 +210,19 @@ export const Event = Schema.StructWithRest(Schema.Struct({
|
|
|
210
210
|
status_code: Schema.optional(Schema.Unknown),
|
|
211
211
|
headers: Schema.optional(Schema.Unknown),
|
|
212
212
|
}), [Schema.Record(Schema.String, Schema.Unknown)]);
|
|
213
|
+
const RefusalEvent = Schema.Union([
|
|
214
|
+
Schema.Struct({
|
|
215
|
+
type: Schema.tag("response.refusal.delta"),
|
|
216
|
+
item_id: Schema.String,
|
|
217
|
+
delta: Schema.String,
|
|
218
|
+
}),
|
|
219
|
+
Schema.Struct({
|
|
220
|
+
type: Schema.tag("response.refusal.done"),
|
|
221
|
+
item_id: Schema.String,
|
|
222
|
+
refusal: Schema.String,
|
|
223
|
+
}),
|
|
224
|
+
]);
|
|
225
|
+
const isRefusalEvent = Schema.is(RefusalEvent);
|
|
213
226
|
const BASE = { id: ADAPTER, name: NAME };
|
|
214
227
|
// =============================================================================
|
|
215
228
|
// Request Lowering
|
|
@@ -832,6 +845,13 @@ export const step = (state, event) => {
|
|
|
832
845
|
? onOutputTextDelta(state, event, event.item_id)
|
|
833
846
|
: onOutputTextDone(state, event, event.item_id));
|
|
834
847
|
}
|
|
848
|
+
if (event.type === "response.refusal.delta" || event.type === "response.refusal.done") {
|
|
849
|
+
if (!isRefusalEvent(event))
|
|
850
|
+
return ProviderShared.eventError(state.id, `${event.type} is malformed`);
|
|
851
|
+
return Effect.succeed(event.type === "response.refusal.delta"
|
|
852
|
+
? onOutputTextDelta(state, event, event.item_id)
|
|
853
|
+
: onOutputTextDone(state, { ...event, text: event.refusal }, event.item_id));
|
|
854
|
+
}
|
|
835
855
|
if (event.type === "response.reasoning.delta" || event.type === "response.reasoning_summary_text.delta") {
|
|
836
856
|
if (!event.item_id)
|
|
837
857
|
return ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
|
|
@@ -204,6 +204,7 @@ export declare const OpenAIChatEvent: Schema.Struct<{
|
|
|
204
204
|
readonly choices: Schema.optional<Schema.NullOr<Schema.$Array<Schema.Struct<{
|
|
205
205
|
readonly delta: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
|
|
206
206
|
readonly content: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
207
|
+
readonly refusal: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
207
208
|
readonly reasoning_content: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
208
209
|
readonly reasoning: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
209
210
|
readonly reasoning_text: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
@@ -584,6 +585,7 @@ export declare const protocol: Protocol<{
|
|
|
584
585
|
readonly reasoning_content?: string | null | undefined;
|
|
585
586
|
readonly reasoning_text?: string | null | undefined;
|
|
586
587
|
readonly content?: string | null | undefined;
|
|
588
|
+
readonly refusal?: string | null | undefined;
|
|
587
589
|
readonly tool_calls?: readonly {
|
|
588
590
|
readonly function?: {
|
|
589
591
|
readonly name?: string | null | undefined;
|
|
@@ -13,7 +13,7 @@ import { Lifecycle } from "./utils/lifecycle.js";
|
|
|
13
13
|
import { ToolSchemaProjection } from "./utils/tool-schema.js";
|
|
14
14
|
import { ToolStream } from "./utils/tool-stream.js";
|
|
15
15
|
const ADAPTER = "openai-chat";
|
|
16
|
-
const RESERVED_REASONING_FIELDS = new Set(["role", "content", "tool_calls"]);
|
|
16
|
+
const RESERVED_REASONING_FIELDS = new Set(["role", "content", "refusal", "tool_calls"]);
|
|
17
17
|
export const DEFAULT_BASE_URL = "https://api.openai.com/v1";
|
|
18
18
|
export const PATH = "/chat/completions";
|
|
19
19
|
// =============================================================================
|
|
@@ -144,6 +144,7 @@ const OpenAIChatToolCallDelta = Schema.Struct({
|
|
|
144
144
|
});
|
|
145
145
|
const OpenAIChatDelta = Schema.StructWithRest(Schema.Struct({
|
|
146
146
|
content: optionalNull(Schema.String),
|
|
147
|
+
refusal: optionalNull(Schema.String),
|
|
147
148
|
reasoning_content: optionalNull(Schema.String),
|
|
148
149
|
reasoning: optionalNull(Schema.String),
|
|
149
150
|
reasoning_text: optionalNull(Schema.String),
|
|
@@ -568,6 +569,7 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
568
569
|
let lifecycle = state.lifecycle;
|
|
569
570
|
const reasoning = reasoningDelta(delta, state.reasoningField);
|
|
570
571
|
const hasLateContent = Boolean(delta?.content) ||
|
|
572
|
+
Boolean(delta?.refusal) ||
|
|
571
573
|
reasoning !== undefined ||
|
|
572
574
|
(Array.isArray(delta?.reasoning_details) && delta.reasoning_details.length > 0) ||
|
|
573
575
|
toolDeltas.some((tool) => Boolean(tool.id) || Boolean(tool.function?.name) || Boolean(tool.function?.arguments));
|
|
@@ -587,13 +589,17 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
587
589
|
lifecycle = Lifecycle.reasoningDelta(lifecycle, events, "reasoning-0", text, deltaMetadata);
|
|
588
590
|
else if (reasoningDetailsObserved &&
|
|
589
591
|
!lifecycle.reasoning.has("reasoning-0") &&
|
|
590
|
-
(Boolean(delta?.content) || toolDeltas.length > 0))
|
|
592
|
+
(Boolean(delta?.content) || Boolean(delta?.refusal) || toolDeltas.length > 0))
|
|
591
593
|
lifecycle = Lifecycle.reasoningStart(lifecycle, events, "reasoning-0", deltaMetadata);
|
|
592
594
|
const reasoningEmitted = state.reasoningEmitted || lifecycle.reasoning.has("reasoning-0");
|
|
593
595
|
if (delta?.content) {
|
|
594
596
|
lifecycle = Lifecycle.reasoningEnd(lifecycle, events, "reasoning-0", reasoningMetadata(reasoningField, reasoningDetailsObserved ? state.reasoningDetails : undefined));
|
|
595
597
|
lifecycle = Lifecycle.textDelta(lifecycle, events, "text-0", delta.content);
|
|
596
598
|
}
|
|
599
|
+
if (delta?.refusal) {
|
|
600
|
+
lifecycle = Lifecycle.reasoningEnd(lifecycle, events, "reasoning-0", reasoningMetadata(reasoningField, reasoningDetailsObserved ? state.reasoningDetails : undefined));
|
|
601
|
+
lifecycle = Lifecycle.textDelta(lifecycle, events, "text-0", delta.refusal);
|
|
602
|
+
}
|
|
597
603
|
// Compatible providers may omit indexes. Prefer durable identity, then use
|
|
598
604
|
// batch position for parallel deltas or the latest call for sparse chunks.
|
|
599
605
|
for (const [position, tool] of toolDeltas.entries()) {
|
|
@@ -3,11 +3,6 @@ export interface Settings extends Readonly<Record<string, unknown>> {
|
|
|
3
3
|
readonly baseURL?: string;
|
|
4
4
|
readonly headers?: Readonly<Record<string, string>>;
|
|
5
5
|
readonly body?: Readonly<Record<string, unknown>>;
|
|
6
|
-
readonly limits?: {
|
|
7
|
-
readonly context: number;
|
|
8
|
-
readonly input?: number;
|
|
9
|
-
readonly output: number;
|
|
10
|
-
};
|
|
11
6
|
}
|
|
12
7
|
export interface Definition<ProviderSettings extends Settings = Settings, Options extends ProviderOptions = ProviderOptions> {
|
|
13
8
|
readonly model: (modelID: string, settings: ProviderSettings) => LanguageModel<Options>;
|
|
@@ -58,7 +58,6 @@ const config = (settings) => {
|
|
|
58
58
|
credentials: settings.credentials,
|
|
59
59
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
60
60
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
61
|
-
limits: settings.limits,
|
|
62
61
|
providerOptions: settings.providerOptions,
|
|
63
62
|
region: settings.region,
|
|
64
63
|
};
|
|
@@ -35,7 +35,6 @@ export const model = (modelID, settings) => {
|
|
|
35
35
|
generation: settings.topP === undefined ? undefined : { topP: settings.topP },
|
|
36
36
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
37
37
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
38
|
-
limits: settings.limits,
|
|
39
38
|
region: settings.region,
|
|
40
39
|
}).model(modelID);
|
|
41
40
|
};
|
|
@@ -37,7 +37,6 @@ export const model = (modelID, settings) => {
|
|
|
37
37
|
baseURL: settings.baseURL,
|
|
38
38
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
39
39
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
40
|
-
limits: settings.limits,
|
|
41
40
|
provider: settings.provider,
|
|
42
41
|
providerOptions: settings.providerOptions,
|
|
43
42
|
}).model(modelID);
|
|
@@ -34,7 +34,6 @@ export const model = (modelID, settings) => {
|
|
|
34
34
|
baseURL: settings.baseURL,
|
|
35
35
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
36
36
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
37
|
-
limits: settings.limits,
|
|
38
37
|
providerOptions: settings.providerOptions,
|
|
39
38
|
}).model(modelID);
|
|
40
39
|
};
|
package/dist/providers/azure.js
CHANGED
|
@@ -74,7 +74,6 @@ const config = (settings) => {
|
|
|
74
74
|
apiVersion: settings.apiVersion,
|
|
75
75
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
76
76
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
77
|
-
limits: settings.limits,
|
|
78
77
|
providerOptions: settings.providerOptions,
|
|
79
78
|
queryParams: settings.queryParams === undefined ? undefined : { ...settings.queryParams },
|
|
80
79
|
useDeploymentBasedUrls: settings.useDeploymentBasedUrls,
|
|
@@ -42,7 +42,6 @@ export const model = (modelID, settings) => {
|
|
|
42
42
|
baseURL: settings.baseURL,
|
|
43
43
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
44
44
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
45
|
-
limits: settings.limits,
|
|
46
45
|
location: settings.location,
|
|
47
46
|
project: settings.project,
|
|
48
47
|
providerOptions: settings.providerOptions,
|
|
@@ -67,7 +67,6 @@ export const model = (modelID, settings) => {
|
|
|
67
67
|
baseURL: settings.baseURL,
|
|
68
68
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
69
69
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
70
|
-
limits: settings.limits,
|
|
71
70
|
location: settings.location,
|
|
72
71
|
project: settings.project,
|
|
73
72
|
providerOptions: settings.providerOptions,
|
|
@@ -43,7 +43,6 @@ export const model = (modelID, settings) => {
|
|
|
43
43
|
baseURL: settings.baseURL,
|
|
44
44
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
45
45
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
46
|
-
limits: settings.limits,
|
|
47
46
|
location: settings.location,
|
|
48
47
|
project: settings.project,
|
|
49
48
|
providerOptions: settings.providerOptions,
|
|
@@ -73,7 +73,6 @@ export const model = (modelID, settings) => {
|
|
|
73
73
|
baseURL: settings.baseURL,
|
|
74
74
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
75
75
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
76
|
-
limits: settings.limits,
|
|
77
76
|
location: settings.location,
|
|
78
77
|
project: settings.project,
|
|
79
78
|
providerOptions: settings.providerOptions,
|
package/dist/providers/google.js
CHANGED
|
@@ -37,7 +37,6 @@ export const model = (modelID, settings) => configure({
|
|
|
37
37
|
baseURL: settings.baseURL,
|
|
38
38
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
39
39
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
40
|
-
limits: settings.limits,
|
|
41
40
|
providerOptions: settings.providerOptions,
|
|
42
41
|
}).model(modelID);
|
|
43
42
|
export const image = provider.image;
|
|
@@ -27,7 +27,6 @@ export const model = (modelID, settings) => configure({
|
|
|
27
27
|
baseURL: settings.baseURL,
|
|
28
28
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
29
29
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
30
|
-
limits: settings.limits,
|
|
31
30
|
provider: settings.provider,
|
|
32
31
|
providerOptions: settings.providerOptions,
|
|
33
32
|
}).model(modelID);
|
|
@@ -43,7 +43,6 @@ export const model = (modelID, settings) => configure({
|
|
|
43
43
|
baseURL: settings.baseURL,
|
|
44
44
|
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
45
45
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
46
|
-
limits: settings.limits,
|
|
47
46
|
provider: settings.provider,
|
|
48
47
|
providerOptions: settings.providerOptions,
|
|
49
48
|
}).model(modelID);
|
package/dist/providers/openai.js
CHANGED
|
@@ -69,7 +69,6 @@ const config = (settings) => {
|
|
|
69
69
|
baseURL: settings.baseURL,
|
|
70
70
|
headers: Object.keys(headers).length === 0 ? undefined : headers,
|
|
71
71
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
72
|
-
limits: settings.limits,
|
|
73
72
|
providerOptions: settings.providerOptions,
|
|
74
73
|
queryParams: settings.queryParams === undefined ? undefined : { ...settings.queryParams },
|
|
75
74
|
};
|
|
@@ -307,6 +307,7 @@ export declare const protocol: Protocol<{
|
|
|
307
307
|
readonly reasoning_content?: string | null | undefined;
|
|
308
308
|
readonly reasoning_text?: string | null | undefined;
|
|
309
309
|
readonly content?: string | null | undefined;
|
|
310
|
+
readonly refusal?: string | null | undefined;
|
|
310
311
|
readonly tool_calls?: readonly {
|
|
311
312
|
readonly function?: {
|
|
312
313
|
readonly name?: string | null | undefined;
|
|
@@ -112,6 +112,5 @@ export const model = (modelID, settings) => configure({
|
|
|
112
112
|
baseURL: settings.baseURL,
|
|
113
113
|
headers: settings.headers,
|
|
114
114
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
115
|
-
limits: settings.limits,
|
|
116
115
|
providerOptions: settings.providerOptions,
|
|
117
116
|
}).model(modelID);
|
package/dist/providers/xai.js
CHANGED
|
@@ -71,7 +71,6 @@ export const model = (modelID, settings) => configure({
|
|
|
71
71
|
baseURL: settings.baseURL,
|
|
72
72
|
headers: settings.headers,
|
|
73
73
|
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
74
|
-
limits: settings.limits,
|
|
75
74
|
providerOptions: settings.providerOptions,
|
|
76
75
|
}).model(modelID);
|
|
77
76
|
export const responses = provider.responses;
|
package/dist/route/client.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { HttpTransport } from "./transport/index.js";
|
|
|
7
7
|
import type { HttpMiddleware, Transport, TransportRuntime, WebSocketChannelExecutor } from "./transport/index.js";
|
|
8
8
|
import type { Protocol } from "./protocol.js";
|
|
9
9
|
import type { ProtocolID, ProviderOptions } from "../schema/index.js";
|
|
10
|
-
import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel,
|
|
10
|
+
import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LLMEvent, ProviderID } from "../schema/index.js";
|
|
11
11
|
export interface RouteBody<Body> {
|
|
12
12
|
/** Schema for the validated provider-native body sent as the JSON request. */
|
|
13
13
|
readonly schema: Schema.Codec<Body, unknown>;
|
|
@@ -36,14 +36,12 @@ export type RouteLanguageModelInput = Omit<LanguageModel.Input, "provider" | "ro
|
|
|
36
36
|
export type RouteRoutedLanguageModelInput = Omit<LanguageModel.Input, "route">;
|
|
37
37
|
export interface RouteDefaults {
|
|
38
38
|
readonly headers?: Record<string, string>;
|
|
39
|
-
readonly limits?: LanguageModelLimits;
|
|
40
39
|
readonly generation?: GenerationOptions;
|
|
41
40
|
readonly providerOptions?: ProviderOptions;
|
|
42
41
|
readonly http?: HttpOptions;
|
|
43
42
|
}
|
|
44
43
|
export interface RouteDefaultsInput {
|
|
45
44
|
readonly headers?: Record<string, string>;
|
|
46
|
-
readonly limits?: LanguageModelLimits.Input;
|
|
47
45
|
readonly generation?: GenerationOptions.Input;
|
|
48
46
|
readonly providerOptions?: ProviderOptions;
|
|
49
47
|
readonly http?: HttpOptions.Input;
|
package/dist/route/client.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Framing } from "./framing.js";
|
|
|
6
6
|
import { HttpTransport } from "./transport/index.js";
|
|
7
7
|
import { applyCachePolicy } from "../cache-policy.js";
|
|
8
8
|
import * as ProviderShared from "../protocols/shared.js";
|
|
9
|
-
import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel,
|
|
9
|
+
import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LLMEvent, InvalidProviderOutputReason, ProviderID, mergeGenerationOptions, mergeHttpOptions, mergeProviderOptions, } from "../schema/index.js";
|
|
10
10
|
const makeRouteLanguageModel = (route, mapped) => {
|
|
11
11
|
const provider = route.provider ?? ("provider" in mapped ? mapped.provider : undefined);
|
|
12
12
|
if (!provider)
|
|
@@ -25,7 +25,6 @@ const mergeRouteDefaults = (base, patch) => {
|
|
|
25
25
|
...base,
|
|
26
26
|
...patch,
|
|
27
27
|
headers,
|
|
28
|
-
limits: patch.limits === undefined ? base?.limits : LanguageModelLimits.make(patch.limits),
|
|
29
28
|
generation: mergeGenerationOptions(generationOptions(base?.generation), generationOptions(patch.generation)),
|
|
30
29
|
providerOptions: mergeProviderOptions(base?.providerOptions, patch.providerOptions),
|
|
31
30
|
http: mergeHttpOptions(base?.http, httpOptions(patch.http), headers === undefined ? undefined : new HttpOptions({ headers })),
|
package/dist/schema/options.d.ts
CHANGED
|
@@ -49,20 +49,7 @@ export type GenerationOptionsFields = {
|
|
|
49
49
|
};
|
|
50
50
|
export type GenerationOptionsInput = GenerationOptions | GenerationOptionsFields;
|
|
51
51
|
export declare const mergeGenerationOptions: (...items: ReadonlyArray<GenerationOptionsInput | undefined>) => GenerationOptions | undefined;
|
|
52
|
-
declare const LanguageModelLimits_base: Schema.Class<LanguageModelLimits, Schema.Struct<{
|
|
53
|
-
readonly context: Schema.optional<Schema.Number>;
|
|
54
|
-
readonly input: Schema.optional<Schema.Number>;
|
|
55
|
-
readonly output: Schema.optional<Schema.Number>;
|
|
56
|
-
}>, {}>;
|
|
57
|
-
export declare class LanguageModelLimits extends LanguageModelLimits_base {
|
|
58
|
-
}
|
|
59
|
-
export declare namespace LanguageModelLimits {
|
|
60
|
-
type Input = LanguageModelLimits | ConstructorParameters<typeof LanguageModelLimits>[0];
|
|
61
|
-
/** Normalize model limit input into the canonical `LanguageModelLimits` class. */
|
|
62
|
-
const make: (input: Input | undefined) => LanguageModelLimits;
|
|
63
|
-
}
|
|
64
52
|
declare const LanguageModelDefaults_base: Schema.Class<LanguageModelDefaults, Schema.Struct<{
|
|
65
|
-
readonly limits: Schema.optional<typeof LanguageModelLimits>;
|
|
66
53
|
readonly generation: Schema.optional<typeof GenerationOptions>;
|
|
67
54
|
readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
68
55
|
readonly http: Schema.optional<typeof HttpOptions>;
|
|
@@ -71,7 +58,6 @@ export declare class LanguageModelDefaults extends LanguageModelDefaults_base {
|
|
|
71
58
|
}
|
|
72
59
|
export declare namespace LanguageModelDefaults {
|
|
73
60
|
type Input = LanguageModelDefaults | {
|
|
74
|
-
readonly limits?: LanguageModelLimits.Input;
|
|
75
61
|
readonly generation?: GenerationOptions.Input;
|
|
76
62
|
readonly providerOptions?: ProviderOptions;
|
|
77
63
|
readonly http?: HttpOptions.Input;
|
package/dist/schema/options.js
CHANGED
|
@@ -76,18 +76,7 @@ export const mergeGenerationOptions = (...items) => {
|
|
|
76
76
|
});
|
|
77
77
|
return Object.values(result).some((value) => value !== undefined) ? result : undefined;
|
|
78
78
|
};
|
|
79
|
-
export class LanguageModelLimits extends Schema.Class("LLM.LanguageModelLimits")({
|
|
80
|
-
context: Schema.optional(Schema.Number),
|
|
81
|
-
input: Schema.optional(Schema.Number),
|
|
82
|
-
output: Schema.optional(Schema.Number),
|
|
83
|
-
}) {
|
|
84
|
-
}
|
|
85
|
-
(function (LanguageModelLimits) {
|
|
86
|
-
/** Normalize model limit input into the canonical `LanguageModelLimits` class. */
|
|
87
|
-
LanguageModelLimits.make = (input) => input instanceof LanguageModelLimits ? input : new LanguageModelLimits(input ?? {});
|
|
88
|
-
})(LanguageModelLimits || (LanguageModelLimits = {}));
|
|
89
79
|
export class LanguageModelDefaults extends Schema.Class("LLM.LanguageModelDefaults")({
|
|
90
|
-
limits: Schema.optional(LanguageModelLimits),
|
|
91
80
|
generation: Schema.optional(GenerationOptions),
|
|
92
81
|
providerOptions: Schema.optional(ProviderOptions),
|
|
93
82
|
http: Schema.optional(HttpOptions),
|
|
@@ -99,7 +88,6 @@ export class LanguageModelDefaults extends Schema.Class("LLM.LanguageModelDefaul
|
|
|
99
88
|
if (input instanceof LanguageModelDefaults)
|
|
100
89
|
return input;
|
|
101
90
|
return new LanguageModelDefaults({
|
|
102
|
-
limits: input.limits === undefined ? undefined : LanguageModelLimits.make(input.limits),
|
|
103
91
|
generation: input.generation === undefined ? undefined : GenerationOptions.make(input.generation),
|
|
104
92
|
providerOptions: input.providerOptions,
|
|
105
93
|
http: input.http === undefined ? undefined : HttpOptions.make(input.http),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-17717",
|
|
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.110",
|
|
33
|
-
"@opencode-ai/http-recorder": "0.0.0-dev-
|
|
33
|
+
"@opencode-ai/http-recorder": "0.0.0-dev-17717",
|
|
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-dev-
|
|
42
|
+
"@opencode-ai/schema": "0.0.0-dev-17717",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-rc.110",
|
|
45
45
|
"google-auth-library": "10.5.0"
|