The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
package cmd
import (
"os"
"path/filepath"
"testing"
"github.com/asymptote-labs/agent-beacon/cli/beacon-hooks/internal/logging"
"github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve/activesession"
"github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve/localingest"
)
// TestMain keeps the active-session record every endpoint event updates out of the real home
// directory; tests that check it point BEACON_ACTIVE_SESSIONS_FILE somewhere of their own.
func TestMain(m *testing.M) {
dir, err := os.MkdirTemp("", "beacon-hooks-active-")
if err != nil {
panic(err)
}
os.Setenv(activesession.PathEnv, filepath.Join(dir, activesession.FileName))
// Auto-share is off unless a test turns it on in a settings file of its own.
settingsPath := filepath.Join(dir, "share-settings.json")
logging.ShareSettingsPath = func() string { return settingsPath }
// Never send to a real collector's ingest socket, which a developer's restricted-mode machine
// has.
logging.EndpointIngest = localingest.Deliverer{
Client: localingest.Client{SocketPath: filepath.Join(dir, "no-ingest.sock")},
Spool: localingest.Spool{Dir: filepath.Join(dir, "spool")},
}
// Beacon's Cursor hooks are not installed unless a test writes a hooks file of its own; the
// developer's real ~/.cursor/hooks.json must not decide what a test records.
cursorHooksPath := filepath.Join(dir, "cursor-hooks.json")
cursorUserHooksPath = func() string { return cursorHooksPath }
// A suite run from inside a Claude Code session must not append to that session's env file.
os.Unsetenv("CLAUDE_ENV_FILE")
code := m.Run()
os.RemoveAll(dir)
os.Exit(code)
}