kylon-cli 0.2.0-next.152 → 0.2.0-next.155

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
@@ -7,11 +7,11 @@ Requires Node.js 22 or newer.
7
7
  ## Install
8
8
 
9
9
  The CLI is published to npm as
10
- [`kylon-cli`](https://www.npmjs.com/package/kylon-cli). The Web UI
11
- generates two separate commands an **install** step and a **run**
12
- step each with its own Copy button. Operators paste the install
13
- once per host (and any time they want to upgrade) and the run
14
- whenever they want to start the daemon.
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
15
 
16
16
  ### Step 1 — Install kylon (once per host, re-paste to upgrade)
17
17
 
@@ -36,15 +36,16 @@ Requirements: Node.js 22+ (npm ships with Node). Linux / macOS only
36
36
 
37
37
  ```bash
38
38
  kylon gateway run \
39
+ --session-dir ~/.kylon/agents/<agent-id> \
39
40
  --server-url https://<origin>/api \
40
41
  --provider codex \
41
42
  --api-key <agent-api-key>
42
43
  ```
43
44
 
44
- `gateway run` registers the session (writing `~/.kylon/gateway-session.json`
45
- with mode `0600`) and starts the daemon in one step. On the next
46
- invocation, if a session already exists, plain `kylon gateway run`
47
- without flags picks it up and jumps straight to start. See
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
48
49
  [Usage → Run](#run) for the full decision table. The daemon runs
49
50
  in the foreground until you stop it with `Ctrl+C`; hosts that want a
50
51
  supervised daemon typically wrap the same command in
@@ -64,17 +65,60 @@ for the debugger-friendly tsx-based dev loop.
64
65
 
65
66
  npm dist-tags are the version pointer — there is no server-side version
66
67
  policy. Every merge to `develop` publishes a prerelease to the `next` tag
67
- (`.github/workflows/cli-publish.yml`); cutting a `kylon-cli-vX.Y.Z`
68
- release tag publishes a stable to `latest`. dev installs `@next` and prd
69
- installs `@latest`, so each environment tracks its own train.
70
-
71
- Cutting a stable is a manual, when-ready step: tag a validated build
72
- `kylon-cli-vX.Y.Z` and push the tag; CI publishes it to `latest`. Don't
73
- `npm publish` ad-hoc — releases go through the CI workflow so the OIDC
74
- publish path is exercised end-to-end.
68
+ (`.github/workflows/cli-publish.yml`). A production deployment dispatched from
69
+ `main` automatically invokes the same workflow in stable mode and publishes the
70
+ exact `packages/cli/package.json` version to `latest`; it is idempotent when that
71
+ version already exists. A CLI change intended for production must therefore bump
72
+ the package version before the production deploy, or the stable publish will
73
+ correctly no-op and `latest` will remain on the existing build.
74
+
75
+ A matching `kylon-cli-vX.Y.Z` tag is an alternative supported stable-release
76
+ trigger, not a required extra step after a production deploy. Do not run
77
+ `npm publish` ad hoc: both paths use the CI workflow and its OIDC publisher.
78
+ Development installs `@next` and production installs `@latest`, so each
79
+ environment tracks its own release train.
75
80
 
76
81
  ## Usage
77
82
 
83
+ ### Sign in for workspace commands
84
+
85
+ For a person using `kylon workspace ...` from their own terminal, open the
86
+ workspace's **Settings → Kylon CLI** section, expand it, and copy its setup
87
+ command, or run:
88
+
89
+ ```bash
90
+ npm install -g kylon-cli@latest && kylon auth login --workspace <WORKSPACE_ID>
91
+ ```
92
+
93
+ The CLI opens Kylon in your browser. After you sign in, confirm the installation
94
+ and workspace shown on the authorization page. Kylon then creates one credential
95
+ for that CLI installation and workspace. The secret is delivered directly to the
96
+ local CLI callback and saved in the versioned credential collection at
97
+ `~/.kylon/workspace-auth.json` with mode `0600`; it is not displayed in Settings.
98
+ The collection keeps credentials separately by server and workspace, and
99
+ `--scope-workspace` selects the matching entry.
100
+
101
+ Each installation credential expires after 90 days. Re-running `kylon auth
102
+ login` for the same installation and workspace rotates that credential, making
103
+ the previous value invalid. Use `kylon auth status` to inspect the bound
104
+ workspace and expiration time.
105
+
106
+ ```bash
107
+ kylon auth logout --workspace <WORKSPACE_ID>
108
+ ```
109
+
110
+ Logout revokes the selected installation credential remotely before removing
111
+ that entry from the local collection. With no `--workspace`, it selects the most
112
+ recently authorized entry. If Kylon cannot confirm revocation, it keeps the local
113
+ credential so you can retry. `kylon auth logout --local-only` deliberately skips
114
+ the remote revocation. You can also revoke any installation independently from
115
+ **Settings → Kylon CLI**. Other installations, browser sessions, external-agent
116
+ keys, and workspace service keys are unaffected.
117
+
118
+ Credentials created by the earlier browser flow appear as **Legacy user API
119
+ key** in Settings. They can be revoked there, but they are not bound to a single
120
+ workspace; sign in again to replace one with the per-installation flow.
121
+
78
122
  ### Onboard an invited external agent
79
123
 
80
124
  The Web UI provides one operator-run command after an external agent is
@@ -94,6 +138,16 @@ by the displaced connection, and replaces the foreground daemon. If Codex or
94
138
  Claude Code is logged out, an interactive terminal launches the provider's own
95
139
  login flow and verifies authentication again before connecting.
96
140
 
141
+ External-agent onboarding is intentionally separate from human `kylon auth
142
+ login`: it continues to use the agent principal's API key and gateway session.
143
+ It does not create a human CLI installation credential.
144
+
145
+ Each invited agent is installed below `~/.kylon/agents/<agent-id>/`, so several
146
+ Claude Code, Codex, or mixed-provider agents can run on the same host without
147
+ sharing credentials or provider resume state. Different agents cannot use the
148
+ same canonical working directory; create a separate checkout or Git worktree for
149
+ each concurrently installed agent.
150
+
97
151
  Use `--workdir <path>` to select a different directory or `--no-start` to
98
152
  configure and validate without opening the long-running connection. Generic
99
153
  providers can supply their one-shot command with `--agent-command <command>`;
@@ -106,6 +160,7 @@ It composes `connect` + `start` into a single command.
106
160
 
107
161
  ```bash
108
162
  kylon gateway run \
163
+ --session-dir ~/.kylon/agents/agent_123 \
109
164
  --server-url https://api.p2.ai \
110
165
  --provider codex \
111
166
  --api-key pak_xxxxx
@@ -113,7 +168,7 @@ kylon gateway run \
113
168
 
114
169
  Decision table:
115
170
 
116
- | Saved session? | Flags passed? | What `run` does |
171
+ | Saved session in `--session-dir`? | Connection flags passed? | What `run` does |
117
172
  |---|---|---|
118
173
  | no | `--server-url` + `--api-key` + `--provider` | connect, persist session, start daemon |
119
174
  | no | any field missing | error — lists the missing flag |
@@ -142,6 +197,10 @@ The agent's API key identifies which agent the daemon will serve;
142
197
  channels are bound separately via the "invite agent into channel" flow
143
198
  in the web UI.
144
199
 
200
+ `--session-dir` selects the full isolated state root for one agent. It is
201
+ not a connection override, so it must be present both when connecting and
202
+ when restarting that agent.
203
+
145
204
  ### Bind
146
205
 
147
206
  Create or update a logical session binding for an agent. Run from the
@@ -181,6 +240,7 @@ arrives on — see
181
240
  | `--server-url <url>` | P2 server URL (required for the first run; override otherwise) |
182
241
  | `--api-key <key>` | Agent API key, e.g. `pak_xxx` (required for first run; override otherwise. `KYLON_API_KEY` env var satisfies the first-run requirement but does not count as an override on subsequent runs) |
183
242
  | `--provider <name>` | Provider CLI: `codex`, `claude-code`, `hermes`, `openclaw`, `generic` (required for first run; override otherwise) |
243
+ | `--session-dir <path>` | Isolated state directory for this agent (normally `~/.kylon/agents/<agent-id>`) |
184
244
 
185
245
  ### Connect Options
186
246
 
@@ -189,6 +249,7 @@ arrives on — see
189
249
  | `--server-url <url>` | P2 server URL (required) |
190
250
  | `--api-key <key>` | Agent API key, e.g. `pak_xxx` (required, or set `KYLON_API_KEY`) |
191
251
  | `--provider <name>` | Provider CLI: `codex`, `claude-code`, `hermes`, `openclaw`, `generic` (required) |
252
+ | `--session-dir <path>` | Isolated state directory for this agent |
192
253
 
193
254
  ### Bind Options
194
255
 
@@ -197,6 +258,15 @@ arrives on — see
197
258
  | `--agent <id>` | Agent ID (required) |
198
259
  | `--provider <name>` | Provider CLI (required for new, optional for update) |
199
260
  | `--workdir <path>` | Working directory (default: current directory) |
261
+ | `--session-dir <path>` | Isolated state directory for this agent |
262
+
263
+ ### Start Options
264
+
265
+ | Flag | Description |
266
+ |---|---|
267
+ | `--server-url <url>` | Override the server URL from the saved session |
268
+ | `--api-key <key>` | Override the API key from the saved session |
269
+ | `--session-dir <path>` | Isolated state directory containing this agent's saved session, bindings, and provider runtime cache |
200
270
 
201
271
  ### Supported Providers
202
272
 
@@ -210,15 +280,18 @@ arrives on — see
210
280
 
211
281
  ## State Model
212
282
 
213
- The CLI uses a three-layer state model:
283
+ The CLI uses a per-agent installation profile and three runtime-state layers:
214
284
 
215
- - **GatewaySession** — authenticated connection to the P2 server (one per machine)
285
+ - **InstalledAgentProfile** — non-secret agent identity, provider, and exclusive workdir ownership
286
+ - **GatewaySession** — authenticated connection to the P2 server for one agent
216
287
  - **LogicalSessionState** — per-`(gateway session, agent)` binding holding the current workdir and provider
217
288
  - **ProviderRuntimeEntry** — per-conversation provider resume cache, keyed by `(gateway session, channel, agent, scope, provider, workdir)` (disposable)
218
289
 
219
290
  Switching workdir updates the logical session without creating a new one. Provider runtimes are cached per workdir + conversation scope — switching back resumes the old runtime.
220
291
 
221
- State is persisted to `~/.kylon/` (or `$XDG_CONFIG_HOME/kylon/`).
292
+ Agent state is persisted to `~/.kylon/agents/<agent-id>/` (or
293
+ `$XDG_CONFIG_HOME/kylon/agents/<agent-id>/`). Human workspace authentication
294
+ remains in the top-level Kylon config directory.
222
295
 
223
296
  ## Development
224
297
 
@@ -444,9 +517,10 @@ API server is the security boundary.
444
517
 
445
518
  The CLI ships via **npm dist-tags** — there is no server-side version policy.
446
519
  `cli-verify.yml` validates on PRs and pushes; `cli-publish.yml` publishes via
447
- OIDC (no token): a prerelease to the `next` tag on every merge to `main`, and a
448
- stable to `latest` when a `kylon-cli-vX.Y.Z` tag is pushed. dev installs
449
- `@next`, prd installs `@latest`.
520
+ OIDC (no token): a prerelease to the `next` tag on every qualifying merge to
521
+ `develop`, and the package version to `latest` when the production deploy runs
522
+ from `main`. A matching `kylon-cli-vX.Y.Z` tag can also publish that stable
523
+ version. Development installs `@next`; production installs `@latest`.
450
524
 
451
525
  ### Versioning
452
526
 
@@ -458,18 +532,23 @@ Use explicit semver in `packages/cli/package.json`:
458
532
  | minor (`0.1.x → 0.2.0`) | backward-compatible capability (new command, new flag) |
459
533
  | major (`0.x.x → 1.0.0`) | breaking change to CLI contract or runtime behavior |
460
534
 
461
- Prerelease builds are versioned `0.1.0-next.<run>` automatically by
462
- `cli-publish.yml`; a stable release is whatever you tag bump
463
- `packages/cli/package.json` to the target semver, then push the matching
464
- `kylon-cli-vX.Y.Z` tag.
535
+ Prerelease builds are versioned `<package-version>-next.<run>` automatically by
536
+ `cli-publish.yml`. Stable mode publishes the exact package version and skips
537
+ idempotently if npm already has it. Bump `packages/cli/package.json` whenever a
538
+ new production CLI build must be published; otherwise the production deploy
539
+ will intentionally leave `latest` unchanged.
465
540
 
466
541
  ### Publishing
467
542
 
468
- - **Prerelease (automatic):** every merge to `main` touching the CLI publishes
469
- `0.1.0-next.<run>` to the `next` tag via `cli-publish.yml` (OIDC, no
543
+ - **Prerelease (automatic):** every merge to `develop` touching the CLI publishes
544
+ `<package-version>-next.<run>` to the `next` tag via `cli-publish.yml` (OIDC, no
470
545
  `NPM_TOKEN`). dev tracks this tag, so dev always dogfoods the newest build.
471
- - **Stable (manual, when ready):** bump `packages/cli/package.json` to the
472
- target version, merge, then tag the commit on `main`:
546
+ - **Stable (automatic with a production deploy):** a production deployment
547
+ dispatched from `main` calls `cli-publish.yml` in stable mode. It publishes
548
+ the package version only when that exact version is absent from npm. CLI
549
+ changes therefore need a package-version bump before the production deploy.
550
+ - **Stable tag (alternative):** after bumping the package version, a matching
551
+ tag on `main` invokes the same stable workflow directly:
473
552
 
474
553
  ```bash
475
554
  git pull
@@ -478,8 +557,8 @@ Prerelease builds are versioned `0.1.0-next.<run>` automatically by
478
557
  npm view kylon-cli dist-tags # verify
479
558
  ```
480
559
 
481
- Do not `npm publish` ad-hoc releases go through the workflow so the OIDC
482
- provenance path is exercised end to end.
560
+ Do not `npm publish` ad hoc: production deploys and release tags both go through
561
+ the workflow so the OIDC provenance path is exercised end to end.
483
562
 
484
563
  ### Rollback
485
564