Skip to content

Commit 7e8afba

Browse files
authored
feat(plugins): mirror local coding sessions to a remote Beam receiver (#114735)
* feat(plugins): mirror local coding sessions to a remote Beam receiver * fix(plugins): satisfy static gates for the Beam mirror seam * fix(plugins): import the config type from the narrow contracts subpath * fix(plugins): require catalog consent and loopback-only plaintext for the Beam mirror
1 parent a04ba3a commit 7e8afba

15 files changed

Lines changed: 950 additions & 3 deletions

‎config/knip.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ const config = {
371371
"extensions/onepassword/onepassword-op-path.js": ["exports"],
372372
// Focused CLI tests exercise plan construction through this explicit test seam.
373373
"extensions/onepassword/src/secret-ref-cli.ts": ["exports"],
374+
// Mirror config parsing, redaction mapping, cap fitting, and the runner are
375+
// asserted by the focused Beam mirror tests; production wires only the service.
376+
"extensions/beam/src/mirror.ts": ["exports", "types"],
374377
"src/infra/heartbeat-wake.ts": ["exports"],
375378
},
376379
workspaces: {

‎docs/docs_map.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5719,6 +5719,7 @@ Do not edit it by hand; run `pnpm docs:map:gen`.
57195719
- H2: Request
57205720
- H2: Storage and visibility
57215721
- H2: Security boundary
5722+
- H2: Mirroring
57225723
- H2: Troubleshooting
57235724
- H2: Related
57245725

‎docs/plugins/beam.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,37 @@ Beam is passive session publication, not remote control.
117117
- The receiver still treats every transcript as untrusted text. Copying a beamed transcript into a new agent session is a separate operator action.
118118
- Requests are rate-limited and concurrency-limited before the body is read.
119119

120+
## Mirroring
121+
122+
Beam can also act as the sender: an opt-in mirror that continuously publishes this machine's active local coding sessions (Claude Code, Codex, and other registered session catalogs) to a remote Beam receiver, such as a shared team Gateway. Teammates then watch near-live session transcripts in the remote Control UI without any access to the source machine.
123+
124+
```json5
125+
{
126+
plugins: {
127+
entries: {
128+
beam: {
129+
enabled: true,
130+
config: {
131+
mirror: {
132+
endpoint: "https://team.example.com/api/v1/beam/sessions",
133+
token: { source: "env", provider: "default", id: "BEAM_TEAM_TOKEN" },
134+
catalogs: ["claude", "codex"],
135+
},
136+
},
137+
},
138+
},
139+
},
140+
}
141+
```
142+
143+
- `endpoint` (required): the remote receiver URL. HTTPS is enforced for non-loopback hosts; plaintext `http://` is accepted only for `localhost`/`127.0.0.1`/`::1` development.
144+
- `token`: Gateway credential for the remote receiver, sent as `Authorization: Bearer`. Accepts a plain string or a secret reference; a configured-but-unresolved token pauses mirroring instead of sending unauthenticated requests. Deployments fronted by an identity-aware proxy need an ingress that accepts this bearer credential.
145+
- `catalogs` (required): the session catalog ids to mirror, as explicit per-catalog consent — an omitted or empty list mirrors nothing. The local `beam` receiver catalog is always excluded so two mirrored Gateways cannot re-mirror each other's rows.
146+
- `pollSeconds` (default 30, minimum 10): how often the mirror scans local catalogs.
147+
- `activeWindowMinutes` (default 180): sessions with newer activity than this window count as live and stay mirrored; when a session goes idle past the window the mirror sends one final `completed` update.
148+
149+
The mirror applies the same redaction contract as the beam skill before anything leaves the machine: only user and agent message text is uploaded, while reasoning, tool calls, tool results, and raw payloads are replaced with compact counts. Snapshots are capped to the receiver limits (200 items, 56 KiB), dropping oldest entries first and marking the upload `truncated`. Sessions on paired nodes are not mirrored; the mirror shares only sessions from this Gateway's machine, newest 32 first.
150+
120151
## Troubleshooting
121152

122153
`404 Not Found`

‎extensions/beam/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
22
import { createBeamRequestHandler } from "./src/http.js";
3+
import { createBeamMirrorService } from "./src/mirror.js";
34
import { createBeamSessionCatalog } from "./src/session-catalog.js";
45
import { createBeamStore } from "./src/store.js";
56

@@ -19,5 +20,6 @@ export default definePluginEntry({
1920
resolveControlUiBasePath: () => api.runtime.config.current().gateway?.controlUi?.basePath,
2021
}),
2122
});
23+
api.registerService(createBeamMirrorService({ runtime: api.runtime }));
2224
},
2325
});

‎extensions/beam/openclaw.plugin.json‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,46 @@
44
"onStartup": false,
55
"onConfigPaths": ["plugins.entries.beam"]
66
},
7+
"uiHints": {
8+
"mirror.endpoint": {
9+
"label": "Mirror Endpoint",
10+
"help": "Remote Beam receiver URL, e.g. https://team.example.com/api/v1/beam/sessions."
11+
},
12+
"mirror.token": {
13+
"label": "Mirror Token",
14+
"help": "Gateway credential for the remote receiver, sent as a Bearer token.",
15+
"sensitive": true
16+
}
17+
},
718
"configSchema": {
819
"type": "object",
920
"additionalProperties": false,
10-
"properties": {}
21+
"properties": {
22+
"mirror": {
23+
"type": "object",
24+
"additionalProperties": false,
25+
"required": ["endpoint", "catalogs"],
26+
"properties": {
27+
"endpoint": {
28+
"type": "string"
29+
},
30+
"token": {
31+
"type": ["string", "object"]
32+
},
33+
"catalogs": {
34+
"type": "array",
35+
"items": {
36+
"type": "string"
37+
}
38+
},
39+
"pollSeconds": {
40+
"type": "number"
41+
},
42+
"activeWindowMinutes": {
43+
"type": "number"
44+
}
45+
}
46+
}
47+
}
1148
}
1249
}

0 commit comments

Comments
 (0)