@opencode/ai 0.0.0-dev-20413 → 0.0.0-dev-20415
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/cache-policy.js
CHANGED
|
@@ -36,6 +36,7 @@ const resolve = (policy) => {
|
|
|
36
36
|
// prefix caching, Gemini's implicit + out-of-band CachedContent). Skip the
|
|
37
37
|
// whole policy pass for these — emitting hints would be harmless but pointless.
|
|
38
38
|
const RESPECTS_INLINE_HINTS = new Set([
|
|
39
|
+
"alibaba-chat",
|
|
39
40
|
"alibaba-messages",
|
|
40
41
|
"anthropic-messages",
|
|
41
42
|
"anthropic-compatible-messages",
|
|
@@ -52,13 +53,14 @@ const RESPECTS_INLINE_HINTS = new Set([
|
|
|
52
53
|
// OpenRouter upstreams other than Anthropic and Alibaba Qwen cache without breakpoints. Gemini uses only the last
|
|
53
54
|
// breakpoint, so a conversation-tail breakpoint writes a new cache every step and costs more than none. Qwen ignores
|
|
54
55
|
// breakpoints on tool definitions and caches tools with the system prompt.
|
|
56
|
+
const QWEN = { system: true, messages: { tail: 1 } };
|
|
55
57
|
const openRouterPolicy = (modelID) => {
|
|
56
58
|
// `~anthropic/claude-sonnet-latest` style IDs are OpenRouter aliases for the latest model in a family.
|
|
57
59
|
const id = modelID.replace(/^~/, "");
|
|
58
60
|
if (id.startsWith("anthropic/"))
|
|
59
61
|
return AUTO;
|
|
60
62
|
if (id.startsWith("qwen/"))
|
|
61
|
-
return
|
|
63
|
+
return QWEN;
|
|
62
64
|
return NONE;
|
|
63
65
|
};
|
|
64
66
|
const makeHint = (ttlSeconds) => ttlSeconds !== undefined ? new CacheHint({ type: "ephemeral", ttlSeconds }) : new CacheHint({ type: "ephemeral" });
|
|
@@ -143,7 +145,11 @@ export const applyCachePolicy = (request) => {
|
|
|
143
145
|
return request;
|
|
144
146
|
const policy = request.model.route.id === "openrouter" && (request.cache === undefined || request.cache === "auto")
|
|
145
147
|
? openRouterPolicy(request.model.id)
|
|
146
|
-
:
|
|
148
|
+
: request.model.route.id === "alibaba-chat" && (request.cache === undefined || request.cache === "auto")
|
|
149
|
+
? request.model.id.toLowerCase().startsWith("qwen")
|
|
150
|
+
? QWEN
|
|
151
|
+
: NONE
|
|
152
|
+
: resolve(request.cache);
|
|
147
153
|
if (!policy.tools && !policy.system && !policy.messages)
|
|
148
154
|
return request;
|
|
149
155
|
const hint = makeHint(policy.ttlSeconds);
|
|
@@ -2,6 +2,7 @@ import { Effect, Schema } from "effect";
|
|
|
2
2
|
import { Protocol } from "../route/protocol.js";
|
|
3
3
|
import { OpenAIChat } from "./openai-chat.js";
|
|
4
4
|
import { JsonObject, ProviderShared } from "./shared.js";
|
|
5
|
+
import { cacheControl } from "./utils/cache.js";
|
|
5
6
|
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
6
7
|
const Options = Schema.Struct({
|
|
7
8
|
reasoningEffort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
|
|
@@ -53,7 +54,7 @@ export const protocol = Protocol.make({
|
|
|
53
54
|
from: Effect.fn("AlibabaChat.fromRequest")(function* (req) {
|
|
54
55
|
const opts = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Options))(req.providerOptions ?? {});
|
|
55
56
|
return {
|
|
56
|
-
...(yield* OpenAIChat.
|
|
57
|
+
...(yield* OpenAIChat.fromRequest(req, { cacheControl: cacheControl() })),
|
|
57
58
|
enable_thinking: opts.enableThinking,
|
|
58
59
|
// Alibaba also rejects an explicit budget that is not below `max_completion_tokens`.
|
|
59
60
|
thinking_budget: opts.thinkingBudget === undefined
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20415",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
36
36
|
"@effect/platform-node": "4.0.0-rc.112",
|
|
37
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
37
|
+
"@opencode/http-recorder": "0.0.0-dev-20415",
|
|
38
38
|
"@tsconfig/bun": "1.0.9",
|
|
39
39
|
"@types/bun": "1.4.0",
|
|
40
40
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
45
45
|
"@smithy/eventstream-codec": "4.2.14",
|
|
46
46
|
"@smithy/util-utf8": "4.2.2",
|
|
47
|
-
"@opencode/schema": "0.0.0-dev-
|
|
47
|
+
"@opencode/schema": "0.0.0-dev-20415",
|
|
48
48
|
"aws4fetch": "1.0.20",
|
|
49
49
|
"effect": "4.0.0-rc.112",
|
|
50
50
|
"google-auth-library": "10.5.0"
|