kylon-cli 0.2.2-next.227 → 0.2.2-next.228

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 CHANGED
@@ -1,56 +1,39 @@
1
1
  # kylon-cli
2
2
 
3
- Gateway CLI for connecting local agent providers to a P2 workspace.
3
+ Computer host CLI for running external agents on your own machine for a P2
4
+ workspace.
4
5
 
5
6
  Requires Node.js 22.15.0 or newer.
6
7
 
7
8
  ## Install
8
9
 
9
10
  The CLI is published to npm as
10
- [`kylon-cli`](https://www.npmjs.com/package/kylon-cli). The Web UI's
11
- Onboarding tab provides one opaque `npx ... onboard --url ...` command
12
- for the normal setup and re-onboarding flow. Its collapsed manual setup
13
- shows the separate install and run commands documented below for recovery
14
- and advanced operation.
15
-
16
- ### Step 1 Install kylon (once per host, re-paste to upgrade)
17
-
18
- ```bash
19
- npm install -g kylon-cli@latest
20
- ```
21
-
22
- Installs the CLI globally so the `kylon` binary lands on PATH — the
23
- gateway daemon's child `kylon workspace …` calls (issued by the
24
- provider subprocess) resolve it there. Re-run to upgrade to whatever
25
- the dist-tag now points to. If the global install needs elevated
26
- permissions, prefix it with `sudo`.
27
-
28
- The dist-tag tracks the environment: production installs `@latest`,
29
- dev installs `@next` (newest prerelease). To pin a specific build,
30
- install `kylon-cli@X.Y.Z`.
11
+ [`kylon-cli`](https://www.npmjs.com/package/kylon-cli). The Web UI provides
12
+ two copy-paste entry points, both built on `kylon connect`:
13
+
14
+ - **Workspace Settings Kylon CLI** shows
15
+ `npx --yes kylon-cli@<tag> connect --workspace <id>` — registers this machine
16
+ as a computer for the workspace and runs the host daemon. Agents are then
17
+ assigned to the computer from the web.
18
+ - **An external agent's Settings page** (and the create-agent flow) shows
19
+ `npx --yes kylon-cli@<tag> connect --url '<setup url>'` — same registration,
20
+ plus the named agent is assigned to this computer in the same run. The setup
21
+ URL carries intent only (workspace + agent), never a credential, and expires
22
+ after an hour.
23
+
24
+ Both commands browser-authenticate the operator, enroll the computer (minting a
25
+ machine-scoped credential stored locally with mode `0600`), and start the host
26
+ daemon. In release builds on supported hosts a user-level
27
+ `launchd` / `systemd --user` service is installed so the daemon survives
28
+ terminal exit, reboot, and sleep/wake; otherwise the daemon runs in the
29
+ foreground until `Ctrl+C`.
30
+
31
+ The dist-tag tracks the environment: production uses `@latest`, dev uses
32
+ `@next` (newest prerelease). To pin a specific build, use `kylon-cli@X.Y.Z`.
31
33
 
32
34
  Requirements: Node.js 22.15.0+ (npm ships with Node). Linux / macOS only
33
35
  (Windows operators should use WSL).
34
36
 
35
- ### Step 2 — Start the gateway daemon
36
-
37
- ```bash
38
- kylon gateway run \
39
- --session-dir ~/.kylon/agents/<agent-id> \
40
- --server-url https://<origin>/api \
41
- --provider codex \
42
- --api-key <agent-api-key>
43
- ```
44
-
45
- `gateway run` registers the session inside the selected agent directory
46
- (writing `~/.kylon/agents/<agent-id>/gateway-session.json` with mode `0600`)
47
- and starts the daemon in one step. On the next invocation, pass the same
48
- `--session-dir` without connection flags to jump straight to start. See
49
- [Usage → Run](#run) for the full decision table. The daemon runs
50
- in the foreground until you stop it with `Ctrl+C`; hosts that want a
51
- supervised daemon typically wrap the same command in
52
- `launchd` / `systemd` / `supervisord`.
53
-
54
37
  ### Local development (contributors)
55
38
 
56
39
  ```bash
@@ -151,161 +134,66 @@ Credentials created by the earlier browser flow appear as **Legacy user API
151
134
  key** in Settings. They can be revoked there, but they are not bound to a single
152
135
  workspace; sign in again to replace one with the per-installation flow.
153
136
 
154
- ### Onboard an invited external agent
137
+ ### Connect a computer (and optionally an agent)
155
138
 
156
- The Web UI provides one operator-run command after an external agent is
157
- created:
139
+ `kylon connect` is the single onboarding entrypoint.
158
140
 
159
141
  ```bash
160
- npx --yes kylon-cli@latest onboard \
161
- --url 'https://api.kylon.io/docs/agent-onboard/<opaque-token>'
162
- ```
163
-
164
- The command resolves the invitation without printing its API key, checks the
165
- local provider, verifies Codex or Claude Code authentication, connects the
166
- gateway, binds a managed per-agent working directory, and installs or updates a
167
- user-level `launchd` / `systemd --user` service running the unified gateway. The
168
- command returns after the service is active; the gateway then survives terminal
169
- exit, crash restart, reboot, and sleep/wake reconnects. Re-onboarding the same
170
- agent preserves its registered provider and directory, safely interrupts
171
- unfinished work owned by the displaced connection, and reconciles only that
172
- agent inside the existing daemon. If Codex or Claude Code is logged out, an
173
- interactive terminal launches the provider's own login flow and verifies
174
- authentication again before connecting.
175
-
176
- External-agent onboarding is intentionally separate from human `kylon auth
177
- login`: it continues to use the agent principal's API key and gateway session.
178
- It does not create a human CLI installation credential.
179
-
180
- Each invited agent is installed below `~/.kylon/agents/<agent-id>/`, so several
181
- Claude Code, Codex, or mixed-provider agents can run on the same host without
182
- sharing credentials or provider resume state. Different agents cannot use the
183
- same canonical working directory; create a separate checkout or Git worktree for
184
- each concurrently installed agent.
185
-
186
- Use `--workdir <path>` to select a different directory or `--no-start` to
187
- configure and validate without opening the long-running connection. Generic
188
- providers can supply their one-shot command with `--agent-command <command>`;
189
- an interactive terminal prompts for it when the flag is omitted.
190
-
191
- ### Run
192
-
193
- `gateway run` is the recommended entrypoint for external agent operators.
194
- It composes `connect` + `start` into a single command.
195
-
196
- ```bash
197
- kylon gateway run \
198
- --session-dir ~/.kylon/agents/agent_123 \
199
- --server-url https://api.p2.ai \
200
- --provider codex \
201
- --api-key pak_xxxxx
202
- ```
203
-
204
- Decision table:
205
-
206
- | Saved session in `--session-dir`? | Connection flags passed? | What `run` does |
207
- |---|---|---|
208
- | no | `--server-url` + `--api-key` + `--provider` | connect, persist session, start daemon |
209
- | no | any field missing | error — lists the missing flag |
210
- | yes | none | start the daemon from the saved session |
211
- | yes | any | reconnect with the overrides (falls back to saved values for fields you didn't pass), persist the refreshed session, start the daemon |
142
+ # From Workspace Settings — register this machine, assign agents from the web:
143
+ npx --yes kylon-cli@latest connect --workspace <WORKSPACE_ID>
212
144
 
213
- Only CLI flags count as overrides. On first connect, `KYLON_API_KEY` is
214
- persisted and the process is immediately replaced with a credential-free
215
- daemon image. With a saved session, the saved key remains authoritative and
216
- any inherited `KYLON_API_KEY` is removed before the daemon starts.
217
-
218
- ### Connect
219
-
220
- Register this machine as the gateway client for an external agent.
221
- Most operators should prefer `gateway run` above. Use `connect` on its
222
- own when scripting or when you need to register a session without
223
- immediately starting the daemon.
224
-
225
- ```bash
226
- kylon gateway connect \
227
- --server-url https://api.p2.ai \
228
- --api-key pak_xxxxx \
229
- --provider codex
145
+ # From an agent's page register this machine AND assign that agent to it:
146
+ npx --yes kylon-cli@latest connect --url 'https://api.kylon.io/docs/computer-setup/<opaque-token>'
230
147
  ```
231
148
 
232
- The agent's API key identifies which agent the daemon will serve;
233
- channels are bound separately via the "invite agent into channel" flow
234
- in the web UI.
235
-
236
- `--session-dir` selects the full isolated state root for one agent. It is
237
- not a connection override, so it must be present both when connecting and
238
- when restarting that agent.
239
-
240
- ### Bind
149
+ Both forms browser-authenticate the operator (same PKCE flow as
150
+ `kylon auth login`), enroll the machine as a **computer** keyed on its stable
151
+ install id (re-running is idempotent), persist the machine-scoped credential,
152
+ and start the host daemon. The `--url` form resolves the setup link to a
153
+ workspace + agent and, after enrollment, assigns that agent to this computer —
154
+ authorized as the signed-in user, so an account that cannot manage the agent
155
+ gets a clear error and the computer registration still stands.
156
+
157
+ The daemon then reconciles the computer's assigned agents from the server:
158
+ each agent gets an isolated state root under `~/.kylon/agents/<agent-id>/`,
159
+ provider readiness (Codex / Claude Code install + authentication) is reported
160
+ per agent, and assignments arrive over the computer's single SSE stream.
161
+ Assigning, moving, or unassigning agents later happens in the web UI; the
162
+ daemon picks the change up without re-running `connect`.
163
+
164
+ Use `--no-start` to register without starting the daemon, `--json` for
165
+ machine-readable output, and `--server-url` to target a non-default API origin
166
+ (the `--url` form resolves the origin from the setup link itself).
241
167
 
242
- Create or update a logical session binding for an agent. Run from the
243
- target working directory:
244
-
245
- ```bash
246
- kylon gateway bind \
247
- --agent agent_123 \
248
- --provider codex
249
- ```
168
+ ### Run
250
169
 
251
- Switch an existing binding to a different directory:
170
+ `gateway run` starts the host daemon from this machine's saved computer
171
+ registration. It is the command the installed `launchd` / `systemd --user`
172
+ service execs; run it manually to host agents in the foreground.
252
173
 
253
174
  ```bash
254
- cd /path/to/other/repo
255
- kylon gateway bind --agent agent_123 --workdir .
175
+ kylon gateway run
256
176
  ```
257
177
 
258
- Bindings are keyed by `(gateway session, agent)`. The same agent
259
- behaves the same way regardless of which channel an assignment
260
- arrives on — see
261
- [`docs/journal_docs/05_27_gateway_routing_simplification.md`](../../docs/journal_docs/05_27_gateway_routing_simplification.md).
178
+ It takes no connection flags: register first with `kylon connect`. Without a
179
+ saved computer registration it exits with an error pointing there.
262
180
 
263
181
  ### Commands
264
182
 
265
183
  | Command | Description |
266
184
  |---|---|
267
- | `kylon gateway run` | **Recommended.** Connect + start in one step; idempotent when a session already exists. |
268
- | `kylon gateway connect` | Register this machine as the gateway client for an agent (API key identifies which), without starting the daemon. |
269
- | `kylon gateway bind` | Create or update a logical session binding. |
270
- | `kylon gateway start` | Start the gateway daemon from a saved session — opens the SSE stream and executes assignments. Credential/server overrides are rejected on this long-running entrypoint. |
271
-
272
- ### Run Options
273
-
274
- | Flag | Description |
275
- |---|---|
276
- | `--server-url <url>` | P2 server URL (required for the first run; override otherwise) |
277
- | `--api-key <key>` | Agent API key, e.g. `pak_xxx` (required for first run; override otherwise. `KYLON_API_KEY` satisfies first-run setup and is removed from the daemon environment after the key is persisted) |
278
- | `--provider <name>` | Provider CLI: `codex`, `claude-code`, `hermes`, `openclaw`, `generic` (required for first run; override otherwise) |
279
- | `--session-dir <path>` | Isolated state directory for this agent (normally `~/.kylon/agents/<agent-id>`) |
185
+ | `kylon connect` | **Recommended.** Register this computer (browser auth + enrollment) and run the host daemon. `--url` also assigns one agent. |
186
+ | `kylon gateway run` | Run the host daemon from the saved computer registration (service entrypoint). |
280
187
 
281
188
  ### Connect Options
282
189
 
283
190
  | Flag | Description |
284
191
  |---|---|
285
- | `--server-url <url>` | P2 server URL (required) |
286
- | `--api-key <key>` | Agent API key, e.g. `pak_xxx` (required, or set `KYLON_API_KEY`) |
287
- | `--provider <name>` | Provider CLI: `codex`, `claude-code`, `hermes`, `openclaw`, `generic` (required) |
288
- | `--session-dir <path>` | Isolated state directory for this agent |
289
-
290
- ### Bind Options
291
-
292
- | Flag | Description |
293
- |---|---|
294
- | `--agent <id>` | Agent ID (required) |
295
- | `--provider <name>` | Provider CLI (required for new, optional for update) |
296
- | `--workdir <path>` | Working directory (default: current directory) |
297
- | `--session-dir <path>` | Isolated state directory for this agent |
298
-
299
- ### Start Options
300
-
301
- | Flag | Description |
302
- |---|---|
303
- | `--session-dir <path>` | Isolated state directory containing this agent's saved session, bindings, and provider runtime cache |
304
-
305
- `gateway start` accepts credentials and the server origin only from the saved
306
- session. Use `gateway run` when a credential or origin must be supplied or
307
- changed; it persists the session and replaces the process with a credential-free
308
- daemon image before opening SSE.
192
+ | `--workspace <id>` | Workspace to register this computer with |
193
+ | `--url <setup url>` | Agent setup link from Kylon; implies the workspace and assigns that agent after enrollment (alternative to `--workspace`) |
194
+ | `--server-url <url>` | API server URL (defaults to `https://api.kylon.io`; ignored in favor of the origin resolved from `--url`) |
195
+ | `--no-start` | Register only; do not start the daemon |
196
+ | `--json` | Emit machine-readable JSON |
309
197
 
310
198
  ### Supported Providers
311
199