@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.
- package/README.md +0 -200
- package/dist/protocols/anthropic-messages.d.ts +1 -24
- package/dist/protocols/anthropic-messages.js +12 -58
- package/dist/protocols/meta-messages.d.ts +0 -6
- package/dist/protocols/open-responses-channel.d.ts +0 -2
- package/dist/protocols/open-responses-channel.js +2 -2
- package/dist/protocols/open-responses-continuation.d.ts +3 -7
- package/dist/protocols/open-responses-continuation.js +7 -16
- package/dist/protocols/open-responses.d.ts +9 -141
- package/dist/protocols/open-responses.js +7 -29
- package/dist/provider-package.d.ts +0 -4
- package/dist/providers/amazon-bedrock-mantle.d.ts +62 -4
- package/dist/providers/amazon-bedrock-mantle.js +20 -23
- package/dist/providers/amazon-bedrock.js +3 -3
- package/dist/providers/anthropic-compatible.d.ts +2 -7
- package/dist/providers/anthropic-compatible.js +12 -18
- package/dist/providers/anthropic.d.ts +2 -7
- package/dist/providers/anthropic.js +9 -12
- package/dist/providers/azure.d.ts +2 -1
- package/dist/providers/azure.js +14 -14
- package/dist/providers/baseten.d.ts +3 -2
- package/dist/providers/baseten.js +6 -6
- package/dist/providers/cerebras.d.ts +3 -2
- package/dist/providers/cerebras.js +6 -6
- package/dist/providers/cloudflare-ai-gateway.d.ts +2 -1
- package/dist/providers/cloudflare-ai-gateway.js +10 -16
- package/dist/providers/cloudflare-workers-ai.d.ts +2 -1
- package/dist/providers/cloudflare-workers-ai.js +9 -15
- package/dist/providers/deepinfra.d.ts +3 -2
- package/dist/providers/deepinfra.js +6 -6
- package/dist/providers/deepseek.d.ts +3 -2
- package/dist/providers/deepseek.js +6 -6
- package/dist/providers/fireworks.d.ts +3 -2
- package/dist/providers/fireworks.js +6 -6
- package/dist/providers/google-vertex-chat.d.ts +3 -2
- package/dist/providers/google-vertex-chat.js +12 -12
- package/dist/providers/google-vertex-messages.d.ts +3 -8
- package/dist/providers/google-vertex-messages.js +12 -12
- package/dist/providers/google-vertex-responses.d.ts +3 -2
- package/dist/providers/google-vertex-responses.js +12 -12
- package/dist/providers/google-vertex-shared.js +3 -14
- package/dist/providers/google-vertex.d.ts +2 -1
- package/dist/providers/google-vertex.js +12 -18
- package/dist/providers/google.d.ts +3 -2
- package/dist/providers/google.js +6 -6
- package/dist/providers/groq.d.ts +3 -2
- package/dist/providers/groq.js +6 -6
- package/dist/providers/index.d.ts +0 -3
- package/dist/providers/index.js +0 -3
- package/dist/providers/meta.d.ts +3 -8
- package/dist/providers/meta.js +6 -6
- package/dist/providers/minimax/chat.js +6 -6
- package/dist/providers/minimax/responses.js +6 -6
- package/dist/providers/minimax.d.ts +3 -8
- package/dist/providers/minimax.js +6 -6
- package/dist/providers/mistral.d.ts +3 -2
- package/dist/providers/mistral.js +6 -6
- package/dist/providers/openai-compatible-responses.d.ts +3 -2
- package/dist/providers/openai-compatible-responses.js +7 -7
- package/dist/providers/openai-compatible.d.ts +3 -2
- package/dist/providers/openai-compatible.js +7 -7
- package/dist/providers/openai.d.ts +3 -2
- package/dist/providers/openai.js +9 -9
- package/dist/providers/openrouter.d.ts +3 -2
- package/dist/providers/openrouter.js +6 -6
- package/dist/providers/togetherai.d.ts +3 -2
- package/dist/providers/togetherai.js +6 -6
- package/dist/providers/xai.d.ts +3 -2
- package/dist/providers/xai.js +6 -10
- package/dist/providers/zai.d.ts +8 -133
- package/dist/providers/zai.js +0 -32
- package/dist/route/client.js +2 -5
- package/dist/route/transport/websocket.js +2 -6
- package/dist/schema/errors.d.ts +0 -12
- package/dist/schema/errors.js +0 -11
- package/dist/schema/options.d.ts +0 -2
- package/dist/schema/options.js +0 -2
- package/package.json +3 -3
- package/dist/protocols/alibaba-chat.d.ts +0 -225
- package/dist/protocols/alibaba-chat.js +0 -75
- package/dist/protocols/alibaba-messages.d.ts +0 -350
- package/dist/protocols/alibaba-messages.js +0 -40
- package/dist/protocols/alibaba-responses.d.ts +0 -255
- package/dist/protocols/alibaba-responses.js +0 -80
- package/dist/protocols/zai-chat.d.ts +0 -202
- package/dist/protocols/zai-chat.js +0 -49
- package/dist/protocols/zai-messages.d.ts +0 -344
- package/dist/protocols/zai-messages.js +0 -27
- package/dist/providers/alibaba/chat.d.ts +0 -1
- package/dist/providers/alibaba/chat.js +0 -1
- package/dist/providers/alibaba/messages.d.ts +0 -3
- package/dist/providers/alibaba/messages.js +0 -1
- package/dist/providers/alibaba/responses.d.ts +0 -3
- package/dist/providers/alibaba/responses.js +0 -1
- package/dist/providers/alibaba.d.ts +0 -711
- package/dist/providers/alibaba.js +0 -94
- package/dist/providers/moonshot/chat.d.ts +0 -1
- package/dist/providers/moonshot/chat.js +0 -1
- package/dist/providers/moonshot/messages.d.ts +0 -4
- package/dist/providers/moonshot/messages.js +0 -8
- package/dist/providers/moonshot/responses.d.ts +0 -4
- package/dist/providers/moonshot/responses.js +0 -8
- package/dist/providers/moonshot.d.ts +0 -596
- package/dist/providers/moonshot.js +0 -90
- package/dist/providers/zai/chat.d.ts +0 -1
- package/dist/providers/zai/chat.js +0 -1
- package/dist/providers/zai-coding-plan/chat.d.ts +0 -1
- package/dist/providers/zai-coding-plan/chat.js +0 -1
- package/dist/providers/zai-coding-plan/messages.d.ts +0 -4
- package/dist/providers/zai-coding-plan/messages.js +0 -8
- package/dist/providers/zai-coding-plan/responses.d.ts +0 -4
- package/dist/providers/zai-coding-plan/responses.js +0 -8
- package/dist/providers/zai-coding-plan.d.ts +0 -577
- package/dist/providers/zai-coding-plan.js +0 -63
package/dist/providers/zai.d.ts
CHANGED
|
@@ -1,149 +1,24 @@
|
|
|
1
|
-
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
-
import { ZAIChat } from "../protocols/zai-chat.js";
|
|
3
1
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
|
-
import {
|
|
5
|
-
import { type ModelID } from "../schema/index.js";
|
|
2
|
+
import { HttpOptions, type ModelID } from "../schema/index.js";
|
|
6
3
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
-
export type
|
|
8
|
-
export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
9
|
-
readonly baseURL?: string;
|
|
10
|
-
readonly providerOptions?: ChatOptionsInput;
|
|
11
|
-
};
|
|
12
|
-
export type Settings = ProviderPackage.Settings & ChatOptionsInput & {
|
|
13
|
-
readonly apiKey?: string;
|
|
4
|
+
export type Config = ProviderAuthOption<"optional"> & {
|
|
14
5
|
readonly baseURL?: string;
|
|
6
|
+
readonly headers?: Record<string, string>;
|
|
7
|
+
readonly http?: HttpOptions.Input;
|
|
15
8
|
};
|
|
16
9
|
export type { ZAIImageOptions } from "../protocols/zai-images.js";
|
|
17
|
-
export declare const routes: Route<{
|
|
18
|
-
readonly model: string;
|
|
19
|
-
readonly messages: readonly ({
|
|
20
|
-
readonly role: "system";
|
|
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
|
-
readonly type: "image_url";
|
|
30
|
-
readonly image_url: {
|
|
31
|
-
readonly url: string;
|
|
32
|
-
};
|
|
33
|
-
})[];
|
|
34
|
-
} | {
|
|
35
|
-
readonly role: "user";
|
|
36
|
-
readonly content: string | readonly ({
|
|
37
|
-
readonly type: "text";
|
|
38
|
-
readonly text: string;
|
|
39
|
-
readonly cache_control?: {
|
|
40
|
-
readonly type: "ephemeral";
|
|
41
|
-
readonly ttl?: string | undefined;
|
|
42
|
-
} | undefined;
|
|
43
|
-
} | {
|
|
44
|
-
readonly type: "image_url";
|
|
45
|
-
readonly image_url: {
|
|
46
|
-
readonly url: string;
|
|
47
|
-
};
|
|
48
|
-
})[];
|
|
49
|
-
} | {
|
|
50
|
-
readonly [x: string]: unknown;
|
|
51
|
-
readonly content: string | null;
|
|
52
|
-
readonly role: "assistant";
|
|
53
|
-
readonly reasoning?: string | undefined;
|
|
54
|
-
readonly reasoning_content?: string | undefined;
|
|
55
|
-
readonly reasoning_text?: string | undefined;
|
|
56
|
-
readonly cache_control?: {
|
|
57
|
-
readonly type: "ephemeral";
|
|
58
|
-
readonly ttl?: string | undefined;
|
|
59
|
-
} | undefined;
|
|
60
|
-
readonly tool_calls?: readonly {
|
|
61
|
-
readonly id: string;
|
|
62
|
-
readonly type: "function";
|
|
63
|
-
readonly function: {
|
|
64
|
-
readonly name: string;
|
|
65
|
-
readonly arguments: string;
|
|
66
|
-
};
|
|
67
|
-
}[] | undefined;
|
|
68
|
-
readonly reasoning_details?: unknown;
|
|
69
|
-
} | {
|
|
70
|
-
readonly content: string;
|
|
71
|
-
readonly role: "tool";
|
|
72
|
-
readonly tool_call_id: string;
|
|
73
|
-
readonly cache_control?: {
|
|
74
|
-
readonly type: "ephemeral";
|
|
75
|
-
readonly ttl?: string | undefined;
|
|
76
|
-
} | undefined;
|
|
77
|
-
})[];
|
|
78
|
-
readonly stream: true;
|
|
79
|
-
readonly max_completion_tokens?: number | undefined;
|
|
80
|
-
readonly max_tokens?: number | undefined;
|
|
81
|
-
readonly tools?: readonly {
|
|
82
|
-
readonly function: {
|
|
83
|
-
readonly description: string;
|
|
84
|
-
readonly name: string;
|
|
85
|
-
readonly parameters: {
|
|
86
|
-
readonly [x: string]: unknown;
|
|
87
|
-
};
|
|
88
|
-
readonly strict?: boolean | undefined;
|
|
89
|
-
};
|
|
90
|
-
readonly type: "function";
|
|
91
|
-
readonly cache_control?: {
|
|
92
|
-
readonly type: "ephemeral";
|
|
93
|
-
readonly ttl?: string | undefined;
|
|
94
|
-
} | undefined;
|
|
95
|
-
}[] | undefined;
|
|
96
|
-
readonly stop?: readonly string[] | undefined;
|
|
97
|
-
readonly temperature?: number | undefined;
|
|
98
|
-
readonly seed?: number | undefined;
|
|
99
|
-
readonly thinking?: {
|
|
100
|
-
readonly type?: string | undefined;
|
|
101
|
-
readonly clear_thinking?: boolean | undefined;
|
|
102
|
-
} | undefined;
|
|
103
|
-
readonly user_id?: string | undefined;
|
|
104
|
-
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
105
|
-
readonly type: "function";
|
|
106
|
-
readonly function: {
|
|
107
|
-
readonly name: string;
|
|
108
|
-
};
|
|
109
|
-
} | undefined;
|
|
110
|
-
readonly top_p?: number | undefined;
|
|
111
|
-
readonly frequency_penalty?: number | undefined;
|
|
112
|
-
readonly presence_penalty?: number | undefined;
|
|
113
|
-
readonly prompt_cache_key?: string | undefined;
|
|
114
|
-
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
115
|
-
readonly store?: boolean | undefined;
|
|
116
|
-
readonly stream_options?: {
|
|
117
|
-
readonly include_usage: boolean;
|
|
118
|
-
} | undefined;
|
|
119
|
-
readonly tool_stream?: boolean | undefined;
|
|
120
|
-
readonly response_format?: {
|
|
121
|
-
readonly type: string;
|
|
122
|
-
} | undefined;
|
|
123
|
-
readonly do_sample?: boolean | undefined;
|
|
124
|
-
readonly request_id?: string | undefined;
|
|
125
|
-
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
|
|
126
10
|
export declare const configure: (input?: Config) => {
|
|
127
11
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
128
|
-
|
|
129
|
-
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ZAIChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
130
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
12
|
+
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/zai-images.js").ZAIImageOptions>;
|
|
131
13
|
configure: (input?: Config) => /*elided*/ any;
|
|
132
14
|
};
|
|
133
15
|
export declare const provider: {
|
|
134
16
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
135
|
-
|
|
136
|
-
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ZAIChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
137
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
17
|
+
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/zai-images.js").ZAIImageOptions>;
|
|
138
18
|
configure: (input?: Config) => {
|
|
139
19
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
140
|
-
|
|
141
|
-
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ZAIChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
142
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
|
|
20
|
+
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/zai-images.js").ZAIImageOptions>;
|
|
143
21
|
configure: /*elided*/ any;
|
|
144
22
|
};
|
|
145
23
|
};
|
|
146
|
-
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("
|
|
147
|
-
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ZAIChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
148
|
-
export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
|
|
149
|
-
export * as ZAI from "./zai.js";
|
|
24
|
+
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/zai-images.js").ZAIImageOptions>;
|
package/dist/providers/zai.js
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
|
-
import { ZAIChat } from "../protocols/zai-chat.js";
|
|
2
1
|
import { ZAIImages } from "../protocols/zai-images.js";
|
|
3
|
-
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
4
2
|
import { AuthOptions } from "../route/auth-options.js";
|
|
5
|
-
import { Route } from "../route/client.js";
|
|
6
|
-
import { Endpoint } from "../route/endpoint.js";
|
|
7
3
|
import { HttpOptions, ProviderID } from "../schema/index.js";
|
|
8
4
|
export const id = ProviderID.make("zai");
|
|
9
5
|
const auth = (options) => AuthOptions.bearer(options, "ZAI_API_KEY");
|
|
10
|
-
const chatRoute = Route.make({
|
|
11
|
-
id: "zai-chat",
|
|
12
|
-
provider: id,
|
|
13
|
-
providerMetadataKey: "zai",
|
|
14
|
-
protocol: ZAIChat.protocol,
|
|
15
|
-
endpoint: Endpoint.path("/chat/completions", { baseURL: "https://api.z.ai/api/paas/v4" }),
|
|
16
|
-
framing: OpenAIChat.framing,
|
|
17
|
-
});
|
|
18
|
-
export const routes = [chatRoute];
|
|
19
6
|
export const configure = (input = {}) => {
|
|
20
|
-
const { apiKey: _apiKey, auth: _auth, baseURL, ...rest } = input;
|
|
21
|
-
const chat = (modelID) => chatRoute
|
|
22
|
-
.with({
|
|
23
|
-
...rest,
|
|
24
|
-
endpoint: baseURL === undefined ? undefined : { baseURL },
|
|
25
|
-
auth: auth(input),
|
|
26
|
-
})
|
|
27
|
-
.model({ id: modelID, compatibility: ZAIChat.compatibility });
|
|
28
7
|
const image = (modelID) => ZAIImages.model({
|
|
29
8
|
id: modelID,
|
|
30
9
|
auth: auth(input),
|
|
@@ -34,20 +13,9 @@ export const configure = (input = {}) => {
|
|
|
34
13
|
});
|
|
35
14
|
return {
|
|
36
15
|
id,
|
|
37
|
-
model: chat,
|
|
38
|
-
chat,
|
|
39
16
|
image,
|
|
40
17
|
configure,
|
|
41
18
|
};
|
|
42
19
|
};
|
|
43
20
|
export const provider = configure();
|
|
44
21
|
export const image = provider.image;
|
|
45
|
-
export const chat = provider.chat;
|
|
46
|
-
export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
|
|
47
|
-
apiKey,
|
|
48
|
-
baseURL,
|
|
49
|
-
headers,
|
|
50
|
-
http: body === undefined ? undefined : { body: { ...body } },
|
|
51
|
-
providerOptions,
|
|
52
|
-
}).model(modelID);
|
|
53
|
-
export * as ZAI from "./zai.js";
|
package/dist/route/client.js
CHANGED
|
@@ -8,16 +8,13 @@ import { applyCachePolicy } from "../cache-policy.js";
|
|
|
8
8
|
import { normalizeToolHistory } from "../tool-history.js";
|
|
9
9
|
import { sanitizeSurrogates } from "../utils/sanitize.js";
|
|
10
10
|
import * as ProviderShared from "../protocols/shared.js";
|
|
11
|
-
import { AIError, CompactionResponse, CompactionCheckpointResponse, AIErrorReason, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LLMEvent, InvalidProviderOutputError,
|
|
11
|
+
import { AIError, CompactionResponse, CompactionCheckpointResponse, AIErrorReason, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LLMEvent, InvalidProviderOutputError, ProviderID, mergeGenerationOptions, mergeHttpOptions, mergeProviderOptions, } from "../schema/index.js";
|
|
12
12
|
const makeRouteLanguageModel = (route, mapped) => {
|
|
13
13
|
const provider = route.provider ?? ("provider" in mapped ? mapped.provider : undefined);
|
|
14
14
|
if (!provider)
|
|
15
15
|
throw new Error(`Route.model(${route.id}) requires a provider`);
|
|
16
16
|
if (!endpointBaseURL(route.endpoint))
|
|
17
|
-
throw new
|
|
18
|
-
provider: ProviderID.make(provider),
|
|
19
|
-
message: `Route.model(${route.id}) requires an endpoint baseURL — configure it on the route first`,
|
|
20
|
-
});
|
|
17
|
+
throw new Error(`Route.model(${route.id}) requires an endpoint baseURL — configure it on the route first`);
|
|
21
18
|
return LanguageModel.make({
|
|
22
19
|
...mapped,
|
|
23
20
|
provider,
|
|
@@ -63,12 +63,8 @@ const waitOpen = (ws, input) => {
|
|
|
63
63
|
};
|
|
64
64
|
const onAbort = () => {
|
|
65
65
|
cleanup();
|
|
66
|
-
if (ws.readyState
|
|
67
|
-
|
|
68
|
-
// Node's ws reports an aborted handshake as an error event on the next tick; with no listener left
|
|
69
|
-
// after cleanup, EventEmitter would throw it as an uncaught exception.
|
|
70
|
-
ws.addEventListener("error", () => { }, { once: true });
|
|
71
|
-
ws.close(1000);
|
|
66
|
+
if (ws.readyState !== globalThis.WebSocket.CLOSED && ws.readyState !== globalThis.WebSocket.CLOSING)
|
|
67
|
+
ws.close(1000);
|
|
72
68
|
};
|
|
73
69
|
const onOpen = () => {
|
|
74
70
|
cleanup();
|
package/dist/schema/errors.d.ts
CHANGED
|
@@ -44,18 +44,6 @@ declare const UnsupportedOperationError_base: Schema.Class<UnsupportedOperationE
|
|
|
44
44
|
*/
|
|
45
45
|
export declare class UnsupportedOperationError extends UnsupportedOperationError_base {
|
|
46
46
|
}
|
|
47
|
-
declare const ProviderConfigurationError_base: Schema.Class<ProviderConfigurationError, Schema.TaggedStruct<"ProviderConfiguration", {
|
|
48
|
-
readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
|
|
49
|
-
readonly message: Schema.String;
|
|
50
|
-
}>, import("effect/Cause").YieldableError>;
|
|
51
|
-
/**
|
|
52
|
-
* Provider settings that are missing, conflicting, or unsupported, such as
|
|
53
|
-
* Azure without `resourceName` or `baseURL`. Thrown synchronously while a
|
|
54
|
-
* provider facade or package entrypoint configures a model, before any
|
|
55
|
-
* request exists, so it is not an `AIError` reason.
|
|
56
|
-
*/
|
|
57
|
-
export declare class ProviderConfigurationError extends ProviderConfigurationError_base {
|
|
58
|
-
}
|
|
59
47
|
declare const NoRouteError_base: Schema.Class<NoRouteError, Schema.TaggedStruct<"NoRoute", {
|
|
60
48
|
readonly route: Schema.String;
|
|
61
49
|
readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
|
package/dist/schema/errors.js
CHANGED
|
@@ -41,17 +41,6 @@ export class UnsupportedOperationError extends Schema.TaggedError("AI.Error.Unsu
|
|
|
41
41
|
route: Schema.optional(RouteID),
|
|
42
42
|
}) {
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Provider settings that are missing, conflicting, or unsupported, such as
|
|
46
|
-
* Azure without `resourceName` or `baseURL`. Thrown synchronously while a
|
|
47
|
-
* provider facade or package entrypoint configures a model, before any
|
|
48
|
-
* request exists, so it is not an `AIError` reason.
|
|
49
|
-
*/
|
|
50
|
-
export class ProviderConfigurationError extends Schema.TaggedError("AI.Error.ProviderConfiguration")("ProviderConfiguration", {
|
|
51
|
-
provider: ProviderID,
|
|
52
|
-
message: Schema.String,
|
|
53
|
-
}) {
|
|
54
|
-
}
|
|
55
44
|
export class NoRouteError extends Schema.TaggedError("AI.Error.NoRoute")("NoRoute", {
|
|
56
45
|
...ReasonFields,
|
|
57
46
|
route: RouteID,
|
package/dist/schema/options.d.ts
CHANGED
|
@@ -82,8 +82,6 @@ declare const LanguageModelCompatibility_base: Schema.Class<LanguageModelCompati
|
|
|
82
82
|
readonly supportsStrictMode: Schema.optional<Schema.Boolean>;
|
|
83
83
|
readonly zaiToolStream: Schema.optional<Schema.Boolean>;
|
|
84
84
|
readonly requireSignature: Schema.optional<Schema.Boolean>;
|
|
85
|
-
/** Supports Anthropic's thinking-prefix mismatch controls. Overrides model-ID detection. */
|
|
86
|
-
readonly supportsThinkingBlockBinding: Schema.optional<Schema.Boolean>;
|
|
87
85
|
}>, {}>;
|
|
88
86
|
export declare class LanguageModelCompatibility extends LanguageModelCompatibility_base {
|
|
89
87
|
}
|
package/dist/schema/options.js
CHANGED
|
@@ -109,8 +109,6 @@ export class LanguageModelCompatibility extends Schema.Class("LLM.LanguageModelC
|
|
|
109
109
|
supportsStrictMode: Schema.optional(Schema.Boolean),
|
|
110
110
|
zaiToolStream: Schema.optional(Schema.Boolean),
|
|
111
111
|
requireSignature: Schema.optional(Schema.Boolean),
|
|
112
|
-
/** Supports Anthropic's thinking-prefix mismatch controls. Overrides model-ID detection. */
|
|
113
|
-
supportsThinkingBlockBinding: Schema.optional(Schema.Boolean),
|
|
114
112
|
}) {
|
|
115
113
|
}
|
|
116
114
|
(function (LanguageModelCompatibility) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-dev-19276",
|
|
4
4
|
"name": "@opencode/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.112",
|
|
33
|
-
"@opencode/http-recorder": "0.0.0-
|
|
33
|
+
"@opencode/http-recorder": "0.0.0-dev-19276",
|
|
34
34
|
"@tsconfig/bun": "1.0.9",
|
|
35
35
|
"@types/bun": "1.4.0",
|
|
36
36
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
41
41
|
"@smithy/eventstream-codec": "4.2.14",
|
|
42
42
|
"@smithy/util-utf8": "4.2.2",
|
|
43
|
-
"@opencode/schema": "0.0.0-
|
|
43
|
+
"@opencode/schema": "0.0.0-dev-19276",
|
|
44
44
|
"aws4fetch": "1.0.20",
|
|
45
45
|
"effect": "4.0.0-rc.112",
|
|
46
46
|
"google-auth-library": "10.5.0"
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import { Protocol } from "../route/protocol.js";
|
|
3
|
-
import { OpenAIChat } from "./openai-chat.js";
|
|
4
|
-
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
5
|
-
export type ReasoningEffort = OpenResponsesOptions.ReasoningEffort;
|
|
6
|
-
declare const Options: Schema.Struct<{
|
|
7
|
-
readonly reasoningEffort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
8
|
-
readonly enableThinking: Schema.optional<Schema.Boolean>;
|
|
9
|
-
readonly thinkingBudget: Schema.optional<Schema.Int>;
|
|
10
|
-
readonly preserveThinking: Schema.optional<Schema.Boolean>;
|
|
11
|
-
readonly clearThinking: Schema.optional<Schema.Boolean>;
|
|
12
|
-
readonly thinking: Schema.optional<Schema.Struct<{
|
|
13
|
-
readonly type: Schema.declare<"disabled" | (string & {}) | "adaptive", "disabled" | (string & {}) | "adaptive">;
|
|
14
|
-
}>>;
|
|
15
|
-
readonly toolStream: Schema.optional<Schema.Boolean>;
|
|
16
|
-
readonly parallelToolCalls: Schema.optional<Schema.Boolean>;
|
|
17
|
-
readonly repetitionPenalty: Schema.optional<Schema.Number>;
|
|
18
|
-
readonly responseFormat: Schema.optional<Schema.Struct<{
|
|
19
|
-
readonly type: Schema.declare<(string & {}) | "text" | "json_schema" | "json_object", (string & {}) | "text" | "json_schema" | "json_object">;
|
|
20
|
-
readonly json_schema: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
21
|
-
}>>;
|
|
22
|
-
readonly enableSearch: Schema.optional<Schema.Boolean>;
|
|
23
|
-
readonly searchOptions: Schema.optional<Schema.Struct<{
|
|
24
|
-
readonly forced_search: Schema.optional<Schema.Boolean>;
|
|
25
|
-
readonly search_strategy: Schema.optional<Schema.declare<(string & {}) | "agent" | "max" | "turbo" | "agent_max", (string & {}) | "agent" | "max" | "turbo" | "agent_max">>;
|
|
26
|
-
readonly enable_search_extension: Schema.optional<Schema.Boolean>;
|
|
27
|
-
}>>;
|
|
28
|
-
}>;
|
|
29
|
-
export type OptionsInput = typeof Options.Type;
|
|
30
|
-
export declare const compatibility: {
|
|
31
|
-
maxTokensField: "max_completion_tokens";
|
|
32
|
-
supportsStore: false;
|
|
33
|
-
supportsStrictMode: false;
|
|
34
|
-
reasoningField: string;
|
|
35
|
-
zaiToolStream: false;
|
|
36
|
-
};
|
|
37
|
-
export declare const protocol: Protocol<{
|
|
38
|
-
readonly model: string;
|
|
39
|
-
readonly messages: readonly ({
|
|
40
|
-
readonly role: "system";
|
|
41
|
-
readonly content: string | readonly ({
|
|
42
|
-
readonly type: "text";
|
|
43
|
-
readonly text: string;
|
|
44
|
-
readonly cache_control?: {
|
|
45
|
-
readonly type: "ephemeral";
|
|
46
|
-
readonly ttl?: string | undefined;
|
|
47
|
-
} | undefined;
|
|
48
|
-
} | {
|
|
49
|
-
readonly type: "image_url";
|
|
50
|
-
readonly image_url: {
|
|
51
|
-
readonly url: string;
|
|
52
|
-
};
|
|
53
|
-
})[];
|
|
54
|
-
} | {
|
|
55
|
-
readonly role: "user";
|
|
56
|
-
readonly content: string | readonly ({
|
|
57
|
-
readonly type: "text";
|
|
58
|
-
readonly text: string;
|
|
59
|
-
readonly cache_control?: {
|
|
60
|
-
readonly type: "ephemeral";
|
|
61
|
-
readonly ttl?: string | undefined;
|
|
62
|
-
} | undefined;
|
|
63
|
-
} | {
|
|
64
|
-
readonly type: "image_url";
|
|
65
|
-
readonly image_url: {
|
|
66
|
-
readonly url: string;
|
|
67
|
-
};
|
|
68
|
-
})[];
|
|
69
|
-
} | {
|
|
70
|
-
readonly [x: string]: unknown;
|
|
71
|
-
readonly content: string | null;
|
|
72
|
-
readonly role: "assistant";
|
|
73
|
-
readonly reasoning?: string | undefined;
|
|
74
|
-
readonly reasoning_content?: string | undefined;
|
|
75
|
-
readonly reasoning_text?: string | undefined;
|
|
76
|
-
readonly cache_control?: {
|
|
77
|
-
readonly type: "ephemeral";
|
|
78
|
-
readonly ttl?: string | undefined;
|
|
79
|
-
} | undefined;
|
|
80
|
-
readonly tool_calls?: readonly {
|
|
81
|
-
readonly id: string;
|
|
82
|
-
readonly type: "function";
|
|
83
|
-
readonly function: {
|
|
84
|
-
readonly name: string;
|
|
85
|
-
readonly arguments: string;
|
|
86
|
-
};
|
|
87
|
-
}[] | undefined;
|
|
88
|
-
readonly reasoning_details?: unknown;
|
|
89
|
-
} | {
|
|
90
|
-
readonly content: string;
|
|
91
|
-
readonly role: "tool";
|
|
92
|
-
readonly tool_call_id: string;
|
|
93
|
-
readonly cache_control?: {
|
|
94
|
-
readonly type: "ephemeral";
|
|
95
|
-
readonly ttl?: string | undefined;
|
|
96
|
-
} | undefined;
|
|
97
|
-
})[];
|
|
98
|
-
readonly stream: true;
|
|
99
|
-
readonly max_completion_tokens?: number | undefined;
|
|
100
|
-
readonly max_tokens?: number | undefined;
|
|
101
|
-
readonly tools?: readonly {
|
|
102
|
-
readonly function: {
|
|
103
|
-
readonly description: string;
|
|
104
|
-
readonly name: string;
|
|
105
|
-
readonly parameters: {
|
|
106
|
-
readonly [x: string]: unknown;
|
|
107
|
-
};
|
|
108
|
-
readonly strict?: boolean | undefined;
|
|
109
|
-
};
|
|
110
|
-
readonly type: "function";
|
|
111
|
-
readonly cache_control?: {
|
|
112
|
-
readonly type: "ephemeral";
|
|
113
|
-
readonly ttl?: string | undefined;
|
|
114
|
-
} | undefined;
|
|
115
|
-
}[] | undefined;
|
|
116
|
-
readonly stop?: readonly string[] | undefined;
|
|
117
|
-
readonly temperature?: number | undefined;
|
|
118
|
-
readonly seed?: number | undefined;
|
|
119
|
-
readonly thinking?: {
|
|
120
|
-
readonly type: "disabled" | (string & {}) | "adaptive";
|
|
121
|
-
} | undefined;
|
|
122
|
-
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
123
|
-
readonly type: "function";
|
|
124
|
-
readonly function: {
|
|
125
|
-
readonly name: string;
|
|
126
|
-
};
|
|
127
|
-
} | undefined;
|
|
128
|
-
readonly top_p?: number | undefined;
|
|
129
|
-
readonly top_k?: number | undefined;
|
|
130
|
-
readonly frequency_penalty?: number | undefined;
|
|
131
|
-
readonly presence_penalty?: number | undefined;
|
|
132
|
-
readonly prompt_cache_key?: string | undefined;
|
|
133
|
-
readonly parallel_tool_calls?: boolean | undefined;
|
|
134
|
-
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
135
|
-
readonly store?: boolean | undefined;
|
|
136
|
-
readonly stream_options?: {
|
|
137
|
-
readonly include_usage: boolean;
|
|
138
|
-
} | undefined;
|
|
139
|
-
readonly tool_stream?: boolean | undefined;
|
|
140
|
-
readonly enable_thinking?: boolean | undefined;
|
|
141
|
-
readonly thinking_budget?: number | undefined;
|
|
142
|
-
readonly preserve_thinking?: boolean | undefined;
|
|
143
|
-
readonly clear_thinking?: boolean | undefined;
|
|
144
|
-
readonly repetition_penalty?: number | undefined;
|
|
145
|
-
readonly response_format?: {
|
|
146
|
-
readonly type: (string & {}) | "text" | "json_schema" | "json_object";
|
|
147
|
-
readonly json_schema?: {
|
|
148
|
-
readonly [x: string]: unknown;
|
|
149
|
-
} | undefined;
|
|
150
|
-
} | undefined;
|
|
151
|
-
readonly enable_search?: boolean | undefined;
|
|
152
|
-
readonly search_options?: {
|
|
153
|
-
readonly forced_search?: boolean | undefined;
|
|
154
|
-
readonly search_strategy?: (string & {}) | "agent" | "max" | "turbo" | "agent_max" | undefined;
|
|
155
|
-
readonly enable_search_extension?: boolean | undefined;
|
|
156
|
-
} | undefined;
|
|
157
|
-
}, string, "[DONE]" | {
|
|
158
|
-
readonly [x: string]: unknown;
|
|
159
|
-
readonly error?: {
|
|
160
|
-
readonly [x: string]: unknown;
|
|
161
|
-
readonly message: string;
|
|
162
|
-
readonly code?: string | number | null | undefined;
|
|
163
|
-
} | null | undefined;
|
|
164
|
-
readonly usage?: {
|
|
165
|
-
readonly [x: string]: unknown;
|
|
166
|
-
readonly cached_tokens?: number | null | undefined;
|
|
167
|
-
readonly prompt_tokens?: number | null | undefined;
|
|
168
|
-
readonly completion_tokens?: number | null | undefined;
|
|
169
|
-
readonly total_tokens?: number | null | undefined;
|
|
170
|
-
readonly prompt_tokens_details?: {
|
|
171
|
-
readonly [x: string]: unknown;
|
|
172
|
-
readonly cached_tokens?: number | null | undefined;
|
|
173
|
-
readonly cache_write_tokens?: number | null | undefined;
|
|
174
|
-
} | null | undefined;
|
|
175
|
-
readonly prompt_cache_hit_tokens?: number | null | undefined;
|
|
176
|
-
readonly completion_tokens_details?: {
|
|
177
|
-
readonly [x: string]: unknown;
|
|
178
|
-
readonly reasoning_tokens?: number | null | undefined;
|
|
179
|
-
readonly accepted_prediction_tokens?: number | null | undefined;
|
|
180
|
-
readonly rejected_prediction_tokens?: number | null | undefined;
|
|
181
|
-
} | null | undefined;
|
|
182
|
-
} | null | undefined;
|
|
183
|
-
readonly choices?: readonly {
|
|
184
|
-
readonly [x: string]: unknown;
|
|
185
|
-
readonly delta?: {
|
|
186
|
-
readonly [x: string]: unknown;
|
|
187
|
-
readonly reasoning?: string | null | undefined;
|
|
188
|
-
readonly reasoning_content?: string | null | undefined;
|
|
189
|
-
readonly reasoning_text?: string | null | undefined;
|
|
190
|
-
readonly content?: string | null | undefined;
|
|
191
|
-
readonly refusal?: string | null | undefined;
|
|
192
|
-
readonly tool_calls?: readonly {
|
|
193
|
-
readonly function?: {
|
|
194
|
-
readonly name?: string | null | undefined;
|
|
195
|
-
readonly arguments?: string | null | undefined;
|
|
196
|
-
} | null | undefined;
|
|
197
|
-
readonly id?: string | null | undefined;
|
|
198
|
-
readonly index?: number | null | undefined;
|
|
199
|
-
}[] | null | undefined;
|
|
200
|
-
readonly reasoning_details?: unknown;
|
|
201
|
-
} | null | undefined;
|
|
202
|
-
readonly usage?: {
|
|
203
|
-
readonly [x: string]: unknown;
|
|
204
|
-
readonly cached_tokens?: number | null | undefined;
|
|
205
|
-
readonly prompt_tokens?: number | null | undefined;
|
|
206
|
-
readonly completion_tokens?: number | null | undefined;
|
|
207
|
-
readonly total_tokens?: number | null | undefined;
|
|
208
|
-
readonly prompt_tokens_details?: {
|
|
209
|
-
readonly [x: string]: unknown;
|
|
210
|
-
readonly cached_tokens?: number | null | undefined;
|
|
211
|
-
readonly cache_write_tokens?: number | null | undefined;
|
|
212
|
-
} | null | undefined;
|
|
213
|
-
readonly prompt_cache_hit_tokens?: number | null | undefined;
|
|
214
|
-
readonly completion_tokens_details?: {
|
|
215
|
-
readonly [x: string]: unknown;
|
|
216
|
-
readonly reasoning_tokens?: number | null | undefined;
|
|
217
|
-
readonly accepted_prediction_tokens?: number | null | undefined;
|
|
218
|
-
readonly rejected_prediction_tokens?: number | null | undefined;
|
|
219
|
-
} | null | undefined;
|
|
220
|
-
} | null | undefined;
|
|
221
|
-
readonly finish_reason?: string | null | undefined;
|
|
222
|
-
readonly native_finish_reason?: string | null | undefined;
|
|
223
|
-
}[] | null | undefined;
|
|
224
|
-
}, OpenAIChat.ParserState>;
|
|
225
|
-
export * as AlibabaChat from "./alibaba-chat.js";
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
2
|
-
import { Protocol } from "../route/protocol.js";
|
|
3
|
-
import { OpenAIChat } from "./openai-chat.js";
|
|
4
|
-
import { JsonObject, ProviderShared } from "./shared.js";
|
|
5
|
-
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
6
|
-
const Options = Schema.Struct({
|
|
7
|
-
reasoningEffort: OpenResponsesOptions.Options.fields.reasoningEffort,
|
|
8
|
-
enableThinking: Schema.optional(Schema.Boolean),
|
|
9
|
-
thinkingBudget: Schema.optional(Schema.Int),
|
|
10
|
-
preserveThinking: Schema.optional(Schema.Boolean),
|
|
11
|
-
clearThinking: Schema.optional(Schema.Boolean),
|
|
12
|
-
thinking: Schema.optional(Schema.Struct({
|
|
13
|
-
type: Schema.declare(Schema.is(Schema.String)),
|
|
14
|
-
})),
|
|
15
|
-
toolStream: Schema.optional(Schema.Boolean),
|
|
16
|
-
parallelToolCalls: OpenResponsesOptions.Options.fields.parallelToolCalls,
|
|
17
|
-
repetitionPenalty: Schema.optional(Schema.Number),
|
|
18
|
-
responseFormat: Schema.optional(Schema.Struct({
|
|
19
|
-
type: Schema.declare(Schema.is(Schema.String)),
|
|
20
|
-
json_schema: Schema.optional(JsonObject),
|
|
21
|
-
})),
|
|
22
|
-
enableSearch: Schema.optional(Schema.Boolean),
|
|
23
|
-
searchOptions: Schema.optional(Schema.Struct({
|
|
24
|
-
forced_search: Schema.optional(Schema.Boolean),
|
|
25
|
-
search_strategy: Schema.optional(Schema.declare(Schema.is(Schema.String))),
|
|
26
|
-
enable_search_extension: Schema.optional(Schema.Boolean),
|
|
27
|
-
})),
|
|
28
|
-
});
|
|
29
|
-
export const compatibility = {
|
|
30
|
-
maxTokensField: "max_completion_tokens",
|
|
31
|
-
supportsStore: false,
|
|
32
|
-
supportsStrictMode: false,
|
|
33
|
-
reasoningField: "reasoning_content",
|
|
34
|
-
zaiToolStream: false,
|
|
35
|
-
};
|
|
36
|
-
export const protocol = Protocol.make({
|
|
37
|
-
id: "alibaba-chat",
|
|
38
|
-
body: {
|
|
39
|
-
schema: Schema.Struct({
|
|
40
|
-
...OpenAIChat.bodyFields,
|
|
41
|
-
enable_thinking: Options.fields.enableThinking,
|
|
42
|
-
thinking_budget: Options.fields.thinkingBudget,
|
|
43
|
-
preserve_thinking: Options.fields.preserveThinking,
|
|
44
|
-
clear_thinking: Options.fields.clearThinking,
|
|
45
|
-
thinking: Options.fields.thinking,
|
|
46
|
-
parallel_tool_calls: Options.fields.parallelToolCalls,
|
|
47
|
-
repetition_penalty: Options.fields.repetitionPenalty,
|
|
48
|
-
top_k: Schema.optional(Schema.Int),
|
|
49
|
-
response_format: Options.fields.responseFormat,
|
|
50
|
-
enable_search: Options.fields.enableSearch,
|
|
51
|
-
search_options: Options.fields.searchOptions,
|
|
52
|
-
}),
|
|
53
|
-
from: Effect.fn("AlibabaChat.fromRequest")(function* (req) {
|
|
54
|
-
const opts = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Options))(req.providerOptions ?? {});
|
|
55
|
-
return {
|
|
56
|
-
...(yield* OpenAIChat.protocol.body.from(req)),
|
|
57
|
-
enable_thinking: opts.enableThinking,
|
|
58
|
-
thinking_budget: opts.thinkingBudget,
|
|
59
|
-
preserve_thinking: opts.preserveThinking,
|
|
60
|
-
clear_thinking: opts.clearThinking,
|
|
61
|
-
thinking: opts.thinking,
|
|
62
|
-
tool_stream: opts.toolStream,
|
|
63
|
-
parallel_tool_calls: opts.parallelToolCalls ??
|
|
64
|
-
(req.toolChoice?.disableParallelToolUse === undefined ? undefined : !req.toolChoice.disableParallelToolUse),
|
|
65
|
-
repetition_penalty: opts.repetitionPenalty,
|
|
66
|
-
top_k: req.generation?.topK,
|
|
67
|
-
response_format: opts.responseFormat,
|
|
68
|
-
enable_search: opts.enableSearch,
|
|
69
|
-
search_options: opts.searchOptions,
|
|
70
|
-
};
|
|
71
|
-
}),
|
|
72
|
-
},
|
|
73
|
-
stream: OpenAIChat.protocol.stream,
|
|
74
|
-
});
|
|
75
|
-
export * as AlibabaChat from "./alibaba-chat.js";
|