diff --git a/CHANGELOG.md b/CHANGELOG.md index 3706816b69..37ca28fc5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag ### Changes +- **dsh PTC sessions get compression back: a `run_code` omnibus on the wire reads as reachable, not unreachable (#3600).** dsh PTC presets collapse EVERY tool into a single `run_code` omnibus (the SDK bindings nest inside it), so the top-level tools array carries no `compress` entry. The #3427 reachability gate read exactly that shape as "tool not host-scoped → suppress the compress surface", and released 0.1.198 suppressed every dsh PTC session: 89× `ARMED-SUPPRESSED` nudges while the window ran to 100%, then the output got clamped and the session was effectively dead — silently, while standard-mode sessions on the same install kept compressing (v0.1.197 had no tools factor in its nudge gate, so this is a release regression, not "never worked"). The gate now treats a `run_code` omnibus declaration as reachable: top-level absence is not evidence of unreachability when the omnibus swallows everything. The #3177 true negative keeps its suppression (a bare single tool that is neither `compress` nor the omnibus still drops the surface), and the #3401 positive case is unchanged. + - **dsh desktop settings pane: the embed probe is admitted for the Electron scheme origin (#3513, desktop variant).** The dsh DESKTOP app renders its settings pane from the custom scheme origin `dsh-app://app` (not an http origin like dsh web). The #3514 fix echoed the requesting Origin — but the request never reached the echo: `isTrustedAdminOrigin` only accepts http/https origins, so the probe's `GET /__bili/?embed=1` died in the trust gate with a bare 403 and no `access-control-allow-origin` — the pane stayed on "正在连接 bili 代理…" forever (real-world console: "blocked by CORS policy … from origin 'dsh-app://app'"). The gate now admits exactly that one origin (scheme `dsh-app`, hostname `app`): browsers set the Origin header themselves and the `dsh-app` scheme only exists inside the dsh Electron app, so a website can never produce that Origin — while rebinding attacks still arrive with http/https attacker hostnames and stay rejected. Foreign hostnames under the same scheme (`dsh-app://evil`) and every other custom scheme stay 403; the existing #3514 echo then covers the response. - **dist is self-contained again: the zod leak from the jimp image-rescale lane is bundled away, with a build gate to keep it away (#3511 P0).** #3425 inlined jimp (pure-JS image encoder, devDependency), and jimp imports zod at module scope — leaking 16 STATIC `from"zod"` imports into `dist/index.js` and `dist/agent/pi-native.js`. Static imports resolve at module load with no degrade path, so installs that ship the package without its node_modules (dsh profile bare copies, thin plugin copies — the real dsh/pi plugin shapes) died with `ERR_MODULE_NOT_FOUND` and model traffic silently went direct, uncompressed. zod is now bundled like every other transitive of an inlined dependency (dist/index.js grows ~1.4 MB); the ONE sanctioned external consumer — the opencode V1 host interop, which wants the HOST's zod instance and already degrades when unresolvable — keeps its own runtime resolution through an opaque specifier. `npm run build` now fails on any static zod import surviving into dist (`scripts/check-dist-external-zod.mjs`). Verified: a bare `dist/` copy with zero node_modules runs `node dist/index.js --version` clean. - **dsh web settings panel: the embed pre-flight gets its CORS answer (#3513).** The #3100 pre-flight fetches `/__bili/?embed=1` CROSS-origin — the dsh web page lives on the host's port, the proxy on its own, and while both are loopback names (so the trusted-origin gate admits the request), a cors-mode fetch is only readable when the response carries `access-control-allow-origin`. It never did: the browser rejected the probe, the verdict never landed, and the pane stayed on "connecting to the bili proxy…" forever while the proxy itself (model traffic, iframe navigation) kept working. The embed-face GET now echoes the requesting Origin — a static HTML shell with no state, reachable only by origins the #115/#1537 gates already admitted; clients without an Origin header (curl, CLIs) see no header at all, and the DNS-rebinding gates are untouched. diff --git a/src/server/lane-decisions.ts b/src/server/lane-decisions.ts index c1f5f77710..6c921a0d7b 100644 --- a/src/server/lane-decisions.ts +++ b/src/server/lane-decisions.ts @@ -220,9 +220,14 @@ export function resolveLaneDecisions(input: LaneDecisionInput): LaneDecisions { // In PLUGIN mode the host owns the tool table: reach when this request // declares `compress` (observed — some dsh profiles DO surface it, #3401) // or the host exposes bili tools to the model by design (profile default, - // #3177). + // #3177). PTC presets collapse EVERY tool into a single `run_code` + // omnibus (SDK bindings nested inside it), so top-level absence of + // `compress` is not evidence of unreachability there — an omnibus + // declaration reads as reachable (#3600: released 0.1.198 suppressed the + // surface on every dsh PTC session until the window hit 100%). const compressReachable = !input.pluginMode || declaredTools.has("compress") + || declaredTools.has("run_code") || !profile.toolsHostScopedByDefault; const compressSurfaceOn = input.shouldInject && compressReachable; const billingBlockObserved = extractBillingAttributionBlock(systemOf(input.parsed)) !== undefined; diff --git a/tests/lane-decisions-matrix.test.ts b/tests/lane-decisions-matrix.test.ts index 33c531bfa8..1e6fcbf01c 100644 --- a/tests/lane-decisions-matrix.test.ts +++ b/tests/lane-decisions-matrix.test.ts @@ -225,6 +225,17 @@ const ROWS: { name: string; lane: Lane; tools: string[]; injectTool?: boolean; e // the wire still drops the surface today. The fix commit flips this row to // {nudge:true, standingPrompt:true} — until then this pins the bug. { name: "dsh compress-on-wire keeps the surface (fix #3401 via lane-decisions observation)", lane: "dsh", tools: ["compress", "get_weather"], expect: () => ({ nudge: true, standingPrompt: true }) }, + // #3600 FIX ROW: dsh PTC presets collapse every tool into a single + // `run_code` omnibus (SDK bindings nested inside it), so the top-level + // absence of `compress` is NOT evidence of unreachability. 0.1.198 read + // this shape as unreachable and suppressed the nudge all the way to the + // 100% window (89× ARMED-SUPPRESSED, output clamped) — the omnibus reads + // as reachable now. + { name: "dsh run_code omnibus keeps the surface (#3600 PTC shape)", lane: "dsh", tools: ["run_code"], expect: () => ({ nudge: true, standingPrompt: true }) }, + // Named-tool precision must survive the #3600 fix: a bare single tool + // that is NOT the omnibus and NOT compress stays a true negative + // (#3177 preset-standard shape keeps its suppression). + { name: "dsh single non-omnibus tool still drops the surface (precision retained)", lane: "dsh", tools: ["get_weather"], expect: () => ({ nudge: false, standingPrompt: false }) }, { name: "dsh acp_status-only drops the surface (named-tool precision target)", lane: "dsh", tools: ["acp_status"], expect: () => ({ nudge: false, standingPrompt: false }) }, // #3427 review: pin the disclosed anthropic-wire convergence — with // injectTool off the nudge must stay off on ALL wires (master allowed it