@opencode/ai 0.0.0-dev-177 → 0.0.0-dev-187
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 +13 -58
- package/dist/image-client.d.ts +45 -0
- package/dist/index.d.ts +36 -19
- package/dist/index.js +13 -2
- package/dist/media-client.d.ts +1 -0
- package/dist/media-client.js +1 -0
- package/dist/provider-error.js +0 -2
- package/dist/providers/digitalocean/responses.d.ts +4 -0
- package/dist/providers/digitalocean/responses.js +1 -0
- package/dist/providers/digitalocean.d.ts +206 -4
- package/dist/providers/digitalocean.js +17 -6
- package/dist/providers/index.d.ts +0 -4
- package/dist/providers/index.js +0 -4
- package/dist/providers/openrouter/responses.d.ts +4 -0
- package/dist/providers/openrouter/responses.js +1 -0
- package/dist/providers/openrouter.d.ts +207 -5
- package/dist/providers/openrouter.js +20 -11
- package/dist/providers/venice/responses.d.ts +4 -0
- package/dist/providers/venice/responses.js +1 -0
- package/dist/providers/venice.d.ts +206 -4
- package/dist/providers/venice.js +33 -17
- package/dist/route/auth.d.ts +1 -1
- package/dist/route/media-protocol.d.ts +2 -4
- package/dist/route/media.d.ts +1 -1
- package/dist/route/media.js +2 -4
- package/dist/speech-client.d.ts +48 -0
- package/dist/testing/decision.d.ts +16 -0
- package/dist/testing/decision.js +20 -0
- package/dist/testing/image.d.ts +14 -0
- package/dist/testing/image.js +12 -0
- package/dist/testing/media.d.ts +18 -0
- package/dist/testing/media.js +36 -0
- package/dist/testing/script.d.ts +28 -0
- package/dist/testing/script.js +60 -0
- package/dist/testing/speech.d.ts +14 -0
- package/dist/testing/speech.js +12 -0
- package/dist/testing/transcription.d.ts +14 -0
- package/dist/testing/transcription.js +12 -0
- package/dist/testing/video.d.ts +14 -0
- package/dist/testing/video.js +12 -0
- package/dist/testing.d.ts +10 -21
- package/dist/testing.js +11 -54
- package/dist/transcription-client.d.ts +64 -0
- package/dist/video-client.d.ts +41 -0
- package/package.json +14 -18
- package/dist/protocols/bfl-images.d.ts +0 -47
- package/dist/protocols/bfl-images.js +0 -155
- package/dist/protocols/fal-images.d.ts +0 -36
- package/dist/protocols/fal-images.js +0 -96
- package/dist/protocols/fal-video.d.ts +0 -29
- package/dist/protocols/fal-video.js +0 -73
- package/dist/protocols/replicate-images.d.ts +0 -28
- package/dist/protocols/replicate-images.js +0 -127
- package/dist/protocols/stability-images.d.ts +0 -44
- package/dist/protocols/stability-images.js +0 -131
- package/dist/protocols/utils/fal-queue.d.ts +0 -26
- package/dist/protocols/utils/fal-queue.js +0 -67
- package/dist/providers/black-forest-labs.d.ts +0 -21
- package/dist/providers/black-forest-labs.js +0 -23
- package/dist/providers/fal.d.ts +0 -24
- package/dist/providers/fal.js +0 -26
- package/dist/providers/replicate.d.ts +0 -21
- package/dist/providers/replicate.js +0 -17
- package/dist/providers/stability.d.ts +0 -23
- package/dist/providers/stability.js +0 -18
|
@@ -8,6 +8,7 @@ import { SystemOne } from "../protocols/system-one.js";
|
|
|
8
8
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
9
9
|
import { MediaRoute } from "../route/media.js";
|
|
10
10
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
11
|
+
import { OpenResponses } from "../protocols/open-responses.js";
|
|
11
12
|
import { cacheControl } from "../protocols/utils/cache.js";
|
|
12
13
|
import { isRecord, JsonObject, lenient, ProviderShared } from "../protocols/shared.js";
|
|
13
14
|
export const id = ProviderID.make("openrouter");
|
|
@@ -90,18 +91,22 @@ export const route = Route.make({
|
|
|
90
91
|
endpoint: Endpoint.path("/chat/completions", { baseURL }),
|
|
91
92
|
framing: OpenAIChat.framing,
|
|
92
93
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
};
|
|
94
|
+
const responsesRoute = Route.make({
|
|
95
|
+
id: "openrouter-responses",
|
|
96
|
+
provider: id,
|
|
97
|
+
providerMetadataKey: "openrouter",
|
|
98
|
+
protocol: OpenResponses.protocol,
|
|
99
|
+
endpoint: Endpoint.path("/responses", { baseURL }),
|
|
100
|
+
transport: OpenResponses.httpTransport,
|
|
101
|
+
defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
|
|
102
|
+
});
|
|
103
|
+
export const routes = [route, responsesRoute];
|
|
102
104
|
export const configure = (input = {}) => {
|
|
103
|
-
const
|
|
105
|
+
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input;
|
|
104
106
|
const auth = AuthOptions.bearer(input, "OPENROUTER_API_KEY");
|
|
107
|
+
const options = { ...defaults, endpoint: { baseURL: endpoint ?? baseURL }, auth };
|
|
108
|
+
const chatRoute = route.with(options);
|
|
109
|
+
const configuredResponses = responsesRoute.with(options);
|
|
105
110
|
const decisionRoute = SystemOne.route.with({
|
|
106
111
|
provider: id,
|
|
107
112
|
providerMetadataKey: "openrouter",
|
|
@@ -119,7 +124,8 @@ export const configure = (input = {}) => {
|
|
|
119
124
|
});
|
|
120
125
|
return {
|
|
121
126
|
id,
|
|
122
|
-
model: (modelID) =>
|
|
127
|
+
model: (modelID) => chatRoute.model({ id: modelID, compatibility: { supportsPromptCacheKey: true } }),
|
|
128
|
+
responses: (modelID) => configuredResponses.model({ id: modelID }),
|
|
123
129
|
image,
|
|
124
130
|
decision,
|
|
125
131
|
configure,
|
|
@@ -128,7 +134,9 @@ export const configure = (input = {}) => {
|
|
|
128
134
|
export const provider = configure();
|
|
129
135
|
export const decision = provider.decision;
|
|
130
136
|
export const image = provider.image;
|
|
137
|
+
export const responses = provider.responses;
|
|
131
138
|
export const model = (modelID, settings) => configure(config(settings)).model(modelID);
|
|
139
|
+
export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
|
|
132
140
|
export const imageModel = (modelID, settings) => {
|
|
133
141
|
const input = config(settings);
|
|
134
142
|
return configure(input).image(modelID, input.providerOptions);
|
|
@@ -146,3 +154,4 @@ function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
|
|
|
146
154
|
providerOptions,
|
|
147
155
|
};
|
|
148
156
|
}
|
|
157
|
+
export * as OpenRouter from "./openrouter.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { responsesModel as model } from "../venice.js";
|
|
@@ -3,19 +3,217 @@ import { VeniceChat } from "../protocols/venice-chat.js";
|
|
|
3
3
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
5
5
|
import { type ModelID } from "../schema/index.js";
|
|
6
|
+
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
6
7
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
8
|
export type ChatOptionsInput = VeniceChat.OptionsInput;
|
|
8
9
|
export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
9
10
|
readonly baseURL?: string;
|
|
10
11
|
readonly queryParams?: Readonly<Record<string, string>>;
|
|
11
|
-
readonly providerOptions?: ChatOptionsInput;
|
|
12
|
+
readonly providerOptions?: ChatOptionsInput | OpenResponsesProviderOptionsInput;
|
|
12
13
|
};
|
|
13
|
-
export type Settings = ProviderPackage.Settings &
|
|
14
|
+
export type Settings<Options = ChatOptionsInput> = ProviderPackage.Settings & Options & {
|
|
14
15
|
readonly apiKey?: string;
|
|
15
16
|
readonly baseURL?: string;
|
|
16
17
|
readonly queryParams?: Readonly<Record<string, string>>;
|
|
17
18
|
};
|
|
18
|
-
export declare const routes: Route<{
|
|
19
|
+
export declare const routes: (Route<{
|
|
20
|
+
readonly model: string;
|
|
21
|
+
readonly input: readonly ({
|
|
22
|
+
readonly type: "configuration_update";
|
|
23
|
+
readonly reasoning: {
|
|
24
|
+
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: "message";
|
|
28
|
+
readonly role: "system";
|
|
29
|
+
readonly content: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly type: "message";
|
|
32
|
+
readonly role: "developer";
|
|
33
|
+
readonly content: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
36
|
+
readonly call_id: string;
|
|
37
|
+
readonly output: string | readonly ({
|
|
38
|
+
readonly type: "input_text";
|
|
39
|
+
readonly text: string;
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: "input_video";
|
|
42
|
+
readonly video_url: string;
|
|
43
|
+
} | {
|
|
44
|
+
readonly type: "input_image";
|
|
45
|
+
readonly image_url: string;
|
|
46
|
+
readonly detail?: string | undefined;
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: "input_file";
|
|
49
|
+
readonly filename: string;
|
|
50
|
+
readonly detail?: string | undefined;
|
|
51
|
+
readonly file_data?: string | undefined;
|
|
52
|
+
readonly file_url?: string | undefined;
|
|
53
|
+
})[];
|
|
54
|
+
} | {
|
|
55
|
+
readonly type: "reasoning";
|
|
56
|
+
readonly id?: string | undefined;
|
|
57
|
+
readonly summary: readonly {
|
|
58
|
+
readonly type: "summary_text";
|
|
59
|
+
readonly text: string;
|
|
60
|
+
}[];
|
|
61
|
+
readonly encrypted_content?: string | null | undefined;
|
|
62
|
+
} | {
|
|
63
|
+
readonly type: "compaction";
|
|
64
|
+
readonly id?: string | null | undefined;
|
|
65
|
+
readonly encrypted_content: string;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: "message";
|
|
68
|
+
readonly role: "user";
|
|
69
|
+
readonly content: readonly ({
|
|
70
|
+
readonly type: "input_text";
|
|
71
|
+
readonly text: string;
|
|
72
|
+
} | {
|
|
73
|
+
readonly type: "input_video";
|
|
74
|
+
readonly video_url: string;
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: "input_image";
|
|
77
|
+
readonly image_url: string;
|
|
78
|
+
readonly detail?: string | undefined;
|
|
79
|
+
} | {
|
|
80
|
+
readonly type: "input_file";
|
|
81
|
+
readonly filename: string;
|
|
82
|
+
readonly detail?: string | undefined;
|
|
83
|
+
readonly file_data?: string | undefined;
|
|
84
|
+
readonly file_url?: string | undefined;
|
|
85
|
+
})[];
|
|
86
|
+
readonly id?: string | undefined;
|
|
87
|
+
readonly status?: string | undefined;
|
|
88
|
+
} | {
|
|
89
|
+
readonly type: "message";
|
|
90
|
+
readonly id?: string | undefined;
|
|
91
|
+
readonly role: "assistant";
|
|
92
|
+
readonly content: readonly {
|
|
93
|
+
readonly type: "output_text";
|
|
94
|
+
readonly text: string;
|
|
95
|
+
}[];
|
|
96
|
+
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
97
|
+
readonly status?: string | undefined;
|
|
98
|
+
} | {
|
|
99
|
+
readonly type: "function_call";
|
|
100
|
+
readonly id?: string | undefined;
|
|
101
|
+
readonly call_id: string;
|
|
102
|
+
readonly name: string;
|
|
103
|
+
readonly namespace?: string | undefined;
|
|
104
|
+
readonly arguments: string;
|
|
105
|
+
} | {
|
|
106
|
+
readonly type: "custom_tool_call";
|
|
107
|
+
readonly id?: string | undefined;
|
|
108
|
+
readonly call_id: string;
|
|
109
|
+
readonly name: string;
|
|
110
|
+
readonly input: string;
|
|
111
|
+
} | {
|
|
112
|
+
readonly [x: string]: unknown;
|
|
113
|
+
readonly type: "web_search_call";
|
|
114
|
+
readonly id: string;
|
|
115
|
+
readonly status?: string | undefined;
|
|
116
|
+
readonly action?: {
|
|
117
|
+
readonly [x: string]: unknown;
|
|
118
|
+
} | null | undefined;
|
|
119
|
+
} | {
|
|
120
|
+
readonly [x: string]: unknown;
|
|
121
|
+
readonly type: "file_search_call";
|
|
122
|
+
readonly id: string;
|
|
123
|
+
readonly status?: string | undefined;
|
|
124
|
+
readonly queries?: readonly string[] | undefined;
|
|
125
|
+
readonly results?: readonly {
|
|
126
|
+
readonly [x: string]: unknown;
|
|
127
|
+
}[] | null | undefined;
|
|
128
|
+
} | {
|
|
129
|
+
readonly [x: string]: unknown;
|
|
130
|
+
readonly type: "code_interpreter_call";
|
|
131
|
+
readonly id: string;
|
|
132
|
+
readonly status?: string | undefined;
|
|
133
|
+
readonly code?: string | null | undefined;
|
|
134
|
+
readonly container_id?: string | null | undefined;
|
|
135
|
+
readonly outputs?: readonly {
|
|
136
|
+
readonly [x: string]: unknown;
|
|
137
|
+
}[] | null | undefined;
|
|
138
|
+
} | {
|
|
139
|
+
readonly [x: string]: unknown;
|
|
140
|
+
readonly type: "mcp_call";
|
|
141
|
+
readonly id: string;
|
|
142
|
+
readonly status?: string | undefined;
|
|
143
|
+
readonly server_label?: string | undefined;
|
|
144
|
+
readonly name?: string | undefined;
|
|
145
|
+
readonly arguments?: string | undefined;
|
|
146
|
+
readonly output?: string | null | undefined;
|
|
147
|
+
readonly error?: unknown;
|
|
148
|
+
} | {
|
|
149
|
+
readonly [x: string]: unknown;
|
|
150
|
+
readonly type: string;
|
|
151
|
+
readonly id: string;
|
|
152
|
+
})[];
|
|
153
|
+
readonly instructions?: string | undefined;
|
|
154
|
+
readonly tools?: readonly ({
|
|
155
|
+
readonly type: "custom";
|
|
156
|
+
readonly name: string;
|
|
157
|
+
readonly description: string;
|
|
158
|
+
readonly format: {
|
|
159
|
+
readonly type: "text";
|
|
160
|
+
} | {
|
|
161
|
+
readonly type: "grammar";
|
|
162
|
+
readonly syntax: "lark" | "regex";
|
|
163
|
+
readonly definition: string;
|
|
164
|
+
};
|
|
165
|
+
} | {
|
|
166
|
+
readonly type: "function";
|
|
167
|
+
readonly name: string;
|
|
168
|
+
readonly description: string;
|
|
169
|
+
readonly parameters: {
|
|
170
|
+
readonly [x: string]: unknown;
|
|
171
|
+
};
|
|
172
|
+
readonly strict?: boolean | undefined;
|
|
173
|
+
} | {
|
|
174
|
+
readonly [x: string]: unknown;
|
|
175
|
+
readonly type: string;
|
|
176
|
+
})[] | undefined;
|
|
177
|
+
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
178
|
+
readonly type: "custom" | "function";
|
|
179
|
+
readonly name: string;
|
|
180
|
+
} | {
|
|
181
|
+
readonly type: "allowed_tools";
|
|
182
|
+
readonly mode: "auto" | "none" | "required";
|
|
183
|
+
readonly tools: readonly {
|
|
184
|
+
readonly type: "custom" | "function";
|
|
185
|
+
readonly name: string;
|
|
186
|
+
}[];
|
|
187
|
+
} | undefined;
|
|
188
|
+
readonly store?: boolean | undefined;
|
|
189
|
+
readonly metadata?: {
|
|
190
|
+
readonly [x: string]: string;
|
|
191
|
+
} | undefined;
|
|
192
|
+
readonly safety_identifier?: string | undefined;
|
|
193
|
+
readonly stream_options?: {
|
|
194
|
+
readonly include_obfuscation?: boolean | undefined;
|
|
195
|
+
} | undefined;
|
|
196
|
+
readonly top_logprobs?: number | undefined;
|
|
197
|
+
readonly truncation?: "auto" | "disabled" | undefined;
|
|
198
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
199
|
+
readonly prompt_cache_key?: string | undefined;
|
|
200
|
+
readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
|
|
201
|
+
readonly reasoning?: {
|
|
202
|
+
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
203
|
+
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
204
|
+
} | undefined;
|
|
205
|
+
readonly text?: {
|
|
206
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
207
|
+
} | undefined;
|
|
208
|
+
readonly max_output_tokens?: number | undefined;
|
|
209
|
+
readonly max_tool_calls?: number | undefined;
|
|
210
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
211
|
+
readonly temperature?: number | undefined;
|
|
212
|
+
readonly top_p?: number | undefined;
|
|
213
|
+
readonly presence_penalty?: number | undefined;
|
|
214
|
+
readonly frequency_penalty?: number | undefined;
|
|
215
|
+
readonly stream: true;
|
|
216
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
|
|
19
217
|
readonly model: string;
|
|
20
218
|
readonly tools?: readonly ({
|
|
21
219
|
readonly type: "function";
|
|
@@ -210,7 +408,7 @@ export declare const routes: Route<{
|
|
|
210
408
|
readonly [x: string]: unknown;
|
|
211
409
|
} | undefined;
|
|
212
410
|
readonly user?: string | undefined;
|
|
213
|
-
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
|
|
411
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>)[];
|
|
214
412
|
export declare const configure: (input?: Config) => {
|
|
215
413
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
216
414
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
@@ -285,6 +483,7 @@ export declare const configure: (input?: Config) => {
|
|
|
285
483
|
} | undefined;
|
|
286
484
|
readonly user?: string | undefined;
|
|
287
485
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
486
|
+
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
288
487
|
configure: typeof configure;
|
|
289
488
|
};
|
|
290
489
|
export declare const provider: {
|
|
@@ -361,6 +560,7 @@ export declare const provider: {
|
|
|
361
560
|
} | undefined;
|
|
362
561
|
readonly user?: string | undefined;
|
|
363
562
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
563
|
+
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
364
564
|
configure: typeof configure;
|
|
365
565
|
};
|
|
366
566
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
@@ -399,5 +599,7 @@ export declare const chat: (modelID: string | ModelID) => import("../schema/opti
|
|
|
399
599
|
} | undefined;
|
|
400
600
|
readonly user?: string | undefined;
|
|
401
601
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
602
|
+
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
402
603
|
export declare const model: ProviderPackage.Model<Settings, ChatOptionsInput>;
|
|
604
|
+
export declare const responsesModel: ProviderPackage.Model<Settings<OpenResponsesProviderOptionsInput>, OpenResponsesProviderOptionsInput>;
|
|
403
605
|
export * as Venice from "./venice.js";
|
package/dist/providers/venice.js
CHANGED
|
@@ -1,38 +1,54 @@
|
|
|
1
1
|
import { VeniceChat } from "../protocols/venice-chat.js";
|
|
2
2
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
3
|
+
import { OpenResponses } from "../protocols/open-responses.js";
|
|
3
4
|
import { AuthOptions } from "../route/auth-options.js";
|
|
4
5
|
import { Route } from "../route/client.js";
|
|
5
6
|
import { Endpoint } from "../route/endpoint.js";
|
|
6
7
|
import { ProviderID } from "../schema/index.js";
|
|
7
8
|
export const id = ProviderID.make("venice");
|
|
9
|
+
const baseURL = "https://api.venice.ai/api/v1";
|
|
8
10
|
const route = Route.make({
|
|
9
11
|
id: "venice-chat",
|
|
10
12
|
provider: id,
|
|
11
13
|
providerMetadataKey: "venice",
|
|
12
14
|
protocol: VeniceChat.protocol,
|
|
13
|
-
endpoint: Endpoint.path("/chat/completions", { baseURL
|
|
15
|
+
endpoint: Endpoint.path("/chat/completions", { baseURL }),
|
|
14
16
|
framing: OpenAIChat.framing,
|
|
15
17
|
});
|
|
16
|
-
|
|
18
|
+
const responsesRoute = Route.make({
|
|
19
|
+
id: "venice-responses",
|
|
20
|
+
provider: id,
|
|
21
|
+
providerMetadataKey: "venice",
|
|
22
|
+
protocol: OpenResponses.protocol,
|
|
23
|
+
endpoint: Endpoint.path("/responses", { baseURL }),
|
|
24
|
+
transport: OpenResponses.httpTransport,
|
|
25
|
+
defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
|
|
26
|
+
});
|
|
27
|
+
export const routes = [route, responsesRoute];
|
|
17
28
|
export const configure = (input = {}) => {
|
|
18
|
-
const { apiKey: _apiKey, auth: _auth, baseURL, queryParams, ...rest } = input;
|
|
19
|
-
const
|
|
20
|
-
.with({
|
|
29
|
+
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, queryParams, ...rest } = input;
|
|
30
|
+
const options = {
|
|
21
31
|
...rest,
|
|
22
|
-
endpoint: { baseURL:
|
|
32
|
+
endpoint: { baseURL: endpoint ?? baseURL, query: queryParams },
|
|
23
33
|
auth: AuthOptions.bearer(input, "VENICE_API_KEY"),
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
};
|
|
35
|
+
const chat = (modelID) => route.with(options).model({ id: modelID, compatibility: VeniceChat.compatibility });
|
|
36
|
+
const responses = (modelID) => responsesRoute.with(options).model({ id: modelID });
|
|
37
|
+
return { id, model: chat, chat, responses, configure };
|
|
27
38
|
};
|
|
28
39
|
export const provider = configure();
|
|
29
40
|
export const chat = provider.chat;
|
|
30
|
-
export const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
export const responses = provider.responses;
|
|
42
|
+
export const model = (modelID, settings) => configure(config(settings)).model(modelID);
|
|
43
|
+
export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
|
|
44
|
+
function config({ apiKey, baseURL, queryParams, body, headers, ...providerOptions } = {}) {
|
|
45
|
+
return {
|
|
46
|
+
apiKey,
|
|
47
|
+
baseURL,
|
|
48
|
+
queryParams,
|
|
49
|
+
headers,
|
|
50
|
+
http: body === undefined ? undefined : { body },
|
|
51
|
+
providerOptions,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
38
54
|
export * as Venice from "./venice.js";
|
package/dist/route/auth.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare function header(name: string): (source: Secret | Credential) => D
|
|
|
45
45
|
export declare function header(name: string, source: Secret | Credential): Definition;
|
|
46
46
|
export declare function bearerHeader(name: string): (source: Secret | Credential) => Definition;
|
|
47
47
|
export declare function bearerHeader(name: string, source: Secret | Credential): Definition;
|
|
48
|
-
/** `Authorization: <scheme> <secret>` for providers whose scheme is not `Bearer`, such as
|
|
48
|
+
/** `Authorization: <scheme> <secret>` for providers whose scheme is not `Bearer`, such as Deepgram's `Token`. */
|
|
49
49
|
export declare function scheme(name: string): (source: Secret | Credential) => Definition;
|
|
50
50
|
export declare function scheme(name: string, source: Secret | Credential): Definition;
|
|
51
51
|
export declare const toEffect: (input: Definition) => (authInput: AuthInput) => Effect.Effect<Headers.Headers, AIError>;
|
|
@@ -52,18 +52,16 @@ export interface Started<Token> {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* A follow-up call's inputs: the decoded token and the auth headers the route sent, so a protocol can attach them
|
|
55
|
-
* to output URLs that require the same credentials to download (Veo).
|
|
56
|
-
* route's executor, for URLs that expire too soon to hand back (BFL).
|
|
55
|
+
* to output URLs that require the same credentials to download (Veo).
|
|
57
56
|
*/
|
|
58
57
|
export interface PollContext<Token> {
|
|
59
58
|
readonly token: Token;
|
|
60
59
|
readonly auth: Record<string, string>;
|
|
61
|
-
readonly materialize: (asset: Media.Asset) => Effect.Effect<Media.Asset, AIError>;
|
|
62
60
|
}
|
|
63
61
|
/**
|
|
64
62
|
* Submit, then poll. `start` posts the body to the route endpoint; `status`, `result`, and `cancel` are follow-up
|
|
65
63
|
* calls addressed by the token. Paths are relative to the route base URL unless the provider hands back absolute
|
|
66
|
-
* URLs
|
|
64
|
+
* URLs, in which case they are used verbatim. `result` is always its own GET: providers that
|
|
67
65
|
* return the output inside the status body (Veo, xAI, Runway) point `result.path` at the status path and decode the
|
|
68
66
|
* same document, so `Generation.await` and `Video.resume(...).await()` behave identically everywhere.
|
|
69
67
|
*/
|
package/dist/route/media.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Stream } from "effect";
|
|
2
2
|
import { Auth } from "./auth.js";
|
|
3
3
|
import { Endpoint } from "./endpoint.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { Interface } from "./executor-service.js";
|
|
5
5
|
import { MediaProtocol } from "./media-protocol.js";
|
|
6
6
|
import { Generation } from "../generation.js";
|
|
7
7
|
import { AIError, HttpOptions, ProviderID, type ProviderOptions } from "../schema/index.js";
|
package/dist/route/media.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Duration, Effect, Schedule, Schema, Stream } from "effect";
|
|
|
2
2
|
import { Headers, HttpClientRequest } from "effect/http";
|
|
3
3
|
import { Auth } from "./auth.js";
|
|
4
4
|
import { Endpoint } from "./endpoint.js";
|
|
5
|
-
import { RequestExecutorService } from "./executor-service.js";
|
|
6
5
|
import { RequestExecutor } from "./executor.js";
|
|
7
6
|
import { MediaProtocol } from "./media-protocol.js";
|
|
8
7
|
import { Generation, isTerminal } from "../generation.js";
|
|
@@ -61,10 +60,9 @@ export const queued = (input) => {
|
|
|
61
60
|
// A protocol producing a token its own codec rejects is a programmer defect, not a provider error.
|
|
62
61
|
const encodeToken = Schema.encodeSync(protocol.token);
|
|
63
62
|
const generationRoute = (token, http, execute) => {
|
|
64
|
-
const materialize = (asset) => asset.materialize().pipe(Effect.provideService(RequestExecutorService, { execute }));
|
|
65
63
|
// Only the GET exchange retries: a decoded terminal failure (`output.ended`) can be a `ProviderInternal` too, and
|
|
66
64
|
// re-reading it would spin until the caller's deadline.
|
|
67
|
-
const poll = (operation) => transport.call("GET", operation.path(token), http, execute).pipe(Effect.retry({ schedule: READ_RETRY, while: isRetryable }), Effect.flatMap((sent) => operation.decode(sent.response, { token, auth: sent.auth
|
|
65
|
+
const poll = (operation) => transport.call("GET", operation.path(token), http, execute).pipe(Effect.retry({ schedule: READ_RETRY, while: isRetryable }), Effect.flatMap((sent) => operation.decode(sent.response, { token, auth: sent.auth })));
|
|
68
66
|
const status = poll(protocol.status);
|
|
69
67
|
const cancel = protocol.cancel;
|
|
70
68
|
const send = cancel === undefined
|
|
@@ -178,7 +176,7 @@ const makeTransport = (input) => {
|
|
|
178
176
|
}),
|
|
179
177
|
/** Bodiless follow-up call (status, result, cancel) with the same auth and headers as `submit`. */
|
|
180
178
|
call: (method, path, http, execute) => {
|
|
181
|
-
// Provider-issued absolute URLs
|
|
179
|
+
// Provider-issued absolute URLs are used as-is; everything else resolves against the base.
|
|
182
180
|
const url = withQuery(/^https?:\/\//.test(path) ? new URL(path) : baseURL(path), http?.query);
|
|
183
181
|
for (const [key, value] of Object.entries(input.endpoint.query ?? {}))
|
|
184
182
|
url.searchParams.set(key, value);
|
package/dist/speech-client.d.ts
CHANGED
|
@@ -8,6 +8,54 @@ export declare class SpeechClientService extends SpeechClientService_base {
|
|
|
8
8
|
export declare const Service: typeof SpeechClientService;
|
|
9
9
|
export type Service = SpeechClientService;
|
|
10
10
|
export declare const SpeechClient: {
|
|
11
|
+
readonly responseEvents: (response: SpeechResponse) => readonly ({
|
|
12
|
+
readonly type: "audio-delta";
|
|
13
|
+
readonly chunk: Uint8Array<ArrayBufferLike>;
|
|
14
|
+
} | {
|
|
15
|
+
readonly type: "timestamps";
|
|
16
|
+
readonly items: readonly {
|
|
17
|
+
readonly text: string;
|
|
18
|
+
readonly startSeconds: number;
|
|
19
|
+
readonly endSeconds: number;
|
|
20
|
+
}[];
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: "generation-queued";
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly position?: number | undefined;
|
|
25
|
+
} | {
|
|
26
|
+
readonly type: "generation-progress";
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly progress?: number | undefined;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "finish";
|
|
31
|
+
readonly audio: import("./media.js").Asset;
|
|
32
|
+
readonly usage?: {
|
|
33
|
+
readonly type: "seconds";
|
|
34
|
+
readonly seconds: number;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "characters";
|
|
37
|
+
readonly characters: number;
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: "credits";
|
|
40
|
+
readonly credits: number;
|
|
41
|
+
} | {
|
|
42
|
+
readonly type: "compute";
|
|
43
|
+
readonly seconds: number;
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: "tokens";
|
|
46
|
+
readonly input?: number | undefined;
|
|
47
|
+
readonly output?: number | undefined;
|
|
48
|
+
readonly total?: number | undefined;
|
|
49
|
+
readonly details?: {
|
|
50
|
+
readonly [x: string]: unknown;
|
|
51
|
+
} | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
readonly providerMetadata?: {
|
|
54
|
+
readonly [x: string]: {
|
|
55
|
+
readonly [x: string]: unknown;
|
|
56
|
+
};
|
|
57
|
+
} | undefined;
|
|
58
|
+
})[];
|
|
11
59
|
readonly layer: import("effect/Layer").Layer<SpeechClientService, never, import("./route.js").RequestExecutorService>;
|
|
12
60
|
readonly generate: (request: SpeechRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Effect").Effect<SpeechResponse, import("./effect.js").AIError, SpeechClientService>;
|
|
13
61
|
readonly stream: (request: SpeechRequestFor, options?: import("./generation.js").AwaitOptions) => import("effect/Stream").Stream<{
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
|
+
import { type Interface } from "../decision-client.js";
|
|
3
|
+
import type { DecisionRequestFor, DecisionResponse } from "../decision.js";
|
|
4
|
+
import { AIError } from "../schema/index.js";
|
|
5
|
+
import { TestScript } from "./script.js";
|
|
6
|
+
/** Returned as scripted, without checking its answers against the request's questions. */
|
|
7
|
+
export type Response = DecisionResponse | AIError;
|
|
8
|
+
export interface TestInterface extends Interface, TestScript.Controls<DecisionRequestFor, Response> {
|
|
9
|
+
}
|
|
10
|
+
declare const Test_base: Context.ServiceClass<Test, "@opencode/ai/TestDecision/Test", TestInterface>;
|
|
11
|
+
export declare class Test extends Test_base {
|
|
12
|
+
}
|
|
13
|
+
export type LayerOptions = TestScript.Options<DecisionRequestFor, Response>;
|
|
14
|
+
/** Provides one shared implementation under `DecisionClient.Service` and `TestDecision.Test`. */
|
|
15
|
+
export declare const testLayer: (options?: LayerOptions) => Layer.Layer<import("../decision-client.js").Service | Test, never, never>;
|
|
16
|
+
export * as TestDecision from "./decision.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
import { DecisionClient } from "../decision-client.js";
|
|
3
|
+
import { AIError } from "../schema/index.js";
|
|
4
|
+
import { TestScript } from "./script.js";
|
|
5
|
+
export class Test extends Context.Service()("@opencode/ai/TestDecision/Test") {
|
|
6
|
+
}
|
|
7
|
+
/** Provides one shared implementation under `DecisionClient.Service` and `TestDecision.Test`. */
|
|
8
|
+
export const testLayer = (options = {}) => Layer.effectContext(Effect.sync(() => {
|
|
9
|
+
const script = TestScript.make("TestDecision", options);
|
|
10
|
+
const client = Test.of({
|
|
11
|
+
...script.controls,
|
|
12
|
+
generate: (request) => script
|
|
13
|
+
.take(request)
|
|
14
|
+
.pipe(Effect.flatMap((response) => response instanceof AIError
|
|
15
|
+
? Effect.fail(response)
|
|
16
|
+
: Effect.succeed(response))),
|
|
17
|
+
});
|
|
18
|
+
return Context.make(DecisionClient.Service, client).pipe(Context.add(Test, client));
|
|
19
|
+
}));
|
|
20
|
+
export * as TestDecision from "./decision.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import type { ImageEvent, ImageRequestFor, ImageResponse } from "../image.js";
|
|
3
|
+
import { TestMedia } from "./media.js";
|
|
4
|
+
import type { TestScript } from "./script.js";
|
|
5
|
+
export type Response = TestMedia.Response<ImageResponse>;
|
|
6
|
+
export interface TestInterface extends TestMedia.TestInterface<ImageRequestFor, ImageEvent, ImageResponse> {
|
|
7
|
+
}
|
|
8
|
+
declare const Test_base: Context.ServiceClass<Test, "@opencode/ai/TestImage/Test", TestInterface>;
|
|
9
|
+
export declare class Test extends Test_base {
|
|
10
|
+
}
|
|
11
|
+
export type LayerOptions = TestScript.Options<ImageRequestFor, Response>;
|
|
12
|
+
/** Provides one shared implementation under `ImageClient.Service` and `TestImage.Test`. */
|
|
13
|
+
export declare const testLayer: (options?: LayerOptions) => import("effect/Layer").Layer<import("../image-client.js").ImageClientService | Test, never, never>;
|
|
14
|
+
export * as TestImage from "./image.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import { ImageClient } from "../image-client.js";
|
|
3
|
+
import { TestMedia } from "./media.js";
|
|
4
|
+
export class Test extends Context.Service()("@opencode/ai/TestImage/Test") {
|
|
5
|
+
}
|
|
6
|
+
/** Provides one shared implementation under `ImageClient.Service` and `TestImage.Test`. */
|
|
7
|
+
export const testLayer = (options = {}) => TestMedia.testLayer(ImageClient.Service, Test, {
|
|
8
|
+
name: "TestImage",
|
|
9
|
+
responseEvents: ImageClient.responseEvents,
|
|
10
|
+
options,
|
|
11
|
+
});
|
|
12
|
+
export * as TestImage from "./image.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
|
+
import type { MediaClient } from "../media-client.js";
|
|
3
|
+
import { AIError } from "../schema/index.js";
|
|
4
|
+
import { TestScript } from "./script.js";
|
|
5
|
+
/** A scripted reply: the response every operation returns, or the error it fails with. */
|
|
6
|
+
export type Response<Value> = Value | AIError;
|
|
7
|
+
export interface TestInterface<Req extends MediaClient.RoutedRequest<Req, Event, Value>, Event, Value> extends MediaClient.Interface<Req, Event, Value>, TestScript.Controls<Req, Response<Value>> {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Builds one media test client. `stream` expands the response like an inline route, and `start` returns an already
|
|
11
|
+
* finished generation whose token `resume` accepts.
|
|
12
|
+
*/
|
|
13
|
+
export declare const testLayer: <Self, Test, Req extends MediaClient.RoutedRequest<Req, Event, Value>, Event, Value>(service: Context.Service<Self, MediaClient.Interface<Req, Event, Value>>, test: Context.Service<Test, TestInterface<Req, Event, Value>>, input: {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly responseEvents: (response: Value) => ReadonlyArray<Event>;
|
|
16
|
+
readonly options: TestScript.Options<Req, Response<Value>>;
|
|
17
|
+
}) => Layer.Layer<Self | Test, never, never>;
|
|
18
|
+
export * as TestMedia from "./media.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Stream } from "effect";
|
|
2
|
+
import { Generation } from "../generation.js";
|
|
3
|
+
import { AIError } from "../schema/index.js";
|
|
4
|
+
import { TestScript } from "./script.js";
|
|
5
|
+
/**
|
|
6
|
+
* Builds one media test client. `stream` expands the response like an inline route, and `start` returns an already
|
|
7
|
+
* finished generation whose token `resume` accepts.
|
|
8
|
+
*/
|
|
9
|
+
export const testLayer = (service, test, input) => Layer.effectContext(Effect.sync(() => {
|
|
10
|
+
const script = TestScript.make(input.name, input.options);
|
|
11
|
+
const generations = new Map();
|
|
12
|
+
const result = (response) => response instanceof AIError ? Effect.fail(response) : Effect.succeed(response);
|
|
13
|
+
const completed = (id, response) => {
|
|
14
|
+
const snapshot = { id, status: response instanceof AIError ? "failed" : "completed" };
|
|
15
|
+
return new Generation({ status: Effect.succeed(snapshot), result: result(response) }, id, snapshot);
|
|
16
|
+
};
|
|
17
|
+
const generate = (request) => script.take(request).pipe(Effect.flatMap(result));
|
|
18
|
+
const client = test.of({
|
|
19
|
+
...script.controls,
|
|
20
|
+
generate,
|
|
21
|
+
stream: (request) => Stream.fromIterableEffect(Effect.map(generate(request), input.responseEvents)),
|
|
22
|
+
start: (request) => script.take(request).pipe(Effect.map((response) => {
|
|
23
|
+
const id = `${input.name}-${generations.size + 1}`;
|
|
24
|
+
generations.set(id, response);
|
|
25
|
+
return completed(id, response);
|
|
26
|
+
})),
|
|
27
|
+
resume: (_model, token) => {
|
|
28
|
+
const response = typeof token === "string" ? generations.get(token) : undefined;
|
|
29
|
+
if (response === undefined)
|
|
30
|
+
return Effect.die(new Error(`${input.name} has no generation ${String(token)}`));
|
|
31
|
+
return Effect.succeed(completed(String(token), response));
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return Context.make(service, client).pipe(Context.add(test, client));
|
|
35
|
+
}));
|
|
36
|
+
export * as TestMedia from "./media.js";
|