Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cd35dbf
fix: carry the restored output budget across the watermark rebind (#6…
sx4im Nov 14, 2026
5bd8909
test: pin the output-budget re-export identity in the side-lane suite…
Nov 14, 2026
02757a0
fix(persist): retain calibration model provenance on cold load
mariopasquali Nov 8, 2026
fa9b192
test: pin restored calibration model provenance
mariopasquali Nov 8, 2026
36b13ad
fix: restore persisted emergency shrink status evidence
mariopasquali Nov 8, 2026
804c89b
perf(reconcile): compute candidate word evidence once per pass
Maziar123 Nov 15, 2026
642124b
fix(omp): drop the stamped prompt_cache_key on a direct send
Maziar123 Nov 15, 2026
3d82e25
fix(preflight): fold an over-window payload while epoch confirmation …
Maziar123 Nov 15, 2026
5a0a7b8
fix: route OpenCode 2.x built-in Claude Agent provider through the pr…
sx4im Nov 15, 2026
9dc914c
fix: drop unused export OPENCODE_CLAUDE_AGENT_PROVIDER (unused-export…
Nov 15, 2026
686d3d8
feat(dsh): surface compaction overlay coverage on the first routed re…
OMSociety Nov 14, 2026
4f518a2
test(dsh): pin the #6770 coverage readout wiring (#6770)
OMSociety Nov 15, 2026
78b85c6
docs: document the OpenCode 2.x built-in Claude Agent provider routin…
Nov 15, 2026
14c8c64
Merge <author branch> (PR #6819) into batch11-wave11
ranxianglei Nov 18, 2026
6c1832d
Merge <author branch> (PR #6807) into batch11-wave11
ranxianglei Nov 18, 2026
c07804c
Merge <author branch> (PR #6803) into batch11-wave11
ranxianglei Nov 18, 2026
7931c1f
Merge <author branch> (PR #6801) into batch11-wave11
ranxianglei Nov 18, 2026
b5d9e07
Merge <author branch> (PR #6775) into batch11-wave11
ranxianglei Nov 18, 2026
6fc596a
Merge <author branch> (PR #6772) into batch11-wave11
ranxianglei Nov 18, 2026
104b7d9
Merge <author branch> (PR #6766) into batch11-wave11
ranxianglei Nov 18, 2026
05d75f2
test(golden): regenerate storage-render goldens for the merged tree (…
ranxianglei Nov 18, 2026
307337c
Merge origin/master into batch11-wave11 (golden conflict: take master…
ranxianglei Nov 18, 2026
75a4538
test(golden): regenerate storage-render goldens on the merged tree (#…
ranxianglei Nov 18, 2026
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
21 changes: 21 additions & 0 deletions docs/clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,27 @@ healthy, requests go direct (uncompressed) with a one-time warning and
recover automatically. Under a `bili opencode` launch this entry is skipped
entirely (the launcher owns the proxy).

### Built-in Claude Agent provider (2.x)

OpenCode 2.x ships a built-in **Claude Agent** provider (`claude-agent/*`) that drives a local Claude Code CLI. That child calls Anthropic directly — it makes no request *from* OpenCode — so the plugin's HTTP-hook routing never sees its traffic and its sessions would otherwise run uncompressed. On a 2.x host, `bili plugin install opencode` routes it by writing `providers.claude-agent.settings.baseURL` in your opencode config, pinned to the live opencode lane port:

```json
{
"providers": {
"claude-agent": {
"settings": {
"baseURL": "http://127.0.0.1:<port>/bili/https://api.anthropic.com"
}
}
}
}
```

- **Existing installs** — re-run `bili plugin install opencode`; the entry is written at install time, so a pre-existing config is not retro-routed.
- **Port drift** — if the opencode lane port changes, the pinned URL goes stale; `bili doctor` warns on the opencode lane and a re-run re-pins it.
- **Your own proxy** — a non-bili `baseURL` is left untouched (it's yours, not ours to clobber).
- **Known limitation** — compression works, but the `mcp__opencode__*` bili tools still have no session state in these sessions: the proxy keys the session by the Claude Code child's id, not OpenCode's `ses_…` id.

### OpenAI Responses WebSockets (V2)

The V2 plugin also intercepts OpenAI `experimental.ws.handshake` requests.
Expand Down
21 changes: 21 additions & 0 deletions docs/clients.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,27 @@ HTTPS 走证书 MITM,HTTP 走临时 `opencode.json` 副本(`/bili/` 改写;JSONC

加载时插件自拉起自己的代理(健康的已有实例直接复用不重复起;父进程 pid 看门狗在 opencode 退出时收掉它),把模型流量路由到 `<proxy>/bili/<upstream-url>`,暴露与启动器模式相同的原生 bili 工具 —— 无固定端口、无环境变量、免启动器。退出:`BILI_NATIVE_OPENCODE=0`。若没有任何代理能拉到健康状态,请求直连(不压缩)并给一次性告警,之后自动恢复。在 `bili opencode` 启动下该条目整体跳过(代理归启动器管)。

### 内置 Claude Agent provider(2.x)

OpenCode 2.x 内置了一个 **Claude Agent** provider(`claude-agent/*`),它驱动一个本地 Claude Code CLI。这个子进程直连 Anthropic——不从 OpenCode 发请求——所以插件的 HTTP-hook 路由永远看不到它的流量,其会话否则会不压缩地运行。在 2.x 主机上,`bili plugin install opencode` 通过在你的 opencode 配置里写入 `providers.claude-agent.settings.baseURL`(钉在 opencode 泳道的实时端口)来路由它:

```json
{
"providers": {
"claude-agent": {
"settings": {
"baseURL": "http://127.0.0.1:<port>/bili/https://api.anthropic.com"
}
}
}
}
```

- **已有安装** —— 重新运行 `bili plugin install opencode`;该条目在安装时写入,所以已有配置不会被追溯路由。
- **端口漂移** —— 如果 opencode 泳道端口变化,钉死的 URL 会失效;`bili doctor` 会在 opencode 泳道告警,重新运行会重新钉死。
- **你自己的代理** —— 非 bili 的 `baseURL` 会被保留不动(那是你的,不是我们要覆盖的)。
- **已知限制** —— 压缩可用,但这些会话里 `mcp__opencode__*` bili 工具仍然没有会话状态:代理以 Claude Code 子进程的 id 为键,而非 OpenCode 的 `ses_…` id。

### OpenAI Responses WebSocket(V2)

V2 插件也接管 OpenAI 的 `experimental.ws.handshake` 请求,两端均使用
Expand Down
4 changes: 3 additions & 1 deletion docs/message-identity.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ id・ハッシュ・形状はいずれもヒント;「私のブロックはど
- **Epoch-confirm ゲート**:全面崩壊は `foldEpochConfirmPending` を latch し、
エラーを 1 回出し、preflight はリクエストを逐字通過させる —— folding は*一
時的停止*;何も削除されず、何もサイレントにリセットされない。整列回復(ホ
ストが真の履歴を再送)で latch は自動クリア。
ストが真の履歴を再送)で latch は自動クリア。この一時停止は逐字ペイロー
ドがモデルウィンドウに収まる間だけ有効:ウィンドウ超過のペイロードは通
過できないため、preflight は通常どおり fold する(#6069)。
- **Unresolved-anchor 配置**(kernel `prune.ts`):アンカーがすべて解決失敗し
たブロックは、tail ではなく最後の user メッセージに挿入される —— サマリー
ブロックがユーザーの最新質問の *後* に乗ることがなくなった(#3640 の
Expand Down
5 changes: 4 additions & 1 deletion docs/message-identity.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ rule; proof tests in `tests/fold-anchor-doctrine.test.ts`):
- **Epoch-confirm gate**: total collapse latches `foldEpochConfirmPending`,
emits one error, and preflight passes requests through verbatim — folding
*pauses*; nothing is deleted, nothing is silently reset. Alignment
recovery (the host resends the true history) auto-clears the latch.
recovery (the host resends the true history) auto-clears the latch. The
pause holds only while the verbatim payload fits the model window: an
over-window payload cannot pass through, so preflight folds it as usual
(#6069).
- **Unresolved-anchor placement** (kernel `prune.ts`): a block whose anchors
all failed to resolve now inserts at the last user message instead of the
tail — a summary block can no longer ride *after* the user's newest
Expand Down
2 changes: 1 addition & 1 deletion docs/message-identity.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bili 的应对遵循上文的失败模式公理:**不猜** old→new 配对(猜
- **形状层**(保序):当一次性缺失**成片** covered id(≥ `SHAPE_MASS_MIN`)时,残留散文锚按会话顺序与入站候选配对,受编辑诚实门约束——词袋相等 + simhash ≤ 8 + role + 长度卫兵(sim 层用于 gap 的同一道门,用在 claim 上)。无文本锚(图片族:构造上无 sh/wh)在两侧被已验证的侧翼包夹、且逐桶计数恰相等时按第 k 对第 k 配对——byImage 纪律推广到 bili 自家占位变体之外。
- **残差普查与判决分类**:阶梯认不下的部分被*分类*,而非假定已毁。`shapeExplained`(变换:claim 或近重证据承担了主体)——一次性 info latch,清零 streak。`truncationExplained`(良性删除:残差全部到处缺席、零近重、且**wire 连续性见证**——冻结的旧序尾部仍居于入站头部)——块休眠而非 reap(#2695)。其余照旧是 drift,照旧升级。
- **episode 见证人**:首个 drift pass 冻结旧序尾部(`foldEpisodeOrder`);同会话 id 下的外来会话与它无连续性,整体替换无法冒充截断。
- **epoch 确认门**:全塌 latch `foldEpochConfirmPending`,发一条 error,preflight 原样透传——折叠*暂停*;不删任何东西,不静默重置。对齐恢复(宿主重发真实历史)自动清 latch。
- **epoch 确认门**:全塌 latch `foldEpochConfirmPending`,发一条 error,preflight 原样透传——折叠*暂停*;不删任何东西,不静默重置。对齐恢复(宿主重发真实历史)自动清 latch。暂停只在原样载荷放得进模型窗口时成立:超窗载荷无法透传,preflight 照常折叠(#6069)。
- **未解析锚摆位**(内核 `prune.ts`):锚全部解析失败的块,插入点从尾部改为最后一个 user 消息——摘要块再也不会骑在用户最新提问*之后*(#3640 的六个骑尾块)。

诚实边界是有意的:形状层要求**严格**词袋相等,所以系统性内容突变——比如宿主给历史批量加/删尾部 `<system-reminder>` 后缀——**不会**被认成同一条消息(模糊内容 join 在 decompress 时认错;见下文被否决备选)。这类事件被分类为截断或全塌,落在休眠/暂停路径上——永不静默重键。批量同后缀重戳(N 对保序对共享完全相同的 delta)是否值得单独立一个*可验证*类,是待生产日志定界的开放跟进项(#3640/#3588)。
Expand Down
11 changes: 11 additions & 0 deletions src/agent/dsh-compaction-disable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ export function _resetDshCompactionGateTelemetryForTest(): void {
delete (globalThis as Record<string, unknown>)[DSH_COMPACTION_GATE_TELEMETRY_KEY];
}

/** #6770: one-line coverage summary shared by the durable profile notes (#3962)
* and bili-native's first-request log line. Pure over the record; "no entry
* rewritten" is the honest frame because preset configs resolve lazily. */
export function compactionCoverageText(telemetry: DshCompactionGateTelemetry | null = dshCompactionGateTelemetry()): string {
if (telemetry === null || telemetry.covered.length === 0) {
return "no preset entry rewritten in this process (preset configs resolve lazily — zero at this point does not mean zero later)";
}
const entries = telemetry.covered.map((c) => `${c.entry}\u00d7${c.rows}`).join(", ");
return `${telemetry.covered.length} preset ${telemetry.covered.length === 1 ? "entry" : "entries"} rewritten (${entries})`;
}

type PresetRow = { name?: unknown; group?: unknown; config?: unknown };

/** Count compaction-basic/command-compact rows the disable walk would mark
Expand Down
30 changes: 23 additions & 7 deletions src/agent/dsh-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import { installNativeWebSocketIntercept } from "./native-ws-intercept.js";
import { asciiHeaderValue, fetchManifest, fetchProxyVersion, fetchStatus, fetchStatusLatest, forwardTool, reportAttributionHealth, reportRuntimeInfo, waitForProxyVersion, type ManifestTool } from "./shared.js";
import { createForkAdopter, sideShapedBody } from "./fork-adopt.js";
import { clearIncrementalProbe, createPrepareDirectSend, INCREMENTAL_TURN_MARKER_HEADER, INCREMENTAL_TURN_ID_HEADER, newIncrementalTurnId, noteIncrementalRejection, noteIncrementalAck, planIncrementalTurn, probeIncrementalTurns, rememberOriginalBody, sweepStale, wireMessagesLookAnthropic, type IncrementalWireMessage } from "./incremental-client.js";
import { declareDshCompactionActive, detectCompactionOverlayGap, dshCompactionGateTelemetry } from "./dsh-compaction-disable.js";
import { compactionCoverageText, declareDshCompactionActive, detectCompactionOverlayGap } from "./dsh-compaction-disable.js";
import { maskUrlForDiagnostics } from "../log-mask.js";
import { mediaBytesOfWireBody } from "./media-bytes.js";
import { conversationRecallStats, learnConversation, recallBoundaryOfMessages, recallConversation, recallHistoryFingerprints, recallLaneHasEntries, recallLaneKey } from "./conversation-recall.js";
Expand Down Expand Up @@ -294,12 +294,7 @@ export { DSH_BUILD_CHECK } from "./client-build-note.js";
* the gate rows' fate implied. Best-effort by necessity: preset configs
* resolve lazily, so "so far" is the honest frame. */
function gateCoverageSuffix(): string {
const t = dshCompactionGateTelemetry();
if (t === null || t.covered.length === 0) {
return " Overlay coverage so far: no preset entry rewritten in this process (preset configs resolve lazily — zero at this point does not mean zero later).";
}
const entries = t.covered.map((c) => `${c.entry}\u00d7${c.rows}`).join(", ");
return ` Overlay coverage so far: ${t.covered.length} preset ${t.covered.length === 1 ? "entry" : "entries"} rewritten (${entries}).`;
return ` Overlay coverage so far: ${compactionCoverageText()}.`;
}

/** #1590/#1809: origin of the proxy as currently reachable — register.base
Expand Down Expand Up @@ -1256,6 +1251,12 @@ interface LlmDispatchScope {
const dispatchScope = new AsyncLocalStorage<LlmDispatchScope>();

let noticedScopedAttribution = false;
// #6770: the #3962 coverage readout only ever rode the profile-bundle note,
// which stays silent wherever profileContext.startedBundles cannot be read
// (observed on both a desktop dsh build and the dsh-go runtime), so the
// coverage reading had no reachable exit. Emit it once per process on the
// first routed request instead.
let compactionCoverageNoted = false;

/** #4491: extract the host message ids from llm/stream `options.messages`,
* all-or-nothing. Mirrors validateMsgIds in src/msgid-pin.ts (the 400-class
Expand Down Expand Up @@ -1340,6 +1341,15 @@ function attributionOf(ctx: PluginContext): GateAttribution {
// driving), and it survives exactly the shapes the ambient reading does
// not (agentless compaction/title lanes, disposed scopes, retried
// re-sends whose initiator scope went away between attempts).
// #6770: first routed request is the earliest point where the overlay's
// structural rewrites can have happened (preset configs resolve lazily),
// so the coverage reading goes out here — the durable profile note that
// used to carry it never fires when profileContext.startedBundles cannot
// be read, which is the observed state on every host we checked.
if (!compactionCoverageNoted) {
compactionCoverageNoted = true;
persistClientEvent(`bili-native-dsh: compaction overlay coverage — ${compactionCoverageText()} (#6770)`);
}
const scoped = dispatchScope.getStore();
if (scoped !== undefined && scoped.sid.length > 0) {
if (!noticedScopedAttribution) {
Expand Down Expand Up @@ -3119,6 +3129,12 @@ export function _resetDshNewerBuildNoteForTest(): void {
dshNewerBuildNoted = false;
}

/** Test hook (#6770): reset the once-per-process compaction-coverage readout
* flag so a test can pin the emit wiring, not just the formatter. */
export function _resetCompactionCoverageNoteForTest(): void {
compactionCoverageNoted = false;
}

/** #2924 direction 2: a `threw` attribution (host agent scope disposed
* mid-request) gets a bounded settle-retry before the gate decides. The
* defaults cap the added latency of a dying turn at ~(attempts-1)×delayMs;
Expand Down
10 changes: 6 additions & 4 deletions src/agent/omp-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
// (BILLION_CONTEXT_PLUGIN=0 / BILI_NATIVE_OMP=0).

import { ensureProxyRunning, LAUNCHER_DEFAULT_HOST } from "../launcher.js";
import { createBiliPlugin } from "./pi.js";
import { createBiliPlugin, createOmpDirectSendGuard } from "./pi.js";
import { applyOmpFirstEventTimeout, applyOmpMessageThreadsOff, markNativeHost, nativeAttachOrigin, nativeBootstrapGate, nativeProxyScriptPath, proxyEnvOrigin, setNativeOriginWaiter, singleFlight } from "./native-bootstrap.js";
import { installNativeFetchIntercept, noteRoutedOrigin, observeRoutedOrigin, readyOrigin, setDeclaredModelEndpoints, type NativeInterceptState } from "./native-intercept.js";
import { loadDeclaredModelEndpoints } from "../model-endpoints.js";
import { clearIncrementalProbe, createPrepareDirectSend, hostMsgIdHintFor, INCREMENTAL_TURN_MARKER_HEADER, INCREMENTAL_TURN_ID_HEADER, newIncrementalTurnId, noteIncrementalAck, noteIncrementalRejection, planIncrementalTurn, probeIncrementalTurns, rememberOriginalBody, sweepStale, wireMessagesLookAnthropic, type IncrementalWireMessage } from "./incremental-client.js";
import { clearIncrementalProbe, hostMsgIdHintFor, INCREMENTAL_TURN_MARKER_HEADER, INCREMENTAL_TURN_ID_HEADER, newIncrementalTurnId, noteIncrementalAck, noteIncrementalRejection, planIncrementalTurn, probeIncrementalTurns, rememberOriginalBody, sweepStale, wireMessagesLookAnthropic, type IncrementalWireMessage } from "./incremental-client.js";
import * as pfChannel from "./pf-channel.js";
import { fetchProxyVersion, waitForProxyVersion } from "./shared.js";
import { logHostEvent } from "./host-log.js";
Expand Down Expand Up @@ -214,8 +214,10 @@ export async function ompIncrementalBeforeSend(url: string, init: RequestInit |

state.beforeSend = ompIncrementalBeforeSend;
// #3304: the omp swap stamps the turn id atomically with the body, so the
// strict shared guard applies — mutated + unrestorable ⇒ refuse locally.
state.prepareDirectSend = createPrepareDirectSend();
// strict shared guard applies — mutated + unrestorable ⇒ refuse locally. A
// direct send also drops the prompt_cache_key the plugin stamped (no proxy
// strips it on that path).
state.prepareDirectSend = createOmpDirectSendGuard();

export function ompIncrementalOnResponse(_url: string, response: Response, headers?: Record<string, string>): void {
const turnId = headers?.[INCREMENTAL_TURN_ID_HEADER];
Expand Down
Loading
Loading