@opencode-ai/ai 0.0.0-next-15825 → 0.0.0-next-15830
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 +43 -2
- package/dist/image-client.d.ts +19 -0
- package/dist/image-client.js +19 -0
- package/dist/image.d.ts +78 -0
- package/dist/image.js +77 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/protocols/index.d.ts +1 -0
- package/dist/protocols/index.js +1 -0
- package/dist/protocols/openai-compatible-responses.d.ts +14 -2
- package/dist/protocols/openai-images.d.ts +36 -0
- package/dist/protocols/openai-images.js +145 -0
- package/dist/protocols/openai-responses.d.ts +100 -14
- package/dist/protocols/openai-responses.js +73 -19
- package/dist/protocols/utils/openai-image.d.ts +5 -0
- package/dist/protocols/utils/openai-image.js +18 -0
- package/dist/providers/azure.d.ts +14 -2
- package/dist/providers/github-copilot.d.ts +14 -2
- package/dist/providers/google-vertex-responses.d.ts +14 -2
- package/dist/providers/openai-compatible-responses.d.ts +14 -2
- package/dist/providers/openai.d.ts +50 -5
- package/dist/providers/openai.js +33 -2
- package/dist/providers/xai.d.ts +14 -2
- package/dist/route/auth.d.ts +4 -2
- package/package.json +3 -3
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type ProviderAuthOption } from "../route/auth-options";
|
|
2
2
|
import type { Route, RouteDefaultsInput } from "../route/client";
|
|
3
3
|
import type { ProviderPackage } from "../provider-package";
|
|
4
|
-
import { type ModelID } from "../schema";
|
|
4
|
+
import { ToolDefinition, type ModelID } from "../schema";
|
|
5
5
|
import { type OpenAIProviderOptionsInput } from "./openai-options";
|
|
6
|
+
import { type OpenAIImageOptions } from "../protocols/openai-images";
|
|
6
7
|
export type { OpenAIOptionsInput, OpenAIResponseIncludable } from "./openai-options";
|
|
8
|
+
export type { OpenAIImageOptions } from "../protocols/openai-images";
|
|
7
9
|
export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
8
10
|
export declare const routes: (Route<{
|
|
9
11
|
readonly messages: readonly (import("effect/Schema").Struct.ReadonlySide<{
|
|
@@ -122,7 +124,7 @@ export declare const routes: (Route<{
|
|
|
122
124
|
readonly effort?: string | undefined;
|
|
123
125
|
readonly summary?: "auto" | undefined;
|
|
124
126
|
} | undefined;
|
|
125
|
-
readonly tools?: readonly {
|
|
127
|
+
readonly tools?: readonly ({
|
|
126
128
|
readonly type: "function";
|
|
127
129
|
readonly name: string;
|
|
128
130
|
readonly description: string;
|
|
@@ -130,11 +132,23 @@ export declare const routes: (Route<{
|
|
|
130
132
|
readonly [x: string]: unknown;
|
|
131
133
|
};
|
|
132
134
|
readonly strict?: boolean | undefined;
|
|
133
|
-
}
|
|
135
|
+
} | {
|
|
136
|
+
readonly type: "image_generation";
|
|
137
|
+
readonly size?: string | undefined;
|
|
138
|
+
readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
|
|
139
|
+
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
140
|
+
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
141
|
+
readonly output_compression?: number | undefined;
|
|
142
|
+
readonly action?: "generate" | "auto" | "edit" | undefined;
|
|
143
|
+
readonly input_fidelity?: "low" | "high" | undefined;
|
|
144
|
+
readonly partial_images?: number | undefined;
|
|
145
|
+
})[] | undefined;
|
|
134
146
|
readonly temperature?: number | undefined;
|
|
135
147
|
readonly tool_choice?: "required" | "none" | "auto" | import("effect/Schema").Struct.ReadonlySide<{
|
|
136
148
|
readonly type: import("effect/Schema").tag<"function">;
|
|
137
149
|
readonly name: import("effect/Schema").String;
|
|
150
|
+
}, "Type"> | import("effect/Schema").Struct.ReadonlySide<{
|
|
151
|
+
readonly type: import("effect/Schema").tag<"image_generation">;
|
|
138
152
|
}, "Type"> | undefined;
|
|
139
153
|
readonly top_p?: number | undefined;
|
|
140
154
|
readonly store?: boolean | undefined;
|
|
@@ -198,7 +212,7 @@ export declare const routes: (Route<{
|
|
|
198
212
|
readonly effort?: string | undefined;
|
|
199
213
|
readonly summary?: "auto" | undefined;
|
|
200
214
|
} | undefined;
|
|
201
|
-
readonly tools?: readonly {
|
|
215
|
+
readonly tools?: readonly ({
|
|
202
216
|
readonly type: "function";
|
|
203
217
|
readonly name: string;
|
|
204
218
|
readonly description: string;
|
|
@@ -206,11 +220,23 @@ export declare const routes: (Route<{
|
|
|
206
220
|
readonly [x: string]: unknown;
|
|
207
221
|
};
|
|
208
222
|
readonly strict?: boolean | undefined;
|
|
209
|
-
}
|
|
223
|
+
} | {
|
|
224
|
+
readonly type: "image_generation";
|
|
225
|
+
readonly size?: string | undefined;
|
|
226
|
+
readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
|
|
227
|
+
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
228
|
+
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
229
|
+
readonly output_compression?: number | undefined;
|
|
230
|
+
readonly action?: "generate" | "auto" | "edit" | undefined;
|
|
231
|
+
readonly input_fidelity?: "low" | "high" | undefined;
|
|
232
|
+
readonly partial_images?: number | undefined;
|
|
233
|
+
})[] | undefined;
|
|
210
234
|
readonly temperature?: number | undefined;
|
|
211
235
|
readonly tool_choice?: "required" | "none" | "auto" | import("effect/Schema").Struct.ReadonlySide<{
|
|
212
236
|
readonly type: import("effect/Schema").tag<"function">;
|
|
213
237
|
readonly name: import("effect/Schema").String;
|
|
238
|
+
}, "Type"> | import("effect/Schema").Struct.ReadonlySide<{
|
|
239
|
+
readonly type: import("effect/Schema").tag<"image_generation">;
|
|
214
240
|
}, "Type"> | undefined;
|
|
215
241
|
readonly top_p?: number | undefined;
|
|
216
242
|
readonly store?: boolean | undefined;
|
|
@@ -224,7 +250,22 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
|
224
250
|
readonly baseURL?: string;
|
|
225
251
|
readonly queryParams?: Record<string, string>;
|
|
226
252
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
253
|
+
readonly image?: ImageConfig;
|
|
227
254
|
};
|
|
255
|
+
export interface ImageConfig {
|
|
256
|
+
readonly providerOptions?: OpenAIImageOptions;
|
|
257
|
+
}
|
|
258
|
+
export interface ImageGenerationOptions {
|
|
259
|
+
readonly action?: "auto" | "generate" | "edit";
|
|
260
|
+
readonly background?: "auto" | "opaque" | "transparent";
|
|
261
|
+
readonly inputFidelity?: "low" | "high";
|
|
262
|
+
readonly outputCompression?: number;
|
|
263
|
+
readonly outputFormat?: "png" | "jpeg" | "webp";
|
|
264
|
+
readonly partialImages?: number;
|
|
265
|
+
readonly quality?: "auto" | "low" | "medium" | "high";
|
|
266
|
+
readonly size?: string;
|
|
267
|
+
}
|
|
268
|
+
export declare const imageGeneration: (options?: ImageGenerationOptions) => ToolDefinition;
|
|
228
269
|
export interface Settings extends ProviderPackage.Settings {
|
|
229
270
|
readonly apiKey?: string;
|
|
230
271
|
readonly baseURL?: string;
|
|
@@ -240,6 +281,7 @@ export declare const configure: (input?: Config) => {
|
|
|
240
281
|
responses: (id: string | ModelID) => import("..").Model;
|
|
241
282
|
responsesWebSocket: (id: string | ModelID) => import("..").Model;
|
|
242
283
|
chat: (id: string | ModelID) => import("..").Model;
|
|
284
|
+
image: (modelID: string | ModelID) => import("..").ImageModel;
|
|
243
285
|
configure: (input?: Config) => /*elided*/ any;
|
|
244
286
|
};
|
|
245
287
|
export declare const provider: {
|
|
@@ -248,12 +290,14 @@ export declare const provider: {
|
|
|
248
290
|
responses: (id: string | ModelID) => import("..").Model;
|
|
249
291
|
responsesWebSocket: (id: string | ModelID) => import("..").Model;
|
|
250
292
|
chat: (id: string | ModelID) => import("..").Model;
|
|
293
|
+
image: (modelID: string | ModelID) => import("..").ImageModel;
|
|
251
294
|
configure: (input?: Config) => {
|
|
252
295
|
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
253
296
|
model: (id: string | ModelID) => import("..").Model;
|
|
254
297
|
responses: (id: string | ModelID) => import("..").Model;
|
|
255
298
|
responsesWebSocket: (id: string | ModelID) => import("..").Model;
|
|
256
299
|
chat: (id: string | ModelID) => import("..").Model;
|
|
300
|
+
image: (modelID: string | ModelID) => import("..").ImageModel;
|
|
257
301
|
configure: /*elided*/ any;
|
|
258
302
|
};
|
|
259
303
|
};
|
|
@@ -262,3 +306,4 @@ export declare const chatModel: ProviderPackage.Definition<Settings>["model"];
|
|
|
262
306
|
export declare const responses: (id: string | ModelID) => import("..").Model;
|
|
263
307
|
export declare const responsesWebSocket: (id: string | ModelID) => import("..").Model;
|
|
264
308
|
export declare const chat: (id: string | ModelID) => import("..").Model;
|
|
309
|
+
export declare const image: (modelID: string | ModelID) => import("..").ImageModel;
|
package/dist/providers/openai.js
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
import { AuthOptions } from "../route/auth-options";
|
|
2
|
-
import { ProviderID } from "../schema";
|
|
2
|
+
import { HttpOptions, ProviderID, ToolDefinition, mergeHttpOptions } from "../schema";
|
|
3
3
|
import * as OpenAIChat from "../protocols/openai-chat";
|
|
4
4
|
import * as OpenAIResponses from "../protocols/openai-responses";
|
|
5
5
|
import { withOpenAIOptions } from "./openai-options";
|
|
6
|
+
import { OpenAIImages } from "../protocols/openai-images";
|
|
6
7
|
export const id = ProviderID.make("openai");
|
|
7
8
|
export const routes = [OpenAIResponses.route, OpenAIResponses.webSocketRoute, OpenAIChat.route];
|
|
9
|
+
export const imageGeneration = (options = {}) => ToolDefinition.make({
|
|
10
|
+
name: "image_generation",
|
|
11
|
+
description: "Generate or edit an image using OpenAI's hosted image generation tool.",
|
|
12
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
13
|
+
native: {
|
|
14
|
+
openai: {
|
|
15
|
+
type: "image_generation",
|
|
16
|
+
action: options.action,
|
|
17
|
+
background: options.background,
|
|
18
|
+
input_fidelity: options.inputFidelity,
|
|
19
|
+
output_compression: options.outputCompression,
|
|
20
|
+
output_format: options.outputFormat,
|
|
21
|
+
partial_images: options.partialImages,
|
|
22
|
+
quality: options.quality,
|
|
23
|
+
size: options.size,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
8
27
|
const auth = (options) => AuthOptions.bearer(options, "OPENAI_API_KEY");
|
|
9
28
|
const defaults = (input) => {
|
|
10
|
-
const { apiKey: _, auth: _auth, baseURL: _baseURL, queryParams: _queryParams, ...rest } = input;
|
|
29
|
+
const { apiKey: _, auth: _auth, baseURL: _baseURL, queryParams: _queryParams, image: _image, ...rest } = input;
|
|
11
30
|
return rest;
|
|
12
31
|
};
|
|
13
32
|
const configuredRoute = (route, input) => route.with({
|
|
@@ -22,12 +41,23 @@ export const configure = (input = {}) => {
|
|
|
22
41
|
const responses = (id) => responsesRoute.with(withOpenAIOptions(id, modelDefaults, { textVerbosity: true })).model({ id });
|
|
23
42
|
const responsesWebSocket = (id) => responsesWebSocketRoute.with(withOpenAIOptions(id, modelDefaults, { textVerbosity: true })).model({ id });
|
|
24
43
|
const chat = (id) => chatRoute.with(withOpenAIOptions(id, modelDefaults)).model({ id });
|
|
44
|
+
const image = (modelID) => OpenAIImages.model({
|
|
45
|
+
id: modelID,
|
|
46
|
+
auth: auth(input),
|
|
47
|
+
baseURL: input.baseURL,
|
|
48
|
+
headers: input.headers,
|
|
49
|
+
defaults: {
|
|
50
|
+
providerOptions: input.image?.providerOptions === undefined ? undefined : { openai: { ...input.image.providerOptions } },
|
|
51
|
+
http: mergeHttpOptions(input.http === undefined ? undefined : HttpOptions.make(input.http), input.queryParams === undefined ? undefined : new HttpOptions({ query: input.queryParams })),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
25
54
|
return {
|
|
26
55
|
id,
|
|
27
56
|
model: responses,
|
|
28
57
|
responses,
|
|
29
58
|
responsesWebSocket,
|
|
30
59
|
chat,
|
|
60
|
+
image,
|
|
31
61
|
configure,
|
|
32
62
|
};
|
|
33
63
|
};
|
|
@@ -60,3 +90,4 @@ export const chatModel = (modelID, settings) => configure(config(settings)).chat
|
|
|
60
90
|
export const responses = provider.responses;
|
|
61
91
|
export const responsesWebSocket = provider.responsesWebSocket;
|
|
62
92
|
export const chat = provider.chat;
|
|
93
|
+
export const image = provider.image;
|
package/dist/providers/xai.d.ts
CHANGED
|
@@ -122,7 +122,7 @@ export declare const routes: (import("../route").Route<{
|
|
|
122
122
|
readonly effort?: string | undefined;
|
|
123
123
|
readonly summary?: "auto" | undefined;
|
|
124
124
|
} | undefined;
|
|
125
|
-
readonly tools?: readonly {
|
|
125
|
+
readonly tools?: readonly ({
|
|
126
126
|
readonly type: "function";
|
|
127
127
|
readonly name: string;
|
|
128
128
|
readonly description: string;
|
|
@@ -130,11 +130,23 @@ export declare const routes: (import("../route").Route<{
|
|
|
130
130
|
readonly [x: string]: unknown;
|
|
131
131
|
};
|
|
132
132
|
readonly strict?: boolean | undefined;
|
|
133
|
-
}
|
|
133
|
+
} | {
|
|
134
|
+
readonly type: "image_generation";
|
|
135
|
+
readonly size?: string | undefined;
|
|
136
|
+
readonly quality?: "low" | "medium" | "high" | "auto" | undefined;
|
|
137
|
+
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
138
|
+
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
139
|
+
readonly output_compression?: number | undefined;
|
|
140
|
+
readonly action?: "generate" | "auto" | "edit" | undefined;
|
|
141
|
+
readonly input_fidelity?: "low" | "high" | undefined;
|
|
142
|
+
readonly partial_images?: number | undefined;
|
|
143
|
+
})[] | undefined;
|
|
134
144
|
readonly temperature?: number | undefined;
|
|
135
145
|
readonly tool_choice?: "required" | "none" | "auto" | import("effect/Schema").Struct.ReadonlySide<{
|
|
136
146
|
readonly type: import("effect/Schema").tag<"function">;
|
|
137
147
|
readonly name: import("effect/Schema").String;
|
|
148
|
+
}, "Type"> | import("effect/Schema").Struct.ReadonlySide<{
|
|
149
|
+
readonly type: import("effect/Schema").tag<"image_generation">;
|
|
138
150
|
}, "Type"> | undefined;
|
|
139
151
|
readonly top_p?: number | undefined;
|
|
140
152
|
readonly store?: boolean | undefined;
|
package/dist/route/auth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Config, Effect, Redacted } from "effect";
|
|
2
2
|
import { Headers } from "effect/unstable/http";
|
|
3
|
-
import { LLMError, type
|
|
3
|
+
import { LLMError, type HttpOptions } from "../schema";
|
|
4
4
|
export declare class MissingCredentialError extends Error {
|
|
5
5
|
readonly source: string;
|
|
6
6
|
readonly _tag = "MissingCredentialError";
|
|
@@ -10,7 +10,9 @@ export type CredentialError = MissingCredentialError | Config.ConfigError;
|
|
|
10
10
|
export type AuthError = CredentialError | LLMError;
|
|
11
11
|
type Secret = string | Redacted.Redacted | Config.Config<string | Redacted.Redacted>;
|
|
12
12
|
export interface AuthInput {
|
|
13
|
-
readonly request:
|
|
13
|
+
readonly request: {
|
|
14
|
+
readonly http?: HttpOptions;
|
|
15
|
+
};
|
|
14
16
|
readonly method: "POST" | "GET";
|
|
15
17
|
readonly url: string;
|
|
16
18
|
readonly body: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-15830",
|
|
4
4
|
"name": "@opencode-ai/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
28
28
|
"@effect/platform-node": "4.0.0-beta.98",
|
|
29
|
-
"@opencode-ai/http-recorder": "0.0.0-next-
|
|
29
|
+
"@opencode-ai/http-recorder": "0.0.0-next-15830",
|
|
30
30
|
"@tsconfig/bun": "1.0.9",
|
|
31
31
|
"@types/bun": "1.3.13",
|
|
32
32
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@smithy/eventstream-codec": "4.2.14",
|
|
37
37
|
"@smithy/util-utf8": "4.2.2",
|
|
38
|
-
"@opencode-ai/schema": "0.0.0-next-
|
|
38
|
+
"@opencode-ai/schema": "0.0.0-next-15830",
|
|
39
39
|
"aws4fetch": "1.0.20",
|
|
40
40
|
"effect": "4.0.0-beta.98",
|
|
41
41
|
"google-auth-library": "10.5.0"
|