@lobehub/cli 0.0.75 → 0.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -0
- package/dist/acceptance-report.html +854 -804
- package/dist/index.js +82975 -59244
- package/man/man1/lh.1 +9 -3
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -50,6 +50,79 @@ Diagnostics never dump the service's command line or environment. Older connecto
|
|
|
50
50
|
on Linux use a conservative `/proc` lookup; an inaccessible or unsupported entry
|
|
51
51
|
is reported as unknown instead of guessed.
|
|
52
52
|
|
|
53
|
+
## Managed cloud devices
|
|
54
|
+
|
|
55
|
+
A managed cloud device is a device that LobeHub creates and runs for you. The
|
|
56
|
+
platform that runs it starts the agent with:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
lh connect --managed
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Managed mode reads everything from the environment. It does not use a stored
|
|
63
|
+
login, a keychain or a browser, and it writes no credentials to disk, so it runs
|
|
64
|
+
headless in a container. `lh connect service install` is not needed: the
|
|
65
|
+
platform supervises the process and restarts it when it exits.
|
|
66
|
+
|
|
67
|
+
| Variable | Required | Meaning |
|
|
68
|
+
| --------------------------------- | -------- | ----------------------------------------------------------- |
|
|
69
|
+
| `LOBEHUB_MANAGED_DEVICE_ID` | yes | The device id. It replaces the id derived from the machine. |
|
|
70
|
+
| `LOBEHUB_MANAGED_DEVICE_SECRET` | yes | The bootstrap secret. The CLI never prints it. |
|
|
71
|
+
| `LOBEHUB_SERVER` | yes | The LobeHub server URL. |
|
|
72
|
+
| `LOBEHUB_DEVICE_GATEWAY_URL` | yes | The device gateway URL. |
|
|
73
|
+
| `LOBEHUB_DEVICE_ACTIVITY_COMMAND` | no | A JSON array: a command to run while the device does work. |
|
|
74
|
+
|
|
75
|
+
If a required variable is missing, the CLI names it and exits with status 1.
|
|
76
|
+
`LOBEHUB_SERVER` and `LOBEHUB_DEVICE_GATEWAY_URL` must use `https`; `http` is
|
|
77
|
+
accepted only for `localhost` and the loopback addresses `127.0.0.0/8` and
|
|
78
|
+
`::1`. The URLs must not contain a user name, a password, a query or a fragment.
|
|
79
|
+
A path is kept, so `https://example.com/lobehub` sends the token request to
|
|
80
|
+
`https://example.com/lobehub/api/device/managed/token`. `--managed` cannot be used
|
|
81
|
+
with `--token`, `--gateway`, `--device-id`, `--workspace`, `--public` or
|
|
82
|
+
`--daemon`.
|
|
83
|
+
|
|
84
|
+
After the CLI reads the secret, it removes it from its own environment, so the
|
|
85
|
+
processes it starts (tool calls, agent runs) do not inherit it. This does not
|
|
86
|
+
hide the secret from the device: other processes of the same user can still
|
|
87
|
+
read the environment the CLI started with (for example `/proc/<pid>/environ`).
|
|
88
|
+
The secret only gets tokens for this device, and it stops working when the
|
|
89
|
+
device is deleted.
|
|
90
|
+
|
|
91
|
+
**Token.** The CLI sends `POST {LOBEHUB_SERVER}/api/device/managed/token` with
|
|
92
|
+
`{ "deviceId", "secret" }` and gets `{ "token", "expiresAt" }`, where
|
|
93
|
+
`expiresAt` is an RFC 3339 time with `Z` or an offset. The token's
|
|
94
|
+
`workspace_id` claim, when present, makes the device a workspace device;
|
|
95
|
+
otherwise its `sub` is the owning user.
|
|
96
|
+
|
|
97
|
+
- The CLI gets a new token when 80% of the token's lifetime has passed (at least
|
|
98
|
+
5 s after it got the previous one). The open gateway connection stays up:
|
|
99
|
+
only the next connection uses the new token, so running tool calls, agent
|
|
100
|
+
runs and tunnels continue.
|
|
101
|
+
- On HTTP 408, 429 or 5xx, a network error or an unreadable response, the CLI
|
|
102
|
+
tries again after 1 s, then 2 s, 4 s and so on, up to 60 s between attempts
|
|
103
|
+
(each delay ±20%). It continues until the server answers.
|
|
104
|
+
- On HTTP 401 (wrong secret, or the device was deleted), 404 (the server has no
|
|
105
|
+
managed cloud devices) or another 4xx, the CLI exits with status 1.
|
|
106
|
+
- If the gateway rejects a token, the CLI gets a new token and connects again.
|
|
107
|
+
If the gateway also rejects that token before a connection succeeds, the CLI
|
|
108
|
+
exits with status 1.
|
|
109
|
+
|
|
110
|
+
**Activity command.** When `LOBEHUB_DEVICE_ACTIVITY_COMMAND` is set, the CLI runs
|
|
111
|
+
it while the device serves a tool call, an RPC, an agent run or an open tunnel.
|
|
112
|
+
It runs when the work starts and then every 30 s while work continues, never
|
|
113
|
+
more than once in 30 s and never two at a time. The work does not wait for it.
|
|
114
|
+
A run that takes longer than 10 s is stopped. Failures appear only in the debug
|
|
115
|
+
log (`--verbose`).
|
|
116
|
+
|
|
117
|
+
The value is a JSON array of strings: the program, then its arguments, for
|
|
118
|
+
example `["my-agent","touch"]`. The CLI runs the program directly, without a
|
|
119
|
+
shell, so there is no quoting, `$VAR`, `~` or glob expansion, and `|`, `;`, `&`,
|
|
120
|
+
`>` and `<` are ordinary characters. If the value is not a non-empty JSON array
|
|
121
|
+
of non-empty strings, the CLI exits with status 1 at startup. To use shell
|
|
122
|
+
features, give an explicit shell, for example
|
|
123
|
+
`["sh","-c","my-agent touch >> /var/log/activity"]`. When the CLI stops, it
|
|
124
|
+
also stops a command that is still running.
|
|
125
|
+
|
|
53
126
|
## Publish local artifacts
|
|
54
127
|
|
|
55
128
|
```bash
|