@opencode/ai 0.0.0-dev-482 → 0.0.0-dev-513
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/dist/effect.d.ts +1 -12
- package/dist/effect.js +1 -5
- package/dist/effort-updates.d.ts +2 -2
- package/dist/image-client.d.ts +4 -4
- package/dist/index.d.ts +1 -12
- package/dist/index.js +1 -5
- package/dist/protocols/alibaba-responses.js +8 -20
- package/dist/protocols/anthropic-messages.js +35 -89
- package/dist/protocols/bedrock-converse.js +2 -3
- package/dist/protocols/gemini.js +26 -40
- package/dist/protocols/meta-responses.js +1 -1
- package/dist/protocols/open-responses-channel.js +6 -19
- package/dist/protocols/open-responses-continuation.d.ts +1 -5
- package/dist/protocols/open-responses-continuation.js +1 -3
- package/dist/protocols/open-responses.js +1 -3
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +2 -2
- package/dist/protocols/openai-responses.js +8 -26
- package/dist/protocols/utils/bedrock-cache.js +2 -5
- package/dist/protocols/utils/cache.d.ts +3 -0
- package/dist/protocols/utils/cache.js +15 -2
- package/dist/protocols/utils/image-sizing.d.ts +1 -1
- package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
- package/dist/protocols/utils/responses-hosted-tools.js +31 -0
- package/dist/protocols/utils/tool-stream.d.ts +3 -209
- package/dist/protocols/utils/tool-stream.js +3 -13
- package/dist/protocols/xai-responses.js +4 -24
- package/dist/providers/baseten.d.ts +1 -1
- package/dist/providers/baseten.js +7 -21
- package/dist/providers/cerebras.d.ts +1 -1
- package/dist/providers/cerebras.js +3 -14
- package/dist/providers/cloudflare-ai-gateway.js +5 -25
- package/dist/providers/cloudflare-shared.d.ts +9 -0
- package/dist/providers/cloudflare-shared.js +25 -0
- package/dist/providers/cloudflare-workers-ai.js +4 -20
- package/dist/providers/cohere/chat.js +2 -7
- package/dist/providers/cohere.d.ts +1 -1
- package/dist/providers/cohere.js +5 -12
- package/dist/providers/deepinfra.d.ts +1 -1
- package/dist/providers/deepinfra.js +4 -12
- package/dist/providers/deepseek.d.ts +1 -1
- package/dist/providers/deepseek.js +3 -14
- package/dist/providers/digitalocean.d.ts +1 -1
- package/dist/providers/digitalocean.js +5 -7
- package/dist/providers/fireworks.d.ts +1 -1
- package/dist/providers/fireworks.js +3 -14
- package/dist/providers/google/interactions.js +2 -7
- package/dist/providers/google-vertex-chat.js +3 -29
- package/dist/providers/google-vertex-messages.js +3 -29
- package/dist/providers/google-vertex-mistral.js +3 -29
- package/dist/providers/google-vertex-responses.js +3 -29
- package/dist/providers/google-vertex-shared.d.ts +30 -0
- package/dist/providers/google-vertex-shared.js +25 -0
- package/dist/providers/google.js +3 -11
- package/dist/providers/groq.d.ts +1 -1
- package/dist/providers/groq.js +3 -14
- package/dist/providers/meta.d.ts +1 -1
- package/dist/providers/meta.js +6 -20
- package/dist/providers/minimax/chat.js +2 -7
- package/dist/providers/minimax/responses.js +2 -7
- package/dist/providers/minimax.d.ts +1 -1
- package/dist/providers/minimax.js +5 -20
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/mistral.js +3 -14
- package/dist/providers/moonshot/messages.js +2 -7
- package/dist/providers/moonshot/responses.js +2 -7
- package/dist/providers/moonshot.d.ts +1 -1
- package/dist/providers/moonshot.js +3 -14
- package/dist/providers/openai-compatible-responses.js +2 -8
- package/dist/providers/openai-compatible.js +3 -9
- package/dist/providers/opencode.d.ts +1 -1
- package/dist/providers/opencode.js +5 -1
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.js +9 -20
- package/dist/providers/settings.d.ts +40 -0
- package/dist/providers/settings.js +19 -0
- package/dist/providers/togetherai.d.ts +1 -1
- package/dist/providers/togetherai.js +3 -14
- package/dist/providers/typesafe-ai.d.ts +1 -1
- package/dist/providers/typesafe-ai.js +5 -1
- package/dist/providers/vercel-ai-gateway.d.ts +1 -1
- package/dist/providers/vercel-ai-gateway.js +8 -22
- package/dist/providers/xai.js +3 -11
- package/dist/providers/zai-coding-plan/messages.js +2 -7
- package/dist/providers/zai-coding-plan/responses.js +2 -7
- package/dist/providers/zai-coding-plan.d.ts +1 -1
- package/dist/providers/zai-coding-plan.js +3 -14
- package/dist/providers/zai.d.ts +1 -1
- package/dist/providers/zai.js +6 -22
- package/dist/public.d.ts +12 -0
- package/dist/public.js +5 -0
- package/dist/schema/events.js +31 -64
- package/dist/speech-client.d.ts +4 -4
- package/dist/transcription-client.d.ts +4 -4
- package/dist/video-client.d.ts +4 -4
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
3
3
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
4
4
|
import { type ModelID } from "../schema/index.js";
|
|
5
5
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
2
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
3
2
|
import { Route } from "../route/client.js";
|
|
4
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
5
4
|
import { ProviderID } from "../schema/index.js";
|
|
5
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
6
6
|
export const id = ProviderID.make("togetherai");
|
|
7
7
|
const baseURL = "https://api.together.xyz/v1";
|
|
8
8
|
export const route = Route.make({
|
|
@@ -15,12 +15,7 @@ export const route = Route.make({
|
|
|
15
15
|
});
|
|
16
16
|
export const routes = [route];
|
|
17
17
|
export const configure = (input = {}) => {
|
|
18
|
-
const
|
|
19
|
-
const configured = route.with({
|
|
20
|
-
...defaults,
|
|
21
|
-
endpoint: { baseURL: endpoint ?? baseURL },
|
|
22
|
-
auth: AuthOptions.bearer(input, ["TOGETHER_API_KEY", "TOGETHER_AI_API_KEY"]),
|
|
23
|
-
});
|
|
18
|
+
const configured = route.with(bearerRouteDefaults(input, ["TOGETHER_API_KEY", "TOGETHER_AI_API_KEY"], baseURL));
|
|
24
19
|
return {
|
|
25
20
|
id,
|
|
26
21
|
model: (modelID) => configured.model({
|
|
@@ -31,10 +26,4 @@ export const configure = (input = {}) => {
|
|
|
31
26
|
};
|
|
32
27
|
};
|
|
33
28
|
export const provider = configure();
|
|
34
|
-
export const model = (modelID,
|
|
35
|
-
apiKey,
|
|
36
|
-
baseURL,
|
|
37
|
-
headers,
|
|
38
|
-
http: body === undefined ? undefined : { body },
|
|
39
|
-
providerOptions,
|
|
40
|
-
}).model(modelID);
|
|
29
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
@@ -21,5 +21,5 @@ export declare const provider: {
|
|
|
21
21
|
configure: typeof configure;
|
|
22
22
|
};
|
|
23
23
|
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
24
|
-
export declare const decisionModel: (modelID: string,
|
|
24
|
+
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
25
25
|
export * as TypeSafeAI from "./typesafe-ai.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HttpOptions, ProviderID } from "../schema/index.js";
|
|
2
2
|
import { AuthOptions } from "../route/auth-options.js";
|
|
3
3
|
import { SystemOne } from "../protocols/system-one.js";
|
|
4
|
+
import { toConfig } from "./settings.js";
|
|
4
5
|
export const id = ProviderID.make("typesafe-ai");
|
|
5
6
|
const baseURL = "https://api.typesafe.ai/v1";
|
|
6
7
|
export const configure = (input = {}) => {
|
|
@@ -18,5 +19,8 @@ export const configure = (input = {}) => {
|
|
|
18
19
|
};
|
|
19
20
|
export const provider = configure();
|
|
20
21
|
export const decision = provider.decision;
|
|
21
|
-
export const decisionModel = (modelID,
|
|
22
|
+
export const decisionModel = (modelID, settings) => {
|
|
23
|
+
const input = toConfig(settings);
|
|
24
|
+
return configure(input).decision(modelID, input.providerOptions);
|
|
25
|
+
};
|
|
22
26
|
export * as TypeSafeAI from "./typesafe-ai.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
2
2
|
import type { ProviderPackage } from "../provider-package.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
5
5
|
import { ModelID, type ProviderOptions } from "../schema/index.js";
|
|
6
6
|
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
@@ -7,12 +7,12 @@ import { OpenAIImages } from "../protocols/openai-images.js";
|
|
|
7
7
|
import { XAIImages } from "../protocols/xai-images.js";
|
|
8
8
|
import { ProviderShared } from "../protocols/shared.js";
|
|
9
9
|
import { gatewayProtocol } from "../protocols/utils/gateway-protocol.js";
|
|
10
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
11
10
|
import { Route } from "../route/client.js";
|
|
12
11
|
import { Endpoint } from "../route/endpoint.js";
|
|
13
12
|
import { Framing } from "../route/framing.js";
|
|
14
13
|
import { MediaRoute } from "../route/media.js";
|
|
15
14
|
import { ModelID, ProviderID, ProviderMetadata, ReasoningEffort, } from "../schema/index.js";
|
|
15
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
16
16
|
export const id = ProviderID.make("vercel-ai-gateway");
|
|
17
17
|
const baseURL = "https://ai-gateway.vercel.sh/v1";
|
|
18
18
|
const GatewayOptionsSchema = Schema.Struct({
|
|
@@ -118,12 +118,7 @@ const imageSizing = (request) => {
|
|
|
118
118
|
return { providerOptions: { xai: { aspect_ratio: request.aspect, resolution: XAIImages.resolution(request) } } };
|
|
119
119
|
};
|
|
120
120
|
export const configure = (input = {}) => {
|
|
121
|
-
const
|
|
122
|
-
const configured = {
|
|
123
|
-
...defaults,
|
|
124
|
-
endpoint: { baseURL: endpoint ?? baseURL },
|
|
125
|
-
auth: AuthOptions.bearer(input, ["AI_GATEWAY_API_KEY", "VERCEL_OIDC_TOKEN"]),
|
|
126
|
-
};
|
|
121
|
+
const configured = bearerRouteDefaults(input, ["AI_GATEWAY_API_KEY", "VERCEL_OIDC_TOKEN"], baseURL);
|
|
127
122
|
const messages = (modelID) => messagesRoute.with(configured).model({
|
|
128
123
|
id: modelID,
|
|
129
124
|
// Recorded Gateway translations for non-Claude models return thinking with empty signatures.
|
|
@@ -159,25 +154,16 @@ export const messages = provider.messages;
|
|
|
159
154
|
export const responses = provider.responses;
|
|
160
155
|
export const chat = provider.chat;
|
|
161
156
|
export const image = provider.image;
|
|
162
|
-
export const model = (modelID, settings) => configure(
|
|
163
|
-
export const messagesModel = (modelID, settings) => configure(
|
|
164
|
-
export const responsesModel = (modelID, settings) => configure(
|
|
165
|
-
export const chatModel = (modelID, settings) => configure(
|
|
157
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
158
|
+
export const messagesModel = (modelID, settings) => configure(toConfig(settings)).messages(modelID);
|
|
159
|
+
export const responsesModel = (modelID, settings) => configure(toConfig(settings)).responses(modelID);
|
|
160
|
+
export const chatModel = (modelID, settings) => configure(toConfig(settings)).chat(modelID);
|
|
166
161
|
export const imageModel = (modelID, settings) => {
|
|
167
|
-
const input =
|
|
162
|
+
const input = toConfig(settings);
|
|
168
163
|
return configure(input).image(modelID, input.providerOptions);
|
|
169
164
|
};
|
|
170
165
|
export const decisionModel = (modelID, settings) => {
|
|
171
|
-
const input =
|
|
166
|
+
const input = toConfig(settings);
|
|
172
167
|
return configure(input).decision(modelID, input.providerOptions);
|
|
173
168
|
};
|
|
174
|
-
function config({ apiKey, baseURL, headers, body, ...providerOptions } = {}) {
|
|
175
|
-
return {
|
|
176
|
-
apiKey,
|
|
177
|
-
baseURL,
|
|
178
|
-
headers,
|
|
179
|
-
http: body === undefined ? undefined : { body },
|
|
180
|
-
providerOptions,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
169
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
package/dist/providers/xai.js
CHANGED
|
@@ -8,6 +8,7 @@ import { OpenResponsesChannel } from "../protocols/open-responses-channel.js";
|
|
|
8
8
|
import { XAIResponses } from "../protocols/xai-responses.js";
|
|
9
9
|
import { XAIImages } from "../protocols/xai-images.js";
|
|
10
10
|
import { XAIVideo } from "../protocols/xai-video.js";
|
|
11
|
+
import { toConfig } from "./settings.js";
|
|
11
12
|
export const id = ProviderID.make("xai");
|
|
12
13
|
const baseURL = "https://api.x.ai/v1";
|
|
13
14
|
const RESPONSES_WEBSOCKET_ROTATE_AFTER_MS = 24 * 60 * 1000;
|
|
@@ -73,20 +74,11 @@ export const configure = (input = {}) => {
|
|
|
73
74
|
};
|
|
74
75
|
};
|
|
75
76
|
export const provider = configure();
|
|
76
|
-
export const model = (modelID, settings) => configure(
|
|
77
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
77
78
|
export const imageModel = (modelID, settings) => {
|
|
78
|
-
const input =
|
|
79
|
+
const input = toConfig(settings);
|
|
79
80
|
return configure(input).image(modelID, input.providerOptions);
|
|
80
81
|
};
|
|
81
|
-
function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
|
|
82
|
-
return {
|
|
83
|
-
apiKey,
|
|
84
|
-
baseURL,
|
|
85
|
-
headers,
|
|
86
|
-
http: body === undefined ? undefined : { body },
|
|
87
|
-
providerOptions,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
82
|
export const responses = provider.responses;
|
|
91
83
|
export const chat = provider.chat;
|
|
92
84
|
export const image = provider.image;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { ZAICodingPlan } from "../zai-coding-plan.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
baseURL,
|
|
5
|
-
headers,
|
|
6
|
-
http: body === undefined ? undefined : { body },
|
|
7
|
-
providerOptions,
|
|
8
|
-
}).messages(modelID);
|
|
2
|
+
import { toConfig } from "../settings.js";
|
|
3
|
+
export const model = (modelID, settings) => ZAICodingPlan.configure(toConfig(settings)).messages(modelID);
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { ZAICodingPlan } from "../zai-coding-plan.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
baseURL,
|
|
5
|
-
headers,
|
|
6
|
-
http: body === undefined ? undefined : { body },
|
|
7
|
-
providerOptions,
|
|
8
|
-
}).responses(modelID);
|
|
2
|
+
import { toConfig } from "../settings.js";
|
|
3
|
+
export const model = (modelID, settings) => ZAICodingPlan.configure(toConfig(settings)).responses(modelID);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { ZAIChat } from "../protocols/zai-chat.js";
|
|
3
3
|
import { ZAIMessages } from "../protocols/zai-messages.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
5
5
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
6
6
|
import { type ModelID } from "../schema/index.js";
|
|
7
7
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -3,11 +3,11 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
|
3
3
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
4
4
|
import { ZAIChat } from "../protocols/zai-chat.js";
|
|
5
5
|
import { ZAIMessages } from "../protocols/zai-messages.js";
|
|
6
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
7
6
|
import { Route } from "../route/client.js";
|
|
8
7
|
import { Endpoint } from "../route/endpoint.js";
|
|
9
8
|
import { Framing } from "../route/framing.js";
|
|
10
9
|
import { ProviderID } from "../schema/index.js";
|
|
10
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
11
11
|
export const id = ProviderID.make("zai-coding-plan");
|
|
12
12
|
const chatRoute = Route.make({
|
|
13
13
|
id: "zai-coding-chat",
|
|
@@ -36,12 +36,7 @@ const responsesRoute = Route.make({
|
|
|
36
36
|
});
|
|
37
37
|
export const routes = [chatRoute, messagesRoute, responsesRoute];
|
|
38
38
|
export const configure = (input = {}) => {
|
|
39
|
-
const
|
|
40
|
-
const defaults = {
|
|
41
|
-
...rest,
|
|
42
|
-
endpoint: baseURL === undefined ? undefined : { baseURL },
|
|
43
|
-
auth: AuthOptions.bearer(input, "ZAI_API_KEY"),
|
|
44
|
-
};
|
|
39
|
+
const defaults = bearerRouteDefaults(input, "ZAI_API_KEY");
|
|
45
40
|
const chat = (modelID) => chatRoute.with(defaults).model({ id: modelID, compatibility: ZAIChat.compatibility });
|
|
46
41
|
const messages = (modelID) => messagesRoute
|
|
47
42
|
.with(defaults)
|
|
@@ -53,11 +48,5 @@ export const provider = configure();
|
|
|
53
48
|
export const chat = provider.chat;
|
|
54
49
|
export const messages = provider.messages;
|
|
55
50
|
export const responses = provider.responses;
|
|
56
|
-
export const model = (modelID,
|
|
57
|
-
apiKey,
|
|
58
|
-
baseURL,
|
|
59
|
-
headers,
|
|
60
|
-
http: body === undefined ? undefined : { body },
|
|
61
|
-
providerOptions,
|
|
62
|
-
}).model(modelID);
|
|
51
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
63
52
|
export * as ZAICodingPlan from "./zai-coding-plan.js";
|
package/dist/providers/zai.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { ZAIChat } from "../protocols/zai-chat.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
5
5
|
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
6
6
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
package/dist/providers/zai.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { ZAIChat } from "../protocols/zai-chat.js";
|
|
2
2
|
import { ZAIImages } from "../protocols/zai-images.js";
|
|
3
3
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
4
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
5
4
|
import { Route } from "../route/client.js";
|
|
6
5
|
import { Endpoint } from "../route/endpoint.js";
|
|
7
6
|
import { MediaRoute } from "../route/media.js";
|
|
8
7
|
import { ProviderID } from "../schema/index.js";
|
|
8
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
9
9
|
export const id = ProviderID.make("zai");
|
|
10
|
-
const auth = (options) => AuthOptions.bearer(options, "ZAI_API_KEY");
|
|
11
10
|
const chatRoute = Route.make({
|
|
12
11
|
id: "zai-chat",
|
|
13
12
|
provider: id,
|
|
@@ -18,15 +17,9 @@ const chatRoute = Route.make({
|
|
|
18
17
|
});
|
|
19
18
|
export const routes = [chatRoute];
|
|
20
19
|
export const configure = (input = {}) => {
|
|
21
|
-
const
|
|
22
|
-
const chat = (modelID) => chatRoute
|
|
23
|
-
|
|
24
|
-
...rest,
|
|
25
|
-
endpoint: baseURL === undefined ? undefined : { baseURL },
|
|
26
|
-
auth: auth(input),
|
|
27
|
-
})
|
|
28
|
-
.model({ id: modelID, compatibility: ZAIChat.compatibility });
|
|
29
|
-
const media = MediaRoute.deployment(input, auth(input));
|
|
20
|
+
const defaults = bearerRouteDefaults(input, "ZAI_API_KEY");
|
|
21
|
+
const chat = (modelID) => chatRoute.with(defaults).model({ id: modelID, compatibility: ZAIChat.compatibility });
|
|
22
|
+
const media = MediaRoute.deployment(input, defaults.auth);
|
|
30
23
|
const image = (modelID, providerOptions) => ZAIImages.model({ ...media, id: modelID, providerOptions });
|
|
31
24
|
return {
|
|
32
25
|
id,
|
|
@@ -39,18 +32,9 @@ export const configure = (input = {}) => {
|
|
|
39
32
|
export const provider = configure();
|
|
40
33
|
export const image = provider.image;
|
|
41
34
|
export const chat = provider.chat;
|
|
42
|
-
export const model = (modelID, settings) => configure(
|
|
35
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
43
36
|
export const imageModel = (modelID, settings) => {
|
|
44
|
-
const input =
|
|
37
|
+
const input = toConfig(settings);
|
|
45
38
|
return configure(input).image(modelID, input.providerOptions);
|
|
46
39
|
};
|
|
47
|
-
function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
|
|
48
|
-
return {
|
|
49
|
-
apiKey,
|
|
50
|
-
baseURL,
|
|
51
|
-
headers,
|
|
52
|
-
http: body === undefined ? undefined : { body },
|
|
53
|
-
providerOptions,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
40
|
export * as ZAI from "./zai.js";
|
package/dist/public.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./provider-error.js";
|
|
2
|
+
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
3
|
+
export type { GenerationOptionsFields, GenerationOptionsInput, LanguageModelInput, LanguageModelProviderOptions, LLMRequest, ToolDefinitionInput, ToolNamespaceInput, ToolNamespaceEntryInput, ToolEntryInput, UsageInput, } from "./schema/index.js";
|
|
4
|
+
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
5
|
+
export type { ImageModelOptions, ImageOptions, ImageRequest, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
|
|
6
|
+
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
7
|
+
export type { AnswerFor, AnswersFor, DecisionInput, DecisionModelOptions, DecisionOptions, DecisionQuestions, DecisionRequest, DecisionRequestInput, DecisionResponseFor, DecisionModelRoute, } from "./decision.js";
|
|
8
|
+
export { Media } from "./media.js";
|
|
9
|
+
export type { AwaitOptions as GenerationAwaitOptions, Event as GenerationEvent, Poll, Route as GenerationRoute, Snapshot as GenerationSnapshot, Status as GenerationStatus, } from "./generation.js";
|
|
10
|
+
export type { ExecutableTool, Tool, ToolExecute, ToolExecuteContext, ToolInput, ToolInputType, ToolModelOutputInput, ToolOptions, ToolSchema, ToolToModelOutput, } from "./tool.js";
|
|
11
|
+
export type { LLM } from "./llm.js";
|
|
12
|
+
export type { LLMLoopInput, LLMRequestInput } from "./llm.js";
|
package/dist/public.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./provider-error.js";
|
|
2
|
+
export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
|
|
3
|
+
export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
|
|
4
|
+
export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
|
|
5
|
+
export { Media } from "./media.js";
|
package/dist/schema/events.js
CHANGED
|
@@ -363,81 +363,48 @@ const appendEvent = (state, event) => {
|
|
|
363
363
|
usage: "usage" in event && event.usage !== undefined ? event.usage : state.usage,
|
|
364
364
|
};
|
|
365
365
|
};
|
|
366
|
-
const
|
|
367
|
-
const reasoningContent = (text, providerMetadata) => providerMetadata === undefined ? { type: "reasoning", text } : { type: "reasoning", text, providerMetadata };
|
|
366
|
+
const contentPart = (type, text, providerMetadata) => providerMetadata === undefined ? { type, text } : { type, text, providerMetadata };
|
|
368
367
|
const contentWith = (state, content) => ({
|
|
369
368
|
...state,
|
|
370
369
|
message: Message.assistant(content),
|
|
371
370
|
});
|
|
372
371
|
const appendContent = (state, part) => contentWith(state, [...state.message.content, part]);
|
|
373
372
|
const replaceContent = (state, index, part) => contentWith(state, state.message.content.map((item, itemIndex) => (itemIndex === index ? part : item)));
|
|
374
|
-
const
|
|
375
|
-
|
|
373
|
+
const contentParts = (state, type) => type === "text" ? state.textParts : state.reasoningParts;
|
|
374
|
+
const withContentParts = (state, type, parts) => (type === "text" ? { ...state, textParts: parts } : { ...state, reasoningParts: parts });
|
|
375
|
+
const ensureContent = (state, type, id, providerMetadata) => {
|
|
376
|
+
const parts = contentParts(state, type);
|
|
377
|
+
if (parts[id])
|
|
376
378
|
return state;
|
|
377
|
-
return {
|
|
378
|
-
...
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
[id]: { contentIndex: state.message.content.length, text: "", providerMetadata },
|
|
382
|
-
},
|
|
383
|
-
};
|
|
384
|
-
};
|
|
385
|
-
const reduceTextDelta = (state, event) => {
|
|
386
|
-
const started = ensureText(state, event.id, event.providerMetadata);
|
|
387
|
-
const current = started.textParts[event.id];
|
|
388
|
-
if (!current)
|
|
389
|
-
return started;
|
|
390
|
-
const text = current.text + event.text;
|
|
391
|
-
const providerMetadata = event.providerMetadata ?? current.providerMetadata;
|
|
392
|
-
return {
|
|
393
|
-
...replaceContent(started, current.contentIndex, textContent(text, providerMetadata)),
|
|
394
|
-
textParts: { ...started.textParts, [event.id]: { ...current, text, providerMetadata } },
|
|
395
|
-
};
|
|
396
|
-
};
|
|
397
|
-
const reduceTextEnd = (state, event) => {
|
|
398
|
-
const current = state.textParts[event.id];
|
|
399
|
-
if (!current)
|
|
400
|
-
return state;
|
|
401
|
-
const text = event.text ?? current.text;
|
|
402
|
-
const providerMetadata = event.providerMetadata ?? current.providerMetadata;
|
|
403
|
-
return {
|
|
404
|
-
...replaceContent(state, current.contentIndex, textContent(text, providerMetadata)),
|
|
405
|
-
textParts: { ...state.textParts, [event.id]: { ...current, text, providerMetadata } },
|
|
406
|
-
};
|
|
379
|
+
return withContentParts(appendContent(state, contentPart(type, "", providerMetadata)), type, {
|
|
380
|
+
...parts,
|
|
381
|
+
[id]: { contentIndex: state.message.content.length, text: "", providerMetadata },
|
|
382
|
+
});
|
|
407
383
|
};
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
...appendContent(state, reasoningContent("", providerMetadata)),
|
|
413
|
-
reasoningParts: {
|
|
414
|
-
...state.reasoningParts,
|
|
415
|
-
[id]: { contentIndex: state.message.content.length, text: "", providerMetadata },
|
|
416
|
-
},
|
|
417
|
-
};
|
|
418
|
-
};
|
|
419
|
-
const reduceReasoningDelta = (state, event) => {
|
|
420
|
-
const started = ensureReasoning(state, event.id, event.providerMetadata);
|
|
421
|
-
const current = started.reasoningParts[event.id];
|
|
384
|
+
const reduceContentDelta = (state, type, event) => {
|
|
385
|
+
const started = ensureContent(state, type, event.id, event.providerMetadata);
|
|
386
|
+
const parts = contentParts(started, type);
|
|
387
|
+
const current = parts[event.id];
|
|
422
388
|
if (!current)
|
|
423
389
|
return started;
|
|
424
390
|
const text = current.text + event.text;
|
|
425
391
|
const providerMetadata = event.providerMetadata ?? current.providerMetadata;
|
|
426
|
-
return {
|
|
427
|
-
...
|
|
428
|
-
|
|
429
|
-
};
|
|
392
|
+
return withContentParts(replaceContent(started, current.contentIndex, contentPart(type, text, providerMetadata)), type, {
|
|
393
|
+
...parts,
|
|
394
|
+
[event.id]: { ...current, text, providerMetadata },
|
|
395
|
+
});
|
|
430
396
|
};
|
|
431
|
-
const
|
|
432
|
-
const
|
|
397
|
+
const reduceContentEnd = (state, type, event) => {
|
|
398
|
+
const parts = contentParts(state, type);
|
|
399
|
+
const current = parts[event.id];
|
|
433
400
|
if (!current)
|
|
434
401
|
return state;
|
|
435
402
|
const text = event.text ?? current.text;
|
|
436
403
|
const providerMetadata = event.providerMetadata ?? current.providerMetadata;
|
|
437
|
-
return {
|
|
438
|
-
...
|
|
439
|
-
|
|
440
|
-
};
|
|
404
|
+
return withContentParts(replaceContent(state, current.contentIndex, contentPart(type, text, providerMetadata)), type, {
|
|
405
|
+
...parts,
|
|
406
|
+
[event.id]: { ...current, text, providerMetadata },
|
|
407
|
+
});
|
|
441
408
|
};
|
|
442
409
|
const reduceToolInputStart = (state, event) => ({
|
|
443
410
|
...state,
|
|
@@ -501,17 +468,17 @@ const reduceResponseState = (state, event) => {
|
|
|
501
468
|
case "compaction":
|
|
502
469
|
return appendContent(next, event);
|
|
503
470
|
case "text-start":
|
|
504
|
-
return
|
|
471
|
+
return ensureContent(next, "text", event.id, event.providerMetadata);
|
|
505
472
|
case "text-delta":
|
|
506
|
-
return
|
|
473
|
+
return reduceContentDelta(next, "text", event);
|
|
507
474
|
case "text-end":
|
|
508
|
-
return
|
|
475
|
+
return reduceContentEnd(next, "text", event);
|
|
509
476
|
case "reasoning-start":
|
|
510
|
-
return
|
|
477
|
+
return ensureContent(next, "reasoning", event.id, event.providerMetadata);
|
|
511
478
|
case "reasoning-delta":
|
|
512
|
-
return
|
|
479
|
+
return reduceContentDelta(next, "reasoning", event);
|
|
513
480
|
case "reasoning-end":
|
|
514
|
-
return
|
|
481
|
+
return reduceContentEnd(next, "reasoning", event);
|
|
515
482
|
case "tool-input-start":
|
|
516
483
|
return reduceToolInputStart(next, event);
|
|
517
484
|
case "tool-input-delta":
|
package/dist/speech-client.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare const SpeechClient: {
|
|
|
57
57
|
} | undefined;
|
|
58
58
|
})[];
|
|
59
59
|
readonly layer: import("effect/Layer").Layer<SpeechClientService, never, import("./route.js").RequestExecutorService>;
|
|
60
|
-
readonly generate: (request: SpeechRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<SpeechResponse, import("./
|
|
60
|
+
readonly generate: (request: SpeechRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<SpeechResponse, import("./public.js").AIError, SpeechClientService>;
|
|
61
61
|
readonly stream: (request: SpeechRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
|
|
62
62
|
readonly type: "audio-delta";
|
|
63
63
|
readonly chunk: Uint8Array<ArrayBufferLike>;
|
|
@@ -97,11 +97,11 @@ export declare const SpeechClient: {
|
|
|
97
97
|
readonly [x: string]: unknown;
|
|
98
98
|
};
|
|
99
99
|
} | undefined;
|
|
100
|
-
} | import("./generation.js").Observation, import("./
|
|
101
|
-
readonly start: (request: SpeechRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<SpeechResponse>, import("./
|
|
100
|
+
} | import("./generation.js").Observation, import("./public.js").AIError, SpeechClientService>;
|
|
101
|
+
readonly start: (request: SpeechRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<SpeechResponse>, import("./public.js").AIError, SpeechClientService>;
|
|
102
102
|
readonly resume: (model: import("./speech.js").SpeechModel<{
|
|
103
103
|
readonly [x: string]: unknown;
|
|
104
|
-
}>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<SpeechResponse>, import("./
|
|
104
|
+
}>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<SpeechResponse>, import("./public.js").AIError, SpeechClientService>;
|
|
105
105
|
readonly Service: typeof SpeechClientService;
|
|
106
106
|
};
|
|
107
107
|
export {};
|
|
@@ -73,7 +73,7 @@ export declare const TranscriptionClient: {
|
|
|
73
73
|
readonly type: "finish";
|
|
74
74
|
})[];
|
|
75
75
|
readonly layer: import("effect/Layer").Layer<TranscriptionClientService, never, import("./route.js").RequestExecutorService>;
|
|
76
|
-
readonly generate: (request: TranscriptionRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<TranscriptionResponse, import("./
|
|
76
|
+
readonly generate: (request: TranscriptionRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<TranscriptionResponse, import("./public.js").AIError, TranscriptionClientService>;
|
|
77
77
|
readonly stream: (request: TranscriptionRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
|
|
78
78
|
readonly type: "text-delta";
|
|
79
79
|
readonly delta: string;
|
|
@@ -129,11 +129,11 @@ export declare const TranscriptionClient: {
|
|
|
129
129
|
};
|
|
130
130
|
} | undefined;
|
|
131
131
|
readonly type: "finish";
|
|
132
|
-
} | import("./generation.js").Observation, import("./
|
|
133
|
-
readonly start: (request: TranscriptionRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<TranscriptionResponse>, import("./
|
|
132
|
+
} | import("./generation.js").Observation, import("./public.js").AIError, TranscriptionClientService>;
|
|
133
|
+
readonly start: (request: TranscriptionRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<TranscriptionResponse>, import("./public.js").AIError, TranscriptionClientService>;
|
|
134
134
|
readonly resume: (model: import("./transcription.js").TranscriptionModel<{
|
|
135
135
|
readonly [x: string]: unknown;
|
|
136
|
-
}>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<TranscriptionResponse>, import("./
|
|
136
|
+
}>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<TranscriptionResponse>, import("./public.js").AIError, TranscriptionClientService>;
|
|
137
137
|
readonly Service: typeof TranscriptionClientService;
|
|
138
138
|
};
|
|
139
139
|
export {};
|
package/dist/video-client.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare const VideoClient: {
|
|
|
50
50
|
} | undefined;
|
|
51
51
|
})[];
|
|
52
52
|
readonly layer: import("effect/Layer").Layer<VideoClientService, never, import("./route.js").RequestExecutorService>;
|
|
53
|
-
readonly generate: (request: VideoRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<VideoResponse, import("./
|
|
53
|
+
readonly generate: (request: VideoRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<VideoResponse, import("./public.js").AIError, VideoClientService>;
|
|
54
54
|
readonly stream: (request: VideoRequest, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
|
|
55
55
|
readonly type: "video";
|
|
56
56
|
readonly index: number;
|
|
@@ -83,11 +83,11 @@ export declare const VideoClient: {
|
|
|
83
83
|
readonly [x: string]: unknown;
|
|
84
84
|
};
|
|
85
85
|
} | undefined;
|
|
86
|
-
} | import("./generation.js").Observation, import("./
|
|
87
|
-
readonly start: (request: VideoRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./
|
|
86
|
+
} | import("./generation.js").Observation, import("./public.js").AIError, VideoClientService>;
|
|
87
|
+
readonly start: (request: VideoRequest) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./public.js").AIError, VideoClientService>;
|
|
88
88
|
readonly resume: (model: import("./video.js").VideoModel<{
|
|
89
89
|
readonly [x: string]: unknown;
|
|
90
|
-
}>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./
|
|
90
|
+
}>, token: unknown) => import("effect/Effect").Effect<import("./generation.js").Generation<VideoResponse>, import("./public.js").AIError, VideoClientService>;
|
|
91
91
|
readonly Service: typeof VideoClientService;
|
|
92
92
|
};
|
|
93
93
|
export {};
|
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-513",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -520,7 +520,7 @@
|
|
|
520
520
|
"devDependencies": {
|
|
521
521
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
522
522
|
"@effect/platform-node": "4.1.0",
|
|
523
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
523
|
+
"@opencode/http-recorder": "0.0.0-dev-513",
|
|
524
524
|
"@tsconfig/bun": "1.0.9",
|
|
525
525
|
"@types/bun": "1.4.3",
|
|
526
526
|
"@typescript/native": "npm:typescript@7.1.0-beta",
|
|
@@ -530,7 +530,7 @@
|
|
|
530
530
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
531
531
|
"@smithy/eventstream-codec": "4.2.14",
|
|
532
532
|
"@smithy/util-utf8": "4.2.2",
|
|
533
|
-
"@opencode/schema": "0.0.0-dev-
|
|
533
|
+
"@opencode/schema": "0.0.0-dev-513",
|
|
534
534
|
"aws4fetch": "1.0.20",
|
|
535
535
|
"effect": "4.1.0",
|
|
536
536
|
"google-auth-library": "10.5.0"
|