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
Add Sharing Sessions docs section
Claude8b593dc3c5dd
diff --git a/CLAUDE.md b/CLAUDE.mdindex bbae5ddf..83eef3a9 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -69,7 +69,7 @@ Supported runtime surfaces today:- Token usage and runtime-reported cost capture across spans, logs, and metric datapoints, normalized into `gen_ai.usage`, with attribution rollups served by the dashboard token view (`/api/tokens`) and the `beacon token-usage` report command for local and CI logs. Every report row carries three costs (`cli/beacon/internal/tokens/cost.go`): `cost_usd` (runtime-reported, unchanged), `estimated_cost_usd` (list price of every priced token, from `internal/pricing`, computed after dedup and cumulative resolution) and `effective_cost_usd` with `cost_source` (per endpoint/harness/session scope, reported cost wins wholesale when the scope has any; otherwise the estimate; session-less events per event), plus `unpriced_events`/`unpriced_tokens` and a report-level `pricing` block (catalog provenance, per-model key, match, base rates, bands applied, fallbacks, unpriced models). Long-context bands apply only to events `requestScoped` classifies as one model request; it defaults to aggregate, so a new capture path is priced at base rates until it is added there with a test. Lens data (`LensDataV1`) carries no estimate.- Local threat detection via `beacon scan`, which runs the open Threat Rules format (`spec/threat-rules`; CEL match conditions over the endpoint event schema, with embedded conformance fixtures) over the runtime JSONL. The engine (`pkg/asymptoteobserve/threatrules`) ships in the binary; the rule corpus is external data loaded from a local store (`~/.beacon/endpoint/rules`) managed by `beacon rules`, so the corpus can grow without enlarging the binary. `scan` is read-only and offline; only the explicit, user-initiated `beacon rules pull <url>` reaches the network. A small frozen baseline is embedded so `scan` works before any rules are installed.- Session handoff via `beacon handoff list|export|resume` (`cli/beacon/internal/handoff`, `cli/beacon/cmd/handoff*.go`; docs in `docs/cli/handoff.mdx` and `docs/concepts/session-handoff.mdx`). Every runtime is one entry in the registry in `cli/beacon/internal/handoff/runtimes.go`: its session source, the names it answers to, and the commands that reopen it or start it from a brief; `TestRegistryIsConsistent` checks the entries. Handoff reads the session stores of Claude Code, Codex CLI, OpenCode, Cline, Pi, Prime Agent, Factory Droid, GitHub Copilot CLI, Hermes Agent, DeepSeek Harness, fx, Grok Build, OpenClaw Gateway and Cursor read-only and never touches the network. Oh My Pi, Gemini CLI, Qwen Code, Kiro, Antigravity CLI, Devin CLI, Muse Code, OpenHands and goose have no store Beacon reads: their sessions come from the runtime log, and they take a brief as the target of `--agent`. `resume` reopens a session natively with its runtime's own command when it can, and otherwise writes a brief to `~/.beacon/endpoint/handoffs` (0700/0600) and starts a new session pointed at it. DeepSeek Harness cannot be started, and Hermes Agent and fx only reopen their own sessions, so their sessions continue in another runtime. fx, Grok Build and Cursor find a session by the directory they run in, so they are reopened natively only in the session's own directory. The brief is passed by absolute path, never inlined on a command line. Every launch keeps the runtime's approvals on: Beacon never passes a flag that turns them off, names the approval mode that asks where a CLI takes one (Cline always gets `--auto-approve false`, because Cline defaults to approving every tool call), and removes or overrides environment switches that would approve everything (`COPILOT_ALLOW_ALL`, `COPILOT_PLAN_THEN_AUTOPILOT`, `HERMES_YOLO_MODE`, `GOOSE_MODE`); `--print` shows them under `env`. Briefs run every event through `SanitizeEvent`, and quoted content goes in fences longer than any backtick run it contains, with inline fields reduced to one line, so quoted content cannot forge brief structure. A new session's first prompt ends with the `[beacon-handoff from=<harness> session=<id>]` marker (`pkg/asymptoteobserve/handoff.go`). The hook and plugin prompt paths and the session-store mappers record a `session.handoff` event with `handoff.{source_harness,source_session_id}` when they see it; that is an observed claim, not a verified identity.-- Session sharing via `beacon share` and `beacon share refresh` (`cli/beacon/cmd/share.go`; docs in `docs/cli/share.mdx`). It publishes one session the person names (or the most recent in a directory) to beacon.sh as a shared trace that is a `beacon.trace.v1` trace, the projection the dashboard uses: `BuildShareBundle` (sanitize, scrub, then `TraceEventFromEvent`/`TraceBuilder`), the wire types (`ShareTraceV1` summary body, `ShareEventsBatchV1` of `TraceEventV1`s, `ShareTraceStateV1` with `last_event_id`), `ShareExternalID` (`<harness>:<session-id>`, or a sha256 form), `ShareRelation` and `ShareEventsAfter` live in `pkg/asymptoteobserve/share.go`, and the client in `cli/beacon/internal/account/share.go` (`PUT /v1/traces/{external_id}`, `POST .../events/batch` capped at `ShareMaxEventsPerBatch`, `GET`). The chat view is derived on beacon.sh with `TraceMessages` (`pkg/asymptoteobserve/tracemessages.go`), which pairs a tool invocation and its completion by `tool_call_id` and writes a call reported twice once; messages are never uploaded. Sessions resolve through the handoff registry (store first, then the runtime log). Every event goes through `SanitizeEvent` and session-directory/home paths are rewritten in every projected field before projection, and the shared summary drops the working directory and repository path and names the project by `project.name`. `--print` shows the exact `{external_id, trace, events}` payload with no network, `public` needs confirmation (refused without a terminal unless `--yes`), a re-share upserts by stable event id, and a refresh sends only `ShareEventsAfter` the server's `last_event_id` (re-sending it and any tool call still open). After an upload it writes one `session.shared` event (`event.fidelity=inferred`, no collection method) carrying `shared_url`, `visibility`, `shared_at`/`last_refreshed_at` in raw, which the trace list reads as the sharing state; the projection skips that event. It never runs from hooks or in the background, except the opted-in pre-push sharing below. With no selector (or `--current`) it shares the session it runs inside: `BEACON_SESSION_ID`/`BEACON_HARNESS` (the Claude Code SessionStart hook appends both as `export` lines to `$CLAUDE_ENV_FILE`, plain identifiers only; a child runtime inherits them, so without `--harness` they are refused, naming both sessions, when the named session ran outside this directory and its parents or another runtime worked here more recently: `shareEnvContradiction`), then the active-session record (only when the entry was seen at least as recently as the directory's newest session, since OTLP-only and poll runtimes never write it), then the directory's most recent session. The record is `pkg/asymptoteobserve/activesession` (`~/.beacon/endpoint/active-sessions.json`, 0600 under 0700, atomic and locked, at most 256 entries, 14-day prune, an unchanged entry rewritten at most once a minute), written by the hook logger after every endpoint event with a session id, working directory and harness; it holds identifiers and paths only, never content, and hooks write it silently and never touch the network for it. Hook tests point `BEACON_ACTIVE_SESSIONS_FILE` at a temp file in `TestMain`. Auto-share (`beacon share auto enable|disable|status`, `cli/beacon/cmd/share_auto.go`, settings in `pkg/asymptoteobserve/shareauto`) is server-side publishing: when it applies to a session's working directory, the hook logger writes ONE local `session.share_requested` event per session (`event.fidelity=inferred`, `share.visibility`; deduplicated under the active-session record's lock) and Beacon Cloud forwarding ships it; beacon.sh builds and refreshes the trace with the same `BuildShareBundle` projection and `ShareExternalID`. Hooks never upload. The user file `~/.beacon/endpoint/share.json` (0600, CLI-written) holds the user-wide switch, three-state (unset, on, or off as a kill switch over every project; `auto.state`, with `auto.enabled` kept in step so older files read) and per-project choices by path, which a user-wide enable or disable never rewrites; a project marker `<repo>/.beacon/share.json` may disable on its own (and an off marker wins over the user's entry for the same directory; the closest directory with an entry or marker decides) but enables only when the user's file trusts that project, with the user's visibility, so a cloned repository can never publish someone's sessions. `ForHook` costs one failed read when nothing is enabled. Hook tests point `BEACON_SHARE_SETTINGS_FILE` at a temp file. The share projection and `handoff.LogSessions` recency skip `session.share_requested`.+- Session sharing via `beacon share` and `beacon share refresh` (`cli/beacon/cmd/share.go`; docs in `docs/cli/share.mdx`, with the workflow guides in `docs/sharing/` kept in sync). It publishes one session the person names (or the most recent in a directory) to beacon.sh as a shared trace that is a `beacon.trace.v1` trace, the projection the dashboard uses: `BuildShareBundle` (sanitize, scrub, then `TraceEventFromEvent`/`TraceBuilder`), the wire types (`ShareTraceV1` summary body, `ShareEventsBatchV1` of `TraceEventV1`s, `ShareTraceStateV1` with `last_event_id`), `ShareExternalID` (`<harness>:<session-id>`, or a sha256 form), `ShareRelation` and `ShareEventsAfter` live in `pkg/asymptoteobserve/share.go`, and the client in `cli/beacon/internal/account/share.go` (`PUT /v1/traces/{external_id}`, `POST .../events/batch` capped at `ShareMaxEventsPerBatch`, `GET`). The chat view is derived on beacon.sh with `TraceMessages` (`pkg/asymptoteobserve/tracemessages.go`), which pairs a tool invocation and its completion by `tool_call_id` and writes a call reported twice once; messages are never uploaded. Sessions resolve through the handoff registry (store first, then the runtime log). Every event goes through `SanitizeEvent` and session-directory/home paths are rewritten in every projected field before projection, and the shared summary drops the working directory and repository path and names the project by `project.name`. `--print` shows the exact `{external_id, trace, events}` payload with no network, `public` needs confirmation (refused without a terminal unless `--yes`), a re-share upserts by stable event id, and a refresh sends only `ShareEventsAfter` the server's `last_event_id` (re-sending it and any tool call still open). After an upload it writes one `session.shared` event (`event.fidelity=inferred`, no collection method) carrying `shared_url`, `visibility`, `shared_at`/`last_refreshed_at` in raw, which the trace list reads as the sharing state; the projection skips that event. It never runs from hooks or in the background, except the opted-in pre-push sharing below. With no selector (or `--current`) it shares the session it runs inside: `BEACON_SESSION_ID`/`BEACON_HARNESS` (the Claude Code SessionStart hook appends both as `export` lines to `$CLAUDE_ENV_FILE`, plain identifiers only; a child runtime inherits them, so without `--harness` they are refused, naming both sessions, when the named session ran outside this directory and its parents or another runtime worked here more recently: `shareEnvContradiction`), then the active-session record (only when the entry was seen at least as recently as the directory's newest session, since OTLP-only and poll runtimes never write it), then the directory's most recent session. The record is `pkg/asymptoteobserve/activesession` (`~/.beacon/endpoint/active-sessions.json`, 0600 under 0700, atomic and locked, at most 256 entries, 14-day prune, an unchanged entry rewritten at most once a minute), written by the hook logger after every endpoint event with a session id, working directory and harness; it holds identifiers and paths only, never content, and hooks write it silently and never touch the network for it. Hook tests point `BEACON_ACTIVE_SESSIONS_FILE` at a temp file in `TestMain`. Auto-share (`beacon share auto enable|disable|status`, `cli/beacon/cmd/share_auto.go`, settings in `pkg/asymptoteobserve/shareauto`) is server-side publishing: when it applies to a session's working directory, the hook logger writes ONE local `session.share_requested` event per session (`event.fidelity=inferred`, `share.visibility`; deduplicated under the active-session record's lock) and Beacon Cloud forwarding ships it; beacon.sh builds and refreshes the trace with the same `BuildShareBundle` projection and `ShareExternalID`. Hooks never upload. The user file `~/.beacon/endpoint/share.json` (0600, CLI-written) holds the user-wide switch, three-state (unset, on, or off as a kill switch over every project; `auto.state`, with `auto.enabled` kept in step so older files read) and per-project choices by path, which a user-wide enable or disable never rewrites; a project marker `<repo>/.beacon/share.json` may disable on its own (and an off marker wins over the user's entry for the same directory; the closest directory with an entry or marker decides) but enables only when the user's file trusts that project, with the user's visibility, so a cloned repository can never publish someone's sessions. `ForHook` costs one failed read when nothing is enabled. Hook tests point `BEACON_SHARE_SETTINGS_FILE` at a temp file. The share projection and `handoff.LogSessions` recency skip `session.share_requested`.- Commit-to-session links via `beacon git setup|status|remove|link|notes` (`cli/beacon/internal/gitlink`, `cli/beacon/cmd/git*.go`; docs in `docs/cli/git.mdx`). A link is a `beacon:<harness>/<session-id>` line in a git note under `refs/notes/beacon`; it carries identifiers only, never content, because notes can be pushed. Which sessions to link is inferred from the local runtime log: a session is linked when, between the parent commit and the commit (at least two hours, at most 24), it wrote a file the commit changes (for a merge, only files that differ from every parent, so a clean merge or pull links nothing). Evidence is file write events, write-type `file.operation`s, plainly readable shell targets, and `apply_patch` envelopes; reads never count. Note updates are a compare-and-swap on the notes ref through a private `refs/notes/beacon-tx/` working ref, and every existing note line, a teammate's or a person's, is kept verbatim. `setup` installs post-commit (links HEAD in the foreground with a 3 s budget, silent, never fails the commit, skips rebase/cherry-pick/revert) and post-rewrite (normalizes the note git concatenates on amend) as standalone `beacon-<hook>` scripts called from a marked block inserted after the shebang of the repository's own hook; only shell hooks are edited, `core.hooksPath` is refused without `--hooks-path`, and `notes.rewriteRef` carries links through amend and rebase. `BEACON_GIT_HOOKS=0` disables the hooks for one command. Every link a run adds is also written to the runtime log as one `session.commit_linked` event in the linked session's timeline (`event.fidelity=inferred`, no collection method), with commit id, branch and credential-stripped remote in the OTel-shaped `vcs` block and overlap counts in `vcs.attribution`; the event deliberately carries no file, command or tool fields so it can never become attribution evidence. Sharing is opt-in (`setup --share-notes`, off by default): a non-destructive fetch refspec `+refs/notes/beacon:refs/notes/beacon-remotes/<remote>` so git's own fetch brings teammates' links into a read-only tracking ref that `beacon git notes` unions with the local one (never force-fetch into `refs/notes/beacon`: it would destroy unpushed links), and a pre-push hook that fetches, merges with `cat_sort_uniq` through the same CAS, and pushes only the notes ref with `--no-verify`, within a 10 s budget and never failing the push. That pre-push hook is the only Beacon git hook that touches the network, and only during a push the person started; `beacon git notes push|fetch` do the same by hand. A note line may carry the session's share URL as its first trailing field (`beacon:<harness>/<id> <url>`; an identifier, not content): `gitlink.ValidShareURL` admits only https URLs on beacon.sh or the configured Beacon host (`AllowShareHost`, fed by `gitAllowShareHosts`), on write and on read, and `MergeNote`/`ParseNote` prefer the line with the URL over the bare one. Post-commit and `link` take URLs only from local `session.shared` events (`localShareURLs`). `setup --share-sessions [--share-visibility]` (implies `--share-notes`; stored as `beacon.shareSessions`/`beacon.shareVisibility` in local git config; public needs confirmation or `--yes`) makes the pre-push hook, which now receives git's stdin, share sessions linked to pushed commits that have no URL (at most 100 commits/10 sessions, silent without credentials, never failing the push; the budget is enforced by the clock: the share phase runs in a goroutine delivering URLs to a collector, the hook takes what it holds after the 6 s upload budget and abandons the rest, then writes notes and pushes the notes ref with what remains of the hook's 10 s, never less than 1 s and 3 s, so only the main path ever writes notes) through `shareUpload` (`cmd/share_upload.go`: `alignShareSource` + `ShareEventsAfter`), then write the URLs into the notes before pushing them. `beacon share --follow [--interval]` (`cmd/share_follow.go`) polls the session locally, uploads through `shareUpload` only when the fingerprint of the projected trace events changed (the events only: the trace body carries its build time), stops at `session.ended` or Ctrl+C (`shareFollowWait`/`shareFollowSignals` are the test seams), and records `session.shared` after each upload, later ones as refreshes that keep the share date; `docs/cli/share.mdx` carries the API-key CI walkthrough with GitHub Actions and GitLab CI examples. Local views show sharing read-only: the trace summary (`traceFold`, which wraps `asymptoteobserve.TraceBuilder` with the local-only `traceStaleness`, and the history through `traceAggregateState`, derivation version 12) and the dashboard's `SessionRecord.Sharing` mark a shared session `stale` when an event `asymptoteobserve.ShareProjects` accepts (the one definition of what a share publishes) and that is not the share's own (`shareActivity`) is newer than what its last `session.shared` record covered (`shared_through`), and carry `asymptoteobserve.ShareRefreshCommand` for the reader to copy; the session list/page, `beacon traces` TUI and plain list display them, and nothing in them shares.- Beacon Cloud MCP registration via `beacon mcp connect|disconnect|status` (`cli/beacon/internal/mcpconnect`, `cli/beacon/cmd/mcp_connect.go`; docs in `docs/cli/mcp-connect.mdx`). It registers the Beacon Cloud MCP server as `beacon-managed`, a different name from the local stdio server `beacon`, in the user-level config of Claude Code, Codex CLI, Cursor, VS Code, Gemini CLI and OpenCode. It prints manual steps for runtimes without confirmed MCP OAuth support. OAuth is the default and writes only the URL; `--token-env` writes a reference to an environment variable in each harness's own syntax, never a value. `connect` never reads or copies the account token and never writes a token; minting one is the separate, explicit `beacon mcp token create`. It is explicit and interactive: never run by an unattended install; the onboarding wizard runs it only after the person chose Beacon Cloud and left "Beacon Cloud MCP" selected (that screen is the confirmation), and otherwise the install only suggests it. It is refused as root, and refused in CI or without a terminal unless `--yes` is given. Its one network request is the RFC 9728 resource-metadata check of the URL, which `--dry-run` skips. Configs are edited like the Kimi Code writer: never re-serialized, spliced as text, parsed back and compared before an atomic replace, backed up first. What was written is recorded in `~/.beacon/mcp/connections.json`, and `disconnect` removes only entries recorded there that still point at the recorded URL. `cmd/mcp_connect_e2e_test.go` runs the real harness CLIs when they are installed; re-run it when a harness changes its MCP config format.- An optional, off-by-default policy seam in the hook path (`cli/beacon-hooks/internal/policy`) governed by the stable contract in `pkg/asymptoteobserve/policycontract`. When `BEACON_POLICY_PROVIDER` names an executable, the `pre-tool` and `permission-request` hooks send it a JSON request describing the imminent tool call and honor an allow/deny response, returning the runtime's native deny shape and `policy.enforcement=enforce` telemetry on a deny. The seam is inert when unset and fail-open on any error (timeout, non-zero exit, malformed output), so the open build ships no enforcement of its own; all audit/enforce decision logic lives in the external provider. `rules/agent-control/agent-permission-bypass-spawn.rule.yaml` is the open detect twin that flags the same pattern in `beacon scan`.diff --git a/docs/cli/share.mdx b/docs/cli/share.mdxindex d938fc22..b7823859 100644--- a/docs/cli/share.mdx+++ b/docs/cli/share.mdx@@ -7,6 +7,8 @@ description: "Share a local agent session as a trace on beacon.sh"`beacon share` publishes one local agent session as a shared trace on beacon.sh and prints its link. The trace shows the session's prompts, the agent's answers and reasoning, and every tool call with its result, in order.+For a walkthrough of every way to share (from the CLI, an agent skill, auto-share, git hooks or CI), see [Sharing sessions](/sharing/index).+```bash title="Command syntax"beacon share [--current | --session <id> | --source-path <path> | --cwd <dir>] [flags]beacon share --list [--cwd <dir>] [--harness <runtime>]diff --git a/docs/docs.json b/docs/docs.jsonindex edbe81c1..59179de3 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -97,6 +97,18 @@"manage/profile"]},+ {+ "group": "Sharing Sessions",+ "icon": "share-nodes",+ "pages": [+ "sharing/index",+ "sharing/cli",+ "sharing/agent-skills",+ "sharing/agent-hooks",+ "sharing/git-hooks",+ "sharing/api-key"+ ]+ },{"group": "How Beacon Works","icon": "book-open",diff --git a/docs/sharing/agent-hooks.mdx b/docs/sharing/agent-hooks.mdxnew file mode 100644index 00000000..39439b3f--- /dev/null+++ b/docs/sharing/agent-hooks.mdx@@ -0,0 +1,73 @@+---+title: "Sharing via Agent Hooks"+description: "Publish new agent sessions automatically with auto-share and Beacon Cloud"+---++Auto-share publishes your agent sessions as shared traces without running `beacon share` each time. Beacon's agent hooks mark each new session for sharing, [Beacon Cloud forwarding](/cli/endpoint-connect) carries that mark with the rest of the session's events, and beacon.sh builds the trace and keeps it current as the session continues.++The hooks themselves never upload anything or touch the network. They write one local event per session; forwarding, which you already turned on, does the rest.++## Requirements++- Beacon installed with hooks for your runtimes: [`beacon endpoint install`](/cli/endpoint-install).+- The endpoint connected to Beacon Cloud: [`beacon endpoint connect`](/cli/endpoint-connect). Without it, the request is written and stays local, so nothing is published.+- Standard privacy mode, if the traces should show content. In Metadata-only mode, forwarding removes prompts, answers, reasoning and tool output before upload, so the trace shows what happened but not what was said.++## Turn on auto-share++```bash+beacon share auto enable # every new session, direct (link only)+beacon share auto enable --project . # only sessions in this repository+beacon share auto enable --visibility private+```++`enable` warns when the endpoint is not connected to Beacon Cloud or forwards in Metadata-only mode. `--visibility public` lists every new session in Discover, so it asks first, and without a terminal it is refused unless you add `--yes`.++## How it works++1. **A session starts.** On the first event Beacon's hooks see for a session (its `SessionStart` where the runtime has one), they write one `session.share_requested` event to the local runtime log, with the session id, runtime and visibility. Each session is requested once.+2. **Forwarding ships it.** Beacon Cloud forwarding sends that event along with the session's prompts, tool calls and other events, through the same local privacy transform as everything else.+3. **beacon.sh publishes the trace.** It builds the shared trace from the session's forwarded events, with the same projection and redaction `beacon share` uses, and updates it as more events arrive while the agent works.++A trace published this way has the same id as one shared with `beacon share`, so a session shared both ways is one trace.++Sessions that were already running when you turned auto-share on are requested on their next event. Earlier sessions are not; share those with [`beacon share`](/sharing/cli).++## Supported runtimes++Auto-share covers every runtime Beacon captures through its hooks or a Beacon-managed plugin, including Claude Code, Codex CLI, Cursor, Cline, OpenCode, Pi, Oh My Pi, Prime Agent, Senpi, OpenClaw, Kimi Code, Kiro, Factory Droid, Devin, Grok Build, Hermes Agent, Qwen Code, Antigravity CLI, OpenHands, Muse Code, VS Code and DeepSeek Harness. See [Agent Harness Integrations](/runtimes/index) for how each one is captured.++Runtimes Beacon sees only through OpenTelemetry or by reading their session store, such as Gemini CLI, GitHub Copilot CLI, Claude Cowork and fx, have no hook to write the request. Share their sessions with [`beacon share`](/sharing/cli).++## Per-project settings++`--project <dir>` applies the choice to one project. It is recorded for you by path in `~/.beacon/endpoint/share.json`, and in `<dir>/.beacon/share.json` so it can be committed to the repository.++- A repository's file can turn auto-share **off** for everyone who works in it, and an off file wins over your own setting for that directory.+- A repository's file can turn auto-share **on** only for someone who also ran `beacon share auto enable --project` there, and the visibility always comes from that person's own setting. A cloned repository can never publish your sessions.+- The nearest directory with a setting decides.++```bash+beacon share auto status # what applies here, and why+beacon share auto status --project ~/src/app+```++## Turn it off++```bash+beacon share auto disable # every project+beacon share auto disable --project . # only this one+```++`disable` without `--project` is a switch over every project: it keeps the projects you enabled, so a later `enable` restores exactly what was on before. Turning auto-share off stops new requests. Traces already published stay until you unshare them on beacon.sh.++## Related++<Columns cols={2}>+ <Card title="Auto-share reference" icon="book" href="/cli/share#auto-share">+ The full settings model and `status` output.+ </Card>+ <Card title="Sharing via Git Hooks" icon="code-branch" href="/sharing/git-hooks">+ Share only the sessions behind the commits you push.+ </Card>+</Columns>diff --git a/docs/sharing/agent-skills.mdx b/docs/sharing/agent-skills.mdxnew file mode 100644index 00000000..743bdc62--- /dev/null+++ b/docs/sharing/agent-skills.mdx@@ -0,0 +1,90 @@+---+title: "Sharing via Agent Skills"+description: "Ask your coding agent to share the session it is in"+---++The `beacon-trace-share` skill is one of the [Beacon Skills](/concepts/beacon-skills). Install it once, and you can ask the agent you are working with to "share this session". The agent runs [`beacon share --current`](/cli/share#sharing-this-session) from its own shell, then replies with the link.++## Install the skill++The interactive [`beacon endpoint install`](/cli/endpoint-onboarding#agent-tools) installs the Beacon Skills for every project unless you turn them off in the wizard. To install them at any other time:++```bash+beacon skills install+```++This writes the skills to `~/.agents/skills`, which Codex CLI, Gemini CLI, OpenCode, Pi and other runtimes read, and to `~/.claude/skills` when Claude Code is set up. They are carried in the `beacon` binary, so installing needs no network.++The skills also install as a plugin from the `asymptote-labs/agent-beacon` repository, for example in Claude Code:++```text+/plugin marketplace add asymptote-labs/agent-beacon+/plugin install beacon@beacon+```++[Beacon Skills](/concepts/beacon-skills#install) lists the install command for every other runtime.++## Sign in++The agent shares with your credential, so sign in once in your own terminal:++```bash+beacon login+```++The agent never runs `beacon login` itself, because it opens a browser. In CI or another headless environment, set a Beacon API key in `BEACON_API_KEY` instead (see [Sharing via API Key](/sharing/api-key)). Never paste a key into the conversation.++## Share from chat++Ask in your own words:++```text+Share this session.+```++```text+Share this session privately.+```++```text+Update the shared trace with what we just did.+```++The skill tells the agent to:++1. Check that `beacon` is on `PATH`, and stop if it is not.+2. Run `beacon share --current --harness <its runtime> --json` from the session's working directory. Naming its runtime keeps Beacon from picking another runtime's session in the same directory.+3. Reply with the link, its visibility and how many events the trace holds. When Beacon picked the most recent session in the directory rather than one it knew was this one, the agent says which session it shared.++New traces are `direct` (anyone with the link). The agent uses `private` when you ask for it, and asks you to confirm before it makes a session `public`. Asked to update a trace, it runs `beacon share refresh`, which uploads only the steps added since the last upload.++To see what would be uploaded first, ask the agent to run the share with `--print`.++## How the agent finds its own session++An agent does not know its session id. `beacon share --current` finds it from, in order:++1. `BEACON_SESSION_ID` and `BEACON_HARNESS`, which Beacon's Claude Code `SessionStart` hook exports into every shell command the session runs.+2. The session Beacon's hooks last saw for that runtime in this directory.+3. The most recent session in this directory.++See [Sharing this session](/cli/share#sharing-this-session) for how conflicts are resolved.++## Remove the skill++```bash+beacon skills uninstall+```++This removes only the copies Beacon installed. If you installed the plugin from a marketplace, uninstall it there.++## Related++<Columns cols={2}>+ <Card title="Beacon Skills" icon="book" href="/concepts/beacon-skills">+ Every Beacon skill and how to install it in each runtime.+ </Card>+ <Card title="Sharing via Agent Hooks" icon="bolt" href="/sharing/agent-hooks">+ Share every new session automatically instead.+ </Card>+</Columns>diff --git a/docs/sharing/api-key.mdx b/docs/sharing/api-key.mdxnew file mode 100644index 00000000..64d45639--- /dev/null+++ b/docs/sharing/api-key.mdx@@ -0,0 +1,159 @@+---+title: "Sharing via API Key"+description: "Share agent sessions from CI, containers and headless machines with a Beacon API key"+---++Where nobody can run `beacon login` (CI runners, containers, scheduled jobs, a server you reach over SSH), `beacon share` authenticates with a Beacon API key instead. The key works the same way everywhere `beacon share` runs, including the [`beacon-trace-share` skill](/sharing/agent-skills) and the [pre-push hook](/sharing/git-hooks).++## Create an API key++1. Sign in to beacon.sh and open **API Keys** in the dashboard ([beacon.sh/dashboard/api-keys](https://beacon.sh/dashboard/api-keys)).+2. Create a key with the **Publish shared traces** (`traces:write`) permission, which is all `beacon share` needs, including `refresh` and `--follow`. Choose an expiry.+3. Copy the key. It starts with `bcn_api_` and is shown only once.++Store it as a secret in your CI system, for example a GitHub Actions secret or a masked GitLab CI/CD variable named `BEACON_API_KEY`. Never commit it.++## Use the key++```bash+export BEACON_API_KEY=bcn_api_...+beacon share --cwd . --json+```++No `beacon login` is needed. Prefer the environment variable to `--key`, which puts the key on the command line where process listings can see it.++`beacon share` uses the first credential available: `--key`, then a `beacon login` sign-in carrying `traces:write`, then `BEACON_API_KEY`. On a machine that is also signed in, pass `--key` to use the key. The key is sent only in the request's `Authorization` header to beacon.sh, redirects are refused, and it is never printed. For a self-hosted Beacon service, set `BEACON_AUTH_URL` (or `--auth-url`) to that service.++## Run the share in the agent's job++`beacon share` reads the session from the machine it runs on, so run it in the same job as the agent, after it. Claude Code and Codex CLI keep sessions in stores `beacon share` reads directly, so nothing else needs to be installed. For a runtime whose sessions Beacon reads only from its runtime log, start [Beacon CI telemetry](/cli/ci-start) before the agent and pass the CI log with `--log-path`.++## GitHub Actions++This workflow runs an agent on a pull request, shares its session, adds the link to the job summary, and comments it on the pull request:++```yaml title=".github/workflows/agent.yml"+name: Agent+on:+ pull_request:+ workflow_dispatch:++jobs:+ agent:+ runs-on: ubuntu-latest+ permissions:+ contents: read+ pull-requests: write+ steps:+ - uses: actions/checkout@v4++ - name: Install Beacon+ run: curl -fsSL https://github.com/asymptote-labs/agent-beacon/releases/latest/download/install.sh | bash++ - name: Run the agent+ env:+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}+ run: npx -y @anthropic-ai/claude-code --print "Fix the failing test and explain the change"++ - name: Share the agent session+ id: share+ if: always()+ env:+ BEACON_API_KEY: ${{ secrets.BEACON_API_KEY }}+ run: |+ out="$(beacon share --cwd . --harness auto --json)" || { echo "$out"; exit 0; }+ url="$(printf '%s' "$out" | jq -r '.data.shared_url')"+ echo "url=$url" >> "$GITHUB_OUTPUT"+ echo "### Agent session" >> "$GITHUB_STEP_SUMMARY"+ echo "$url" >> "$GITHUB_STEP_SUMMARY"++ - name: Link the session on the pull request+ if: github.event_name == 'pull_request' && steps.share.outputs.url != ''+ uses: actions/github-script@v7+ env:+ SHARE_URL: ${{ steps.share.outputs.url }}+ with:+ script: |+ await github.rest.issues.createComment({+ owner: context.repo.owner,+ repo: context.repo.repo,+ issue_number: context.issue.number,+ body: `Agent session: ${process.env.SHARE_URL}`,+ });+```++The link reaches the script through an environment variable rather than being written into it, so nothing in the share output can change what the script runs. A failed share leaves the job green (`exit 0`); remove that to make a missing trace fail the build.++## GitLab CI++```yaml title=".gitlab-ci.yml"+agent:+ image: node:22+ variables:+ # BEACON_API_KEY and ANTHROPIC_API_KEY are masked CI/CD variables.+ GIT_DEPTH: "0"+ before_script:+ - apt-get update -qq && apt-get install -y -qq jq sudo+ - curl -fsSL https://github.com/asymptote-labs/agent-beacon/releases/latest/download/install.sh | bash+ script:+ - npx -y @anthropic-ai/claude-code --print "Fix the failing test and explain the change"+ after_script:+ - beacon share --cwd "$CI_PROJECT_DIR" --harness auto --json | tee beacon-share.json || true+ - echo "Agent session: $(jq -r '.data.shared_url // empty' beacon-share.json)"+ artifacts:+ when: always+ paths:+ - beacon-share.json+```++`after_script` runs in the same job even when the agent fails, so the session is still on disk.++## Docker++Install Beacon in the image and pass the keys in at run time:++```dockerfile title="Dockerfile"+FROM node:22-slim+RUN apt-get update -qq && apt-get install -y -qq curl ca-certificates \+ && curl -fsSL https://github.com/asymptote-labs/agent-beacon/releases/latest/download/install.sh | bash+WORKDIR /app+COPY . .+CMD ["sh", "-c", "npx -y @anthropic-ai/claude-code --print \"$PROMPT\"; beacon share --cwd /app --harness auto --json"]+```++```bash+docker run \+ -e ANTHROPIC_API_KEY \+ -e BEACON_API_KEY \+ -e PROMPT="Review this codebase for bugs" \+ my-agent-image+```++`-e NAME` without a value passes the variable from your shell, so the key is not written on the command line.++## Headless machines and SSH++```bash+export BEACON_API_KEY=bcn_api_...+beacon share --cwd ~/src/app --json+```++## Tips++- Use `--json` in CI and read `data.shared_url` from the result.+- Use `--harness auto` when the job could run more than one runtime, or name the one it runs.+- Keep the default `direct` visibility, or use `--visibility private`, for sessions that touched proprietary code. Without a terminal, `public` needs `--yes`.+- Run `beacon share --print` once in the pipeline to read exactly what it uploads.+- Share after the agent finishes rather than with `--follow`: `--follow` needs the session to exist when it starts, and most CI runners stop background processes when their step ends.+- Revoke a key from **API Keys** on beacon.sh as soon as it is no longer needed.++## Related++<Columns cols={2}>+ <Card title="beacon share reference" icon="book" href="/cli/share#credentials">+ Credential order and every flag.+ </Card>+ <Card title="Beacon CI telemetry" icon="gears" href="/cli/ci">+ Capture agent runs in CI for runtimes without a session store.+ </Card>+</Columns>diff --git a/docs/sharing/cli.mdx b/docs/sharing/cli.mdxnew file mode 100644index 00000000..0522d7aa--- /dev/null+++ b/docs/sharing/cli.mdx@@ -0,0 +1,113 @@+---+title: "Sharing via CLI"+description: "Share a local agent session from your terminal with beacon share"+---++`beacon share` publishes one local agent session as a shared trace on beacon.sh and prints its link. It reads the session from your own machine, so it works for any runtime Beacon captures, whether or not the endpoint is connected to Beacon Cloud.++## Sign in++```bash+beacon login+```++`beacon login` opens a browser to sign in to beacon.sh. The sign-in carries the `traces:write` permission `beacon share` needs. On a machine without a browser, use an [API key](/sharing/api-key) instead.++## Share a session++Run `beacon share` in the directory where the agent worked:++```bash+beacon share+```++With no other flag it shares the session it runs inside, and otherwise the most recent session that ran in the current directory. It names the session it picked before uploading, prints the link on stdout and a summary on stderr.++```text title="Example output"+https://beacon.sh/s/k3x7q9m2a8c4d1e5f6g7h8j9+```++To pick a different session:++```bash+beacon share --list # sessions here, newest first+beacon share --session 5f0c1d2e # a session id, or a prefix of at least 6 characters+beacon share --cwd ~/src/app # the most recent session in another directory+beacon share --harness codex # only one runtime's sessions+```++`--harness` matters when more than one runtime worked in the same directory. See [Choosing the session](/cli/share#choosing-the-session) for every selector.++## Check before you share++`--print` shows exactly the payload that would be uploaded, as JSON, and sends nothing:++```bash+beacon share --print+```++Read it before sharing a session that touched credentials or private data. Redaction catches common secret shapes, not everything sensitive.++## Set visibility and title++```bash+beacon share --visibility private+beacon share --visibility public # asks for confirmation first+beacon share --title "Fix the login test"+```++| `--visibility` | Who can view the trace |+|----------------|------------------------|+| `direct` | Anyone with the link, never listed. The default for a new trace |+| `private` | Only you |+| `public` | Anyone, and listed in Discover |++Without a terminal, `--visibility public` is refused unless you add `--yes`. A re-share keeps the trace's visibility unless you pass `--visibility` again.++## Keep a trace up to date++Sharing a session again updates the same trace; nothing is duplicated. Two commands keep it current:++```bash+beacon share refresh # upload only the events added since the last upload+beacon share --follow # keep uploading while the session runs, until it ends or Ctrl+C+beacon share --follow --interval 30s+```++`--follow` checks the session locally every interval (default `10s`) and makes a request only when something changed. It stops when the session records its end.++## Script it++`--json` prints one document, for scripts and agents:++```bash+beacon share --json+```++```json+{"ok":true,"data":{"trace_id":"k3x...","external_id":"claude_code:5f0c1d2e-...","shared_url":"https://beacon.sh/s/k3x...","visibility":"direct","harness":"claude_code","event_count":42,"uploaded":42,"selected_by":"recent"}}+```++On failure it prints `{"ok":false,"error":"..."}` and exits non-zero.++## See what you shared++After an upload, `beacon share` records a `session.shared` event in the local runtime log with the link and visibility, so the local dashboard and `beacon endpoint traces list --state shared` mark the session as shared. A shared session with newer local activity shows as stale, with the `beacon share refresh` command to bring it up to date.++```bash+beacon endpoint traces list --state shared+beacon endpoint traces list --state stale+```++Change visibility, copy links or unshare from the **Shared** page of the Beacon Cloud dashboard.++## Related++<Columns cols={2}>+ <Card title="beacon share reference" icon="book" href="/cli/share">+ Every flag, how `--current` finds a session, and the upload format.+ </Card>+ <Card title="Sharing via Agent Skills" icon="wand-magic-sparkles" href="/sharing/agent-skills">+ Let your agent run `beacon share` for you.+ </Card>+</Columns>diff --git a/docs/sharing/git-hooks.mdx b/docs/sharing/git-hooks.mdxnew file mode 100644index 00000000..e5d6c03b--- /dev/null+++ b/docs/sharing/git-hooks.mdx@@ -0,0 +1,102 @@+---+title: "Sharing via Git Hooks"+description: "Link commits to the agent sessions that wrote them, and share those sessions on push"+---++Beacon's git hooks record which agent sessions produced each commit, as a git note on the commit. Share the notes with your remote and teammates can trace a line of code back to the session that wrote it. Turn on session sharing as well and the pre-push hook publishes those sessions to beacon.sh and writes their links into the notes, so every pushed commit points at its trace.++## Link commits to sessions++```bash+cd my-repo+beacon git setup+```++This installs a `post-commit` hook that links every new commit as it is made, a `post-rewrite` hook that tidies links after an amend or rebase, and sets `notes.rewriteRef` so links follow a commit when it is rewritten. Existing shell hooks keep working: Beacon adds a short marked block that calls its own scripts.++The post-commit hook reads the local runtime log and links each session that wrote a file the commit changes, between the parent commit and the commit. It never prints, never touches the network, gives up after three seconds, and never fails a commit. Reads do not count, and a clean merge or `git pull` links nothing.++A link names a session by runtime and id, never its content:++```text+beacon:claude_code/5f0c1d2e-aaaa-4bbb-8ccc-000000000001+```++```bash+beacon git notes # recent linked commits+git log --notes=beacon # links inline in git log+beacon git link 3f6aa6c # link a commit made before setup+```++See [How sessions are matched to a commit](/cli/git#how-sessions-are-matched-to-a-commit) for the exact rules.++## Share links with your team++Links stay local until you share them:++```bash+beacon git setup --share-notes+```++- A fetch refspec brings teammates' links into a read-only copy on every `git fetch` or `git pull`, and `beacon git notes` shows them alongside yours. Your own unpushed links are never overwritten.+- A `pre-push` hook merges the remote's links with yours and pushes only `refs/notes/beacon` to the remote you are pushing to. It gives up after ten seconds and never fails your push.++To push or fetch links by hand instead:++```bash+beacon git notes push+beacon git notes fetch upstream+```++## Share sessions on push++```bash+beacon git setup --share-sessions # new traces are direct (link only)+beacon git setup --share-sessions --share-visibility private+```++With `--share-sessions` (which implies `--share-notes`), every `git push` also:++1. Reads the commits being pushed (at most 100) and the sessions linked to them.+2. Shares each linked session that has no link to a trace yet (at most 10 per push), with the same upload and redaction as [`beacon share`](/sharing/cli). A session already shared from this machine only gets its link written. A teammate's session, which this machine does not have, is skipped.+3. Writes each trace's link into the commit's note, then pushes the notes.++```text title="Note with a share link"+beacon:claude_code/5f0c1d2e-aaaa-4bbb-8ccc-000000000001 https://beacon.sh/s/k3x7q9m2a8c4d1e5f6g7h8j9+```++The hook uses your `beacon login` sign-in or `BEACON_API_KEY`; without either it shares nothing and prints nothing. Uploads get six of the hook's ten seconds, and whatever finished in time is written to the notes. It never fails the push; a failure prints one line. `--share-visibility public` lists every linked session in Discover, so `setup` asks first, and without a terminal needs `--yes`.++The choice is stored in the repository's own git config (`beacon.shareSessions`, `beacon.shareVisibility`), so it applies to this clone only. Only `https` links on beacon.sh, or on the Beacon service the CLI is configured for, are written to or shown from notes, because a note can come from anyone who pushes to the remote.++## Hook managers++Tools such as husky and lefthook point `core.hooksPath` at a directory they own. `beacon git setup` will not write there by default; it prints the line to add to that tool's hook instead:++```bash+beacon git hook post-commit || true+```++Pass `--hooks-path` to install into that directory anyway. Called through a hook manager's `pre-push` line, Beacon cannot see which refs are being pushed, so it shares links but not sessions.++## Turn it off++```bash+BEACON_GIT_HOOKS=0 git push # skip Beacon's hooks for one command+beacon git setup --share-sessions=false # stop sharing sessions, keep sharing links+beacon git setup --share-notes=false # stop sharing links and sessions+beacon git remove # remove Beacon's hooks and settings+```++`remove` leaves the links already written in `refs/notes/beacon`.++## Related++<Columns cols={2}>+ <Card title="beacon git reference" icon="book" href="/cli/git">+ Every flag, the note format and the `session.commit_linked` event.+ </Card>+ <Card title="Sharing via API Key" icon="key" href="/sharing/api-key">+ Share from CI and other machines without a browser.+ </Card>+</Columns>diff --git a/docs/sharing/index.mdx b/docs/sharing/index.mdxnew file mode 100644index 00000000..40c93eef--- /dev/null+++ b/docs/sharing/index.mdx@@ -0,0 +1,89 @@+---+title: "Sharing sessions"+description: "Publish agent sessions as shared traces on beacon.sh, by hand or automatically"+---++A shared trace is one agent session published on beacon.sh with a link you can send to anyone you choose. It shows the session's prompts, the agent's answers and reasoning, and every tool call, command, file edit and MCP call with its result, in order. Secrets are redacted and local paths are made relative before anything leaves your machine.++Sharing is always something you turn on. Beacon's hooks and background jobs never upload a session unless you set up one of the automatic workflows below.++## Choose a sharing workflow++<Columns cols={2}>+ <Card title="Sharing via CLI" icon="terminal" href="/sharing/cli">+ Share a session from your terminal with `beacon share`, pick its visibility, and keep it current.+ </Card>+ <Card title="Sharing via Agent Skills" icon="wand-magic-sparkles" href="/sharing/agent-skills">+ Install the `beacon-trace-share` skill, then ask your agent to share the session it is in.+ </Card>+ <Card title="Sharing via Agent Hooks" icon="bolt" href="/sharing/agent-hooks">+ Turn on auto-share and every new session is published through Beacon Cloud as the agent works.+ </Card>+ <Card title="Sharing via Git Hooks" icon="code-branch" href="/sharing/git-hooks">+ Link commits to the sessions that wrote them, and share those sessions when you push.+ </Card>+ <Card title="Sharing via API Key" icon="key" href="/sharing/api-key">+ Share from CI, containers and other machines where nobody can run `beacon login`.+ </Card>+ <Card title="Sharing from Beacon Cloud" icon="cloud" href="#sharing-from-beacon-cloud">+ Share a forwarded session from its page in the Beacon Cloud dashboard.+ </Card>+</Columns>++| Workflow | Who starts the upload | Needs |+|----------|----------------------|-------|+| [CLI](/sharing/cli) | You, with `beacon share` | `beacon login` or an API key |+| [Agent Skills](/sharing/agent-skills) | Your agent, when you ask it to | `beacon login` or an API key, and the skill installed |+| [Agent Hooks](/sharing/agent-hooks) | beacon.sh, from the events forwarding already sends | An endpoint [connected to Beacon Cloud](/cli/endpoint-connect) |+| [Git Hooks](/sharing/git-hooks) | The pre-push hook, during a push you started | `beacon git setup --share-sessions`, and `beacon login` or an API key |+| [API Key](/sharing/api-key) | Your CI job, with `beacon share` | A `bcn_api_` key with the `traces:write` permission |++## Visibility levels++Every shared trace has one of three visibility levels:++| Visibility | Who can view the trace |+|------------|------------------------|+| `direct` | Anyone with the link. It is never listed or indexed. The default for a new trace |+| `private` | Only you, while signed in to beacon.sh |+| `public` | Anyone. The trace is listed in Discover |++Making a trace public always asks for confirmation first, and without a terminal to ask on it is refused unless you pass `--yes`. Sharing a session again updates the same trace and keeps its visibility unless you name a new one. You can change a trace's visibility, copy its link or unshare it from the **Shared** page of the Beacon Cloud dashboard, or from the trace page itself.++## What a shared trace contains++Every workflow publishes the same thing: a `beacon.trace.v1` trace built from the session's Beacon events, the same projection the local [dashboard](/cli/dashboard) and [lenses](/concepts/lenses) read. Before anything is uploaded:++- Every event goes through Beacon's secret redaction and size limits.+- Paths under the session's directory are written relative to it, and your home directory becomes `~`.+- The working directory and repository path are left out. The project is named by the repository's or directory's name, and the remote is sent without credentials.+- Cost is sent only when the runtime reported one, never a list-price estimate.++beacon.sh redacts every string again on its side. Redaction catches common credential shapes, not everything sensitive, so run `beacon share --print` to read exactly what would be uploaded before sharing a session that touched secrets. [`beacon share`](/cli/share#what-is-uploaded) has the full details.++Each session has one stable id on beacon.sh (`<runtime>:<session-id>`), so a session shared more than one way, for example by hand and then by the pre-push hook, is still one trace.++## Sharing from Beacon Cloud++When an endpoint is [connected to Beacon Cloud](/cli/endpoint-connect), its sessions appear in [Agent Activity](/cloud/sessions). Open a session and select **Share** to publish a snapshot of it from the events your device forwarded, with a visibility and an optional title. **Update snapshot** refreshes it later. What the trace can show depends on the device's [privacy mode](/deployment/managed#what-leaves-your-machine): a Metadata-only device forwards no prompts, answers or tool output, so neither does its trace.++## Credentials++Sharing from the CLI, a skill or the pre-push hook uses the first of these that is available:++1. A Beacon API key passed with `--key` (`bcn_api_...`).+2. Your [`beacon login`](/cli/account-auth) sign-in, when it carries the `traces:write` permission. A sign-in from an older `beacon login` lacks it; run `beacon login` again.+3. A Beacon API key in the `BEACON_API_KEY` environment variable.++The credential is sent only in the request's `Authorization` header, redirects are refused, and it is never printed or written into config. See [Sharing via API Key](/sharing/api-key) for creating a key.++## Related++<Columns cols={2}>+ <Card title="beacon share" icon="terminal" href="/cli/share">+ Every flag, the upload format and the output.+ </Card>+ <Card title="beacon git" icon="code-branch" href="/cli/git">+ Commit-to-session links and sharing them with a team.+ </Card>+</Columns>