diff --git a/CHANGELOG.md b/CHANGELOG.md index adcbb45210..bbb6f57cf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag ### Fixes +- **Bump acp-kernel 0.0.74 → 0.0.77; `acp_cache` held off every wire surface until adoption (#800)**: the pin jumps three kernel releases — 0.0.75 (cache-reconciliation core: `acp_cache` tool + `buildCacheReport`; recommend tail-below-gate fix), 0.0.76 (Google/Gemini wire codec; recommend range integrity), 0.0.77 (nudge ranges ordered/merged by position instead of ref number — fixes #887). Kernel ≥0.0.75 ships a fifth proxy tool, `acp_cache`, but this proxy has no execution path for it: an intercepted call fell through `executeProxyTool` into the unknown-tool branch, which reports SUCCESS with `[Unknown proxy tool: acp_cache]` — a model calling it would get a plausible-looking result that did nothing. Until adoption lands (feature #800, owner decision pending), `src/compress-tool.ts` derives `PROXY_TOOL_NAMES` and the four `BILI_ACP_TOOLS_*` arrays from the kernel constants minus `UNADOPTED_KERNEL_TOOLS` (`{acp_cache}`) — the single choke point every serving surface consumes (Responses/OpenAI/Anthropic tool arrays, plugin manifest + allowed list, absorb gate, Responses-adapter classification), so the tool stays off the wire everywhere without touching call sites. `MUTATING_PROXY_TOOLS`/`READONLY_PROXY_TOOLS` stay raw re-exports (classification sets only; `acp_cache` is correctly classified readonly and no serving surface reads them). The #841 parity test (`tests/search-context-cross-session.test.ts`) extends the "no other tool may change" contract against the FILTERED kernel side only, so a future BILI-side leak of an unadopted tool still fails. - **A render tag wrapped around the model's whole turn no longer reaches the client as orphan markup (PR #872)**: a model imitating the render tag can write its entire turn — tool call included — where the opening's attributes are still open (recorded shape: `=0.0.75 ships acp_cache (prompt-cache reconciliation report) +// but this proxy has no execution path for it yet — executeProxyTool would answer +// a call with "[Unknown proxy tool: acp_cache]" reported as success. Keep it off +// every wire surface until adoption lands (kernel constants are shared and never +// mutated; the filtered copies below are the single choke point all injection consumes). +export const UNADOPTED_KERNEL_TOOLS: ReadonlySet = new Set([ACP_CACHE_TOOL_NAME]); +export const PROXY_TOOL_NAMES: ReadonlySet = new Set([...ACP_TOOL_NAMES].filter((n) => !UNADOPTED_KERNEL_TOOLS.has(n))); +export { ACP_MUTATING_TOOLS as MUTATING_PROXY_TOOLS, ACP_READONLY_TOOLS as READONLY_PROXY_TOOLS } from "acp-kernel"; // #841: host-side conversation_id extension of search_context. Kernel constants // are shared and never mutated; ALL wire-mode injection points must use these @@ -102,10 +112,10 @@ export const BILI_SEARCH_CONTEXT_TOOL_RESPONSES = { parameters: withConversationId(SEARCH_CONTEXT_TOOL_RESPONSES.parameters), }; -export const BILI_ACP_TOOLS_ANTHROPIC = ACP_TOOLS_ANTHROPIC.map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL : t)); -export const BILI_ACP_TOOLS_OPENAI = ACP_TOOLS_OPENAI.map((t) => (t.function.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_OPENAI : t)); -export const BILI_ACP_TOOLS_RESPONSES = ACP_TOOLS_RESPONSES.map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_RESPONSES : t)); -export const BILI_ACP_READONLY_TOOLS_RESPONSES = ACP_READONLY_TOOLS_RESPONSES.map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_RESPONSES : t)); +export const BILI_ACP_TOOLS_ANTHROPIC = ACP_TOOLS_ANTHROPIC.filter((t) => !UNADOPTED_KERNEL_TOOLS.has(t.name)).map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL : t)); +export const BILI_ACP_TOOLS_OPENAI = ACP_TOOLS_OPENAI.filter((t) => !UNADOPTED_KERNEL_TOOLS.has(t.function.name)).map((t) => (t.function.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_OPENAI : t)); +export const BILI_ACP_TOOLS_RESPONSES = ACP_TOOLS_RESPONSES.filter((t) => !UNADOPTED_KERNEL_TOOLS.has(t.name)).map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_RESPONSES : t)); +export const BILI_ACP_READONLY_TOOLS_RESPONSES = ACP_READONLY_TOOLS_RESPONSES.filter((t) => !UNADOPTED_KERNEL_TOOLS.has(t.name)).map((t) => (t.name === SEARCH_CONTEXT_TOOL_NAME ? BILI_SEARCH_CONTEXT_TOOL_RESPONSES : t)); // The kernel ships no Responses-format absorb const (the four ACP tools have // *_RESPONSES variants; absorb is host-registered opt-in). Synthesize it in diff --git a/src/plugin.ts b/src/plugin.ts index 08e647c48e..909e3e8a4c 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -5,7 +5,7 @@ import type { ServerResponse } from "node:http"; import fs from "node:fs"; import path from "node:path"; import { acquireInFlight, effectiveConfig, findSessionByCanonicalId, listSessions, markCompactionBoundary, markDirty, peekSession, releaseInFlight, withSessionLock, type Session } from "./session.js"; -import { ABSORB_TOOL, ABSORB_TOOL_NAME, ABSORB_TOOL_OPENAI, ABSORB_TOOL_RESPONSES, ACP_TOOLS_ANTHROPIC, ACP_TOOLS_OPENAI, ACP_TOOLS_RESPONSES, PROXY_TOOL_NAMES, SEARCH_CONTEXT_CONVERSATION_ID_PARAM, SEARCH_CONTEXT_TOOL_NAME } from "./compress-tool.js"; +import { ABSORB_TOOL, ABSORB_TOOL_NAME, ABSORB_TOOL_OPENAI, ABSORB_TOOL_RESPONSES, BILI_ACP_TOOLS_ANTHROPIC, BILI_ACP_TOOLS_OPENAI, BILI_ACP_TOOLS_RESPONSES, PROXY_TOOL_NAMES, SEARCH_CONTEXT_CONVERSATION_ID_PARAM, SEARCH_CONTEXT_TOOL_NAME } from "./compress-tool.js"; import { effectiveAbsorbConfig, isProxyToolFor } from "./absorb.js"; import { executeProxyTool } from "./loop/core.js"; import { normalizeSseLineEndings } from "./sse-util.js"; @@ -405,9 +405,9 @@ export function handlePluginManifest(res: import("node:http").ServerResponse): v // manifest has no request context to know which route will win. toolNames: [...PROXY_TOOL_NAMES, ABSORB_TOOL_NAME], tools: { - anthropic: withSearchContextConversationDescription([...ACP_TOOLS_ANTHROPIC, ABSORB_TOOL].map(withConversationIdParam)), - openai: withSearchContextConversationDescription([...ACP_TOOLS_OPENAI, ABSORB_TOOL_OPENAI].map(withConversationIdParam)), - responses: withSearchContextConversationDescription([...ACP_TOOLS_RESPONSES, ABSORB_TOOL_RESPONSES].map(withConversationIdParam)), + anthropic: withSearchContextConversationDescription([...BILI_ACP_TOOLS_ANTHROPIC, ABSORB_TOOL].map(withConversationIdParam)), + openai: withSearchContextConversationDescription([...BILI_ACP_TOOLS_OPENAI, ABSORB_TOOL_OPENAI].map(withConversationIdParam)), + responses: withSearchContextConversationDescription([...BILI_ACP_TOOLS_RESPONSES, ABSORB_TOOL_RESPONSES].map(withConversationIdParam)), }, headers: { agent: PLUGIN_AGENT_HEADER, conversation: PLUGIN_CONVERSATION_HEADER, contextWindow: PLUGIN_CONTEXT_WINDOW_HEADER }, toolEndpoint: "/__bili/plugin/tool", diff --git a/tests/search-context-cross-session.test.ts b/tests/search-context-cross-session.test.ts index c85fc19120..0ad9ef24fb 100644 --- a/tests/search-context-cross-session.test.ts +++ b/tests/search-context-cross-session.test.ts @@ -6,7 +6,7 @@ import { tmpdir } from "node:os"; import { createHash } from "node:crypto"; import { ACP_READONLY_TOOLS_RESPONSES, ACP_TOOLS_ANTHROPIC, ACP_TOOLS_OPENAI, ACP_TOOLS_RESPONSES, SEARCH_CONTEXT_TOOL_NAME, createCore, createInitialState, defaultConfig } from "acp-kernel"; import { anthropicToCore, type AnthropicRequestBody } from "acp-kernel/wire"; -import { BILI_ACP_READONLY_TOOLS_RESPONSES, BILI_ACP_TOOLS_ANTHROPIC, BILI_ACP_TOOLS_OPENAI, BILI_ACP_TOOLS_RESPONSES } from "../src/compress-tool.ts"; +import { BILI_ACP_READONLY_TOOLS_RESPONSES, BILI_ACP_TOOLS_ANTHROPIC, BILI_ACP_TOOLS_OPENAI, BILI_ACP_TOOLS_RESPONSES, UNADOPTED_KERNEL_TOOLS } from "../src/compress-tool.ts"; import { SessionStore, _setStoreForTest } from "../src/persist.ts"; import { _resetSessionsForTest, getSession, type Session } from "../src/session.ts"; import { executeSearchContext, executeSearchContextTarget } from "../src/decompress-shared.ts"; @@ -78,8 +78,16 @@ test("#841 schema: BILI arrays add optional conversation_id to search_context on const kernelProps = paramsOf(kernelEntry!).properties as Record; assert.equal(kernelProps.conversation_id, undefined, "kernel constant must not be mutated"); + // The kernel may ship tools the host has not adopted yet (acp_cache, #800); + // those are intentionally absent from the BILI arrays, so drop them from the + // kernel side only — a BILI-side leak of an unadopted tool must still fail. + const adoptedInKernel = (t: unknown): boolean => { + const e = t as FlatTool; + const name = shape === "openai" ? e.function?.name : e.name; + return !UNADOPTED_KERNEL_TOOLS.has(name as string); + }; const biliRest = bili.filter((t) => t !== entry); - const kernelRest = kernel.filter((t) => t !== kernelEntry); + const kernelRest = kernel.filter((t) => t !== kernelEntry && adoptedInKernel(t)); assert.deepEqual(biliRest, kernelRest, "no other tool may change"); } const ro = searchEntry(BILI_ACP_READONLY_TOOLS_RESPONSES, "flat")!;