The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
dsh: install hooks only where dsh can load the hook bridge (#954)
Jake Hemmerle96188fde81d6
diff --git a/CLAUDE.md b/CLAUDE.mdindex 3e221c8d..0482eea5 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -54,7 +54,7 @@ Supported runtime surfaces today:- Kimi Code registers in the `[[hooks]]` array of the runtime's own `$KIMI_CODE_HOME/config.toml` (default `~/.kimi-code`), the same file that holds `[providers.<name>].api_key`. Beacon appends its block and never re-serializes the document, and every write is parsed back and compared against the intended result before it replaces the file. Detection and removal go by the hook command rather than by Beacon's comment, because Kimi Code's legacy `kimi-cli` migration re-serializes config.toml and drops every comment. There is no project scope: Kimi Code reads one user-level config file. Thirteen of its twenty events are registered; `SessionHeartbeat` is deliberately left out because its sixty-second timer runs only when a hook is configured for it, and `Interrupt` because Beacon's closing action asserts the agent finished. Kimi Code reports real operator approval decisions over `PermissionRequest`/`PermissionResult`, so `PreToolUse` must not also synthesize one. Beacon writes nothing to stdout on this runtime, because `UserPromptSubmit` stdout is appended to the model's context; the policy seam denies with exit code 2 and is inert in the permission-request phase, which Kimi Code does not allow blocking. No token usage is exposed on any hook payload.- Kiro uses one Beacon-owned hook file under `.kiro/hooks` or `$KIRO_HOME`/`~/.kiro/hooks`. Its hook stdout is added to agent context on `SessionStart` and `UserPromptSubmit`, so Beacon writes nothing to stdout on Kiro; blocking is exit code 2 with the reason on stderr. Approvals are not exposed or synthesized.- goose currently has only the adapter: `cli/beacon-hooks/cmd/goose.go` can map a manually written `hooks.json` that invokes `beacon-hooks --platform goose`, but there is no `beacon endpoint hooks install --harness goose`, no `DiscoverGoose`, and no automatic OTLP configuration. Keep README/docs from implying goose is generally installable until those pieces exist. goose uses HTTP OTLP (4318), its blocking hook stdout must be `{"decision":"allow"}` or `{"decision":"block"}`, and it exposes no approval decisions or tool output.-- DeepSeek Harness (`dsh`) is installed through two user-level files: `$DSH_HOME/beacon-endpoint-hooks.json` and a row in `$DSH_HOME/cordis.patch.yml`; there is no project scope. It also installs a Beacon-owned local skill at `$DSH_HOME/skills/beacon-endpoint/SKILL.md` and supports native session backfill from `$DSH_HOME/sessions` through `beacon endpoint dsh sync`, which fills assistant text/reasoning, tool failures, and token usage that the hook bridge does not expose. It rides the Claude-shaped envelope on the hook path, but `run_code` remains `tool.invoked` because nested commands fire their own hooks.+- DeepSeek Harness (`dsh`) is installed through two user-level files: `$DSH_HOME/beacon-endpoint-hooks.json` and a row in `$DSH_HOME/cordis.patch.yml`; there is no project scope. The `@deepseek-ai/dsh-hooks-claude-code` bridge that row mounts is not shipped with the CLI (dev dependency only) and must be installed per profile with `@deepseek-ai/dsh-hook-protocol` at exactly the dsh version; a mount dsh cannot load is skipped at boot with only a warning. So `InstallDsh` first runs `hooks.InspectDshBridge` (`internal/endpoint/hooks/dsh_bridge.go`, read-only: the installation found from the `dsh` launcher on PATH, each `$DSH_HOME/profiles/*` resolved Node-style, and rows in any patch layer that mount a bridge by absolute path at Beacon's hooks file) and returns `*DshBridgeUnavailableError` without writing anything when nothing loads a matching bridge; explicit `--harness dsh` fails, `--all` and endpoint install skip with a warning. A healthy by-path mount (how Nix installs it; it must also resolve its declared dsh peers from its own location, because dsh's host-package interception applies only to profile plugins, else `peers_missing`) counts as installed and Beacon writes no row of its own (removing one it wrote earlier) so hooks never run twice. Beacon never installs the packages. `DshStatus.Active`/`Bridge`, discovery (misconfigured when inactive), doctor `dsh_hook_bridge`, and inventory (each profile's patch layer) surface it; tests build on-disk fixtures with `internal/endpoint/hooks/dshtest`. It also installs a Beacon-owned local skill at `$DSH_HOME/skills/beacon-endpoint/SKILL.md` and supports native session backfill from `$DSH_HOME/sessions` through `beacon endpoint dsh sync`, which fills assistant text/reasoning, tool failures, and token usage that the hook bridge does not expose. It rides the Claude-shaped envelope on the hook path, but `run_code` remains `tool.invoked` because nested commands fire their own hooks.- fx (vercel-labs/fx) telemetry read from the session store fx commits under `~/.fx/sessions/`, covering session start, prompts, tool calls, commands with exit codes and output, file reads/creates/edits with diffs, MCP tool calls, agent messages, history compaction, and per-turn token usage plus reported cost. fx exposes no third-party hook, plugin, or OTLP surface -- its lifecycle hooks are compiled into the binary -- so collection is a read of fx's own records, run by `beacon endpoint fx sync`. Every event carries `harness.collection_method=poll`; approvals are not synthesized (fx persists permission feedback text, not a per-call decision, matching the Cline and Pi posture) and no session-end event is invented, since fx sessions are resumable. Implementation lives in `cli/beacon/internal/fxsession` and `cli/beacon/cmd/endpoint_fx.go`.- Claude Cowork admin-configured OpenTelemetry setup guidance and local validation.- OpenClaw Gateway uses a Beacon-managed plugin directory plus OpenClaw's own diagnostics OTLP guidance (`beacon endpoint integrations openclaw`). The plugin's `before_tool_call` hook is fail-closed, so the handler dispatches synchronously and returns without awaiting. Conversation hooks, including `llm_output`, require `plugins.entries.beacon-endpoint.hooks.allowConversationAccess`; without it, token and agent-message coverage is partial. Beacon reads OpenClaw JSON/JSON5 config for advice but does not rewrite it.diff --git a/cli/beacon/README.md b/cli/beacon/README.mdindex 990b4b6d..c7e157ba 100644--- a/cli/beacon/README.md+++ b/cli/beacon/README.md@@ -674,10 +674,14 @@ the model. The one exception is the optional policy seam, whose deny is exit codThe DeepSeek Harness integration is the one install that takes two files,because `dsh` reads no hooks file until something mounts a reader at it: theharness composes itself from a plugin tree, and `@deepseek-ai/dsh-hooks-claude-code`--- the Claude Code hook bridge DeepSeek ships as a dependency of the CLI -- is not+-- the Claude Code hook bridge DeepSeek publishes for every dsh release -- is notin the default tree. So Beacon writes `$DSH_HOME/beacon-endpoint-hooks.json`, ahooks file it owns outright, and adds one row to `$DSH_HOME/cordis.patch.yml`-mounting the bridge at it. `$DSH_HOME` defaults to `~/.dsh`. The home-level patch+mounting the bridge at it. `$DSH_HOME` defaults to `~/.dsh`. The bridge does not+ship with the CLI, so it must be installed into each profile at exactly the dsh+version (`dsh plugin --profile <name> add @deepseek-ai/dsh-hooks-claude-code@<v>+@deepseek-ai/dsh-hook-protocol@<v>`), and install refuses when nothing can load+it. The home-level patchlayer applies over every profile, so one install covers the CLI, Web, ACP and SDKsurfaces; there is no project scope, because the bridge's `configPath` isprocess-level and a repository has nowhere to mount from, so `--level project` isdiff --git a/cli/beacon/cmd/dsh_bridge_test.go b/cli/beacon/cmd/dsh_bridge_test.gonew file mode 100644index 00000000..7377ddb9--- /dev/null+++ b/cli/beacon/cmd/dsh_bridge_test.go@@ -0,0 +1,159 @@+package cmd++import (+ "bytes"+ "errors"+ "os"+ "path/filepath"+ "strings"+ "testing"+ "time"++ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/dshsession"+ endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/diagnostics"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/harness"+ endpointhooks "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks/dshtest"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/lifecycle"+)++// dshBridgeTestHome isolates the Harness home and hides any real dsh on PATH.+func dshBridgeTestHome(t *testing.T) (home, dshHome string, cfg endpointconfig.Config) {+ t.Helper()+ home = t.TempDir()+ t.Setenv("HOME", home)+ t.Setenv("USERPROFILE", home)+ dshHome = filepath.Join(home, ".dsh")+ t.Setenv("DSH_HOME", dshHome)+ t.Setenv("PATH", t.TempDir())+ origLevel := endpointOpts.hookLevel+ t.Cleanup(func() { endpointOpts.hookLevel = origLevel })+ endpointOpts.hookLevel = "user"+ return home, dshHome, endpointconfig.Config{LogPath: filepath.Join(home, "runtime.jsonl"), UserMode: true}+}++// Named explicitly, a DeepSeek Harness that cannot load the bridge is an error; swept up with+// other targets it is skipped with the reason, and the targets after it still install.+func TestHooksInstallRefusesDshExplicitlyAndSkipsItInASweep(t *testing.T) {+ home, dshHome, cfg := dshBridgeTestHome(t)+ dshtest.InstallCLI(t, "0.2.1-rc.2")+ dshtest.Profile(t, dshHome, "web")++ var warnings bytes.Buffer+ err := installEndpointHookTargets(&warnings, []string{"dsh"}, cfg, false)+ var unavailable *endpointhooks.DshBridgeUnavailableError+ if !errors.As(err, &unavailable) {+ t.Fatalf("explicit install err = %v, want DshBridgeUnavailableError", err)+ }++ err = installEndpointHookTargets(&warnings, []string{"dsh", "kiro"}, cfg, true)+ if err != nil {+ t.Fatalf("sweep err = %v, want dsh skipped", err)+ }+ out := warnings.String()+ if !strings.Contains(out, "Warning: skipped DeepSeek Harness") || !strings.Contains(out, "dsh plugin --profile") {+ t.Fatalf("warning = %q", out)+ }+ if strings.Contains(strings.ToLower(out), "beacon will install") || strings.Contains(out, "npm install") {+ t.Fatalf("warning suggests Beacon installs packages: %q", out)+ }+ if _, err := os.Stat(filepath.Join(home, ".kiro", "hooks", "beacon-endpoint.json")); err != nil {+ t.Fatalf("the target after dsh was not installed: %v", err)+ }+ if _, err := os.Stat(filepath.Join(dshHome, "cordis.patch.yml")); !os.IsNotExist(err) {+ t.Fatal("the skipped dsh install wrote a mount")+ }+}++// Endpoint install sweeps detected runtimes and turns a target error into a warning; the dsh+// refusal must come through that path as a warning that leaves the install successful.+func TestEndpointInstallSkipsDshWithoutABridge(t *testing.T) {+ _, dshHome, _ := dshBridgeTestHome(t)+ dshtest.InstallCLI(t, "0.2.1-rc.2")+ dshtest.Profile(t, dshHome, "web")+ var report, out bytes.Buffer+ installHookTargetsFromEndpointInstall(&report, &out, []string{"dsh"})+ if !strings.Contains(out.String(), "Warning: dsh hooks were not installed") || !strings.Contains(out.String(), "Beacon does not install packages") {+ t.Fatalf("output = %q", out.String())+ }+}++func TestDshHookBridgeDoctorCheck(t *testing.T) {+ _, dshHome, cfg := dshBridgeTestHome(t)+ dshtest.InstallCLI(t, "0.2.1-rc.2")+ dshtest.InstallBridge(t, dshHome, "web", "0.2.1-rc.2", "0.2.1-rc.2")+ dshtest.Profile(t, dshHome, "headless")+ if err := installEndpointHookTarget("dsh", cfg); err != nil {+ t.Fatal(err)+ }++ check, ok := dshHookBridgeCheck()+ if !ok || check.Name != "dsh_hook_bridge" || check.Status != diagnostics.StatusWarn || check.Evidence != "dsh_hook_bridge_partial" ||+ !strings.Contains(check.Action, "dsh plugin --profile headless add") {+ t.Fatalf("partial check = %+v", check)+ }++ dshtest.InstallBridge(t, dshHome, "headless", "0.2.1-rc.2", "0.2.1-rc.2")+ if check, _ := dshHookBridgeCheck(); check.Status != diagnostics.StatusOK {+ t.Fatalf("complete check = %+v", check)+ }++ // dsh upgraded under an installed bridge: both versions are named.+ dshtest.InstallCLI(t, "0.2.2")+ check, _ = dshHookBridgeCheck()+ if check.Status != diagnostics.StatusWarn || check.Evidence != "dsh_hook_bridge_unavailable" ||+ !strings.Contains(check.Message, "dsh is 0.2.2") || !strings.Contains(check.Message, "0.2.1-rc.2") ||+ !strings.Contains(check.Action, "Beacon does not install packages") {+ t.Fatalf("mismatch check = %+v", check)+ }+}++func TestDshHookBridgeDoctorCheckSkipsWithoutHooks(t *testing.T) {+ _, dshHome, _ := dshBridgeTestHome(t)+ dshtest.InstallCLI(t, "0.2.1-rc.2")+ dshtest.Profile(t, dshHome, "web")+ if _, ok := dshHookBridgeCheck(); ok {+ t.Fatal("bridge check ran with no dsh hooks installed")+ }+}++// When dsh cannot load the bridge, every session runs without hook events, and dsh_hook_capture+// would blame the sandbox for it. Doctor reports the bridge and leaves the capture check out; with+// a working bridge both run.+func TestDoctorReportsTheBridgeInsteadOfBlamingTheSandbox(t *testing.T) {+ home := t.TempDir()+ t.Setenv("HOME", home)+ t.Setenv("USERPROFILE", home)+ origBridge, origCapture := doctorDshHookBridgeCheck, doctorDshHookCaptureCheck+ t.Cleanup(func() { doctorDshHookBridgeCheck, doctorDshHookCaptureCheck = origBridge, origCapture })+ captureCalls := 0+ doctorDshHookCaptureCheck = func(string) (diagnostics.Check, bool) {+ captureCalls+++ return diagnostics.Check{Name: "dsh_hook_capture", Target: dshsession.Harness, Status: diagnostics.StatusWarn}, true+ }+ bridge := diagnostics.Check{Name: "dsh_hook_bridge", Target: dshsession.Harness, Status: diagnostics.StatusWarn, Evidence: "dsh_hook_bridge_unavailable"}+ doctorDshHookBridgeCheck = func() (diagnostics.Check, bool) { return bridge, true }++ status := lifecycle.Status{+ LogPath: filepath.Join(home, "runtime.jsonl"),+ RuntimeLog: lifecycle.RuntimeLogSource{EffectiveUserMode: true},+ Harnesses: []harness.Harness{{Name: dshsession.Harness, Detected: true, TelemetryStatus: harness.TelemetryEnabled}},+ }+ names := func() []string {+ var out []string+ for _, c := range buildDoctorResult(status, time.Now()).Checks {+ if strings.HasPrefix(c.Name, "dsh_") {+ out = append(out, c.Name)+ }+ }+ return out+ }+ if got := names(); len(got) != 1 || got[0] != "dsh_hook_bridge" || captureCalls != 0 {+ t.Fatalf("checks = %v (capture calls %d), want only dsh_hook_bridge", got, captureCalls)+ }+ bridge.Evidence, bridge.Status = "dsh_hook_bridge_loads", diagnostics.StatusOK+ if got := names(); len(got) != 2 || captureCalls != 1 {+ t.Fatalf("checks = %v with a loadable bridge, want both", got)+ }+}diff --git a/cli/beacon/cmd/dsh_target_test.go b/cli/beacon/cmd/dsh_target_test.goindex 1972f59c..e9747f76 100644--- a/cli/beacon/cmd/dsh_target_test.go+++ b/cli/beacon/cmd/dsh_target_test.go@@ -8,6 +8,7 @@ import (endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config"endpointhooks "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks/dshtest")// The install -> status -> uninstall round trip for DeepSeek Harness, through the CLI entry points@@ -23,6 +24,7 @@ func TestEndpointHooksInstallAndUninstallDsh(t *testing.T) {t.Setenv("HOME", home)t.Setenv("USERPROFILE", home)t.Setenv("DSH_HOME", "")+ dshtest.Ready(t, filepath.Join(home, ".dsh"), "0.2.1-rc.2")cfg := endpointconfig.Config{LogPath: filepath.Join(home, "runtime.jsonl"), UserMode: true}origLevel := endpointOpts.hookLevel@@ -174,6 +176,7 @@ func TestEndpointHooksDshLeavesTheUsersPatchRowsAlone(t *testing.T) {t.Setenv("HOME", home)t.Setenv("USERPROFILE", home)t.Setenv("DSH_HOME", "")+ dshtest.Ready(t, filepath.Join(home, ".dsh"), "0.2.1-rc.2")cfg := endpointconfig.Config{LogPath: filepath.Join(home, "runtime.jsonl"), UserMode: true}origLevel := endpointOpts.hookLeveldiff --git a/cli/beacon/cmd/endpoint_diagnostics.go b/cli/beacon/cmd/endpoint_diagnostics.goindex b67c2e1a..6b070f9d 100644--- a/cli/beacon/cmd/endpoint_diagnostics.go+++ b/cli/beacon/cmd/endpoint_diagnostics.go@@ -172,8 +172,17 @@ func buildDoctorResult(status lifecycle.Status, generatedAt time.Time) doctorReschecks = append(checks, codexTokenAttributionCheck(status.LogPath, status.RuntimeLog.EffectiveUserMode))}if dshDetected {- if check, ok := doctorDshHookCaptureCheck(status.LogPath); ok {+ bridgeUnavailable := false+ if check, ok := doctorDshHookBridgeCheck(); ok {checks = append(checks, check)+ bridgeUnavailable = check.Evidence == "dsh_hook_bridge_unavailable"+ }+ // When dsh cannot load the bridge at all, every session runs without hook events and the+ // capture check would blame the sandbox for it. The bridge check has already said why.+ if !bridgeUnavailable {+ if check, ok := doctorDshHookCaptureCheck(status.LogPath); ok {+ checks = append(checks, check)+ }}}if check, ok := gitHookBudgetCheck(status.LogPath, generatedAt); ok {@@ -1462,6 +1471,14 @@ func harnessAction(h harness.Harness, effectiveUserMode bool) string {// sweep can only read what Grok has already committed. The check's message names the sweep for// the cases where that is what is behind.case "hooks+session_log":+ // DeepSeek Harness hooks that are installed but cannot be loaded are not fixed by+ // installing again, which would refuse: the bridge has to be installed into dsh first,+ // and the dsh_hook_bridge check names the command.+ // Discovery points ConfigPath at the hooks file only when the hooks are installed.+ if h.Name == dshsession.Harness && h.TelemetryStatus == harness.TelemetryMisconfigured &&+ filepath.Base(h.ConfigPath) == "beacon-endpoint-hooks.json" {+ return "see the dsh_hook_bridge check; until then run beacon endpoint dsh sync"+ }return "beacon endpoint hooks install --harness " + h.Name}return ""diff --git a/cli/beacon/cmd/endpoint_dsh_doctor.go b/cli/beacon/cmd/endpoint_dsh_doctor.goindex 8d1e12ad..00274adb 100644--- a/cli/beacon/cmd/endpoint_dsh_doctor.go+++ b/cli/beacon/cmd/endpoint_dsh_doctor.go@@ -53,6 +53,67 @@ func dshHookCaptureCheck(logPath string) (diagnostics.Check, bool) {return dshHookCaptureCheckAt(logPath, status.HooksPath, store.DSHHome), true}+// doctorDshHookBridgeCheck is the bridge check doctor runs, indirected like the capture check.+var doctorDshHookBridgeCheck = dshHookBridgeCheck++// dshHookBridgeCheck reports whether dsh can load the hook bridge the installed hooks depend on.+//+// The capture check above can only see that sessions ran without hook events. This one says why+// when the cause is the bridge: dsh does not ship it, so it has to be installed into a profile at+// exactly the dsh version (or mounted by path), and a dsh upgrade leaves an installed bridge one+// version behind. In each case dsh skips the mount with a warning and the hooks record nothing.+func dshHookBridgeCheck() (diagnostics.Check, bool) {+ status := endpointhooks.DshHookStatus(endpointhooks.DshOptions{Level: endpointhooks.LevelUser})+ if !status.Installed || status.Bridge == nil {+ return diagnostics.Check{}, false+ }+ return dshHookBridgeCheckFor(*status.Bridge, status.PathMounted), true+}++func dshHookBridgeCheckFor(bridge endpointhooks.DshBridgeReport, pathMounted bool) diagnostics.Check {+ check := diagnostics.Check{+ Name: "dsh_hook_bridge",+ Target: dshsession.Harness,+ Status: diagnostics.StatusOK,+ Severity: diagnostics.SeverityInfo,+ Evidence: "dsh_hook_bridge_loads",+ Message: "DeepSeek Harness " + bridge.Summary(),+ }+ missing := bridge.ProfilesWithoutBridge()+ switch {+ case !bridge.Ready:+ check.Status = diagnostics.StatusWarn+ check.Severity = diagnostics.SeverityMedium+ check.Evidence = "dsh_hook_bridge_unavailable"+ check.Message = "DeepSeek Harness hooks are installed but dsh cannot load them: " + bridge.Summary() ++ ". dsh skips the mount with a warning at boot, so no hook event is recorded"+ check.Action = dshBridgeAction(bridge, "")+ case bridge.DshVersion == "":+ check.Status = diagnostics.StatusWarn+ check.Severity = diagnostics.SeverityLow+ check.Evidence = "dsh_version_unknown"+ check.Message = "the DeepSeek Harness hook bridge resolves, but the running dsh version could not be determined (" ++ bridge.DshVersionError + "), so Beacon cannot confirm the bridge matches it"+ check.Action = "make sure `dsh` is on PATH for this user, then run beacon endpoint doctor again"+ case !pathMounted && len(missing) > 0:+ check.Status = diagnostics.StatusWarn+ check.Severity = diagnostics.SeverityLow+ check.Evidence = "dsh_hook_bridge_partial"+ check.Message = fmt.Sprintf("DeepSeek Harness %s; sessions in those profiles record no hook events", bridge.Summary())+ check.Action = dshBridgeAction(bridge, missing[0])+ }+ return check+}++// dshBridgeAction says how to add the bridge, without suggesting Beacon will do it.+func dshBridgeAction(bridge endpointhooks.DshBridgeReport, profile string) string {+ add := "install @deepseek-ai/dsh-hooks-claude-code and @deepseek-ai/dsh-hook-protocol at exactly the dsh version into the profile"+ if cmd := bridge.InstallCommand(profile); cmd != "" {+ add = "run `" + cmd + "`"+ }+ return add + " (Beacon does not install packages), then restart dsh; until then `beacon endpoint dsh sync` collects sessions from DeepSeek's session store"+}+// dshHookCaptureCheckAt is dshHookCaptureCheck with its inputs resolved, so it can be tested// against a temporary Harness home and runtime log.func dshHookCaptureCheckAt(logPath, hooksPath, dshHome string) diagnostics.Check {diff --git a/cli/beacon/cmd/endpoint_dsh_doctor_test.go b/cli/beacon/cmd/endpoint_dsh_doctor_test.goindex b8d33ef4..ad40722c 100644--- a/cli/beacon/cmd/endpoint_dsh_doctor_test.go+++ b/cli/beacon/cmd/endpoint_dsh_doctor_test.go@@ -2,6 +2,7 @@ package cmdimport ("fmt"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks/dshtest""os""path/filepath""strings"@@ -179,6 +180,7 @@ func TestDshHookCaptureCheckFindsARealInstall(t *testing.T) {t.Setenv("USERPROFILE", home)dshHome := filepath.Join(home, "dsh")t.Setenv("DSH_HOME", dshHome)+ dshtest.Ready(t, dshHome, "0.2.1-rc.2")origLevel := endpointOpts.hookLevelt.Cleanup(func() { endpointOpts.hookLevel = origLevel })endpointOpts.hookLevel = "user"diff --git a/cli/beacon/cmd/endpoint_hooks.go b/cli/beacon/cmd/endpoint_hooks.goindex 41d52130..0eda3c5c 100644--- a/cli/beacon/cmd/endpoint_hooks.go+++ b/cli/beacon/cmd/endpoint_hooks.go@@ -2,6 +2,7 @@ package cmdimport ("encoding/json"+ "errors""fmt""io""os"@@ -50,9 +51,21 @@ func runEndpointHooksInstall(cmd *cobra.Command, args []string) error {}return printPlannedActions(actions)}- cfg := loadOrDefaultConfig()+ return installEndpointHookTargets(os.Stderr, targets, loadOrDefaultConfig(), endpointOpts.allTargets)+}++// installEndpointHookTargets installs each target in turn and stops at the first error, except+// that a DeepSeek Harness which cannot load the hook bridge is skipped with a warning when it was+// swept up by --all rather than named. That is a property of the machine, not a failed write:+// named explicitly it is an error, and in a sweep it must not abort every target after it.+func installEndpointHookTargets(warnings io.Writer, targets []string, cfg endpointconfig.Config, sweep bool) error {for _, name := range targets {if err := installEndpointHookTarget(name, cfg); err != nil {+ var unavailable *endpointhooks.DshBridgeUnavailableError+ if sweep && errors.As(err, &unavailable) {+ fmt.Fprintf(warnings, "Warning: skipped DeepSeek Harness: %v\n", err)+ continue+ }return err}}@@ -268,7 +281,20 @@ func installEndpointHookTargetTo(report, notes io.Writer, name string, cfg endpo// least likely to guess at. Naming only the hooks file would send somebody looking for a// mount that is not there.fmt.Fprintf(report, "DeepSeek Harness hooks installed: %s\n", status.HooksPath)- fmt.Fprintf(report, "DeepSeek Harness hook bridge mounted in: %s\n", status.PatchPath)+ if status.PathMounted {+ fmt.Fprintf(report, "DeepSeek Harness hook bridge: already mounted by path, no row written (%s)\n", status.Bridge.Summary())+ } else {+ fmt.Fprintf(report, "DeepSeek Harness hook bridge mounted in: %s\n", status.PatchPath)+ }+ // A row mounted by package name resolves only in profiles that have the bridge installed;+ // the others boot with "1 entry did not activate" and run without hooks. Said here so+ // that warning is expected rather than a surprise.+ if status.Bridge != nil && !status.PathMounted {+ if missing := status.Bridge.ProfilesWithoutBridge(); len(missing) > 0 {+ fmt.Fprintf(notes, "DeepSeek Harness profile(s) %s do not have the hook bridge installed and will boot without hooks. "++ "To add it to one: %s\n", strings.Join(missing, ", "), status.Bridge.InstallCommand(missing[0]))+ }+ }// Said on every install, because a running dsh will not pick this up on its own unless the// profile enabled HMR -- and the symptom otherwise is a successful install collecting// nothing until the next restart, which reads as a broken install.@@ -855,9 +881,12 @@ func runEndpointHooksStatus(cmd *cobra.Command, args []string) error {// Both paths again, and here it is diagnostic rather than informational: installed is// the conjunction of the two files, so an operator reading installed=false needs to// know which one to look at.- fmt.Printf("DeepSeek Harness hooks: installed=%t path=%s patch=%s\n",- status.Installed, status.HooksPath, status.PatchPath)+ fmt.Printf("DeepSeek Harness hooks: installed=%t active=%t path=%s patch=%s\n",+ status.Installed, status.Active, status.HooksPath, status.PatchPath)fmt.Println(status.Message)+ if status.Bridge != nil && !status.Installed {+ fmt.Println(status.Bridge.Summary())+ }case "kimi":status := statuses["kimi"].(endpointhooks.KimiStatus)fmt.Printf("Kimi Code hooks: installed=%t path=%s\n", status.Installed, status.HooksPath)diff --git a/cli/beacon/internal/endpoint/dashboard/dsh_test.go b/cli/beacon/internal/endpoint/dashboard/dsh_test.goindex 718fc439..4702abb2 100644--- a/cli/beacon/internal/endpoint/dashboard/dsh_test.go+++ b/cli/beacon/internal/endpoint/dashboard/dsh_test.go@@ -5,6 +5,7 @@ import ("testing"endpointhooks "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks/dshtest")// The dashboard's harness list is a hand-written sequence of calls, one per runtime, so a runtime@@ -15,6 +16,7 @@ func TestHookStatusesIncludesDsh(t *testing.T) {t.Setenv("HOME", home)t.Setenv("USERPROFILE", home)t.Setenv("DSH_HOME", "")+ dshtest.Ready(t, filepath.Join(home, ".dsh"), "0.2.1-rc.2")logPath := filepath.Join(home, "runtime.jsonl")find := func() *HookStatus {diff --git a/cli/beacon/internal/endpoint/harness/dsh.go b/cli/beacon/internal/endpoint/harness/dsh.goindex 668b1d44..7657c429 100644--- a/cli/beacon/internal/endpoint/harness/dsh.go+++ b/cli/beacon/internal/endpoint/harness/dsh.go@@ -28,6 +28,13 @@ func DiscoverDsh() Harness {h.ConfigPath = store.SessionsDir}h.TelemetryStatus, h.Message = dshCollectionStatus(hookStatus.Installed, store.SessionsDir)+ // Hooks dsh cannot load are files, not telemetry: the mount is skipped at boot with a warning.+ // Reported as misconfigured, with the reason, rather than as enabled.+ if hookStatus.Installed && !hookStatus.Active && hookStatus.Bridge != nil {+ h.TelemetryStatus = TelemetryMisconfigured+ h.Message = "Beacon DeepSeek Harness hooks are configured but dsh cannot load them: " + hookStatus.Bridge.Summary() ++ "; `beacon endpoint doctor` says how to fix it, and `beacon endpoint dsh sync` collects sessions meanwhile"+ }return h}diff --git a/cli/beacon/internal/endpoint/harness/dsh_test.go b/cli/beacon/internal/endpoint/harness/dsh_test.gonew file mode 100644index 00000000..63794693--- /dev/null+++ b/cli/beacon/internal/endpoint/harness/dsh_test.go@@ -0,0 +1,35 @@+package harness++import (+ "path/filepath"+ "strings"+ "testing"++ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks/dshtest"+)++// Hooks dsh cannot load are files, not telemetry. After a dsh upgrade leaves the installed bridge a+// version behind, discovery must say so rather than report the integration enabled.+func TestDiscoverDshReportsHooksDshCannotLoadAsMisconfigured(t *testing.T) {+ home := t.TempDir()+ t.Setenv("HOME", home)+ t.Setenv("USERPROFILE", home)+ dshHome := filepath.Join(home, ".dsh")+ t.Setenv("DSH_HOME", dshHome)+ t.Setenv("PATH", t.TempDir())+ dshtest.InstallCLI(t, "0.2.1-rc.2")+ dshtest.InstallBridge(t, dshHome, "web", "0.2.1-rc.2", "0.2.1-rc.2")+ if _, err := hooks.InstallDsh(hooks.DshOptions{Level: hooks.LevelUser, LogPath: filepath.Join(home, "runtime.jsonl"), UserMode: true}); err != nil {+ t.Fatal(err)+ }+ if h := DiscoverDsh(); h.TelemetryStatus != TelemetryEnabled {+ t.Fatalf("discovery with a loadable bridge = %s (%s)", h.TelemetryStatus, h.Message)+ }++ dshtest.InstallCLI(t, "0.2.2")+ h := DiscoverDsh()+ if h.TelemetryStatus != TelemetryMisconfigured || !strings.Contains(h.Message, "dsh is 0.2.2") {+ t.Fatalf("discovery after a dsh upgrade = %s (%s), want misconfigured naming the versions", h.TelemetryStatus, h.Message)+ }+}diff --git a/cli/beacon/internal/endpoint/hooks/dsh.go b/cli/beacon/internal/endpoint/hooks/dsh.goindex a81ea9f0..854e8a9e 100644--- a/cli/beacon/internal/endpoint/hooks/dsh.go+++ b/cli/beacon/internal/endpoint/hooks/dsh.go@@ -12,12 +12,18 @@ import (// the runtime does not read a hooks file until something tells it to.//// `dsh` runs Claude Code hooks through `@deepseek-ai/dsh-hooks-claude-code`, a bridge DeepSeek-// ships as a dependency of the CLI but does not mount. Nothing is loaded by convention: the-// harness composes itself from a plugin tree, and a plugin that is not in the tree does not exist.-// So Beacon writes+// publishes for every dsh release but neither ships with the CLI nor mounts. Nothing is loaded by+// convention: the harness composes itself from a plugin tree, and a plugin that is not in the tree+// does not exist. So Beacon writes//// 1. `$DSH_HOME/beacon-endpoint-hooks.json` -- a Claude Code hooks file Beacon owns outright, and-// 2. one row in `$DSH_HOME/cordis.patch.yml` mounting the bridge at that file.+// 2. one row in `$DSH_HOME/cordis.patch.yml` mounting the bridge at that file,+//+// and only after checking that something can load a bridge matching the running dsh (see+// dsh_bridge.go). A row nothing resolves does not fail boot; dsh skips it with a warning and runs+// with no hooks, so writing one unchecked is an install that reports success and captures nothing.+// When the bridge is already mounted by absolute path at Beacon's hooks file -- how a declarative+// setup mounts it -- Beacon writes only the hooks file.//// The second file is the interesting one and it is not Beacon's. It is the user's own tweak layer,// applied over every profile, and it may already carry their rows, their comments and `!!js`@@ -56,8 +62,10 @@ const (dshPatchFileName = "cordis.patch.yml"// dshBridgePackage is the plugin that runs Claude Code hooks against the harness's extension- // points. It ships as a dependency of the `dsh` CLI, so mounting it needs no install step --- // the row alone activates it, the same way the runtime's own webhook overlay works.+ // points. It is published at every dsh version but is only a development dependency of the+ // `dsh` CLI, so a row naming it resolves only where it has been installed, normally into a+ // profile with `dsh plugin --profile <name> add`. InspectDshBridge checks that before a row is+ // written.dshBridgePackage = "@deepseek-ai/dsh-hooks-claude-code"// dshPatchEntryID identifies Beacon's row.@@ -136,11 +144,20 @@ type DshOptions struct {}type DshStatus struct {- Installed bool `json:"installed"`+ // Installed is true when the hooks file registers Beacon's commands and something mounts the+ // bridge at it: Beacon's row in the home patch layer, or a path mount in any layer.+ Installed bool `json:"installed"`+ // Active is Installed and a route that loads a bridge matching the running dsh. An install that+ // is not active writes files dsh will not act on.+ Active bool `json:"active"`BinaryPath string `json:"binary_path,omitempty"`HooksPath string `json:"hooks_path,omitempty"`PatchPath string `json:"patch_path,omitempty"`- Message string `json:"message,omitempty"`+ // PathMounted is true when the bridge is mounted by absolute path at the hooks file rather+ // than by Beacon's row.+ PathMounted bool `json:"path_mounted,omitempty"`+ Bridge *DshBridgeReport `json:"bridge,omitempty"`+ Message string `json:"message,omitempty"`}// dshHooksFile is the Claude Code hooks document Beacon writes: a bare event map.@@ -178,8 +195,26 @@ var dshRuntime = hookRuntime{isInstalled: isDshInstalledAt,}+// InstallDsh installs the hooks, or returns a *DshBridgeUnavailableError and writes nothing when no+// route loads a bridge matching the running dsh.func InstallDsh(opts DshOptions) (DshStatus, error) {- status, err := installRuntimeHooks(dshRuntime, RuntimeOptions(opts))+ hooksPath, err := dshHooksPath(opts.Level)+ if err != nil {+ return DshStatus{}, err+ }+ report := InspectDshBridge(filepath.Dir(hooksPath), hooksPath)+ if !report.Ready {+ return DshStatus{HooksPath: hooksPath, PatchPath: dshPatchPathFor(hooksPath), Bridge: &report, Message: report.Summary()},+ &DshBridgeUnavailableError{Report: report}+ }+ runtime := dshRuntime+ if report.PathMounted() {+ // Something already mounts a matching bridge at this hooks file. A second mount would run+ // every hook twice, so Beacon writes the hooks file only and drops a row of its own left by+ // an earlier install.+ runtime.install = installDshHooksFileOnly+ }+ status, err := installRuntimeHooks(runtime, RuntimeOptions(opts))if err != nil {return DshStatus{}, err}@@ -188,7 +223,12 @@ func InstallDsh(opts DshOptions) (DshStatus, error) {return DshStatus{}, err}}- return dshStatusFromRuntime(status), nil+ out := dshStatusFromRuntime(status)+ out.PathMounted = report.PathMounted()+ out.Bridge = &report+ out.Active = true+ out.Message = report.Summary()+ return out, nil}func UninstallDsh(opts DshOptions) (DshStatus, error) {@@ -205,8 +245,20 @@ func UninstallDsh(opts DshOptions) (DshStatus, error) {return dshStatusFromRuntime(status), nil}+// DshHookStatus reports both files and whether dsh can load a matching bridge.func DshHookStatus(opts DshOptions) DshStatus {- return dshStatusFromRuntime(runtimeHookStatus(dshRuntime, RuntimeOptions(opts)))+ status := dshStatusFromRuntime(runtimeHookStatus(dshRuntime, RuntimeOptions(opts)))+ if status.HooksPath == "" {+ return status+ }+ report := InspectDshBridge(filepath.Dir(status.HooksPath), status.HooksPath)+ status.Bridge = &report+ status.PathMounted = report.PathMounted()+ status.Active = status.Installed && report.Ready+ if status.Installed {+ status.Message = "DeepSeek Harness endpoint hooks are installed; " + report.Summary()+ }+ return status}func IsDshInstalled(opts DshOptions) bool {@@ -252,6 +304,24 @@ func dshPatchPathFor(hooksPath string) string {// pointing at a file that does not exist, and the bridge's answer to that is to log a warning and// register nothing -- an install that looks complete and captures nothing.func installDshHooks(path, binaryPath, logPath, configPath string) error {+ if err := writeDshHooksFile(path, binaryPath, logPath, configPath); err != nil {+ return err+ }+ return addDshPatchEntry(dshPatchPathFor(path), path)+}++// installDshHooksFileOnly writes the hooks file for a bridge already mounted by path, and removes a+// row of Beacon's own so the bridge is not mounted twice.+func installDshHooksFileOnly(path, binaryPath, logPath, configPath string) error {+ if err := writeDshHooksFile(path, binaryPath, logPath, configPath); err != nil {+ return err+ }+ _, err := removeDshPatchEntry(dshPatchPathFor(path))+ return err+}++// writeDshHooksFile writes Beacon's hooks file.+func writeDshHooksFile(path, binaryPath, logPath, configPath string) error {if err := dshHookFileIsBeacons(path); err != nil {return err}@@ -275,10 +345,7 @@ func installDshHooks(path, binaryPath, logPath, configPath string) error {// service or a desktop host running as a different account, and a file only its author can// read would make the hooks stop working there with no diagnostic -- the bridge logs a warning// and registers nothing. The file contains a command line and no secrets.- if err := os.WriteFile(path, data, 0644); err != nil {- return err- }- return addDshPatchEntry(dshPatchPathFor(path), path)+ return os.WriteFile(path, data, 0644)}// removeDshHooks removes both halves, and reports whether anything was there.@@ -317,7 +384,7 @@ func removeDshHooks(path string) (bool, error) {// the same failure the other installers guard against by checking the hook command rather than the// file's existence, applied to a runtime where the evidence is split across two files.func isDshInstalledAt(path string) bool {- return dshHasEndpointHooks(path) && dshPatchHasEntry(dshPatchPathFor(path))+ return dshHasEndpointHooks(path) && (dshPatchHasEntry(dshPatchPathFor(path)) || dshHasPathMount(path))}// dshHasEndpointHooks reports whether the hooks file registers a Beacon command.diff --git a/cli/beacon/internal/endpoint/hooks/dsh_bridge.go b/cli/beacon/internal/endpoint/hooks/dsh_bridge.gonew file mode 100644index 00000000..20e51526--- /dev/null+++ b/cli/beacon/internal/endpoint/hooks/dsh_bridge.go@@ -0,0 +1,568 @@+package hooks++import (+ "context"+ "encoding/json"+ "fmt"+ "os"+ "os/exec"+ "path/filepath"+ "regexp"+ "sort"+ "strings"+ "time"++ "gopkg.in/yaml.v3"+)++// Whether DeepSeek Harness can actually load the Claude Code hook bridge.+//+// Writing the hooks file and mounting the bridge is not enough on its own. The `dsh` CLI does not+// ship `@deepseek-ai/dsh-hooks-claude-code`: it is only a development dependency of the CLI+// package. A mount by package name therefore resolves only where the bridge has been installed --+// into a profile, with `dsh plugin --profile <name> add ...` -- and a mount nothing can resolve is+// not an error to dsh. The profile boots, prints "1 entry did not activate", and runs with no hooks+// at all, which is an install that reports success and captures nothing.+//+// The bridge also has to match the harness it runs in. Each release pins its dsh peers, including+// `@deepseek-ai/dsh-hook-protocol` (which the CLI does not ship either), to that exact dsh version,+// and both are published for every dsh release. A bridge for another version, or one installed+// without the protocol package, fails to import in the same quiet way.+//+// So before mounting anything Beacon checks, read-only, whether some route resolves a bridge and+// protocol of the running dsh's version:+//+// - the dsh installation itself, for a release that ships the bridge as a dependency;+// - each profile under $DSH_HOME/profiles, resolving the package the way Node does from the+// profile directory, which is where a row naming the package is resolved from; and+// - an existing patch row, in the home layer or a profile layer, whose `name` is an absolute path+// to a bridge package and whose `config.configPath` is Beacon's hooks file. That is how a+// declarative setup (a Nix store path, say) mounts the bridge, and Beacon must neither report it+// as broken nor add a second mount beside it, which would run every hook twice.+//+// Beacon never installs packages itself: it is local-only, and a package install is a network+// fetch. When nothing resolves, the install refuses and says how the person can add the bridge.++const (+ // dshHookProtocolPackage is the bridge's protocol peer. The CLI does not ship it either.+ dshHookProtocolPackage = "@deepseek-ai/dsh-hook-protocol"+ // dshCLIPackage is the CLI package, whose package.json carries the running version.+ dshCLIPackage = "@deepseek-ai/dsh"+ // dshProfilesDirName is where profiles live under the Harness home.+ dshProfilesDirName = "profiles"+ // dshVersionTimeout bounds `dsh --version`, the fallback when the installation cannot be found+ // from the launcher on PATH.+ dshVersionTimeout = 10 * time.Second+)++// Bridge route statuses.+const (+ DshBridgeOK = "ok"+ DshBridgeUnverified = "unverified" // resolves, but the dsh version is unknown+ DshBridgeMissing = "missing" // the bridge package does not resolve+ DshBridgeProtocolMissing = "protocol_missing" // the bridge resolves but its protocol peer does not+ DshBridgeVersionMismatch = "version_mismatch" // the bridge or protocol is for another dsh version+ DshBridgePeersMissing = "peers_missing" // a bridge mounted by path cannot resolve its dsh peers+)++// DshBridgeRoute is one place dsh could load the bridge from.+type DshBridgeRoute struct {+ // Kind is "install" (the dsh installation), "profile" or "path_mount".+ Kind string `json:"kind"`+ // Name is the profile name for a profile route.+ Name string `json:"name,omitempty"`+ // Path is the profile directory, or the patch layer holding a path mount.+ Path string `json:"path,omitempty"`+ // BridgePath is where the bridge package resolved.+ BridgePath string `json:"bridge_path,omitempty"`+ BridgeVersion string `json:"bridge_version,omitempty"`+ ProtocolVersion string `json:"protocol_version,omitempty"`+ Status string `json:"status"`+ Detail string `json:"detail,omitempty"`+}++// Loads reports whether dsh would load the bridge through this route.+func (r DshBridgeRoute) Loads() bool {+ return r.Status == DshBridgeOK || r.Status == DshBridgeUnverified+}++// DshBridgeReport is what Beacon found about the bridge for one Harness home.+type DshBridgeReport struct {+ // DshVersion is the running dsh version, empty when it could not be determined.+ DshVersion string `json:"dsh_version,omitempty"`+ // DshVersionError says why the version is unknown.+ DshVersionError string `json:"dsh_version_error,omitempty"`+ // Install is the dsh installation route, when the installation was found.+ Install *DshBridgeRoute `json:"install,omitempty"`+ // Profiles are the profiles under the Harness home.+ Profiles []DshBridgeRoute `json:"profiles,omitempty"`+ // PathMounts are rows that mount a bridge by absolute path at Beacon's hooks file.+ PathMounts []DshBridgeRoute `json:"path_mounts,omitempty"`+ // Ready is true when at least one route loads a matching bridge.+ Ready bool `json:"ready"`+}++// PathMounted reports whether a path mount already loads a matching bridge at Beacon's hooks file,+// in which case Beacon writes no mount of its own.+func (r DshBridgeReport) PathMounted() bool {+ for _, m := range r.PathMounts {+ if m.Loads() {+ return true+ }+ }+ return false+}++// installLoads reports whether the dsh installation itself provides the bridge, which makes a+// package-name mount load in every profile.+func (r DshBridgeReport) installLoads() bool {+ return r.Install != nil && r.Install.Loads()+}++// ProfilesWithoutBridge names the profiles that would log "did not activate" for a mount by package+// name. Empty when the installation provides the bridge, because then every profile resolves it.+func (r DshBridgeReport) ProfilesWithoutBridge() []string {+ if r.installLoads() {+ return nil+ }+ var names []string+ for _, p := range r.Profiles {+ if !p.Loads() {+ names = append(names, p.Name)+ }+ }+ return names+}++// Summary is one line for status output.+func (r DshBridgeReport) Summary() string {+ version := r.DshVersion+ if version == "" {+ version = "unknown"+ }+ switch {+ case r.PathMounted():+ for _, m := range r.PathMounts {+ if m.Loads() {+ return fmt.Sprintf("hook bridge %s mounted by path in %s (dsh %s)", m.BridgeVersion, m.Path, version)+ }+ }+ case r.installLoads():+ return fmt.Sprintf("hook bridge %s ships with dsh %s", r.Install.BridgeVersion, version)+ case r.Ready:+ var loads []string+ for _, p := range r.Profiles {+ if p.Loads() {+ loads = append(loads, p.Name)+ }+ }+ line := fmt.Sprintf("hook bridge loads in profile(s) %s (dsh %s)", strings.Join(loads, ", "), version)+ if missing := r.ProfilesWithoutBridge(); len(missing) > 0 {+ line += fmt.Sprintf("; profile(s) %s cannot load it and boot without hooks", strings.Join(missing, ", "))+ }+ return line+ }+ return fmt.Sprintf("hook bridge cannot be loaded by dsh %s: %s", version, r.problem())+}++// problem describes why no route loads, naming both versions on a mismatch.+func (r DshBridgeReport) problem() string {+ routes := append([]DshBridgeRoute{}, r.PathMounts...)+ if r.Install != nil {+ routes = append(routes, *r.Install)+ }+ routes = append(routes, r.Profiles...)+ for _, route := range routes {+ if route.Status == DshBridgeVersionMismatch || route.Status == DshBridgeProtocolMissing || route.Status == DshBridgePeersMissing {+ return route.Detail+ }+ }+ if len(r.Profiles) == 0 {+ return fmt.Sprintf("%s is not part of the dsh installation and there are no profiles under the Harness home", dshBridgePackage)+ }+ return fmt.Sprintf("%s is not part of the dsh installation and is not installed in any profile", dshBridgePackage)+}++// InstallCommand is the command a person can run to add the bridge to a profile, or empty when the+// dsh version is unknown and so cannot be pinned.+func (r DshBridgeReport) InstallCommand(profile string) string {+ if r.DshVersion == "" {+ return ""+ }+ if profile == "" {+ profile = r.suggestedProfile()+ }+ return fmt.Sprintf("dsh plugin --profile %s add %s@%s %s@%s", profile, dshBridgePackage, r.DshVersion, dshHookProtocolPackage, r.DshVersion)+}++// suggestedProfile names the profile a fix applies to when one stands out: a profile whose bridge+// is stale or incomplete, or the only profile there is.+func (r DshBridgeReport) suggestedProfile() string {+ for _, p := range r.Profiles {+ if p.Status == DshBridgeVersionMismatch || p.Status == DshBridgeProtocolMissing {+ return p.Name+ }+ }+ if len(r.Profiles) == 1 {+ return r.Profiles[0].Name+ }+ return "<profile>"+}++// DshBridgeUnavailableError is returned by InstallDsh when nothing can load a matching bridge.+type DshBridgeUnavailableError struct {+ Report DshBridgeReport+}++func (e *DshBridgeUnavailableError) Error() string {+ var b strings.Builder+ b.WriteString("DeepSeek Harness hook telemetry was not installed: ")+ b.WriteString(e.Report.problem())+ b.WriteString(". A mount dsh cannot load is skipped at boot with a warning, so the hooks would record nothing. ")+ b.WriteString("Beacon does not install packages. To add the bridge to a profile yourself, run ")+ if cmd := e.Report.InstallCommand(""); cmd != "" {+ b.WriteString("`" + cmd + "`")+ } else {+ b.WriteString("`dsh plugin --profile <profile> add " + dshBridgePackage + "@<dsh version> " + dshHookProtocolPackage + "@<dsh version>`")+ }+ b.WriteString(" (both at exactly the dsh version), then install the hooks again. Until then, `beacon endpoint dsh sync` collects DeepSeek Harness sessions from its session store")+ return b.String()+}++// dshInstallation is what Beacon could learn about the running dsh.+type dshInstallation struct {+ version string+ // modules is the installation's node_modules directory, empty when it was not found.+ modules string+ err error+}++// probeDshInstallation finds the dsh installation, a seam for tests.+var probeDshInstallation = defaultProbeDshInstallation++// dshLauncherBinJS matches the CLI entry point a launcher script executes.+var dshLauncherBinJS = regexp.MustCompile(`(/[^\s"'$]*/node_modules/@deepseek-ai/dsh)/lib/bin\.js`)++// dshLauncherNext matches another absolute dsh launcher a wrapper script execs.+var dshLauncherNext = regexp.MustCompile(`(/[^\s"'$]*/bin/dsh)\b`)++// dshLauncherShimBinJS matches the CLI entry point in the shims npm writes on Windows (dsh.cmd,+// dsh.ps1 and the sh shim beside them), which name it relative to the shim's own directory: %dp0%+// in dsh.cmd, $basedir in dsh.ps1, and $basedir_win (older npm: $basedir) in the sh shim.+var dshLauncherShimBinJS = regexp.MustCompile(`(?:%~?dp0%?|\$basedir(?:_win)?)[\\/]+(node_modules[\\/]+@deepseek-ai[\\/]+dsh)[\\/]+lib[\\/]+bin\.js`)++func defaultProbeDshInstallation() dshInstallation {+ launcher, err := exec.LookPath("dsh")+ if err != nil {+ return dshInstallation{err: fmt.Errorf("dsh is not on PATH")}+ }+ if pkg := dshPackageFromLauncher(launcher, 0); pkg != "" {+ if version := packageVersion(pkg); version != "" {+ return dshInstallation{version: version, modules: filepath.Join(pkg, "node_modules")}+ }+ }+ // The installation could not be found from the launcher. Ask dsh itself; --version prints+ // the version and boots nothing.+ ctx, cancel := context.WithTimeout(context.Background(), dshVersionTimeout)+ defer cancel()+ out, err := exec.CommandContext(ctx, launcher, "--version").Output()+ if err != nil {+ return dshInstallation{err: fmt.Errorf("`dsh --version` failed: %v", err)}+ }+ version := strings.TrimSpace(strings.SplitN(string(out), "\n", 2)[0])+ if version == "" {+ return dshInstallation{err: fmt.Errorf("`dsh --version` printed nothing")}+ }+ return dshInstallation{version: version}+}++// dshPackageFromLauncher follows a dsh launcher to the CLI package directory: a symlink straight to+// lib/bin.js (an npm global install), an npm Windows shim naming it relative to the shim, or a+// script that runs that file or execs another launcher (a wrapper, as Nix and similar package+// managers write). Empty when it cannot tell.+func dshPackageFromLauncher(path string, depth int) string {+ if depth > 4 {+ return ""+ }+ if real, err := filepath.EvalSymlinks(path); err == nil {+ path = real+ }+ if filepath.Base(path) == "bin.js" && filepath.Base(filepath.Dir(path)) == "lib" {+ return filepath.Dir(filepath.Dir(path))+ }+ info, err := os.Stat(path)+ if err != nil || info.IsDir() || info.Size() > 256<<10 {+ return ""+ }+ data, err := os.ReadFile(path)+ if err != nil {+ return ""+ }+ text := string(data)+ if m := dshLauncherShimBinJS.FindStringSubmatch(text); m != nil {+ return filepath.Join(filepath.Dir(path), filepath.FromSlash(strings.ReplaceAll(m[1], `\`, "/")))+ }+ if m := dshLauncherBinJS.FindStringSubmatch(text); m != nil {+ return m[1]+ }+ for _, m := range dshLauncherNext.FindAllStringSubmatch(text, -1) {+ if next := m[1]; next != path {+ if pkg := dshPackageFromLauncher(next, depth+1); pkg != "" {+ return pkg+ }+ }+ }+ return ""+}++// InspectDshBridge reports, read-only, whether dsh can load a bridge that matches it.+func InspectDshBridge(home, hooksPath string) DshBridgeReport {+ inst := probeDshInstallation()+ report := DshBridgeReport{DshVersion: inst.version}+ if inst.err != nil {+ report.DshVersionError = inst.err.Error()+ }+ if inst.modules != "" {+ route := DshBridgeRoute{Kind: "install", Path: filepath.Dir(inst.modules)}+ if dir := filepath.Join(inst.modules, filepath.FromSlash(dshBridgePackage)); packageVersion(dir) != "" {+ evaluateBridge(&route, dir, report.DshVersion, inst.modules, true)+ } else {+ route.Status = DshBridgeMissing+ route.Detail = fmt.Sprintf("dsh %s does not ship %s", report.DshVersion, dshBridgePackage)+ }+ report.Install = &route+ }++ profilesDir := filepath.Join(home, dshProfilesDirName)+ entries, _ := os.ReadDir(profilesDir)+ for _, entry := range entries {+ if !entry.IsDir() {+ continue+ }+ dir := filepath.Join(profilesDir, entry.Name())+ route := DshBridgeRoute{Kind: "profile", Name: entry.Name(), Path: dir}+ if bridge := resolveNodePackage(dir, dshBridgePackage); bridge != "" {+ evaluateBridge(&route, bridge, report.DshVersion, inst.modules, true)+ } else if report.installLoads() {+ route = *report.Install+ route.Kind, route.Name, route.Path = "profile", entry.Name(), dir+ } else {+ route.Status = DshBridgeMissing+ route.Detail = fmt.Sprintf("%s is not installed in profile %s", dshBridgePackage, entry.Name())+ }+ report.Profiles = append(report.Profiles, route)+ }++ for _, layer := range dshPatchLayers(home) {+ for _, name := range dshPathMountNames(layer, hooksPath) {+ route := DshBridgeRoute{Kind: "path_mount", Path: layer}+ if pkg := packageRootFor(name, dshBridgePackage); pkg != "" {+ evaluateBridge(&route, pkg, report.DshVersion, inst.modules, false)+ } else {+ route.BridgePath = name+ route.Status = DshBridgeMissing+ route.Detail = fmt.Sprintf("%s in %s is not a %s package", name, layer, dshBridgePackage)+ }+ report.PathMounts = append(report.PathMounts, route)+ }+ }++ report.Ready = report.installLoads() || report.PathMounted()+ for _, p := range report.Profiles {+ if p.Loads() {+ report.Ready = true+ }+ }+ return report+}++// evaluateBridge fills a route from the bridge package at dir.+//+// The bridge imports its dsh peers, so each must resolve the way Node resolves it from the bridge's+// real location. A bridge installed into a profile or shipped with dsh also gets the packages the+// dsh installation ships, because dsh intercepts those imports for profile plugins. A bridge mounted+// by absolute path does not (hostPeers false): dsh 0.2.1-rc.2 fails to import such a bridge with+// "Cannot find package '@deepseek-ai/dsh-llm'" unless its peers resolve from where it sits, which+// is what a declarative package provides with node_modules links into the dsh installation.+func evaluateBridge(route *DshBridgeRoute, dir, dshVersion, installModules string, hostPeers bool) {+ route.BridgePath = dir+ route.BridgeVersion = packageVersion(dir)+ real := dir+ if r, err := filepath.EvalSymlinks(dir); err == nil {+ real = r+ }+ resolve := func(name string, fromHost bool) string {+ if found := resolveNodePackage(real, name); found != "" {+ return found+ }+ if fromHost && installModules != "" {+ if candidate := filepath.Join(installModules, filepath.FromSlash(name)); packageVersion(candidate) != "" {+ return candidate+ }+ }+ return ""+ }+ // The protocol is never shipped with dsh, but a release that ships the bridge could ship it too,+ // so the installation fallback applies to every route that imports through dsh.+ protocol := resolve(dshHookProtocolPackage, hostPeers || route.Kind == "install")+ route.ProtocolVersion = packageVersion(protocol)+ var missingPeers []string+ for _, peer := range readPackageManifest(dir).peerNames() {+ if peer == dshHookProtocolPackage {+ continue+ }+ // With the installation unknown, packages dsh ships cannot be checked for a profile route;+ // they are assumed to be there, which is what dsh provides.+ if hostPeers && installModules == "" {+ continue+ }+ if resolve(peer, hostPeers) == "" {+ missingPeers = append(missingPeers, peer)+ }+ }+ switch {+ case protocol == "":+ route.Status = DshBridgeProtocolMissing+ route.Detail = fmt.Sprintf("%s %s is installed at %s but %s is not resolvable from it", dshBridgePackage, route.BridgeVersion, dir, dshHookProtocolPackage)+ case len(missingPeers) > 0:+ route.Status = DshBridgePeersMissing+ route.Detail = fmt.Sprintf("%s %s at %s cannot resolve %s from where it is; a bridge mounted by path needs its dsh peers next to it, for example node_modules links into the dsh installation",+ dshBridgePackage, route.BridgeVersion, dir, strings.Join(missingPeers, ", "))+ case dshVersion == "":+ route.Status = DshBridgeUnverified+ route.Detail = fmt.Sprintf("%s %s resolves, but the running dsh version could not be determined", dshBridgePackage, route.BridgeVersion)+ case route.BridgeVersion != dshVersion || route.ProtocolVersion != dshVersion:+ route.Status = DshBridgeVersionMismatch+ route.Detail = fmt.Sprintf("dsh is %s but %s is %s and %s is %s; both must match dsh exactly",+ dshVersion, dshBridgePackage, route.BridgeVersion, dshHookProtocolPackage, route.ProtocolVersion)+ default:+ route.Status = DshBridgeOK+ }+}++// resolveNodePackage looks name up the way Node resolves a bare specifier imported from dir: in+// node_modules of dir and of each of its ancestors. Empty when it does not resolve.+func resolveNodePackage(dir, name string) string {+ for current := filepath.Clean(dir); ; current = filepath.Dir(current) {+ if filepath.Base(current) != "node_modules" {+ candidate := filepath.Join(current, "node_modules", filepath.FromSlash(name))+ if packageVersion(candidate) != "" {+ return candidate+ }+ }+ if parent := filepath.Dir(current); parent == current {+ return ""+ }+ }+}++// packageRootFor finds the package named name that contains path (a package directory or a file+// inside one), or empty.+func packageRootFor(path, name string) string {+ current := filepath.Clean(path)+ for i := 0; i < 8; i++ {+ if packageName(current) == name {+ return current+ }+ parent := filepath.Dir(current)+ if parent == current {+ break+ }+ current = parent+ }+ return ""+}++type packageManifest struct {+ Name string `json:"name"`+ Version string `json:"version"`+ PeerDependencies map[string]string `json:"peerDependencies"`+}++// peerNames lists the declared peers in a stable order.+func (m packageManifest) peerNames() []string {+ names := make([]string, 0, len(m.PeerDependencies))+ for name := range m.PeerDependencies {+ names = append(names, name)+ }+ sort.Strings(names)+ return names+}++func readPackageManifest(dir string) packageManifest {+ if dir == "" {+ return packageManifest{}+ }+ data, err := os.ReadFile(filepath.Join(dir, "package.json"))+ if err != nil {+ return packageManifest{}+ }+ var manifest packageManifest+ _ = json.Unmarshal(data, &manifest)+ return manifest+}++func packageVersion(dir string) string { return readPackageManifest(dir).Version }+func packageName(dir string) string { return readPackageManifest(dir).Name }++// dshPatchLayers lists the patch files dsh composes: the home layer and each profile's own.+func dshPatchLayers(home string) []string {+ layers := []string{filepath.Join(home, dshPatchFileName)}+ profiles, _ := filepath.Glob(filepath.Join(home, dshProfilesDirName, "*", dshPatchFileName))+ sort.Strings(profiles)+ return append(layers, profiles...)+}++// dshPathMountNames returns the absolute `name` of every row in a patch layer that mounts a plugin+// by path with `config.configPath` equal to hooksPath. Rows are read from the top-level list and+// from `insert` lists. A configPath written as an expression cannot be evaluated here and does not+// match.+func dshPathMountNames(layer, hooksPath string) []string {+ data, err := os.ReadFile(layer)+ if err != nil {+ return nil+ }+ var doc yaml.Node+ if yaml.Unmarshal(data, &doc) != nil || len(doc.Content) == 0 || doc.Content[0].Kind != yaml.SequenceNode {+ return nil+ }+ want := filepath.Clean(hooksPath)+ var names []string+ consider := func(row *yaml.Node) {+ if row.Kind != yaml.MappingNode {+ return+ }+ name := mappingValue(row, "name")+ config := mappingValue(row, "config")+ if name == nil || name.Kind != yaml.ScalarNode || !filepath.IsAbs(name.Value) || config == nil {+ return+ }+ path := mappingValue(config, "configPath")+ if path == nil || path.Kind != yaml.ScalarNode || (path.Tag != "" && path.Tag != "!!str") {+ return+ }+ if filepath.Clean(path.Value) == want {+ names = append(names, name.Value)+ }+ }+ for _, element := range doc.Content[0].Content {+ consider(element)+ if insert := mappingValue(element, "insert"); insert != nil && insert.Kind == yaml.SequenceNode {+ for _, row := range insert.Content {+ consider(row)+ }+ }+ }+ return names+}++// dshHasPathMount reports whether any patch layer mounts a plugin by path at hooksPath, whatever its+// health. It is the path-mount half of "the hooks file is read".+func dshHasPathMount(hooksPath string) bool {+ for _, layer := range dshPatchLayers(filepath.Dir(hooksPath)) {+ if len(dshPathMountNames(layer, hooksPath)) > 0 {+ return true+ }+ }+ return false+}diff --git a/cli/beacon/internal/endpoint/hooks/dsh_bridge_test.go b/cli/beacon/internal/endpoint/hooks/dsh_bridge_test.gonew file mode 100644index 00000000..061d579d--- /dev/null+++ b/cli/beacon/internal/endpoint/hooks/dsh_bridge_test.go@@ -0,0 +1,242 @@+package hooks++import (+ "errors"+ "os"+ "path/filepath"+ "runtime"+ "strings"+ "testing"++ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks/dshtest"+)++const testDshVersion = "0.2.1-rc.2"++// dshBridgeHome isolates HOME, DSH_HOME and PATH so the real dsh on a developer machine is never+// seen, and returns the Harness home and Beacon's hooks file path in it.+func dshBridgeHome(t *testing.T) (dshHome, hooksPath string) {+ t.Helper()+ home := t.TempDir()+ t.Setenv("HOME", home)+ t.Setenv("USERPROFILE", home)+ dshHome = filepath.Join(home, "dsh-home")+ t.Setenv("DSH_HOME", dshHome)+ t.Setenv("PATH", t.TempDir())+ return dshHome, filepath.Join(dshHome, dshHookFileName)+}++func installDshForTest(t *testing.T) (DshStatus, error) {+ t.Helper()+ return InstallDsh(DshOptions{Level: LevelUser, LogPath: filepath.Join(t.TempDir(), "runtime.jsonl"), UserMode: true})+}++func TestInstallDshRefusesWhenNothingCanLoadTheBridge(t *testing.T) {+ dshHome, hooksPath := dshBridgeHome(t)+ dshtest.InstallCLI(t, testDshVersion)+ dshtest.Profile(t, dshHome, "web")++ _, err := installDshForTest(t)+ var unavailable *DshBridgeUnavailableError+ if !errors.As(err, &unavailable) {+ t.Fatalf("err = %v, want DshBridgeUnavailableError", err)+ }+ msg := err.Error()+ for _, want := range []string{+ "dsh plugin --profile web add @deepseek-ai/dsh-hooks-claude-code@" + testDshVersion + " @deepseek-ai/dsh-hook-protocol@" + testDshVersion,+ "Beacon does not install packages",+ "beacon endpoint dsh sync",+ } {+ if !strings.Contains(msg, want) {+ t.Fatalf("message %q does not contain %q", msg, want)+ }+ }+ for _, path := range []string{hooksPath, dshPatchPathFor(hooksPath)} {+ if _, err := os.Stat(path); !os.IsNotExist(err) {+ t.Fatalf("refused install wrote %s", path)+ }+ }+}++func TestInstallDshMountsWhenAProfileHasAMatchingBridge(t *testing.T) {+ dshHome, hooksPath := dshBridgeHome(t)+ dshtest.InstallCLI(t, testDshVersion)+ dshtest.InstallBridge(t, dshHome, "web", testDshVersion, testDshVersion)+ dshtest.Profile(t, dshHome, "headless")++ status, err := installDshForTest(t)+ if err != nil {+ t.Fatal(err)+ }+ if !status.Active || status.PathMounted || !dshPatchHasEntry(dshPatchPathFor(hooksPath)) {+ t.Fatalf("status = %+v, want an active install with Beacon's row", status)+ }+ if got := status.Bridge.ProfilesWithoutBridge(); len(got) != 1 || got[0] != "headless" {+ t.Fatalf("profiles without bridge = %v, want [headless]", got)+ }+ after := DshHookStatus(DshOptions{Level: LevelUser})+ if !after.Installed || !after.Active || after.Bridge.DshVersion != testDshVersion {+ t.Fatalf("status after install = %+v", after)+ }+}++func TestInstallDshNamesBothVersionsOnAMismatch(t *testing.T) {+ dshHome, _ := dshBridgeHome(t)+ dshtest.InstallCLI(t, testDshVersion)+ dshtest.InstallBridge(t, dshHome, "web", "0.2.1-alpha.2", "0.2.1-alpha.2")++ _, err := installDshForTest(t)+ if err == nil || !strings.Contains(err.Error(), "dsh is "+testDshVersion) || !strings.Contains(err.Error(), "is 0.2.1-alpha.2") {+ t.Fatalf("err = %v, want both versions named", err)+ }+ report := InspectDshBridge(dshHome, filepath.Join(dshHome, dshHookFileName))+ if report.Ready || report.Profiles[0].Status != DshBridgeVersionMismatch {+ t.Fatalf("report = %+v", report)+ }+}++func TestInspectDshBridgeNeedsTheProtocolPeer(t *testing.T) {+ dshHome, hooksPath := dshBridgeHome(t)+ dshtest.InstallCLI(t, testDshVersion)+ dshtest.InstallBridge(t, dshHome, "web", testDshVersion, "")+ report := InspectDshBridge(dshHome, hooksPath)+ if report.Ready || report.Profiles[0].Status != DshBridgeProtocolMissing {+ t.Fatalf("report = %+v, want protocol_missing", report)+ }+}++// A bridge mounted by absolute path at Beacon's hooks file, in a profile layer, is how a+// declarative setup installs it. Beacon accepts it, writes only the hooks file, and removes a row+// of its own so the bridge is not mounted twice.+func TestInstallDshAcceptsAPathMountAndWritesNoSecondMount(t *testing.T) {+ dshHome, hooksPath := dshBridgeHome(t)+ cli := dshtest.InstallCLI(t, testDshVersion)+ store := t.TempDir()+ bridge := filepath.Join(store, "bridge")+ dshtest.WriteBridge(t, bridge, testDshVersion)+ dshtest.WritePackage(t, filepath.Join(bridge, "node_modules", "@deepseek-ai", "dsh-hook-protocol"), dshtest.ProtocolPackage, testDshVersion)+ profile := dshtest.Profile(t, dshHome, "web")+ layer := filepath.Join(profile, dshPatchFileName)+ writeFile(t, layer, "# managed elsewhere\n- insert:\n - id: hooks-bridge\n name: "+filepath.Join(bridge, "lib", "index.js")+"\n config:\n configPath: "+hooksPath+"\n")++ // dsh does not hand a bridge mounted by path the packages it ships, so with its dsh peers+ // unresolvable from where it sits, the mount is skipped at boot and is not a route.+ report := InspectDshBridge(dshHome, hooksPath)+ if report.Ready || len(report.PathMounts) != 1 || report.PathMounts[0].Status != DshBridgePeersMissing ||+ !strings.Contains(report.PathMounts[0].Detail, "@deepseek-ai/dsh-llm") {+ t.Fatalf("path mount without its peers = %+v", report.PathMounts)+ }+ // The declarative package links them into the dsh installation.+ for _, peer := range dshtest.HostPeers {+ link := filepath.Join(bridge, "node_modules", filepath.FromSlash(peer))+ if err := os.MkdirAll(filepath.Dir(link), 0o755); err != nil {+ t.Fatal(err)+ }+ if err := os.Symlink(filepath.Join(cli, "node_modules", filepath.FromSlash(peer)), link); err != nil {+ t.Fatal(err)+ }+ }+ // A row left by an earlier Beacon install.+ if err := addDshPatchEntry(dshPatchPathFor(hooksPath), hooksPath); err != nil {+ t.Fatal(err)+ }++ status, err := installDshForTest(t)+ if err != nil {+ t.Fatal(err)+ }+ if !status.PathMounted || !status.Active {+ t.Fatalf("status = %+v, want an active path mount", status)+ }+ if dshPatchHasEntry(dshPatchPathFor(hooksPath)) {+ t.Fatal("Beacon's own row is still mounted beside the path mount; every hook would run twice")+ }+ if data, _ := os.ReadFile(layer); !strings.Contains(string(data), "# managed elsewhere") {+ t.Fatal("the profile layer was rewritten")+ }+ after := DshHookStatus(DshOptions{Level: LevelUser})+ if !after.Installed || !after.Active || !after.PathMounted {+ t.Fatalf("status after install = %+v, want installed, active and path-mounted", after)+ }++ // The same mount one version behind is reported, not accepted.+ dshtest.WritePackage(t, bridge, dshtest.BridgePackage, "0.2.1-alpha.2")+ stale := DshHookStatus(DshOptions{Level: LevelUser})+ if !stale.Installed || stale.Active || stale.Bridge.PathMounted() || stale.Bridge.PathMounts[0].Status != DshBridgeVersionMismatch {+ t.Fatalf("stale mount status = %+v", stale)+ }+}++func TestInspectDshBridgeFindsABridgeShippedWithDsh(t *testing.T) {+ dshHome, hooksPath := dshBridgeHome(t)+ pkg := dshtest.InstallCLI(t, testDshVersion)+ dshtest.WritePackage(t, filepath.Join(pkg, "node_modules", "@deepseek-ai", "dsh-hooks-claude-code"), dshtest.BridgePackage, testDshVersion)+ dshtest.WritePackage(t, filepath.Join(pkg, "node_modules", "@deepseek-ai", "dsh-hook-protocol"), dshtest.ProtocolPackage, testDshVersion)+ dshtest.Profile(t, dshHome, "web")+ report := InspectDshBridge(dshHome, hooksPath)+ if !report.Ready || report.Install == nil || report.Install.Status != DshBridgeOK || len(report.ProfilesWithoutBridge()) != 0 {+ t.Fatalf("report = %+v", report)+ }+}++// Package managers such as Nix install dsh behind wrapper scripts that exec another launcher,+// which execs node on the CLI's lib/bin.js. The version is read from that package, not by running dsh.+func TestDshInstallationIsFoundThroughWrapperLaunchers(t *testing.T) {+ if runtime.GOOS == "windows" {+ t.Skip("wrapper scripts are a Unix install shape; PATH lookup on Windows needs an extension")+ }+ _, _ = dshBridgeHome(t)+ root := t.TempDir()+ pkg := filepath.Join(root, "store", "lib", "node_modules", "@deepseek-ai", "dsh")+ dshtest.WritePackage(t, pkg, "@deepseek-ai/dsh", testDshVersion)+ inner := filepath.Join(root, "store", "bin", "dsh")+ writeFile(t, inner, "#!/bin/bash -e\nexec -a \"dsh\" \"/opt/node/bin/node\" "+filepath.Join(pkg, "lib", "bin.js")+" \"$@\"\n")+ bin := filepath.Join(root, "bin")+ writeFile(t, filepath.Join(bin, "dsh"), "#!/bin/bash\nexport DSH_TELEMETRY_DISABLED=1\nexec "+inner+" \"$@\"\n")+ for _, p := range []string{inner, filepath.Join(bin, "dsh")} {+ if err := os.Chmod(p, 0o755); err != nil {+ t.Fatal(err)+ }+ }+ t.Setenv("PATH", bin)+ inst := defaultProbeDshInstallation()+ if inst.version != testDshVersion || inst.modules != filepath.Join(pkg, "node_modules") {+ t.Fatalf("installation = %+v", inst)+ }+}++// On Windows npm writes dsh.cmd, dsh.ps1 and an sh shim into its prefix, each naming the CLI+// relative to the shim's own directory rather than linking to it.+func TestDshPackageIsFoundFromNpmWindowsShims(t *testing.T) {+ root, err := filepath.EvalSymlinks(t.TempDir()) // the launcher is resolved before it is read+ if err != nil {+ t.Fatal(err)+ }+ pkg := filepath.Join(root, "node_modules", "@deepseek-ai", "dsh")+ for name, shim := range map[string]string{"dsh.cmd": dshtest.NpmCmdShim, "dsh": dshtest.NpmShShim} {+ launcher := filepath.Join(root, name)+ writeFile(t, launcher, shim)+ if got := dshPackageFromLauncher(launcher, 0); got != pkg {+ t.Errorf("%s: package = %q, want %q", name, got, pkg)+ }+ }+}++func TestInspectDshBridgeWithoutDshIsUnverified(t *testing.T) {+ dshHome, hooksPath := dshBridgeHome(t)+ dshtest.InstallBridge(t, dshHome, "web", testDshVersion, testDshVersion)+ report := InspectDshBridge(dshHome, hooksPath)+ if !report.Ready || report.DshVersion != "" || report.Profiles[0].Status != DshBridgeUnverified || report.DshVersionError == "" {+ t.Fatalf("report = %+v", report)+ }+}++func writeFile(t *testing.T, path, content string) {+ t.Helper()+ if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(path, []byte(content), 0o644); err != nil {+ t.Fatal(err)+ }+}diff --git a/cli/beacon/internal/endpoint/hooks/dshtest/dshtest.go b/cli/beacon/internal/endpoint/hooks/dshtest/dshtest.gonew file mode 100644index 00000000..d75b62b8--- /dev/null+++ b/cli/beacon/internal/endpoint/hooks/dshtest/dshtest.go@@ -0,0 +1,132 @@+// Package dshtest builds on-disk DeepSeek Harness fixtures for tests: a dsh CLI package reachable+// on PATH, and profiles with the Claude Code hook bridge installed, so code that inspects whether+// dsh can load the bridge runs against files rather than a seam.+package dshtest++import (+ "encoding/json"+ "os"+ "path/filepath"+ "runtime"+ "testing"+)++const (+ BridgePackage = "@deepseek-ai/dsh-hooks-claude-code"+ ProtocolPackage = "@deepseek-ai/dsh-hook-protocol"+)++// HostPeers are the bridge's dsh peers that the dsh installation ships, a representative subset of+// what the real bridge declares.+var HostPeers = []string{"@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-llm"}++// NpmCmdShim is the dsh.cmd launcher npm (cmd-shim 9) writes into its prefix directory on Windows.+// It names the CLI relative to its own directory.+const NpmCmdShim = "@ECHO off\r\nGOTO start\r\n:find_dp0\r\nSET dp0=%~dp0\r\nEXIT /b\r\n:start\r\nSETLOCAL\r\nCALL :find_dp0\r\n\r\n" ++ "IF EXIST \"%dp0%\\node.exe\" (\r\n SET \"_prog=%dp0%\\node.exe\"\r\n) ELSE (\r\n SET \"_prog=node\"\r\n)\r\n\r\n" ++ "endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & set PATHEXT=%PATHEXT:;.JS;=;% & \"%_prog%\" \"%dp0%\\node_modules\\@deepseek-ai\\dsh\\lib\\bin.js\" %*\r\n"++// NpmShShim is the extensionless sh launcher npm (cmd-shim 9) writes beside dsh.cmd on Windows,+// abridged to the lines that locate the CLI.+const NpmShShim = "#!/bin/sh\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")\nbasedir_win=\"$basedir\"\n\n" ++ "PROG_EXE=\"$basedir/node.exe\"\nif ! [ -x \"$PROG_EXE\" ]; then\n PROG_EXE=node\nfi\n\n" ++ "exec \"$PROG_EXE\" \"$basedir_win/node_modules/@deepseek-ai/dsh/lib/bin.js\" \"$@\"\n"++// InstallCLI writes a dsh CLI package of the given version under a temporary directory and puts a+// `dsh` launcher for it first on PATH, the shape of an npm global install: a symlink to its+// lib/bin.js, or on Windows the package under the prefix's node_modules with a dsh.cmd shim.+// It returns the package directory.+func InstallCLI(t testing.TB, version string) string {+ t.Helper()+ root := t.TempDir()+ modules := filepath.Join(root, "lib", "node_modules")+ if runtime.GOOS == "windows" {+ modules = filepath.Join(root, "node_modules")+ }+ pkg := filepath.Join(modules, "@deepseek-ai", "dsh")+ WritePackage(t, pkg, "@deepseek-ai/dsh", version)+ for _, peer := range HostPeers {+ WritePackage(t, filepath.Join(pkg, "node_modules", filepath.FromSlash(peer)), peer, version)+ }+ binJS := filepath.Join(pkg, "lib", "bin.js")+ if err := os.MkdirAll(filepath.Dir(binJS), 0o755); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(binJS, []byte("#!/usr/bin/env node\n"), 0o755); err != nil {+ t.Fatal(err)+ }+ if runtime.GOOS == "windows" {+ if err := os.WriteFile(filepath.Join(root, "dsh.cmd"), []byte(NpmCmdShim), 0o755); err != nil {+ t.Fatal(err)+ }+ t.Setenv("PATH", root+string(os.PathListSeparator)+os.Getenv("PATH"))+ return pkg+ }+ bin := filepath.Join(root, "bin")+ if err := os.MkdirAll(bin, 0o755); err != nil {+ t.Fatal(err)+ }+ if err := os.Symlink(binJS, filepath.Join(bin, "dsh")); err != nil {+ t.Fatal(err)+ }+ t.Setenv("PATH", bin+string(os.PathListSeparator)+os.Getenv("PATH"))+ return pkg+}++// InstallBridge installs the bridge and its protocol peer at version into a profile under dshHome,+// as `dsh plugin --profile <profile> add` leaves them, and returns the profile directory.+func InstallBridge(t testing.TB, dshHome, profile, bridgeVersion, protocolVersion string) string {+ t.Helper()+ dir := filepath.Join(dshHome, "profiles", profile)+ WriteBridge(t, filepath.Join(dir, "node_modules", filepath.FromSlash(BridgePackage)), bridgeVersion)+ if protocolVersion != "" {+ WritePackage(t, filepath.Join(dir, "node_modules", filepath.FromSlash(ProtocolPackage)), ProtocolPackage, protocolVersion)+ }+ return dir+}++// Profile creates an empty profile directory under dshHome.+func Profile(t testing.TB, dshHome, profile string) string {+ t.Helper()+ dir := filepath.Join(dshHome, "profiles", profile)+ if err := os.MkdirAll(dir, 0o755); err != nil {+ t.Fatal(err)+ }+ return dir+}++// WriteBridge writes a bridge package at dir that declares its peers, pinned to version, the way+// the published bridge does.+func WriteBridge(t testing.TB, dir, version string) {+ t.Helper()+ peers := map[string]string{ProtocolPackage: version}+ for _, peer := range HostPeers {+ peers[peer] = version+ }+ writeManifest(t, dir, map[string]interface{}{"name": BridgePackage, "version": version, "peerDependencies": peers})+}++// WritePackage writes a package.json naming a package at dir.+func WritePackage(t testing.TB, dir, name, version string) {+ t.Helper()+ writeManifest(t, dir, map[string]interface{}{"name": name, "version": version})+}++func writeManifest(t testing.TB, dir string, manifest map[string]interface{}) {+ t.Helper()+ if err := os.MkdirAll(dir, 0o755); err != nil {+ t.Fatal(err)+ }+ data, _ := json.Marshal(manifest)+ if err := os.WriteFile(filepath.Join(dir, "package.json"), data, 0o644); err != nil {+ t.Fatal(err)+ }+}++// Ready installs a dsh CLI at version and a matching bridge in profile "web" under dshHome, the+// fixture a test needs when it only wants the install to proceed.+func Ready(t testing.TB, dshHome, version string) {+ t.Helper()+ InstallCLI(t, version)+ InstallBridge(t, dshHome, "web", version, version)+}diff --git a/cli/beacon/internal/endpoint/inventory/dsh_test.go b/cli/beacon/internal/endpoint/inventory/dsh_test.goindex 12715d72..fbe40416 100644--- a/cli/beacon/internal/endpoint/inventory/dsh_test.go+++ b/cli/beacon/internal/endpoint/inventory/dsh_test.go@@ -124,3 +124,36 @@ func TestScanReportsNoProjectScopedDshConfig(t *testing.T) {}}}++// A declarative setup mounts the bridge by absolute path in a profile's own patch layer, pointing+// it at Beacon's hooks file. That layer is reported, and as Beacon-managed even though it names no+// package, so a working install is not shown as a half-install.+func TestScanReportsAProfileLayerThatMountsTheBridgeByPath(t *testing.T) {+ home := t.TempDir()+ work := t.TempDir()+ t.Setenv("DSH_HOME", "")+ dir := filepath.Join(home, ".dsh")+ hooksPath := filepath.Join(dir, "beacon-endpoint-hooks.json")+ layer := filepath.Join(dir, "profiles", "web", "cordis.patch.yml")+ other := filepath.Join(dir, "profiles", "tui", "cordis.patch.yml")+ for path, content := range map[string]string{+ layer: "- insert:\n - id: hooks-bridge\n name: /nix/store/abc-bridge/lib/index.js\n config:\n configPath: " + hooksPath + "\n",+ other: "- id: tools\n config: {}\n",+ } {+ if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(path, []byte(content), 0644); err != nil {+ t.Fatal(err)+ }+ }+ result := Scan(Options{HomeDir: home, WorkingDir: work})+ mounted := findConfig(result.Configs, "deepseek_harness", layer)+ if mounted == nil || !mounted.BeaconManaged {+ t.Fatalf("profile layer mounting the bridge at Beacon's hooks file = %+v, want reported and Beacon-managed", mounted)+ }+ unrelated := findConfig(result.Configs, "deepseek_harness", other)+ if unrelated == nil || unrelated.BeaconManaged {+ t.Fatalf("an unrelated profile layer = %+v, want reported and not Beacon-managed", unrelated)+ }+}diff --git a/cli/beacon/internal/endpoint/inventory/inventory.go b/cli/beacon/internal/endpoint/inventory/inventory.goindex 54f527da..ef9ff086 100644--- a/cli/beacon/internal/endpoint/inventory/inventory.go+++ b/cli/beacon/internal/endpoint/inventory/inventory.go@@ -609,12 +609,27 @@ func kiroCandidates(home, wd string) []candidate {// The patch file is listed as YAML and the hooks file as JSON, which is what they are -- and the// patch file is also the user's own, so the inventory may well find rows in it that have nothing to// do with Beacon. Detection keys on Beacon's mount, not on the file existing.+//+// Each profile's own patch layer is listed too, because that is where a declarative setup (a Nix+// store path, say) mounts the bridge at Beacon's hooks file instead of Beacon's row in the home+// layer. Without it, an install that works would look like a half-install here.func dshCandidates(home string) []candidate {dir := dshUserDir(home)- return []candidate{+ items := []candidate{{runtime: "deepseek_harness", path: filepath.Join(dir, "beacon-endpoint-hooks.json"), scope: ScopeUser, format: formatJSON, kind: KindHookConfig},{runtime: "deepseek_harness", path: filepath.Join(dir, "cordis.patch.yml"), scope: ScopeUser, format: formatYAML, kind: KindHookConfig},}+ entries, _ := readDirPath(filepath.Join(dir, "profiles"))+ for _, entry := range entries {+ if !entry.IsDir() {+ continue+ }+ layer := filepath.Join(dir, "profiles", entry.Name(), "cordis.patch.yml")+ if _, err := statPath(layer); err == nil {+ items = append(items, candidate{runtime: "deepseek_harness", path: layer, scope: ScopeUser, format: formatYAML, kind: KindHookConfig})+ }+ }+ return items}// kimiCandidates covers the one file a Kimi Code install touches.@@ -1114,9 +1129,13 @@ func beaconManaged(item candidate, data []byte) bool {// the plugin specifier the loader resolves, so it cannot be edited to something else and still// work. A user who mounts the bridge themselves would match too -- which is correct, since// that is a live route from this runtime into a hooks file.+ //+ // A patch layer that mounts the bridge by path (a Nix store path names no package) is+ // recognized by the hooks file it points the bridge at, which is Beacon's.case "deepseek_harness":return strings.Contains(text, "--platform dsh") || strings.Contains(text, "--platform=dsh") ||- strings.Contains(text, "@deepseek-ai/dsh-hooks-claude-code")+ strings.Contains(text, "@deepseek-ai/dsh-hooks-claude-code") ||+ strings.Contains(text, "beacon-endpoint-hooks.json")// Matched on the hook command rather than on the comment Beacon writes above its block, and// here that is not a preference between two working options: Kimi Code's legacy migration// from `kimi-cli` rewrites this file by serializing the merged config, which keeps thediff --git a/cli/beacon/internal/endpoint/inventory/inventory_test.go b/cli/beacon/internal/endpoint/inventory/inventory_test.goindex c9798281..224eca68 100644--- a/cli/beacon/internal/endpoint/inventory/inventory_test.go+++ b/cli/beacon/internal/endpoint/inventory/inventory_test.go@@ -547,6 +547,9 @@ func TestScanIncludesAllSupportedCurrentUserAndProjectConfigs(t *testing.T) {home := t.TempDir()work := t.TempDir()t.Setenv("SHELL", "/bin/bash")+ // The Harness home is pinned under home: its profiles' patch layers are candidates too, so a+ // developer whose DSH_HOME points at a real one would otherwise see their profiles counted.+ t.Setenv("DSH_HOME", "")// Oh My Pi's user extension path is the one candidate an environment variable can move, so the// variables it reads are cleared: a developer who happens to run Oh My Pi under a profile would// otherwise see this test fail on a path that is correct for their machine.diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex 24a2c64b..4a877be1 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -25,6 +25,7 @@ Stay up to date with the latest changes to the Agent Beacon CLI.- **Splunk and Falcon HEC forwarding redacts secrets** · With direct Splunk HEC or Falcon LogScale HEC forwarding configured, credentials in prompts, tool output and other telemetry reached the SIEM unredacted, while the local runtime log redacted them. The collector now redacts secrets before telemetry fans out to those exporters, with the same rules as the local log. Installs without HEC forwarding are unchanged.- **Dashboard session IDs are real links** · Session IDs in the dashboard's session list only responded to a row click, so they couldn't be reached with Tab or opened in a new tab. Each ID is now a link: Tab and Enter open the session, and modifier-click or middle-click opens it in another tab. Clicking elsewhere in the row still opens it.- **Dashboard harness and model filters stick** · A bookmarked or shared dashboard URL with a harness or model filter loaded unfiltered, because the filter was applied before its options had loaded, and a search with no results cleared the selected harness or model, so the next refresh broadened the view. Selections now hold until you choose All.+- **DeepSeek Harness hooks are installed only where dsh can load them** · `beacon endpoint hooks install --harness dsh` mounted DeepSeek's Claude Code hook bridge by package name, but `dsh` does not ship that bridge, so on a standard install the mount was skipped at boot with `warning: 1 entry did not activate` and the hooks recorded nothing while the install reported success. Install now checks, read-only, whether the `dsh` installation, a profile, or an existing mount by path loads `@deepseek-ai/dsh-hooks-claude-code` and `@deepseek-ai/dsh-hook-protocol` at exactly the running `dsh` version. When nothing does, an explicit `--harness dsh` install refuses and writes nothing, and `--all` and `beacon endpoint install` skip DeepSeek Harness with a warning; both give the `dsh plugin --profile <name> add …` command at your version and point at `beacon endpoint dsh sync`. Beacon never installs the packages itself. A bridge already mounted by absolute path at Beacon's hooks file (how a Nix setup mounts it) counts as installed when its `dsh` peers resolve from where it sits, and Beacon writes no second mount. `hooks status` reports `active` and the bridge detail, discovery reports an install dsh cannot load as misconfigured, inventory lists each profile's patch layer, and the new doctor check `dsh_hook_bridge` names both versions when a `dsh` upgrade leaves the bridge behind. See [Installing the hook bridge](/runtimes/deepseek-harness#installing-the-hook-bridge).- **Dashboard output tokens count reasoning once** · The local dashboard's token view added reasoning tokens to output, but `gen_ai.usage.output_tokens` already includes them, so models that report reasoning had their output and total tokens overstated. Output and the total now count reasoning once, the split bar no longer shows reasoning as a separate segment, and a note below it gives the reasoning count included in output. `beacon token-usage` already counted it this way.---diff --git a/docs/cli/endpoint-doctor.mdx b/docs/cli/endpoint-doctor.mdxindex 04b925da..9f7d2264 100644--- a/docs/cli/endpoint-doctor.mdx+++ b/docs/cli/endpoint-doctor.mdx@@ -26,6 +26,7 @@ Doctor verifies:- Runtime log permissions- Service definition: launchd plist on macOS, systemd unit on Linux- Configured harness telemetry and recent observed events+- Whether DeepSeek Harness can load the hook bridge its hooks depend on (`dsh_hook_bridge`)- Whether DeepSeek Harness hooks are actually recording live events (`dsh_hook_capture`)- Whether Beacon's git hooks ran out of time recently (`git_hook_budget`)- Whether a real user's agent runtime points at the collector (system mode only)@@ -48,6 +49,26 @@ Everything else can be green when this fails. The collector is running, the servIf no logged-in user can be identified at all, this reports a warning rather than a failure: an unattended host legitimately has nobody to configure, and that is not something an operator can act on.+### `dsh_hook_bridge`++This check runs only when DeepSeek Harness is detected and Beacon's hooks for it are installed. `dsh` does not ship the Claude Code hook bridge the hooks run through, and a mount it cannot load is skipped at boot with a warning, so an install can be complete on disk and record nothing. The check reports what Beacon found about the bridge:++```+dsh_hook_bridge: warn target=deepseek_harness (DeepSeek Harness hooks are installed but dsh cannot+ load them: hook bridge cannot be loaded by dsh 0.2.2: dsh is 0.2.2 but+ @deepseek-ai/dsh-hooks-claude-code is 0.2.1-rc.2 and @deepseek-ai/dsh-hook-protocol is 0.2.1-rc.2; ...)+ action="run `dsh plugin --profile <profile> add @deepseek-ai/[email protected] @deepseek-ai/[email protected]` (Beacon does not install packages), then restart dsh; ..."+```++| Evidence | Status | Meaning |+|----------|--------|---------|+| `dsh_hook_bridge_loads` | ok | A bridge and protocol matching `dsh` load, from a profile, the installation, or a path mount |+| `dsh_hook_bridge_partial` | warn | Some profiles have no bridge and boot without hooks; they are named |+| `dsh_hook_bridge_unavailable` | warn | Nothing loads a matching bridge, most often after a `dsh` upgrade (both versions are named), or a bridge mounted by path whose `dsh` peers do not resolve from where it sits |+| `dsh_version_unknown` | warn | A bridge resolves, but `dsh` is not on `PATH`, so its version cannot be compared |++It is a warning, not a failure: installing packages into a `dsh` profile is the operator's step, and Beacon does not take it. `--fix` lists the check as a manual skip. See [Installing the hook bridge](/runtimes/deepseek-harness#installing-the-hook-bridge).+### `dsh_hook_capture`This check runs only when DeepSeek Harness is detected and Beacon's hooks for it are installed. It catches a failure no other check sees: the hooks are loaded, but they cannot write the runtime log because `dsh` runs them inside its session sandbox. `harness_observed` stays green in this state, because `beacon endpoint dsh sync` fills the log with poll events under the same harness name.diff --git a/docs/runtimes/deepseek-harness.mdx b/docs/runtimes/deepseek-harness.mdxindex 9f1ed369..a68ad2e6 100644--- a/docs/runtimes/deepseek-harness.mdx+++ b/docs/runtimes/deepseek-harness.mdx@@ -5,7 +5,7 @@ description: "Beacon support details for DeepSeek Harness (dsh) endpoint telemet## Runtime overview-Beacon supports DeepSeek Harness — DeepSeek's open agent harness, run as `dsh` — through the Claude Code hook bridge DeepSeek ships in the CLI, sent to `beacon-hooks`, plus a local poll of DeepSeek's native session files.+Beacon supports DeepSeek Harness — DeepSeek's open agent harness, run as `dsh` — through the Claude Code hook bridge DeepSeek publishes for every `dsh` release, sent to `beacon-hooks`, plus a local poll of DeepSeek's native session files.```bashbeacon endpoint hooks install --harness dsh@@ -16,14 +16,19 @@ beacon endpoint hooks install --harness dshDeepSeek Harness is composed rather than configured: every capability is a plugin, and the CLI, Web, ACP, and SDK surfaces are four compositions of one harness booting from one Harness home. There is one integration rather than one per surface, and one harness name — `deepseek_harness` — rather than a name per surface.<Note>-**`dsh` does not read a hooks file until something mounts a reader at it.** `@deepseek-ai/dsh-hooks-claude-code` ships as a dependency of the `dsh` CLI but is not in the default plugin tree, so there is no convention that picks a hooks file up. That is why a Beacon install here is **two files**: the hooks file, and one row mounting the bridge at it.+**`dsh` does not read a hooks file until something mounts a reader at it.** That reader is `@deepseek-ai/dsh-hooks-claude-code`, which is not in the default plugin tree, so there is no convention that picks a hooks file up. That is why a Beacon install here is **two files**: the hooks file, and one row mounting the bridge at it.</Note>+<Warning>+**The bridge is not shipped with `dsh`.** It is only a development dependency of the `dsh` CLI, so a profile has it only when it has been [installed into that profile](#installing-the-hook-bridge), together with `@deepseek-ai/dsh-hook-protocol`, at exactly the `dsh` version. A mount `dsh` cannot load does not stop it from starting: the profile boots with `warning: 1 entry did not activate` and runs with no hooks. Beacon checks for a loadable bridge before it mounts one, and refuses rather than writing a mount that records nothing.+</Warning>+## PrerequisitesBefore enabling DeepSeek Harness telemetry, make sure:- `dsh` is installed and has been run at least once, so the Harness home exists.+- The hook bridge is installed in the profiles you use, at your `dsh` version. See [Installing the hook bridge](#installing-the-hook-bridge). Session sync needs no bridge.- `beacon endpoint install` has run so shared endpoint config and runtime log paths exist.- `dsh` is restarted after hook install or removal, unless your profile enables HMR — the config watcher picks the patch layer up live, and without it the plugin tree is read at startup.@@ -53,6 +58,35 @@ The row Beacon adds looks like this:The home-level patch layer is applied over **every** profile and outranks each profile's own, so one install covers `dsh`, `dsh web`, the ACP server, and the SDK. `configPath` is absolute because the bridge resolves a relative path against the directory the process was launched from, which for an agent runtime is wherever you happened to be standing.+### Installing the hook bridge++The row names the bridge by package, and `dsh` resolves it from each profile's directory. Install it into every profile you run, with DeepSeek's own plugin manager, at exactly your `dsh` version:++```bash+dsh --version # for example 0.2.1-rc.2+dsh plugin --profile web add \+ @deepseek-ai/[email protected] \+ @deepseek-ai/[email protected]+```++Both packages are published for every `dsh` release and pin their `dsh` peers to it exactly, so a bridge for another version fails to load the same quiet way a missing one does. Upgrading `dsh` means installing the bridge again at the new version.++Beacon never installs these packages itself. Before it writes the row, `beacon endpoint hooks install --harness dsh` checks, read-only, whether a matching bridge and protocol resolve:++- from the `dsh` installation, for a release that ships the bridge;+- from each profile under `$DSH_HOME/profiles`; or+- through a row that already mounts a bridge **by absolute path** at Beacon's hooks file, in the home layer or a profile's own layer. This is how a declarative setup installs it, for example a Nix store path. Beacon treats it as installed, writes only the hooks file, and adds no row of its own (removing one an earlier install wrote), because a second mount would run every hook twice. A bridge mounted by path does not see the packages `dsh` ships, which `dsh` provides only to profile plugins, so its declared `@deepseek-ai/*` peers (`dsh-agent`, `dsh-llm`, `cordis` and the rest) and the protocol must resolve from where it sits, for example as `node_modules` links into the `dsh` installation. Without them `dsh` fails to import it with `Cannot find package '@deepseek-ai/dsh-llm'`, and Beacon reports the mount as `peers_missing` rather than installed.++| What Beacon finds | `hooks install --harness dsh` | `hooks install --all`, `endpoint install` |+|-------------------|-------------------------------|-------------------------------------------|+| No route loads a matching bridge | Refuses, exits non-zero, writes nothing | Skips DeepSeek Harness with a warning; other runtimes install |+| Some profiles have it, others do not | Installs, and names the profiles that will boot without hooks | Same |+| A matching path mount | Writes the hooks file only | Same |++Every refusal and warning gives the `dsh plugin --profile <name> add …` command at your version, and points at [`beacon endpoint dsh sync`](/cli/endpoint-dsh), which collects sessions from the session store with no bridge at all.++The `dsh` version is read from the installation the `dsh` on `PATH` launches, following wrapper scripts, and from `dsh --version` when the installation cannot be found that way.+Beacon also reads committed native session records from `$DSH_HOME/sessions` through:```bash@@ -139,7 +173,9 @@ Beacon's hooks carry no `matcher`. An absent matcher is the match-all form in thbeacon endpoint hooks status --harness dsh```-Status reports **both** paths, because `installed` is the conjunction of the two files: a hooks file with nothing mounted at it is a file nothing reads, and a mount pointing at a missing hooks file is a bridge that logs a warning and registers nothing. `beacon endpoint inventory` lists both for the same reason, so a half-install is visible as a half-install.+Status reports **both** paths, because `installed` is the conjunction of the two files: a hooks file with nothing mounted at it is a file nothing reads, and a mount pointing at a missing hooks file is a bridge that logs a warning and registers nothing. `beacon endpoint inventory` lists both for the same reason, so a half-install is visible as a half-install. A bridge mounted by path in a profile's own `cordis.patch.yml` counts as the mount, and inventory lists each profile's patch layer.++Status also reports `active`: the files are in place **and** some route loads a bridge matching the running `dsh`. `--json` carries the detail under `bridge`: the `dsh` version, each profile with the bridge and protocol versions it resolves and a status (`ok`, `missing`, `protocol_missing`, `version_mismatch`, or `unverified` when the `dsh` version is unknown), and any path mounts, which can also be `peers_missing`. Discovery reports an installed but inactive integration as misconfigured, and `beacon endpoint doctor` explains it under [`dsh_hook_bridge`](/cli/endpoint-doctor#dsh_hook_bridge).DeepSeek Harness reports as the `deepseek_harness` harness with capability `hooks+session_log`. Live hook events carry `harness.collection_method=hook`; backfilled native session events carry `harness.collection_method=poll`. The bridge is a plugin, but it is DeepSeek's plugin, shipped and versioned with the CLI; what Beacon contributes is command hooks, and the thing that runs on each hook event is the same `beacon-hooks` binary every other hook runtime runs.@@ -276,6 +312,7 @@ grep '"name":"deepseek_harness"' ~/.beacon/endpoint/logs/runtime.jsonl | tail -3If DeepSeek Harness telemetry is missing:+- Run `beacon endpoint doctor`. If it reports `dsh_hook_bridge: warn`, `dsh` cannot load the bridge, or some profiles cannot: it names the `dsh` and bridge versions and the command that installs a matching bridge. The startup line `warning: 1 entry did not activate` with `Cannot find package '@deepseek-ai/dsh-hooks-claude-code'` (or `dsh-hook-protocol`) is the same problem seen from `dsh`. See [Installing the hook bridge](#installing-the-hook-bridge).- Run `beacon endpoint doctor`. If it reports `dsh_hook_capture: warn`, the hooks are loaded but cannot write the log, which is almost always the session sandbox. See [Live hooks and the DeepSeek Harness sandbox](#live-hooks-and-the-deepseek-harness-sandbox). Hook stderr, and `dsh`'s own hook output, will show `beacon-hooks: this event was NOT recorded`.- Confirm **both** files exist. `beacon endpoint hooks status --harness dsh` prints both paths; either one alone is inert.- Check `$DSH_HOME`: if it is set, both files are under that directory, not `~/.dsh`.diff --git a/docs/runtimes/index.mdx b/docs/runtimes/index.mdxindex 94043947..1c335919 100644--- a/docs/runtimes/index.mdx+++ b/docs/runtimes/index.mdx@@ -117,7 +117,7 @@ MDM assets, meaning Jamf Pro Extension Attributes, Fleet osquery queries, and Ri| Cursor | The default `beacon endpoint install` detects Cursor and installs its hooks. To backfill committed local sessions, schedule `beacon endpoint cursor sync` in the logged-in user's context or leave `--watch` running. || Cline | Install the managed plugin with `beacon endpoint hooks install --harness cline`. To backfill committed local tasks and sessions, schedule `beacon endpoint cline sync` in the logged-in user's context or leave `--watch` running. || Codex CLI | `beacon endpoint install` configures local OTLP export. To backfill committed sessions, schedule `beacon endpoint codex sync` in the logged-in user's context or leave `--watch` running. |-| DeepSeek Harness | Install hooks with `beacon endpoint hooks install --harness dsh`. To backfill committed native sessions, schedule `beacon endpoint dsh sync` in the logged-in user's context or leave `--watch` running. |+| DeepSeek Harness | Install the hook bridge into each profile at your `dsh` version ([how](/runtimes/deepseek-harness#installing-the-hook-bridge)), then install hooks with `beacon endpoint hooks install --harness dsh`. To backfill committed native sessions, schedule `beacon endpoint dsh sync` in the logged-in user's context or leave `--watch` running. || Gemini CLI | The default `beacon endpoint install` detects Gemini and manages `~/.gemini/settings.json` for local OTLP collection. Use an explicit list such as `claude,codex,gemini` when automatic discovery is unavailable. || fx (Vercel Labs) | Nothing to configure in fx. Schedule [`beacon endpoint fx sync`](/cli/endpoint-fx) in the logged-in user's context, or leave `--watch` running, so committed sessions keep reaching the runtime log. Nothing sweeps on its own. || OpenCode | Install the managed plugin for live telemetry with `beacon endpoint hooks install --harness opencode`. To backfill committed local sessions, schedule [`beacon endpoint opencode sync`](/cli/endpoint-opencode) in the logged-in user's context or leave `--watch` running. |diff --git a/docs/runtimes/integration-model.mdx b/docs/runtimes/integration-model.mdxindex b93cef39..bc266c47 100644--- a/docs/runtimes/integration-model.mdx+++ b/docs/runtimes/integration-model.mdx@@ -62,7 +62,7 @@ During install, Beacon configures the runtime surfaces it can safely manage:| [Codex CLI](/runtimes/codex-cli) | Local OTLP logs, selective turn traces, SessionStart hook, and poll of `~/.codex/sessions` | Beacon writes structured Codex OTLP config, filters noisy internal spans, and joins OS-user context to per-turn usage. `beacon endpoint codex sync` backfills committed sessions as poll events. || [Gemini CLI](/runtimes/gemini-cli) | Opt-in local OTLP logs, traces, and metrics | Beacon writes Gemini telemetry settings and maps Gemini prompts, tool calls, MCP activity, file operations, and approval events into endpoint events. || [GitHub Copilot CLI](/runtimes/github-copilot-cli) | MDM-managed OTLP HTTP export plus poll of `~/.copilot/session-state` | Beacon validates Copilot's effective launch environment and maps Copilot spans into prompt, session, tool, and approval-like endpoint events. `beacon endpoint copilot sync` backfills committed session records as poll events with assistant text, complete tool results, commands, file activity, and token usage. |-| [DeepSeek Harness](/runtimes/deepseek-harness) | Native hook bridge plus poll of `$DSH_HOME/sessions` | Beacon installs an owned hooks file and a mount row in the runtime's home-level `cordis.patch.yml`. `beacon endpoint dsh sync` backfills assistant text/reasoning, failures, persisted tool detail, and token usage as poll events. There is no project scope. |+| [DeepSeek Harness](/runtimes/deepseek-harness) | Native hook bridge plus poll of `$DSH_HOME/sessions` | Beacon installs an owned hooks file and a mount row in the runtime's home-level `cordis.patch.yml`, once it has checked that a profile, the installation, or an existing path mount loads a bridge matching the running `dsh`; the bridge itself is installed per profile with `dsh plugin`. `beacon endpoint dsh sync` backfills assistant text/reasoning, failures, persisted tool detail, and token usage as poll events. There is no project scope. || [Kimi Code](/runtimes/kimi-code) | Native hook payloads through `beacon-hooks` | Beacon appends a verified `[[hooks]]` block to the runtime's existing `config.toml` without reserializing the file. Hooks cover lifecycle, prompts, tools, commands, files, MCP, subagents, compaction, and observed permission decisions. Kimi exposes no token usage on hooks and has no project scope. || [VS Code](/runtimes/vscode) | Copilot Chat OTel plus optional preview hooks | Beacon writes VS Code Copilot OTel settings and maps Copilot prompts, sessions, model metadata, and tool activity into endpoint events. Hooks are optional for extra lifecycle and cross-agent detail. || [Antigravity CLI](/runtimes/antigravity-cli) | Native hook payloads through `beacon-hooks` | Beacon writes a managed Antigravity hook block and maps prompt, pre-tool, post-tool, invocation, command, file edit, and diff telemetry into endpoint events. |