@opencode-ai/ai 0.0.0-next-16149 → 0.0.0-next-16150
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/protocols/anthropic-messages.d.ts +23 -0
- package/dist/protocols/anthropic-messages.js +46 -3
- package/dist/protocols/gemini.d.ts +11 -0
- package/dist/protocols/gemini.js +18 -3
- package/dist/providers/anthropic-compatible.d.ts +6 -4
- package/dist/providers/anthropic.d.ts +6 -4
- package/dist/providers/google-vertex-messages.d.ts +6 -4
- package/dist/providers/google-vertex.d.ts +5 -4
- package/dist/providers/google.d.ts +5 -4
- package/package.json +3 -3
- package/dist/protocols/utils/anthropic-options.d.ts +0 -31
- package/dist/protocols/utils/anthropic-options.js +0 -47
- package/dist/protocols/utils/gemini-options.d.ts +0 -12
- package/dist/protocols/utils/gemini-options.js +0 -19
- package/dist/providers/anthropic-options.d.ts +0 -24
- package/dist/providers/anthropic-options.js +0 -1
- package/dist/providers/gemini-options.d.ts +0 -10
- package/dist/providers/gemini-options.js +0 -1
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { Route } from "../route/client";
|
|
3
3
|
import { Protocol } from "../route/protocol";
|
|
4
|
+
import { type ProviderOptions } from "../schema";
|
|
4
5
|
import { Lifecycle } from "./utils/lifecycle";
|
|
5
6
|
import { ToolStream } from "./utils/tool-stream";
|
|
6
7
|
export declare const DEFAULT_BASE_URL = "https://api.anthropic.com/v1";
|
|
7
8
|
export declare const PATH = "/messages";
|
|
9
|
+
export type ThinkingInput = {
|
|
10
|
+
readonly type: "adaptive";
|
|
11
|
+
readonly display?: "summarized" | "omitted";
|
|
12
|
+
} | {
|
|
13
|
+
readonly type: "disabled";
|
|
14
|
+
} | ({
|
|
15
|
+
readonly type: "enabled";
|
|
16
|
+
} & ({
|
|
17
|
+
readonly budgetTokens: number;
|
|
18
|
+
readonly budget_tokens?: number;
|
|
19
|
+
} | {
|
|
20
|
+
readonly budgetTokens?: number;
|
|
21
|
+
readonly budget_tokens: number;
|
|
22
|
+
}));
|
|
23
|
+
export interface OptionsInput {
|
|
24
|
+
readonly [key: string]: unknown;
|
|
25
|
+
readonly thinking?: ThinkingInput;
|
|
26
|
+
readonly effort?: string;
|
|
27
|
+
}
|
|
28
|
+
export type ProviderOptionsInput = ProviderOptions & {
|
|
29
|
+
readonly anthropic?: OptionsInput;
|
|
30
|
+
};
|
|
8
31
|
export declare const AnthropicMessagesBody: Schema.Struct<{
|
|
9
32
|
model: Schema.String;
|
|
10
33
|
system: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
@@ -8,7 +8,6 @@ import { LLMError, LLMEvent, Usage, } from "../schema";
|
|
|
8
8
|
import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared";
|
|
9
9
|
import { classifyProviderFailure } from "../provider-error";
|
|
10
10
|
import * as Cache from "./utils/cache";
|
|
11
|
-
import { AnthropicOptions } from "./utils/anthropic-options";
|
|
12
11
|
import { Lifecycle } from "./utils/lifecycle";
|
|
13
12
|
import { ToolSchemaProjection } from "./utils/tool-schema";
|
|
14
13
|
import { ToolStream } from "./utils/tool-stream";
|
|
@@ -130,6 +129,19 @@ const AnthropicToolChoice = Schema.Union([
|
|
|
130
129
|
Schema.Struct({ type: Schema.Literals(["auto", "any", "none"]) }),
|
|
131
130
|
Schema.Struct({ type: Schema.tag("tool"), name: Schema.String }),
|
|
132
131
|
]);
|
|
132
|
+
const AnthropicThinking = Schema.Union([
|
|
133
|
+
Schema.Struct({
|
|
134
|
+
type: Schema.tag("enabled"),
|
|
135
|
+
budget_tokens: Schema.Number,
|
|
136
|
+
}),
|
|
137
|
+
Schema.Struct({
|
|
138
|
+
type: Schema.tag("adaptive"),
|
|
139
|
+
display: Schema.optional(Schema.Literals(["summarized", "omitted"])),
|
|
140
|
+
}),
|
|
141
|
+
Schema.Struct({
|
|
142
|
+
type: Schema.tag("disabled"),
|
|
143
|
+
}),
|
|
144
|
+
]);
|
|
133
145
|
const AnthropicOutputConfig = Schema.Struct({
|
|
134
146
|
effort: Schema.optional(Schema.String),
|
|
135
147
|
});
|
|
@@ -145,7 +157,7 @@ const AnthropicBodyFields = {
|
|
|
145
157
|
top_p: Schema.optional(Schema.Number),
|
|
146
158
|
top_k: Schema.optional(Schema.Number),
|
|
147
159
|
stop_sequences: optionalArray(Schema.String),
|
|
148
|
-
thinking: Schema.optional(
|
|
160
|
+
thinking: Schema.optional(AnthropicThinking),
|
|
149
161
|
output_config: Schema.optional(AnthropicOutputConfig),
|
|
150
162
|
};
|
|
151
163
|
export const AnthropicMessagesBody = Schema.Struct(AnthropicBodyFields);
|
|
@@ -433,6 +445,37 @@ const lowerMessages = Effect.fn("AnthropicMessages.lowerMessages")(function* (re
|
|
|
433
445
|
}
|
|
434
446
|
return messages;
|
|
435
447
|
});
|
|
448
|
+
const resolveOptions = Effect.fn("AnthropicMessages.resolveOptions")(function* (request) {
|
|
449
|
+
const input = request.providerOptions?.anthropic;
|
|
450
|
+
return {
|
|
451
|
+
thinking: yield* resolveThinking(input?.thinking),
|
|
452
|
+
effort: typeof input?.effort === "string" ? input.effort : undefined,
|
|
453
|
+
};
|
|
454
|
+
});
|
|
455
|
+
const resolveThinking = Effect.fn("AnthropicMessages.resolveThinking")(function* (input) {
|
|
456
|
+
if (!ProviderShared.isRecord(input))
|
|
457
|
+
return undefined;
|
|
458
|
+
if (input.type === "adaptive") {
|
|
459
|
+
const display = input.display === "summarized"
|
|
460
|
+
? "summarized"
|
|
461
|
+
: input.display === "omitted"
|
|
462
|
+
? "omitted"
|
|
463
|
+
: undefined;
|
|
464
|
+
return { type: "adaptive", ...(display === undefined ? {} : { display }) };
|
|
465
|
+
}
|
|
466
|
+
if (input.type === "disabled")
|
|
467
|
+
return { type: "disabled" };
|
|
468
|
+
if (input.type !== "enabled")
|
|
469
|
+
return undefined;
|
|
470
|
+
const budget = typeof input.budgetTokens === "number"
|
|
471
|
+
? input.budgetTokens
|
|
472
|
+
: typeof input.budget_tokens === "number"
|
|
473
|
+
? input.budget_tokens
|
|
474
|
+
: undefined;
|
|
475
|
+
if (budget === undefined)
|
|
476
|
+
return yield* ProviderShared.invalidRequest("Anthropic thinking provider option requires budgetTokens");
|
|
477
|
+
return { type: "enabled", budget_tokens: budget };
|
|
478
|
+
});
|
|
436
479
|
const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (request) {
|
|
437
480
|
const generation = request.generation;
|
|
438
481
|
const toolSchemaCompatibility = request.model.compatibility?.toolSchema;
|
|
@@ -457,7 +500,7 @@ const fromRequest = Effect.fn("AnthropicMessages.fromRequest")(function* (reques
|
|
|
457
500
|
if (breakpoints.dropped > 0) {
|
|
458
501
|
yield* Effect.logWarning(`Anthropic Messages: dropped ${breakpoints.dropped} cache breakpoint(s); the API allows at most ${ANTHROPIC_BREAKPOINT_CAP} per request.`);
|
|
459
502
|
}
|
|
460
|
-
const options = yield*
|
|
503
|
+
const options = yield* resolveOptions(request);
|
|
461
504
|
return {
|
|
462
505
|
model: request.model.id,
|
|
463
506
|
system,
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { Route } from "../route/client";
|
|
3
3
|
import { Protocol } from "../route/protocol";
|
|
4
|
+
import { type ProviderOptions } from "../schema";
|
|
4
5
|
import { Lifecycle } from "./utils/lifecycle";
|
|
5
6
|
export declare const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
7
|
+
export interface OptionsInput {
|
|
8
|
+
readonly [key: string]: unknown;
|
|
9
|
+
readonly thinkingConfig?: {
|
|
10
|
+
readonly thinkingBudget?: number;
|
|
11
|
+
readonly includeThoughts?: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export type ProviderOptionsInput = ProviderOptions & {
|
|
15
|
+
readonly gemini?: OptionsInput;
|
|
16
|
+
};
|
|
6
17
|
declare const GeminiBody: Schema.Struct<{
|
|
7
18
|
contents: Schema.$Array<Schema.Struct<{
|
|
8
19
|
readonly role: Schema.Literals<readonly ["user", "model"]>;
|
package/dist/protocols/gemini.js
CHANGED
|
@@ -6,7 +6,6 @@ import { Framing } from "../route/framing";
|
|
|
6
6
|
import { Protocol } from "../route/protocol";
|
|
7
7
|
import { LLMEvent, Usage, } from "../schema";
|
|
8
8
|
import { JsonObject, optionalArray, ProviderShared } from "./shared";
|
|
9
|
-
import { GeminiOptions } from "./utils/gemini-options";
|
|
10
9
|
import { GeminiToolSchema } from "./utils/gemini-tool-schema";
|
|
11
10
|
import { Lifecycle } from "./utils/lifecycle";
|
|
12
11
|
import { ToolSchemaProjection } from "./utils/tool-schema";
|
|
@@ -70,13 +69,17 @@ const GeminiToolConfig = Schema.Struct({
|
|
|
70
69
|
allowedFunctionNames: optionalArray(Schema.String),
|
|
71
70
|
}),
|
|
72
71
|
});
|
|
72
|
+
const GeminiThinkingConfig = Schema.Struct({
|
|
73
|
+
thinkingBudget: Schema.optional(Schema.Number),
|
|
74
|
+
includeThoughts: Schema.optional(Schema.Boolean),
|
|
75
|
+
});
|
|
73
76
|
const GeminiGenerationConfig = Schema.Struct({
|
|
74
77
|
maxOutputTokens: Schema.optional(Schema.Number),
|
|
75
78
|
temperature: Schema.optional(Schema.Number),
|
|
76
79
|
topP: Schema.optional(Schema.Number),
|
|
77
80
|
topK: Schema.optional(Schema.Number),
|
|
78
81
|
stopSequences: optionalArray(Schema.String),
|
|
79
|
-
thinkingConfig: Schema.optional(
|
|
82
|
+
thinkingConfig: Schema.optional(GeminiThinkingConfig),
|
|
80
83
|
});
|
|
81
84
|
const GeminiBodyFields = {
|
|
82
85
|
contents: Schema.Array(GeminiContent),
|
|
@@ -243,10 +246,22 @@ const lowerMessages = Effect.fn("Gemini.lowerMessages")(function* (request) {
|
|
|
243
246
|
}
|
|
244
247
|
return contents;
|
|
245
248
|
});
|
|
249
|
+
const resolveOptions = (request) => {
|
|
250
|
+
const value = request.providerOptions?.gemini?.thinkingConfig;
|
|
251
|
+
if (!ProviderShared.isRecord(value))
|
|
252
|
+
return {};
|
|
253
|
+
const thinkingConfig = {
|
|
254
|
+
thinkingBudget: typeof value.thinkingBudget === "number" ? value.thinkingBudget : undefined,
|
|
255
|
+
includeThoughts: typeof value.includeThoughts === "boolean" ? value.includeThoughts : undefined,
|
|
256
|
+
};
|
|
257
|
+
return {
|
|
258
|
+
thinkingConfig: Object.values(thinkingConfig).some((item) => item !== undefined) ? thinkingConfig : undefined,
|
|
259
|
+
};
|
|
260
|
+
};
|
|
246
261
|
const fromRequest = Effect.fn("Gemini.fromRequest")(function* (request) {
|
|
247
262
|
const hasTools = request.tools.length > 0;
|
|
248
263
|
const generation = request.generation;
|
|
249
|
-
const options =
|
|
264
|
+
const options = resolveOptions(request);
|
|
250
265
|
const toolSchemaCompatibility = request.model.compatibility?.toolSchema;
|
|
251
266
|
const generationConfig = {
|
|
252
267
|
maxOutputTokens: generation?.maxTokens,
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package";
|
|
2
|
+
import { AnthropicMessages } from "../protocols/anthropic-messages";
|
|
2
3
|
import type { ProviderAuthOption } from "../route/auth-options";
|
|
3
4
|
import type { RouteDefaultsInput } from "../route/client";
|
|
4
5
|
import { type ModelID } from "../schema";
|
|
5
|
-
|
|
6
|
-
export type
|
|
6
|
+
export type AnthropicOptionsInput = AnthropicMessages.OptionsInput;
|
|
7
|
+
export type AnthropicProviderOptionsInput = AnthropicMessages.ProviderOptionsInput;
|
|
8
|
+
export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput;
|
|
7
9
|
export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
8
10
|
export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
9
11
|
readonly provider?: string;
|
|
10
12
|
readonly baseURL: string;
|
|
11
|
-
readonly providerOptions?:
|
|
13
|
+
readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
|
|
12
14
|
};
|
|
13
15
|
export type Settings = ProviderPackage.Settings & ({
|
|
14
16
|
readonly apiKey?: string;
|
|
@@ -19,7 +21,7 @@ export type Settings = ProviderPackage.Settings & ({
|
|
|
19
21
|
}) & {
|
|
20
22
|
readonly baseURL: string;
|
|
21
23
|
readonly provider?: string;
|
|
22
|
-
readonly providerOptions?:
|
|
24
|
+
readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
|
|
23
25
|
};
|
|
24
26
|
export declare const routes: import("../route").Route<{
|
|
25
27
|
readonly messages: readonly (import("effect/Schema").Struct.ReadonlySide<{
|
|
@@ -2,8 +2,10 @@ import type { RouteDefaultsInput } from "../route/client";
|
|
|
2
2
|
import type { ProviderAuthOption } from "../route/auth-options";
|
|
3
3
|
import type { ProviderPackage } from "../provider-package";
|
|
4
4
|
import { type ModelID } from "../schema";
|
|
5
|
-
import
|
|
6
|
-
export type
|
|
5
|
+
import { AnthropicMessages } from "../protocols/anthropic-messages";
|
|
6
|
+
export type AnthropicOptionsInput = AnthropicMessages.OptionsInput;
|
|
7
|
+
export type AnthropicProviderOptionsInput = AnthropicMessages.ProviderOptionsInput;
|
|
8
|
+
export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput;
|
|
7
9
|
export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
8
10
|
export declare const routes: import("../route").Route<{
|
|
9
11
|
readonly messages: readonly (import("effect/Schema").Struct.ReadonlySide<{
|
|
@@ -185,7 +187,7 @@ export declare const routes: import("../route").Route<{
|
|
|
185
187
|
}, import("../route/transport/http").HttpPrepared<string>>[];
|
|
186
188
|
export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
187
189
|
readonly baseURL?: string;
|
|
188
|
-
readonly providerOptions?:
|
|
190
|
+
readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
|
|
189
191
|
};
|
|
190
192
|
export type Settings = ProviderPackage.Settings & ({
|
|
191
193
|
readonly apiKey?: string;
|
|
@@ -195,7 +197,7 @@ export type Settings = ProviderPackage.Settings & ({
|
|
|
195
197
|
readonly authToken?: string;
|
|
196
198
|
}) & {
|
|
197
199
|
readonly baseURL?: string;
|
|
198
|
-
readonly providerOptions?:
|
|
200
|
+
readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
|
|
199
201
|
};
|
|
200
202
|
export declare const configure: (input?: Config) => {
|
|
201
203
|
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import type { ProviderPackage } from "../provider-package";
|
|
3
|
+
import { AnthropicMessages } from "../protocols/anthropic-messages";
|
|
3
4
|
import { Route, type RouteDefaultsInput } from "../route/client";
|
|
4
5
|
import { type ModelID } from "../schema";
|
|
5
|
-
import type { AnthropicProviderOptionsInput } from "./anthropic-options";
|
|
6
6
|
import { GoogleVertexShared } from "./google-vertex-shared";
|
|
7
|
-
export type
|
|
7
|
+
export type AnthropicOptionsInput = AnthropicMessages.OptionsInput;
|
|
8
|
+
export type AnthropicProviderOptionsInput = AnthropicMessages.ProviderOptionsInput;
|
|
9
|
+
export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput;
|
|
8
10
|
export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
9
11
|
export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & {
|
|
10
12
|
readonly baseURL?: string;
|
|
11
13
|
readonly location?: string;
|
|
12
14
|
readonly project?: string;
|
|
13
|
-
readonly providerOptions?:
|
|
15
|
+
readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
|
|
14
16
|
};
|
|
15
17
|
export interface Settings extends ProviderPackage.Settings {
|
|
16
18
|
readonly accessToken?: string;
|
|
@@ -18,7 +20,7 @@ export interface Settings extends ProviderPackage.Settings {
|
|
|
18
20
|
readonly baseURL?: string;
|
|
19
21
|
readonly location?: string;
|
|
20
22
|
readonly project?: string;
|
|
21
|
-
readonly providerOptions?:
|
|
23
|
+
readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
|
|
22
24
|
}
|
|
23
25
|
export declare const routes: Route<{
|
|
24
26
|
anthropic_version: "vertex-2023-10-16";
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package";
|
|
2
|
+
import { Gemini } from "../protocols/gemini";
|
|
2
3
|
import { Route, type RouteDefaultsInput } from "../route/client";
|
|
3
4
|
import { type ModelID } from "../schema";
|
|
4
|
-
import type { GeminiProviderOptionsInput } from "./gemini-options";
|
|
5
5
|
import { GoogleVertexShared } from "./google-vertex-shared";
|
|
6
|
-
export type
|
|
6
|
+
export type GeminiOptionsInput = Gemini.OptionsInput;
|
|
7
|
+
export type GeminiProviderOptionsInput = Gemini.ProviderOptionsInput;
|
|
7
8
|
export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
8
9
|
export type Config = RouteDefaultsInput & GoogleVertexShared.ApiKeyOptions & {
|
|
9
10
|
readonly baseURL?: string;
|
|
10
11
|
readonly location?: string;
|
|
11
12
|
readonly project?: string;
|
|
12
|
-
readonly providerOptions?:
|
|
13
|
+
readonly providerOptions?: Gemini.ProviderOptionsInput;
|
|
13
14
|
};
|
|
14
15
|
export type Settings = ProviderPackage.Settings & ({
|
|
15
16
|
readonly accessToken?: string;
|
|
@@ -21,7 +22,7 @@ export type Settings = ProviderPackage.Settings & ({
|
|
|
21
22
|
readonly baseURL?: string;
|
|
22
23
|
readonly location?: string;
|
|
23
24
|
readonly project?: string;
|
|
24
|
-
readonly providerOptions?:
|
|
25
|
+
readonly providerOptions?: Gemini.ProviderOptionsInput;
|
|
25
26
|
};
|
|
26
27
|
export declare const routes: Route<{
|
|
27
28
|
readonly contents: readonly import("effect/Schema").Struct.ReadonlySide<{
|
|
@@ -2,9 +2,10 @@ import type { RouteDefaultsInput } from "../route/client";
|
|
|
2
2
|
import type { ProviderAuthOption } from "../route/auth-options";
|
|
3
3
|
import type { ProviderPackage } from "../provider-package";
|
|
4
4
|
import { type ModelID } from "../schema";
|
|
5
|
-
import
|
|
5
|
+
import { Gemini } from "../protocols/gemini";
|
|
6
6
|
export type { GoogleImageOptions } from "../protocols/google-images";
|
|
7
|
-
export type
|
|
7
|
+
export type GeminiOptionsInput = Gemini.OptionsInput;
|
|
8
|
+
export type GeminiProviderOptionsInput = Gemini.ProviderOptionsInput;
|
|
8
9
|
export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
9
10
|
export declare const routes: import("../route").Route<{
|
|
10
11
|
readonly contents: readonly import("effect/Schema").Struct.ReadonlySide<{
|
|
@@ -71,12 +72,12 @@ export declare const routes: import("../route").Route<{
|
|
|
71
72
|
}, import("../route/transport/http").HttpPrepared<string>>[];
|
|
72
73
|
export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
73
74
|
readonly baseURL?: string;
|
|
74
|
-
readonly providerOptions?:
|
|
75
|
+
readonly providerOptions?: Gemini.ProviderOptionsInput;
|
|
75
76
|
};
|
|
76
77
|
export interface Settings extends ProviderPackage.Settings {
|
|
77
78
|
readonly apiKey?: string;
|
|
78
79
|
readonly baseURL?: string;
|
|
79
|
-
readonly providerOptions?:
|
|
80
|
+
readonly providerOptions?: Gemini.ProviderOptionsInput;
|
|
80
81
|
}
|
|
81
82
|
export declare const configure: (input?: Config) => {
|
|
82
83
|
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
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-16150",
|
|
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-16150",
|
|
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-16150",
|
|
39
39
|
"aws4fetch": "1.0.20",
|
|
40
40
|
"effect": "4.0.0-beta.98",
|
|
41
41
|
"google-auth-library": "10.5.0"
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
2
|
-
import type { LLMRequest } from "../../schema";
|
|
3
|
-
export declare const ThinkingSchema: Schema.Union<readonly [Schema.Struct<{
|
|
4
|
-
readonly type: Schema.tag<"enabled">;
|
|
5
|
-
readonly budget_tokens: Schema.Number;
|
|
6
|
-
}>, Schema.Struct<{
|
|
7
|
-
readonly type: Schema.tag<"adaptive">;
|
|
8
|
-
readonly display: Schema.optional<Schema.Literals<readonly ["summarized", "omitted"]>>;
|
|
9
|
-
}>, Schema.Struct<{
|
|
10
|
-
readonly type: Schema.tag<"disabled">;
|
|
11
|
-
}>]>;
|
|
12
|
-
export type Thinking = Schema.Schema.Type<typeof ThinkingSchema>;
|
|
13
|
-
export interface Resolved {
|
|
14
|
-
readonly thinking?: Thinking;
|
|
15
|
-
readonly effort?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare const resolve: (request: LLMRequest) => Effect.Effect<{
|
|
18
|
-
thinking: {
|
|
19
|
-
display?: "summarized" | "omitted" | undefined;
|
|
20
|
-
type: "adaptive";
|
|
21
|
-
budget_tokens?: undefined;
|
|
22
|
-
} | {
|
|
23
|
-
type: "disabled";
|
|
24
|
-
budget_tokens?: undefined;
|
|
25
|
-
} | {
|
|
26
|
-
type: "enabled";
|
|
27
|
-
budget_tokens: number;
|
|
28
|
-
} | undefined;
|
|
29
|
-
effort: string | undefined;
|
|
30
|
-
}, import("../..").LLMError, never>;
|
|
31
|
-
export * as AnthropicOptions from "./anthropic-options";
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
2
|
-
import { ProviderShared } from "../shared";
|
|
3
|
-
export const ThinkingSchema = Schema.Union([
|
|
4
|
-
Schema.Struct({
|
|
5
|
-
type: Schema.tag("enabled"),
|
|
6
|
-
budget_tokens: Schema.Number,
|
|
7
|
-
}),
|
|
8
|
-
Schema.Struct({
|
|
9
|
-
type: Schema.tag("adaptive"),
|
|
10
|
-
display: Schema.optional(Schema.Literals(["summarized", "omitted"])),
|
|
11
|
-
}),
|
|
12
|
-
Schema.Struct({
|
|
13
|
-
type: Schema.tag("disabled"),
|
|
14
|
-
}),
|
|
15
|
-
]);
|
|
16
|
-
export const resolve = Effect.fn("AnthropicOptions.resolve")(function* (request) {
|
|
17
|
-
const input = request.providerOptions?.anthropic;
|
|
18
|
-
return {
|
|
19
|
-
thinking: yield* resolveThinking(input?.thinking),
|
|
20
|
-
effort: typeof input?.effort === "string" ? input.effort : undefined,
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
const resolveThinking = Effect.fn("AnthropicOptions.resolveThinking")(function* (input) {
|
|
24
|
-
if (!ProviderShared.isRecord(input))
|
|
25
|
-
return undefined;
|
|
26
|
-
if (input.type === "adaptive") {
|
|
27
|
-
const display = input.display === "summarized"
|
|
28
|
-
? "summarized"
|
|
29
|
-
: input.display === "omitted"
|
|
30
|
-
? "omitted"
|
|
31
|
-
: undefined;
|
|
32
|
-
return { type: "adaptive", ...(display === undefined ? {} : { display }) };
|
|
33
|
-
}
|
|
34
|
-
if (input.type === "disabled")
|
|
35
|
-
return { type: "disabled" };
|
|
36
|
-
if (input.type !== "enabled")
|
|
37
|
-
return undefined;
|
|
38
|
-
const budget = typeof input.budgetTokens === "number"
|
|
39
|
-
? input.budgetTokens
|
|
40
|
-
: typeof input.budget_tokens === "number"
|
|
41
|
-
? input.budget_tokens
|
|
42
|
-
: undefined;
|
|
43
|
-
if (budget === undefined)
|
|
44
|
-
return yield* ProviderShared.invalidRequest("Anthropic thinking provider option requires budgetTokens");
|
|
45
|
-
return { type: "enabled", budget_tokens: budget };
|
|
46
|
-
});
|
|
47
|
-
export * as AnthropicOptions from "./anthropic-options";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import type { LLMRequest } from "../../schema";
|
|
3
|
-
export declare const ThinkingConfigSchema: Schema.Struct<{
|
|
4
|
-
readonly thinkingBudget: Schema.optional<Schema.Number>;
|
|
5
|
-
readonly includeThoughts: Schema.optional<Schema.Boolean>;
|
|
6
|
-
}>;
|
|
7
|
-
export type ThinkingConfig = Schema.Schema.Type<typeof ThinkingConfigSchema>;
|
|
8
|
-
export interface Resolved {
|
|
9
|
-
readonly thinkingConfig?: ThinkingConfig;
|
|
10
|
-
}
|
|
11
|
-
export declare const resolve: (request: LLMRequest) => Resolved;
|
|
12
|
-
export * as GeminiOptions from "./gemini-options";
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import { ProviderShared } from "../shared";
|
|
3
|
-
export const ThinkingConfigSchema = Schema.Struct({
|
|
4
|
-
thinkingBudget: Schema.optional(Schema.Number),
|
|
5
|
-
includeThoughts: Schema.optional(Schema.Boolean),
|
|
6
|
-
});
|
|
7
|
-
export const resolve = (request) => {
|
|
8
|
-
const value = request.providerOptions?.gemini?.thinkingConfig;
|
|
9
|
-
if (!ProviderShared.isRecord(value))
|
|
10
|
-
return {};
|
|
11
|
-
const thinkingConfig = {
|
|
12
|
-
thinkingBudget: typeof value.thinkingBudget === "number" ? value.thinkingBudget : undefined,
|
|
13
|
-
includeThoughts: typeof value.includeThoughts === "boolean" ? value.includeThoughts : undefined,
|
|
14
|
-
};
|
|
15
|
-
return {
|
|
16
|
-
thinkingConfig: Object.values(thinkingConfig).some((item) => item !== undefined) ? thinkingConfig : undefined,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export * as GeminiOptions from "./gemini-options";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ProviderOptions } from "../schema";
|
|
2
|
-
export type AnthropicThinkingInput = {
|
|
3
|
-
readonly type: "adaptive";
|
|
4
|
-
readonly display?: "summarized" | "omitted";
|
|
5
|
-
} | {
|
|
6
|
-
readonly type: "disabled";
|
|
7
|
-
} | ({
|
|
8
|
-
readonly type: "enabled";
|
|
9
|
-
} & ({
|
|
10
|
-
readonly budgetTokens: number;
|
|
11
|
-
readonly budget_tokens?: number;
|
|
12
|
-
} | {
|
|
13
|
-
readonly budgetTokens?: number;
|
|
14
|
-
readonly budget_tokens: number;
|
|
15
|
-
}));
|
|
16
|
-
export interface AnthropicOptionsInput {
|
|
17
|
-
readonly [key: string]: unknown;
|
|
18
|
-
readonly thinking?: AnthropicThinkingInput;
|
|
19
|
-
readonly effort?: string;
|
|
20
|
-
}
|
|
21
|
-
export type AnthropicProviderOptionsInput = ProviderOptions & {
|
|
22
|
-
readonly anthropic?: AnthropicOptionsInput;
|
|
23
|
-
};
|
|
24
|
-
export * as AnthropicProviderOptions from "./anthropic-options";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as AnthropicProviderOptions from "./anthropic-options";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ThinkingConfig } from "../protocols/utils/gemini-options";
|
|
2
|
-
import type { ProviderOptions } from "../schema";
|
|
3
|
-
export interface GeminiOptionsInput {
|
|
4
|
-
readonly [key: string]: unknown;
|
|
5
|
-
readonly thinkingConfig?: ThinkingConfig;
|
|
6
|
-
}
|
|
7
|
-
export type GeminiProviderOptionsInput = ProviderOptions & {
|
|
8
|
-
readonly gemini?: GeminiOptionsInput;
|
|
9
|
-
};
|
|
10
|
-
export * as GeminiProviderOptions from "./gemini-options";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as GeminiProviderOptions from "./gemini-options";
|