Skip to content

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

Retire hook-triggered inventory; keep the old hook commands parsing

shukieshah5e6bbec9fb5a
diff --git a/cli/beacon-hooks/cmd/endpoint_events.go b/cli/beacon-hooks/cmd/endpoint_events.go
index fa00031c..2ee86a18 100644
--- a/cli/beacon-hooks/cmd/endpoint_events.go
+++ b/cli/beacon-hooks/cmd/endpoint_events.go
@@ -6,7 +6,6 @@ import (
"encoding/hex"
"fmt"
"os"
- "os/exec"
"path/filepath"
"strconv"
"strings"
@@ -18,8 +17,6 @@ import (
"github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve"
)
-var runInventoryHeartbeatCommand = exec.CommandContext
-
func emitHookEvent(logger *logging.Logger, action, category, severity, message string, input map[string]interface{}, fields map[string]interface{}) {
emitHookEventWithFidelity(logger, action, category, severity, message, asymptoteobserve.FidelityObserved, input, fields)
}
@@ -226,52 +223,6 @@ func maybeUploadCursorCloudTelemetry(logger *logging.Logger) {
uploadCloudTelemetry(logger, true)
}
-func maybeEmitInventoryHeartbeat(logger *logging.Logger, input map[string]interface{}) {
- cliPath := strings.TrimSpace(os.Getenv("BEACON_ENDPOINT_CLI"))
- if cliPath == "" {
- return
- }
- args := []string{"endpoint", "inventory", "heartbeat", "--trigger", "hook", "--trigger-harness", platformFlag}
- if configPath := strings.TrimSpace(os.Getenv("BEACON_ENDPOINT_CONFIG")); configPath != "" {
- args = append(args, "--config", configPath)
- }
- if logPath := inventoryEndpointLogPath(); logPath != "" {
- args = append(args, "--log-path", logPath)
- }
- if cwd := resolveCwd(input, platformFlag); cwd != "" {
- args = append(args, "--working-dir", cwd)
- }
- ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
- defer cancel()
- cmd := runInventoryHeartbeatCommand(ctx, cliPath, args...)
- if out, err := cmd.CombinedOutput(); err != nil {
- logger.Warn("Inventory heartbeat failed", "error", err.Error(), "output", strings.TrimSpace(string(out)))
- }
-}
-
-func inventoryEndpointLogPath() string {
- if path := firstHookEnv("BEACON_ENDPOINT_LOG", "BEACON_CLOUD_LOG_PATH", "BEACON_LOG_PATH", "BEACON_RUNTIME_LOG"); path != "" {
- return path
- }
- if os.Getenv("BEACON_ENDPOINT_MODE") == "" {
- return ""
- }
- home, err := os.UserHomeDir()
- if err != nil {
- return ""
- }
- return filepath.Join(home, ".beacon", "endpoint", "logs", "runtime.jsonl")
-}
-
-func firstHookEnv(keys ...string) string {
- for _, key := range keys {
- if value := strings.TrimSpace(os.Getenv(key)); value != "" {
- return value
- }
- }
- return ""
-}
-
func sessionFields(sessionID string, input map[string]interface{}) map[string]interface{} {
return sessionFieldsForPlatform(sessionID, input, platformFlag)
}
diff --git a/cli/beacon-hooks/cmd/endpoint_events_test.go b/cli/beacon-hooks/cmd/endpoint_events_test.go
index 1dd4ec87..41dfc0b4 100644
--- a/cli/beacon-hooks/cmd/endpoint_events_test.go
+++ b/cli/beacon-hooks/cmd/endpoint_events_test.go
@@ -1,14 +1,9 @@
package cmd
import (
- "context"
"os"
- "os/exec"
"path/filepath"
- "reflect"
"testing"
-
- "github.com/asymptote-labs/agent-beacon/cli/beacon-hooks/internal/logging"
)
func writeGitHead(t *testing.T, repo, head string) {
@@ -401,114 +396,3 @@ func TestToolFieldsMapsGenericFlatTransportKeysForKnownMCP(t *testing.T) {
t.Fatalf("mcp.resource.uri = %q, want file URI", got)
}
}
-
-func TestMaybeEmitInventoryHeartbeatInvokesBeaconCLI(t *testing.T) {
- oldPlatform := platformFlag
- oldRunner := runInventoryHeartbeatCommand
- defer func() {
- platformFlag = oldPlatform
- runInventoryHeartbeatCommand = oldRunner
- }()
- platformFlag = "cursor"
- t.Setenv("BEACON_ENDPOINT_CLI", "/usr/local/bin/beacon")
- t.Setenv("BEACON_ENDPOINT_CONFIG", "/tmp/beacon/config.json")
- t.Setenv("BEACON_ENDPOINT_LOG", "/tmp/beacon/runtime.jsonl")
-
- var gotName string
- var gotArgs []string
- runInventoryHeartbeatCommand = func(ctx context.Context, name string, args ...string) *exec.Cmd {
- gotName = name
- gotArgs = append([]string(nil), args...)
- cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=TestInventoryHeartbeatCommandHelperProcess")
- cmd.Env = append(os.Environ(), "GO_WANT_INVENTORY_HELPER_PROCESS=1")
- return cmd
- }
-
- logger := logging.NewLoggerForPlatform("test", "cursor")
- maybeEmitInventoryHeartbeat(logger, map[string]interface{}{"cwd": "/repo"})
-
- if gotName != "/usr/local/bin/beacon" {
- t.Fatalf("command name = %q, want beacon path", gotName)
- }
- wantArgs := []string{
- "endpoint", "inventory", "heartbeat",
- "--trigger", "hook",
- "--trigger-harness", "cursor",
- "--config", "/tmp/beacon/config.json",
- "--log-path", "/tmp/beacon/runtime.jsonl",
- "--working-dir", "/repo",
- }
- if !reflect.DeepEqual(gotArgs, wantArgs) {
- t.Fatalf("args = %#v, want %#v", gotArgs, wantArgs)
- }
-}
-
-func TestMaybeEmitInventoryHeartbeatInvokesBeaconCLIForAnyEndpointPlatform(t *testing.T) {
- oldPlatform := platformFlag
- oldRunner := runInventoryHeartbeatCommand
- defer func() {
- platformFlag = oldPlatform
- runInventoryHeartbeatCommand = oldRunner
- }()
- platformFlag = "gemini"
- t.Setenv("BEACON_ENDPOINT_CLI", "/usr/local/bin/beacon")
- t.Setenv("BEACON_ENDPOINT_LOG", "/tmp/beacon/runtime.jsonl")
- var gotArgs []string
- called := false
- runInventoryHeartbeatCommand = func(ctx context.Context, name string, args ...string) *exec.Cmd {
- called = true
- gotArgs = append([]string(nil), args...)
- cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=TestInventoryHeartbeatCommandHelperProcess")
- cmd.Env = append(os.Environ(), "GO_WANT_INVENTORY_HELPER_PROCESS=1")
- return cmd
- }
-
- logger := logging.NewLoggerForPlatform("test", "gemini")
- maybeEmitInventoryHeartbeat(logger, map[string]interface{}{"cwd": "/repo"})
-
- if !called {
- t.Fatal("inventory heartbeat command should run for endpoint hook platforms")
- }
- wantArgs := []string{
- "endpoint", "inventory", "heartbeat",
- "--trigger", "hook",
- "--trigger-harness", "gemini",
- "--log-path", "/tmp/beacon/runtime.jsonl",
- "--working-dir", "/repo",
- }
- if !reflect.DeepEqual(gotArgs, wantArgs) {
- t.Fatalf("args = %#v, want %#v", gotArgs, wantArgs)
- }
-}
-
-func TestMaybeEmitInventoryHeartbeatSkipsWithoutEndpointCLI(t *testing.T) {
- oldPlatform := platformFlag
- oldRunner := runInventoryHeartbeatCommand
- defer func() {
- platformFlag = oldPlatform
- runInventoryHeartbeatCommand = oldRunner
- }()
- platformFlag = "cursor"
- t.Setenv("BEACON_ENDPOINT_CLI", "")
- called := false
- runInventoryHeartbeatCommand = func(ctx context.Context, name string, args ...string) *exec.Cmd {
- called = true
- cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=TestInventoryHeartbeatCommandHelperProcess")
- cmd.Env = append(os.Environ(), "GO_WANT_INVENTORY_HELPER_PROCESS=1")
- return cmd
- }
-
- logger := logging.NewLoggerForPlatform("test", "cursor")
- maybeEmitInventoryHeartbeat(logger, map[string]interface{}{"cwd": "/repo"})
-
- if called {
- t.Fatal("inventory heartbeat command should not run without BEACON_ENDPOINT_CLI")
- }
-}
-
-func TestInventoryHeartbeatCommandHelperProcess(t *testing.T) {
- if os.Getenv("GO_WANT_INVENTORY_HELPER_PROCESS") != "1" {
- return
- }
- os.Exit(0)
-}
diff --git a/cli/beacon-hooks/cmd/inventory_heartbeat.go b/cli/beacon-hooks/cmd/inventory_heartbeat.go
index 5c4343be..51878076 100644
--- a/cli/beacon-hooks/cmd/inventory_heartbeat.go
+++ b/cli/beacon-hooks/cmd/inventory_heartbeat.go
@@ -2,15 +2,20 @@ package cmd
import (
"github.com/spf13/cobra"
-
- "github.com/asymptote-labs/agent-beacon/cli/beacon-hooks/internal/logging"
)
+// inventoryHeartbeatCmd is a no-op kept for hooks installed by older Beacon versions.
+//
+// Codex hooks written before the scheduled inventory job existed invoke
+// `beacon-hooks --platform codex inventory-heartbeat` on every session start and prompt, and
+// those hook files are only rewritten by a hooks reinstall. Inventory is written by
+// `beacon endpoint inventory heartbeat --scheduled` under launchd or systemd now, so this
+// command reads its input and answers with the empty response every hook expects.
var inventoryHeartbeatCmd = &cobra.Command{
- Use: "inventory-heartbeat",
- Short: "Emit endpoint inventory heartbeat telemetry",
- Long: `Inventory heartbeat hook - triggered by agent lifecycle hooks to refresh local configuration inventory.`,
- Run: runInventoryHeartbeat,
+ Use: "inventory-heartbeat",
+ Short: "No-op kept for hooks installed by older versions; inventory is a scheduled job now",
+ Hidden: true,
+ Run: runInventoryHeartbeat,
}
func init() {
@@ -18,13 +23,6 @@ func init() {
}
func runInventoryHeartbeat(cmd *cobra.Command, args []string) {
- input, err := readStdinJSON()
- if err != nil {
- outputJSON(emptyResponse)
- return
- }
-
- logger := logging.NewLoggerForPlatform("inventory-heartbeat", platformFlag)
- maybeEmitInventoryHeartbeat(logger, input)
+ _, _ = readStdinJSON()
outputJSON(emptyResponse)
}
diff --git a/cli/beacon-hooks/cmd/inventory_heartbeat_test.go b/cli/beacon-hooks/cmd/inventory_heartbeat_test.go
new file mode 100644
index 00000000..76aeb210
--- /dev/null
+++ b/cli/beacon-hooks/cmd/inventory_heartbeat_test.go
@@ -0,0 +1,32 @@
+package cmd
+
+import (
+ "io"
+ "os"
+ "testing"
+)
+
+// Old Codex hooks call this subcommand on every prompt. It must answer and do nothing else: no
+// subprocess, no file, however the environment is set.
+func TestInventoryHeartbeatSubcommandIsANoOp(t *testing.T) {
+ t.Setenv("BEACON_ENDPOINT_CLI", "/definitely/not/a/binary")
+ t.Setenv("BEACON_ENDPOINT_LOG", t.TempDir()+"/runtime.jsonl")
+ r, w, err := os.Pipe()
+ if err != nil {
+ t.Fatal(err)
+ }
+ oldStdin := os.Stdin
+ os.Stdin = r
+ t.Cleanup(func() { os.Stdin = oldStdin })
+ _, _ = io.WriteString(w, `{"session_id":"s1","cwd":"/repo"}`)
+ _ = w.Close()
+
+ runInventoryHeartbeat(inventoryHeartbeatCmd, nil)
+
+ if entries, _ := os.ReadDir(t.TempDir()); len(entries) != 0 {
+ t.Fatalf("no-op must not write files: %v", entries)
+ }
+ if !inventoryHeartbeatCmd.Hidden {
+ t.Fatal("the retired subcommand should be hidden from help")
+ }
+}
diff --git a/cli/beacon-hooks/cmd/kiro.go b/cli/beacon-hooks/cmd/kiro.go
index 303cf68a..e249860c 100644
--- a/cli/beacon-hooks/cmd/kiro.go
+++ b/cli/beacon-hooks/cmd/kiro.go
@@ -20,7 +20,7 @@ import (
// "prompt": "...", "assistant_response": "..."}
//
// So Kiro rides the shared subcommands, the way OpenHands does and for the same reason: the shared
-// path already carries the inventory heartbeat, log rotation, session state, the policy seam,
+// path already carries log rotation, session state, the policy seam,
// content retention and the tool call id, and a second implementation of those would be the thing
// that drifts. There is not one envelope reader in this file, because there is nothing to
// translate -- `session_id`, `cwd` and `prompt` all resolve through the shared default cases.
diff --git a/cli/beacon-hooks/cmd/openhands.go b/cli/beacon-hooks/cmd/openhands.go
index 30774fad..eae18d57 100644
--- a/cli/beacon-hooks/cmd/openhands.go
+++ b/cli/beacon-hooks/cmd/openhands.go
@@ -14,8 +14,8 @@ import (
// OpenHands documents its hooks format as compatible with Claude Code's, and the six events line
// up one for one with commands this binary already has -- SessionStart, UserPromptSubmit,
// PreToolUse, PostToolUse, Stop, SessionEnd. That is why OpenHands rides the shared commands
-// rather than getting a mapper of its own: the shared path already carries the inventory
-// heartbeat, log rotation, session state, the policy seam, content retention and the tool call id,
+// rather than getting a mapper of its own: the shared path already carries log rotation,
+// session state, the policy seam, content retention and the tool call id,
// and a second implementation of those would be the thing that drifts.
//
// What "compatible" does not cover is the envelope's field names, which are the SDK's HookEvent
diff --git a/cli/beacon-hooks/cmd/policy.go b/cli/beacon-hooks/cmd/policy.go
index f08add4c..980777ed 100644
--- a/cli/beacon-hooks/cmd/policy.go
+++ b/cli/beacon-hooks/cmd/policy.go
@@ -47,7 +47,7 @@ type policyDenial struct {
// policyExit is os.Exit, indirected so a test can observe the status without ending the run.
//
-// Same reason runInventoryHeartbeatCommand is a variable: the behavior under test is a side effect
+// Indirected for the same reason the runtime writers are: the behavior under test is a side effect
// on the process, and there is no way to assert on it otherwise.
var policyExit = os.Exit
diff --git a/cli/beacon-hooks/cmd/prompt_submit.go b/cli/beacon-hooks/cmd/prompt_submit.go
index 23689c10..8dd50761 100644
--- a/cli/beacon-hooks/cmd/prompt_submit.go
+++ b/cli/beacon-hooks/cmd/prompt_submit.go
@@ -30,7 +30,6 @@ func runPromptSubmit(cmd *cobra.Command, args []string) {
logger := newHookLogger("prompt-submit", platformFlag, sessionID)
logger.Debug("Prompt submit observed")
- maybeEmitInventoryHeartbeat(logger, input)
fields := sessionFields(sessionID, input)
if isCascadePlatform(platformFlag) {
fields = cascadeMetadataFields(sessionID, input)
diff --git a/cli/beacon-hooks/cmd/root.go b/cli/beacon-hooks/cmd/root.go
index 5f48f162..24bb7d34 100644
--- a/cli/beacon-hooks/cmd/root.go
+++ b/cli/beacon-hooks/cmd/root.go
@@ -42,7 +42,12 @@ func init() {
rootCmd.PersistentFlags().StringVar(&platformFlag, "platform", "claude", "Platform context: claude, cline, codex, antigravity, copilot, cursor, vscode, devin, devin-cli, devin-desktop, factory, goose, grok, hermes, kiro, muse, opencode, openhands, or qwen")
rootCmd.PersistentFlags().StringVar(&logFlag, "log", "", "Endpoint runtime log to append to (same value as BEACON_ENDPOINT_LOG)")
rootCmd.PersistentFlags().StringVar(&configFlag, "config", "", "Endpoint config to read (same value as BEACON_ENDPOINT_CONFIG)")
- rootCmd.PersistentFlags().StringVar(&cliFlag, "cli", "", "Path to the beacon CLI for inventory heartbeats (same value as BEACON_ENDPOINT_CLI)")
+ // --cli is ignored. Every hook command written before inventory became a scheduled job
+ // carries it, and those commands are only rewritten by a hooks reinstall, so it must keep
+ // parsing. Hidden rather than deprecated: cobra prints a deprecation notice to stderr on
+ // every use, and several runtimes surface hook stderr to the person at the keyboard.
+ rootCmd.PersistentFlags().StringVar(&cliFlag, "cli", "", "Ignored; kept for hook commands written by older versions (mapped to BEACON_ENDPOINT_CLI)")
+ _ = rootCmd.PersistentFlags().MarkHidden("cli")
rootCmd.PersistentPreRun = func(*cobra.Command, []string) { applyEndpointFlagsToEnv() }
}
@@ -55,8 +60,7 @@ func init() {
// leave two ways to answer the same question during the transition. One source of truth is worth
// more here than avoiding a Setenv in a process that exists for a few milliseconds and does one job.
//
-// It also means a child process inherits them, which is what the inventory heartbeat subprocess
-// needs anyway.
+// It also means a child process inherits them, which is what the policy provider subprocess relies on.
//
// A flag beats an inherited variable. Both can be present -- an already-installed POSIX hook carries
// the env prefix, and a repair rewrites the command to use flags -- and when they disagree the flag
diff --git a/cli/beacon-hooks/cmd/root_endpoint_flags_test.go b/cli/beacon-hooks/cmd/root_endpoint_flags_test.go
index 6cba18b8..c4849c7f 100644
--- a/cli/beacon-hooks/cmd/root_endpoint_flags_test.go
+++ b/cli/beacon-hooks/cmd/root_endpoint_flags_test.go
@@ -97,3 +97,20 @@ func TestWhitespaceOnlyFlagsAreNotValues(t *testing.T) {
t.Fatalf("BEACON_ENDPOINT_MODE = %q, want a blank flag not to imply endpoint mode", got)
}
}
+
+// A hook command written by an older version may carry --cli as its only endpoint flag. It must
+// keep implying endpoint mode, or that install would silently start writing to a default path.
+func TestCLIFlagAloneStillImpliesEndpointMode(t *testing.T) {
+ t.Setenv("BEACON_ENDPOINT_CLI", "")
+ t.Setenv("BEACON_ENDPOINT_MODE", "")
+ withFlags(t, "", "", "/opt/beacon/bin/beacon")
+
+ applyEndpointFlagsToEnv()
+
+ if got := os.Getenv("BEACON_ENDPOINT_MODE"); got != "1" {
+ t.Fatalf("BEACON_ENDPOINT_MODE = %q, want 1 from --cli alone", got)
+ }
+ if got := os.Getenv("BEACON_ENDPOINT_CLI"); got != "/opt/beacon/bin/beacon" {
+ t.Fatalf("BEACON_ENDPOINT_CLI = %q; the value is still mapped even though nothing reads it", got)
+ }
+}
diff --git a/cli/beacon-hooks/cmd/session_start.go b/cli/beacon-hooks/cmd/session_start.go
index d5fbc34f..ab8b4047 100644
--- a/cli/beacon-hooks/cmd/session_start.go
+++ b/cli/beacon-hooks/cmd/session_start.go
@@ -35,7 +35,6 @@ func runSessionStart(cmd *cobra.Command, args []string) {
if err := cloudshuttle.ResetFromEnv(); err != nil {
platformLogger.Warn("Failed to reset cloud telemetry log", "error", err.Error())
}
- maybeEmitInventoryHeartbeat(platformLogger, input)
if sessionID == "" {
if isDevinLikePlatform(platformFlag) {
logger := logging.NewLoggerForPlatform("session-start", platformFlag)
diff --git a/cli/beacon/internal/endpoint/hooks/codex.go b/cli/beacon/internal/endpoint/hooks/codex.go
index ce321457..b13dc236 100644
--- a/cli/beacon/internal/endpoint/hooks/codex.go
+++ b/cli/beacon/internal/endpoint/hooks/codex.go
@@ -62,12 +62,12 @@ func codexStatusFromRuntime(status runtimeStatus) CodexStatus {
func installCodexHooks(path, binaryPath, logPath, configPath string) error {
prefix := endpointCommandPrefix("codex", binaryPath, logPath, configPath)
+ // Only the OS-user session context is hook-driven. Inventory used to ride SessionStart and
+ // UserPromptSubmit here; it is written by the scheduled inventory job now.
endpointHooks := map[string]settingsHookGroup{
"SessionStart": {Hooks: []settingsHookRef{
- {Type: "command", Command: prefix + " inventory-heartbeat", Timeout: 10},
{Type: "command", Command: prefix + " codex-session-context", Timeout: 10},
}},
- "UserPromptSubmit": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " inventory-heartbeat", Timeout: 10}}},
}
return installSettingsEndpointHooks(path, "codex", endpointHooks)
}
diff --git a/cli/beacon/internal/endpoint/hooks/codex_test.go b/cli/beacon/internal/endpoint/hooks/codex_test.go
index 650db15a..e275e3e0 100644
--- a/cli/beacon/internal/endpoint/hooks/codex_test.go
+++ b/cli/beacon/internal/endpoint/hooks/codex_test.go
@@ -7,7 +7,7 @@ import (
"testing"
)
-func TestInstallCodexHooksUsesInventoryAndSessionContext(t *testing.T) {
+func TestInstallCodexHooksWritesSessionContextOnly(t *testing.T) {
path := filepath.Join(t.TempDir(), "hooks.json")
existing := `{"hooks":{"SessionStart":[{"hooks":[{"type":"command","command":"echo keep"},{"type":"command","command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform codex inventory-heartbeat"}]}],"Stop":[{"hooks":[{"type":"command","command":"BEACON_ENDPOINT_MODE=1 beacon-hooks --platform codex codex-usage-sync"}]}]}}`
if err := os.WriteFile(path, []byte(existing), 0600); err != nil {
@@ -26,9 +26,7 @@ func TestInstallCodexHooksUsesInventoryAndSessionContext(t *testing.T) {
for _, want := range []string{
"echo keep",
"SessionStart",
- "UserPromptSubmit",
"--platform codex",
- "inventory-heartbeat",
"codex-session-context",
"--log '/tmp/runtime.jsonl'",
"--config '/tmp/config.json'",
@@ -37,7 +35,8 @@ func TestInstallCodexHooksUsesInventoryAndSessionContext(t *testing.T) {
t.Fatalf("Codex hooks missing %q:\n%s", want, text)
}
}
- for _, forbidden := range []string{"session-start", "prompt-submit", " stop", " session-end", "codex-usage-sync"} {
+ // The fixture's old inventory-heartbeat entry proves a reinstall strips what older versions wrote.
+ for _, forbidden := range []string{"session-start", "prompt-submit", " stop", " session-end", "codex-usage-sync", "inventory-heartbeat", "UserPromptSubmit", "--cli"} {
if strings.Contains(text, forbidden) {
t.Fatalf("Codex hooks should not install duplicate generic runtime hooks %q:\n%s", forbidden, text)
}
diff --git a/cli/beacon/internal/endpoint/hooks/command_parse_test.go b/cli/beacon/internal/endpoint/hooks/command_parse_test.go
index 8ddce788..9cab9a29 100644
--- a/cli/beacon/internal/endpoint/hooks/command_parse_test.go
+++ b/cli/beacon/internal/endpoint/hooks/command_parse_test.go
@@ -2,6 +2,7 @@ package hooks
import (
"reflect"
+ "strings"
"testing"
)
@@ -232,3 +233,20 @@ func TestEndpointCommandArgsMatchPrefix(t *testing.T) {
})
}
}
+
+// Inventory is written by the scheduled job, so the hook command no longer carries a path to the
+// CLI. Emitting it again would be harmless but would re-open the door to hook-driven inventory.
+func TestEndpointCommandBuildersNoLongerEmitCLI(t *testing.T) {
+ prefix := endpointCommandPrefix("claude", "/opt/beacon/hooks/beacon-hooks", "/var/log/beacon/runtime.jsonl", "/etc/beacon/config.json")
+ if strings.Contains(prefix, "--cli") {
+ t.Fatalf("prefix must not carry --cli: %s", prefix)
+ }
+ for _, arg := range endpointCommandArgs("claude", "/opt/beacon/hooks/beacon-hooks", "/var/log/beacon/runtime.jsonl", "/etc/beacon/config.json") {
+ if arg == "--cli" {
+ t.Fatal("argv must not carry --cli")
+ }
+ }
+ if !commandCarriesEndpointSettings("beacon-hooks --platform claude --cli /opt/beacon/bin/beacon session-start") {
+ t.Fatal("a hook written by an older version, carrying only --cli, must still be recognized")
+ }
+}
diff --git a/cli/beacon/internal/endpoint/hooks/kiro.go b/cli/beacon/internal/endpoint/hooks/kiro.go
index bfe9382c..3b122bdf 100644
--- a/cli/beacon/internal/endpoint/hooks/kiro.go
+++ b/cli/beacon/internal/endpoint/hooks/kiro.go
@@ -65,8 +65,8 @@ const (
// rather than the inherited default because 60 seconds is a long time to hold an agent turn for a
// telemetry hook that finishes in milliseconds -- these are ceilings on a hang, not budgets.
//
-// The two long ones are long for a reason: prompt submission may run the inventory heartbeat, and
-// the closing event flushes cloud telemetry, which has a ten-second timeout of its own.
+// The two long ones are long for a reason: prompt submission can wait on the policy seam, and the
+// closing event flushes cloud telemetry, which has a ten-second timeout of its own.
//
// Zero is deliberately never written. On Kiro `0` does not mean "the default", it means *no
// timeout at all* -- a hook that hung would hang the agent turn with it, indefinitely.
diff --git a/cli/beacon/internal/endpoint/hooks/openhands.go b/cli/beacon/internal/endpoint/hooks/openhands.go
index f206510b..ab76a723 100644
--- a/cli/beacon/internal/endpoint/hooks/openhands.go
+++ b/cli/beacon/internal/endpoint/hooks/openhands.go
@@ -61,8 +61,8 @@ const openHandsAllToolsMatcher = "*"
// rather than the inherited default because 60 seconds is a long time to hold an agent turn for a
// telemetry hook that finishes in milliseconds -- these are ceilings on a hang, not budgets.
//
-// The two long ones are long for a reason: prompt submission may run the inventory heartbeat, and
-// the closing events flush cloud telemetry, which has a ten-second timeout of its own.
+// The two long ones are long for a reason: prompt submission can wait on the policy seam, and the
+// closing events flush cloud telemetry, which has a ten-second timeout of its own.
const (
openHandsSessionStartTimeoutSeconds = 10
openHandsPromptSubmitTimeoutSeconds = 30
diff --git a/cli/beacon/internal/endpoint/hooks/runtime.go b/cli/beacon/internal/endpoint/hooks/runtime.go
index 135df0c1..526a917b 100644
--- a/cli/beacon/internal/endpoint/hooks/runtime.go
+++ b/cli/beacon/internal/endpoint/hooks/runtime.go
@@ -143,11 +143,6 @@ func endpointCommandArgs(platform, binaryPath, logPath, configPath string) []str
if configPath != "" {
args = append(args, "--config", configPath)
}
- // Best-effort, exactly as in endpointCommandPrefix: the CLI path only enables the inventory
- // heartbeat, and a hook with no --cli still captures everything else.
- if cliPath, err := os.Executable(); err == nil && cliPath != "" {
- args = append(args, "--cli", cliPath)
- }
return args
}
@@ -159,11 +154,6 @@ func endpointCommandPrefix(platform, binaryPath, logPath, configPath string) str
if configPath != "" {
args = append(args, "--config", hookCommandQuote(configPath))
}
- // Best-effort: the CLI path only enables the inventory heartbeat, and a hook with no --cli
- // still captures everything else.
- if cliPath, err := os.Executable(); err == nil && cliPath != "" {
- args = append(args, "--cli", hookCommandQuote(cliPath))
- }
return strings.Join(args, " ")
}
@@ -220,6 +210,8 @@ func commandCarriesEndpointSettings(command string) bool {
if field == "BEACON_ENDPOINT_MODE=1" {
return true
}
+ // --cli is no longer written (inventory comes from the scheduled job, not the hook), but
+ // it is still recognized so hooks installed by older versions are repaired and removed.
for _, name := range []string{"--log", "--config", "--cli"} {
if field == name || strings.HasPrefix(field, name+"=") {
return true
diff --git a/packaging/linux/nfpm/postinstall.sh b/packaging/linux/nfpm/postinstall.sh
index cc459791..48157919 100755
--- a/packaging/linux/nfpm/postinstall.sh
+++ b/packaging/linux/nfpm/postinstall.sh
@@ -33,6 +33,10 @@ fi
if [ -x /opt/beacon/bin/beacon ]; then
/opt/beacon/bin/beacon endpoint update install-daemon >/dev/null 2>&1 || \
echo "beacon: scheduled updater not configured (endpoint is installed and running)" >&2
+ # The scheduled inventory job is on by default; endpoint install already wrote and loaded it,
+ # this re-reconcile is idempotent and covers an upgrade that skipped install.
+ /opt/beacon/bin/beacon endpoint inventory install-daemon --system >/dev/null 2>&1 || \
+ echo "beacon: scheduled inventory job not configured (endpoint is installed and running)" >&2
fi
echo "beacon: endpoint installed. Check it with: beacon endpoint status --system"
diff --git a/packaging/macos/scripts/postinstall b/packaging/macos/scripts/postinstall
index 23618dd9..729daaef 100755
--- a/packaging/macos/scripts/postinstall
+++ b/packaging/macos/scripts/postinstall
@@ -124,6 +124,11 @@ if command -v launchctl >/dev/null 2>&1; then
echo "Error: could not reconcile Beacon endpoint updater daemon" >&2
exit 1
}
+ # The scheduled inventory job is on by default; loading it fires the first heartbeat at once, so
+ # an endpoint upgraded from a version without the job starts reporting inventory immediately.
+ # Non-fatal: the endpoint is installed and collecting either way.
+ "${BEACON_BIN:-/opt/beacon/bin/beacon}" endpoint inventory install-daemon --system || \
+ echo "Warning: scheduled inventory job not configured (endpoint is installed and running)" >&2
fi
exit 0