Skip to content
Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag
- **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 `<proxy>/__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.
- **Egress image downscale + `read_original_image` (#3400).** Redoes the image pre-compression removed in #3295 in simplified form — **behavior change**: since #3295 every image passed through byte-identical at original resolution; from this version on, large outbound images are sent SHRUNKEN by default. On every outbound request (after kernel folding, before protocol encoding, all protocols share one pass) an image whose longest edge exceeds 1600 px (`BILI_IMAGE_RESCALE_MAX_DIM`) or whose base64 body exceeds 100 KB is re-encoded fit-inside (never upscaled, original format kept) on an OUTBOUND COPY only — session storage keeps the original bytes byte-exact. A re-encode saving less than 20% of the bytes is discarded (keep-smaller), so small and low-benefit images pass through untouched; only PNG/JPEG/BMP are handled (pure-JS jimp encoder, zero native dependencies — sharp does not return). Each shrunken image carries a stable annotation beside it reporting current vs original size; lanes that register bili tools (proxy-injection lanes, plugin lanes via the plugin manifest) also get the tool named in the annotation — `read_original_image("mNNNNN")` returns the original bytes from local session storage — while tool-rejecting lanes (codex) get size-only notes and no tool. Tool results are structurally exempt from re-shrinking (zero-state loop guard against the #3266 guess-reject-resend disease). Output is deterministic (content-hash cached, one encode per unique image; same history → byte-identical outbound bodies) so upstream prefix caching is undisturbed. Observability: one log line per unique image (dims+bytes before/after) and one per original-image read (ref, sizes, session cumulative count+bytes) — no hard cap, the model was told the sizes. Knobs: `BILI_IMAGE_RESCALE` (`"0"`/`"false"` off; default on), `BILI_IMAGE_RESCALE_MAX_DIM` (default 1600, env-only), config-file key `imageRescale`. Legacy `compress.imageCompression.*` INERT warnings remain owned by #3344/#3355.
- **Settings-panel quick fields for outbound image downscale and absorb (#3546).** The web settings page's quick-fields section exposes two previously JSON-only switches: an outbound image downscale checkbox (`imageRescale`; checked = default-on = key omitted, unchecked writes `false`) with a hint pointing at `BILI_IMAGE_RESCALE_MAX_DIM`, and an instant tool-result absorption checkbox whose checked state writes `compress.absorb.enabled: true` (preserving any existing sub-fields) and whose unchecked state deletes the whole `absorb` block, with a hint noting the #3422 `mediaOnly` default (image-bearing results only). Sub-fields stay in the raw JSON editor; no new config keys.
- **Egress image downscale + `acp_read_original_image` (#3400).** Redoes the image pre-compression removed in #3295 in simplified form — **behavior change**: since #3295 every image passed through byte-identical at original resolution; from this version on, large outbound images are sent SHRUNKEN by default. On every outbound request (after kernel folding, before protocol encoding, all protocols share one pass) an image whose longest edge exceeds 1600 px (`BILI_IMAGE_RESCALE_MAX_DIM`) or whose base64 body exceeds 100 KB is re-encoded fit-inside (never upscaled, original format kept) on an OUTBOUND COPY only — session storage keeps the original bytes byte-exact. A re-encode saving less than 20% of the bytes is discarded (keep-smaller), so small and low-benefit images pass through untouched; only PNG/JPEG/BMP are handled (pure-JS jimp encoder, zero native dependencies — sharp does not return). Each shrunken image carries a stable annotation beside it reporting current vs original size; lanes that register bili tools (proxy-injection lanes, plugin lanes via the plugin manifest) also get the tool named in the annotation — `acp_read_original_image("mNNNNN")` returns the original bytes from local session storage — while tool-rejecting lanes (codex) get size-only notes and no tool. Tool results are structurally exempt from re-shrinking (zero-state loop guard against the #3266 guess-reject-resend disease). Output is deterministic (content-hash cached, one encode per unique image; same history → byte-identical outbound bodies) so upstream prefix caching is undisturbed. Observability: one log line per unique image (dims+bytes before/after) and one per original-image read (ref, sizes, session cumulative count+bytes) — no hard cap, the model was told the sizes. Knobs: `BILI_IMAGE_RESCALE` (`"0"`/`"false"` off; default on), `BILI_IMAGE_RESCALE_MAX_DIM` (default 1600, env-only), config-file key `imageRescale`. Legacy `compress.imageCompression.*` INERT warnings remain owned by #3344/#3355.
- **Lane-decisions 收尾:四处 B 类旁路迁入统一决策点 + nudgeOn 单点(#3482,承接 #3417)。** ①omp 身份戳通道(`stampPromptCacheKey` 的 `agent !== "omp"` 门)改为注册表属性 `stampsBodyPromptCacheKey`;OMP Cowork 直连传输的"是否可能"进注册表(`coworkTransportPossible`),逐请求真相仍由环境观察(`ompCoworkTransportBypassesFetch`)给出。②codex/claude-responses 的 instructions 指纹键控从散落头名比较收进 `WIRE_CLIENTS` 注册表(`instructionsFingerprintKeyed`;信号检测留在 session-id,决策表只在注册表)。③计费块(#2189)提取改由 `laneDecisions.billingBlockWanted` 门控:profile 声明(dsh)或 wire 观察到块任一成立即提取——证据优先,与 toolsReachable 同形状;零 wire 字节变更。④四份手抄 `willInjectNudge` 合取收敛为 `nudgeOn()` 九入参纯函数:responses 的两处有意差异(compaction-trigger 豁免、codex-intercept 健康窗)显式入参,openai/google 的冗余 `shouldInject` 合取被 `compressSurfaceOn` 吸收;1024 点布尔立方等价测试 + 四车道旧公式逐位对照钉死。结构守卫扩展:B 类站点禁裸 lane 名门控,`WIRE_CLIENTS` 注册表条目必须有 `matches()`。⑤HostProfile 注册表整体落在零导入叶子模块 `src/host-profiles.ts`(review 修正:首版让 agent 侧直接 import lane-decisions,preflight→kernel 整链被拖进 dist/agent/pi.js、omp.js,两个宿主扩展包体积翻倍;拆出后两者回到原尺寸,结构守卫钉死该模块必须无 import)。`wantsBillingBlock` 死属性落位为真实消费者(上述③)。dshLedgerFloorTokens 本无 lane 名查(issue 前提修正:#1729 守卫故意 identity-blind,#2193)——三处 ledger floor 调用点保持不动并在 PR 说明。
- **Lane decisions extracted to a single resolver (#3417, fixes #3401).** The four wire adapters each carried their own copy of the lane gates (`dshCompressSurfaceOff`, the dsh compact-rebase guard), and the copies drifted: a dsh profile that DOES declare `compress` on the wire still had the model-side compress surface dropped (#3401). New `src/server/lane-decisions.ts`: a `HostProfile` registry (the only place lane names are compared), per-request `WireObservation` (which bili tools this request actually declares), and `resolveLaneDecisions()` — the one gate the four prepares now consume. Observed reachability overrides the dsh host-scope default, so tool-carrying dsh profiles keep the nudge/standing prompt while bare dsh stays off (#3177 preserved). `biliToolsDeclaredOnWire` gained a named-tool variant (the nudge advertises `compress` specifically). Structural guard test pins that prepares carry no raw lane-name comparisons. The dsh native-compaction rebase gate on all four wires now reads the registry property `compactsClientSide`.
- **Config epoch: stale effectiveConfig stamps are refused (incident class tracked as ⑥ on #2960).** Every wire request stamps the session's resolved config snapshot (`metadata.effectiveConfig`) — but that snapshot was only refreshed on the NEXT wire request, so tool-path readers (plugin tool API, status panels, nudge re-anchor) executed settings the user had already deleted from the config file, and with several instances on one machine a session could carry a foreign instance's stamp for days (the October externalSummary incident: a user-disabled summary chain kept running). The snapshot is now stamped with `metadata.effectiveConfigEpoch` — a content hash of the config file at resolution time. Readers refuse the snapshot when the epoch no longer matches the live file and re-resolve the file tier (global `compress.*`, including `externalSummary`) onto the base config instead; provider/model cascade levels are re-stamped by the session's next wire request. Epochs are content-keyed (byte-identical files validate cross-instance), legacy snapshots without an epoch keep the old merge semantics, forks inherit the epoch key, and the golden drives pin the new metadata digest.
Expand Down
2 changes: 1 addition & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ Top-level keys that control how the proxy listens and behaves globally.
- **Type:** boolean
- **Default:** `true`
- **Status:** ACTIVE
- **Description:** Master switch for the egress image downscale pass (#3295 removed the old arrival-time pass; #3400 re-adds it in simplified form). On every outbound request, after kernel folding and before protocol encoding, images whose longest edge exceeds `BILI_IMAGE_RESCALE_MAX_DIM` (default 1600) OR whose base64 body exceeds 100 KB are re-encoded fit-inside (never upscaled, original format kept) on an OUTBOUND COPY only — session storage keeps the original bytes byte-exact. A re-encode that saves less than 20% of the bytes is discarded (keep-smaller), so small/low-benefit images pass through untouched. Only PNG/JPEG/BMP are handled (pure-JS encoder, zero native dependencies); other formats pass through. Each shrunken image gets a stable annotation beside it reporting current vs original size; on lanes that register bili tools (proxy-injection lanes and plugin lanes via the plugin manifest) it also names `read_original_image("<ref>")`, which returns the original bytes from local session storage — codex-style lanes that reject injected tools get the size-only annotation and no tool. Results of `read_original_image` are structurally exempt from re-shrinking (the loop guard against the #3266 guess-reject-resend disease). Output is deterministic: the same input bytes always produce the same shrunken bytes and the same annotation text, so repeated resends of one history stay byte-stable and upstream prefix caching is undisturbed. One log line per unique image (content-hash cached; cache hits stay silent). Precedence: `BILI_IMAGE_RESCALE` env var (`"0"`/`"false"` disables; live-read, no restart) > this key > default on.
- **Description:** Master switch for the egress image downscale pass (#3295 removed the old arrival-time pass; #3400 re-adds it in simplified form). On every outbound request, after kernel folding and before protocol encoding, images whose longest edge exceeds `BILI_IMAGE_RESCALE_MAX_DIM` (default 1600) OR whose base64 body exceeds 100 KB are re-encoded fit-inside (never upscaled, original format kept) on an OUTBOUND COPY only — session storage keeps the original bytes byte-exact. A re-encode that saves less than 20% of the bytes is discarded (keep-smaller), so small/low-benefit images pass through untouched. Only PNG/JPEG/BMP are handled (pure-JS encoder, zero native dependencies); other formats pass through. Each shrunken image gets a stable annotation beside it reporting current vs original size; on lanes that register bili tools (proxy-injection lanes and plugin lanes via the plugin manifest) it also names `acp_read_original_image("<ref>")`, which returns the original bytes from local session storage — codex-style lanes that reject injected tools get the size-only annotation and no tool. Results of `acp_read_original_image` are structurally exempt from re-shrinking (the loop guard against the #3266 guess-reject-resend disease). Output is deterministic: the same input bytes always produce the same shrunken bytes and the same annotation text, so repeated resends of one history stay byte-stable and upstream prefix caching is undisturbed. One log line per unique image (content-hash cached; cache hits stay silent). Precedence: `BILI_IMAGE_RESCALE` env var (`"0"`/`"false"` disables; live-read, no restart) > this key > default on.

### `resign`

Expand Down
2 changes: 1 addition & 1 deletion CONFIGURATION.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@
- **类型:** boolean
- **默认值:** `true`
- **状态:** ACTIVE
- **说明:** 出站图片降采样 pass 的总开关(#3295 删除了旧的入站时降采样;#3400 以简化形态重新引入)。每个出站请求在 kernel 折叠之后、协议编码之前,对最长边超过 `BILI_IMAGE_RESCALE_MAX_DIM`(默认 1600)**或** base64 体积超过 100 KB 的图片做 fit-inside 重编码(不放大、保留原格式),且只作用于**出站副本**——会话存储中的原始字节保持逐字节原样。重编码节省不足 20% 字节的结果直接丢弃(keep-smaller),小图与低收益图原样通过。仅处理 PNG/JPEG/BMP(纯 JS 编码器,零原生依赖);其他格式原样通过。每张被缩小的图片旁附一段稳定注释,报告当前与原图尺寸;在注册 bili 工具的车道(代理注入车道,以及经插件 manifest 注册的插件车道)中还会指明 `read_original_image("<ref>")`——它从本地会话存储取回原始字节;拒绝注入工具的车道(如 codex)只拿到报尺寸的注释、没有工具。`read_original_image` 的结果**结构性豁免**再次降采样(防 #3266「猜→拒→重发」循环复发的环锁)。输出确定性:同一输入字节永远产出同一缩小字节与同一注释文本,同一历史反复重发保持逐字节稳定,上游前缀缓存不受扰动。每张唯一图片记一条日志(内容 hash 缓存;缓存命中静默)。优先级:`BILI_IMAGE_RESCALE` 环境变量(`"0"`/`"false"` 关闭;实时读取,无需重启)> 本配置键 > 默认开启。
- **说明:** 出站图片降采样 pass 的总开关(#3295 删除了旧的入站时降采样;#3400 以简化形态重新引入)。每个出站请求在 kernel 折叠之后、协议编码之前,对最长边超过 `BILI_IMAGE_RESCALE_MAX_DIM`(默认 1600)**或** base64 体积超过 100 KB 的图片做 fit-inside 重编码(不放大、保留原格式),且只作用于**出站副本**——会话存储中的原始字节保持逐字节原样。重编码节省不足 20% 字节的结果直接丢弃(keep-smaller),小图与低收益图原样通过。仅处理 PNG/JPEG/BMP(纯 JS 编码器,零原生依赖);其他格式原样通过。每张被缩小的图片旁附一段稳定注释,报告当前与原图尺寸;在注册 bili 工具的车道(代理注入车道,以及经插件 manifest 注册的插件车道)中还会指明 `acp_read_original_image("<ref>")`——它从本地会话存储取回原始字节;拒绝注入工具的车道(如 codex)只拿到报尺寸的注释、没有工具。`acp_read_original_image` 的结果**结构性豁免**再次降采样(防 #3266「猜→拒→重发」循环复发的环锁)。输出确定性:同一输入字节永远产出同一缩小字节与同一注释文本,同一历史反复重发保持逐字节稳定,上游前缀缓存不受扰动。每张唯一图片记一条日志(内容 hash 缓存;缓存命中静默)。优先级:`BILI_IMAGE_RESCALE` 环境变量(`"0"`/`"false"` 关闭;实时读取,无需重启)> 本配置键 > 默认开启。

### `resign`

Expand Down
2 changes: 1 addition & 1 deletion src/absorb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function storeEffectiveAbsorb(session: Session, config: Config): void {

export function isProxyToolFor(name: string, session: Session | undefined, config: Config): boolean {
if (PROXY_TOOL_NAMES.has(name)) return true;
// #3400: read_original_image executes server-side on EVERY lane — even
// #3400: acp_read_original_image executes server-side on EVERY lane — even
// where it is not registered in the manifest (codex) a hallucinated call
// must never reach the client as an unsupported tool.
if (name === READ_ORIGINAL_IMAGE_TOOL_NAME) return true;
Expand Down
Loading
Loading