Skip to content

Commit 055a2dc

Browse files
authored
feat: continue dashboard sessions from CLI URLs (#120893)
* feat(cli): ingest session targets * refactor(ui): remove gateway scope shim * docs(cli): document session targets * fix(cli): classify session target failures * fix(cli): keep session target result private * fix(cli): simplify timeout option warning * build: declare session URL contract dependency * fix(cli): parse bare session URL options symmetrically * fix(cli): preserve command-owned URL arguments * build: keep session URL contract build-only * fix: address session URL review findings * test: preserve session key mock exports * fix: keep session URL helpers internal * fix(tui): preserve URL agent for global sessions * fix(tui): keep URL agent input internal * fix(gateway): reconcile websocket protocol owner * fix(attach): preserve global session agent ownership * fix(attach): enforce global owner at grant boundary
1 parent 3bdfd60 commit 055a2dc

39 files changed

Lines changed: 2189 additions & 225 deletions

‎docs/.generated/plugin-sdk-api-baseline.sha256‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
71522995185b956a0cc4927a472cc8d1153e5e998874bfd9a750513175174713 module/account-id
44
d768139934447ff3ecf15470dc1fe613d36509fc5b93fc47ef09d20829cefa57 module/account-resolution
55
4fbb1c87e99399f842a20d75d5e35a4b7064a1b7f02115c23f9a2a7cdcfb57ee module/agent-config-primitives
6-
66c80a448539e52493abe8bd0e6ca3152d2ff7318cf809fe16336f270d2cacdd module/agent-harness
7-
0f254f026d4968ab796096225dfe8ca94655a6ef2d0435eb3c3acba831c0b219 module/agent-harness-runtime
6+
0eeb85850d6056f815e231a7f0acbca6fb4115699407b823a9cf4437bf627e69 module/agent-harness
7+
e1754867b9fbdd210a21c3d00c3aa5f161517bd2ed10c1601f52e3f39714699a module/agent-harness-runtime
88
d6097cfa1b410f4b5267a56a7bd19c2a33fbaf6642683dae6aec68e998e48f6c module/agent-media-payload
99
3035368684499711a63540fbef74b4aae7d131073367a77a3179e3b9aef16ad8 module/agent-runtime
1010
b57a3cb274a9977c48c5387772df7707e50dde9a6132e532e7367a27225dc142 module/agent-scope-runtime
@@ -26,7 +26,7 @@ afad33fdaada25984db53504dc6f665ff0478c12f68b79f36a39d28ceb13355e module/channel
2626
c2cc71d5070b6071c51248b0648d1ad1a9468d3737df890adc77ec02025e8853 module/channel-config-primitives
2727
a6cca5706f3aba6abb2178b175a0986d921ade98c2c05d2a54451e2fb7e16825 module/channel-config-schema
2828
37925e2b8c74b4444a14ea85b831ab569df9d46efebe89714527ee638719c100 module/channel-contract
29-
265ce5d0983e662e2d5b54b7254226a713463c020ccb96b87672409423e1b2a7 module/channel-core
29+
c6427c4fea5bd0a7574af77850445624a80e9988f7129af224a489297af041a3 module/channel-core
3030
f4a9870d37f3b4e824bc7b0f634e4eb868ae7dd4c5a9693f0105a6677c2ff5f9 module/channel-dm-policy
3131
3f78f6022fc2942f60bc07a554f57ef9f8763db773f10f6425fa940acdbe917a module/channel-entry-contract
3232
47cf8765e76c151ae7d2991d41beca62922a8837c1521e10a3fd23f9992c2d7c module/channel-feedback
@@ -60,16 +60,16 @@ ab86235fcfff7c7cf0021fafeca6e92afe2c257ccf6a4a38441e0d41532998ff module/config-
6060
0d99f5cb8c4978ed760e5fb4e476543759fbd8fd5bf73cc50a50c1d550203826 module/config-mutation
6161
1c79d1356d7f41c22a0e85ff43766fc839cf13734435a3dcf7a4739512d513bf module/config-runtime
6262
d9e5f2ae27e29a40a6d6084c4d59e4811b4669235faa6f0d6a4fbfdd62e51ca3 module/conversation-runtime
63-
2b11c2f1fc406190b1b036316bd173a528c92bbc061b3da1a4e971cdd26c7c97 module/core
63+
5bebdf2011850e732ef1f71f5bc7669b7ebc3c4ece653f48c5ee0e3aa4ebc369 module/core
6464
2872c791a0b43fad1020a8f595e506d369bed6c57819733919858dddbd96fbaf module/dedupe-runtime
6565
ebef0e650ab45e44c9335e2b3e15588c968cea6dadd125364a076f9c50ad1e8c module/device-bootstrap
6666
21d86413166ef815581d606f678b6a216a1cc73ffe470b841f5bc4a131bff6df module/diagnostic-runtime
6767
2af0c3b8867148d3deaf0b6d112743a42b206014ed1b5a5cf4ef939f1976d420 module/directory-runtime
68-
b2fd699e080ec56989f0a8f21f4b93ae87842b70671b918d6733777c44c89b07 module/discord
68+
a589c6a22e936d596cdca5ce8d97ea091fd8ddd8d9df9407b57bbf1d683c8e82 module/discord
6969
39fe343ed2119de714757c365eef2ccec89c2c82a0876c60a4bef8ce469f8c8a module/error-runtime
7070
ce4f1602bf5b5de968ca97cede4f498b6ae709a0a59393b5ce9255cf0e6a9d5e module/extension-shared
7171
dd9f6e0fd33cc88b22543c1ee30cc09cf4de4d8f30dff7b7f9cebef885c21543 module/gateway-method-runtime
72-
49c009813a6dd34091d2c1c73eefe210af7926c8c490d87484550c668b3e20ac module/gateway-runtime
72+
c76bd967ef989feff27494df1e59aab2abef6e01aabf96c222b1ea8b153af1fc module/gateway-runtime
7373
1b1c6bd5bfc0cfb0c5bb9bd97f8ac1928750cb87232a3415dd066cc21d7b48b7 module/group-access
7474
4a9e9046f39dd661ef98ad9d37b0088eced2aacfe430fef2a93d4e009b297c3f module/health
7575
a35bf7d756fc781b860d131bac3710e4d3b2dd4403f7f98313899ddf80b564d3 module/hook-runtime
@@ -89,7 +89,7 @@ f74d7295fe716aa140aa0bc9300d6259d71dab826de0808fca6bb02592bf5d6e module/media-m
8989
6a52f93107335f88751704352cc01e62add06f854a5b7d765e2a5ee87c0313b6 module/media-store
9090
b7e71516842300c041d2423d822da0080881db6ddc6b9b9ce38cabd8d546676b module/media-understanding
9191
a206a1486f6a6bed3091795b324e95dd710b4b3b87a4a8f18788e6158a48a922 module/media-understanding-runtime
92-
e78370b4f450b6b29751117c5cbd59f3ade9e6e7a12b754b3d805336d770ef69 module/meeting-runtime
92+
ffc96fca1e036592ed6b640c4917e4773a168b3d88aab1a11de4a4b4df84ce30 module/meeting-runtime
9393
3312468e2e8f3423b765fac6bb17944b800ea2c84acffeb64342c99040b2f482 module/memory-core-host-engine-foundation
9494
e3d2db75fab4b4a4d8a77f7db8fc2df2047678d0570385843c68a2478d2be4e5 module/memory-host-core
9595
1efa0aadc4261d1c6073058cbf3dcc9fa681424819bdd14333e19b249bbc4b18 module/messaging-targets
@@ -103,7 +103,7 @@ b31f5d86904097993a55377fed7973cd298b0e1f49cade7e37a1e28f6e724108 module/plugin-
103103
29e893378475bf70f9265e4bb160860f4fb9783dbbd7d5849cde4d10d3450cb6 module/plugin-entry
104104
61364b898140f866d23aa282251eb2cbbcaf233dd2c966f0d47ea82e1b31d8dc module/plugin-runtime
105105
515ca993ecfdcb462f2e006816fdfc4dfd7752b30fda55b095bc1d443744a231 module/provider-auth
106-
03764516436e159b9352c00377856873d34c41b44ef650fd21653de7643d1861 module/provider-catalog-runtime
106+
a54b42a90c511494e32245f5f1477a65d7b5ca5aaa9993ddafe6132ae42be7c2 module/provider-catalog-runtime
107107
8131147d699394bd06503e2ea2f5f1a50b1594a87dded6d118b74a8d0328c8f6 module/proxy-capture
108108
4a698efc36d896c4702de8df831e36b06e85c82aa30bf86c9b1066e6cad4b700 module/question-gateway-runtime
109109
1171a76ea0485b36f77c9e12601c44a0e858043140e1d4669bb86d1f9e35930b module/reply-chunking
@@ -133,7 +133,7 @@ fb0af0a51ba93e070d8862701c016375cf8576c47be1d25e20537ec86b0bcf73 module/setup
133133
8ec6ca8a40d4117c669fbd0f20241d54e7e6954d7cff8c5b4afc67ec9626e216 module/skill-commands-runtime
134134
0b09bb506ca970ee39b58953d9c1f0407942b2762f54d89a4cd82c35b9bc6c8b module/speech-settings
135135
0b3de0b219e431d26298c83688ffe53c262d58a336ca910e29619b5d0447266e module/ssrf-policy
136-
0be0326d5dfb54aea1cc12bd320de91553859aa055b8ec87c11e498812265ab8 module/ssrf-runtime
136+
6639ba57aacbb620a2f6ff802ecd94fc90b1969292e0306598546b5b4b9261cc module/ssrf-runtime
137137
3855f0a23281d21063762f5b3be2b7485c8bdb3b4cd1692de4f2a17d4eeae496 module/state-paths
138138
21fb493eaeb6e46441863c27a3838b52fc13494fff8f7c90c12b72a3d373b16b module/status-helpers
139139
f097d0096b21c8a052f0f649b7512ecf2aba4744ae6956f001950e053828b309 module/string-coerce-runtime
@@ -145,7 +145,7 @@ d05a2db4a97844950ff3bc30f90f07e7f45600b1219e08a19264174b399817dc module/text-ru
145145
dc1a073c59ab61e2789533b777b3f0cb9af689d64a97796b10e8aa82552510db module/tool-results
146146
a5eef5a532c439b1489236711f4bc2721abe612a9db3911430e1344c239f9861 module/tool-send
147147
cda105b721d498df23a554c6b68be150b8fe66b8b9172185c31a0b3b0646b1dc module/web-media
148-
6bbbbcfea4f3e2acf483aac46d4ad0cda70820bdcfec3bac30a3efe06e6d1331 module/webhook-ingress
148+
60465458d5674539012dabb6bf7861783798fd80b8111948812f1f451d848fd0 module/webhook-ingress
149149
e3a199a9ce0b85d203e9e8a29b500db29c6b7af307e3145d0a311e29d598925b module/webhook-request-guards
150150
de59e86e126b75d13251cba7ebbe27b44d9b5588785d98df5ff4d6722374c81f module/widget-html
151151
9161b36ec0ab062ea41b363c894fcd672a7727f21cb726739f99f9c184fce69d module/zod

‎docs/cli/attach.md‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,50 @@ title: "Attach CLI"
88

99
`openclaw attach` launches Claude Code with a strict temporary MCP config bound to one Gateway session.
1010

11+
```sh
12+
openclaw attach [target]
13+
```
14+
15+
`target` accepts a Control UI session URL, a compact `host/agent/ref`, a bare
16+
short reference, or a literal `agent:...` session key. A URL or host target
17+
authoritatively selects that Gateway; a bare reference uses the configured or
18+
default Gateway.
19+
1120
```sh
1221
openclaw attach
22+
openclaw attach https://gateway.example/dashboard/main/movies-a1166b81
23+
openclaw attach movies-a1166b81
1324
openclaw attach --session agent:main:telegram:123 --ttl 600000
1425
openclaw attach --print-config
1526
```
1627

1728
Options:
1829

1930
- `--session <key>` binds the grant to a Gateway session. Defaults to the main session.
31+
- `--url <url>` selects a Gateway for a bare reference or `--session` key. Do
32+
not combine it with a URL target.
33+
- `--token <token>` and `--password <password>` provide explicit Gateway auth.
34+
- `--tls-fingerprint <sha256>` pins the Gateway TLS certificate.
2035
- `--ttl <ms>` requests a positive grant TTL in milliseconds. The Gateway applies its own ceiling.
2136
- `--bin <path>` selects the Claude Code binary. Default: `claude`.
2237
- `--print-config` writes the temporary `.mcp.json`, prints the launch command and env, and leaves the grant live until TTL expiry (it does not spawn Claude Code or revoke the grant).
2338

39+
Pass either a positional target or `--session`, not both. Short references are
40+
resolved before the scoped attach grant is minted; a missing session is never
41+
created implicitly.
42+
43+
A URL or host target never reuses configured credentials or
44+
`OPENCLAW_GATEWAY_TOKEN` / `OPENCLAW_GATEWAY_PASSWORD`. It uses the stored
45+
device token for that exact Gateway origin, or explicit `--token`/`--password`
46+
credentials. On first contact, pass one of those credentials once, approve the
47+
pairing request in that Gateway's Control UI, and retry; see
48+
[Devices](/cli/devices). Session URLs must stay credential-free: userinfo and
49+
sensitive query or fragment parameters such as `token` and `password` are
50+
rejected.
51+
52+
Target resolution uses the same [session target error matrix](/cli/tui#session-target-errors)
53+
as `openclaw tui`.
54+
2455
The bearer token is passed through environment variables, not argv. OpenClaw launches Claude Code with `--strict-mcp-config --mcp-config <path>` so ambient Claude MCP servers do not join the attached session. Normal launches (without `--print-config`) revoke the grant when the Claude Code process exits.
2556

26-
See also: [Gateway CLI](/cli/gateway), [MCP CLI](/cli/mcp), and [ACP CLI](/cli/acp).
57+
See also: [Control UI URLs](/web/urls), [Devices](/cli/devices), [Gateway CLI](/cli/gateway), [MCP CLI](/cli/mcp), and [ACP CLI](/cli/acp).

‎docs/cli/tui.md‎

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ title: "TUI"
1313
Open the terminal UI connected to the Gateway, or run it in local embedded
1414
mode.
1515

16+
```bash
17+
openclaw tui [target]
18+
```
19+
20+
`target` can be a Control UI session URL, a compact `host/agent/ref`, a bare
21+
short reference such as `movies-a1166b81`, or a literal `agent:...` session key.
22+
A URL or host target authoritatively selects that Gateway; a bare reference
23+
uses the configured or default Gateway. You can also paste a Control UI URL
24+
directly as `openclaw <url>` and place the TUI options after it, for example
25+
`openclaw <url> --token <token> --deliver`.
26+
27+
The bare-URL form accepts `--token`, `--password`, `--tls-fingerprint`,
28+
`--deliver`, `--thinking`, `--message`, `--timeout-ms`, and `--history-limit`.
29+
Use `openclaw tui <url>` when you need another TUI option; `--local`, `--url`,
30+
and `--session` conflict with a session URL.
31+
1632
Related guide: [TUI](/web/tui)
1733

1834
## Options
@@ -37,8 +53,22 @@ Aliases: `openclaw chat` and `openclaw terminal` invoke this command with
3753
## Notes
3854

3955
- `--local` cannot combine with `--url`, `--token`, `--password`, or `--tls-fingerprint`.
40-
- `tui` resolves configured Gateway auth SecretRefs for token/password auth
41-
when possible (`env`/`file`/`exec` providers).
56+
- Pass only one Gateway target. A URL target cannot combine with `--url`, and
57+
any positional target cannot combine with `--session` or local mode.
58+
- A URL or host target never reuses configured credentials or
59+
`OPENCLAW_GATEWAY_TOKEN` / `OPENCLAW_GATEWAY_PASSWORD`. It uses the stored
60+
device token for that exact Gateway origin, or explicit `--token`/`--password`
61+
credentials. On first contact, pass one of those credentials once, approve
62+
the pairing request in that Gateway's Control UI, and retry; see
63+
[Devices](/cli/devices).
64+
- Session URLs must stay credential-free. Userinfo and sensitive query or
65+
fragment parameters such as `token` and `password` are rejected.
66+
- Short references resolve through the Gateway. If a short reference is
67+
ambiguous, the CLI prints candidate names and longer ID prefixes without
68+
attaching to either session.
69+
- With no URL/host target or explicit `--url`, `tui` resolves configured Gateway
70+
auth SecretRefs for token/password auth when possible (`env`/`file`/`exec`
71+
providers).
4272
- With no explicit URL or port, `tui` follows the active local Gateway port
4373
recorded by the running Gateway. Explicit `--url`, `OPENCLAW_GATEWAY_URL`,
4474
`OPENCLAW_GATEWAY_PORT`, and remote Gateway config keep precedence.
@@ -53,12 +83,25 @@ Aliases: `openclaw chat` and `openclaw terminal` invoke this command with
5383
- Session [goals](/tools/goal) appear in the footer and can be managed with
5484
`/goal`.
5585

86+
## Session target errors
87+
88+
| Failure | Recovery |
89+
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
90+
| The Gateway predates short-link resolution | Copy the full session key from that Gateway's Control UI. |
91+
| Session missing or short ref ambiguous | For the configured/local Gateway, run `openclaw sessions list`; for a URL/host target, choose a longer or full key in that Gateway's Control UI. |
92+
| Gateway unreachable | The error names the selected origin. For a `*.ts.net` host, connect Tailscale and confirm the Gateway is reachable on the tailnet. |
93+
| Stored device token revoked or rotated | Rotate it with `openclaw devices rotate --device <deviceId> --role operator`, then reconnect. |
94+
| TLS certificate pin mismatch | The original TLS fingerprint error passes through unchanged; verify the configured or explicit pin before retrying. |
95+
5696
## Examples
5797

5898
```bash
5999
openclaw chat
60100
openclaw tui --local
61101
openclaw tui
102+
openclaw tui https://gateway.example/dashboard/main/movies-a1166b81
103+
openclaw https://gateway.example/dashboard/main/movies-a1166b81 --token <token>
104+
openclaw tui movies-a1166b81
62105
openclaw tui --url ws://127.0.0.1:18789 --token <token>
63106
openclaw tui --session main --deliver
64107
openclaw chat --message "Compare my config to the docs and tell me what to fix"
@@ -96,4 +139,6 @@ rerun `openclaw config validate`. See [TUI](/web/tui) and
96139

97140
- [CLI reference](/cli)
98141
- [TUI](/web/tui)
142+
- [Control UI URLs](/web/urls)
143+
- [Devices](/cli/devices)
99144
- [Goal](/tools/goal)

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,7 @@
20722072
"@lit/context": "1.1.6",
20732073
"@lit/task": "1.0.3",
20742074
"@mdx-js/mdx": "3.1.1",
2075+
"@openclaw/session-url-contract": "workspace:*",
20752076
"@opentelemetry/sdk-node": "0.221.0",
20762077
"@shikijs/core": "4.3.1",
20772078
"@shikijs/engine-javascript": "4.3.1",

‎pnpm-lock.yaml‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎scripts/openclaw-postpack.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import { fileURLToPath } from "node:url";
55
// Restores every source artifact temporarily rewritten for npm packaging.
66
import { restorePackageChangelog } from "./package-changelog.mjs";
77
import { restorePackageDocsMap } from "./package-docs-map.mjs";
8+
import { restorePackageManifest } from "./package-manifest.mjs";
89

910
export async function restorePrepackArtifacts(cwd = process.cwd()) {
1011
await restorePackageChangelog(cwd);
12+
await restorePackageManifest(cwd);
1113
// Release the lifecycle receipt only after every other source mutation settles.
1214
await restorePackageDocsMap(cwd);
1315
}

‎scripts/openclaw-prepack.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { writePackageDistInventoryForPublish } from "./lib/package-dist-inventor
1111
import { restorePrepackArtifacts } from "./openclaw-postpack.mjs";
1212
import { preparePackageChangelog } from "./package-changelog.mjs";
1313
import { preparePackageDocsMap } from "./package-docs-map.mjs";
14+
import { preparePackageManifest } from "./package-manifest.mjs";
1415
import { createPnpmRunnerSpawnSpec } from "./pnpm-runner.mts";
1516
const FULL_GIT_COMMIT_RE = /^[0-9a-f]{40}$/iu;
1617
const requiredPreparedPathGroups = [
@@ -291,6 +292,7 @@ export async function preparePrepackArtifacts(env: NodeJS.ProcessEnv = process.e
291292
// changelog is touched, so concurrent packs cannot restore each other's files.
292293
await preparePackageDocsMap(process.cwd());
293294
try {
295+
await preparePackageManifest(process.cwd());
294296
await preparePackageChangelog(process.cwd(), {
295297
allowUnreleased: resolvePrepackAllowUnreleasedChangelog(env),
296298
});

‎scripts/package-manifest.d.mts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export function restorePackageManifest(cwd?: string): Promise<boolean>;
2+
export function preparePackageManifest(cwd?: string): Promise<boolean>;

0 commit comments

Comments
 (0)