@pleri/olam-cli 0.1.195 → 0.1.198
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 +52 -0
- package/dist/ask/knowledge-pack.generated.d.ts.map +1 -1
- package/dist/ask/knowledge-pack.generated.js +12 -8
- package/dist/ask/knowledge-pack.generated.js.map +1 -1
- package/dist/commands/auth-list-json.d.ts +34 -0
- package/dist/commands/auth-list-json.d.ts.map +1 -1
- package/dist/commands/auth-list-json.js +24 -0
- package/dist/commands/auth-list-json.js.map +1 -1
- package/dist/commands/auth-migrate.d.ts +212 -0
- package/dist/commands/auth-migrate.d.ts.map +1 -0
- package/dist/commands/auth-migrate.js +465 -0
- package/dist/commands/auth-migrate.js.map +1 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +239 -184
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/bootstrap.d.ts +4 -0
- package/dist/commands/bootstrap.d.ts.map +1 -1
- package/dist/commands/bootstrap.js +6 -0
- package/dist/commands/bootstrap.js.map +1 -1
- package/dist/commands/dispatch.d.ts.map +1 -1
- package/dist/commands/dispatch.js +11 -1
- package/dist/commands/dispatch.js.map +1 -1
- package/dist/commands/doctor.d.ts +33 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +299 -12
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/kg-mirror.d.ts +18 -2
- package/dist/commands/kg-mirror.d.ts.map +1 -1
- package/dist/commands/kg-mirror.js +78 -3
- package/dist/commands/kg-mirror.js.map +1 -1
- package/dist/commands/mcp/complete.d.ts +36 -0
- package/dist/commands/mcp/complete.d.ts.map +1 -0
- package/dist/commands/mcp/complete.js +66 -0
- package/dist/commands/mcp/complete.js.map +1 -0
- package/dist/commands/mcp/index.d.ts +1 -1
- package/dist/commands/mcp/index.d.ts.map +1 -1
- package/dist/commands/mcp/index.js +3 -1
- package/dist/commands/mcp/index.js.map +1 -1
- package/dist/commands/memory/bridge.d.ts +1 -1
- package/dist/commands/memory/bridge.d.ts.map +1 -1
- package/dist/commands/memory/bridge.js +2 -6
- package/dist/commands/memory/bridge.js.map +1 -1
- package/dist/commands/memory/secret.d.ts.map +1 -1
- package/dist/commands/memory/secret.js +4 -3
- package/dist/commands/memory/secret.js.map +1 -1
- package/dist/commands/observe.d.ts +3 -3
- package/dist/commands/observe.d.ts.map +1 -1
- package/dist/commands/observe.js +11 -8
- package/dist/commands/observe.js.map +1 -1
- package/dist/commands/runbooks.d.ts.map +1 -1
- package/dist/commands/runbooks.js +77 -10
- package/dist/commands/runbooks.js.map +1 -1
- package/dist/commands/services-tls.d.ts.map +1 -1
- package/dist/commands/services-tls.js +65 -10
- package/dist/commands/services-tls.js.map +1 -1
- package/dist/commands/services.d.ts +35 -1
- package/dist/commands/services.d.ts.map +1 -1
- package/dist/commands/services.js +153 -32
- package/dist/commands/services.js.map +1 -1
- package/dist/commands/setup-phase-8-kg-hook.d.ts +48 -0
- package/dist/commands/setup-phase-8-kg-hook.d.ts.map +1 -0
- package/dist/commands/setup-phase-8-kg-hook.js +93 -0
- package/dist/commands/setup-phase-8-kg-hook.js.map +1 -0
- package/dist/commands/setup-phase-9-memory-bridge.d.ts +36 -0
- package/dist/commands/setup-phase-9-memory-bridge.d.ts.map +1 -0
- package/dist/commands/setup-phase-9-memory-bridge.js +59 -0
- package/dist/commands/setup-phase-9-memory-bridge.js.map +1 -0
- package/dist/commands/setup.d.ts +34 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +372 -32
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/skills-source.d.ts.map +1 -1
- package/dist/commands/skills-source.js +70 -1
- package/dist/commands/skills-source.js.map +1 -1
- package/dist/commands/update.d.ts +24 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +53 -0
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +31 -8
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/image-digests.json +8 -8
- package/dist/index.js +4487 -2451
- package/dist/lib/auth-backend.d.ts +168 -0
- package/dist/lib/auth-backend.d.ts.map +1 -0
- package/dist/lib/auth-backend.js +172 -0
- package/dist/lib/auth-backend.js.map +1 -0
- package/dist/lib/auth-list-cache.d.ts +67 -0
- package/dist/lib/auth-list-cache.d.ts.map +1 -0
- package/dist/lib/auth-list-cache.js +84 -0
- package/dist/lib/auth-list-cache.js.map +1 -0
- package/dist/lib/auth-list.d.ts +107 -0
- package/dist/lib/auth-list.d.ts.map +1 -0
- package/dist/lib/auth-list.js +123 -0
- package/dist/lib/auth-list.js.map +1 -0
- package/dist/lib/auth-login.d.ts +92 -0
- package/dist/lib/auth-login.d.ts.map +1 -0
- package/dist/lib/auth-login.js +124 -0
- package/dist/lib/auth-login.js.map +1 -0
- package/dist/lib/auth-mutator-backend.d.ts +54 -0
- package/dist/lib/auth-mutator-backend.d.ts.map +1 -0
- package/dist/lib/auth-mutator-backend.js +62 -0
- package/dist/lib/auth-mutator-backend.js.map +1 -0
- package/dist/lib/auth-remote.d.ts +50 -0
- package/dist/lib/auth-remote.d.ts.map +1 -1
- package/dist/lib/auth-remote.js +84 -2
- package/dist/lib/auth-remote.js.map +1 -1
- package/dist/lib/bootstrap-kubernetes.d.ts +69 -10
- package/dist/lib/bootstrap-kubernetes.d.ts.map +1 -1
- package/dist/lib/bootstrap-kubernetes.js +264 -46
- package/dist/lib/bootstrap-kubernetes.js.map +1 -1
- package/dist/lib/config.d.ts +35 -4
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +82 -11
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/health-probes.d.ts +0 -22
- package/dist/lib/health-probes.d.ts.map +1 -1
- package/dist/lib/health-probes.js +57 -0
- package/dist/lib/health-probes.js.map +1 -1
- package/dist/lib/peripheral-registry.d.ts +11 -0
- package/dist/lib/peripheral-registry.d.ts.map +1 -1
- package/dist/lib/peripheral-registry.js +5 -0
- package/dist/lib/peripheral-registry.js.map +1 -1
- package/dist/lib/plans-client.d.ts.map +1 -1
- package/dist/lib/plans-client.js +6 -3
- package/dist/lib/plans-client.js.map +1 -1
- package/dist/mcp-server.js +138 -6
- package/hermes-bundle/version.json +1 -1
- package/host-cp/k8s/manifests/30-configmap.yaml +4 -0
- package/host-cp/k8s/manifests/50-deployment.yaml +13 -1
- package/host-cp/k8s/manifests/65-tls-secret-template.yaml.tmpl +35 -0
- package/host-cp/k8s/manifests/auth-service/50-deployment.yaml +1 -1
- package/host-cp/k8s/manifests/kg-service/50-deployment.yaml +1 -1
- package/host-cp/k8s/manifests/mcp-auth-service/50-deployment.yaml +1 -1
- package/host-cp/k8s/manifests/memory-service/50-deployment.yaml +1 -1
- package/host-cp/src/dispatch-persister.mjs +157 -0
- package/host-cp/src/pr-nanny.mjs +7 -0
- package/host-cp/src/server.mjs +175 -3
- package/host-cp/src/world-watchdog-pid-lookup.mjs +119 -0
- package/host-cp/src/world-watchdog-probes.mjs +271 -0
- package/host-cp/src/world-watchdog-recovery.mjs +192 -0
- package/host-cp/src/world-watchdog.mjs +313 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -186,6 +186,58 @@ olam upgrade -y # pull latest digests; restart services
|
|
|
186
186
|
|
|
187
187
|
JSONL audit log at `~/.olam/upgrade.log`.
|
|
188
188
|
|
|
189
|
+
## Cloud-only auth vault (Phase B)
|
|
190
|
+
|
|
191
|
+
Olam's credential vault ships two migration phases:
|
|
192
|
+
|
|
193
|
+
**Phase A** (`@olam/auth-client` — already live): `withCredential` selects the
|
|
194
|
+
cloud auth-worker by default. Resolution order:
|
|
195
|
+
1. `OLAM_CREDENTIAL_BACKEND=local` → local `olam-auth` container at `127.0.0.1:9999`.
|
|
196
|
+
2. `OLAM_CREDENTIAL_BACKEND=remote` → cloud auth-worker.
|
|
197
|
+
3. Auto-discovery via `OLAM_ANTHROPIC_BASE_URL` / `~/.olam/anthropic-base-url` / `~/.olam/cloud-bearer.json`.
|
|
198
|
+
4. Hard-coded fallback → cloud auth-worker (`https://auth-worker.kaluga.co`).
|
|
199
|
+
|
|
200
|
+
**Phase B** (CLI — this package): `olam auth login | list | list-json` default to
|
|
201
|
+
the cloud auth-worker. Operators with an existing local vault can migrate:
|
|
202
|
+
|
|
203
|
+
```sh
|
|
204
|
+
# Plan the migration (read-only, no writes)
|
|
205
|
+
olam auth migrate --dry-run
|
|
206
|
+
|
|
207
|
+
# Run the migration
|
|
208
|
+
olam auth migrate
|
|
209
|
+
|
|
210
|
+
# Opt out: stay on the local container vault
|
|
211
|
+
olam auth login --local
|
|
212
|
+
olam auth list --local
|
|
213
|
+
OLAM_CREDENTIAL_BACKEND=local olam auth list # host-wide env override; no deprecation warning
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
`--local` emits a deprecation warning. The flag will be removed in a future
|
|
217
|
+
release. `OLAM_CREDENTIAL_BACKEND=local` is the quiet host-wide opt-out.
|
|
218
|
+
|
|
219
|
+
**Deferred (OQ7):** `olam auth refresh | disable | enable` are LOCAL ONLY pending
|
|
220
|
+
the admin-mutator UX design tracked in
|
|
221
|
+
[`docs/plans/cloud-only-vault/README.md`](https://github.com/pleri/olam/blob/main/docs/plans/cloud-only-vault/README.md).
|
|
222
|
+
|
|
223
|
+
### `olam doctor` — auth vault health
|
|
224
|
+
|
|
225
|
+
`olam doctor` reports both backends' health at probe position 4:
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
✓ auth vault remote (auth-worker.kaluga.co) healthy (42ms); local (olam-auth:9999) absent
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Three remote states: `healthy` / `unreachable` / `unauthenticated`.
|
|
232
|
+
Three local states: `present-active` / `present-stale` / `absent`.
|
|
233
|
+
|
|
234
|
+
When both backends are present (`remote=healthy` + `local=present-active|present-stale`),
|
|
235
|
+
doctor suggests `olam auth migrate --dry-run` to plan cloud migration.
|
|
236
|
+
|
|
237
|
+
Full design:
|
|
238
|
+
[`docs/architecture/cloud-only-vault.md`](https://github.com/pleri/olam/blob/main/docs/architecture/cloud-only-vault.md),
|
|
239
|
+
[`docs/plans/cloud-only-vault/README.md`](https://github.com/pleri/olam/blob/main/docs/plans/cloud-only-vault/README.md).
|
|
240
|
+
|
|
189
241
|
## Docs
|
|
190
242
|
|
|
191
243
|
- [Full README](https://github.com/pleri/olam#readme)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-pack.generated.d.ts","sourceRoot":"","sources":["../../src/ask/knowledge-pack.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"knowledge-pack.generated.d.ts","sourceRoot":"","sources":["../../src/ask/knowledge-pack.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,cAAc,EAAE,MA+yE5B,CAAC"}
|
|
@@ -2253,7 +2253,7 @@ Top-level commands (run \`olam <command> --help\` for flags and subcommands):
|
|
|
2253
2253
|
- \`olam add\` — Register a local repo path
|
|
2254
2254
|
- \`olam admin\` — Admin operations (require admin secret)
|
|
2255
2255
|
- \`olam aggregate\` — Aggregate plan stats by operator (gate #3 measurement)
|
|
2256
|
-
- \`olam apply\` — Create a world from a runbook (delegates to
|
|
2256
|
+
- \`olam apply\` — Create a world from a runbook spec (port-validates then delegates to WorldManager.createWorld)
|
|
2257
2257
|
- \`olam apply-overlays\` — Merge ~/.claude/skills.overrides/ and ~/.claude/agents.overrides/ over upstream (section-as-unit merge per markdown-merger)
|
|
2258
2258
|
- \`olam ask\` — Ask olam about its own usage, setup, and CLI (local Claude subscription)
|
|
2259
2259
|
- \`olam audit-log\` — Inspect the manifest-refresh audit log (~/.olam/state/manifest-refresh-audit.jsonl).
|
|
@@ -2264,6 +2264,7 @@ Top-level commands (run \`olam <command> --help\` for flags and subcommands):
|
|
|
2264
2264
|
- \`olam bootstrap\` — One-shot wiring of a fresh Hermes install to olam (MCP + KG hook + skill mirror)
|
|
2265
2265
|
- \`olam build\` — Build pristine KG for a workspace (default: current dir). Routes through olam-kg-service /build endpoint. Use --pending to drain the pending queue.
|
|
2266
2266
|
- \`olam check-ports\` — Check if runbook ports are available
|
|
2267
|
+
- \`olam classify\` — Route a query through the remote edge classifier (POST /v1/classify on the proxy Worker)
|
|
2267
2268
|
- \`olam clean\` — Reap orphaned world filesystem state
|
|
2268
2269
|
- \`olam completion\` — Emit a shell completion script for zsh or bash
|
|
2269
2270
|
- \`olam config\` — Manage global olam configuration
|
|
@@ -2273,11 +2274,11 @@ Top-level commands (run \`olam <command> --help\` for flags and subcommands):
|
|
|
2273
2274
|
- \`olam destroy\` — Destroy a world and clean up its resources
|
|
2274
2275
|
- \`olam diagnose\` — Bundle diagnostics into a zip file for sharing with maintainers
|
|
2275
2276
|
- \`olam diff\` — Show what
|
|
2276
|
-
- \`olam disable\` — Take a credential out of rotation (manual cooldown)
|
|
2277
|
+
- \`olam disable\` — Take a credential out of rotation (manual cooldown). LOCAL ONLY — no cloud equivalent yet (see OQ7 in docs/plans/cloud-only-vault/README.md).
|
|
2277
2278
|
- \`olam dispatch\` — Send a prompt to a world for execution
|
|
2278
2279
|
- \`olam doctor\` — Run 4 diagnostic probes against the remote auth-worker
|
|
2279
2280
|
- \`olam down\` — [deprecated] Stop the auth container — use
|
|
2280
|
-
- \`olam enable\` — Re-enable a disabled credential
|
|
2281
|
+
- \`olam enable\` — Re-enable a disabled credential. LOCAL ONLY — no cloud equivalent yet (see OQ7 in docs/plans/cloud-only-vault/README.md).
|
|
2281
2282
|
- \`olam enter\` — Open terminal to a world
|
|
2282
2283
|
- \`olam evict\` — Evict oldest snapshots until total size ≤ cap (default 5GB; override via OLAM_SNAPSHOT_MAX_BYTES)
|
|
2283
2284
|
- \`olam get\` — Print the active substrate
|
|
@@ -2292,15 +2293,16 @@ Top-level commands (run \`olam <command> --help\` for flags and subcommands):
|
|
|
2292
2293
|
- \`olam keys\` — Manage LLM API keys stored at ~/.olam/keys.yaml
|
|
2293
2294
|
- \`olam kg\` — Knowledge-graph operations (kg-service container)
|
|
2294
2295
|
- \`olam lanes\` — Manage claude-lane-* tmux sessions inside a running world
|
|
2295
|
-
- \`olam list\` — List credentials (
|
|
2296
|
+
- \`olam list\` — List credentials. Defaults to the cloud auth-worker (Phase B). Pass --local to read the legacy ~/.olam/auth-data/accounts.json (emits deprecation warning).
|
|
2296
2297
|
- \`olam list-anthropic-tokens\` — List Anthropic proxy tokens from the remote auth-worker (g4)
|
|
2297
|
-
- \`olam login\` —
|
|
2298
|
+
- \`olam login\` — Log into the cloud auth-worker by default (Phase B); use --local to opt into the legacy local auth-service container PKCE flow.
|
|
2298
2299
|
- \`olam logout\` — Remove an account from the auth container
|
|
2299
2300
|
- \`olam logs\` — Stream application logs from a world (engine-agnostic)
|
|
2301
|
+
- \`olam migrate\` — Migrate local ~/.olam/auth-data/accounts.json to the cloud auth-worker.
|
|
2300
2302
|
- \`olam migrate-hooks-back\` — Reverse olam-meta hook injection by restoring ~/.claude/settings.json from a B5 snapshot
|
|
2301
|
-
- \`olam migrate-to-remote\` —
|
|
2303
|
+
- \`olam migrate-to-remote\` — (deprecated) renamed to
|
|
2302
2304
|
- \`olam mirror\` — cloud-kg-mirror operations (build via CF Worker, classify at edge)
|
|
2303
|
-
- \`olam observe\` —
|
|
2305
|
+
- \`olam observe\` — redirect to
|
|
2304
2306
|
- \`olam onboard\` — Fresh-install umbrella: register + clone + install SessionStart hook + first sync, in one verb
|
|
2305
2307
|
- \`olam path\` — Print the absolute path to ~/.olam/keys.yaml
|
|
2306
2308
|
- \`olam plans\` — Manage Olam Cloud plans (list / show / rm / re-register)
|
|
@@ -2309,7 +2311,7 @@ Top-level commands (run \`olam <command> --help\` for flags and subcommands):
|
|
|
2309
2311
|
- \`olam prune\` — Delete shadow-backup files older than a duration (e.g. 30d) OR all of them with --all --force
|
|
2310
2312
|
- \`olam ps\` — List running processes in a world container
|
|
2311
2313
|
- \`olam pull\` — Fetch + reset the clone to upstream HEAD
|
|
2312
|
-
- \`olam refresh\` — Force-refresh an account token (substrate-aware: updates kubernetes Secret on k8s substrate)
|
|
2314
|
+
- \`olam refresh\` — Force-refresh an account token (substrate-aware: updates kubernetes Secret on k8s substrate). LOCAL ONLY — no cloud equivalent yet (see OQ7 in docs/plans/cloud-only-vault/README.md).
|
|
2313
2315
|
- \`olam register\` — Register a world with the running host CP so it appears in the unified UI
|
|
2314
2316
|
- \`olam rekey\` — Rotate the per-world postgres password for a hybrid-mode world
|
|
2315
2317
|
- \`olam remove\` — Permanently remove a credential (purge tokens)
|
|
@@ -2326,6 +2328,7 @@ Top-level commands (run \`olam <command> --help\` for flags and subcommands):
|
|
|
2326
2328
|
- \`olam services\` — Manage Olam service containers (up/down/status/logs)
|
|
2327
2329
|
- \`olam set-prefix\` — Set the deploy prefix for a registered skill source (skills+agents deploy as <prefix>:<canonical-name>)
|
|
2328
2330
|
- \`olam set-prefix-scope\` — Set which artifact kinds are renamed by the prefix (comma-separated: skill, agent, or skill,agent)
|
|
2331
|
+
- \`olam set-prefix-target\` — Restrict prefix renaming to canonical names matching the given glob patterns (only * wildcard supported).
|
|
2329
2332
|
- \`olam setup\` — Fresh-host onboarding wizard (k3d cluster + services, idempotent)
|
|
2330
2333
|
- \`olam setup-linux-gate-status\` — Check whether the Linux platform expansion gate has been triggered
|
|
2331
2334
|
- \`olam setup-metrics\` — Query trust-audit-log for setup dogfood statistics
|
|
@@ -2344,6 +2347,7 @@ Top-level commands (run \`olam <command> --help\` for flags and subcommands):
|
|
|
2344
2347
|
- \`olam uninstall-hook\` — Remove kg-service PreToolUse hook from .claude/settings.json (sentinel-matched; surgical)
|
|
2345
2348
|
- \`olam unset-prefix\` — Remove the deploy prefix from a registered skill source (reverts to canonical deploy names)
|
|
2346
2349
|
- \`olam unset-prefix-scope\` — Remove the prefix-scope override from a registered skill source (reverts to default: both skill and agent are renamed)
|
|
2350
|
+
- \`olam unset-prefix-target\` — Remove the prefix-target override from a registered skill source (reverts to default: all canonical names are renamed)
|
|
2347
2351
|
- \`olam up\` — [deprecated] Start the auth container — use
|
|
2348
2352
|
- \`olam update\` — Update a registered repo
|
|
2349
2353
|
- \`olam upgrade\` — Upgrade the olam-auth container. Default: pull olam-auth@<digest> from ghcr.io and recreate.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-pack.generated.js","sourceRoot":"","sources":["../../src/ask/knowledge-pack.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAoB;AAEpB,MAAM,CAAC,MAAM,cAAc,GAAW
|
|
1
|
+
{"version":3,"file":"knowledge-pack.generated.js","sourceRoot":"","sources":["../../src/ask/knowledge-pack.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAoB;AAEpB,MAAM,CAAC,MAAM,cAAc,GAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+yErC,CAAC"}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* AuthAccountSummary and are never emitted.
|
|
20
20
|
*/
|
|
21
21
|
import type { AuthAccountSummary } from '@olam/core/src/auth/types.js';
|
|
22
|
+
import type { AccountEntry } from '../lib/auth-remote.js';
|
|
22
23
|
/** Per-account row in the `auth list --json` payload. */
|
|
23
24
|
export interface AuthListAccountJson {
|
|
24
25
|
readonly id: string;
|
|
@@ -50,4 +51,37 @@ export interface AuthListJson {
|
|
|
50
51
|
* `--json` wire shape. `now` is injectable for deterministic tests.
|
|
51
52
|
*/
|
|
52
53
|
export declare function renderAuthListJson(accounts: readonly AuthAccountSummary[], now?: number): string;
|
|
54
|
+
/**
|
|
55
|
+
* B4 (narrowed) — JSON shape for `olam auth list --json` when the remote
|
|
56
|
+
* backend is active. The remote payload carries less detail than the local
|
|
57
|
+
* one (no `usage` window stats, no `tokenValid` — those are local-only
|
|
58
|
+
* concepts today), so the wire shape is intentionally narrower. The `stale`
|
|
59
|
+
* + `lastFetchedAt` fields surface the in-process cache's freshness so
|
|
60
|
+
* driver scripts can decide whether to retry.
|
|
61
|
+
*/
|
|
62
|
+
export interface AuthListRemoteAccountJson {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly label: string;
|
|
65
|
+
readonly state: string;
|
|
66
|
+
readonly expiresIn: string;
|
|
67
|
+
readonly provider: string | null;
|
|
68
|
+
readonly email: string | null;
|
|
69
|
+
readonly rateLimitResetsAt: string | null;
|
|
70
|
+
readonly weeklyResetsAt: string | null;
|
|
71
|
+
}
|
|
72
|
+
export interface AuthListRemoteJson {
|
|
73
|
+
readonly count: number;
|
|
74
|
+
/** True iff at least one account is in the `active` state. */
|
|
75
|
+
readonly healthy: boolean;
|
|
76
|
+
/** True iff this payload came from the stale-cache fallback. */
|
|
77
|
+
readonly stale: boolean;
|
|
78
|
+
/** Epoch ms of the underlying fetch; informs the operator how old the data is. */
|
|
79
|
+
readonly lastFetchedAt: number;
|
|
80
|
+
readonly accounts: readonly AuthListRemoteAccountJson[];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Serialise the remote `AccountEntry[]` payload to the `--json` wire shape.
|
|
84
|
+
* `stale` + `fetchedAt` propagate from the orchestrator's `RemoteListResult`.
|
|
85
|
+
*/
|
|
86
|
+
export declare function renderRemoteAuthListJson(accounts: ReadonlyArray<AccountEntry>, stale: boolean, fetchedAt: number): string;
|
|
53
87
|
//# sourceMappingURL=auth-list-json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-list-json.d.ts","sourceRoot":"","sources":["../../src/commands/auth-list-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-list-json.d.ts","sourceRoot":"","sources":["../../src/commands/auth-list-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,0DAA0D;AAC1D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAC;CACnD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,EACvC,GAAG,GAAE,MAAmB,GACvB,MAAM,CAsBR;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,gEAAgE;IAChE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,kFAAkF;IAClF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,SAAS,yBAAyB,EAAE,CAAC;CACzD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EACrC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,CAqBR"}
|
|
@@ -44,4 +44,28 @@ export function renderAuthListJson(accounts, now = Date.now()) {
|
|
|
44
44
|
};
|
|
45
45
|
return JSON.stringify(payload);
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Serialise the remote `AccountEntry[]` payload to the `--json` wire shape.
|
|
49
|
+
* `stale` + `fetchedAt` propagate from the orchestrator's `RemoteListResult`.
|
|
50
|
+
*/
|
|
51
|
+
export function renderRemoteAuthListJson(accounts, stale, fetchedAt) {
|
|
52
|
+
const rows = accounts.map((a) => ({
|
|
53
|
+
id: a.id,
|
|
54
|
+
label: a.label ?? a.id,
|
|
55
|
+
state: a.state ?? 'unknown',
|
|
56
|
+
expiresIn: a.expiresIn ?? '',
|
|
57
|
+
provider: a.provider ?? null,
|
|
58
|
+
email: a.email === undefined ? null : a.email,
|
|
59
|
+
rateLimitResetsAt: a.rateLimitResetsAt === undefined ? null : a.rateLimitResetsAt,
|
|
60
|
+
weeklyResetsAt: a.weeklyResetsAt === undefined ? null : a.weeklyResetsAt,
|
|
61
|
+
}));
|
|
62
|
+
const payload = {
|
|
63
|
+
count: rows.length,
|
|
64
|
+
healthy: rows.some((r) => r.state === 'active'),
|
|
65
|
+
stale,
|
|
66
|
+
lastFetchedAt: fetchedAt,
|
|
67
|
+
accounts: rows,
|
|
68
|
+
};
|
|
69
|
+
return JSON.stringify(payload);
|
|
70
|
+
}
|
|
47
71
|
//# sourceMappingURL=auth-list-json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-list-json.js","sourceRoot":"","sources":["../../src/commands/auth-list-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-list-json.js","sourceRoot":"","sources":["../../src/commands/auth-list-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAgCrD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAuC,EACvC,MAAc,IAAI,CAAC,GAAG,EAAE;IAExB,MAAM,IAAI,GAA0B,QAAQ,CAAC,GAAG,CAA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AAE;QAC5B,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,IAAI;QAC5B,KAAK,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;QAC7C,iBAAiB,EAAE,CAAC,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB;QACjF,cAAc,EAAE,CAAC,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc;KACzE,CAAC,CAAC,CAAC;IAEJ,MAAM,OAAO,GAAuB;QAClC,KAAK,EAAE,IAAI,CAAC,MAAM;QAClB,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC;QAC/C,KAAK;QACL,aAAa,EAAE,SAAS;QACxB,QAAQ,EAAE,IAAI;KACf,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* olam auth migrate — one-shot migration tool for operators with a legacy
|
|
3
|
+
* `~/.olam/auth-data/accounts.json` (the file the pre-Phase-A auth-service
|
|
4
|
+
* container wrote OAuth tokens to). Reads each local account and walks the
|
|
5
|
+
* operator through re-authenticating it against the cloud auth-worker.
|
|
6
|
+
*
|
|
7
|
+
* ───────────────────────────────────────────────────────────────────────────
|
|
8
|
+
* IMPORTANT — DESIGN-DOC NOTE FROM B2's AUDIT
|
|
9
|
+
* ───────────────────────────────────────────────────────────────────────────
|
|
10
|
+
*
|
|
11
|
+
* **There is no `POST /v1/credentials` endpoint on the cloud auth-worker DO.**
|
|
12
|
+
* Phase A's design doc (`docs/architecture/cloud-only-vault.md` §3 — "the
|
|
13
|
+
* bearer IS the credential") makes the explicit choice that the cloud vault
|
|
14
|
+
* does not accept already-minted OAuth tokens over HTTP. The only way a
|
|
15
|
+
* credential lands in the DO is via the worker's own OAuth-callback handler
|
|
16
|
+
* after the operator completes the Anthropic device-code dance.
|
|
17
|
+
*
|
|
18
|
+
* So "migrate" here does NOT mean "POST tokens into the cloud DO" (phase-b-
|
|
19
|
+
* tasks.md B3's wording is shorthand). It means: **for each local account,
|
|
20
|
+
* re-run the OAuth-start flow against the cloud auth-worker so the operator
|
|
21
|
+
* re-authenticates that Anthropic account, and the worker's callback stores
|
|
22
|
+
* the resulting token server-side.**
|
|
23
|
+
*
|
|
24
|
+
* The local OAuth token bytes themselves are never sent anywhere — they
|
|
25
|
+
* remain in `~/.olam/auth-data/accounts.json` until the operator approves
|
|
26
|
+
* the final timestamped rename. Local file is NEVER deleted automatically.
|
|
27
|
+
*
|
|
28
|
+
* ───────────────────────────────────────────────────────────────────────────
|
|
29
|
+
* IDEMPOTENCE MODEL
|
|
30
|
+
* ───────────────────────────────────────────────────────────────────────────
|
|
31
|
+
*
|
|
32
|
+
* Per-account migration state lives in `~/.olam/auth-data/migration-state.json`:
|
|
33
|
+
*
|
|
34
|
+
* {
|
|
35
|
+
* "version": 1,
|
|
36
|
+
* "migrated": {
|
|
37
|
+
* "<sha256(stable-content-shape)>": {
|
|
38
|
+
* "migratedAt": "2026-05-29T...Z",
|
|
39
|
+
* "email": "alice@example.com",
|
|
40
|
+
* "provider": "claude"
|
|
41
|
+
* },
|
|
42
|
+
* ...
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* The hash is computed from a STABLE JSON shape (`{email, provider,
|
|
47
|
+
* anthropicAccountId}`) — re-running migrate after the local vault changes
|
|
48
|
+
* picks up new accounts but skips already-migrated ones. Atomic write
|
|
49
|
+
* (write-to-tmp then rename) guarantees that a mid-flight kill resumes
|
|
50
|
+
* cleanly: any account whose state record is durable on disk is skipped;
|
|
51
|
+
* the rest are re-attempted.
|
|
52
|
+
*
|
|
53
|
+
* ───────────────────────────────────────────────────────────────────────────
|
|
54
|
+
* CLI SURFACE
|
|
55
|
+
* ───────────────────────────────────────────────────────────────────────────
|
|
56
|
+
*
|
|
57
|
+
* olam auth migrate # default: interactive live-run
|
|
58
|
+
* olam auth migrate --dry-run # print the per-account plan only
|
|
59
|
+
* olam auth migrate --remote <url> # override auth-worker URL
|
|
60
|
+
* olam auth migrate --yes # CI safety; only valid w/ --dry-run
|
|
61
|
+
*/
|
|
62
|
+
import type { Command } from 'commander';
|
|
63
|
+
import { DEFAULT_AUTH_WORKER_URL } from '../lib/auth-login.js';
|
|
64
|
+
import { printError, printHeader, printSuccess } from '../output.js';
|
|
65
|
+
/**
|
|
66
|
+
* A row from the legacy local vault. The pre-Phase-A `auth-service` container
|
|
67
|
+
* wrote a richer record than this; for migration purposes we only need the
|
|
68
|
+
* three fields that uniquely identify an Anthropic account.
|
|
69
|
+
*/
|
|
70
|
+
export interface LocalAccount {
|
|
71
|
+
readonly email: string;
|
|
72
|
+
readonly provider: string;
|
|
73
|
+
readonly anthropicAccountId?: string;
|
|
74
|
+
/** Optional label the operator gave the account at login time. */
|
|
75
|
+
readonly label?: string;
|
|
76
|
+
}
|
|
77
|
+
/** Shape of `~/.olam/auth-data/accounts.json` (the legacy vault file). */
|
|
78
|
+
export interface LocalAccountsFile {
|
|
79
|
+
readonly accounts: readonly LocalAccount[];
|
|
80
|
+
}
|
|
81
|
+
/** Per-hash record in `migration-state.json`. */
|
|
82
|
+
export interface MigrationRecord {
|
|
83
|
+
readonly migratedAt: string;
|
|
84
|
+
readonly email: string;
|
|
85
|
+
readonly provider: string;
|
|
86
|
+
}
|
|
87
|
+
/** Shape of `~/.olam/auth-data/migration-state.json`. */
|
|
88
|
+
export interface MigrationState {
|
|
89
|
+
readonly version: 1;
|
|
90
|
+
readonly migrated: Readonly<Record<string, MigrationRecord>>;
|
|
91
|
+
}
|
|
92
|
+
/** Per-account decision in the migration plan. */
|
|
93
|
+
export interface PlannedAccount {
|
|
94
|
+
readonly account: LocalAccount;
|
|
95
|
+
readonly hash: string;
|
|
96
|
+
readonly status: 'pending' | 'already-migrated';
|
|
97
|
+
readonly migratedRecord?: MigrationRecord;
|
|
98
|
+
}
|
|
99
|
+
/** Options parsed from Commander for `olam auth migrate`. */
|
|
100
|
+
export interface AuthMigrateOptions {
|
|
101
|
+
readonly local?: boolean;
|
|
102
|
+
readonly remote?: boolean | string;
|
|
103
|
+
readonly dryRun?: boolean;
|
|
104
|
+
readonly yes?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** Result of a `runAuthMigrate` invocation (drives `process.exitCode`). */
|
|
107
|
+
export interface AuthMigrateResult {
|
|
108
|
+
readonly exitCode: 0 | 1;
|
|
109
|
+
/** Total accounts in the local vault (zero when the file is absent). */
|
|
110
|
+
readonly accountsTotal?: number;
|
|
111
|
+
/** Accounts that were already-migrated at start. */
|
|
112
|
+
readonly accountsAlreadyMigrated?: number;
|
|
113
|
+
/** Accounts that completed migration during THIS invocation. */
|
|
114
|
+
readonly accountsMigratedNow?: number;
|
|
115
|
+
/** Accounts the operator skipped this run. */
|
|
116
|
+
readonly accountsSkipped?: number;
|
|
117
|
+
/** True when --dry-run was honoured (no live OAuth). */
|
|
118
|
+
readonly dryRun?: boolean;
|
|
119
|
+
/** Resolved auth-worker URL for the live-run case. */
|
|
120
|
+
readonly resolvedRemoteUrl?: string;
|
|
121
|
+
}
|
|
122
|
+
export interface AuthMigrateDeps {
|
|
123
|
+
/** Absolute path to ~/.olam/auth-data/accounts.json. */
|
|
124
|
+
readonly accountsPath?: string;
|
|
125
|
+
/** Absolute path to ~/.olam/auth-data/migration-state.json. */
|
|
126
|
+
readonly statePath?: string;
|
|
127
|
+
/** fs.readFileSync surrogate (defaults to real fs). */
|
|
128
|
+
readonly readFileSync?: (p: string) => string;
|
|
129
|
+
/** fs.writeFileSync surrogate (defaults to real fs). */
|
|
130
|
+
readonly writeFileSync?: (p: string, data: string) => void;
|
|
131
|
+
/** fs.renameSync surrogate (defaults to real fs). */
|
|
132
|
+
readonly renameSync?: (from: string, to: string) => void;
|
|
133
|
+
/** fs.existsSync surrogate (defaults to real fs). */
|
|
134
|
+
readonly existsSync?: (p: string) => boolean;
|
|
135
|
+
/** Returns the current ISO timestamp (defaults to new Date().toISOString()). */
|
|
136
|
+
readonly now?: () => string;
|
|
137
|
+
/** Reads OLAM_AUTH_WORKER_URL env var (resolveRemoteUrl). */
|
|
138
|
+
readonly readEnv?: (key: string) => string | undefined;
|
|
139
|
+
/** Reads ~/.olam/auth-worker-url file (resolveRemoteUrl). */
|
|
140
|
+
readonly readAuthWorkerUrlFile?: () => string | null;
|
|
141
|
+
/** True when stdin is a TTY (interactive prompts are meaningful). */
|
|
142
|
+
readonly isTty?: () => boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Per-account interactive prompt:
|
|
145
|
+
* q = abort migration; s = skip this account; anything else = proceed.
|
|
146
|
+
* Returns the operator's raw answer; runAuthMigrate interprets.
|
|
147
|
+
*/
|
|
148
|
+
readonly promptPerAccount?: (question: string) => Promise<string>;
|
|
149
|
+
/** Final "rename local vault?" prompt (yes / no). */
|
|
150
|
+
readonly promptFinalRename?: (question: string) => Promise<string>;
|
|
151
|
+
/** Where banner + table output goes. Defaults to process.stdout. */
|
|
152
|
+
readonly stdout?: NodeJS.WritableStream;
|
|
153
|
+
/** Where errors + warnings go. Defaults to process.stderr. */
|
|
154
|
+
readonly stderr?: NodeJS.WritableStream;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Stable content hash for an account. Two accounts with identical
|
|
158
|
+
* (email, provider, anthropicAccountId) tuples produce the same hash —
|
|
159
|
+
* the operator deleting + re-adding the same Anthropic account locally
|
|
160
|
+
* still resolves to "already migrated" on the cloud side. Tests rely on
|
|
161
|
+
* this invariant being stable (no random salt, no time component).
|
|
162
|
+
*/
|
|
163
|
+
export declare function accountContentHash(account: LocalAccount): string;
|
|
164
|
+
/** Empty initial migration state (version 1). */
|
|
165
|
+
export declare function emptyMigrationState(): MigrationState;
|
|
166
|
+
/**
|
|
167
|
+
* Read + parse migration-state.json. Returns `emptyMigrationState()` when
|
|
168
|
+
* the file is absent (first-ever migrate run). Throws on parse-failure or
|
|
169
|
+
* version drift so the caller can exit 1 with a manual-inspection message.
|
|
170
|
+
*/
|
|
171
|
+
export declare function readMigrationState(statePath: string, deps: Pick<AuthMigrateDeps, 'existsSync' | 'readFileSync'>): MigrationState;
|
|
172
|
+
/**
|
|
173
|
+
* Atomically write migration state. Strategy: serialise to `<path>.tmp`,
|
|
174
|
+
* then `rename` over the live file. The rename is atomic on POSIX (and on
|
|
175
|
+
* NTFS via ReplaceFileEx semantics); a process kill between the .tmp write
|
|
176
|
+
* and the rename leaves the live file untouched.
|
|
177
|
+
*
|
|
178
|
+
* Throws on write or rename failure; caller is expected to surface the
|
|
179
|
+
* error and exit 1 without touching anything else.
|
|
180
|
+
*/
|
|
181
|
+
export declare function writeMigrationStateAtomic(statePath: string, state: MigrationState, deps: Pick<AuthMigrateDeps, 'writeFileSync' | 'renameSync'>): void;
|
|
182
|
+
/**
|
|
183
|
+
* Read + parse the legacy local vault file. Returns `null` when absent
|
|
184
|
+
* (the "nothing to migrate" path). Throws on parse failure.
|
|
185
|
+
*/
|
|
186
|
+
export declare function readLocalAccounts(accountsPath: string, deps: Pick<AuthMigrateDeps, 'existsSync' | 'readFileSync'>): LocalAccountsFile | null;
|
|
187
|
+
/**
|
|
188
|
+
* Pure planner — given the local accounts + the migration state, decide
|
|
189
|
+
* what each account's status is. No IO; trivial to unit-test.
|
|
190
|
+
*/
|
|
191
|
+
export declare function planMigration(accounts: readonly LocalAccount[], state: MigrationState): PlannedAccount[];
|
|
192
|
+
/**
|
|
193
|
+
* Run the `olam auth migrate` decision tree. Every IO touchpoint is funnelled
|
|
194
|
+
* through `AuthMigrateDeps` so tests assert on orchestration without spawning
|
|
195
|
+
* real OAuth round-trips, filesystem writes, or readline reads.
|
|
196
|
+
*/
|
|
197
|
+
export declare function runAuthMigrate(opts: AuthMigrateOptions, deps?: AuthMigrateDeps): Promise<AuthMigrateResult>;
|
|
198
|
+
/**
|
|
199
|
+
* Register `olam auth migrate` on the supplied `auth` subcommand. Called
|
|
200
|
+
* from `packages/cli/src/commands/auth.ts`.
|
|
201
|
+
*/
|
|
202
|
+
export declare function registerAuthMigrate(auth: Command): void;
|
|
203
|
+
export { DEFAULT_AUTH_WORKER_URL };
|
|
204
|
+
export declare const _internal: {
|
|
205
|
+
printError: typeof printError;
|
|
206
|
+
printHeader: typeof printHeader;
|
|
207
|
+
printSuccess: typeof printSuccess;
|
|
208
|
+
pc: import("picocolors/types.js").Colors & {
|
|
209
|
+
createColors: (enabled?: boolean) => import("picocolors/types.js").Colors;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
//# sourceMappingURL=auth-migrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-migrate.d.ts","sourceRoot":"","sources":["../../src/commands/auth-migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,OAAO,EAAoB,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIrE;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,kEAAkE;IAClE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,0EAA0E;AAC1E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,C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