Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(daemon): retain actionable DSH profile startup diagnostics (#10747)

Danila Katalshov7a08b0fecd3f
diff --git a/apps/docs/content/docs/install-agent-runtime.fr.mdx b/apps/docs/content/docs/install-agent-runtime.fr.mdx
index 845214d6f0..9865c492e9 100644
--- a/apps/docs/content/docs/install-agent-runtime.fr.mdx
+++ b/apps/docs/content/docs/install-agent-runtime.fr.mdx
@@ -105,7 +105,9 @@ Privilégiez un bundle que votre propre équipe publie ou compile : cette valeur
**DSH Desktop.** Si vous avez installé DeepSeek Harness Desktop plutôt que le paquet npm, le daemon recherche aussi les shims CLI que génère cette application, dans son propre répertoire de données par utilisateur : `~/Library/Application Support/DSH Desktop` sur macOS, `%APPDATA%\DSH Desktop` sur Windows. Sous Windows, il s'agit des données d'application itinérantes (roaming), pas du répertoire d'installation : l'application s'installe dans Program Files ou dans `%LOCALAPPDATA%\Programs`, mais le CLI qu'elle pilote se trouve à côté de ses autres données par utilisateur. Le segment de version de ces chemins est un identifiant généré ; le daemon les énumère donc et privilégie le plus récent. Rien d'autre n'est nécessaire dans le `PATH` : un shim généré exécute le runtime propre de l'application Desktop par chemin absolu. Si DSH Desktop est installé à un emplacement non standard, faites pointer `MULTICA_DSH_PATH` vers le shim.
-Le daemon n'enregistre DeepSeek Harness qu'après la réussite de `dsh --profile multica --probe`, et signale le profil manquant sur `/health` en cas d'échec.
+**Après une mise à niveau de DSH.** Si la sonde signale des paquets cœur incompatibles dans le profil, sauvegardez le manifeste indiqué dans le diagnostic du daemon. Vérifiez les substitutions de `@deepseek-ai/dsh-agent`, `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools` et `@deepseek-ai/dsh-llm` : préférez les paquets fournis par l’application, ou alignez les substitutions sur la version installée de DSH. Conservez les plugins et hooks indépendants nécessaires ; ne supprimez pas toutes les dépendances. Relancez `dsh --profile multica --probe` après la réparation. Multica indique que ce refus de compatibilité confirmé nécessite une réparation manuelle et n’écrase pas le profil existant.
+
+Le daemon enregistre DeepSeek Harness uniquement après la réussite de `dsh --profile multica --probe`. Le diagnostic de `/health` distingue un profil absent, une réparation manuelle confirmée, une incompatibilité de protocole et une sonde indisponible. En cas d’échec au démarrage, il inclut la version détectée du CLI, l’emplacement du manifeste et les diagnostics expurgés disponibles.
</Accordion>
<Accordion title="MiniMax Code" id="minimax-code">
diff --git a/apps/docs/content/docs/install-agent-runtime.ja.mdx b/apps/docs/content/docs/install-agent-runtime.ja.mdx
index 35ee8535f6..12888ca846 100644
--- a/apps/docs/content/docs/install-agent-runtime.ja.mdx
+++ b/apps/docs/content/docs/install-agent-runtime.ja.mdx
@@ -105,7 +105,9 @@ Node.js 20+ をインストールして `npm install -g @deepseek-ai/dsh` を実
**DSH Desktop。** npm パッケージではなく DeepSeek Harness Desktop をインストールした場合、デーモンはそのアプリが生成する CLI シムも、アプリ自身のユーザーデータディレクトリから探します。macOS は `~/Library/Application Support/DSH Desktop`、Windows は `%APPDATA%\DSH Desktop` です。Windows のそれはローミングのアプリケーションデータであり、インストール先ではありません。アプリ自体は Program Files または `%LOCALAPPDATA%\Programs` に入りますが、駆動される CLI はユーザーごとの他の状態と同じ場所に置かれます。これらのパスのバージョン部分は生成された ID なので、デーモンは列挙して最新のものを優先します。PATH に他のものは必要ありません。生成されたシムはアプリ同梱のランタイムを絶対パスで起動します。DSH Desktop が既定以外の場所にある場合は `MULTICA_DSH_PATH` でそのシムを指定してください。
-デーモンは `dsh --profile multica --probe` が成功した場合のみ DeepSeek Harness を登録し、失敗した場合は `/health` にプロファイルの欠落を報告します。
+**DSH のアップグレード後。** プローブがプロファイル内のコアパッケージの非互換を報告したら、デーモンの診断に示されたマニフェストをバックアップします。`@deepseek-ai/dsh-agent`、`@deepseek-ai/dsh-session`、`@deepseek-ai/dsh-tools`、`@deepseek-ai/dsh-llm` の上書きを確認し、可能ならアプリに付属するコアパッケージを使用するか、インストール済みの DSH と互換性のあるバージョンに揃えてください。必要な独立プラグインやフックは残し、依存関係をすべて削除しないでください。修復後に `dsh --profile multica --probe` を再実行します。Multica は確認済みの互換性拒否を手動修復が必要な状態として報告し、既存のプロファイルを上書きしません。
+
+デーモンは `dsh --profile multica --probe` が成功した場合のみ DeepSeek Harness を登録します。`/health` の診断では、プロファイルの欠落、確認済みの手動修復、プロトコルの非互換、プローブの一時的な利用不可を区別します。起動失敗時には、検出した CLI バージョン、マニフェストの場所、取得できた機密情報を除去した診断出力を示します。
</Accordion>
<Accordion title="MiniMax Code" id="minimax-code">
diff --git a/apps/docs/content/docs/install-agent-runtime.ko.mdx b/apps/docs/content/docs/install-agent-runtime.ko.mdx
index bb3211e550..f28769e71d 100644
--- a/apps/docs/content/docs/install-agent-runtime.ko.mdx
+++ b/apps/docs/content/docs/install-agent-runtime.ko.mdx
@@ -105,7 +105,9 @@ Node.js 20+를 설치하고 `npm install -g @deepseek-ai/dsh`를 실행한 뒤 M
**DSH Desktop.** npm 패키지 대신 DeepSeek Harness Desktop을 설치했다면, 데몬은 그 앱이 생성하는 CLI 심(shim)도 앱 자체의 사용자 데이터 디렉터리에서 찾습니다. macOS는 `~/Library/Application Support/DSH Desktop`, Windows는 `%APPDATA%\DSH Desktop`입니다. Windows의 이 경로는 로밍 애플리케이션 데이터이지 설치 디렉터리가 아닙니다. 앱 자체는 Program Files 또는 `%LOCALAPPDATA%\Programs`에 설치되지만, 앱이 구동하는 CLI는 사용자별 다른 상태와 함께 저장됩니다. 이 경로의 버전 구간은 생성된 id이므로 데몬이 열거하여 가장 최신 것을 우선합니다. `PATH`에 다른 것이 필요하지 않습니다. 생성된 심은 앱에 포함된 런타임을 절대 경로로 실행합니다. DSH Desktop이 기본이 아닌 위치에 있다면 `MULTICA_DSH_PATH`로 그 심을 지정하세요.
-데몬은 `dsh --profile multica --probe`가 성공한 경우에만 DeepSeek Harness를 등록하고, 실패하면 `/health`에 프로필 누락을 보고합니다.
+**DSH 업그레이드 후.** 프로브가 프로필 내부 코어 패키지의 비호환성을 보고하면 데몬 진단에 표시된 매니페스트를 백업하세요. `@deepseek-ai/dsh-agent`, `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-llm`의 재정의를 확인하고, 가능하면 앱에 포함된 코어 패키지를 사용하거나 설치된 DSH와 호환되는 버전으로 맞추세요. 필요한 독립 플러그인과 훅은 유지하고 모든 의존성을 삭제하지 마세요. 수정 후 `dsh --profile multica --probe`를 다시 실행하세요. Multica는 확인된 호환성 거부를 수동 프로필 복구가 필요한 상태로 보고하며 기존 프로필을 덮어쓰지 않습니다.
+
+데몬은 `dsh --profile multica --probe`가 성공한 경우에만 DeepSeek Harness를 등록합니다. `/health` 진단은 프로필 누락, 확인된 수동 복구 필요, 프로토콜 비호환, 프로브의 일시적 사용 불가를 구분합니다. 시작 실패 시 감지된 CLI 버전, 매니페스트 위치, 가능한 경우 민감 정보를 가린 진단 출력을 포함합니다.
</Accordion>
<Accordion title="MiniMax Code" id="minimax-code">
diff --git a/apps/docs/content/docs/install-agent-runtime.mdx b/apps/docs/content/docs/install-agent-runtime.mdx
index b86a5c9c91..450db871d8 100644
--- a/apps/docs/content/docs/install-agent-runtime.mdx
+++ b/apps/docs/content/docs/install-agent-runtime.mdx
@@ -131,7 +131,9 @@ Prefer a bundle your own team publishes or builds: this value is installed into
**DSH Desktop.** If you installed DeepSeek Harness Desktop instead of the npm package, the daemon also looks for the CLI shims that app generates, under its own per-user data directory — `~/Library/Application Support/DSH Desktop` on macOS, `%APPDATA%\DSH Desktop` on Windows. On Windows that is roaming application data, not the install directory: the app installs to Program Files or `%LOCALAPPDATA%\Programs`, but the CLI it drives lives beside its other per-user state. The version segment in those paths is a generated id, so the daemon enumerates them and prefers the newest. Nothing else is needed on `PATH` — a generated shim runs the Desktop app's own runtime by absolute path. If DSH Desktop is installed somewhere non-default, point `MULTICA_DSH_PATH` at the shim.
-The daemon registers DeepSeek Harness only after `dsh --profile multica --probe` succeeds, and reports the missing profile on `/health` when it does not.
+**After upgrading DSH.** If the probe reports incompatible profile-local core packages, back up the manifest named in the daemon diagnostic. Review overrides for `@deepseek-ai/dsh-agent`, `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools`, and `@deepseek-ai/dsh-llm`: use the application-supplied core packages where possible, or align overrides with the installed DSH version. Keep required independent plugins and hooks; do not delete every dependency. Run `dsh --profile multica --probe` again after repairing the profile. Multica reports this confirmed compatibility refusal as requiring manual profile repair and does not overwrite the existing profile.
+
+The daemon registers DeepSeek Harness only after `dsh --profile multica --probe` succeeds. Its `/health` diagnostic distinguishes a missing profile, confirmed manual profile repair, protocol incompatibility, and an unavailable probe. Startup failures include the detected CLI version, manifest location, and redacted diagnostic output when available.
</Accordion>
<Accordion title="Devin CLI" id="devin-cli">
diff --git a/apps/docs/content/docs/install-agent-runtime.zh-Hant.mdx b/apps/docs/content/docs/install-agent-runtime.zh-Hant.mdx
index dbdead2806..73105239ff 100644
--- a/apps/docs/content/docs/install-agent-runtime.zh-Hant.mdx
+++ b/apps/docs/content/docs/install-agent-runtime.zh-Hant.mdx
@@ -105,7 +105,9 @@ Multica 當前會檢測以下命令:
**DSH Desktop。** 裝的是 DeepSeek Harness Desktop 而不是 npm 包時,守護程序也會去找這個應用生成的 CLI shim,位置在它自己的使用者級資料目錄下:macOS 是 `~/Library/Application Support/DSH Desktop`,Windows 是 `%APPDATA%\DSH Desktop`。Windows 上這是漫遊應用資料目錄,不是安裝目錄:應用本身裝在 Program Files 或 `%LOCALAPPDATA%\Programs`,它驅動的 CLI 則和其他使用者級狀態放在一起。這些路徑裡的版本層是生成的 id,守護程序會逐個列舉,優先取最新的一份。PATH 上不需要別的東西,生成的 shim 會用絕對路徑呼叫應用自帶的執行時。DSH Desktop 裝在非預設位置時,用 `MULTICA_DSH_PATH` 指向那個 shim。
-守護程序只有在 `dsh --profile multica --probe` 成功後才註冊 DeepSeek Harness;失敗時會在 `/health` 報告缺少 profile。
+**升級 DSH 後。** 如果探測指出 profile 中的核心套件不相容,先備份守護程序診斷中列出的設定檔。檢查 `@deepseek-ai/dsh-agent`、`@deepseek-ai/dsh-session`、`@deepseek-ai/dsh-tools` 和 `@deepseek-ai/dsh-llm` 的本機覆寫:盡量使用應用程式內附的核心套件,或讓覆寫版本與已安裝的 DSH 版本一致。保留需要的獨立外掛和鉤子,不要刪除所有相依套件。修復後重新執行 `dsh --profile multica --probe`。Multica 會將這種已確認的相容性拒絕回報為需要手動修復 profile,不會覆寫現有設定。
+
+守護程序只有在 `dsh --profile multica --probe` 成功後才註冊 DeepSeek Harness。`/health` 診斷會區分 profile 缺失、已確認需要手動修復、協定不相容和探測暫時無法使用。啟動失敗時,診斷會包含偵測到的 CLI 版本、設定檔位置,以及可用的已遮蔽敏感資訊輸出。
</Accordion>
<Accordion title="Devin CLI" id="devin-cli">
diff --git a/apps/docs/content/docs/install-agent-runtime.zh.mdx b/apps/docs/content/docs/install-agent-runtime.zh.mdx
index 150da07db5..25e8d89f45 100644
--- a/apps/docs/content/docs/install-agent-runtime.zh.mdx
+++ b/apps/docs/content/docs/install-agent-runtime.zh.mdx
@@ -131,7 +131,9 @@ Multica 使用 `amp --execute --stream-json --executor local`,通过标准输
**DSH Desktop。** 装的是 DeepSeek Harness Desktop 而不是 npm 包时,守护进程也会去找这个应用生成的 CLI shim,位置在它自己的用户级数据目录下:macOS 是 `~/Library/Application Support/DSH Desktop`,Windows 是 `%APPDATA%\DSH Desktop`。Windows 上这是漫游应用数据目录,不是安装目录:应用本身装在 Program Files 或 `%LOCALAPPDATA%\Programs`,它驱动的 CLI 则和其他用户级状态放在一起。这些路径里的版本层是生成的 id,守护进程会逐个枚举,优先取最新的一份。PATH 上不需要别的东西,生成的 shim 会用绝对路径调用应用自带的运行时。DSH Desktop 装在非默认位置时,用 `MULTICA_DSH_PATH` 指向那个 shim。
-守护进程只有在 `dsh --profile multica --probe` 成功后才注册 DeepSeek Harness;失败时会在 `/health` 报告缺少 profile。
+**升级 DSH 后。** 如果探测提示 profile 中的核心包不兼容,先备份守护进程诊断中指出的配置文件。检查 `@deepseek-ai/dsh-agent`、`@deepseek-ai/dsh-session`、`@deepseek-ai/dsh-tools` 和 `@deepseek-ai/dsh-llm` 的本地覆盖:尽量使用应用自带的核心包,或让覆盖版本与已安装的 DSH 版本匹配。保留需要的独立插件和钩子,不要删除所有依赖。修复后重新运行 `dsh --profile multica --probe`。Multica 会将这种已确认的兼容性拒绝报告为需要手动修复 profile,不会覆盖现有配置。
+
+守护进程只有在 `dsh --profile multica --probe` 成功后才注册 DeepSeek Harness。`/health` 诊断会区分 profile 缺失、已确认需要手动修复、协议不兼容和探测暂时不可用。启动失败时,诊断会包含检测到的 CLI 版本、配置文件位置,以及可用的脱敏输出。
</Accordion>
<Accordion title="MiniMax Code" id="minimax-code">
diff --git a/server/internal/daemon/agents_probe.go b/server/internal/daemon/agents_probe.go
index 0ec940a3cf..74783eccd5 100644
--- a/server/internal/daemon/agents_probe.go
+++ b/server/internal/daemon/agents_probe.go
@@ -1,8 +1,11 @@
package daemon
import (
+ "bytes"
"context"
"encoding/json"
+ "errors"
+ "fmt"
"os"
"os/exec"
"path/filepath"
@@ -424,7 +427,7 @@ type dshProbeVerdict int
const (
// dshProbeOK: the profile answered with the protocol version this backend drives.
dshProbeOK dshProbeVerdict = iota
- // A configured bridge must be migrated manually, never provisioned over.
+ // An existing profile needs manual repair, never provisioning over it.
dshProbeNeedsMigration
// dshProbeMissingProfile: the manifest does not name the Multica runtime.
// A file that merely exists is not enough — a refused install leaves one.
@@ -439,6 +442,12 @@ const (
dshProbeUnavailable
)
+type dshProbeResult struct {
+ verdict dshProbeVerdict
+ detail string
+ repairSummary string
+}
+
// dshProbeTimeout bounds one `--probe`.
//
// The healthy path boots a whole DSH process — on a Desktop install that means
@@ -476,20 +485,20 @@ func parseDshProbeFrame(output string) (dshProbeFrame, bool) {
// Scoped to the caller's context as well as its own timeout: `--probe` boots a
// whole DSH process, and a round abandoned by a shutting-down daemon should not
// go on holding one for the rest of the timeout — once per retry, per provider.
-func probeDshMulticaProfile(ctx context.Context, executablePath string) dshProbeVerdict {
+func probeDshMulticaProfile(ctx context.Context, executablePath string) dshProbeResult {
// A cancelled round says nothing about the profile, and it must be decided
// before the manifest: a shutdown is not evidence the profile is missing.
if ctx.Err() != nil {
- return dshProbeUnavailable
+ return dshProbeResult{verdict: dshProbeUnavailable}
}
if dshMulticaProfileNeedsMigration() {
- return dshProbeNeedsMigration
+ return dshProbeResult{verdict: dshProbeNeedsMigration}
}
// A manifest that does not name the runtime is missing. Decide that before
// starting dsh: on current DSH, --probe against the skeleton a refused
// install leaves hangs until this timeout, and the file is already the answer.
if !dshMulticaProfilePresent() {
- return dshProbeMissingProfile
+ return dshProbeResult{verdict: dshProbeMissingProfile}
}
parent := ctx
@@ -501,7 +510,12 @@ func probeDshMulticaProfile(ctx context.Context, executablePath string) dshProbe
// grandchildren holding the stdout pipe open — which is both a leaked
// process and, as this probe's own tests showed, a wait that outlives the
// timeout it was supposed to be bounded by.
- output, _ := processtree.Output(ctx, cmd, time.Second)
+ // Keep protocol stdout separate from diagnostics: stderr must never turn
+ // a failed startup into an affirmative probe response. Run uses the same
+ // ownership/lifetime as Output, while retaining stderr on timeout too.
+ var stdout, stderr bytes.Buffer
+ cmd.Stdout, cmd.Stderr = &stdout, &stderr
+ runErr := processtree.Run(ctx, cmd, time.Second)
// The frame decides, not the exit status. A profile that printed a valid
// answer has answered, whatever the process did on its way out — and the
@@ -511,18 +525,18 @@ func probeDshMulticaProfile(ctx context.Context, executablePath string) dshProbe
// agent.DshProtocolVersion, not a local copy: this decides whether the
// daemon may drive the profile, and the code that drives it is the only
// honest source for that number.
- if frame, ok := parseDshProbeFrame(string(output)); ok {
+ if frame, ok := parseDshProbeFrame(stdout.String()); ok {
if frame.Version == 1 && frame.Runtime == "dsh" && frame.ProtocolVersion == agent.DshProtocolVersion {
- return dshProbeOK
+ return dshProbeResult{verdict: dshProbeOK}
}
- return dshProbeIncompatible
+ return dshProbeResult{verdict: dshProbeIncompatible}
}
// No usable answer. A cancelled ROUND is the one case that says nothing
// about the profile: the daemon is shutting down, or this round was
// abandoned, and the probe never got to finish on its own terms.
if parent.Err() != nil {
- return dshProbeUnavailable
+ return dshProbeResult{verdict: dshProbeUnavailable, detail: dshProbeDiagnostic(runErr, stdout.Bytes(), stderr.Bytes())}
}
// Otherwise the manifest decides, and how the probe failed does not.
@@ -538,10 +552,22 @@ func probeDshMulticaProfile(ctx context.Context, executablePath string) dshProbe
//
// The manifest is the same file DSH's own loadProfile consults before it
// refuses to boot, so a confirmed-absent one is evidence, not a guess —
- // while a manifest that IS present keeps every failure transient, which is
- // what protects a working install from being overwritten during an upgrade.
+ // A present manifest must never authorize installation. Unknown failures
+ // stay transient; a completed core-compatibility refusal below is manual
+ // repair and uses the existing confirmation lifecycle before demotion.
if !dshMulticaProfilePresent() {
- return dshProbeMissingProfile
+ return dshProbeResult{verdict: dshProbeMissingProfile}
+ }
+ detail := dshProbeDiagnostic(runErr, stdout.Bytes(), stderr.Bytes())
+ var exitErr *exec.ExitError
+ completed := runErr == nil || (errors.As(runErr, &exitErr) && exitErr.ProcessState.Exited())
+ if ctx.Err() == nil && completed {
+ if summary := dshCoreCompatibilitySummary(stderr.String()); summary != "" {
+ repairSummary := fmt.Sprintf(
+ "%s; back up and inspect %q to align profile-local DSH core dependencies with the application packages, retain required independent plugins, and rerun dsh --profile multica --probe.",
+ summary, dshMulticaProfileManifestPath())
+ return dshProbeResult{verdict: dshProbeNeedsMigration, repairSummary: repairSummary, detail: repairSummary + " " + detail}
+ }
}
- return dshProbeUnavailable
+ return dshProbeResult{verdict: dshProbeUnavailable, detail: detail}
}
diff --git a/server/internal/daemon/agents_probe_dsh_test.go b/server/internal/daemon/agents_probe_dsh_test.go
index 040d44aa91..52d8183421 100644
--- a/server/internal/daemon/agents_probe_dsh_test.go
+++ b/server/internal/daemon/agents_probe_dsh_test.go
@@ -140,7 +140,7 @@ func TestProbeDshMulticaProfile(t *testing.T) {
path := dshProbeFixture(t, `exec sleep 30`, false)
ctx, cancel := context.WithCancel(context.Background())
cancel()
- if got := probeDshMulticaProfile(ctx, path); got != dshProbeUnavailable {
+ if got := probeDshMulticaProfile(ctx, path).verdict; got != dshProbeUnavailable {
t.Fatalf("probeDshMulticaProfile() = %v, want %v", got, dshProbeUnavailable)
}
})
@@ -151,7 +151,7 @@ func TestProbeDshMulticaProfile(t *testing.T) {
shortenDshProbeTimeoutForHang(t)
}
path := dshProbeFixture(t, tc.body, tc.manifest)
- if got := probeDshMulticaProfile(context.Background(), path); got != tc.want {
+ if got := probeDshMulticaProfile(context.Background(), path).verdict; got != tc.want {
t.Fatalf("probeDshMulticaProfile() = %v, want %v", got, tc.want)
}
})
@@ -179,7 +179,7 @@ func TestProbeDshMulticaProfile(t *testing.T) {
t.Fatal(err)
}
start := time.Now()
- if got := probeDshMulticaProfile(context.Background(), path); got != dshProbeMissingProfile {
+ if got := probeDshMulticaProfile(context.Background(), path).verdict; got != dshProbeMissingProfile {
t.Fatalf("probeDshMulticaProfile() = %v, want missing", got)
}
if time.Since(start) > time.Second {
@@ -210,7 +210,7 @@ func TestProbeDshMulticaProfile(t *testing.T) {
if err := os.WriteFile(path, []byte(script), 0o755); err != nil {
t.Fatal(err)
}
- if got := probeDshMulticaProfile(context.Background(), path); got != dshProbeUnavailable {
+ if got := probeDshMulticaProfile(context.Background(), path).verdict; got != dshProbeUnavailable {
t.Fatalf("probeDshMulticaProfile() = %v, want unavailable", got)
}
if _, err := os.Stat(marker); err != nil {
@@ -265,8 +265,9 @@ func TestProbeBuiltinRuntime_DshFailureWithProfileInstalledIsNotCondemned(t *tes
logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
agentVersions: map[string]string{},
}
- _, reason, verdict := d.probeBuiltinRuntime(context.Background(), "dsh",
+ probe := d.probeBuiltinRuntime(context.Background(), "dsh",
AgentEntry{Path: path, Command: "dsh"})
+ reason, verdict := probe.reason, probe.verdict
if verdict == builtinProbeMissingProfile {
t.Fatalf("verdict = missing profile (reason %q); a failing probe over an installed profile must not be installable", reason)
@@ -359,8 +360,9 @@ func TestProbeBuiltinRuntime_DshWithoutMulticaProfile(t *testing.T) {
logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
agentVersions: map[string]string{},
}
- _, reason, verdict := d.probeBuiltinRuntime(
+ probe := d.probeBuiltinRuntime(
context.Background(), "dsh", AgentEntry{Path: path, Command: "dsh"})
+ reason, verdict := probe.reason, probe.verdict
if verdict != tc.wantVerdict {
t.Fatalf("verdict = %v, want %v (reason %q)", verdict, tc.wantVerdict, reason)
}
@@ -382,8 +384,9 @@ func TestProbeBuiltinRuntime_DshBinaryGoneIsNotAProfileVerdict(t *testing.T) {
agentVersions: map[string]string{},
}
gone := filepath.Join(t.TempDir(), "dsh-that-was-removed")
- _, reason, verdict := d.probeBuiltinRuntime(context.Background(), "dsh",
+ probe := d.probeBuiltinRuntime(context.Background(), "dsh",
AgentEntry{Path: gone, Command: ""})
+ reason, verdict := probe.reason, probe.verdict
if verdict == builtinProbeMissingProfile {
t.Fatalf("verdict = missing profile (reason %q), want the version-detection path to report the vanished binary", reason)
}
@@ -495,8 +498,9 @@ func TestProbeBuiltinRuntime_DshThatCannotRunIsNotAProfileVerdict(t *testing.T)
logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
agentVersions: map[string]string{},
}
- _, reason, verdict := d.probeBuiltinRuntime(context.Background(), "dsh",
+ probe := d.probeBuiltinRuntime(context.Background(), "dsh",
AgentEntry{Path: path, Command: "dsh"})
+ reason, verdict := probe.reason, probe.verdict
if verdict == builtinProbeMissingProfile {
t.Fatalf("verdict = missing profile (reason %q); the CLI cannot run at all, "+
@@ -533,7 +537,7 @@ func TestNewRuntimeVerdict_DshProfileCarriesAStructuredCause(t *testing.T) {
{name: "missing, install running", verdict: builtinProbeMissingProfile, installing: true},
} {
t.Run(tc.name, func(t *testing.T) {
- got := newRuntimeVerdict(tc.verdict, "explained elsewhere", "/usr/local/bin/dsh", tc.installing)
+ got := newRuntimeVerdict(builtinProbeResult{verdict: tc.verdict, reason: "explained elsewhere"}, "/usr/local/bin/dsh", tc.installing)
if got.offline == nil {
t.Fatal("offline reason is nil: the server would treat this as a machine that is merely offline")
}
@@ -581,7 +585,8 @@ func TestProbeBuiltinRuntime_DshLegacyProfile(t *testing.T) {
writeDshProfileManifest(t, home, manifest)
t.Setenv(dshProfileBundleEnv, "@multica-ai/dsh-runtime")
d := &Daemon{logger: slog.New(slog.NewTextHandler(io.Discard, nil)), agentVersions: map[string]string{}}
- _, reason, verdict := d.probeBuiltinRuntime(context.Background(), "dsh", AgentEntry{Path: path, Command: "dsh"})
+ probe := d.probeBuiltinRuntime(context.Background(), "dsh", AgentEntry{Path: path, Command: "dsh"})
+ reason, verdict := probe.reason, probe.verdict
if verdict != builtinProbeProfileMigration || !demotableBuiltinProbeVerdict(verdict) {
t.Fatalf("profile verdict = %v, want demotable migration", verdict)
}
diff --git a/server/internal/daemon/agents_probe_hermes_unix_test.go b/server/internal/daemon/agents_probe_hermes_unix_test.go
index 352747a676..eab38c912a 100644
--- a/server/internal/daemon/agents_probe_hermes_unix_test.go
+++ b/server/internal/daemon/agents_probe_hermes_unix_test.go
@@ -34,8 +34,9 @@ echo "Hermes Agent v0.22.5 (2026.9.24)"
logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
agentVersions: map[string]string{},
}
- version, reason, verdict := d.probeBuiltinRuntime(context.Background(), "hermes",
+ probe := d.probeBuiltinRuntime(context.Background(), "hermes",
AgentEntry{Path: path, Command: "hermes"})
+ version, reason, verdict := probe.version, probe.reason, probe.verdict
if verdict != builtinProbeOK {
t.Fatalf("verdict = %v (reason %q), want OK", verdict, reason)
}
diff --git a/server/internal/daemon/client.go b/server/internal/daemon/client.go
index add81377ba..8fc55152b4 100644
--- a/server/internal/daemon/client.go
+++ b/server/internal/daemon/client.go
@@ -1190,10 +1190,9 @@ const RuntimeOfflineCodeNotExecutable = "not_executable"
// queued forever. The exception is an install the daemon is running right now,
// which Installing states explicitly.
//
-// Only an ABSENT profile reaches this code. A profile that is present but
-// answers with a protocol this daemon does not drive never takes a live runtime
-// offline at all: the daemon can be the stale side of that skew, so it reports
-// the incompatibility and leaves the runtime alone.
+// Missing profiles and confirmed manual-repair configurations reach this code.
+// A profile that answers with a protocol this daemon does not drive remains
+// non-demotable: the daemon can be the stale side of that separate skew.
const RuntimeOfflineCodeDshProfile = "dsh_profile"
// RuntimeOfflineReason is why a runtime went offline, in the form clients can
diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.go
index 41f759267b..fa176fae17 100644
--- a/server/internal/daemon/daemon.go
+++ b/server/internal/daemon/daemon.go
@@ -2516,7 +2516,8 @@ type runtimeVerdict struct {
// a file the OS refuses to execute is present, so the self-heal that would have
// re-resolved a vanished path never runs, and the probe failed on this exact
// file.
-func newRuntimeVerdict(verdict builtinProbeVerdict, reason, execPath string, installing bool) runtimeVerdict {
+func newRuntimeVerdict(probe builtinProbeResult, execPath string, installing bool) runtimeVerdict {
+ verdict, reason := probe.verdict, probe.reason
switch verdict {
case builtinProbeNotExecutable:
offline := &RuntimeOfflineReason{Code: RuntimeOfflineCodeNotExecutable, Detail: reason}
@@ -2532,9 +2533,13 @@ func newRuntimeVerdict(verdict builtinProbeVerdict, reason, execPath string, ins
// running right now, which is stated explicitly instead of being
// implied by an absent reason — and withdrawn by
// withdrawDshInstallWait if that install gives up.
+ detail := reason
+ if probe.offlineDetail != "" {
+ detail = probe.offlineDetail
+ }
offline := &RuntimeOfflineReason{
Code: RuntimeOfflineCodeDshProfile,
- Detail: reason,
+ Detail: detail,
Installing: installing && verdict != builtinProbeProfileMigration,
}
repair := dshProfileRepair()
@@ -2544,6 +2549,15 @@ func newRuntimeVerdict(verdict builtinProbeVerdict, reason, execPath string, ins
return runtimeVerdict{reason: reason}
}
+// builtinProbeResult keeps local diagnostics separate from durable repair data.
+// offlineDetail contains only a constructed repair summary, never provider output.
+type builtinProbeResult struct {
+ version string
+ reason string
+ verdict builtinProbeVerdict
+ offlineDetail string
+}
+
// probeBuiltinRuntime resolves and version-detects one built-in provider,
// retrying a fast failure up to runtimeVersionProbeAttempts times. The verdict
// tells the caller how to treat a drop: builtinProbeUnavailable means the
@@ -2553,16 +2567,17 @@ func newRuntimeVerdict(verdict builtinProbeVerdict, reason, execPath string, ins
// the same way, for a CLI that runs but whose backend has no runtime profile
// installed. See builtinProbeVerdict.
//
-// The second return value is a short human-readable reason when the verdict is
-// not OK. It is surfaced on /health as skipped_agents so a user can tell "CLI
+// The result carries a short human-readable reason when the verdict is not OK.
+// It is surfaced on /health as skipped_agents so a user can tell "CLI
// not installed" apart from "CLI installed but dropped at registration", which
// was previously only visible in the daemon log (MUL-5439).
-func (d *Daemon) probeBuiltinRuntime(ctx context.Context, name string, entry AgentEntry) (string, string, builtinProbeVerdict) {
+func (d *Daemon) probeBuiltinRuntime(ctx context.Context, name string, entry AgentEntry) builtinProbeResult {
// museapp has no local binary: version detection runs against the remote
// receptionist instead. This must come before any path resolution — an
// empty entry.Path is expected here, not a missing CLI.
if name == "museapp" {
- return d.probeMuseAppReceptionist(ctx)
+ version, reason, verdict := d.probeMuseAppReceptionist(ctx)
+ return builtinProbeResult{version: version, reason: reason, verdict: verdict}
}
var (
lastErr error
@@ -2630,7 +2645,7 @@ probeLoop:
}
d.logger.Warn("skip registering runtime: re-resolved version too old",
"name", name, "version", heal.rejected.Detected, "error", heal.rejected.Error())
- return heal.rejected.Detected, heal.rejected.Error(), builtinProbeBelowMinimum
+ return builtinProbeResult{version: heal.rejected.Detected, reason: heal.rejected.Error(), verdict: builtinProbeBelowMinimum}
}
version, err := detectAgentVersion(ctx, agent.Command{Path: resolved.Path}.ForVersionProbe(name))
if err != nil {
@@ -2651,7 +2666,7 @@ probeLoop:
d.logger.Warn("skip registering runtime: version too old", "name", name, "version", version, "error", err)
// The version is returned even though the provider is dropped: the
// caller needs it to report what it demoted.
- return version, err.Error(), builtinProbeBelowMinimum
+ return builtinProbeResult{version: version, reason: err.Error(), verdict: builtinProbeBelowMinimum}
}
// The CLI ran but printed something (or nothing) the gate could not
// parse. That is "we didn't learn a version", not "we verified it is
@@ -2698,12 +2713,19 @@ probeLoop:
// daemon may be the stale side of the skew. A probe that merely
// failed is transient, on the same rule every other provider's
// version probe gets.
- switch probeDshMulticaProfile(ctx, resolved.Path) {
+ profileProbe := probeDshMulticaProfile(ctx, resolved.Path)
+ switch profileProbe.verdict {
case dshProbeOK:
case dshProbeNeedsMigration:
+ reason := dshProfileMigrationReason
+ offlineDetail := reason
+ if profileProbe.detail != "" {
+ reason = fmt.Sprintf("DSH %s: %s", dshDiagnosticOutput([]byte(version)), profileProbe.detail)
+ offlineDetail = fmt.Sprintf("DSH %s: %s", dshDiagnosticOutput([]byte(version)), profileProbe.repairSummary)
+ }
d.logger.Warn("skip registering runtime: DSH Multica runtime profile needs manual migration",
- "name", name, "path", resolved.Path)
- return "", dshProfileMigrationReason, builtinProbeProfileMigration
+ "name", name, "path", resolved.Path, "error", reason)
+ return builtinProbeResult{version: "", reason: reason, verdict: builtinProbeProfileMigration, offlineDetail: offlineDetail}
case dshProbeMissingProfile:
d.logger.Warn("skip registering runtime: DSH Multica runtime profile is not installed",
"name", name, "path", resolved.Path)
@@ -2711,19 +2733,22 @@ probeLoop:
if d.startDshProfileProvision(resolved.Path) {
reason = dshProfileInstallStartedReason
}
- return "", reason, builtinProbeMissingProfile
+ return builtinProbeResult{version: "", reason: reason, verdict: builtinProbeMissingProfile}
case dshProbeIncompatible:
d.logger.Warn("skip registering runtime: DSH Multica runtime profile speaks another protocol",
"name", name, "path", resolved.Path)
- return "", dshIncompatibleProfileReason, builtinProbeIncompatibleProfile
+ return builtinProbeResult{version: "", reason: dshIncompatibleProfileReason, verdict: builtinProbeIncompatibleProfile}
default:
// Transient. Retry inside this round's budget, then leave the
// loop for the tail, which reports it as the transient drop it
// is. The labelled break matters: a bare one would leave only
// the switch and fall through to registering a runtime whose
// profile answered nothing.
- lastErr = errors.New(dshProbeFailedReason)
- transientReason = dshProbeFailedReason
+ transientReason = fmt.Sprintf("%s (DSH %s; profile %q)", dshProbeFailedReason, dshDiagnosticOutput([]byte(version)), dshMulticaProfileManifestPath())
+ if profileProbe.detail != "" {
+ transientReason += ": " + profileProbe.detail
+ }
+ lastErr = errors.New(transientReason)
if time.Since(startedAt) >= runtimeVersionProbeRetryWindow {
break probeLoop
}
@@ -2746,7 +2771,7 @@ probeLoop:
version = d.agentVersion(name)
}
d.logger.Debug("agent version detected", "name", name, "version", version, "path", resolved.Path)
- return version, "", builtinProbeOK
+ return builtinProbeResult{version: version, reason: "", verdict: builtinProbeOK}
}
// The OS refusing to execute the file is not a failed probe, it is a
// finding: the CLI is installed, resolvable, and unrunnable. Report it as
@@ -2757,7 +2782,7 @@ probeLoop:
if agent.IsExecFormatError(lastErr) {
d.logger.Warn("skip registering runtime: agent CLI is not executable on this machine",
"name", name, "attempts", attempts, "error", lastErr)
- return "", fmt.Sprintf("agent CLI is not executable: %v", lastErr), builtinProbeNotExecutable
+ return builtinProbeResult{version: "", reason: fmt.Sprintf("agent CLI is not executable: %v", lastErr), verdict: builtinProbeNotExecutable}
}
d.logger.Warn("skip registering runtime", "name", name, "attempts", attempts, "error", lastErr)
@@ -2768,7 +2793,7 @@ probeLoop:
if transientReason != "" {
reason = transientReason
}
- return "", reason, builtinProbeUnavailable
+ return builtinProbeResult{version: "", reason: reason, verdict: builtinProbeUnavailable}
}
// probeMuseAppReceptionist is the museapp equivalent of CLI version detection.
@@ -2831,7 +2856,8 @@ func (d *Daemon) detectBuiltinRuntimes(ctx context.Context) ([]map[string]string
for name, entry := range d.agents() {
name, entry := name, entry
g.Go(func() error {
- version, reason, verdict := d.probeBuiltinRuntime(ctx, name, entry)
+ probe := d.probeBuiltinRuntime(ctx, name, entry)
+ version, reason, verdict := probe.version, probe.reason, probe.verdict
if verdict != builtinProbeOK {
demote := demotableBuiltinProbeVerdict(verdict) &&
(!builtinProbeNeedsConfirmation(verdict) ||
@@ -2839,7 +2865,7 @@ func (d *Daemon) detectBuiltinRuntimes(ctx context.Context) ([]map[string]string
mu.Lock()
skipped[name] = reason
if demote {
- demotable[name] = newRuntimeVerdict(verdict, reason, entry.Path, d.dshInstallInFlight.Load())
+ demotable[name] = newRuntimeVerdict(probe, entry.Path, d.dshInstallInFlight.Load())
} else {
unavailable[name] = reason
}
diff --git a/server/internal/daemon/dsh_probe_diagnostics.go b/server/internal/daemon/dsh_probe_diagnostics.go
new file mode 100644
index 0000000000..746732330d
--- /dev/null
+++ b/server/internal/daemon/dsh_probe_diagnostics.go
@@ -0,0 +1,40 @@
+package daemon
+
+import (
+ "fmt"
+ "regexp"
+ "strings"
+)
+
+// DSH's admission preflight writes this format before plugin logging starts.
+// Restrict it to the core packages implicated in profile-local version skew;
+// an optional plugin's warning does not establish an unusable runtime.
+// Source: deepseek-harness dsh-v0.2.2-rc.3, compatibility-preflight.ts and
+// plugin-compatibility.ts in packages/boot/app-boot/src.
+var dshCoreCompatibilityRefusal = regexp.MustCompile(`^[^\r\n]*: disabling profile plugin [^\r\n]+: Plugin (@deepseek-ai/dsh-(?:agent|session|tools|llm))@([0-9][0-9A-Za-z.+-]{0,79}) is incompatible with dsh ([0-9][0-9A-Za-z.+-]{0,79}): requirements `)
+
+func dshCoreCompatibilitySummary(stderr string) string {
+ for _, line := range strings.Split(stderr, "\n") {
+ if match := dshCoreCompatibilityRefusal.FindStringSubmatch(strings.TrimSpace(line)); match != nil {
+ return dshDiagnosticOutput([]byte(fmt.Sprintf("%s@%s is incompatible with DSH %s", match[1], match[2], match[3])))
+ }
+ }
+ return ""
+}
+
+func dshProbeDiagnostic(err error, stdout, stderr []byte) string {
+ var parts []string
+ if err != nil {
+ parts = append(parts, err.Error())
+ }
+ if len(stdout) != 0 {
+ parts = append(parts, "stdout: "+string(stdout))
+ }
+ if len(stderr) != 0 {
+ parts = append(parts, "stderr: "+string(stderr))
+ }
+ if len(parts) == 0 {
+ parts = append(parts, "probe exited without a protocol frame")
+ }
+ return dshDiagnosticOutput([]byte(strings.Join(parts, "\n")))
+}
diff --git a/server/internal/daemon/dsh_profile.go b/server/internal/daemon/dsh_profile.go
index d12b07e65f..4050c7745f 100644
--- a/server/internal/daemon/dsh_profile.go
+++ b/server/internal/daemon/dsh_profile.go
@@ -273,21 +273,25 @@ const dshProvisionOutputBytes = 2048
// colon and an @ before the next path separator, so "https://host:8443/p" and
// "ssh://git@host/p" are left alone.
//
-// Local to provisioning rather than added to pkg/redact's shared pattern list.
+// Local to DSH diagnostics rather than added to pkg/redact's shared pattern list.
// redact.Text runs over every agent's task messages, comments and error text, so
// a rule added there changes output for every provider; the case that needs it
// here is one package manager's error text, and widening a shared filter is its
// own change with its own blast radius.
var dshProvisionURLCredentials = regexp.MustCompile(`(?i)\b([a-z][a-z0-9+.\-]*)://[^/?#\s:@]+:[^/?#\s@]+@`)
-// dshProvisionOutput renders captured output for a log line. Registry errors
+// Quoted credential fields also occur inside prefixed JSON diagnostic lines.
+var dshQuotedCredential = regexp.MustCompile(`(?i)("(?:api[_-]?key|api[_-]?secret|secret[_-]?key|secret|access[_-]?token|auth[_-]?token|refresh[_-]?token|client[_-]?secret|private[_-]?key|database[_-]?url|db[_-]?(?:password|url)|redis[_-]?url|password|token|authorization)"\s*:\s*)"(?:\\.|[^"\\])*"`)
+
+// dshDiagnosticOutput renders captured probe/install diagnostics. Registry errors
// routinely echo the request URL back, so URL credentials are scrubbed and the
// shared redactor still runs for the token shapes it knows, before the text is
// bounded.
-func dshProvisionOutput(raw []byte) string {
+func dshDiagnosticOutput(raw []byte) string {
text := dshProvisionURLCredentials.ReplaceAllString(
- strings.TrimSpace(string(raw)), "$1://[REDACTED URL CREDENTIALS]@")
- text = redact.Text(text)
+ strings.ToValidUTF8(strings.TrimSpace(string(raw)), "�"), "$1://[REDACTED URL CREDENTIALS]@")
+ text = dshQuotedCredential.ReplaceAllString(text, `${1}"[REDACTED CREDENTIAL]"`)
+ text = strings.ReplaceAll(redact.Text(text), "\x00", "")
if len(text) <= dshProvisionOutputBytes {
return text
}
@@ -297,7 +301,7 @@ func dshProvisionOutput(raw []byte) string {
// produces is an invalid-UTF-8 log line, which downstream JSON encoders
// rewrite into replacement characters.
tail := text[len(text)-dshProvisionOutputBytes:]
- for len(tail) > 0 && !utf8.ValidString(tail[:1]) {
+ for len(tail) > 0 && !utf8.RuneStart(tail[0]) {
tail = tail[1:]
}
return "…" + tail
@@ -360,6 +364,14 @@ func provisionDshMulticaProfile(ctx context.Context, dshPath string, logger *slo
var lastErr error
for i, spec := range specs {
+ // A profile may appear after discovery or after a failed candidate.
+ // Never continue installation over a now-populated profile.
+ if dshMulticaProfileNeedsMigration() {
+ return fmt.Errorf("%s", dshProfileMigrationReason)
+ }
+ if dshMulticaProfilePresent() {
+ return lastErr
+ }
output, err := processtree.CombinedOutput(ctx, dshProvisionCommand(dshPath, spec), 5*time.Second)
switch {
case err == nil && dshMulticaProfilePresent():
@@ -382,10 +394,10 @@ func provisionDshMulticaProfile(ctx context.Context, dshPath string, logger *slo
// done the job, and stopping on it would hide a later spec that
// would have.
lastErr = fmt.Errorf("dsh plugin --profile %s add (candidate %d of %d): reported success without creating the profile: %s",
- dshMulticaProfileName, i+1, len(specs), dshProvisionOutput(output))
+ dshMulticaProfileName, i+1, len(specs), dshDiagnosticOutput(output))
default:
lastErr = fmt.Errorf("dsh plugin --profile %s add (candidate %d of %d): %w: %s",
- dshMulticaProfileName, i+1, len(specs), err, dshProvisionOutput(output))
+ dshMulticaProfileName, i+1, len(specs), err, dshDiagnosticOutput(output))
}
// Leave the directory. A refused add can write a skeleton, and a failure
// can also land on a profile the user already had. dshMulticaProfilePresent
diff --git a/server/internal/daemon/dsh_profile_diagnostics_test.go b/server/internal/daemon/dsh_profile_diagnostics_test.go
new file mode 100644
index 0000000000..1aa2ac9dc2
--- /dev/null
+++ b/server/internal/daemon/dsh_profile_diagnostics_test.go
@@ -0,0 +1,252 @@
+package daemon
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "fmt"
+ "io"
+ "log/slog"
+ "os"
+ "path/filepath"
+ "runtime"
+ "strings"
+ "testing"
+ "time"
+)
+
+// This admission diagnostic is emitted by the reported DSH 0.2.2-rc.3 tag.
+// No actual DSH installation, credentials or model are used by these fixtures.
+const dshCoreCompatibilityFixture = `dsh: disabling profile plugin row "agents": Plugin @deepseek-ai/[email protected] is incompatible with dsh 0.2.2-rc.3: requirements {"engines.dsh":"0.2.2-rc.1"}.`
+
+func TestProbeBuiltinRuntimeDshRetainsStartupDiagnosis(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("POSIX fake CLI; classification tests are platform independent")
+ }
+ originalDelay, originalWindow := runtimeVersionProbeRetryDelay, runtimeVersionProbeRetryWindow
+ t.Cleanup(func() { runtimeVersionProbeRetryDelay, runtimeVersionProbeRetryWindow = originalDelay, originalWindow })
+ runtimeVersionProbeRetryDelay = time.Millisecond
+ runtimeVersionProbeRetryWindow = 10 * time.Millisecond
+ for _, tc := range []struct {
+ name, stderr string
+ want builtinProbeVerdict
+ }{
+ {"confirmed core compatibility", dshCoreCompatibilityFixture, builtinProbeProfileMigration},
+ {"unclassified startup failure", "permission denied opening profile cache", builtinProbeUnavailable},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ path := dshProbeFixture(t, "exit 1", true)
+ manifestPath := dshMulticaProfileManifestPath()
+ data, err := os.ReadFile(manifestPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var manifest map[string]any
+ if err := json.Unmarshal(data, &manifest); err != nil {
+ t.Fatal(err)
+ }
+ manifest["dependencies"] = map[string]string{"@deepseek-ai/dsh-agent": "0.2.2-rc.1", "independent-required-hook": "1.2.3"}
+ before, err := json.Marshal(manifest)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(manifestPath, before, 0600); err != nil {
+ t.Fatal(err)
+ }
+ marker := filepath.Join(t.TempDir(), "provisioned")
+ t.Setenv(dshProfileBundleEnv, "@multica-ai/dsh-runtime")
+ t.Setenv("DSH_DIAGNOSTIC_INSTALL_MARKER", marker)
+ script := "#!/bin/sh\ncase \"$*\" in\n" +
+ "*--version*) printf '%s\\n' '0.2.2-rc.3' ;;\n" +
+ "*--probe*) printf '%s\\n' '" + tc.stderr + "' >&2; exit 1 ;;\n" +
+ "plugin*) printf installed > \"$DSH_DIAGNOSTIC_INSTALL_MARKER\"; exit 1 ;;\n" +
+ "*) exit 2 ;;\nesac\n"
+ if err := os.WriteFile(path, []byte(script), 0755); err != nil {
+ t.Fatal(err)
+ }
+ d := &Daemon{logger: slog.New(slog.NewTextHandler(io.Discard, nil)), agentVersions: map[string]string{}}
+ probe := d.probeBuiltinRuntime(context.Background(), "dsh", AgentEntry{Path: path, Command: "dsh"})
+ reason, verdict := probe.reason, probe.verdict
+ if verdict != tc.want {
+ t.Errorf("verdict=%v, want %v", verdict, tc.want)
+ }
+ for _, part := range []string{tc.stderr[:min(70, len(tc.stderr))], "0.2.2-rc.3", manifestPath} {
+ if !strings.Contains(reason, part) {
+ t.Errorf("startup reason lost %q: %q", part, reason)
+ }
+ }
+ if tc.want == builtinProbeProfileMigration && !builtinProbeNeedsConfirmation(verdict) {
+ t.Error("profile repair bypassed confirmation")
+ }
+ after, err := os.ReadFile(manifestPath)
+ if err != nil || !bytes.Equal(before, after) {
+ t.Fatalf("existing profile changed: %v", err)
+ }
+ time.Sleep(50 * time.Millisecond)
+ if _, err := os.Stat(marker); !os.IsNotExist(err) {
+ t.Fatalf("provisioning ran for an existing profile: %v", err)
+ }
+ })
+ }
+}
+
+func TestDshProfileDiagnosticClassification(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("POSIX fake CLI")
+ }
+ healthy := `{"v":1,"type":"probe","runtime":"dsh","protocol_version":1}`
+ future := `{"v":2,"type":"probe","runtime":"dsh","protocol_version":2}`
+ for _, tc := range []struct {
+ name, stdout, stderr string
+ code int
+ hangs bool
+ want dshProbeVerdict
+ }{
+ {"core agent", "", dshCoreCompatibilityFixture, 1, false, dshProbeNeedsMigration},
+ {"core session", "", strings.ReplaceAll(dshCoreCompatibilityFixture, "dsh-agent", "dsh-session"), 1, false, dshProbeNeedsMigration},
+ {"core tools", "", strings.ReplaceAll(dshCoreCompatibilityFixture, "dsh-agent", "dsh-tools"), 1, false, dshProbeNeedsMigration},
+ {"core llm", "", strings.ReplaceAll(dshCoreCompatibilityFixture, "dsh-agent", "dsh-llm"), 1, false, dshProbeNeedsMigration},
+ {"core refusal exits zero", "", dshCoreCompatibilityFixture, 0, false, dshProbeNeedsMigration},
+ {"optional plugin", "", strings.ReplaceAll(dshCoreCompatibilityFixture, "@deepseek-ai/dsh-agent", "@example/optional-plugin"), 1, false, dshProbeUnavailable},
+ {"incidental incompatibility text", "", "Plugin @deepseek-ai/[email protected] is incompatible with dsh 0.2.2-rc.3", 1, false, dshProbeUnavailable},
+ {"healthy stdout wins", healthy, dshCoreCompatibilityFixture, 1, false, dshProbeOK},
+ {"future stdout keeps protocol skew", future, dshCoreCompatibilityFixture, 1, false, dshProbeIncompatible},
+ {"stderr cannot assert readiness", "", healthy, 1, false, dshProbeUnavailable},
+ {"timeout cannot condemn", "", dshCoreCompatibilityFixture, 0, true, dshProbeUnavailable},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ if tc.hangs {
+ shortenDshProbeTimeoutForHang(t)
+ }
+ body := fmt.Sprintf("printf '%%s\\n' '%s'; printf '%%s\\n' '%s' >&2; ", tc.stdout, tc.stderr)
+ if tc.hangs {
+ body += "exec sleep 30"
+ } else {
+ body += fmt.Sprintf("exit %d", tc.code)
+ }
+ path := dshProbeFixture(t, body, true)
+ if got := probeDshMulticaProfile(context.Background(), path).verdict; got != tc.want {
+ t.Fatalf("profile verdict=%v, want %v", got, tc.want)
+ }
+ })
+ }
+}
+
+func TestProbeBuiltinRuntimeDshRedactsStartupDiagnosis(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("POSIX fake CLI")
+ }
+ secret := "sk-" + strings.Repeat("synthetic", 5)
+ password := "synthetic-registry-password"
+ pemBody := strings.Repeat("SYNTHETIC", 20)
+ stdout := "API_KEY=" + secret + "\n-----BEGIN PRIVATE KEY-----\n" + pemBody + "\n-----END PRIVATE KEY-----"
+ stderr := "fatal probe startup: https://test:" + password + "@registry.example.test/package"
+ body := fmt.Sprintf("printf '%%s\\n' '%s'; printf '%%s\\n' '%s' >&2; exit 1", stdout, stderr)
+ path := dshProbeFixture(t, body, true)
+ originalDelay, originalWindow := runtimeVersionProbeRetryDelay, runtimeVersionProbeRetryWindow
+ t.Cleanup(func() { runtimeVersionProbeRetryDelay, runtimeVersionProbeRetryWindow = originalDelay, originalWindow })
+ runtimeVersionProbeRetryDelay, runtimeVersionProbeRetryWindow = time.Millisecond, time.Millisecond
+ d := &Daemon{logger: slog.New(slog.NewTextHandler(io.Discard, nil)), agentVersions: map[string]string{}}
+ probe := d.probeBuiltinRuntime(context.Background(), "dsh", AgentEntry{Path: path, Command: "dsh"})
+ reason, verdict := probe.reason, probe.verdict
+ if verdict != builtinProbeUnavailable || !strings.Contains(reason, "fatal probe startup") {
+ t.Fatal("redacted startup diagnostic was lost")
+ }
+ for _, sensitive := range []string{secret, password, pemBody} {
+ if strings.Contains(reason, sensitive) {
+ t.Error("synthetic secret survived diagnostic redaction")
+ }
+ }
+}
+
+func TestDshCoreCompatibilitySummaryRedactsVersionTokens(t *testing.T) {
+ secret := "sk-" + strings.Repeat("synthetic", 4)
+ line := strings.Replace(dshCoreCompatibilityFixture, "0.2.2-rc.1", "0.2.2-"+secret, 1)
+ summary := dshCoreCompatibilitySummary(line)
+ if summary == "" {
+ t.Fatal("core compatibility refusal was not recognized")
+ }
+ if strings.Contains(summary, secret) {
+ t.Fatal("captured version token escaped diagnostic redaction")
+ }
+}
+
+func TestDshCoreCompatibilityDemotionRequiresConfirmationAndRecovers(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("POSIX fake CLI")
+ }
+ stubConfirmWindow(t, 0)
+ path := dshProbeFixture(t, dshProbeOKFrame, true)
+ manifestPath := dshMulticaProfileManifestPath()
+ before, err := os.ReadFile(manifestPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ fx := newBatchFixture(t)
+ fx.enableStableRuntimeIDs()
+ d := fx.daemon
+ agents := map[string]AgentEntry{"dsh": {Path: path, Command: "dsh"}}
+ d.cfg.Agents = agents
+ stubAgentProbe(t, agents)
+ fx.setProbeVersion("0.2.2-rc.3")
+ fx.setWorkspaces(WorkspaceInfo{ID: "ws-1", Name: "one"})
+ if err := d.syncWorkspacesFromAPI(context.Background(), false); err != nil {
+ t.Fatal(err)
+ }
+ id := fx.runtimeIDFor("ws-1", "dsh")
+ if id == "" || !fx.runtimeOnline(id) {
+ t.Fatal("healthy fixture never registered")
+ }
+ broken := "#!/bin/sh\nprintf '%s\\n' '" + dshCoreCompatibilityFixture + "' >&2\nprintf 'unrelated-private-startup-text\\000\\n' >&2\nexit 1\n"
+ if err := os.WriteFile(path, []byte(broken), 0755); err != nil {
+ t.Fatal(err)
+ }
+ d.refreshAgentVersions(context.Background())
+ if !fx.runtimeOnline(id) {
+ t.Fatal("first refusal demoted before confirmation")
+ }
+ d.refreshAgentVersions(context.Background())
+ if fx.runtimeOnline(id) {
+ t.Fatal("confirmed core refusal left the runtime online")
+ }
+ reason, ok := fx.runtimeOfflineReason(id)
+ if !ok || reason.Code != RuntimeOfflineCodeDshProfile || reason.Installing || !strings.Contains(reason.Detail, "[email protected]") {
+ t.Fatalf("offline cause lost the manual profile repair diagnosis: %+v", reason)
+ }
+
+ if strings.Contains(reason.Detail, "unrelated-private-startup-text") || strings.ContainsRune(reason.Detail, 0) {
+ t.Error("durable runtime reason contains provider output or NUL")
+ }
+ if !strings.Contains(d.skippedAgentsSnapshot()["dsh"], "unrelated-private-startup-text") {
+ t.Error("daemon diagnostic lost local startup output")
+ }
+ healthy := "#!/bin/sh\n" + dshProbeOKFrame + "\n"
+ if err := os.WriteFile(path, []byte(healthy), 0755); err != nil {
+ t.Fatal(err)
+ }
+ d.convergeRuntimeRegistrations(context.Background())
+ if !fx.runtimeOnline(id) || fx.runtimeIDFor("ws-1", "dsh") != id {
+ t.Fatal("healthy profile did not recover its existing runtime")
+ }
+ if _, ok := fx.runtimeOfflineReason(id); ok {
+ t.Fatal("recovered runtime retained the stale repair reason")
+ }
+ after, err := os.ReadFile(manifestPath)
+ if err != nil || !bytes.Equal(before, after) {
+ t.Fatalf("probe lifecycle changed the user's profile: %v", err)
+ }
+}
+
+func TestDshCoreCompatibilitySignalIsTransient(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("POSIX signal fixture")
+ }
+ path := dshProbeFixture(t, "printf '%s\\n' '"+dshCoreCompatibilityFixture+"' >&2; kill -TERM $$", true)
+ result := probeDshMulticaProfile(context.Background(), path)
+ if result.verdict != dshProbeUnavailable {
+ t.Fatalf("signal verdict=%v, want transient", result.verdict)
+ }
+ if !strings.Contains(result.detail, "[email protected]") {
+ t.Fatal("signal lost available diagnostic")
+ }
+}
diff --git a/server/internal/daemon/dsh_profile_test.go b/server/internal/daemon/dsh_profile_test.go
index 695b9d1244..4a6cecc9d4 100644
--- a/server/internal/daemon/dsh_profile_test.go
+++ b/server/internal/daemon/dsh_profile_test.go
@@ -656,9 +656,22 @@ func TestDshProvisionCommand(t *testing.T) {
}
func TestDshProvisionOutput(t *testing.T) {
+ t.Run("invalid bytes keep readable diagnostic labels", func(t *testing.T) {
+ got := dshDiagnosticOutput([]byte("profile\xff startup failure"))
+ if got != "profile� startup failure" {
+ t.Fatal("diagnostic retained invalid UTF-8")
+ }
+ })
+ t.Run("retains a non-ASCII diagnostic tail", func(t *testing.T) {
+ got := dshDiagnosticOutput([]byte(strings.Repeat("界", dshProvisionOutputBytes)))
+ want := "…" + strings.Repeat("界", dshProvisionOutputBytes/len("界"))
+ if got != want {
+ t.Fatalf("Unicode tail was discarded: got %d bytes, want %d", len(got), len(want))
+ }
+ })
t.Run("bounded from the tail", func(t *testing.T) {
long := strings.Repeat("x", dshProvisionOutputBytes*2) + "THE-END"
- got := dshProvisionOutput([]byte(long))
+ got := dshDiagnosticOutput([]byte(long))
if len(got) > dshProvisionOutputBytes+len("…") {
t.Fatalf("len = %d, want at most %d", len(got), dshProvisionOutputBytes+1)
}
@@ -678,7 +691,7 @@ func TestDshProvisionOutput(t *testing.T) {
{"npm ERR! 404 https://deploy:[email protected]/@acme/dsh-runtime", "hunter2"},
{"ERR_PNPM_FETCH_401 GET http://ci-bot:[email protected]/@corp%2fdsh", "s3cr3t"},
} {
- got := dshProvisionOutput([]byte(tc.raw))
+ got := dshDiagnosticOutput([]byte(tc.raw))
if strings.Contains(got, tc.secret) {
t.Errorf("output = %q, want %q redacted", got, tc.secret)
}
@@ -688,7 +701,7 @@ func TestDshProvisionOutput(t *testing.T) {
// The host has to survive: which registry refused the request is what an
// operator reads, and it is not the secret.
t.Run("keeps the host", func(t *testing.T) {
- got := dshProvisionOutput([]byte("npm ERR! 404 https://deploy:[email protected]/pkg"))
+ got := dshDiagnosticOutput([]byte("npm ERR! 404 https://deploy:[email protected]/pkg"))
if !strings.Contains(got, "registry.example.com") {
t.Errorf("output = %q, want the host kept", got)
}
@@ -702,8 +715,8 @@ func TestDshProvisionOutput(t *testing.T) {
"cloning ssh://[email protected]/multica-ai/multica.git",
"see https://example.com/a:b for details",
} {
- if got := dshProvisionOutput([]byte(raw)); got != raw {
- t.Errorf("dshProvisionOutput(%q) = %q, want it unchanged", raw, got)
+ if got := dshDiagnosticOutput([]byte(raw)); got != raw {
+ t.Errorf("dshDiagnosticOutput(%q) = %q, want it unchanged", raw, got)
}
}
})
@@ -805,3 +818,48 @@ func TestDshMulticaProfileUnreadableManifest(t *testing.T) {
t.Fatal("an unreadable manifest must remain unknown, not missing or requiring migration")
}
}
+
+func TestDshDiagnosticOutputRedactsQuotedCredentials(t *testing.T) {
+ for _, key := range []string{"access_token", "apiKey", "password", "client_secret", "refresh_token", "authorization"} {
+ raw := `prefixed startup: {"` + key + `":"opaque-synthetic-value","message":"permission denied"}`
+ got := dshDiagnosticOutput([]byte(raw))
+ if strings.Contains(got, "opaque-synthetic-value") {
+ t.Errorf("quoted %s credential survived", key)
+ }
+ if !strings.Contains(got, "permission denied") {
+ t.Errorf("%s lost useful diagnostic", key)
+ }
+ }
+}
+
+func TestProvisionDshMulticaProfileRechecksCurrentManifest(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("POSIX fake CLI")
+ }
+ for _, existing := range []bool{true, false} {
+ t.Run(strconv.FormatBool(existing), func(t *testing.T) {
+ dshPath, record := fakeDshScript(t, dshProfileWriteCommand(installedDshProfileManifest())+"\nexit 1")
+ t.Setenv(dshProfileBundleEnv, "first,second")
+ if existing {
+ writeDshProfileManifest(t, os.Getenv("DSH_HOME"), installedDshProfileManifest())
+ }
+ want := installedDshProfileManifest()
+ err := provisionDshMulticaProfile(context.Background(), dshPath, slog.New(slog.NewTextHandler(io.Discard, nil)))
+ calls := strings.Count(readRecord(t, record), "args=")
+ expected := 1
+ if existing {
+ expected = 0
+ }
+ if calls != expected {
+ t.Errorf("install calls=%d, want %d", calls, expected)
+ }
+ if !existing && err == nil {
+ t.Error("partial failed install reported success")
+ }
+ got, readErr := os.ReadFile(dshMulticaProfileManifestPath())
+ if readErr != nil || string(got) != want {
+ t.Fatalf("populated manifest changed: %v", readErr)
+ }
+ })
+ }
+}
diff --git a/server/internal/service/agent_ready.go b/server/internal/service/agent_ready.go
index cba093e34c..6850a089ed 100644
--- a/server/internal/service/agent_ready.go
+++ b/server/internal/service/agent_ready.go
@@ -307,6 +307,7 @@ func runtimeProfileMissingNotice(name string) string {
"%s could not start: the DeepSeek Harness CLI is installed on that machine, but its `multica` runtime profile is missing or needs migration, so this trigger was not queued.\n\n"+
"Build a compatible `@multica-ai/dsh-runtime` bundle from [multica-ai/dsh-multica-runtime](https://github.com/multica-ai/dsh-multica-runtime#local-development), following its README's DSH version requirements. For a missing profile, install the built directory or tarball with `dsh plugin --profile multica add`, or set `MULTICA_DSH_PROFILE_BUNDLE` for the daemon to install it.\n\n"+
"For an existing bridge configuration, back up the profile and install the compatible bundle manually. In `dsh.profile.bundles`, replace `dsh-profile-multica` with `@multica-ai/dsh-runtime`; if both are listed, remove `dsh-profile-multica`. If the first-party runtime is only in `dependencies`, add it to `dsh.profile.bundles`. `MULTICA_DSH_PROFILE_BUNDLE` will not migrate an existing bridge configuration.\n\n"+
+ "If the profile probe names incompatible DSH core packages after an application upgrade, back up the profile manifest and review its profile-local core dependency overrides. Use core packages compatible with the installed application while retaining required independent plugins. Check the daemon's profile diagnostic for the package versions and manifest location, then rerun `dsh --profile multica --probe`.\n\n"+
"The runtime registers on its own within a couple of minutes after that; trigger the agent again then.",
name,
)
diff --git a/server/internal/service/reason_code_test.go b/server/internal/service/reason_code_test.go
index f7e4aa4f3e..1fda7388b7 100644
--- a/server/internal/service/reason_code_test.go
+++ b/server/internal/service/reason_code_test.go
@@ -249,6 +249,8 @@ func TestRuntimeProfileNoticeIncludesManualMigrationPath(t *testing.T) {
"replace `dsh-profile-multica` with `@multica-ai/dsh-runtime`",
"back up",
"will not migrate",
+ "core packages",
+ "independent plugins",
} {
if !strings.Contains(notice, required) {
t.Errorf("blocked-trigger notice lacks migration instruction %q:\n%s", required, notice)