Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5b9ce15
fix(dsh): a never-configured host is not a config error (#7126)
resec Nov 18, 2026
2b1c955
fix(dsh): read the patch layer's disabled value, not the literal `tru…
resec Nov 18, 2026
e237d0a
fix: reject partial pnpm ledger repairs
Afloat16 Nov 18, 2026
6228c39
fix(openai): keep provider usage fields in synthesized completion
Nov 18, 2026
7996c49
fix: abort superseded cache keepalive requests
Afloat16 Nov 18, 2026
60d67f3
fix(dsh): match carriers on their emitted shape, not a bare marker (#…
resec Nov 18, 2026
27289a0
fix(dsh): stand the host-plane /compact command down on a bili-owned …
resec Nov 18, 2026
b2f6694
fix(dsh): decide the launcher overlay from the profile being booted (…
resec Nov 18, 2026
c317260
test(dsh): pin the two remaining bare-marker guard fixtures to the em…
resec Nov 18, 2026
57eea20
fix(dsh): release the fast-path origin when a pinned attach target is…
resec Nov 18, 2026
10d1f1f
test(dsh): register the #7176 suite in LIVE_FILES and make its dead o…
resec Nov 18, 2026
ad325ca
Merge 7187 author branch (PR #7187) into batch12-wave12
ranxianglei Nov 18, 2026
4f36339
Merge 7185 author branch (PR #7185) into batch12-wave12
ranxianglei Nov 18, 2026
674b836
Merge 7182 author branch (PR #7182) into batch12-wave12
ranxianglei Nov 18, 2026
9fdc652
Merge 7177 author branch (PR #7177) into batch12-wave12
ranxianglei Nov 18, 2026
774de3b
Merge 7174 author branch (PR #7174) into batch12-wave12
ranxianglei Nov 18, 2026
b958e15
Merge 7171 author branch (PR #7171) into batch12-wave12
ranxianglei Nov 18, 2026
f0021d0
Merge 7166 author branch (PR #7166) into batch12-wave12
ranxianglei Nov 18, 2026
5f25466
Merge 7162 author branch (PR #7162) into batch12-wave12
ranxianglei Nov 18, 2026
3d31e65
Merge 7161 author branch (PR #7161) into batch12-wave12
ranxianglei Nov 18, 2026
a521ea5
Merge 7159 author branch (PR #7159) into batch12-wave12
ranxianglei Nov 18, 2026
8647c83
Merge 7158 author branch (PR #7158) into batch12-wave12
ranxianglei Nov 18, 2026
74a4df2
Merge 7147 author branch (PR #7147) into batch12-wave12
ranxianglei Nov 18, 2026
bbdf748
Merge 7143 author branch (PR #7143) into batch12-wave12
ranxianglei Nov 18, 2026
b8e3f8f
Merge 7141 author branch (PR #7141) into batch12-wave12
ranxianglei Nov 18, 2026
45bdee1
Merge 7138 author branch (PR #7138) into batch12-wave12
ranxianglei Nov 18, 2026
05c15cf
Merge 7136 author branch (PR #7136) into batch12-wave12
ranxianglei Nov 18, 2026
74300a0
Merge 7133 author branch (PR #7133) into batch12-wave12
ranxianglei Nov 18, 2026
ee8b6fe
Merge 7129 author branch (PR #7129) into batch12-wave12
ranxianglei Nov 18, 2026
daa2c07
Merge 7127 author branch (PR #7127) into batch12-wave12
ranxianglei Nov 18, 2026
1c8cac2
fix: note the output-budget override in the compat.dropFields log (#6…
Nov 17, 2026
b329f58
Merge origin/master (b10c1a0d4ee) into PR #7199 head — resolve live-f…
Nov 20, 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
11 changes: 11 additions & 0 deletions dsh.bundle.patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
- id: compaction-basic
config:
auto: false
# #7154: `/compact` drives the SAME host-side compaction call bili's wire
# guard refuses unconditionally (#1729) — on a lane bili owns the command has
# no outcome except failure, and dsh reports that failure as "Compaction could
# not produce a useful summary", which blames the model for a policy refusal.
# Stand it down with the same static semantics as the `auto: false` row above
# (a kill-switched bili-native does not bring it back either). To get the
# command back, set `disabled: false` for this id in the profile's own
# cordis.patch.yml — be aware every invocation is still refused at the wire.
# Keep in sync with the launcher overlay (writeDshAcpPatch).
- id: command-compact
disabled: true
# #3354: keep in sync with writeDshAcpPatch in src/launcher.ts — entry inject
# lists are REPLACED by patches, not concatenated; if a future dsh ships its
# own inject list on these entries, merge manually in BOTH layers.
Expand Down
8 changes: 8 additions & 0 deletions scripts/live-files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ export const LIVE_FILES = [
// the zone band is irrelevant; the entry is for the tripwire, like
// #5046/#4612.
"tests/storage-integrity-cache.test.ts",
// #7176: the pinned-attach decision test. Every origin is a listen(0)
// pick (the dead arm binds :0, reads the port, closes it and requires
// ECONNREFUSED there), so no fixed port and no zone band is involved; no
// child process is spawned either — the entry is for the SPAWN_RE
// tripwire alone (its hit is the identifier "spawn-fallback" wording plus
// _setSpawnForTest). Both arms reset the module-level origin plane in
// `finally`, so rows cannot leak into each other.
"tests/issue7176-dead-attach-origin-release.test.ts",
];

/** Band width per live file: the zone ladder drifts +1 per EADDRINUSE retry;
Expand Down
18 changes: 18 additions & 0 deletions src/agent/dsh-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,24 @@ export async function verifyAttachAndRecover(attachOrigin: string): Promise<stri
register.base = undefined;
register.retryAt = 0;
}
// #7176: the DEVICE the model channel rides must be released too.
// readyOrigin() short-circuits on state.origin (native-intercept
// :1137), so leaving a proven-dead target bound there kept every later
// model request rewritten onto it and failing — the documented
// "model requests go direct (uncompressed)" degradation could never
// run, and the only way out was the proxy returning. spawnFallback
// already drops it (with the preset unfreeze it needs, because it then
// spawns); this branch must NOT spawn (#1365: a second instance serves
// tools while the model channel stays pinned, and every bili tool call
// 404s), so only the origin plane is cleared: the preset env stays, the
// re-check loop keeps probing via maybeRetry, and traffic degrades to
// direct until the target answers again.
if (state.origin === pinned || state.origin === attachOrigin) {
state.origin = undefined;
persistClientEvent(
`attach target ${pinned} is down — model requests degrade to direct (uncompressed) until it answers again; bili tools stay unbound (the channel is pinned, so no second instance is spawned)`,
);
}
return undefined;
}
return spawnFallback(attachOrigin, `attach target ${attachOrigin} is not healthy — falling back to a spawned proxy`, gen);
Expand Down
98 changes: 56 additions & 42 deletions src/cache-keepalive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ interface KeepaliveEntry {
lastHitAt?: number;
timerId: ReturnType<typeof setTimeout> | undefined;
pingInFlight: boolean;
pingController?: AbortController;
}

const registry = new Map<string, KeepaliveEntry>();
Expand Down Expand Up @@ -345,6 +346,7 @@ function armInternal(inp: KeepaliveArmInput): void {
pingInFlight: false,
};
registry.set(inp.sessionId, entry);
prev?.pingController?.abort();
entry.timerId = scheduleFn(() => {
void firePing(entry);
}, entry.cadenceMs);
Expand Down Expand Up @@ -372,52 +374,63 @@ async function firePing(entry: KeepaliveEntry): Promise<void> {
return;
}
entry.pingInFlight = true;
const controller = new AbortController();
entry.pingController = controller;
// Keep cancellation live until the response body is consumed. Relay the
// deadline without AbortSignal.any, which is absent in early Node 20.
const timeout = AbortSignal.timeout(PING_TIMEOUT_MS);
const onTimeout = () => controller.abort(timeout.reason);
timeout.addEventListener("abort", onTimeout, { once: true });
entry.lastPingAt = clock();
let resp: Response;
try {
resp = await sendPing(entry);
} catch (err) {
entry.pingInFlight = false;
handleFailure(entry, `network: ${err instanceof Error ? err.message : String(err)}`);
return;
}
entry.pingInFlight = false;
if (registry.get(entry.sessionId) !== entry) return;
let text: string;
try {
text = await resp.text();
} catch (err) {
if (resp.status !== 429) {
handleFailure(entry, `response body: ${err instanceof Error ? err.message : String(err)}`);
let resp: Response;
try {
resp = await sendPing(entry, controller.signal);
} catch (err) {
handleFailure(entry, `network: ${err instanceof Error ? err.message : String(err)}`);
return;
}
text = "";
}
if (registry.get(entry.sessionId) !== entry) return;
if (!resp.ok) {
if (resp.status === 429) {
disarm(entry.sessionId, "rate-limited(429)");
if (registry.get(entry.sessionId) !== entry) return;
let text: string;
try {
text = await resp.text();
} catch (err) {
if (resp.status !== 429) {
handleFailure(entry, `response body: ${err instanceof Error ? err.message : String(err)}`);
return;
}
text = "";
}
if (registry.get(entry.sessionId) !== entry) return;
if (!resp.ok) {
if (resp.status === 429) {
disarm(entry.sessionId, "rate-limited(429)");
return;
}
handleFailure(entry, `http ${resp.status}: ${text.slice(0, 200)}`);
return;
}
handleFailure(entry, `http ${resp.status}: ${text.slice(0, 200)}`);
return;
}
let usage: Record<string, unknown> | undefined;
try {
const j = JSON.parse(text) as { usage?: unknown };
if (j && typeof j === "object" && j.usage && typeof j.usage === "object") usage = j.usage as Record<string, unknown>;
} catch {
usage = undefined;
}
const cached = usage ? usageTotals("anthropic", usage).cached : undefined;
entry.pingCount += 1;
if (typeof cached === "number" && cached > 0) {
entry.failStreak = 0;
entry.lastHitAt = clock();
loggerLog("info", `[${entry.sessionId}] [keepalive] ping#${entry.pingCount} hit=${cached}tok`);
reschedule(entry);
} else {
disarm(entry.sessionId, "prefix-dead(cache_read=0)");
let usage: Record<string, unknown> | undefined;
try {
const j = JSON.parse(text) as { usage?: unknown };
if (j && typeof j === "object" && j.usage && typeof j.usage === "object") usage = j.usage as Record<string, unknown>;
} catch {
usage = undefined;
}
const cached = usage ? usageTotals("anthropic", usage).cached : undefined;
entry.pingCount += 1;
if (typeof cached === "number" && cached > 0) {
entry.failStreak = 0;
entry.lastHitAt = clock();
loggerLog("info", `[${entry.sessionId}] [keepalive] ping#${entry.pingCount} hit=${cached}tok`);
reschedule(entry);
} else {
disarm(entry.sessionId, "prefix-dead(cache_read=0)");
}
} finally {
timeout.removeEventListener("abort", onTimeout);
entry.pingInFlight = false;
entry.pingController = undefined;
}
}

Expand All @@ -439,7 +452,7 @@ function reschedule(entry: KeepaliveEntry): void {
}, entry.cadenceMs);
}

async function sendPing(entry: KeepaliveEntry): Promise<Response> {
async function sendPing(entry: KeepaliveEntry, signal: AbortSignal): Promise<Response> {
const headers: Record<string, string> = {};
for (const [k, v] of Object.entries(entry.headers)) {
const lk = k.toLowerCase();
Expand All @@ -453,7 +466,7 @@ async function sendPing(entry: KeepaliveEntry): Promise<Response> {
method: "POST",
headers,
body: buildPingBody(entry.body),
signal: AbortSignal.timeout(PING_TIMEOUT_MS),
signal,
};
if (entry.dispatcher) init.dispatcher = entry.dispatcher;
return await fetch(entry.upstreamUrl, init as RequestInit) as Response;
Expand All @@ -464,6 +477,7 @@ function disarm(sessionId: string, reason: string): void {
if (!entry) return;
registry.delete(sessionId);
if (entry.timerId !== undefined) cancelFn(entry.timerId);
entry.pingController?.abort();
loggerLog("info", `[${sessionId}] [keepalive] disarmed reason=${reason} pings=${entry.pingCount}`);
}

Expand Down
56 changes: 54 additions & 2 deletions src/dsh-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,34 @@ interface DshPatchEntry {
* callers decide how duplicates combine. The single source of truth for
* patch-layer enablement semantics: both the #2462 cost advisory and the
* #2861 host-plugin notice scan through this so they can never drift apart. */
/** #7128: is this `disabled:` value a "row is off" declaration?
*
* The patch layer is YAML with one extension: dsh's loader also accepts
* `disabled: !!js <expr>`, and the dump of a stock web profile carries four
* such forms today. A text scan cannot evaluate an expression, so a declared
* `!!js` value is treated as "the user turned this row off". That is the
* safer error direction for both consumers: under-reporting a cost hint beats
* nagging someone who already disabled the plugin, and the host-plugin notice
* is suppressed exactly when the user acted. Plain booleans are still read
* exactly, including YAML 1.1's `yes`/`on` and quoted forms. */
function isDisabledValue(raw: string): boolean {
let v = raw.trim();
// A YAML comment needs whitespace before '#', so split there and keep the rest out.
const comment = v.indexOf(" #");
if (comment >= 0) v = v.slice(0, comment).trim();
if (v.length === 0) return false;
if (v.startsWith("!!js")) return true;
const quoted =
v.length > 1 &&
((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'")));
if (quoted) v = v.slice(1, -1).trim();
return /^(?:true|yes|on)$/i.test(v);
}

export function parseDshPatchEntries(text: string): DshPatchEntry[] {
const itemRe = /^\s*-\s*id\s*:\s*(\S+)/;
const listItemRe = /^\s*-\s/;
const disabledRe = /^\s+disabled\s*:\s*true\b/;
const disabledRe = /^\s+disabled\s*:\s*(.*)$/;
const out: DshPatchEntry[] = [];
let current: DshPatchEntry | undefined;
for (const line of text.split(/\r?\n/)) {
Expand All @@ -83,7 +107,10 @@ export function parseDshPatchEntries(text: string): DshPatchEntry[] {
current = undefined;
continue;
}
if (current && disabledRe.test(line)) current.disabled = true;
if (current) {
const disabled = line.match(disabledRe);
if (disabled && isDisabledValue(disabled[1] ?? "")) current.disabled = true;
}
}
if (current) out.push(current);
return out;
Expand Down Expand Up @@ -184,6 +211,31 @@ export function dshProfileDependsOnBili(profileDir: string): boolean {
return dshProfileDepSpec(profileDir) !== undefined;
}

/** #7155: the profile a `dsh` argv boots, mirroring dsh's own parser — a bare
* first argument abbreviates `--profile <name>` (except the `plugin`
* subcommand, which takes its own required flag), otherwise the explicit
* `--profile <name>` / `--profile=<name>` wins. undefined when the argv names
* no profile; dsh itself then errors out, so callers fall back to the
* machine-wide answer. The launcher needs this to ask "is THIS profile
* installed" instead of "does any profile on this machine have a copy". */
export function dshProfileFromArgs(args: readonly string[]): string | undefined {
const first = args[0];
if (first !== undefined && !first.startsWith("-") && first !== "plugin") return first;
for (let i = 0; i < args.length; i++) {
const arg = args[i]!;
if (arg === "--") break;
if (arg === "--profile") {
const value = args[i + 1];
return value !== undefined && value !== "" && !value.startsWith("-") ? value : undefined;
}
if (arg.startsWith("--profile=")) {
const value = arg.slice("--profile=".length);
return value !== "" ? value : undefined;
}
}
return undefined;
}

/** #2894: converge this profile's declared billion-context spec to the version
* bili just installed IN PLACE (the dsh desktop lane — #1575). The desktop
* copy's node_modules entry is swapped by bili's own tarball installer while
Expand Down
2 changes: 1 addition & 1 deletion src/dsh-ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export function patchPnpmLock(text: string, spec: string, version: string): Pnpm
const sub = patchNestedEntries(lines.slice(range[0], range[1]), 0, range[1] - range[0], spec, version);
if (sub.kind === "fail") {
// an entry-less section is fine when another section holds the entry
if (patched === 0 && !sub.reason.startsWith("no billion-context entry")) return sub;
if (!sub.reason.startsWith("no billion-context entry")) return sub;
continue;
}
lines.splice(range[0], range[1] - range[0], ...sub.next.split("\n"));
Expand Down
Loading
Loading