@opencode-ai/ai 0.0.0-next-16997 → 0.0.0-next-16998
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 +4 -3
- package/dist/protocols/open-responses.js +1 -1
- package/dist/protocols/utils/open-responses-options.d.ts +0 -1
- package/dist/protocols/utils/open-responses-options.js +0 -1
- package/dist/providers/open-responses-options.d.ts +0 -1
- package/dist/providers/openai-options.js +0 -1
- package/dist/providers/openrouter.d.ts +0 -1
- package/dist/providers/openrouter.js +1 -1
- package/dist/schema/messages.d.ts +1 -0
- package/dist/schema/messages.js +3 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -368,11 +368,12 @@ Other provider exports listed above remain direct facades until they explicitly
|
|
|
368
368
|
|
|
369
369
|
## Provider options & HTTP overlays
|
|
370
370
|
|
|
371
|
-
|
|
371
|
+
Request options in order of stability:
|
|
372
372
|
|
|
373
373
|
1. **`generation`** — portable knobs (`maxTokens`, `temperature`, `topP`, `topK`, penalties, seed, stop).
|
|
374
|
-
2. **`
|
|
375
|
-
3. **`
|
|
374
|
+
2. **`promptCacheKey`** — stable cache affinity lowered by every protocol that supports it.
|
|
375
|
+
3. **`providerOptions: { <provider>: {...} }`** — typed-at-the-facade provider-specific knobs (OpenAI `store`, Anthropic `thinking`, Gemini `thinkingConfig`, OpenRouter routing).
|
|
376
|
+
4. **`http: { body, headers, query }`** — last-resort serializable overlays merged into the final HTTP request. Reach for this only when a stable typed path doesn't yet exist.
|
|
376
377
|
|
|
377
378
|
Route/provider defaults are overridden by request-level values for each axis.
|
|
378
379
|
|
|
@@ -392,7 +392,7 @@ const lowerOptions = (request) => {
|
|
|
392
392
|
return {
|
|
393
393
|
...(options.instructions ? { instructions: options.instructions } : {}),
|
|
394
394
|
...(options.store !== undefined ? { store: options.store } : {}),
|
|
395
|
-
...(
|
|
395
|
+
...(request.promptCacheKey ? { prompt_cache_key: request.promptCacheKey } : {}),
|
|
396
396
|
...(options.include ? { include: options.include } : {}),
|
|
397
397
|
...(options.reasoningEffort || options.reasoningSummary
|
|
398
398
|
? { reasoning: { effort: options.reasoningEffort, summary: options.reasoningSummary } }
|
|
@@ -11,7 +11,6 @@ export declare const ServiceTierSchema: Schema.Literals<readonly ["auto", "defau
|
|
|
11
11
|
export interface Resolved {
|
|
12
12
|
readonly instructions?: string;
|
|
13
13
|
readonly store?: boolean;
|
|
14
|
-
readonly promptCacheKey?: string;
|
|
15
14
|
readonly reasoningEffort?: string;
|
|
16
15
|
readonly reasoningSummary?: "auto" | "concise" | "detailed";
|
|
17
16
|
readonly include?: ReadonlyArray<ResponseIncludable>;
|
|
@@ -29,7 +29,6 @@ export const resolve = (request) => {
|
|
|
29
29
|
return {
|
|
30
30
|
instructions: typeof input?.instructions === "string" ? input.instructions : undefined,
|
|
31
31
|
store: typeof input?.store === "boolean" ? input.store : undefined,
|
|
32
|
-
promptCacheKey: typeof input?.promptCacheKey === "string" ? input.promptCacheKey : undefined,
|
|
33
32
|
reasoningEffort: typeof input?.reasoningEffort === "string" ? input.reasoningEffort : undefined,
|
|
34
33
|
reasoningSummary: reasoningSummary === "auto" || reasoningSummary === "concise" || reasoningSummary === "detailed"
|
|
35
34
|
? reasoningSummary
|
|
@@ -4,7 +4,6 @@ export interface OpenResponsesOptionsInput {
|
|
|
4
4
|
readonly [key: string]: unknown;
|
|
5
5
|
readonly instructions?: string;
|
|
6
6
|
readonly store?: boolean;
|
|
7
|
-
readonly promptCacheKey?: string;
|
|
8
7
|
readonly reasoningEffort?: ReasoningEffort;
|
|
9
8
|
readonly reasoningSummary?: "auto" | "concise" | "detailed";
|
|
10
9
|
readonly include?: ReadonlyArray<ResponseIncludable>;
|
|
@@ -3,7 +3,6 @@ const definedEntries = (input) => Object.entries(input).filter((entry) => entry[
|
|
|
3
3
|
const openAIProviderOptions = (options) => {
|
|
4
4
|
const openai = Object.fromEntries(definedEntries({
|
|
5
5
|
store: options?.store,
|
|
6
|
-
promptCacheKey: options?.promptCacheKey,
|
|
7
6
|
reasoningEffort: options?.reasoningEffort,
|
|
8
7
|
reasoningSummary: options?.reasoningSummary,
|
|
9
8
|
include: options?.include,
|
|
@@ -59,7 +59,6 @@ export interface OpenRouterOptions {
|
|
|
59
59
|
}>;
|
|
60
60
|
readonly models?: ReadonlyArray<string>;
|
|
61
61
|
readonly plugins?: ReadonlyArray<OpenRouterPlugin>;
|
|
62
|
-
readonly promptCacheKey?: string;
|
|
63
62
|
readonly provider?: OpenRouterProviderRouting;
|
|
64
63
|
readonly reasoning?: Readonly<{
|
|
65
64
|
enabled?: boolean;
|
|
@@ -43,6 +43,7 @@ export const protocol = Protocol.make({
|
|
|
43
43
|
...body,
|
|
44
44
|
messages,
|
|
45
45
|
...bodyOptions(request.providerOptions?.openrouter),
|
|
46
|
+
...(request.promptCacheKey ? { prompt_cache_key: request.promptCacheKey } : {}),
|
|
46
47
|
};
|
|
47
48
|
})),
|
|
48
49
|
},
|
|
@@ -79,7 +80,6 @@ const bodyOptions = (input) => {
|
|
|
79
80
|
...(isRecord(debug) ? { debug } : {}),
|
|
80
81
|
...(typeof user === "string" ? { user } : {}),
|
|
81
82
|
...(isRecord(reasoning) ? { reasoning } : {}),
|
|
82
|
-
...(typeof promptCacheKey === "string" ? { prompt_cache_key: promptCacheKey } : {}),
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
85
|
export const route = Route.make({
|
|
@@ -368,6 +368,7 @@ declare const LLMRequest_base: Schema.Class<LLMRequest, Schema.Struct<{
|
|
|
368
368
|
}>]>>;
|
|
369
369
|
readonly ttlSeconds: Schema.optional<Schema.Number>;
|
|
370
370
|
}>]>>;
|
|
371
|
+
readonly promptCacheKey: Schema.optional<Schema.String>;
|
|
371
372
|
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
372
373
|
}>, {}>;
|
|
373
374
|
export declare class LLMRequest extends LLMRequest_base {
|
package/dist/schema/messages.js
CHANGED
|
@@ -211,6 +211,8 @@ export class LLMRequest extends Schema.Class("LLM.Request")({
|
|
|
211
211
|
providerOptions: Schema.optional(ProviderOptions),
|
|
212
212
|
http: Schema.optional(HttpOptions),
|
|
213
213
|
cache: Schema.optional(CachePolicy),
|
|
214
|
+
// Stable cache affinity for protocols that support provider-managed prompt caching.
|
|
215
|
+
promptCacheKey: Schema.optional(Schema.String),
|
|
214
216
|
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
215
217
|
}) {
|
|
216
218
|
}
|
|
@@ -226,6 +228,7 @@ export class LLMRequest extends Schema.Class("LLM.Request")({
|
|
|
226
228
|
providerOptions: request.providerOptions,
|
|
227
229
|
http: request.http,
|
|
228
230
|
cache: request.cache,
|
|
231
|
+
promptCacheKey: request.promptCacheKey,
|
|
229
232
|
metadata: request.metadata,
|
|
230
233
|
});
|
|
231
234
|
LLMRequest.update = (request, patch) => {
|
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-16998",
|
|
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-16998",
|
|
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-16998",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-beta.101",
|
|
45
45
|
"google-auth-library": "10.5.0"
|