Skip to content
Open
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
13 changes: 12 additions & 1 deletion src/agent/client-build-note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
// lanes (pi / oh-my-pi / opencode) are ordinary stable-versioned clients that
// do not auto-drift like that, so per decision on #4545 only dsh is wired —
// but this module is deliberately lane-generic so a second check can be
// added later with one constant and one call site.
// added later with one constant and one call site. #6588 adds the dsh lane's
// host-posture probe here (isDshGoHost): same species of soft, once-per-
// process note.
//
// The guard is SOFT and one-directional: when the resolved client version is
// STRICTLY NEWER than the newest build we test against for that lane, emit
Expand Down Expand Up @@ -122,3 +124,12 @@ export function emitNewerClientBuildNote(
console.warn(msg);
return true;
}

/** Host posture (#6588): the DSH Go Android host stamps its runtime root on
* every process it launches inside the proot rootfs — the only signal that
* reaches this lane there. Blank values mean "not stamped" (fail open to
* silence); the caller owns the once-per-process flag. */
export function isDshGoHost(env: Record<string, string | undefined> = process.env): boolean {
const root = env.DSH_GO_RUNTIME_ROOT;
return typeof root === "string" && root.trim().length > 0;
}
20 changes: 19 additions & 1 deletion src/agent/dsh-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import path from "node:path";
import { fileURLToPath } from "node:url";
import { logHostEvent } from "./host-log.js";
import * as pfChannel from "./pf-channel.js";
import { DSH_BUILD_CHECK, emitNewerClientBuildNote, walkUpNodeModuleVersion } from "./client-build-note.js";
import { DSH_BUILD_CHECK, emitNewerClientBuildNote, isDshGoHost, walkUpNodeModuleVersion } from "./client-build-note.js";
import { ensureProxyRunning, LAUNCHER_DEFAULT_HOST, requestInstanceShutdown } from "../launcher.js";
import { isVersionNewer } from "../update.js";
import { VERSION } from "../version.js";
Expand Down Expand Up @@ -276,6 +276,7 @@ let nonWebTraceLogged = false;
// Unverified dsh client build note (#warn): once-per-process, same channel
// discipline.
let dshNewerBuildNoted = false; // #4545, once per process
let dshGoHostNoted = false; // #6588, once per process
let regAdoptLogged = false;

// #4545 newer-than-tested dsh client-build note (soft, never gates). Shared
Expand Down Expand Up @@ -2877,6 +2878,23 @@ export async function apply(ctx: PluginContext): Promise<void> {
}
}

// DSH Go host posture (#6588): that host ships its own dsh runtime inside a
// proot rootfs and its client is native, so this bundle's web client face
// (dsh.client.platform: web — the Context tab and the settings page) has no
// surface to render into while the host-side lane is unaffected. One probe,
// never a gate; the durable record is the readable one there (the host
// exposes at most its last engine log lines elsewhere).
if (!dshGoHostNoted) {
try {
if (isDshGoHost()) {
logHostEvent("info", "[dsh-client]", "bili-native-dsh: DSH Go host (third-party Android app) — the plugin's web client face (Context tab, settings page) has no surface in its native client; the host-side lane is unaffected (#6588)");
dshGoHostNoted = true;
}
} catch {
// posture probe is fail-open: an odd env stays silent
}
}

// #1772/#3354: in profiles bundling @deepseek-ai/dsh-web-app the RUNNING
// compaction-basic instance sits inside an agent preset (preset-standard's
// config.plugins) where no patch layer can address the NESTED row by id
Expand Down
22 changes: 21 additions & 1 deletion tests/client-build-note.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { DSH_BUILD_CHECK, emitNewerClientBuildNote, maxTestedVersion, newerClientBuildMessage, walkUpNodeModuleVersion } from "../src/agent/client-build-note.ts";
import { DSH_BUILD_CHECK, emitNewerClientBuildNote, isDshGoHost, maxTestedVersion, newerClientBuildMessage, walkUpNodeModuleVersion } from "../src/agent/client-build-note.ts";

const DSH_PKG = "node_modules/@deepseek-ai/dsh/package.json";

Expand Down Expand Up @@ -163,3 +163,23 @@ test("emitNewerClientBuildNote: channels and tri-state outcomes", () => {
fs.rmSync(logDir, { recursive: true, force: true });
}
});

test("isDshGoHost: the runtime-root stamp decides, blank counts as absent (#6588)", () => {
assert.equal(isDshGoHost({}), false, "unset: every other host shape");
assert.equal(isDshGoHost({ DSH_GO_RUNTIME_ROOT: "" }), false, "empty string is not a stamp");
assert.equal(isDshGoHost({ DSH_GO_RUNTIME_ROOT: " " }), false, "whitespace-only is not a stamp");
assert.equal(isDshGoHost({ DSH_GO_RUNTIME_ROOT: "/data/user/0/io.github.ccch1mneyyy.dsh_app/files/runtime/rootfs" }), true);
assert.equal(isDshGoHost({ DSH_GO_RUNTIME_ROOT: " /opt/rootfs " }), true, "surrounding whitespace still stamps the host");
});

test("isDshGoHost: the argument-less default reads the live process.env (#6588)", () => {
const prev = process.env.DSH_GO_RUNTIME_ROOT;
try {
delete process.env.DSH_GO_RUNTIME_ROOT;
assert.equal(isDshGoHost(), false, "unset in the live env: not the dsh-go host");
process.env.DSH_GO_RUNTIME_ROOT = "/data/user/0/io.github.ccch1mneyyy.dsh_app/files/runtime/rootfs";
assert.equal(isDshGoHost(), true, "the production call site passes no argument");
} finally {
if (prev === undefined) delete process.env.DSH_GO_RUNTIME_ROOT; else process.env.DSH_GO_RUNTIME_ROOT = prev;
}
});
Loading