Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ For each request, the proxy resolves the settings by longest-URL-prefix match (t
- **Type:** `string` (pack name, e.g. `"lean"`)
- **Default:** `default` *(unset is equivalent — identity surface, kernel defaults everywhere)*
- **Status:** ACTIVE
- **Description:** Select a named prompt pack — a curated surface preset covering tool descriptions, compress system-prompt sections, and nudge sections — resolved from the kernel's pack chain: **project** `./.billion-context/packs/<name>.json` → **user** `<configDir>/packs/<name>.json` → **builtin** (`default`, `lean`). Built-in `lean` swaps the four ACP tool descriptions for one-liners (no snippet/guideline chrome) while keeping the compression rules default. Unknown names fall back to the identity surface with a one-time warning. Same three-level merge as the other fields; pack-surface sections (tool/section overrides) apply directly, without the `acknowledgePromptsRisk` gate — that gate governs only inline `compress.prompts` rule-text overrides. Note a pack's `prompts` block is ignored by this proxy: rule-text overrides are possible only via inline `compress.prompts`. Requires `acp-kernel` >= 0.0.66.
- **Description:** Select a named prompt pack — a curated surface preset covering tool descriptions, compress system-prompt sections, and nudge sections — resolved from the kernel's pack chain: **project** `./.billion-context/packs/<name>.json` → **user** `<configDir>/packs/<name>.json` → **builtin** (`default`, `lean`). Built-in `lean` swaps the four ACP tool descriptions for one-liners (no snippet/guideline chrome) while keeping the compression rules default. Unknown names fall back to the identity surface with a one-time warning. Same three-level merge as the other fields; pack-surface sections (tool/section overrides) apply directly, without the `acknowledgePromptsRisk` gate — that gate governs only inline `compress.prompts` rule-text overrides. Note a pack's `prompts` block is ignored by this proxy: rule-text overrides are possible only via inline `compress.prompts`. Requires `acp-kernel` >= 0.0.66. **Mode behavior (#3243):** in proxy (wire) mode the pack surface follows the full global → provider → model cascade for BOTH the system prompt and the injected tool descriptions; in native plugin mode (pi/omp/dsh/opencode/MCP lanes) the registered tool descriptions follow the **top-level** `compress.promptPack` only — the plugin manifest is static and session-independent (hosts fetch it before any request arrives, with no model context), while each request's system prompt still honors provider/model-level packs. Set `promptPack` at the top level when you want tool descriptions to follow the pack across all models.

#### `reconcile`

Expand Down
2 changes: 1 addition & 1 deletion CONFIGURATION.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ ACP 原生 agent(当前为 `pi` 扩展)会在每个进程内向代理上报
- **类型:** `string`(包名,如 `"lean"`)
- **默认值:** `default`(未设置等同——恒等表面,全部使用内核默认值)
- **状态:** ACTIVE
- **说明:** 选择一个具名 prompt pack —— 一套策划好的表面预设,覆盖工具描述、压缩系统提示词段落、nudge 段落 —— 从内核的包解析链解析:**项目** `./.billion-context/packs/<name>.json` → **用户** `<configDir>/packs/<name>.json` → **内置**(`default`、`lean`)。内置 `lean` 把四个 ACP 工具描述换成单行版(无 snippet/guideline 包装),压缩规则保持默认。未知包名回退到恒等表面并记录一次警告。与其他字段一样三级级联合并;包的表面覆盖(工具/段落)直接生效,不经 `acknowledgePromptsRisk` 门控——该门控只管内联 `compress.prompts` 的规则文本覆盖。注意:包文件里的 `prompts` 块会被本代理忽略,规则文本只能经内联 `compress.prompts` 设置。需要 `acp-kernel` >= 0.0.66。
- **说明:** 选择一个具名 prompt pack —— 一套策划好的表面预设,覆盖工具描述、压缩系统提示词段落、nudge 段落 —— 从内核的包解析链解析:**项目** `./.billion-context/packs/<name>.json` → **用户** `<configDir>/packs/<name>.json` → **内置**(`default`、`lean`)。内置 `lean` 把四个 ACP 工具描述换成单行版(无 snippet/guideline 包装),压缩规则保持默认。未知包名回退到恒等表面并记录一次警告。与其他字段一样三级级联合并;包的表面覆盖(工具/段落)直接生效,不经 `acknowledgePromptsRisk` 门控——该门控只管内联 `compress.prompts` 的规则文本覆盖。注意:包文件里的 `prompts` 块会被本代理忽略,规则文本只能经内联 `compress.prompts` 设置。需要 `acp-kernel` >= 0.0.66。**模式行为(#3243):** 代理(wire)模式下,包表面同时作用于系统提示词与注入的工具描述,且遵循全局 → provider → model 的完整三级级联;原生插件模式(pi/omp/dsh/opencode/MCP 车道)中,注册的工具描述只跟随**顶层** `compress.promptPack` —— 插件清单是静态的、与会话无关(宿主在任何请求到达前就拉取它,拿不到 model 上下文),而每请求的系统提示词仍遵循 provider/model 层的包。若希望所有 model 的工具描述都跟随包,请在顶层设置 `promptPack`。

#### `reconcile`

Expand Down
16 changes: 11 additions & 5 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BLOCKED_REF, COMPRESS_TOOL_NAME, type CompressionCore, type Config, type CoreMessage, type NudgeDecision, type RetrievalExport, applyRetrieve, countMessageTokens, parseStoredPlaceholder, prune } from "acp-kernel";
import { BLOCKED_REF, COMPRESS_TOOL_NAME, type CompressionCore, type Config, type CoreMessage, type NudgeDecision, type RetrievalExport, type ToolPrompts, applyAcpToolOverrides, applyRetrieve, countMessageTokens, parseStoredPlaceholder, prune } from "acp-kernel";
import { publicSnapshotCapBytes } from "./knobs.js";
import { buildStatusPanel } from "acp-kernel/panel";
import { fileURLToPath } from "node:url";
Expand Down Expand Up @@ -803,7 +803,7 @@ export function handlePluginSessionName(payload: string, res: import("node:http"
// arbitration; see tool-ring.ts). Wire-mode injection serves the kernel
// constants directly, which never carried the param.

export function handlePluginManifest(res: import("node:http").ServerResponse, config: Config): void {
export function handlePluginManifest(res: import("node:http").ServerResponse, config: Config, toolPrompts?: ToolPrompts): void {
// #1192: hosts register whatever the manifest serves verbatim (pi/omp/dsh/
// opencode native plugins, MCP shims), so advertising an opt-in tool this
// proxy's config leaves disabled guarantees a rejected call the moment the
Expand All @@ -813,6 +813,12 @@ export function handlePluginManifest(res: import("node:http").ServerResponse, co
// enablement stays enforced at execution (isProxyToolFor / executeProxyTool).
// #1359: the advertised name is the base-config toolName, matching the
// plugin-lane gate (which adjudicates the same base block).
// #3243: toolPrompts is the pack surface's tool descriptions, resolved by the
// caller from the GLOBAL compress settings — the manifest has no route/model
// context (hosts fetch it before any request arrives), so provider/model-level
// promptPack still shapes each request's system prompt while registered tool
// descriptions follow the top-level pack only. Applied exactly like the wire
// injector (applyAcpToolOverrides on the ACP core arrays before extras merge).
const absorbOn = absorbEnabled(config);
const absorbName = config.absorb?.toolName ?? ABSORB_TOOL_NAME;
const absorbTools = absorbOn ? absorbToolsFor(absorbName) : undefined;
Expand All @@ -830,13 +836,13 @@ export function handlePluginManifest(res: import("node:http").ServerResponse, co
// rule as acp_retrieve above. CCR-off manifests serve the no-range variants so
// a registered agent never sees range fields execution would refuse.
const externalSummary = externalSummaryEnabled(config);
const acpAnthropic = withExternalSummaryTools(ccrOn ? BILI_ACP_TOOLS_ANTHROPIC : BILI_ACP_TOOLS_ANTHROPIC_NO_RANGE, externalSummary);
const acpOpenai = withExternalSummaryTools(ccrOn ? BILI_ACP_TOOLS_OPENAI : BILI_ACP_TOOLS_OPENAI_NO_RANGE, externalSummary);
const acpAnthropic = withExternalSummaryTools(applyAcpToolOverrides(ccrOn ? BILI_ACP_TOOLS_ANTHROPIC : BILI_ACP_TOOLS_ANTHROPIC_NO_RANGE, toolPrompts), externalSummary);
const acpOpenai = withExternalSummaryTools(applyAcpToolOverrides(ccrOn ? BILI_ACP_TOOLS_OPENAI : BILI_ACP_TOOLS_OPENAI_NO_RANGE, toolPrompts), externalSummary);
// Responses wire: plugin mode structurally disarms CCR there (#1271 —
// PLUGIN_CCR_WIRES excludes it), so range restore can never execute for a
// registered agent on that wire — always the no-range variant, mirroring
// how ccrTools above is never spread into the responses array.
const acpResponses = withExternalSummaryTools(BILI_ACP_TOOLS_RESPONSES_NO_RANGE, externalSummary);
const acpResponses = withExternalSummaryTools(applyAcpToolOverrides(BILI_ACP_TOOLS_RESPONSES_NO_RANGE, toolPrompts), externalSummary);
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify({
ok: true,
Expand Down
9 changes: 7 additions & 2 deletions src/server/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { APIG_RESIGN_SCHEME, KNOWN_SIGNATURE_SCHEMES, readPendingRefusals, unres
import { handleAcpCache, readKeySwitchStats, readModelSwitchStats, readProjSwitchStats, readPromptSwitchStats } from "../cache-ledger.js";
import type { ProxyOptions } from "../config.js";
import { loadNamedProviders, loadOptions, loadRoutes, resolveResignSettings } from "../config.js";
import { applyCompressSettings } from "../compress-settings.js";
import { applyCompressSettings, resolveCompressSurfaceDetailed } from "../compress-settings.js";
import { clearConflictEvents, summarizeConflicts } from "../conflict-watch.js";
import { cannotResolveTarget, getAdvisoryState } from "../advisory.js";
import { detectCostAdvisories } from "../plugin-advisory.js";
Expand Down Expand Up @@ -317,7 +317,12 @@ export async function handleAdminRoute(req: http.IncomingMessage, res: http.Serv
// (DEFAULT_CCR_CONFIG et al. inside applyCompressSettings); per-request/route overrides
// are still enforced at execution time, so the manifest stays conservative as #1192
// requires. Do not "simplify" this back to `config`.
return handlePluginManifest(res, applyCompressSettings(config, opts.modelContextLimit, opts.compress, { ...agentProviderRecipes(), ...opts.namedProviders ?? {} }));
// #3243: pass the pack surface's tool descriptions too — resolved from the SAME
// global settings (no route/model context exists at manifest time), so registered
// tool descriptions follow the top-level promptPack while per-request system prompts
// may still honor deeper provider/model levels.
const packSurface = resolveCompressSurfaceDetailed(opts.compress ?? {});
return handlePluginManifest(res, applyCompressSettings(config, opts.modelContextLimit, opts.compress, { ...agentProviderRecipes(), ...opts.namedProviders ?? {} }), packSurface.surface.toolPrompts);
}
if (req.method === "GET" && req.url?.split("?")[0] === "/__bili/plugin/snapshot") {
return await handlePluginSnapshot(new URL(req.url, "http://localhost").searchParams.get("conversationId") ?? "", res);
Expand Down
9 changes: 8 additions & 1 deletion tests/issue1452-socket-hardening.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,14 @@ test("retired stall guard: mid-stream silence survives any short window even wit
},
);
req.end(STREAM_BODY);
await new Promise((r) => setTimeout(r, 2000));
// Poll for the first byte instead of a fixed 2s sleep: on loaded CI
// runners the first byte can legitimately take longer (observed flake,
// windows shard 2026-10-15, rerun green); a real non-streaming bug
// still fails here at the 15s deadline.
const firstByteDeadline = Date.now() + 15_000;
while (seen.length === 0 && Date.now() < firstByteDeadline) {
await new Promise((r) => setTimeout(r, 50));
}
const soFar = seen.join("");
assert.ok(soFar.length > 0, "first chunk should have flowed through");
assert.ok(!soFar.includes("stream error"), `retired guard must not emit a truncation error: ${soFar.slice(0, 300)}`);
Expand Down
Loading
Loading