Skip to content

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

fix(inventory): record every variable the inventory scan follows in the scheduled job (#899)

Rudy Mizrahi Celeklidde7dac6390d
diff --git a/cli/beacon/internal/endpoint/lifecycle/inventory_job_test.go b/cli/beacon/internal/endpoint/lifecycle/inventory_job_test.go
index 6171bc9b..f459dc38 100644
--- a/cli/beacon/internal/endpoint/lifecycle/inventory_job_test.go
+++ b/cli/beacon/internal/endpoint/lifecycle/inventory_job_test.go
@@ -4,6 +4,7 @@ import (
"errors"
"os"
"path/filepath"
+ "reflect"
"runtime"
"strings"
"testing"
@@ -530,3 +531,58 @@ func TestRepairTeardownKeepsScriptForwarders(t *testing.T) {
t.Fatalf("repair's uninstall step changed what it keeps: %+v", opts)
}
}
+
+// The scheduled job starts without the installing shell's environment, so every other variable the
+// inventory scan follows to a runtime's user directory is recorded too. A relative path is made
+// absolute against the install's working directory; an absolute or `~` path, and a name (Oh My
+// Pi's config directory and profile), are recorded exactly as set, since the job resolves them
+// against the same HOME. A variable set to an empty value is recorded, because OMP_PROFILE and
+// OMO's overrides read set-but-empty differently from unset.
+func TestInventoryJobEnvRecordsTheOtherInventoryRootVariables(t *testing.T) {
+ work := t.TempDir()
+ t.Chdir(work)
+ cwd, err := os.Getwd()
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, name := range []string{"CODEX_HOME", "HERMES_HOME", "HERMES_DATA_DIR_SUFFIX", "CLINE_DIR", "GEMINI_CLI_HOME", "CLAUDE_CONFIG_DIR"} {
+ t.Setenv(name, "")
+ }
+ set := map[string]string{
+ "KIRO_HOME": " kiro-dir ",
+ "KIMI_CODE_HOME": "/abs/kimi",
+ "PI_CODING_AGENT_DIR": "~/pi-alt",
+ "PRIME_AGENT_CODING_AGENT_DIR": "~",
+ "OMO_CODING_AGENT_DIR": "",
+ "PI_CONFIG_DIR": ".omp-alt",
+ "OMP_PROFILE": "",
+ "PI_PROFILE": "work",
+ }
+ for name, value := range set {
+ t.Setenv(name, value)
+ }
+ want := map[string]string{
+ "KIRO_HOME": filepath.Join(cwd, "kiro-dir"),
+ "KIMI_CODE_HOME": "/abs/kimi",
+ "PI_CODING_AGENT_DIR": "~/pi-alt",
+ "PRIME_AGENT_CODING_AGENT_DIR": "~",
+ "OMO_CODING_AGENT_DIR": "",
+ "PI_CONFIG_DIR": ".omp-alt",
+ "OMP_PROFILE": "",
+ "PI_PROFILE": "work",
+ }
+ if runtime.GOOS == "windows" {
+ // Not absolute without a drive letter, so it is resolved like any relative path.
+ abs, err := filepath.Abs("/abs/kimi")
+ if err != nil {
+ t.Fatal(err)
+ }
+ want["KIMI_CODE_HOME"] = abs
+ }
+ if env := inventoryJobEnv(true); !reflect.DeepEqual(env, want) {
+ t.Fatalf("user mode env = %v, want %v", env, want)
+ }
+ if got := inventoryJobEnv(false); got != nil {
+ t.Fatalf("system mode env = %v, want none", got)
+ }
+}
diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
index 05e44301..82e2c283 100644
--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
@@ -135,12 +135,12 @@ func reconcileInventoryJobWith(job inventoryJobController, opts InventoryJobOpti
}
// inventoryJobEnv is the environment written into a per-user inventory job. launchd and systemd
-// start the job without the user's shell environment, so a CODEX_HOME, HERMES_HOME, CLINE_DIR,
-// GEMINI_CLI_HOME or CLAUDE_CONFIG_DIR exported in a shell profile would not reach it and the
-// scheduled scan would inventory ~/.codex, ~/.hermes, ~/.cline, ~/.gemini or ~/.claude while the
-// runtime reads the moved directory. Each value is resolved now, from the install's shell, as its
-// runtime resolves it, and recorded as an absolute path so a relative value still means the
-// directory it named at install time:
+// start the job without the user's shell environment, so a variable exported in a shell profile
+// that moves a runtime's user directory -- CODEX_HOME, HERMES_HOME, CLINE_DIR, GEMINI_CLI_HOME,
+// CLAUDE_CONFIG_DIR, or one in inventoryJobPathEnv or inventoryJobNameEnv -- would not reach it,
+// and the scheduled scan would inventory the default directory while the runtime reads the moved
+// one. Each value is taken from the install's shell, so a relative path still means the directory
+// it named at install time:
// - CODEX_HOME must name an existing directory, as Codex requires; otherwise nothing is recorded.
// - HERMES_HOME is trimmed and expanded as Hermes does, and HERMES_DATA_DIR_SUFFIX is recorded as
// it is. HERMES_HOME is recorded before profiles are applied, so the job still follows a later
@@ -148,6 +148,9 @@ func reconcileInventoryJobWith(job inventoryJobController, opts InventoryJobOpti
// - CLINE_DIR is used whenever it is non-empty after trimming, as Cline uses it.
// - GEMINI_CLI_HOME is used whenever it is non-empty, as Gemini CLI uses it.
// - CLAUDE_CONFIG_DIR is used whenever it is non-empty after trimming, as Claude Code uses it.
+// - The rest are recorded whenever they are set, even to an empty value, because Oh My Pi's
+// OMP_PROFILE and OMO's agent-directory overrides treat a set-but-empty variable differently
+// from an unset one. See inventoryJobPathValue for how a path is recorded.
//
// A variable that is unset records nothing, and the job falls back to the default as before.
// System mode records nothing: this process's environment is root's, not the console user's.
@@ -182,12 +185,59 @@ func inventoryJobEnv(userMode bool) map[string]string {
env["CLAUDE_CONFIG_DIR"] = dir
}
}
+ for _, name := range inventoryJobPathEnv {
+ if value, ok := os.LookupEnv(name); ok {
+ env[name] = inventoryJobPathValue(value)
+ }
+ }
+ for _, name := range inventoryJobNameEnv {
+ if value, ok := os.LookupEnv(name); ok {
+ env[name] = value
+ }
+ }
if len(env) == 0 {
return nil
}
return env
}
+// inventoryJobPathEnv are the variables naming a directory that the inventory scan resolves
+// through a runtime's own path rules (inventory's *UserDir helpers, and the hooks installers'
+// *PathForHome resolvers it calls), beyond the ones inventoryJobEnv resolves itself.
+var inventoryJobPathEnv = []string{
+ "KIRO_HOME",
+ "KIMI_CODE_HOME",
+ "DSH_HOME",
+ "OH_PERSISTENCE_DIR",
+ "OPENCLAW_STATE_DIR",
+ "XDG_CONFIG_HOME", // Muse, and VS Code on Linux
+ "PI_CODING_AGENT_DIR", // Pi, Oh My Pi's default profile, and OMO's last fallback
+ "OMO_CODING_AGENT_DIR", // OMO
+ "SENPI_CODING_AGENT_DIR", // OMO's legacy name
+ "PRIME_AGENT_CODING_AGENT_DIR", // Prime Agent
+}
+
+// inventoryJobNameEnv are the variables the inventory scan reads as names rather than paths, so
+// they are recorded exactly as set: Oh My Pi's config directory name under the home directory and
+// its active profile.
+var inventoryJobNameEnv = []string{"PI_CONFIG_DIR", "OMP_PROFILE", "PI_PROFILE"}
+
+// inventoryJobPathValue is how one inventoryJobPathEnv value is recorded. A relative path is made
+// absolute against the install's working directory, after trimming, which every resolver that
+// trims ignores. Anything else is recorded exactly as set: an absolute path already means the same
+// thing in the job, an empty value means what unset does, and a leading `~` is left for each
+// resolver to expand against the same HOME the job runs with, as it did at install time.
+func inventoryJobPathValue(value string) string {
+ path := strings.TrimSpace(value)
+ if path == "" || filepath.IsAbs(path) || path == "~" || strings.HasPrefix(path, "~/") || strings.HasPrefix(path, `~\`) {
+ return value
+ }
+ if abs, err := filepath.Abs(path); err == nil {
+ return abs
+ }
+ return value
+}
+
// inventoryEnabledFromConfigFile reads only the inventory_heartbeat.enabled key. A missing or
// unreadable config, or an absent key, means enabled: the job is on by default.
func inventoryEnabledFromConfigFile(path string) bool {
diff --git a/cli/beacon/internal/endpoint/lifecycle/main_test.go b/cli/beacon/internal/endpoint/lifecycle/main_test.go
index 8cc62ec2..59f7f886 100644
--- a/cli/beacon/internal/endpoint/lifecycle/main_test.go
+++ b/cli/beacon/internal/endpoint/lifecycle/main_test.go
@@ -19,9 +19,13 @@ import (
// anything that would register or start a service.
//
// It also clears CLAUDE_CONFIG_DIR, which a developer's shell may set: tests that write Claude Code
-// settings assume ~/.claude unless they set the variable themselves.
+// settings assume ~/.claude unless they set the variable themselves. It unsets the variables
+// inventoryJobEnv records whenever they are set, so the job-env tests see only what they set.
func TestMain(m *testing.M) {
_ = os.Unsetenv("CLAUDE_CONFIG_DIR")
+ for _, name := range append(append([]string{}, inventoryJobPathEnv...), inventoryJobNameEnv...) {
+ _ = os.Unsetenv(name)
+ }
os.Exit(runWithServiceManagerStandIns(m))
}
diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdx
index 12535cc8..c13fed89 100644
--- a/docs/changelog/cli.mdx
+++ b/docs/changelog/cli.mdx
@@ -11,6 +11,8 @@ Stay up to date with the latest changes to the Agent Beacon CLI.
## October 2026
+- **The scheduled inventory job follows every moved runtime directory** · The job starts without your shell's environment, so a per-user install or repair records the variables that move a runtime's user directory into it. It recorded `CODEX_HOME`, `HERMES_HOME`, `CLINE_DIR`, `GEMINI_CLI_HOME` and `CLAUDE_CONFIG_DIR`, and now also `KIRO_HOME`, `KIMI_CODE_HOME`, `DSH_HOME`, `OH_PERSISTENCE_DIR`, `OPENCLAW_STATE_DIR`, `XDG_CONFIG_HOME` (Muse, and VS Code on Linux), `PI_CODING_AGENT_DIR`, `OMO_CODING_AGENT_DIR`, `SENPI_CODING_AGENT_DIR`, `PRIME_AGENT_CODING_AGENT_DIR`, and Oh My Pi's `PI_CONFIG_DIR`, `OMP_PROFILE` and `PI_PROFILE`. With one of these set only in your shell, the job used to inventory the default directory while the runtime read the moved one. See [Inventory heartbeats](/cli/endpoint-inventory#inventory-heartbeats).
+
### v1.3.42 · October 15, 2026
- **The install wizard says what confirming Beacon Cloud sends** · Choosing Beacon Cloud now says your agent sessions are sent to your Beacon account and kept while the account is active, and that unless you opt out Asymptote uses them for research and AI training and may share de-identified data ([beacon.sh/privacy](https://beacon.sh/privacy)). The confirm screen names the signed-in account, Asymptote Labs, Inc. as the operator, the destination and the capture mode, and says how to turn off research and AI training (profile picture, then Settings), change the mode (`beacon endpoint connect --privacy-mode`), stop sending (`beacon endpoint disconnect`), or delete the data ([email protected]). That screen is where forwarding is authorized. See [Onboarding](/cli/endpoint-onboarding).
diff --git a/docs/cli/endpoint-inventory.mdx b/docs/cli/endpoint-inventory.mdx
index e40c23b2..dba731c1 100644
--- a/docs/cli/endpoint-inventory.mdx
+++ b/docs/cli/endpoint-inventory.mdx
@@ -67,6 +67,8 @@ A scheduled local job appends inventory telemetry to a separate `inventory_state
A system-mode job runs as root and inventories the active console user's home. When nobody is logged in, or the console is held by a macOS service account such as `_mbsetupuser` at the login window, it still writes the heartbeat, with `user_scope.mode` set to `no_console_user`, and no snapshot. Runtime state files the runtime rewrites on every session (`~/.claude.json`) are reported with their hash but left out of the change digest, so `inventory.snapshot` is written when something inventory-relevant changed (a config, hook, skill, or MCP server), not on every Claude Code session. On a Mac with more than one console user the job keeps the last digest per home, so a switch between users is not reported as a change. The scheduled scan covers user-level configuration only; project-scoped files (`.cursor/mcp.json`, `.claude/settings.json` in a repository) are reported by `beacon endpoint inventory` run from that directory, not by the job.
+launchd and systemd start the job without your shell's environment, so a per-user `beacon endpoint install` or `repair` writes the variables that move a runtime's user directory into the job's definition, taking each value from the shell it runs in: `CODEX_HOME`, `HERMES_HOME` and `HERMES_DATA_DIR_SUFFIX`, `CLINE_DIR`, `GEMINI_CLI_HOME`, `CLAUDE_CONFIG_DIR`, `KIRO_HOME`, `KIMI_CODE_HOME`, `DSH_HOME`, `OH_PERSISTENCE_DIR`, `OPENCLAW_STATE_DIR`, `XDG_CONFIG_HOME`, `PI_CODING_AGENT_DIR`, `OMO_CODING_AGENT_DIR`, `SENPI_CODING_AGENT_DIR`, `PRIME_AGENT_CODING_AGENT_DIR`, `PI_CONFIG_DIR`, `OMP_PROFILE` and `PI_PROFILE`. A relative path is recorded as the absolute path it named at install time. If you change one of them later, run `beacon endpoint repair` from a shell that has the new value. A system-mode job records none of them, since the installer's environment is root's.
+
By default, inventory snapshots include config file metadata, MCP server metadata, skill metadata, and hook config metadata across supported local runtimes. They do not include skill instruction bodies, MCP secret values, full environment values, full command arguments, or unrelated config content.
Set `include_contents` to opt the snapshot telemetry into capturing full definitions, matching the `--contents` CLI behavior. When enabled, `inventory.snapshot` events carry redacted, size-limited config/hook/skill `content` blocks and full MCP server `definition` blocks. Secret-looking values are redacted and bodies are truncated to `max_content_bytes` (64 KiB by default). This setting is off by default so the snapshot contract stays metadata-only unless an operator explicitly enables it.