@opencode-ai/ai 0.0.0-next-16570 → 0.0.0-next-16589
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.
|
@@ -6,15 +6,23 @@ import { Lifecycle } from "./utils/lifecycle";
|
|
|
6
6
|
export declare const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
7
7
|
export interface OptionsInput {
|
|
8
8
|
readonly [key: string]: unknown;
|
|
9
|
+
readonly cachedContent?: string;
|
|
10
|
+
readonly safetySettings?: ReadonlyArray<{
|
|
11
|
+
readonly category: "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY" | (string & {});
|
|
12
|
+
readonly threshold: "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF" | (string & {});
|
|
13
|
+
}>;
|
|
14
|
+
readonly serviceTier?: "standard" | "flex" | "priority" | (string & {});
|
|
9
15
|
readonly thinkingConfig?: {
|
|
10
16
|
readonly thinkingBudget?: number;
|
|
11
17
|
readonly includeThoughts?: boolean;
|
|
18
|
+
readonly thinkingLevel?: "minimal" | "low" | "medium" | "high" | (string & {});
|
|
12
19
|
};
|
|
13
20
|
}
|
|
14
21
|
export type ProviderOptionsInput = ProviderOptions & {
|
|
15
22
|
readonly gemini?: OptionsInput;
|
|
16
23
|
};
|
|
17
24
|
declare const GeminiBody: Schema.Struct<{
|
|
25
|
+
cachedContent: Schema.optional<Schema.String>;
|
|
18
26
|
contents: Schema.$Array<Schema.Struct<{
|
|
19
27
|
readonly role: Schema.Literals<readonly ["user", "model"]>;
|
|
20
28
|
readonly parts: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
@@ -47,6 +55,11 @@ declare const GeminiBody: Schema.Struct<{
|
|
|
47
55
|
}>;
|
|
48
56
|
}>]>>;
|
|
49
57
|
}>>;
|
|
58
|
+
safetySettings: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
59
|
+
readonly category: Schema.String;
|
|
60
|
+
readonly threshold: Schema.String;
|
|
61
|
+
}>>>;
|
|
62
|
+
serviceTier: Schema.optional<Schema.String>;
|
|
50
63
|
systemInstruction: Schema.optional<Schema.Struct<{
|
|
51
64
|
readonly parts: Schema.$Array<Schema.Struct<{
|
|
52
65
|
readonly text: Schema.String;
|
|
@@ -74,6 +87,7 @@ declare const GeminiBody: Schema.Struct<{
|
|
|
74
87
|
readonly thinkingConfig: Schema.optional<Schema.Struct<{
|
|
75
88
|
readonly thinkingBudget: Schema.optional<Schema.Number>;
|
|
76
89
|
readonly includeThoughts: Schema.optional<Schema.Boolean>;
|
|
90
|
+
readonly thinkingLevel: Schema.optional<Schema.String>;
|
|
77
91
|
}>>;
|
|
78
92
|
}>>;
|
|
79
93
|
}>;
|
|
@@ -133,6 +147,7 @@ export declare const protocol: Protocol<{
|
|
|
133
147
|
readonly thinkingConfig?: {
|
|
134
148
|
readonly thinkingBudget?: number | undefined;
|
|
135
149
|
readonly includeThoughts?: boolean | undefined;
|
|
150
|
+
readonly thinkingLevel?: string | undefined;
|
|
136
151
|
} | undefined;
|
|
137
152
|
readonly maxOutputTokens?: number | undefined;
|
|
138
153
|
} | undefined;
|
|
@@ -147,6 +162,12 @@ export declare const protocol: Protocol<{
|
|
|
147
162
|
readonly allowedFunctionNames?: readonly string[] | undefined;
|
|
148
163
|
};
|
|
149
164
|
} | undefined;
|
|
165
|
+
readonly cachedContent?: string | undefined;
|
|
166
|
+
readonly safetySettings?: readonly {
|
|
167
|
+
readonly category: string;
|
|
168
|
+
readonly threshold: string;
|
|
169
|
+
}[] | undefined;
|
|
170
|
+
readonly serviceTier?: string | undefined;
|
|
150
171
|
}, string, {
|
|
151
172
|
readonly candidates?: readonly {
|
|
152
173
|
readonly content?: {
|
|
@@ -245,6 +266,7 @@ export declare const route: Route<{
|
|
|
245
266
|
readonly thinkingConfig?: {
|
|
246
267
|
readonly thinkingBudget?: number | undefined;
|
|
247
268
|
readonly includeThoughts?: boolean | undefined;
|
|
269
|
+
readonly thinkingLevel?: string | undefined;
|
|
248
270
|
} | undefined;
|
|
249
271
|
readonly maxOutputTokens?: number | undefined;
|
|
250
272
|
} | undefined;
|
|
@@ -259,5 +281,11 @@ export declare const route: Route<{
|
|
|
259
281
|
readonly allowedFunctionNames?: readonly string[] | undefined;
|
|
260
282
|
};
|
|
261
283
|
} | undefined;
|
|
284
|
+
readonly cachedContent?: string | undefined;
|
|
285
|
+
readonly safetySettings?: readonly {
|
|
286
|
+
readonly category: string;
|
|
287
|
+
readonly threshold: string;
|
|
288
|
+
}[] | undefined;
|
|
289
|
+
readonly serviceTier?: string | undefined;
|
|
262
290
|
}, import("../route/transport/http").HttpPrepared<string>>;
|
|
263
291
|
export * as Gemini from "./gemini";
|
package/dist/protocols/gemini.js
CHANGED
|
@@ -73,6 +73,11 @@ const GeminiToolConfig = Schema.Struct({
|
|
|
73
73
|
const GeminiThinkingConfig = Schema.Struct({
|
|
74
74
|
thinkingBudget: Schema.optional(Schema.Number),
|
|
75
75
|
includeThoughts: Schema.optional(Schema.Boolean),
|
|
76
|
+
thinkingLevel: Schema.optional(Schema.String),
|
|
77
|
+
});
|
|
78
|
+
const GeminiSafetySetting = Schema.Struct({
|
|
79
|
+
category: Schema.String,
|
|
80
|
+
threshold: Schema.String,
|
|
76
81
|
});
|
|
77
82
|
const GeminiGenerationConfig = Schema.Struct({
|
|
78
83
|
maxOutputTokens: Schema.optional(Schema.Number),
|
|
@@ -83,7 +88,10 @@ const GeminiGenerationConfig = Schema.Struct({
|
|
|
83
88
|
thinkingConfig: Schema.optional(GeminiThinkingConfig),
|
|
84
89
|
});
|
|
85
90
|
const GeminiBodyFields = {
|
|
91
|
+
cachedContent: Schema.optional(Schema.String),
|
|
86
92
|
contents: Schema.Array(GeminiContent),
|
|
93
|
+
safetySettings: optionalArray(GeminiSafetySetting),
|
|
94
|
+
serviceTier: Schema.optional(Schema.String),
|
|
87
95
|
systemInstruction: Schema.optional(GeminiSystemInstruction),
|
|
88
96
|
tools: optionalArray(GeminiTool),
|
|
89
97
|
toolConfig: Schema.optional(GeminiToolConfig),
|
|
@@ -248,17 +256,32 @@ const lowerMessages = Effect.fn("Gemini.lowerMessages")(function* (request) {
|
|
|
248
256
|
return contents;
|
|
249
257
|
});
|
|
250
258
|
const resolveOptions = (request) => {
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
return {};
|
|
259
|
+
const input = request.providerOptions?.gemini;
|
|
260
|
+
const value = input?.thinkingConfig;
|
|
254
261
|
const thinkingConfig = {
|
|
255
|
-
thinkingBudget: typeof value.thinkingBudget === "number" ? value.thinkingBudget : undefined,
|
|
256
|
-
includeThoughts: typeof value.includeThoughts === "boolean"
|
|
262
|
+
thinkingBudget: ProviderShared.isRecord(value) && typeof value.thinkingBudget === "number" ? value.thinkingBudget : undefined,
|
|
263
|
+
includeThoughts: ProviderShared.isRecord(value) && typeof value.includeThoughts === "boolean"
|
|
264
|
+
? value.includeThoughts
|
|
265
|
+
: ProviderShared.isRecord(value)
|
|
266
|
+
? true
|
|
267
|
+
: undefined,
|
|
268
|
+
thinkingLevel: ProviderShared.isRecord(value) && typeof value.thinkingLevel === "string" ? value.thinkingLevel : undefined,
|
|
257
269
|
};
|
|
258
270
|
return {
|
|
271
|
+
cachedContent: typeof input?.cachedContent === "string" ? input.cachedContent : undefined,
|
|
272
|
+
safetySettings: mapSafetySettings(input?.safetySettings),
|
|
273
|
+
serviceTier: typeof input?.serviceTier === "string" ? input.serviceTier : undefined,
|
|
259
274
|
thinkingConfig: Object.values(thinkingConfig).some((item) => item !== undefined) ? thinkingConfig : undefined,
|
|
260
275
|
};
|
|
261
276
|
};
|
|
277
|
+
function mapSafetySettings(value) {
|
|
278
|
+
if (!Array.isArray(value))
|
|
279
|
+
return undefined;
|
|
280
|
+
const settings = value.flatMap((item) => ProviderShared.isRecord(item) && typeof item.category === "string" && typeof item.threshold === "string"
|
|
281
|
+
? [{ category: item.category, threshold: item.threshold }]
|
|
282
|
+
: []);
|
|
283
|
+
return settings;
|
|
284
|
+
}
|
|
262
285
|
const fromRequest = Effect.fn("Gemini.fromRequest")(function* (request) {
|
|
263
286
|
const hasTools = request.tools.length > 0;
|
|
264
287
|
const generation = request.generation;
|
|
@@ -273,7 +296,10 @@ const fromRequest = Effect.fn("Gemini.fromRequest")(function* (request) {
|
|
|
273
296
|
thinkingConfig: options.thinkingConfig,
|
|
274
297
|
};
|
|
275
298
|
return {
|
|
299
|
+
cachedContent: options.cachedContent,
|
|
276
300
|
contents: yield* lowerMessages(request),
|
|
301
|
+
safetySettings: options.safetySettings,
|
|
302
|
+
serviceTier: options.serviceTier,
|
|
277
303
|
systemInstruction: request.system.length === 0 ? undefined : { parts: [{ text: ProviderShared.joinText(request.system) }] },
|
|
278
304
|
tools: hasTools
|
|
279
305
|
? [
|
|
@@ -74,6 +74,7 @@ export declare const routes: Route<{
|
|
|
74
74
|
readonly thinkingConfig?: {
|
|
75
75
|
readonly thinkingBudget?: number | undefined;
|
|
76
76
|
readonly includeThoughts?: boolean | undefined;
|
|
77
|
+
readonly thinkingLevel?: string | undefined;
|
|
77
78
|
} | undefined;
|
|
78
79
|
readonly maxOutputTokens?: number | undefined;
|
|
79
80
|
} | undefined;
|
|
@@ -88,6 +89,12 @@ export declare const routes: Route<{
|
|
|
88
89
|
readonly allowedFunctionNames?: readonly string[] | undefined;
|
|
89
90
|
};
|
|
90
91
|
} | undefined;
|
|
92
|
+
readonly cachedContent?: string | undefined;
|
|
93
|
+
readonly safetySettings?: readonly {
|
|
94
|
+
readonly category: string;
|
|
95
|
+
readonly threshold: string;
|
|
96
|
+
}[] | undefined;
|
|
97
|
+
readonly serviceTier?: string | undefined;
|
|
91
98
|
}, import("../route/transport/http").HttpPrepared<string>>[];
|
|
92
99
|
export declare const configure: (input?: Config) => {
|
|
93
100
|
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
@@ -57,6 +57,7 @@ export declare const routes: import("../route").Route<{
|
|
|
57
57
|
readonly thinkingConfig?: {
|
|
58
58
|
readonly thinkingBudget?: number | undefined;
|
|
59
59
|
readonly includeThoughts?: boolean | undefined;
|
|
60
|
+
readonly thinkingLevel?: string | undefined;
|
|
60
61
|
} | undefined;
|
|
61
62
|
readonly maxOutputTokens?: number | undefined;
|
|
62
63
|
} | undefined;
|
|
@@ -71,6 +72,12 @@ export declare const routes: import("../route").Route<{
|
|
|
71
72
|
readonly allowedFunctionNames?: readonly string[] | undefined;
|
|
72
73
|
};
|
|
73
74
|
} | undefined;
|
|
75
|
+
readonly cachedContent?: string | undefined;
|
|
76
|
+
readonly safetySettings?: readonly {
|
|
77
|
+
readonly category: string;
|
|
78
|
+
readonly threshold: string;
|
|
79
|
+
}[] | undefined;
|
|
80
|
+
readonly serviceTier?: string | undefined;
|
|
74
81
|
}, import("../route/transport/http").HttpPrepared<string>>[];
|
|
75
82
|
export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
76
83
|
readonly baseURL?: 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-16589",
|
|
4
4
|
"name": "@opencode-ai/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
32
32
|
"@effect/platform-node": "4.0.0-beta.101",
|
|
33
|
-
"@opencode-ai/http-recorder": "0.0.0-next-
|
|
33
|
+
"@opencode-ai/http-recorder": "0.0.0-next-16589",
|
|
34
34
|
"@tsconfig/bun": "1.0.9",
|
|
35
35
|
"@types/bun": "1.3.13",
|
|
36
36
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@smithy/eventstream-codec": "4.2.14",
|
|
41
41
|
"@smithy/util-utf8": "4.2.2",
|
|
42
|
-
"@opencode-ai/schema": "0.0.0-next-
|
|
42
|
+
"@opencode-ai/schema": "0.0.0-next-16589",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-beta.101",
|
|
45
45
|
"google-auth-library": "10.5.0"
|