Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

feat(endpoint): report DeepSeek Harness in inventory, dashboard and token coverage

Claude12a975b84a5b
diff --git a/cli/beacon/internal/endpoint/dashboard/dsh_test.go b/cli/beacon/internal/endpoint/dashboard/dsh_test.go
new file mode 100644
index 00000000..718fc439
--- /dev/null
+++ b/cli/beacon/internal/endpoint/dashboard/dsh_test.go
@@ -0,0 +1,53 @@
+package dashboard
+
+import (
+ "path/filepath"
+ "testing"
+
+ endpointhooks "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks"
+)
+
+// The dashboard's harness list is a hand-written sequence of calls, one per runtime, so a runtime
+// left out of it is simply absent from the page with nothing to say it should have been there. An
+// operator checking their coverage would conclude DeepSeek Harness is not supported.
+func TestHookStatusesIncludesDsh(t *testing.T) {
+ home := t.TempDir()
+ t.Setenv("HOME", home)
+ t.Setenv("USERPROFILE", home)
+ t.Setenv("DSH_HOME", "")
+
+ logPath := filepath.Join(home, "runtime.jsonl")
+ find := func() *HookStatus {
+ statuses := hookStatuses(logPath, true)
+ for i := range statuses {
+ if statuses[i].Target == "dsh" {
+ return &statuses[i]
+ }
+ }
+ return nil
+ }
+
+ dsh := find()
+ if dsh == nil {
+ t.Fatal("hookStatuses omits dsh; the dashboard would show it as an unsupported runtime")
+ }
+ if dsh.Installed {
+ t.Fatalf("dsh reported installed with nothing in the Harness home: %+v", dsh)
+ }
+ if dsh.Path == "" {
+ t.Fatalf("dsh reported no path: %+v", dsh)
+ }
+
+ if _, err := endpointhooks.InstallDsh(endpointhooks.DshOptions{
+ Level: endpointhooks.LevelUser, LogPath: logPath, UserMode: true,
+ }); err != nil {
+ t.Fatalf("InstallDsh: %v", err)
+ }
+ after := find()
+ if after == nil {
+ t.Fatal("dsh disappeared from hookStatuses after an install")
+ }
+ if !after.Installed {
+ t.Fatalf("dsh still reported not installed after an install: %+v", after)
+ }
+}
diff --git a/cli/beacon/internal/endpoint/dashboard/server.go b/cli/beacon/internal/endpoint/dashboard/server.go
index 23ed7723..7d659811 100644
--- a/cli/beacon/internal/endpoint/dashboard/server.go
+++ b/cli/beacon/internal/endpoint/dashboard/server.go
@@ -376,6 +376,11 @@ func hookStatuses(logPath string, userMode bool) []HookStatus {
add("openhands", openhands.Installed, openhands.HooksPath, openhands.BinaryPath, openhands.Message)
kiro := endpointhooks.KiroHookStatus(endpointhooks.KiroOptions{Level: level, LogPath: logPath, UserMode: userMode})
add("kiro", kiro.Installed, kiro.HooksPath, kiro.BinaryPath, kiro.Message)
+ // The hooks file is the path reported, because it is the one a person would open. The patch
+ // file that mounts the bridge at it is not shown here -- this row carries one path -- and
+ // `beacon endpoint hooks status` reports both.
+ dsh := endpointhooks.DshHookStatus(endpointhooks.DshOptions{Level: level, LogPath: logPath, UserMode: userMode})
+ add("dsh", dsh.Installed, dsh.HooksPath, dsh.BinaryPath, dsh.Message)
muse := endpointhooks.MuseHookStatus(endpointhooks.MuseOptions{Level: level, LogPath: logPath, UserMode: userMode})
add("muse", muse.Installed, muse.HooksPath, muse.BinaryPath, muse.Message)
qwen := endpointhooks.QwenHookStatus(endpointhooks.QwenOptions{Level: level, LogPath: logPath, UserMode: userMode})
diff --git a/cli/beacon/internal/endpoint/inventory/dsh_test.go b/cli/beacon/internal/endpoint/inventory/dsh_test.go
new file mode 100644
index 00000000..12715d72
--- /dev/null
+++ b/cli/beacon/internal/endpoint/inventory/dsh_test.go
@@ -0,0 +1,126 @@
+package inventory
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+// A DeepSeek Harness install is two files and either one alone is inert: the hooks file is a file
+// nothing reads until the patch layer mounts the bridge at it, and the mount registers nothing
+// until the hooks file is there. So the inventory has to report both, and has to report each one's
+// Beacon-managed state independently -- a scan that collapsed them would show a half-install as a
+// whole one, which is the failure mode this runtime makes easiest to hit.
+func TestScanReportsBothHalvesOfADshInstall(t *testing.T) {
+ home := t.TempDir()
+ work := t.TempDir()
+ t.Setenv("DSH_HOME", "")
+
+ dir := filepath.Join(home, ".dsh")
+ if err := os.MkdirAll(dir, 0755); err != nil {
+ t.Fatalf("mkdir: %v", err)
+ }
+ hooksPath := filepath.Join(dir, "beacon-endpoint-hooks.json")
+ patchPath := filepath.Join(dir, "cordis.patch.yml")
+
+ // Only the hooks file, with Beacon's command in it. The mount is missing.
+ if err := os.WriteFile(hooksPath, []byte(`{"PreToolUse":[{"hooks":[{"type":"command",`+
+ `"command":"'/opt/beacon/bin/beacon-hooks' --platform dsh --log '/l' --config '/c' pre-tool"}]}]}`), 0644); err != nil {
+ t.Fatalf("write hooks: %v", err)
+ }
+ // And a patch file that is the user's own, mounting something else entirely.
+ if err := os.WriteFile(patchPath, []byte("- insert:\n - id: schedule\n name: '@deepseek-ai/dsh-schedule'\n"), 0644); err != nil {
+ t.Fatalf("write patch: %v", err)
+ }
+
+ result := Scan(Options{HomeDir: home, WorkingDir: work})
+
+ hooks := findConfig(result.Configs, "deepseek_harness", hooksPath)
+ if hooks == nil {
+ t.Fatalf("scan did not report %s", hooksPath)
+ }
+ if !hooks.BeaconManaged {
+ t.Fatal("the hooks file carries Beacon's hook command but was not reported as Beacon-managed")
+ }
+ patch := findConfig(result.Configs, "deepseek_harness", patchPath)
+ if patch == nil {
+ t.Fatalf("scan did not report %s", patchPath)
+ }
+ if patch.BeaconManaged {
+ t.Fatal("a patch file mounting somebody else's plugin was reported as Beacon-managed; " +
+ "a half-install would read as a whole one")
+ }
+ if patch.ParserMode != formatYAML {
+ t.Fatalf("patch parser mode = %q, want yaml", patch.ParserMode)
+ }
+}
+
+// The mount is recognized by the bridge package its row names rather than by a Beacon marker,
+// because Beacon adds one row to a file the user also writes. A user who mounts the bridge
+// themselves matches too, which is correct: that is a live route from this runtime into a hooks
+// file, and the inventory exists to find those.
+func TestScanRecognizesTheDshBridgeMount(t *testing.T) {
+ home := t.TempDir()
+ t.Setenv("DSH_HOME", "")
+
+ dir := filepath.Join(home, ".dsh")
+ if err := os.MkdirAll(dir, 0755); err != nil {
+ t.Fatalf("mkdir: %v", err)
+ }
+ patchPath := filepath.Join(dir, "cordis.patch.yml")
+ if err := os.WriteFile(patchPath, []byte(
+ "- insert:\n - id: beacon-endpoint-hooks\n name: '@deepseek-ai/dsh-hooks-claude-code'\n"+
+ " config:\n configPath: '"+filepath.Join(dir, "beacon-endpoint-hooks.json")+"'\n"), 0644); err != nil {
+ t.Fatalf("write patch: %v", err)
+ }
+
+ result := Scan(Options{HomeDir: home, WorkingDir: t.TempDir()})
+ patch := findConfig(result.Configs, "deepseek_harness", patchPath)
+ if patch == nil {
+ t.Fatalf("scan did not report %s", patchPath)
+ }
+ if !patch.BeaconManaged {
+ t.Fatal("a patch file mounting the hook bridge was not recognized")
+ }
+}
+
+// DSH_HOME moves the Harness home, so an inventory that assumed ~/.dsh would scan a directory the
+// runtime does not read and report a monitored machine as unmonitored.
+func TestScanHonorsDshHome(t *testing.T) {
+ home := t.TempDir()
+ elsewhere := t.TempDir()
+ t.Setenv("DSH_HOME", elsewhere)
+
+ hooksPath := filepath.Join(elsewhere, "beacon-endpoint-hooks.json")
+ if err := os.WriteFile(hooksPath, []byte(`{"Stop":[{"hooks":[{"type":"command",`+
+ `"command":"'/opt/beacon/bin/beacon-hooks' --platform dsh --log '/l' --config '/c' stop"}]}]}`), 0644); err != nil {
+ t.Fatalf("write hooks: %v", err)
+ }
+
+ result := Scan(Options{HomeDir: home, WorkingDir: t.TempDir()})
+ if config := findConfig(result.Configs, "deepseek_harness", hooksPath); config == nil || !config.BeaconManaged {
+ t.Fatalf("scan did not find the Beacon hooks file under DSH_HOME at %s", hooksPath)
+ }
+ if config := findConfig(result.Configs, "deepseek_harness", filepath.Join(home, ".dsh", "beacon-endpoint-hooks.json")); config != nil {
+ t.Fatalf("scan also looked under ~/.dsh, which this machine's dsh does not read: %+v", config)
+ }
+}
+
+// dsh has no project scope: its plugin tree is composed from the Harness home, so there is nowhere
+// in a repository for a hook bridge to be mounted from. A project candidate would be a path the
+// runtime never reads, reported as if it might be monitored.
+func TestScanReportsNoProjectScopedDshConfig(t *testing.T) {
+ home := t.TempDir()
+ work := t.TempDir()
+ t.Setenv("DSH_HOME", "")
+
+ result := Scan(Options{HomeDir: home, WorkingDir: work})
+ for _, config := range result.Configs {
+ if config.Runtime != "deepseek_harness" {
+ continue
+ }
+ if config.Scope == ScopeProject {
+ t.Fatalf("scan reported a project-scoped dsh config at %s", config.Path)
+ }
+ }
+}
diff --git a/cli/beacon/internal/endpoint/inventory/inventory.go b/cli/beacon/internal/endpoint/inventory/inventory.go
index 69fc8138..8e8d277d 100644
--- a/cli/beacon/internal/endpoint/inventory/inventory.go
+++ b/cli/beacon/internal/endpoint/inventory/inventory.go
@@ -247,6 +247,7 @@ func candidates(home, wd string) []candidate {
items = append(items, museCandidates(home)...)
items = append(items, openHandsCandidates(home, wd)...)
items = append(items, kiroCandidates(home, wd)...)
+ items = append(items, dshCandidates(home)...)
items = append(items, fxCandidates(home, wd)...)
seen := map[string]bool{}
out := make([]candidate, 0, len(items))
@@ -556,6 +557,40 @@ func kiroCandidates(home, wd string) []candidate {
}
}
+// dshCandidates covers both halves of a DeepSeek Harness install.
+//
+// Two files rather than one, because on this runtime either alone is inert: the hooks file is a
+// file nothing reads until the patch layer mounts the bridge at it, and the mount is a bridge that
+// registers nothing until the hooks file is there. Listing both is what lets the inventory report a
+// half-install -- which here is the failure that looks most like success, the same reason Muse Code
+// gets two candidates.
+//
+// No project scope, because dsh has none: its plugin tree is composed from the Harness home, so
+// there is nowhere in a repository for a hook bridge to be mounted from. A `wd` parameter is
+// therefore not taken at all rather than taken and ignored.
+//
+// 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.
+func dshCandidates(home string) []candidate {
+ dir := dshUserDir(home)
+ return []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},
+ }
+}
+
+// dshUserDir resolves the Harness home, mirroring the installer.
+//
+// Exported to the test as a function rather than restated there as a literal path, so the
+// expected-candidate list stays correct on a developer machine that happens to set DSH_HOME.
+func dshUserDir(home string) string {
+ if base := strings.TrimSpace(os.Getenv("DSH_HOME")); base != "" {
+ return base
+ }
+ return filepath.Join(home, ".dsh")
+}
+
// kiroUserDir resolves the global Kiro directory, mirroring the installer.
//
// Exported to the test as a function rather than restated there as a literal path, so the
@@ -988,6 +1023,19 @@ func beaconManaged(item candidate, data []byte) bool {
// keys on, and what survives someone renaming the hooks inside the file.
case "kiro":
return strings.Contains(text, "--platform kiro") || strings.Contains(text, "--platform=kiro")
+ // Two files with two different tells, both matched by one case because both are DeepSeek
+ // Harness's -- the Muse Code shape. The hooks file carries the hook command, since Beacon owns
+ // it outright; cordis.patch.yml carries neither a command nor a Beacon marker, because Beacon
+ // adds one row to a file the user also writes, so it is recognized by the bridge package its
+ // row mounts. Matching either is what lets the inventory report a half-install.
+ //
+ // The bridge package name is safe to match on here in a way a bare marker would not be: it is
+ // 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.
+ case "deepseek_harness":
+ return strings.Contains(text, "--platform dsh") || strings.Contains(text, "--platform=dsh") ||
+ strings.Contains(text, "@deepseek-ai/dsh-hooks-claude-code")
}
if item.runtime == "claude_code" || item.runtime == "codex_cli" {
if strings.Contains(text, "OTEL_EXPORTER_OTLP_ENDPOINT") && localEndpointText(text) {
diff --git a/cli/beacon/internal/endpoint/inventory/inventory_test.go b/cli/beacon/internal/endpoint/inventory/inventory_test.go
index a3e14d42..cb8e9c1f 100644
--- a/cli/beacon/internal/endpoint/inventory/inventory_test.go
+++ b/cli/beacon/internal/endpoint/inventory/inventory_test.go
@@ -398,6 +398,14 @@ func TestScanIncludesAllSupportedCurrentUserAndProjectConfigs(t *testing.T) {
// above. Both can be live at once, so showing one would understate the install.
{runtime: "kiro", path: filepath.Join(kiroUserDir(home), "hooks", "beacon-endpoint.json"), scope: ScopeUser, format: formatJSON, kind: KindHookConfig},
{runtime: "kiro", path: filepath.Join(work, ".kiro", "hooks", "beacon-endpoint.json"), scope: ScopeProject, format: formatJSON, kind: KindHookConfig},
+ // DeepSeek Harness is two files and no project entry. Both halves are reported because
+ // either one alone is inert and the runtime says nothing about it -- the Muse Code shape;
+ // the project scope is absent because dsh composes its plugin tree from the Harness home,
+ // so a repository has nowhere to mount a hook bridge from. cordis.patch.yml is the user's
+ // own file, which is why it is listed as YAML and matched on the bridge package rather
+ // than on a Beacon marker.
+ {runtime: "deepseek_harness", path: filepath.Join(dshUserDir(home), "beacon-endpoint-hooks.json"), scope: ScopeUser, format: formatJSON, kind: KindHookConfig},
+ {runtime: "deepseek_harness", path: filepath.Join(dshUserDir(home), "cordis.patch.yml"), scope: ScopeUser, format: formatYAML, kind: KindHookConfig},
// fx has no Beacon-written file, so all three are its own configuration. The two MCP files
// are the ones that carry information nothing else here reports: fx's profile server list
// and the workspace servers it shares with Claude-compatible runtimes.
diff --git a/cli/beacon/internal/tokens/coverage.go b/cli/beacon/internal/tokens/coverage.go
index c60456c4..334b5e1b 100644
--- a/cli/beacon/internal/tokens/coverage.go
+++ b/cli/beacon/internal/tokens/coverage.go
@@ -113,6 +113,11 @@ var usageExpectation = map[string]struct {
"chatgpt_web": {ExpectNone, "the chat stream reports no token counts"},
"openhands": {ExpectNone, "hook payloads carry no token counts"},
"kiro": {ExpectNone, "hook payloads carry no token counts"},
+ // The bridge builds each hook payload from a fixed base plus per-event fields, and no usage
+ // count is among them on any of the seven events it supports. dsh does record usage -- in its
+ // own session log -- but nothing in the hook surface exposes it, so a DeepSeek Harness session
+ // reporting no tokens is correct rather than silent.
+ "deepseek_harness": {ExpectNone, "the hook bridge's payloads carry no token counts"},
}
// InstalledConfig is the part of a config-scanner row that install detection reads.