Skip to content

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

refactor(cmd): split endpoint.go into concern-focused files

Claudeab68e3604868
diff --git a/cli/beacon/cmd/endpoint.go b/cli/beacon/cmd/endpoint.go
index 84265cb7..7de2f64e 100644
--- a/cli/beacon/cmd/endpoint.go
+++ b/cli/beacon/cmd/endpoint.go
@@ -1,13 +1,9 @@
package cmd
import (
- "context"
"encoding/json"
"fmt"
"os"
- "os/exec"
- "path/filepath"
- "runtime"
"strings"
"time"
@@ -15,16 +11,10 @@ import (
endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/dashboard"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/elastic"
- "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/integrations/cowork"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/integrations/openclaw"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/integrations/vscode"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/lifecycle"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/schema"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/writer"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/version"
)
var endpointOpts struct {
@@ -89,20 +79,6 @@ var endpointCmd = &cobra.Command{
discovery, telemetry collection, and Wazuh-compatible JSON logs.`,
}
-var endpointInstallCmd = &cobra.Command{
- Use: "install",
- Short: "Install local endpoint telemetry configuration",
- SilenceUsage: true,
- RunE: runEndpointInstall,
-}
-
-var endpointStatusCmd = &cobra.Command{
- Use: "status",
- Short: "Show local endpoint status",
- SilenceUsage: true,
- RunE: runEndpointStatus,
-}
-
var endpointDoctorCmd = &cobra.Command{
Use: "doctor",
Short: "Run local endpoint health checks",
@@ -117,13 +93,6 @@ var endpointInventoryCmd = &cobra.Command{
RunE: runEndpointInventory,
}
-var endpointDiscoverCmd = &cobra.Command{
- Use: "discover",
- Short: "Discover supported local AI agent runtimes",
- SilenceUsage: true,
- RunE: runEndpointDiscover,
-}
-
var endpointTestEventCmd = &cobra.Command{
Use: "test-event",
Aliases: []string{"validate-pipeline"},
@@ -139,27 +108,6 @@ var endpointBundleDiagnosticsCmd = &cobra.Command{
RunE: runEndpointBundleDiagnostics,
}
-var endpointUninstallCmd = &cobra.Command{
- Use: "uninstall",
- Short: "Remove local endpoint service files",
- SilenceUsage: true,
- RunE: runEndpointUninstall,
-}
-
-var endpointRepairCmd = &cobra.Command{
- Use: "repair",
- Short: "Repair local endpoint service and telemetry configuration",
- SilenceUsage: true,
- RunE: runEndpointRepair,
-}
-
-var endpointDashboardCmd = &cobra.Command{
- Use: "dashboard",
- Short: "Run the local Beacon endpoint dashboard",
- SilenceUsage: true,
- RunE: runEndpointDashboard,
-}
-
var endpointIntegrationsCmd = &cobra.Command{
Use: "integrations",
Short: "Manage admin-configured endpoint integrations",
@@ -172,11 +120,6 @@ var endpointIntegrationsValidateCmd = &cobra.Command{
RunE: runEndpointIntegrationsValidate,
}
-var endpointHooksCmd = &cobra.Command{
- Use: "hooks",
- Short: "Manage endpoint hook integrations",
-}
-
var endpointConfigCmd = &cobra.Command{
Use: "config",
Short: "Inspect and safely update endpoint configuration",
@@ -204,13 +147,6 @@ var endpointConfigSetRetentionCmd = &cobra.Command{
RunE: runEndpointConfigSetRetention,
}
-var endpointHooksInstallCmd = &cobra.Command{
- Use: "install",
- Short: "Install endpoint hooks for supported harnesses",
- SilenceUsage: true,
- RunE: runEndpointHooksInstall,
-}
-
var topLevelDoctorCmd = &cobra.Command{
Use: "doctor",
Short: "Alias for beacon endpoint doctor",
@@ -232,20 +168,6 @@ var topLevelInventoryCmd = &cobra.Command{
RunE: runEndpointInventory,
}
-var endpointHooksUninstallCmd = &cobra.Command{
- Use: "uninstall",
- Short: "Uninstall endpoint hooks for supported harnesses",
- SilenceUsage: true,
- RunE: runEndpointHooksUninstall,
-}
-
-var endpointHooksStatusCmd = &cobra.Command{
- Use: "status",
- Short: "Show endpoint hook integration status",
- SilenceUsage: true,
- RunE: runEndpointHooksStatus,
-}
-
var endpointCoworkCmd = &cobra.Command{
Use: "claude-cowork",
Short: "Manage Claude Cowork OpenTelemetry integration",
@@ -567,395 +489,6 @@ func init() {
endpointUninstallCmd.Flags().BoolVar(&endpointOpts.dryRun, "dry-run", false, "Print planned actions without changing endpoint files or services")
}
-func runEndpointHooksInstall(cmd *cobra.Command, args []string) error {
- targets, err := hookTargets()
- if err != nil {
- return err
- }
- if endpointOpts.dryRun {
- actions := []plannedAction{}
- for _, name := range targets {
- actions = append(actions, plannedAction{Action: "configure_harness", Target: name, Message: "install endpoint hook integration"})
- }
- return printPlannedActions(actions)
- }
- cfg := loadOrDefaultConfig()
- for _, name := range targets {
- if err := installEndpointHookTarget(name, cfg); err != nil {
- return err
- }
- }
- return nil
-}
-
-func installEndpointHookTarget(name string, cfg endpointconfig.Config) error {
- switch strings.TrimSpace(name) {
- case "antigravity":
- status, err := endpointhooks.InstallAntigravity(endpointhooks.AntigravityOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Printf("Antigravity hooks installed: %s\n", status.ConfigPath)
- case "cursor":
- status, err := endpointhooks.InstallCursor(endpointhooks.CursorOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Printf("Cursor hooks installed: %s\n", status.HooksJSONPath)
- case "claude":
- status, err := endpointhooks.InstallClaude(endpointhooks.ClaudeOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Printf("Claude Code hooks installed: %s\n", status.SettingsPath)
- case "vscode":
- status, err := endpointhooks.InstallVSCode(endpointhooks.VSCodeOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Printf("VS Code hooks installed: %s\n", status.HooksPath)
- case "factory":
- status, err := endpointhooks.InstallFactory(endpointhooks.FactoryOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Printf("Factory hooks installed: %s\n", status.SettingsPath)
- case "opencode":
- status, err := endpointhooks.InstallOpenCode(endpointhooks.OpenCodeOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Printf("opencode plugin installed: %s\n", status.PluginPath)
- case "grok":
- status, err := endpointhooks.InstallGrok(endpointhooks.GrokOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Printf("Grok hooks installed: %s\n", status.HooksPath)
- if strings.Contains(status.Message, "/hooks-trust") {
- fmt.Println(status.Message)
- }
- case "hermes":
- status, err := endpointhooks.InstallHermes(endpointhooks.HermesOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Printf("Hermes Agent hooks installed: %s\n", status.ConfigPath)
- fmt.Println("Hermes may prompt to trust new shell hooks on first use; use HERMES_ACCEPT_HOOKS=1 or hooks_auto_accept: true for non-TTY runs.")
- case "devin-cli":
- status, err := endpointhooks.InstallDevin(endpointhooks.DevinOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Printf("Devin CLI hooks installed: %s\n", status.ConfigPath)
- case "devin-desktop":
- status, err := endpointhooks.InstallDevinDesktop(endpointhooks.DevinDesktopOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Printf("Devin Desktop hooks installed: %s\n", status.ConfigPath)
- fmt.Println("Devin Desktop hook files are installed; generate a Desktop event and check the runtime log to validate execution.")
- case "":
- default:
- return fmt.Errorf("unsupported hook harness %q", name)
- }
- return nil
-}
-
-func runEndpointHooksUninstall(cmd *cobra.Command, args []string) error {
- targets, err := hookTargets()
- if err != nil {
- return err
- }
- if endpointOpts.dryRun {
- actions := []plannedAction{}
- for _, name := range targets {
- actions = append(actions, plannedAction{Action: "remove_hook", Target: name, Message: "uninstall endpoint hook integration"})
- }
- return printPlannedActions(actions)
- }
- cfg := loadOrDefaultConfig()
- for _, name := range targets {
- if err := uninstallEndpointHookTarget(name, cfg); err != nil {
- return err
- }
- }
- return nil
-}
-
-func uninstallEndpointHookTarget(name string, cfg endpointconfig.Config) error {
- switch strings.TrimSpace(name) {
- case "antigravity":
- status, err := endpointhooks.UninstallAntigravity(endpointhooks.AntigravityOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Println(status.Message)
- case "cursor":
- status, err := endpointhooks.UninstallCursor(endpointhooks.CursorOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Println(status.Message)
- case "claude":
- status, err := endpointhooks.UninstallClaude(endpointhooks.ClaudeOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Println(status.Message)
- case "vscode":
- status, err := endpointhooks.UninstallVSCode(endpointhooks.VSCodeOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Println(status.Message)
- case "factory":
- status, err := endpointhooks.UninstallFactory(endpointhooks.FactoryOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Println(status.Message)
- case "opencode":
- status, err := endpointhooks.UninstallOpenCode(endpointhooks.OpenCodeOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Println(status.Message)
- case "grok":
- status, err := endpointhooks.UninstallGrok(endpointhooks.GrokOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Println(status.Message)
- case "hermes":
- status, err := endpointhooks.UninstallHermes(endpointhooks.HermesOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Println(status.Message)
- case "devin-cli":
- status, err := endpointhooks.UninstallDevin(endpointhooks.DevinOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Println(status.Message)
- case "devin-desktop":
- status, err := endpointhooks.UninstallDevinDesktop(endpointhooks.DevinDesktopOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- if err != nil {
- return err
- }
- fmt.Println(status.Message)
- case "":
- default:
- return fmt.Errorf("unsupported hook harness %q", name)
- }
- return nil
-}
-
-func runEndpointHooksStatus(cmd *cobra.Command, args []string) error {
- targets, err := hookTargets()
- if err != nil {
- return err
- }
- cfg := loadOrDefaultConfig()
- statuses := map[string]interface{}{}
- for _, name := range targets {
- switch strings.TrimSpace(name) {
- case "antigravity":
- statuses["antigravity"] = endpointhooks.AntigravityHookStatus(endpointhooks.AntigravityOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- case "cursor":
- statuses["cursor"] = endpointhooks.CursorHookStatus(endpointhooks.CursorOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- case "claude":
- statuses["claude"] = endpointhooks.ClaudeHookStatus(endpointhooks.ClaudeOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- case "vscode":
- statuses["vscode"] = endpointhooks.VSCodeHookStatus(endpointhooks.VSCodeOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- case "factory":
- statuses["factory"] = endpointhooks.FactoryHookStatus(endpointhooks.FactoryOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- case "opencode":
- statuses["opencode"] = endpointhooks.OpenCodeHookStatus(endpointhooks.OpenCodeOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- case "grok":
- statuses["grok"] = endpointhooks.GrokHookStatus(endpointhooks.GrokOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- case "hermes":
- statuses["hermes"] = endpointhooks.HermesHookStatus(endpointhooks.HermesOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- case "devin-cli":
- statuses["devin-cli"] = endpointhooks.DevinHookStatus(endpointhooks.DevinOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- case "devin-desktop":
- statuses["devin-desktop"] = endpointhooks.DevinDesktopHookStatus(endpointhooks.DevinDesktopOptions{
- Level: endpointhooks.Level(endpointOpts.hookLevel),
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
- case "":
- default:
- return fmt.Errorf("unsupported hook harness %q", name)
- }
- }
- if endpointOpts.jsonOutput {
- return json.NewEncoder(os.Stdout).Encode(statuses)
- }
- for _, name := range targets {
- switch strings.TrimSpace(name) {
- case "antigravity":
- status := statuses["antigravity"].(endpointhooks.AntigravityStatus)
- fmt.Printf("Antigravity hooks: installed=%t path=%s\n", status.Installed, status.ConfigPath)
- fmt.Println(status.Message)
- case "cursor":
- status := statuses["cursor"].(endpointhooks.CursorStatus)
- fmt.Printf("Cursor hooks: installed=%t path=%s\n", status.Installed, status.HooksJSONPath)
- fmt.Println(status.Message)
- case "claude":
- status := statuses["claude"].(endpointhooks.ClaudeStatus)
- fmt.Printf("Claude Code hooks: installed=%t path=%s\n", status.Installed, status.SettingsPath)
- fmt.Println(status.Message)
- case "vscode":
- status := statuses["vscode"].(endpointhooks.VSCodeStatus)
- fmt.Printf("VS Code hooks: installed=%t path=%s\n", status.Installed, status.HooksPath)
- fmt.Println(status.Message)
- case "factory":
- status := statuses["factory"].(endpointhooks.FactoryStatus)
- fmt.Printf("Factory hooks: installed=%t path=%s\n", status.Installed, status.SettingsPath)
- fmt.Println(status.Message)
- case "opencode":
- status := statuses["opencode"].(endpointhooks.OpenCodeStatus)
- fmt.Printf("opencode plugin: installed=%t path=%s\n", status.Installed, status.PluginPath)
- fmt.Println(status.Message)
- case "grok":
- status := statuses["grok"].(endpointhooks.GrokStatus)
- fmt.Printf("Grok hooks: installed=%t path=%s\n", status.Installed, status.HooksPath)
- fmt.Println(status.Message)
- case "hermes":
- status := statuses["hermes"].(endpointhooks.HermesStatus)
- fmt.Printf("Hermes Agent hooks: installed=%t path=%s\n", status.Installed, status.ConfigPath)
- fmt.Println(status.Message)
- case "devin-cli":
- status := statuses["devin-cli"].(endpointhooks.DevinStatus)
- fmt.Printf("Devin CLI hooks: installed=%t path=%s\n", status.Installed, status.ConfigPath)
- fmt.Println(status.Message)
- case "devin-desktop":
- status := statuses["devin-desktop"].(endpointhooks.DevinStatus)
- fmt.Printf("Devin Desktop hooks: installed=%t path=%s\n", status.Installed, status.ConfigPath)
- fmt.Println(status.Message)
- }
- }
- return nil
-}
-
func runEndpointOpenClawValidate() error {
cfg := loadOrDefaultConfig()
setup := func() {
@@ -1063,330 +596,10 @@ func runEndpointVSCodeValidate() error {
return nil
}
-func runEndpointElasticUp(ctx context.Context) error {
- if runtime.GOOS != "darwin" {
- return fmt.Errorf("beacon endpoint elastic up is currently macOS-only")
- }
- cfg := loadOrDefaultConfig()
- logPath, err := filepath.Abs(cfg.LogPath)
- if err != nil {
- return err
- }
- packDir := endpointOpts.elasticPackDir
- if packDir == "" {
- packDir = elastic.DefaultOutputDir
- }
- if err := ensureElasticPack(packDir, logPath); err != nil {
- return err
- }
- if err := ensureLogFile(logPath); err != nil {
- return err
- }
- env := os.Environ()
- env = append(env, "BEACON_LOG_DIR="+filepath.Dir(logPath))
- if err := runDockerCompose(ctx, packDir, env, "up", "-d"); err != nil {
- return err
- }
- fmt.Printf("Elasticsearch ready at http://localhost:%s\n", envDefault("BEACON_ELASTIC_ES_PORT", "9200"))
- fmt.Printf("Kibana ready at http://localhost:%s\n", envDefault("BEACON_ELASTIC_KIBANA_PORT", "5601"))
- fmt.Printf("Filebeat tailing %s\n", logPath)
- return nil
-}
-
-func runEndpointElasticDown(ctx context.Context) error {
- if runtime.GOOS != "darwin" {
- return fmt.Errorf("beacon endpoint elastic down is currently macOS-only")
- }
- packDir := endpointOpts.elasticPackDir
- if packDir == "" {
- packDir = elastic.DefaultOutputDir
- }
- if _, err := os.Stat(filepath.Join(packDir, "docker-compose.yml")); os.IsNotExist(err) {
- fmt.Printf("No Elasticsearch stack found for %s\n", packDir)
- return nil
- } else if err != nil {
- return err
- }
- logPath, err := filepath.Abs(loadOrDefaultConfig().LogPath)
- if err != nil {
- return err
- }
- env := append(os.Environ(), "BEACON_LOG_DIR="+filepath.Dir(logPath))
- if err := runDockerCompose(ctx, packDir, env, "down", "--remove-orphans"); err != nil {
- return err
- }
- fmt.Printf("Elasticsearch stack stopped for %s\n", packDir)
- return nil
-}
-
-func ensureElasticPack(packDir, logPath string) error {
- if _, err := os.Stat(filepath.Join(packDir, "docker-compose.yml")); err == nil {
- return nil
- } else if !os.IsNotExist(err) {
- return err
- }
- if err := elastic.InstallPack(packDir, logPath); err != nil {
- return err
- }
- fmt.Printf("Elasticsearch content pack written to %s\n", packDir)
- return nil
-}
-
-func ensureLogFile(path string) error {
- if path == "" {
- return nil
- }
- if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
- return err
- }
- file, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND, 0644)
- if err != nil {
- return err
- }
- return file.Close()
-}
-
-func runDockerCompose(ctx context.Context, dir string, env []string, args ...string) error {
- if _, err := os.Stat(filepath.Join(dir, "docker-compose.yml")); err != nil {
- return fmt.Errorf("docker-compose.yml not found in %s: %w", dir, err)
- }
- fullArgs := append([]string{"compose"}, args...)
- cmd := exec.CommandContext(ctx, "docker", fullArgs...)
- cmd.Dir = dir
- cmd.Env = env
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- return cmd.Run()
-}
-
-func envDefault(name, fallback string) string {
- value := strings.TrimSpace(os.Getenv(name))
- if value == "" {
- return fallback
- }
- return value
-}
-
-func runEndpointDashboard(cmd *cobra.Command, args []string) error {
- cfg := loadOrDefaultConfig()
- userMode := endpointUserMode()
- runtimeLog := lifecycle.ResolveRuntimeLog(userMode, endpointOpts.logPath)
- cfg.UserMode = runtimeLog.EffectiveUserMode
- cfg.LogPath = runtimeLog.EffectiveLogPath
- if endpointOpts.dashboardAddr == "" {
- endpointOpts.dashboardAddr = dashboard.DefaultAddr
- }
- if err := dashboard.ValidateLoopbackAddr(endpointOpts.dashboardAddr); err != nil {
- return err
- }
- url := dashboard.URL(endpointOpts.dashboardAddr)
- fmt.Printf("Beacon endpoint dashboard: %s\n", url)
- fmt.Printf("Runtime log: %s\n", cfg.LogPath)
- if runtimeLog.Warning != "" {
- fmt.Printf("Runtime log source: %s\n", runtimeLog.Warning)
- }
- if endpointOpts.dashboardOpen {
- if err := dashboard.OpenBrowser(url); err != nil {
- return err
- }
- }
- return dashboard.ListenAndServe(dashboard.Options{
- Addr: endpointOpts.dashboardAddr,
- LogPath: cfg.LogPath,
- UserMode: cfg.UserMode,
- })
-}
-
-func runEndpointInstall(cmd *cobra.Command, args []string) error {
- otlpHarnesses, hookHarnesses, err := splitEndpointTargets(splitHarnessCSV(endpointOpts.harnesses))
- if err != nil {
- return err
- }
- if endpointOpts.dryRun {
- return printPlannedActions(plannedInstallActions(false))
- }
- result, err := lifecycle.Install(lifecycle.InstallOptions{
- UserMode: endpointUserMode(),
- LogPath: endpointOpts.logPath,
- Harnesses: otlpHarnesses,
- GRPCPort: endpointOpts.grpcPort,
- HTTPPort: endpointOpts.httpPort,
- CollectorPath: endpointOpts.collectorPath,
- StartService: !endpointOpts.noStart,
- ContentRetention: endpointconfig.ContentRetention(endpointOpts.contentRetention),
- IncludeRuntimeMetrics: endpointOpts.includeRuntimeMetrics,
- IncludeCodexSpans: endpointOpts.includeCodexSpans,
- SplunkHEC: splunkHECOptions(),
- FalconHEC: falconHECOptions(),
- })
- if err != nil {
- return err
- }
- fmt.Printf("Endpoint config written to %s\n", result.ConfigPath)
- fmt.Printf("Collector config written to %s\n", result.CollectorConfigPath)
- fmt.Printf("Launch plist written to %s\n", result.PlistPath)
- fmt.Printf("Install manifest written to %s\n", result.ManifestPath)
- fmt.Printf("Runtime log: %s\n", result.LogPath)
- if err := installHookTargetsFromEndpointInstall(hookHarnesses); err != nil {
- return fmt.Errorf("endpoint install completed, but hook installation failed: %w", err)
- }
- return nil
-}
-
-func runEndpointStatus(cmd *cobra.Command, args []string) error {
- status := lifecycle.GetStatus(endpointUserMode(), endpointOpts.logPath)
- if endpointOpts.jsonOutput {
- return json.NewEncoder(os.Stdout).Encode(status)
- }
- fmt.Printf("Beacon Endpoint Agent %s\n", status.Version)
- fmt.Printf("Config: %s\n", status.ConfigPath)
- fmt.Printf("Runtime log: %s\n", status.LogPath)
- if status.RuntimeLog.Warning != "" {
- fmt.Printf("Runtime log source: %s\n", status.RuntimeLog.Warning)
- }
- fmt.Printf("Collector: grpc=%t http=%t", status.Collector.GRPCReady, status.Collector.HTTPReady)
- if status.Collector.Message != "" {
- fmt.Printf(" (%s)", status.Collector.Message)
- }
- fmt.Println()
- fmt.Printf("Service: loaded=%t running=%t", status.Service.Loaded, status.Service.Running)
- if status.Service.Message != "" {
- fmt.Printf(" (%s)", status.Service.Message)
- }
- fmt.Println()
- for _, h := range status.Harnesses {
- if h.Detected {
- fmt.Printf("Harness: %s %s telemetry=%s\n", h.DisplayName, h.Version, h.TelemetryStatus)
- }
- }
- for _, check := range status.Diagnostics {
- if check.Status != "ok" {
- fmt.Printf("Diagnostic: %s %s (%s)\n", check.Name, check.Status, check.Message)
- }
- }
- if status.LastEvent == "" {
- fmt.Println("Last event: none")
- } else {
- fmt.Println("Last event: present")
- }
- return nil
-}
-
-func runEndpointDiscover(cmd *cobra.Command, args []string) error {
- discovered := harness.DiscoverAll()
- if endpointOpts.jsonOutput {
- if !endpointOpts.allTargets {
- filtered := []harness.Harness{}
- for _, h := range discovered {
- if h.Detected {
- filtered = append(filtered, h)
- }
- }
- return json.NewEncoder(os.Stdout).Encode(filtered)
- }
- return json.NewEncoder(os.Stdout).Encode(discovered)
- }
- for _, h := range discovered {
- if !endpointOpts.allTargets && !h.Detected {
- continue
- }
- state := "not detected"
- if h.Detected {
- state = "detected"
- }
- fmt.Printf("%s: %s, telemetry=%s", h.DisplayName, state, h.TelemetryStatus)
- if h.ExecutablePath != "" {
- fmt.Printf(", path=%s", h.ExecutablePath)
- }
- fmt.Println()
- }
- cfg := loadOrDefaultConfig()
- for _, h := range discovered {
- if h.Detected {
- event := schema.NewEvent(schema.NewEventOptions{
- Action: "agent.detected",
- Category: "inventory",
- Severity: schema.SeverityInfo,
- AgentVersion: version.GetVersion(),
- Harness: schema.HarnessInfo{
- Name: h.Name,
- Version: h.Version,
- ExecutablePath: h.ExecutablePath,
- ConfigPath: h.ConfigPath,
- },
- Message: h.DisplayName + " detected",
- })
- if _, err := writer.AppendEvent(event, writer.Options{Path: cfg.LogPath, UserMode: cfg.UserMode}); err != nil {
- return err
- }
- }
- }
- return nil
-}
-
func writeValidationEvent(cfg endpointconfig.Config, destination string) (string, error) {
return writer.AppendEvent(syntheticEvent(destination), writer.Options{Path: cfg.LogPath, UserMode: cfg.UserMode})
}
-func runEndpointUninstall(cmd *cobra.Command, args []string) error {
- if endpointOpts.dryRun {
- return printPlannedActions(plannedUninstallActions())
- }
- if err := lifecycle.Uninstall(lifecycle.UninstallOptions{UserMode: endpointUserMode(), LogPath: endpointOpts.logPath, KeepLogs: endpointOpts.keepLogs, KeepConfig: endpointOpts.keepConfig}); err != nil {
- return err
- }
- fmt.Println("Endpoint service, config, and managed files removed.")
- return nil
-}
-
-func runEndpointRepair(cmd *cobra.Command, args []string) error {
- otlpHarnesses, hookHarnesses, err := splitEndpointTargets(splitHarnessCSV(endpointOpts.harnesses))
- if err != nil {
- return err
- }
- if endpointOpts.dryRun {
- return printPlannedActions(plannedInstallActions(true))
- }
- result, err := lifecycle.Repair(lifecycle.InstallOptions{
- UserMode: endpointUserMode(),
- LogPath: endpointOpts.logPath,
- Harnesses: otlpHarnesses,
- GRPCPort: endpointOpts.grpcPort,
- HTTPPort: endpointOpts.httpPort,
- CollectorPath: endpointOpts.collectorPath,
- StartService: !endpointOpts.noStart,
- ContentRetention: endpointconfig.ContentRetention(endpointOpts.contentRetention),
- IncludeRuntimeMetrics: endpointOpts.includeRuntimeMetrics,
- IncludeCodexSpans: endpointOpts.includeCodexSpans,
- SplunkHEC: splunkHECOptions(),
- FalconHEC: falconHECOptions(),
- })
- if err != nil {
- return err
- }
- fmt.Printf("Endpoint repaired. Manifest: %s\n", result.ManifestPath)
- if err := installHookTargetsFromEndpointInstall(hookHarnesses); err != nil {
- return fmt.Errorf("endpoint repair completed, but hook installation failed: %w", err)
- }
- return nil
-}
-
-func installHookTargetsFromEndpointInstall(targets []string) error {
- if len(targets) == 0 {
- return nil
- }
- cfg := loadOrDefaultConfig()
- if endpointOpts.logPath != "" {
- cfg.LogPath = endpointOpts.logPath
- }
- for _, target := range targets {
- if err := installEndpointHookTarget(target, cfg); err != nil {
- return err
- }
- }
- return nil
-}
-
func loadOrDefaultConfig() endpointconfig.Config {
userMode := endpointUserMode()
if cfg, err := endpointconfig.Load(userMode); err == nil {
diff --git a/cli/beacon/cmd/endpoint_elastic.go b/cli/beacon/cmd/endpoint_elastic.go
new file mode 100644
index 00000000..57f17361
--- /dev/null
+++ b/cli/beacon/cmd/endpoint_elastic.go
@@ -0,0 +1,117 @@
+package cmd
+
+import (
+ "context"
+ "fmt"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "strings"
+
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/elastic"
+)
+
+func runEndpointElasticUp(ctx context.Context) error {
+ if runtime.GOOS != "darwin" {
+ return fmt.Errorf("beacon endpoint elastic up is currently macOS-only")
+ }
+ cfg := loadOrDefaultConfig()
+ logPath, err := filepath.Abs(cfg.LogPath)
+ if err != nil {
+ return err
+ }
+ packDir := endpointOpts.elasticPackDir
+ if packDir == "" {
+ packDir = elastic.DefaultOutputDir
+ }
+ if err := ensureElasticPack(packDir, logPath); err != nil {
+ return err
+ }
+ if err := ensureLogFile(logPath); err != nil {
+ return err
+ }
+ env := os.Environ()
+ env = append(env, "BEACON_LOG_DIR="+filepath.Dir(logPath))
+ if err := runDockerCompose(ctx, packDir, env, "up", "-d"); err != nil {
+ return err
+ }
+ fmt.Printf("Elasticsearch ready at http://localhost:%s\n", envDefault("BEACON_ELASTIC_ES_PORT", "9200"))
+ fmt.Printf("Kibana ready at http://localhost:%s\n", envDefault("BEACON_ELASTIC_KIBANA_PORT", "5601"))
+ fmt.Printf("Filebeat tailing %s\n", logPath)
+ return nil
+}
+
+func runEndpointElasticDown(ctx context.Context) error {
+ if runtime.GOOS != "darwin" {
+ return fmt.Errorf("beacon endpoint elastic down is currently macOS-only")
+ }
+ packDir := endpointOpts.elasticPackDir
+ if packDir == "" {
+ packDir = elastic.DefaultOutputDir
+ }
+ if _, err := os.Stat(filepath.Join(packDir, "docker-compose.yml")); os.IsNotExist(err) {
+ fmt.Printf("No Elasticsearch stack found for %s\n", packDir)
+ return nil
+ } else if err != nil {
+ return err
+ }
+ logPath, err := filepath.Abs(loadOrDefaultConfig().LogPath)
+ if err != nil {
+ return err
+ }
+ env := append(os.Environ(), "BEACON_LOG_DIR="+filepath.Dir(logPath))
+ if err := runDockerCompose(ctx, packDir, env, "down", "--remove-orphans"); err != nil {
+ return err
+ }
+ fmt.Printf("Elasticsearch stack stopped for %s\n", packDir)
+ return nil
+}
+
+func ensureElasticPack(packDir, logPath string) error {
+ if _, err := os.Stat(filepath.Join(packDir, "docker-compose.yml")); err == nil {
+ return nil
+ } else if !os.IsNotExist(err) {
+ return err
+ }
+ if err := elastic.InstallPack(packDir, logPath); err != nil {
+ return err
+ }
+ fmt.Printf("Elasticsearch content pack written to %s\n", packDir)
+ return nil
+}
+
+func ensureLogFile(path string) error {
+ if path == "" {
+ return nil
+ }
+ if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
+ return err
+ }
+ file, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND, 0644)
+ if err != nil {
+ return err
+ }
+ return file.Close()
+}
+
+func runDockerCompose(ctx context.Context, dir string, env []string, args ...string) error {
+ if _, err := os.Stat(filepath.Join(dir, "docker-compose.yml")); err != nil {
+ return fmt.Errorf("docker-compose.yml not found in %s: %w", dir, err)
+ }
+ fullArgs := append([]string{"compose"}, args...)
+ cmd := exec.CommandContext(ctx, "docker", fullArgs...)
+ cmd.Dir = dir
+ cmd.Env = env
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ return cmd.Run()
+}
+
+func envDefault(name, fallback string) string {
+ value := strings.TrimSpace(os.Getenv(name))
+ if value == "" {
+ return fallback
+ }
+ return value
+}
diff --git a/cli/beacon/cmd/endpoint_hooks.go b/cli/beacon/cmd/endpoint_hooks.go
new file mode 100644
index 00000000..93f1d12d
--- /dev/null
+++ b/cli/beacon/cmd/endpoint_hooks.go
@@ -0,0 +1,427 @@
+package cmd
+
+import (
+ "encoding/json"
+ "fmt"
+ "os"
+ "strings"
+
+ 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/spf13/cobra"
+)
+
+var endpointHooksCmd = &cobra.Command{
+ Use: "hooks",
+ Short: "Manage endpoint hook integrations",
+}
+
+var endpointHooksInstallCmd = &cobra.Command{
+ Use: "install",
+ Short: "Install endpoint hooks for supported harnesses",
+ SilenceUsage: true,
+ RunE: runEndpointHooksInstall,
+}
+
+var endpointHooksUninstallCmd = &cobra.Command{
+ Use: "uninstall",
+ Short: "Uninstall endpoint hooks for supported harnesses",
+ SilenceUsage: true,
+ RunE: runEndpointHooksUninstall,
+}
+
+var endpointHooksStatusCmd = &cobra.Command{
+ Use: "status",
+ Short: "Show endpoint hook integration status",
+ SilenceUsage: true,
+ RunE: runEndpointHooksStatus,
+}
+
+func runEndpointHooksInstall(cmd *cobra.Command, args []string) error {
+ targets, err := hookTargets()
+ if err != nil {
+ return err
+ }
+ if endpointOpts.dryRun {
+ actions := []plannedAction{}
+ for _, name := range targets {
+ actions = append(actions, plannedAction{Action: "configure_harness", Target: name, Message: "install endpoint hook integration"})
+ }
+ return printPlannedActions(actions)
+ }
+ cfg := loadOrDefaultConfig()
+ for _, name := range targets {
+ if err := installEndpointHookTarget(name, cfg); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func installEndpointHookTarget(name string, cfg endpointconfig.Config) error {
+ switch strings.TrimSpace(name) {
+ case "antigravity":
+ status, err := endpointhooks.InstallAntigravity(endpointhooks.AntigravityOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Antigravity hooks installed: %s\n", status.ConfigPath)
+ case "cursor":
+ status, err := endpointhooks.InstallCursor(endpointhooks.CursorOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Cursor hooks installed: %s\n", status.HooksJSONPath)
+ case "claude":
+ status, err := endpointhooks.InstallClaude(endpointhooks.ClaudeOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Claude Code hooks installed: %s\n", status.SettingsPath)
+ case "vscode":
+ status, err := endpointhooks.InstallVSCode(endpointhooks.VSCodeOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("VS Code hooks installed: %s\n", status.HooksPath)
+ case "factory":
+ status, err := endpointhooks.InstallFactory(endpointhooks.FactoryOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Factory hooks installed: %s\n", status.SettingsPath)
+ case "opencode":
+ status, err := endpointhooks.InstallOpenCode(endpointhooks.OpenCodeOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("opencode plugin installed: %s\n", status.PluginPath)
+ case "grok":
+ status, err := endpointhooks.InstallGrok(endpointhooks.GrokOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Grok hooks installed: %s\n", status.HooksPath)
+ if strings.Contains(status.Message, "/hooks-trust") {
+ fmt.Println(status.Message)
+ }
+ case "hermes":
+ status, err := endpointhooks.InstallHermes(endpointhooks.HermesOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Hermes Agent hooks installed: %s\n", status.ConfigPath)
+ fmt.Println("Hermes may prompt to trust new shell hooks on first use; use HERMES_ACCEPT_HOOKS=1 or hooks_auto_accept: true for non-TTY runs.")
+ case "devin-cli":
+ status, err := endpointhooks.InstallDevin(endpointhooks.DevinOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Devin CLI hooks installed: %s\n", status.ConfigPath)
+ case "devin-desktop":
+ status, err := endpointhooks.InstallDevinDesktop(endpointhooks.DevinDesktopOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Devin Desktop hooks installed: %s\n", status.ConfigPath)
+ fmt.Println("Devin Desktop hook files are installed; generate a Desktop event and check the runtime log to validate execution.")
+ case "":
+ default:
+ return fmt.Errorf("unsupported hook harness %q", name)
+ }
+ return nil
+}
+
+func runEndpointHooksUninstall(cmd *cobra.Command, args []string) error {
+ targets, err := hookTargets()
+ if err != nil {
+ return err
+ }
+ if endpointOpts.dryRun {
+ actions := []plannedAction{}
+ for _, name := range targets {
+ actions = append(actions, plannedAction{Action: "remove_hook", Target: name, Message: "uninstall endpoint hook integration"})
+ }
+ return printPlannedActions(actions)
+ }
+ cfg := loadOrDefaultConfig()
+ for _, name := range targets {
+ if err := uninstallEndpointHookTarget(name, cfg); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func uninstallEndpointHookTarget(name string, cfg endpointconfig.Config) error {
+ switch strings.TrimSpace(name) {
+ case "antigravity":
+ status, err := endpointhooks.UninstallAntigravity(endpointhooks.AntigravityOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Println(status.Message)
+ case "cursor":
+ status, err := endpointhooks.UninstallCursor(endpointhooks.CursorOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Println(status.Message)
+ case "claude":
+ status, err := endpointhooks.UninstallClaude(endpointhooks.ClaudeOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Println(status.Message)
+ case "vscode":
+ status, err := endpointhooks.UninstallVSCode(endpointhooks.VSCodeOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Println(status.Message)
+ case "factory":
+ status, err := endpointhooks.UninstallFactory(endpointhooks.FactoryOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Println(status.Message)
+ case "opencode":
+ status, err := endpointhooks.UninstallOpenCode(endpointhooks.OpenCodeOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Println(status.Message)
+ case "grok":
+ status, err := endpointhooks.UninstallGrok(endpointhooks.GrokOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Println(status.Message)
+ case "hermes":
+ status, err := endpointhooks.UninstallHermes(endpointhooks.HermesOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Println(status.Message)
+ case "devin-cli":
+ status, err := endpointhooks.UninstallDevin(endpointhooks.DevinOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Println(status.Message)
+ case "devin-desktop":
+ status, err := endpointhooks.UninstallDevinDesktop(endpointhooks.DevinDesktopOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Println(status.Message)
+ case "":
+ default:
+ return fmt.Errorf("unsupported hook harness %q", name)
+ }
+ return nil
+}
+
+func runEndpointHooksStatus(cmd *cobra.Command, args []string) error {
+ targets, err := hookTargets()
+ if err != nil {
+ return err
+ }
+ cfg := loadOrDefaultConfig()
+ statuses := map[string]interface{}{}
+ for _, name := range targets {
+ switch strings.TrimSpace(name) {
+ case "antigravity":
+ statuses["antigravity"] = endpointhooks.AntigravityHookStatus(endpointhooks.AntigravityOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ case "cursor":
+ statuses["cursor"] = endpointhooks.CursorHookStatus(endpointhooks.CursorOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ case "claude":
+ statuses["claude"] = endpointhooks.ClaudeHookStatus(endpointhooks.ClaudeOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ case "vscode":
+ statuses["vscode"] = endpointhooks.VSCodeHookStatus(endpointhooks.VSCodeOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ case "factory":
+ statuses["factory"] = endpointhooks.FactoryHookStatus(endpointhooks.FactoryOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ case "opencode":
+ statuses["opencode"] = endpointhooks.OpenCodeHookStatus(endpointhooks.OpenCodeOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ case "grok":
+ statuses["grok"] = endpointhooks.GrokHookStatus(endpointhooks.GrokOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ case "hermes":
+ statuses["hermes"] = endpointhooks.HermesHookStatus(endpointhooks.HermesOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ case "devin-cli":
+ statuses["devin-cli"] = endpointhooks.DevinHookStatus(endpointhooks.DevinOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ case "devin-desktop":
+ statuses["devin-desktop"] = endpointhooks.DevinDesktopHookStatus(endpointhooks.DevinDesktopOptions{
+ Level: endpointhooks.Level(endpointOpts.hookLevel),
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+ case "":
+ default:
+ return fmt.Errorf("unsupported hook harness %q", name)
+ }
+ }
+ if endpointOpts.jsonOutput {
+ return json.NewEncoder(os.Stdout).Encode(statuses)
+ }
+ for _, name := range targets {
+ switch strings.TrimSpace(name) {
+ case "antigravity":
+ status := statuses["antigravity"].(endpointhooks.AntigravityStatus)
+ fmt.Printf("Antigravity hooks: installed=%t path=%s\n", status.Installed, status.ConfigPath)
+ fmt.Println(status.Message)
+ case "cursor":
+ status := statuses["cursor"].(endpointhooks.CursorStatus)
+ fmt.Printf("Cursor hooks: installed=%t path=%s\n", status.Installed, status.HooksJSONPath)
+ fmt.Println(status.Message)
+ case "claude":
+ status := statuses["claude"].(endpointhooks.ClaudeStatus)
+ fmt.Printf("Claude Code hooks: installed=%t path=%s\n", status.Installed, status.SettingsPath)
+ fmt.Println(status.Message)
+ case "vscode":
+ status := statuses["vscode"].(endpointhooks.VSCodeStatus)
+ fmt.Printf("VS Code hooks: installed=%t path=%s\n", status.Installed, status.HooksPath)
+ fmt.Println(status.Message)
+ case "factory":
+ status := statuses["factory"].(endpointhooks.FactoryStatus)
+ fmt.Printf("Factory hooks: installed=%t path=%s\n", status.Installed, status.SettingsPath)
+ fmt.Println(status.Message)
+ case "opencode":
+ status := statuses["opencode"].(endpointhooks.OpenCodeStatus)
+ fmt.Printf("opencode plugin: installed=%t path=%s\n", status.Installed, status.PluginPath)
+ fmt.Println(status.Message)
+ case "grok":
+ status := statuses["grok"].(endpointhooks.GrokStatus)
+ fmt.Printf("Grok hooks: installed=%t path=%s\n", status.Installed, status.HooksPath)
+ fmt.Println(status.Message)
+ case "hermes":
+ status := statuses["hermes"].(endpointhooks.HermesStatus)
+ fmt.Printf("Hermes Agent hooks: installed=%t path=%s\n", status.Installed, status.ConfigPath)
+ fmt.Println(status.Message)
+ case "devin-cli":
+ status := statuses["devin-cli"].(endpointhooks.DevinStatus)
+ fmt.Printf("Devin CLI hooks: installed=%t path=%s\n", status.Installed, status.ConfigPath)
+ fmt.Println(status.Message)
+ case "devin-desktop":
+ status := statuses["devin-desktop"].(endpointhooks.DevinStatus)
+ fmt.Printf("Devin Desktop hooks: installed=%t path=%s\n", status.Installed, status.ConfigPath)
+ fmt.Println(status.Message)
+ }
+ }
+ return nil
+}
diff --git a/cli/beacon/cmd/endpoint_install.go b/cli/beacon/cmd/endpoint_install.go
new file mode 100644
index 00000000..957fd874
--- /dev/null
+++ b/cli/beacon/cmd/endpoint_install.go
@@ -0,0 +1,274 @@
+package cmd
+
+import (
+ "encoding/json"
+ "fmt"
+ "os"
+
+ endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/dashboard"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/harness"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/lifecycle"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/schema"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/writer"
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/version"
+ "github.com/spf13/cobra"
+)
+
+var endpointInstallCmd = &cobra.Command{
+ Use: "install",
+ Short: "Install local endpoint telemetry configuration",
+ SilenceUsage: true,
+ RunE: runEndpointInstall,
+}
+
+var endpointStatusCmd = &cobra.Command{
+ Use: "status",
+ Short: "Show local endpoint status",
+ SilenceUsage: true,
+ RunE: runEndpointStatus,
+}
+
+var endpointDiscoverCmd = &cobra.Command{
+ Use: "discover",
+ Short: "Discover supported local AI agent runtimes",
+ SilenceUsage: true,
+ RunE: runEndpointDiscover,
+}
+
+var endpointUninstallCmd = &cobra.Command{
+ Use: "uninstall",
+ Short: "Remove local endpoint service files",
+ SilenceUsage: true,
+ RunE: runEndpointUninstall,
+}
+
+var endpointRepairCmd = &cobra.Command{
+ Use: "repair",
+ Short: "Repair local endpoint service and telemetry configuration",
+ SilenceUsage: true,
+ RunE: runEndpointRepair,
+}
+
+var endpointDashboardCmd = &cobra.Command{
+ Use: "dashboard",
+ Short: "Run the local Beacon endpoint dashboard",
+ SilenceUsage: true,
+ RunE: runEndpointDashboard,
+}
+
+func runEndpointDashboard(cmd *cobra.Command, args []string) error {
+ cfg := loadOrDefaultConfig()
+ userMode := endpointUserMode()
+ runtimeLog := lifecycle.ResolveRuntimeLog(userMode, endpointOpts.logPath)
+ cfg.UserMode = runtimeLog.EffectiveUserMode
+ cfg.LogPath = runtimeLog.EffectiveLogPath
+ if endpointOpts.dashboardAddr == "" {
+ endpointOpts.dashboardAddr = dashboard.DefaultAddr
+ }
+ if err := dashboard.ValidateLoopbackAddr(endpointOpts.dashboardAddr); err != nil {
+ return err
+ }
+ url := dashboard.URL(endpointOpts.dashboardAddr)
+ fmt.Printf("Beacon endpoint dashboard: %s\n", url)
+ fmt.Printf("Runtime log: %s\n", cfg.LogPath)
+ if runtimeLog.Warning != "" {
+ fmt.Printf("Runtime log source: %s\n", runtimeLog.Warning)
+ }
+ if endpointOpts.dashboardOpen {
+ if err := dashboard.OpenBrowser(url); err != nil {
+ return err
+ }
+ }
+ return dashboard.ListenAndServe(dashboard.Options{
+ Addr: endpointOpts.dashboardAddr,
+ LogPath: cfg.LogPath,
+ UserMode: cfg.UserMode,
+ })
+}
+
+func runEndpointInstall(cmd *cobra.Command, args []string) error {
+ otlpHarnesses, hookHarnesses, err := splitEndpointTargets(splitHarnessCSV(endpointOpts.harnesses))
+ if err != nil {
+ return err
+ }
+ if endpointOpts.dryRun {
+ return printPlannedActions(plannedInstallActions(false))
+ }
+ result, err := lifecycle.Install(lifecycle.InstallOptions{
+ UserMode: endpointUserMode(),
+ LogPath: endpointOpts.logPath,
+ Harnesses: otlpHarnesses,
+ GRPCPort: endpointOpts.grpcPort,
+ HTTPPort: endpointOpts.httpPort,
+ CollectorPath: endpointOpts.collectorPath,
+ StartService: !endpointOpts.noStart,
+ ContentRetention: endpointconfig.ContentRetention(endpointOpts.contentRetention),
+ IncludeRuntimeMetrics: endpointOpts.includeRuntimeMetrics,
+ IncludeCodexSpans: endpointOpts.includeCodexSpans,
+ SplunkHEC: splunkHECOptions(),
+ FalconHEC: falconHECOptions(),
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Endpoint config written to %s\n", result.ConfigPath)
+ fmt.Printf("Collector config written to %s\n", result.CollectorConfigPath)
+ fmt.Printf("Launch plist written to %s\n", result.PlistPath)
+ fmt.Printf("Install manifest written to %s\n", result.ManifestPath)
+ fmt.Printf("Runtime log: %s\n", result.LogPath)
+ if err := installHookTargetsFromEndpointInstall(hookHarnesses); err != nil {
+ return fmt.Errorf("endpoint install completed, but hook installation failed: %w", err)
+ }
+ return nil
+}
+
+func runEndpointStatus(cmd *cobra.Command, args []string) error {
+ status := lifecycle.GetStatus(endpointUserMode(), endpointOpts.logPath)
+ if endpointOpts.jsonOutput {
+ return json.NewEncoder(os.Stdout).Encode(status)
+ }
+ fmt.Printf("Beacon Endpoint Agent %s\n", status.Version)
+ fmt.Printf("Config: %s\n", status.ConfigPath)
+ fmt.Printf("Runtime log: %s\n", status.LogPath)
+ if status.RuntimeLog.Warning != "" {
+ fmt.Printf("Runtime log source: %s\n", status.RuntimeLog.Warning)
+ }
+ fmt.Printf("Collector: grpc=%t http=%t", status.Collector.GRPCReady, status.Collector.HTTPReady)
+ if status.Collector.Message != "" {
+ fmt.Printf(" (%s)", status.Collector.Message)
+ }
+ fmt.Println()
+ fmt.Printf("Service: loaded=%t running=%t", status.Service.Loaded, status.Service.Running)
+ if status.Service.Message != "" {
+ fmt.Printf(" (%s)", status.Service.Message)
+ }
+ fmt.Println()
+ for _, h := range status.Harnesses {
+ if h.Detected {
+ fmt.Printf("Harness: %s %s telemetry=%s\n", h.DisplayName, h.Version, h.TelemetryStatus)
+ }
+ }
+ for _, check := range status.Diagnostics {
+ if check.Status != "ok" {
+ fmt.Printf("Diagnostic: %s %s (%s)\n", check.Name, check.Status, check.Message)
+ }
+ }
+ if status.LastEvent == "" {
+ fmt.Println("Last event: none")
+ } else {
+ fmt.Println("Last event: present")
+ }
+ return nil
+}
+
+func runEndpointDiscover(cmd *cobra.Command, args []string) error {
+ discovered := harness.DiscoverAll()
+ if endpointOpts.jsonOutput {
+ if !endpointOpts.allTargets {
+ filtered := []harness.Harness{}
+ for _, h := range discovered {
+ if h.Detected {
+ filtered = append(filtered, h)
+ }
+ }
+ return json.NewEncoder(os.Stdout).Encode(filtered)
+ }
+ return json.NewEncoder(os.Stdout).Encode(discovered)
+ }
+ for _, h := range discovered {
+ if !endpointOpts.allTargets && !h.Detected {
+ continue
+ }
+ state := "not detected"
+ if h.Detected {
+ state = "detected"
+ }
+ fmt.Printf("%s: %s, telemetry=%s", h.DisplayName, state, h.TelemetryStatus)
+ if h.ExecutablePath != "" {
+ fmt.Printf(", path=%s", h.ExecutablePath)
+ }
+ fmt.Println()
+ }
+ cfg := loadOrDefaultConfig()
+ for _, h := range discovered {
+ if h.Detected {
+ event := schema.NewEvent(schema.NewEventOptions{
+ Action: "agent.detected",
+ Category: "inventory",
+ Severity: schema.SeverityInfo,
+ AgentVersion: version.GetVersion(),
+ Harness: schema.HarnessInfo{
+ Name: h.Name,
+ Version: h.Version,
+ ExecutablePath: h.ExecutablePath,
+ ConfigPath: h.ConfigPath,
+ },
+ Message: h.DisplayName + " detected",
+ })
+ if _, err := writer.AppendEvent(event, writer.Options{Path: cfg.LogPath, UserMode: cfg.UserMode}); err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+}
+
+func runEndpointUninstall(cmd *cobra.Command, args []string) error {
+ if endpointOpts.dryRun {
+ return printPlannedActions(plannedUninstallActions())
+ }
+ if err := lifecycle.Uninstall(lifecycle.UninstallOptions{UserMode: endpointUserMode(), LogPath: endpointOpts.logPath, KeepLogs: endpointOpts.keepLogs, KeepConfig: endpointOpts.keepConfig}); err != nil {
+ return err
+ }
+ fmt.Println("Endpoint service, config, and managed files removed.")
+ return nil
+}
+
+func runEndpointRepair(cmd *cobra.Command, args []string) error {
+ otlpHarnesses, hookHarnesses, err := splitEndpointTargets(splitHarnessCSV(endpointOpts.harnesses))
+ if err != nil {
+ return err
+ }
+ if endpointOpts.dryRun {
+ return printPlannedActions(plannedInstallActions(true))
+ }
+ result, err := lifecycle.Repair(lifecycle.InstallOptions{
+ UserMode: endpointUserMode(),
+ LogPath: endpointOpts.logPath,
+ Harnesses: otlpHarnesses,
+ GRPCPort: endpointOpts.grpcPort,
+ HTTPPort: endpointOpts.httpPort,
+ CollectorPath: endpointOpts.collectorPath,
+ StartService: !endpointOpts.noStart,
+ ContentRetention: endpointconfig.ContentRetention(endpointOpts.contentRetention),
+ IncludeRuntimeMetrics: endpointOpts.includeRuntimeMetrics,
+ IncludeCodexSpans: endpointOpts.includeCodexSpans,
+ SplunkHEC: splunkHECOptions(),
+ FalconHEC: falconHECOptions(),
+ })
+ if err != nil {
+ return err
+ }
+ fmt.Printf("Endpoint repaired. Manifest: %s\n", result.ManifestPath)
+ if err := installHookTargetsFromEndpointInstall(hookHarnesses); err != nil {
+ return fmt.Errorf("endpoint repair completed, but hook installation failed: %w", err)
+ }
+ return nil
+}
+
+func installHookTargetsFromEndpointInstall(targets []string) error {
+ if len(targets) == 0 {
+ return nil
+ }
+ cfg := loadOrDefaultConfig()
+ if endpointOpts.logPath != "" {
+ cfg.LogPath = endpointOpts.logPath
+ }
+ for _, target := range targets {
+ if err := installEndpointHookTarget(target, cfg); err != nil {
+ return err
+ }
+ }
+ return nil
+}