opencode-cache-engine 0.3.3 → 0.3.4
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/package.json +1 -1
- package/test/cache-engine.test.mjs +49 -2
package/package.json
CHANGED
|
@@ -1035,10 +1035,15 @@ async function runMiMoHeaderHookProbe() {
|
|
|
1035
1035
|
sessionID,
|
|
1036
1036
|
agent: "build",
|
|
1037
1037
|
model,
|
|
1038
|
-
provider: { id: model.providerID },
|
|
1038
|
+
provider: { source: "config", info: { id: model.providerID }, options: {} },
|
|
1039
1039
|
message: { id: "msg", sessionID, role: "user", content: "probe" },
|
|
1040
1040
|
}, output)
|
|
1041
|
-
return {
|
|
1041
|
+
return {
|
|
1042
|
+
headers: output.headers,
|
|
1043
|
+
sameObject: output.headers === headersRef,
|
|
1044
|
+
outputKeys: Object.keys(output),
|
|
1045
|
+
modelHeaders: model.headers,
|
|
1046
|
+
}
|
|
1042
1047
|
}
|
|
1043
1048
|
const mimoOpenRouter = {
|
|
1044
1049
|
providerID: "openrouter",
|
|
@@ -1057,6 +1062,29 @@ async function runMiMoHeaderHookProbe() {
|
|
|
1057
1062
|
const glm2 = await invoke(glmOpenRouter, "ses_glm_same")
|
|
1058
1063
|
const glmDifferent = await invoke(glmOpenRouter, "ses_glm_other")
|
|
1059
1064
|
const glmDirect = await invoke({ ...glmOpenRouter, providerID: "zai" }, "ses_glm_direct", { "User-Agent": "preserve-glm" })
|
|
1065
|
+
const nonOpenRouterMatrix = [
|
|
1066
|
+
["mimo-direct", { ...mimoOpenRouter, providerID: "xiaomi" }],
|
|
1067
|
+
["glm-direct", { ...glmOpenRouter, providerID: "zai" }],
|
|
1068
|
+
["deepseek-direct", { providerID: "deepseek", id: "deepseek-v4.1-flash", api: { id: "deepseek-v4.1-flash" }, headers: {} }],
|
|
1069
|
+
["gpt-openai", { providerID: "openai", id: "gpt-5.6", api: { id: "gpt-5.6", npm: "@ai-sdk/openai" }, headers: {} }],
|
|
1070
|
+
["unknown-provider", { ...mimoOpenRouter, providerID: "unknown-provider" }],
|
|
1071
|
+
["missing-provider", { ...mimoOpenRouter, providerID: undefined }],
|
|
1072
|
+
["opencode-go-mimo", { ...mimoOpenRouter, providerID: "opencode" }],
|
|
1073
|
+
["opencode-go-glm", { ...glmOpenRouter, providerID: "opencode" }],
|
|
1074
|
+
]
|
|
1075
|
+
const compatibility = []
|
|
1076
|
+
for (const [name, model] of nonOpenRouterMatrix) {
|
|
1077
|
+
const existing = { "User-Agent": "preserve-" + name, "x-compat-test": name }
|
|
1078
|
+
compatibility.push({ name, ...(await invoke(model, "ses_" + name, existing)), expected: existing })
|
|
1079
|
+
}
|
|
1080
|
+
const gptOutput = { options: {} }
|
|
1081
|
+
await hooks["chat.params"]({
|
|
1082
|
+
sessionID: "ses_gpt_native_cache",
|
|
1083
|
+
agent: "build",
|
|
1084
|
+
model: { providerID: "openai", id: "gpt-5.6", api: { id: "gpt-5.6", npm: "@ai-sdk/openai" } },
|
|
1085
|
+
provider: { source: "config", info: { id: "openai" }, options: {} },
|
|
1086
|
+
message: { id: "msg-gpt", sessionID: "ses_gpt_native_cache", role: "user", content: "probe" },
|
|
1087
|
+
}, gptOutput)
|
|
1060
1088
|
const configured = await invoke({
|
|
1061
1089
|
...mimoOpenRouter,
|
|
1062
1090
|
headers: { "X-Session-Id": "user-configured-value" },
|
|
@@ -1073,6 +1101,8 @@ async function runMiMoHeaderHookProbe() {
|
|
|
1073
1101
|
glm2,
|
|
1074
1102
|
glmDifferent,
|
|
1075
1103
|
glmDirect,
|
|
1104
|
+
compatibility,
|
|
1105
|
+
gptOptions: gptOutput.options,
|
|
1076
1106
|
configured,
|
|
1077
1107
|
configuredModelHeaders: configured.modelHeaders,
|
|
1078
1108
|
earlierPlugin,
|
|
@@ -1139,3 +1169,20 @@ test("GLM direct Z.AI does not receive x-session-id", async () => {
|
|
|
1139
1169
|
assert.equal(result.glmDirect.headers["x-session-id"], undefined)
|
|
1140
1170
|
assert.deepEqual(result.glmDirect.headers, { "User-Agent": "preserve-glm" })
|
|
1141
1171
|
})
|
|
1172
|
+
|
|
1173
|
+
test("non-OpenRouter endpoint matrix is x-session-id non-mutating and preserves unrelated headers", async () => {
|
|
1174
|
+
const result = await miMoHeaderResults()
|
|
1175
|
+
assert.equal(result.compatibility.length, 8)
|
|
1176
|
+
for (const item of result.compatibility) {
|
|
1177
|
+
assert.equal(item.headers["x-session-id"], undefined, `${item.name} must not receive OpenRouter affinity`)
|
|
1178
|
+
assert.deepEqual(item.headers, item.expected, `${item.name} unrelated headers must remain unchanged`)
|
|
1179
|
+
assert.equal(item.sameObject, true, `${item.name} headers object must be preserved`)
|
|
1180
|
+
assert.deepEqual(item.outputKeys, ["headers"], `${item.name} hook output remains headers-only`)
|
|
1181
|
+
}
|
|
1182
|
+
})
|
|
1183
|
+
|
|
1184
|
+
test("OpenAI GPT retains its existing chat.params cache options without affinity headers", async () => {
|
|
1185
|
+
const result = await miMoHeaderResults()
|
|
1186
|
+
assert.equal(typeof result.gptOptions.promptCacheKey, "string")
|
|
1187
|
+
assert.deepEqual(result.gptOptions.promptCacheOptions, { mode: "implicit", ttl: "30m" })
|
|
1188
|
+
})
|