passport-bridge 0.24.0 → 0.25.0

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.
Files changed (86) hide show
  1. package/README.md +69 -30
  2. package/dist/cliArgs.d.ts +1 -1
  3. package/dist/cliArgs.js +17 -6
  4. package/dist/cliAutopilot.js +15 -4
  5. package/dist/cliAutopilotPolicy.d.ts +8 -0
  6. package/dist/cliAutopilotPolicy.js +23 -1
  7. package/dist/cliChanges.d.ts +80 -0
  8. package/dist/cliChanges.js +340 -0
  9. package/dist/cliClient.d.ts +5 -0
  10. package/dist/cliClient.js +15 -3
  11. package/dist/cliHook.d.ts +1 -1
  12. package/dist/cliHook.js +35 -35
  13. package/dist/cliHookAudit.d.ts +44 -0
  14. package/dist/cliHookAudit.js +57 -0
  15. package/dist/cliHookDecide.js +3 -1
  16. package/dist/cliHookDeliver.d.ts +8 -0
  17. package/dist/cliHookDeliver.js +25 -0
  18. package/dist/cliHookGuard.d.ts +16 -1
  19. package/dist/cliHookGuard.js +31 -10
  20. package/dist/cliHookInput.d.ts +3 -0
  21. package/dist/cliHookInput.js +13 -0
  22. package/dist/cliHookLocal.d.ts +3 -2
  23. package/dist/cliHookLocal.js +5 -2
  24. package/dist/cliHookRewrite.d.ts +2 -0
  25. package/dist/cliHookRewrite.js +1 -1
  26. package/dist/cliKeys.js +11 -1
  27. package/dist/cliKeysRotate.d.ts +24 -0
  28. package/dist/cliKeysRotate.js +149 -0
  29. package/dist/cliMain.js +56 -15
  30. package/dist/cliOutput.js +41 -5
  31. package/dist/cliPolicyV2.js +14 -0
  32. package/dist/cliProjectSummary.d.ts +9 -0
  33. package/dist/cliProjectSummary.js +134 -0
  34. package/dist/cliProtocol.d.ts +10 -0
  35. package/dist/cliProtocol.js +15 -0
  36. package/dist/cliRequest.d.ts +27 -0
  37. package/dist/cliRequest.js +92 -0
  38. package/dist/cliRestoreRequests.d.ts +57 -0
  39. package/dist/cliRestoreRequests.js +186 -0
  40. package/dist/cliSessions.d.ts +3 -0
  41. package/dist/cliSessions.js +24 -1
  42. package/dist/cliSessionsJson.d.ts +48 -2
  43. package/dist/cliSessionsJson.js +7 -9
  44. package/dist/cliSessionsRender.d.ts +8 -3
  45. package/dist/cliSessionsRender.js +16 -7
  46. package/dist/cliUndo.d.ts +1 -3
  47. package/dist/cliUndo.js +9 -15
  48. package/dist/cliUndoLocal.d.ts +27 -0
  49. package/dist/cliUndoLocal.js +105 -0
  50. package/dist/cliUpdate.d.ts +29 -0
  51. package/dist/cliUpdate.js +195 -0
  52. package/dist/cliWait.js +2 -2
  53. package/dist/completion.js +6 -1
  54. package/dist/doctor.js +4 -0
  55. package/dist/execNoKey.d.ts +4 -4
  56. package/dist/execNoKey.js +17 -11
  57. package/dist/gitBackup.d.ts +111 -0
  58. package/dist/gitBackup.js +391 -0
  59. package/dist/gitSnapshot.d.ts +82 -0
  60. package/dist/gitSnapshot.js +478 -0
  61. package/dist/initInstall.d.ts +22 -0
  62. package/dist/initInstall.js +70 -1
  63. package/dist/localBackups.d.ts +102 -0
  64. package/dist/localBackups.js +233 -0
  65. package/dist/localGit.d.ts +24 -0
  66. package/dist/localGit.js +44 -0
  67. package/dist/localRestore.d.ts +42 -0
  68. package/dist/localRestore.js +94 -0
  69. package/dist/localTrash.d.ts +97 -0
  70. package/dist/localTrash.js +394 -0
  71. package/dist/pluginPin.d.ts +1 -1
  72. package/dist/pluginPin.js +1 -1
  73. package/dist/plural.d.ts +2 -0
  74. package/dist/plural.js +13 -0
  75. package/dist/regenerable.d.ts +24 -0
  76. package/dist/regenerable.js +219 -0
  77. package/dist/selfUpdate.d.ts +92 -0
  78. package/dist/selfUpdate.js +361 -0
  79. package/dist/selfUpdateContract.d.ts +20 -0
  80. package/dist/selfUpdateContract.js +56 -0
  81. package/dist/updateTrigger.d.ts +18 -0
  82. package/dist/updateTrigger.js +77 -0
  83. package/dist/version.d.ts +1 -1
  84. package/dist/version.js +1 -1
  85. package/npm-shrinkwrap.json +2 -2
  86. package/package.json +1 -1
package/README.md CHANGED
@@ -13,7 +13,7 @@ Member profiles get the same tool access, agent selection, guardrails, approvals
13
13
  npm install --global passport-bridge
14
14
  ```
15
15
 
16
- Requires Node.js 22.23.2 or newer. `npx passport-bridge@latest scan` and `npx passport-bridge@latest init` need no install and run on Node.js 20 or newer; `scan` also needs no account. `@latest` keeps an older global install from running instead. The CLI makes no background registry request, telemetry, or self-update; check with `npm view passport-bridge version` and upgrade with `npm install --global passport-bridge@latest`.
16
+ Requires Node.js 22.23.2 or newer. `npx passport-bridge@latest scan` and `npx passport-bridge@latest init` need no install and run on Node.js 20 or newer; `scan` also needs no account. `@latest` keeps an older global install from running instead. The CLI makes no background registry request or telemetry. It updates itself only to the exact version Passport names, when you or your admin ask for it on **Agents** or you run `passport update` (see [Updates](#updates)); `npm install --global passport-bridge@<version>` works too.
17
17
 
18
18
  ## Quick start
19
19
 
@@ -44,6 +44,7 @@ passport run github_search_issues '{"query":"SSO"}'
44
44
  - `--no-open` (or `PASSPORT_NO_OPEN=1`) prints the sign-in link instead of opening a browser. Use it over SSH and in headless sessions; open the link on any device.
45
45
  - Remote servers must use HTTPS. Plain HTTP works only on `localhost`, `127.0.0.0/8`, or `::1`.
46
46
  - Requires a gateway reporting serverInfo `passport` 0.5.0 or newer with the four-tool CLI protocol; older servers fail before any tool call.
47
+ - A profile saved by `passport-bridge login` belongs to an agent, not the CLI. `status`, `doctor`, and every gateway command say so (`This sign-in was made for an agent by passport-bridge login, so Passport CLI can't use it.`, exit 2, cause `agent_sign_in`) and name `passport login` (with `--cloud <origin>` off passportmcp.com); the agent keeps its own sign-in.
47
48
  - `passport help [command]` documents every option. `help`, `version`, `profiles`, `use`, and `completion` work offline.
48
49
 
49
50
  ## Commands
@@ -62,6 +63,7 @@ passport run github_search_issues '{"query":"SSO"}'
62
63
  | `describe <tool>` | One exact definition with its full parameter schema. |
63
64
  | `run <tool> [json]` | Run a tool through Passport governance. |
64
65
  | `connect [app...] [--alias <name>] [--open] [--wait <s>]` | Show member sign-in links and optionally wait for completion. |
66
+ | `request <app> [--full] --reason "<why>"` | Ask an admin for an app you don't have, or for Full access where you have Read-only. A person decides in Passport; nothing is granted here. See [Asking for access](#asking-for-access). |
65
67
  | `resources [uri] [--out <file>]` | List or read MCP resources. |
66
68
  | `prompts [name] [--set k=v] [--out <file>]` | List or get MCP prompts. |
67
69
  | `scan [--path <dir>] [--verbose] [--check]` | Find keys your agents can reach on this computer and what each can do, without an account. Signed in, also report the MCP servers set up in your agents to your workspace and exit 5 when its policy doesn't allow one. `--check` scans files only (not the shell environment), never reports, and exits 5 on a high or medium key. |
@@ -69,10 +71,12 @@ passport run github_search_issues '{"query":"SSO"}'
69
71
  | `wait <approval-id> [--timeout <s>]` | Wait for a person to decide an approval request, until they do or it expires. Agents run it in the background. |
70
72
  | `rules test "<command>" [--environment <kind>]` | What Autopilot decides for a command, why, and which environment it acts on. |
71
73
  | `sessions [--all\|--running\|--production-changes] [--project <name>] [--pr <n>] [--since <when>]`, `sessions <id>` | Your agents' work items by project, Notable first; the Production changes ledger; or one session's outcome and recent actions. |
74
+ | `changes [--env production] [--since <when>] [--until <date>]` | What your agents changed in Production, one row each, grouped by app and newest first. |
72
75
  | `undo <action-id>\|--last [--option <id>] [--yes]` | Undo an action Passport took a backup before, within 7 days. See [Undo](#undo). |
73
76
  | `setup` | Install and maintain assigned team workflows as managed skills. |
74
77
  | `session` | Run NDJSON commands over one authenticated MCP session. |
75
78
  | `access` | Signed managed access: `keygen`, `actions`, `run`, `invoke`, `status`, `cancel`. |
79
+ | `update`, `update check`, `update off\|on` | Install the exact version Passport names, check what runs here, or turn automatic updates off on this computer. See [Updates](#updates). |
76
80
  | `completion <bash\|zsh\|fish>` | Print a completion script. Offline. |
77
81
  | `help [command]`, `version` | Help; package version and local profile context. |
78
82
 
@@ -101,6 +105,17 @@ passport connect github --wait 120
101
105
  - The CLI never retries after a network failure or timeout, since the outcome is unknown.
102
106
  - `connect` with no app names uses one aggregate link when several apps need sign-in. Agent tokens get guidance but cannot create sign-in links.
103
107
 
108
+ ### Asking for access
109
+
110
+ ```sh
111
+ passport request github --full --reason "Open the release pull request for the fix"
112
+ passport request linear --reason "Triage this week's bugs"
113
+ ```
114
+
115
+ - `request` files the same request an agent's `passport_request_access` files (`POST /api/my/app-requests`), into the queue admins already answer. It prints `Asked: Full access to GitHub. An admin at Acme decides.` and `Run your command again once it's approved.`; asking again for the same thing says `Already asked`. Where the workspace lets you add the app yourself, or you already have it, it says so and files nothing. `--json` prints `{filed:true,requestId,status,what,created,app}` or `{filed:false,message,app}`.
116
+ - The reason (10 to 280 characters) goes to the admin. Agent tokens can't ask: their owner does. Ten requests an hour per person, shared with agents.
117
+ - A Read-only or No access block names it: `You have read-only access to GitHub in Passport, so only reads run. Ask an admin for full access: passport request github --full --reason "<why>"`, then the app's Access link on the next line.
118
+
104
119
  ### Resources and prompts
105
120
 
106
121
  ```sh
@@ -221,7 +236,7 @@ Two hooks per agent. `passport hook` runs after each shell command and records t
221
236
 
222
237
  - **Allow** (Claude Code `permissionDecision: "allow"`, Cursor `permission: "allow"`) only when every part of the line is understood and allowed: vendor commands in `src/cliHookVendors.ts` read with confidence, and everyday commands (below). Substitutions, heredocs, variables in a path, unknown wrappers or environment prefixes, scripts, aliases, `make`, and programs Passport doesn't know mean no decision, so the agent's own permission rules apply. Codex can't receive allow; its own approvals apply (see `passport sync`).
223
238
  - **Ask** or **deny** when any recognized command needs it. The strictest part of a compound command wins and names itself. `--help` and `--dry-run` never ask.
224
- - Each reason names its cause in one line: `Passport: railway redeploy changes Production. Approve to run it.`, or `Blocked by a team rule: no deletes in Production. Ask an admin to run it, or request an exception in Passport.` (a cause that isn't a rule reads `Blocked by Passport: <cause>`).
239
+ - Each reason names its cause in one line: `Passport: railway redeploy changes Production. Approve to run it.` A change a safety pack raises says what it does and how it's decided: `Passport: railway variables --set changes Production. Rules decide it like a delete. Approve to run it.` (`rules test` shows `Class: Change, decided like a Delete`), or `Blocked by a team rule: no deletes in Production. Ask an admin to run it, or request an exception in Passport.` (a cause that isn't a rule reads `Blocked by Passport: <cause>`).
225
240
 
226
241
  **Speed.** Hooks must never slow agents down. The launcher `$PASSPORT_HOME/cli/bin/passport` (written by `src/initInstall.ts`) answers plain reads and local dev commands in POSIX sh without starting Node (`src/launcherFastPath.ts`): `ls`, `cat`, `rg`, `git status`, `cargo check`, and the rest of a fixed list, joined only by single pipes, with relative paths that stay in the folder and pass through no symlink or hidden file. It answers only while `cli-policy/fastpath.ok` is armed: a full guard run arms it for five minutes when the cached rules give those commands exactly the launcher's answer (`src/hookFastPath.ts`), and a policy or profile change removes it. Each answer appends one line (agent, session id, program names, never an argument) to `cli-policy/fastpath.spool`, which the next full run counts. Anything else, or any doubt, starts Node with the same input, through `dist/hookMain.js`, which loads only the guard. `src/launcherFastPath.test.ts` holds the launcher to the full guard's exact answer across both corpora and generated variants. `PASSPORT_HOOK_FAST=0` turns it off. The after-hook and the guard's own report never wait on the network: they queue to `$PASSPORT_HOME/hook-outbox/` and a detached `passport hook flush` sends them within the budget (`src/hookOutbox.ts`). Each guard run records its timings (numbers only, `src/cliSpeed.ts`), sent every five minutes with the answered counts. `npm run bench:guard` times it all on the compiled CLI.
227
242
 
@@ -262,7 +277,7 @@ An ask becomes one Activity row. In Claude Code, with the audit hook registered,
262
277
 
263
278
  **When Passport can't be reached.** A local run, block, or attended ask stands as decided. When the guard needs Passport (an unattended ask, Codex, or a Production action someone else approves) and it doesn't answer within the budget, the environment's `offline` setting from cli-policy v2 decides: ask, block, or allow (ask everywhere by default). An ask nobody can answer (unattended, or Codex) blocks, a second-person action is always blocked, and allow never covers an irreversible action or an ask from a team floor, team or workspace rule, approver rule, or approved exception. A policy synced more than 7 days ago uses the default. The reason ends with one line saying why, such as `Nobody is here to approve it and Passport couldn't be reached, so it's blocked.`
264
279
 
265
- **App access.** The person's pass for the app a `passport exec` CLI acts on (Railway for `railway`, GitHub for `gh`, and so on) comes with cli-policy v2 as `access`, one record per CLI whose app limits the person (an older server's `appAccess` map is read the same way). The guard applies it before any rule, and no rule or exception lifts it. No access blocks every command of that CLI with `You don't have access to Railway in Passport. Ask an admin.` and a link to the app's Access tab; read-only blocks everything but reads. `passport exec` says the same (exit 5, cause `no_access`, with `Access: <link>`). A CLI whose app isn't in the workspace keeps working from its key.
280
+ **App access.** The person's pass for the app a `passport exec` CLI acts on (Railway for `railway`, GitHub for `gh`, and so on) comes with cli-policy v2 as `access`, one record per CLI whose app limits the person (an older server's `appAccess` map is read the same way). The guard applies it before any rule, and no rule or exception lifts it. No access blocks every command of that CLI with `You don't have access to Railway in Passport. Ask an admin: passport request railway --reason "<why>"` and, on the next line, a link to the app's Access tab; read-only blocks everything but reads and names `passport request railway --full --reason "<why>"`. `passport exec` says the same (exit 5, cause `no_access`, with `Access: <link>`). A CLI whose app isn't in the workspace keeps working from its key.
266
281
 
267
282
  `src/cliPolicy.ts` caches the member's CLI policy (`GET /api/my/cli-policy`) at `$PASSPORT_HOME/cli-policy/<profile>.json` (mode 600). Servers with Autopilot send version 2 (`src/cliPolicyV2.ts`: presets, floors, CLI rules, irreversible and delete verbs, environment flags, placed environments); older servers send version 1, and then the guard keeps its earlier shape: ask or deny before destructive verbs, never allow, no server call, and reports without the Autopilot fields. `passport login` and `passport status` refresh it and `passport logout` removes it. A 404 or error keeps the previous copy; with no copy the guard asks before every destructive verb. `PASSPORT_HOOK_DISABLED=1` turns both hooks off.
268
283
 
@@ -277,7 +292,9 @@ passport rules test "railway redeploy -e staging"
277
292
  passport rules test "rm -rf ~/"
278
293
  passport wait apr_123
279
294
  passport sessions # or: --all, --running, --production-changes
295
+ passport sessions --project acme-api # the project's page, then its work
280
296
  passport sessions ses_123
297
+ passport changes --env production --since 1h
281
298
  passport sync # or: passport sync --remove
282
299
  passport env # or: passport env set railway qa staging
283
300
  passport actions add scripts/deploy.py --environment production --class change
@@ -288,7 +305,8 @@ passport actions sync # propose this repository's .passport/actions.toml
288
305
 
289
306
  - `rules test` classifies the command here and sends only its app and verb (and the environment kind) to `POST /api/my/rules/test`, never the command line. An everyday command goes as a finding (`{finding: {vendor, verb, risk, environment}}`), because only this computer can place its paths. It prints the decision, its cause, the environment, and the class. Without a server answer it decides from this computer's copy and says how old it is. `--environment` picks one when the flags don't say.
290
307
  - `wait` long-polls `GET /api/my/approvals/<id>/wait` (30 s per request), after a short first look that names who decides, until a person decides or the request expires; `--timeout <s>` caps it. Agents run it as a background command and are woken when it exits. Once Passport says the request is still pending (never for one that doesn't exist or is already decided), on a terminal it prints the approval link and one live line (`Waiting for Erin · 1:32 left`); piped, `Waiting for a decision on <id> (until it expires at 14:05).` and `Open in Passport: <url>`. Ctrl-C exits 4 with `The request is still open. Keep waiting any time.` and `Run: passport wait <id>`. Approved: `Approved by Ramish (once). Run the command again.`, or `… for this session. Matching commands in this session run without asking.` (exit 0). Declined: the person's note, cleaned and labelled, `Declined by Ramish. Their note: "Use staging first"` (exit 5, cause `approval_denied`). Expired: `Expired at 14:05 with no decision. Run the command again to ask again.` (exit 5, cause `approval_expired`). Still waiting at `--timeout`: exit 4 with the same command as `next`.
291
- - `sessions` lists work items the way the Sessions page does (`GET /api/my/work-items`): a pull request or branch with every session on it rolled up, grouped by project (or, for app connections, by the apps they used). Each item has its agents, then one shape line: actions, active time, failed, confirmed Production changes, unplaced changes, asks with how they ended, blocked, data checks, undone, and the share Passport couldn't check. Notable items come first; the rest fold into `14 routine work items · 3,200 reads · nothing needed you`. `--all` lists every item, `--running` only those with a running session, and `--production-changes` prints the ledger (`GET /api/my/production-ledger`, 7 days unless `--since`): changes to confirmed Production by app and target, then the unplaced count with a link to set environments. `--project`, `--pr`, `--since` (`today`, `24h`, `7d`, `30d`, `90d`, or a date read in local time), and `--status running|ended` go to the server, which applies them to every session in the window, never to a loaded page. The CLI follows up to five pages and then links the rest. `sessions <id>` reads one session (`GET /api/my/agent-sessions/<id>`): its title, place, agent, and active time; the web page's summary strip (actions, shipped, Production, failed, asked, not checked, undo, data checks); and its 15 latest actions with what each acted on, where it landed, and how it ended. On a terminal parts wrap only between `·` and the timeline stacks when it doesn't fit; piped output never wraps and has no color.
308
+ - `sessions` lists work items the way the Sessions page does (`GET /api/my/work-items`): a pull request or branch with every session on it rolled up, grouped by project (or, for app connections, by the apps they used). Each item has its agents, then one shape line: actions, active time, failed, confirmed Production changes, unplaced changes, asks with how they ended, blocked, data checks, undone, and the share Passport couldn't check. Notable items come first; the rest fold into `14 routine work items · 3,200 reads · nothing needed you`. `--all` lists every item, `--running` only those with a running session, and `--production-changes` prints the ledger (`GET /api/my/production-ledger`, 7 days unless `--since`): changes to confirmed Production by app and target, then the unplaced count with a link to set environments. `--project`, `--pr`, `--since` (`today`, `24h`, `7d`, `30d`, `90d`, or a date read in local time), and `--status running|ended` go to the server, which applies them to every session in the window, never to a loaded page. The CLI follows up to five pages and then links the rest. `--project <name>` on its own (no lens, `--pr`, or `--status`) opens with the web project page's summary (`GET /api/my/projects/<name>`): sessions and how many run, Environments (the repository's placement, then each platform its changes reached and how many were unplaced), the rules for the apps and scripts it uses, and its Production changes in the last 7 days, then the work list; `--json` adds it as `project` (`{project,link,sinceTs,environments:[{appKey,appName,role,label,kind,source,reached,unplaced}],rules:[{id,kind,label,decision}],moreRules,production:{total,unplaced,apps},totals}`), and a server without the page prints the list alone. A work item with several sessions links to its own page (`#projects/<name>/work?branch=`). `sessions <id>` reads one session (`GET /api/my/agent-sessions/<id>`): its title, place, agent, and active time; the web page's summary strip (actions, shipped, Production, failed, asked, not checked, undo, data checks); and its 15 latest actions with what each acted on, where it landed, and how it ended. On a terminal parts wrap only between `·` and the timeline stacks when it doesn't fit; piped output never wraps and has no color.
309
+ - `changes` lists every change, delete, and irreversible action that ran on confirmed Production in the window (`GET /api/my/production-changes`), the list Sessions › Production changes shows: grouped by app, newest first, each with its time and command (and what it acted on), then the agent, the person, the pull request (else branch), Failed or Approved, and Undo available, Undone by, or Undo expired. Consecutive alike changes (same command, target, agent, person, repository, and branch) fold into one line, `git push → main ×28` with their span of times, unless one failed, was approved, or has an undo state; `--json` keeps every change. With changes from more than one repository, each line names its repository. Blocked and declined actions never reached Production and aren't listed; unplaced changes are one count with a link to set environments. `--since` takes `1h`, `6h`, `24h` (the default), `7d`, `30d`, `today`, or a date read in local time; `--until` a date; `--project`, `--pr`, `--app`, and `--agent` narrow on the server. `--env` accepts only `production` for now. When the window holds more than one read returns, it says so and links the web page. The deploy and error lanes are web-only.
292
310
  - `sync` writes the allows Passport is sure of into each agent's own permission settings, so those prompts disappear offline and in Codex (`src/nativeSync.ts`). Only reads, test runners, builds and type checks, linters that only check, `git status`, `git add`, and `git commit`, checked against the person's rules. Formatters, fixing linters, `mv`/`cp`, and package scripts stay with the hook, which sees what they touch; deletes, installs, pushes, and Production never sync. Claude Code: `Bash(npm test *)` in `permissions.allow` of `~/.claude/settings.json`. Codex: `prefix_rule(pattern = ["npm", "test"], decision = "allow")` in `~/.codex/rules/passport.rules`, a file Passport owns. Cursor CLI: `Shell(npm:test*)` in `permissions.allow` of `~/.cursor/cli-config.json`. Cursor: `npm test` in `terminalAllowlist` of `~/.cursor/permissions.json`, only when that list already exists there (defining it replaces Cursor's in-app list). Entries Passport added are listed in `$PASSPORT_HOME/native-sync.json`; an entry you had before is never claimed or removed, and a file Passport can't parse exactly (JSONC) is left alone. Sync runs on `init`, `init --org`, every rules refresh, and `passport sync`; `hook uninstall`, `sync --remove`, and signing out of the last profile take the entries out.
293
311
  - `status` is one screen, like `gh auth status`, with a label per row (`You` with the name you signed in as, `Computer`, `Guard`, `Autopilot`, `Apps`, `Keys`, `Shims`, `This folder`, `Allowlists`, `CLI`); under 60 columns each label gets its own row, and piped it never wraps. `Guard` lists each agent's guard (`✓ Claude Code On`, `! Codex Not trusted`) with its fix on the line under it, the coverage line, and sends the daily guard report when due. It also adds today's speed line, `Passport adds ~20 ms per action and asked you twice today. 412 actions ran on their own.` (across your computers when the server keeps speed numbers, else `(this computer)`), and `Answered for you: N prompts today` (allows the hook gave in Claude Code and Cursor, and Codex commands Passport synced, counted only when the agent would have prompted) and which agents' allowlists are synced. Under the presets, one line per exception that lets something run your presets would ask about, in the web's words: `! 1 exception: deletes run in Production without asking, even without a backup.` Counts are appended locally (`$PASSPORT_HOME/answered/`) and sent in batches at most every five minutes as `answered: {batch, count}` on `POST /api/my/cli-activity`.
294
312
  - `actions` tells Passport what a project script does (`src/cliActions.ts`): `actions add <script> [args…] --environment <kind> --class <class>` sends the path in the repository (or `make`, `npm`, `pnpm`, `yarn` with the target), an argument glob, the repository's remote fingerprint and name, and the SHA-256 of what it runs, never its contents, to `POST /api/my/project-actions`. `--id <op_…>` resolves a Session row's **Tell Passport what this does** from this computer's scan cache. `actions sync` proposes each entry of `.passport/actions.toml`. A change, delete, or irreversible in Production applies at once; anything looser waits for an admin. The guard then decides a matching run as vendor `project` with that class and environment; it never makes a line allowed on its own, and a changed script stops matching (`projectChanged`) until it's set again. `.passport/actions.toml` entries apply locally only when they ask or block.
@@ -301,6 +319,7 @@ passport keys move # confirm each key [y/N], store it in Passport, si
301
319
  passport keys move railway # only the Railway key
302
320
  passport keys # what Passport holds, and what's still on this computer
303
321
  passport keys add railway # store a key you paste (stdin, never echoed)
322
+ passport keys rotate railway # replace it with a new key, checked with Railway first
304
323
  passport exec -- railway up -e staging
305
324
  passport keys shim # the CLIs that run through Passport when you type them
306
325
  ```
@@ -313,8 +332,9 @@ passport keys shim # the CLIs that run through Passport when you type
313
332
  - Keys stay in Passport: while Passport holds a working key for a CLI (the exec marker), the guard denies that CLI's own sign-in (`railway login`, `gh auth login`, `aws sso login`, `fly auth login`, …) in Claude Code, Codex, and Cursor with `Passport holds your Railway key; run it through Passport: passport exec -- railway <command>.`, and `exec` (so a shim) refuses it the same way. `keys move` signs a browser sign-in out (Railway, Vercel, and Wrangler session fields only) when Passport already holds a working key, without sending it anywhere. The first interactive `keys move` asks once, `Keep my CLIs signed out? … [y/N]`; with yes, the daily check removes a returned key while Passport holds a working one and reports it as `autoRemoved` (the server records a `cli_key_removed` silent fix for each). `passport keys signed-out [on|off]` changes the answer. Both choices live in `$PASSPORT_HOME/keys-choices/<profile>.json` (vendor names and the answer only).
314
333
  - Dev loops: `railway run|shell|connect`, `vercel dev|build`, and `supabase functions serve` stay refused by `exec`; `wrangler dev` runs through it only when Passport hands out a short-lived Cloudflare key (otherwise exec refuses before the command runs). `passport keys keep <cli> [--remove]` keeps a CLI signed in here on purpose: the guard lets its sign-in run, Passport never removes it, its shim goes, and the report counts it under `kept` (with local copy `dev` on the key), never as a key left to move. The release computer's Railway key is kept the same way (`releases`). `remaining` is counted one way everywhere: one per CLI sign-in `keys move` can act on, by provider.
315
334
  - `keys move` finds CLI sign-ins (Railway, GitHub CLI, Vercel, Wrangler API tokens, Supabase, Stripe test keys, the AWS `default` profile) and tokens in Claude Code's settings `env`. For each it asks `[y/N]` (Enter keeps it; `--yes` moves them all; `keys move <cli>` only that CLI's), stores the key in Passport (`POST /api/my/keys`), then signs that CLI out by removing only the credential: the token fields of `~/.railway/config.json` (project links stay), `token` in Vercel's `auth.json` (not revoked; the current team stays), Wrangler's sign-in keys in `default.toml`, the Supabase `access-token` file and its keychain token (saved database passwords stay), the Stripe profile's API keys and its live key in the keychain (account, color, and other profiles stay), the AWS profile's key lines, or the one settings entry. Files are written atomically with their mode kept. Vendor sign-outs don't run because they do more (`railway logout` unlinks every project, `vercel logout` revokes the token Passport just stored); only the GitHub CLI's `gh auth logout --hostname github.com` runs, adding `--user <active>` when several accounts are signed in, so other hosts and accounts stay. Keychain items are deleted by exact service and account (`security delete-generic-password` on macOS, `secret-tool clear` on Linux); where that isn't possible the row says which keychain copy may stay. Wrangler OAuth tokens are removed locally, not revoked. A sign-out that fails leaves the key in Passport and says what's left on disk. `.env` files are never touched: "Used by your app, so Passport leaves it." Browser-session sign-ins (Railway, Vercel, Wrangler OAuth) can't move; the line says how to make a token instead. A different key than the one already in Passport is replaced only when the person types the CLI's name at a terminal (`Type railway to confirm, or press Enter to cancel:`); no flag does it, so an agent's script can never swap a key. The CLI then names the key it replaces (`replace: <keyId>` on `POST /api/my/keys`). The server alerts the owner and admins with an Undo, records it in the audit trail, and keeps the old value encrypted for seven days (`POST /api/my/keys/:id/restore` from the browser, or the alert). Without a person at a terminal (`--yes`, no terminal), both keys stay, and the line says `Replacing a key in Passport needs you at a terminal. Run passport keys move railway yourself.` The scan report sent afterwards carries provider counts only.
335
+ - `keys rotate <app>` (an app like `github` or `cloudflare`, or its CLI) replaces a key Passport holds. It needs a person at a terminal: without one, or with `--json`, it exits 6 and nothing is read or sent, and no flag answers for you. It reads `GET /api/my/keys` for the key and its rotation guide, prints where to make the new key (`Make a new Railway key at https://railway.com/account/tokens` and one step), asks `Paste the new Railway key (it won't be shown): ` with echo off (AWS: the id and secret on one line), and sends it once to `POST /api/my/keys/:id/rotate` with this computer's name. Passport checks it with one harmless read at the provider (Railway `me`, GitHub `/user`, Vercel `/v2/user`, Cloudflare token verify, Supabase projects, Stripe balance, AWS `GetCallerIdentity`, Neon `/users/me`, Fly.io `viewer`) before it swaps anything, in one locked update that refuses if the key changed meanwhile. A refused, unchecked, or unchanged key exits 1 with `Railway didn't accept that key. Your old key is unchanged.` (or the matching line). On success it prints `✓ Railway accepted the new key. Agents use it from now on.`, then `Now revoke the old key at Railway: <page>` and the step. Like every replace from the CLI, the old value stays restorable for seven days and the owner and admins get an alert with an Undo; **Done** in the web records the revoke. The value is never printed, logged, or in `--json`; the audit trail says who rotated which app's key, when, and from which computer.
316
336
  - `exec -- <cli> …` runs railway, gh, vercel, wrangler, supabase, stripe, aws, neonctl, or flyctl from PATH. It classifies the command here, asks `POST /api/my/exec/authorize`, and on allow sets only that vendor's variables (`GH_TOKEN`, `RAILWAY_API_TOKEN`, `VERCEL_TOKEN`, `CLOUDFLARE_API_TOKEN`, `SUPABASE_ACCESS_TOKEN`, `STRIPE_API_KEY`, `AWS_*`, `NEON_API_KEY`, `FLY_API_TOKEN`) in the child's environment, removing Passport's own and any stray vendor tokens. Output and exit code pass through. Afterwards it reports the exit code and duration (`POST /api/my/exec/result`, best effort, two seconds at most) so the session row reads Ran or Failed. It refuses paths, shells, `env`, and subcommands that would print the key, sign in again, mint longer-lived tokens, or run another program with the key (`railway run`, `gh auth`, gh extensions, `aws configure`, `vercel dev`, `fly tokens`).
317
- - Asks wait for your approval in Passport (web or push) when you're at the keyboard or with `--wait <sec>`; otherwise exit 4 with the approval id: run `passport wait <id>`, then the command again. While it waits, the approval link prints at once and, on a terminal, one live line counts down (`Waiting for Erin · 1:32 left`); piped, it prints the waiting line and `Open in Passport: <url>`. Ctrl-C exits 4: `The request is still open. Keep waiting, then run the command again.` and `Run: passport wait <id>`. An approval is used once. Blocked or declined: exit 5. A decline answers the same command for ten minutes, said with who and when: `Declined 2 minutes ago by Erin: Not during the freeze.` and `Run with --ask-again to request again.`; `--ask-again` opens a new request. No key, or it stopped working: exit 3 (`No Railway key in Passport yet. Add a Railway key in Passport → Apps.`, or `Your Railway key in Passport stopped working. Update it in Apps.`). When this computer still has the Railway CLI's own sign-in, the no-key line is `No Railway key in Passport yet, but this computer has one.` with `Run: passport keys move railway` instead (read here; Passport never sees this computer's files). Offline: exit 1, nothing runs, and exec never uses a key on this computer instead. A team that requires the guard refuses exec for an agent whose computer hasn't reported its guard On in 48 hours: exit 5 with `Blocked by Passport: guard required…` and the fix.
337
+ - Asks wait for your approval in Passport (web or push) when you're at the keyboard or with `--wait <sec>`; otherwise exit 4 with the approval id: run `passport wait <id>`, then the command again. While it waits, the approval link prints at once and, on a terminal, one live line counts down (`Waiting for Erin · 1:32 left`); piped, it prints the waiting line and `Open in Passport: <url>`. Ctrl-C exits 4: `The request is still open. Keep waiting, then run the command again.` and `Run: passport wait <id>`. An approval is used once. Blocked or declined: exit 5. A decline answers the same command for ten minutes, said with who and when: `Declined 2 minutes ago by Erin: Not during the freeze.` and `Run with --ask-again to request again.`; `--ask-again` opens a new request. No key, or it stopped working: exit 3 (`No Railway key in Passport yet.` with `Run: passport keys add railway`, or `Your Railway key in Passport stopped working. Update it in Apps.`). When this computer still has the Railway CLI's own sign-in, the no-key line is `No Railway key in Passport yet, but this computer has one.` with `Run: passport keys move railway` instead (read here; Passport never sees this computer's files). Offline: exit 1, nothing runs, and exec never uses a key on this computer instead. A team that requires the guard refuses exec for an agent whose computer hasn't reported its guard On in 48 hours: exit 5 with `Blocked by Passport: guard required…` and the fix.
318
338
  - In Claude Code, the guard rewrites a plain vendor command whose key is in Passport to `passport exec` (PreToolUse `updatedInput` with allow; a block stays a deny). When the rules ask, or someone is at the keyboard, the rewrite adds `--wait 120`, so the agent holds while the person approves: "Approve it on your phone or in Passport." Codex and Cursor get no rewrite: use `passport exec` there.
319
339
  - Cloud agents (Agents → Cloud agents) run exec and MCP with their agent token in `PASSPORT_AGENT_KEY` and `PASSPORT_ENDPOINT`: the owner's rules decide, the owner's keys are used, and approvals go to the owner.
320
340
  - Backups: for `gh issue close`, `gh pr close`, `gh api -X DELETE` of a branch, `vercel env rm`, `vercel rollback`, and `vercel promote`, exec also sends the ids Passport needs to take a backup first (repo and number or branch; the linked Vercel project and variable name from `.vercel/project.json`), never a value. After the run it prints `Backup taken. Undo within 7 days: passport undo <action-id>`, or `No backup: <reason>` for a delete it couldn't back up.
@@ -324,8 +344,13 @@ passport keys shim # the CLIs that run through Passport when you type
324
344
  ```sh
325
345
  passport undo act_123
326
346
  passport undo --last --yes
347
+ passport undo --local
348
+ passport undo --local <id> --yes
327
349
  ```
328
350
 
351
+ - `--local` lists the backups the guard kept on this computer in the last 7 days (`bridge/src/localBackups.ts`): `rm` of project or home paths moved to a per-project trash (Claude Code: the guard rewrites the command to `passport hook trash`), work `git reset --hard`/`clean`/`checkout --`/`restore` threw away (a commit through a temporary index under `refs/passport/backups/<id>`), dropped stashes, and refs `git branch -d`/`tag -d`/`update-ref -d`/`push --delete`/`push --force` moved. With an id (8+ characters) it shows what comes back, asks, and puts it back; anything there now is replaced only after its own question (left as it is without a terminal). Exit 0 when everything is back, 1 when some of it was left. The audit row of such a command carries `backup: "taken"` and the backup's id, so the row in Passport says **Undo on** this computer with the exact command.
352
+ - **Send to** this computer in Passport queues a restore here. The next time you run `passport` in a terminal (or `passport undo --local`), it shows what comes back and asks; nothing is put back without that yes, never from the hook, a script, or `--yes`. Passport's row then says what happened.
353
+
329
354
  - Shows what comes back and what won't, how old the backup is, and how long undo stays available, then asks `Undo it? [y/N]` (and which option, when there are several). Without a terminal it prints the preview and `passport undo <id> --yes`; `--option <id>` picks an option.
330
355
  - Passport decides an undo from the CLI like a change in that environment. Asks first: exit 4 with the approval id; run `passport wait <id>`, then the undo again. Blocked or declined: exit 5. Done: exit 0, with each step (`✓`/`✗`). Partly done or failed: exit 1. Expired, already undone, or otherwise unavailable: exit 5 with the reason. No backup: exit 6. Needs a member profile.
331
356
 
@@ -344,6 +369,18 @@ printf '%s\n' \
344
369
  - Allowed commands: `status`, `search`, `describe`, `run`, `connect`, `resources`, `prompts` (and `discover`, the old inventory name, for one release).
345
370
  - Governance is unchanged; access tokens keep normal expiry and refresh.
346
371
 
372
+ ### Updates
373
+
374
+ `passport update` moves this computer's Passport CLI to the exact `passport-bridge` version Passport names (`src/cliUpdate.ts`, `src/selfUpdate.ts`): the one you or your admin asked for on **Agents** (`Update`, or `Update all N` on **Agents → Everyone**), else the newest published version (a server-side constant, `LATEST_PUBLISHED_BRIDGE_VERSION` in `shared/agentUpdateContract.ts`). A range, a tag, a prerelease, or a version not newer than this one is never installed.
375
+
376
+ - **Passport's own copy** (`$PASSPORT_HOME/cli/<version>/`, what `init` and the plugin install): `npm view passport-bridge@<version> version` must answer exactly that version, then `npm install passport-bridge@<version> --ignore-scripts --omit=dev` into a temporary folder (the package's `npm-shrinkwrap.json` pins its dependencies). The staged copy must say it is that version and answer `version --json` with it; then it is copied to `cli/<version>/` and the launchers and `cli/current` switch over with one rename each. The launcher hooks run (`cli/bin/passport`) must then answer `version --json` with the new version, or the old launchers and link go back byte for byte and the new folder is removed. Hook entries never change, so Claude Code, Codex (its `trusted_hash` stays valid), Cursor, managed (`--lock`) installs, and the Passport plugin (which reads the launcher's `exec '<node>' '<entry>'` line) all follow. The old version's folder stays, so a command running from it keeps running.
377
+ - **A global npm install**: `npm install --global passport-bridge@<version> --ignore-scripts`, then the same check; if the new version doesn't start, the old version is installed again.
378
+ - **npx or any other copy**: left alone, and reported as such.
379
+
380
+ npm runs without a shell (the npm next to this Node, else `npm` on PATH), one update at a time per computer (`$PASSPORT_HOME/update/.lock`). Only version numbers, the install kind (`copy`, `global`, `npx`, `other`), and a reason code (`off`, `npx`, `unmanaged`, `not-published`, `permission`, `network`, `install-failed`, `verify-failed`) reach Passport; npm's output never leaves the computer.
381
+
382
+ **Automatic updates.** On a signed-in computer, after a command that worked (not `scan`), and from the hooks' detached flush, at most every 15 minutes per computer (`$PASSPORT_HOME/update/.checked`), the CLI starts a detached `passport update --background` (`src/updateTrigger.ts`) and returns; nothing waits for it. It sends `POST /api/my/agent-update/check {version, auto, install}` and installs only a version someone requested, then reports `POST /api/my/agent-update/report {from, version, outcome, reason?, install}`. `passport update off` (stored in `$PASSPORT_HOME/update/settings.json`) keeps checking so Agents can say "Automatic updates are off on this computer.", but never installs; `PASSPORT_AUTO_UPDATE=off` also stops the checks. There are no checks in CI (`CI`), from an agent token, inside an update, or from npx's cache. `passport update` by hand works with automatic updates off.
383
+
347
384
  ### Shell completion
348
385
 
349
386
  ```sh
@@ -438,31 +475,33 @@ Questions follow one convention (`src/cliAsk.ts`), only on a terminal: `[Y/n]` f
438
475
 
439
476
  On a terminal, human output comes from one renderer (`src/term.ts`): it wraps to the window's width (at least 40 columns, at most 100) without breaking a URL or a `passport` command, hangs wrapped lines under their label or mark, stacks a table one row at a time when its columns don't fit, and clips a live line (a countdown, a "Checking…" row) to one row so it's always replaced cleanly. Marks always sit next to words (`✓ On`, `! Not trusted`, `– skipped`), with `+`, `!`, `-` where the terminal can't show them. Piped output never wraps, has no color, and draws no live lines. `NO_COLOR` and `TERM=dumb` turn color off.
440
477
 
441
- | Command | JSON value |
442
- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
443
- | `login` | `{profile,endpoint,client,surface,active,workspaceId,workspaceName?,memberName?,next}`; without a terminal or with `--json`, step one is `{status:"pending",verification_url,code,expires_in,next_step,login_id,next}` |
444
- | `profiles` | `{profiles:[{name,active,client?}],active?}` |
445
- | `use` | `{profile,active:true}` |
446
- | `logout` | `{profile,removed,revoked,shimsRemoved?}` |
447
- | `status` | `{workspace,member,endpoint,auth,profile?,client,mcps,autopilot?:{presets,floors,floorReason?,exceptions?,cache:{version,fetchedAt,ageMs}},next?,computer,keys?,keysOnThisComputer?,folder,cli:{version},signedInAs?,shims?:[{vendor,command,state}]}` |
448
- | `wait` | `{approvalId,status:"approved",scope?,message}`; declined, expired, and still-waiting are errors with `approvalId` |
449
- | `rules` | `{command,decision,cause?,explanation?,environment?,environmentAssumed?,actionClass?,source}` |
450
- | `sessions` | `{view,groups:[{key,kind,label,apps,running,production,unplaced,items:[{key,title,project,branch,pull,agents,sessions,sessionIds,startedAt,lastActivityAt,activeMs,running,waiting,shape,reasons,severity,link}],routine:{count,sessions,actions,reads,items}\|null}],totals,complete,nextCursor}`; `--production-changes`: `{view,sinceTs,untilTs,total,unplaced,apps:[{appKey,appName,count,lastTs,targets:[{target,tool,actionClass,count,failed,firstTs,lastTs}]}]}`; `<id>`: `{view,session,outcome,approvals,timeline,nextCursor}` |
451
- | `undo` | `{actionId,status,message,steps:[{label,ok,detail?}],option,undoActionId?}`; without `--yes` off a terminal, `{actionId,status:"preview",preview,next}`; pending, blocked, and declined are errors |
452
- | `doctor` | `{version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}`, also on failure |
453
- | `ready` | `{ready,version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}` |
454
- | `search` | Gateway payload with `results` or `catalog`, and `note` |
455
- | `describe` | Tool definition (`tool`, `parameters`) plus `name`/`inputSchema` aliases |
456
- | `run` | Full governed MCP tool result, including `structuredContent` |
457
- | `connect` | Gateway payload with `connections` and optional `connectAllUrl` |
458
- | `resources`, `prompts` | MCP list, read, or get result |
459
- | `discover` | `{snapshot,report,compliant}` (the old name of `scan`'s inventory step, for one release) |
460
- | `scan` | `{version:1,findings:[{id,provider,kind,label,severity,location,locations,blastRadius}],agents,unreadable,checked,inventory?:{snapshot,report,compliant}}`; `inventory` only when signed in, or `{error}` when it couldn't be sent |
461
- | `session` | NDJSON `{id?,ok,exitCode,result?}` or `{id?,ok:false,error,cause,exitCode,...}` |
462
- | `access` | `keygen`: algorithm, paths, public JWK; `actions`: `{actions}`; `run`/`cancel`: `{run}`; `invoke`: governed result; `status`: `{receipt}` |
463
- | `completion` | `{shell,script}` |
464
- | `help` | `{command,help}` |
465
- | `version` | `{version,profileCount,profileSelected,selectionSource,next,endpoint?,profile?}` |
478
+ | Command | JSON value |
479
+ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
480
+ | `login` | `{profile,endpoint,client,surface,active,workspaceId,workspaceName?,memberName?,next}`; without a terminal or with `--json`, step one is `{status:"pending",verification_url,code,expires_in,next_step,login_id,next}` |
481
+ | `profiles` | `{profiles:[{name,active,client?}],active?}` |
482
+ | `use` | `{profile,active:true}` |
483
+ | `logout` | `{profile,removed,revoked,shimsRemoved?}` |
484
+ | `status` | `{workspace,member,endpoint,auth,profile?,client,mcps,autopilot?:{presets,floors,floorReason?,exceptions?,cache:{version,fetchedAt,ageMs}},next?,computer,keys?,keysOnThisComputer?,folder,cli:{version},signedInAs?,shims?:[{vendor,command,state}]}` |
485
+ | `wait` | `{approvalId,status:"approved",scope?,message}`; declined, expired, and still-waiting are errors with `approvalId` |
486
+ | `rules` | `{command,decision,cause?,explanation?,environment?,environmentAssumed?,actionClass?,source}` |
487
+ | `sessions` | `{view,groups:[{key,kind,label,apps,running,production,unplaced,items:[{key,title,project,branch,pull,agents,sessions,sessionIds,startedAt,lastActivityAt,activeMs,running,waiting,shape,reasons,severity,link}],routine:{count,sessions,actions,reads,items}\|null}],totals,complete,nextCursor}` (`--project <name>` alone adds `project`); `--production-changes`: `{view,sinceTs,untilTs,total,unplaced,apps:[{appKey,appName,count,lastTs,targets:[{target,tool,actionClass,count,failed,firstTs,lastTs}]}]}`; `<id>`: `{view,session,outcome,approvals,timeline,nextCursor}` |
488
+ | `changes` | `{view,environment,sinceTs,untilTs,total,unplaced,complete,apps:[{vendor,appName,changes:[{id,ts,person,agent,agentName,appKey,vendor,appName,command,target,actionClass,result,approved,sessionId,project,branch,pull,undo}]}]}` |
489
+ | `undo` | `{actionId,status,message,steps:[{label,ok,detail?}],option,undoActionId?}`; without `--yes` off a terminal, `{actionId,status:"preview",preview,next}`; pending, blocked, and declined are errors |
490
+ | `doctor` | `{version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}`, also on failure |
491
+ | `ready` | `{ready,version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}` |
492
+ | `search` | Gateway payload with `results` or `catalog`, and `note` |
493
+ | `describe` | Tool definition (`tool`, `parameters`) plus `name`/`inputSchema` aliases |
494
+ | `run` | Full governed MCP tool result, including `structuredContent` |
495
+ | `connect` | Gateway payload with `connections` and optional `connectAllUrl` |
496
+ | `resources`, `prompts` | MCP list, read, or get result |
497
+ | `discover` | `{snapshot,report,compliant}` (the old name of `scan`'s inventory step, for one release) |
498
+ | `scan` | `{version:1,findings:[{id,provider,kind,label,severity,location,locations,blastRadius}],agents,unreadable,checked,inventory?:{snapshot,report,compliant}}`; `inventory` only when signed in, or `{error}` when it couldn't be sent |
499
+ | `session` | NDJSON `{id?,ok,exitCode,result?}` or `{id?,ok:false,error,cause,exitCode,...}` |
500
+ | `access` | `keygen`: algorithm, paths, public JWK; `actions`: `{actions}`; `run`/`cancel`: `{run}`; `invoke`: governed result; `status`: `{receipt}` |
501
+ | `update` | `{version,latest,requested,auto,install,outcome?,to?}`; `check` leaves out `outcome`; `off`/`on`: `{auto}`. A failed update is an error with `cause: "update_failed"` and a `hint`. |
502
+ | `completion` | `{shell,script}` |
503
+ | `help` | `{command,help}` |
504
+ | `version` | `{version,profileCount,profileSelected,selectionSource,next,endpoint?,profile?}` |
466
505
 
467
506
  Errors: `{"error":"...","cause":"blocked","exitCode":5,"app":"github"}`, optionally with `approvalId`, `hint`, `profiles`, `next` (`argv` plus description), `remediation`, `retry`, `requiredInput`, or `connectUrl`.
468
507
 
package/dist/cliArgs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const COMMANDS: readonly ["init", "login", "logout", "profiles", "use", "status", "doctor", "ready", "search", "describe", "run", "connect", "resources", "prompts", "discover", "scan", "hook", "wait", "rules", "actions", "sessions", "env", "sync", "exec", "undo", "keys", "setup", "session", "access", "completion", "help", "version"];
1
+ export declare const COMMANDS: readonly ["init", "login", "logout", "profiles", "use", "status", "doctor", "ready", "search", "describe", "run", "connect", "request", "resources", "prompts", "discover", "scan", "hook", "wait", "rules", "actions", "sessions", "changes", "env", "sync", "exec", "undo", "keys", "setup", "session", "access", "update", "completion", "help", "version"];
2
2
  export type Command = (typeof COMMANDS)[number];
3
3
  /** Old names that still run for one release, left out of help, completion,
4
4
  * and suggestions. `discover` is part of `scan` now. */
package/dist/cliArgs.js CHANGED
@@ -12,6 +12,7 @@ export const COMMANDS = [
12
12
  "describe",
13
13
  "run",
14
14
  "connect",
15
+ "request",
15
16
  "resources",
16
17
  "prompts",
17
18
  "discover",
@@ -21,6 +22,7 @@ export const COMMANDS = [
21
22
  "rules",
22
23
  "actions",
23
24
  "sessions",
25
+ "changes",
24
26
  "env",
25
27
  "sync",
26
28
  "exec",
@@ -29,6 +31,7 @@ export const COMMANDS = [
29
31
  "setup",
30
32
  "session",
31
33
  "access",
34
+ "update",
32
35
  "completion",
33
36
  "help",
34
37
  "version"
@@ -47,7 +50,7 @@ const FLAGS = {
47
50
  help: { kind: "boolean" },
48
51
  cloud: { kind: "value", commands: ["login", "init", "setup"] },
49
52
  workspace: { kind: "value", commands: ["login", "access"] },
50
- client: { kind: "value", commands: ["login", "setup", "hook", "exec"] },
53
+ client: { kind: "value", commands: ["login", "setup", "hook", "exec", "changes"] },
51
54
  apply: { kind: "boolean", commands: ["setup", "hook"] },
52
55
  guard: { kind: "boolean", commands: ["hook"] },
53
56
  hold: { kind: "value", commands: ["hook"] },
@@ -64,7 +67,7 @@ const FLAGS = {
64
67
  "move-keys": { kind: "boolean", commands: ["init"] },
65
68
  "dry-run": { kind: "boolean", commands: ["init"] },
66
69
  "ask-again": { kind: "boolean", commands: ["exec"] },
67
- app: { kind: "value", commands: ["search"] },
70
+ app: { kind: "value", commands: ["search", "changes"] },
68
71
  args: { kind: "value", commands: ["run", "actions"] },
69
72
  id: { kind: "value", commands: ["actions"] },
70
73
  class: { kind: "value", commands: ["actions"] },
@@ -94,12 +97,19 @@ const FLAGS = {
94
97
  all: { kind: "boolean", commands: ["sessions"] },
95
98
  running: { kind: "boolean", commands: ["sessions"] },
96
99
  "production-changes": { kind: "boolean", commands: ["sessions"] },
97
- project: { kind: "value", commands: ["sessions"] },
98
- pr: { kind: "value", commands: ["sessions"] },
99
- since: { kind: "value", commands: ["sessions"] },
100
+ project: { kind: "value", commands: ["sessions", "changes"] },
101
+ pr: { kind: "value", commands: ["sessions", "changes"] },
102
+ since: { kind: "value", commands: ["sessions", "changes"] },
103
+ until: { kind: "value", commands: ["changes"] },
104
+ env: { kind: "value", commands: ["changes"] },
100
105
  remove: { kind: "boolean", commands: ["sync", "keys"] },
101
106
  last: { kind: "boolean", commands: ["undo"] },
102
- option: { kind: "value", commands: ["undo"] }
107
+ local: { kind: "boolean", commands: ["undo"] },
108
+ // The detached check the CLI and hooks start; not for people to type.
109
+ background: { kind: "boolean", commands: ["update"] },
110
+ option: { kind: "value", commands: ["undo"] },
111
+ reason: { kind: "value", commands: ["request"] },
112
+ full: { kind: "boolean", commands: ["request"] }
103
113
  };
104
114
  /** `--agent` is the documented name; `--client` keeps working everywhere. */
105
115
  const FLAG_ALIASES = { agent: "client", agents: "clients" };
@@ -261,6 +271,7 @@ function validateShape(command, positionals) {
261
271
  wait: 1,
262
272
  rules: 2,
263
273
  sessions: 1,
274
+ changes: 0,
264
275
  env: 4,
265
276
  sync: 0,
266
277
  undo: 1,
@@ -61,10 +61,17 @@ function ruleTestLines(term, label, result, source) {
61
61
  label,
62
62
  ` ${mark(term, DECISION_MARKS[result.decision])} ${explanation}`,
63
63
  ...(environment ? [` Environment: ${environment}`] : []),
64
- ...(result.actionClass ? [` Class: ${CLASS_LABEL[result.actionClass]}`] : []),
64
+ ...(result.actionClass ? [` Class: ${classLine(result)}`] : []),
65
65
  ...indented(source)
66
66
  ];
67
67
  }
68
+ /** "Change", or "Change, decided like a Delete" for one a safety pack raises.
69
+ * An older server sends a raised change as a Delete with no `treatedAs`. */
70
+ function classLine(result) {
71
+ if (result.treatedAs)
72
+ return `${CLASS_LABEL.change}, decided like a ${CLASS_LABEL.delete}`;
73
+ return CLASS_LABEL[result.actionClass];
74
+ }
68
75
  /** Place every finding in the environment the person picked. */
69
76
  function inEnvironment(findings, environment) {
70
77
  if (!environment)
@@ -84,7 +91,11 @@ function localTest(command, findings, complete, policy, machine) {
84
91
  ...(decision.cause ? { cause: decision.cause } : {}),
85
92
  ...(decision.environment ? { environment: decision.environment } : {}),
86
93
  ...(decision.environmentSource === "assumed" ? { environmentAssumed: true } : {}),
87
- ...(decision.actionClass ? { actionClass: decision.actionClass } : {})
94
+ ...(decision.treatedAs
95
+ ? { actionClass: "change", treatedAs: decision.treatedAs }
96
+ : decision.actionClass
97
+ ? { actionClass: decision.actionClass }
98
+ : {})
88
99
  };
89
100
  }
90
101
  /**
@@ -194,7 +205,7 @@ export async function rules(args, runtime, deps = {}) {
194
205
  // The server knows grants, every rule, and the workspace's environments.
195
206
  const asked = profile || deps.api ? await askServer(testBody(lead, label, target, environment), args, runtime, deps) : null;
196
207
  let result = asked;
197
- let source = result ? "Decided by your workspace's rules." : "";
208
+ let source = result ? (result.decision === "none" ? "" : "Decided by your workspace's rules.") : "";
198
209
  if (!result) {
199
210
  result = local ?? { decision: "none" };
200
211
  source = cached
@@ -204,7 +215,7 @@ export async function rules(args, runtime, deps = {}) {
204
215
  : "Decided on this computer from built-in rules. Sign in to use yours.\nRun: passport login";
205
216
  }
206
217
  return {
207
- json: { command: label, ...result, source: source.startsWith("Decided by") ? "server" : "local" },
218
+ json: { command: label, ...result, source: asked ? "server" : "local" },
208
219
  human: ruleTestLines(termOf(runtime.stdout, runtime.env), label, result, source).join("\n")
209
220
  };
210
221
  }
@@ -175,6 +175,10 @@ export type AutopilotPolicy = {
175
175
  * repository name (lowercase): Production for one that deploys on merge.
176
176
  * Present only when the server places git and gh by reach (`localReach.ts`). */
177
177
  repos?: Record<string, EnvKind>;
178
+ /** Rows where this person's Hands-off deletes run without a backup. Present
179
+ * only when the server asks before a Hands-off shell delete nothing can
180
+ * back up (`backupGate`); an older server sends nothing and nothing changes. */
181
+ withoutBackup?: Partial<Record<"staging" | "development" | "other", true>>;
178
182
  /** Known project scripts (Batch A item 5), vendor `project`: they set class
179
183
  * and environment only, never an allow. */
180
184
  project?: {
@@ -211,6 +215,8 @@ export type ActionFacts = {
211
215
  verb: string;
212
216
  actionClass: ActionClass;
213
217
  environment: ActionEnv;
218
+ /** This computer takes a backup first (`localBackups.ts`). */
219
+ backup?: boolean;
214
220
  };
215
221
  export type LocalDecision = {
216
222
  decision: Decision;
@@ -223,6 +229,8 @@ export declare function accessRecordFor(policy: AutopilotPolicy, vendor: string)
223
229
  /** The server's `decideAction`, minus grants (only the server knows them).
224
230
  * The access ceiling comes first and nothing lifts it; the second-person rule
225
231
  * turns a Production run into an ask the server owns. */
232
+ /** Checked copy of shared/undoContract.ts `UNDO_COPY.askCause` (cliAutopilotPolicy.test.ts). */
233
+ export declare const NO_BACKUP_CAUSE = "Couldn't take a backup first";
226
234
  export declare function decideAction(policy: AutopilotPolicy, facts: ActionFacts): LocalDecision;
227
235
  /** Whether an ask needs someone other than the person at the keyboard. */
228
236
  export declare function needsSecondPerson(cause: Cause | undefined): boolean;
@@ -283,6 +283,27 @@ function accessCeiling(policy, facts) {
283
283
  /** The server's `decideAction`, minus grants (only the server knows them).
284
284
  * The access ceiling comes first and nothing lifts it; the second-person rule
285
285
  * turns a Production run into an ask the server owns. */
286
+ /** Checked copy of shared/undoContract.ts `UNDO_COPY.askCause` (cliAutopilotPolicy.test.ts). */
287
+ export const NO_BACKUP_CAUSE = "Couldn't take a backup first";
288
+ /**
289
+ * The backup rule for the shell (server `applyShellBackupGate`): a Delete the
290
+ * preset would run asks when nothing can back it up here, unless the person
291
+ * turned on "Run deletes without a backup" for that row. `facts.backup`:
292
+ * this computer takes one first (`localBackups.ts`). An exception or a floor
293
+ * decides as before.
294
+ */
295
+ function backupGate(policy, facts, decided) {
296
+ const rows = policy.withoutBackup;
297
+ if (!rows || decided.decision !== "allow" || facts.actionClass !== "delete")
298
+ return decided;
299
+ if (decided.cause.kind !== "preset" && decided.cause.kind !== "default")
300
+ return decided;
301
+ if (facts.backup)
302
+ return decided;
303
+ if (facts.environment !== "production" && rows[facts.environment] === true)
304
+ return decided;
305
+ return { decision: "ask", cause: { kind: decided.cause.kind, label: NO_BACKUP_CAUSE } };
306
+ }
286
307
  export function decideAction(policy, facts) {
287
308
  const ceiling = accessCeiling(policy, facts);
288
309
  if (ceiling)
@@ -290,7 +311,8 @@ export function decideAction(policy, facts) {
290
311
  const decided = decideByRules(policy, facts);
291
312
  const classes = policy.secondPerson?.classes ?? [];
292
313
  if (decided.decision !== "allow" || facts.environment !== "production" || !classes.includes(facts.actionClass)) {
293
- return decided;
314
+ // Someone else approving comes first; then the backup rule.
315
+ return backupGate(policy, facts, decided);
294
316
  }
295
317
  const label = facts.actionClass === "change" ? SECOND_PERSON_LABEL.change : SECOND_PERSON_LABEL.delete;
296
318
  return { decision: "ask", cause: { kind: "floor", label } };
@@ -0,0 +1,80 @@
1
+ /**
2
+ * `passport changes`: what changed in Production, the list Sessions ›
3
+ * Production changes shows. Every change, delete, and irreversible action
4
+ * that ran on confirmed Production in the window, grouped by app, newest
5
+ * first, with the agent, the person, the work item, the result, and undo.
6
+ *
7
+ * passport changes the last 24 hours
8
+ * passport changes --env production --since 1h
9
+ *
10
+ * Filters run on the server (`GET /api/my/production-changes`). `--json`
11
+ * prints `ChangesJson`, never the server's raw page.
12
+ */
13
+ import { type ParsedArgs } from "./cliArgs.js";
14
+ import { type AutopilotDependencies } from "./cliMemberCall.js";
15
+ import { type CommandResult, type Runtime } from "./cliSupport.js";
16
+ import { type Term } from "./term.js";
17
+ export type UndoJson = {
18
+ state: string;
19
+ label: string;
20
+ undoneBy: string | null;
21
+ };
22
+ export type ChangeJson = {
23
+ id: string;
24
+ ts: number | null;
25
+ person: string | null;
26
+ agent: string;
27
+ agentName: string;
28
+ appKey: string;
29
+ vendor: string;
30
+ appName: string;
31
+ command: string;
32
+ target: string | null;
33
+ actionClass: "change" | "delete" | "irreversible";
34
+ result: "ok" | "error";
35
+ approved: boolean;
36
+ sessionId: string | null;
37
+ project: string | null;
38
+ branch: string | null;
39
+ pull: {
40
+ number: number;
41
+ title: string;
42
+ url: string | null;
43
+ } | null;
44
+ undo: UndoJson | null;
45
+ };
46
+ /** `passport changes --json`. */
47
+ export type ChangesJson = {
48
+ view: "production-changes";
49
+ environment: "production";
50
+ sinceTs: number | null;
51
+ untilTs: number | null;
52
+ total: number;
53
+ unplaced: number;
54
+ complete: boolean;
55
+ apps: Array<{
56
+ vendor: string;
57
+ appName: string;
58
+ changes: ChangeJson[];
59
+ }>;
60
+ };
61
+ /** `--since` as the server reads it. */
62
+ export declare function changesSince(raw: string): string | null;
63
+ /** The server's page as `ChangesJson`: grouped by app (newest first), then time. */
64
+ export declare function changesOf(raw: unknown): ChangesJson;
65
+ /** "14:02" today, "Oct 19 14:02" before. */
66
+ export declare function changeTime(ms: number | null, now: number): string;
67
+ /** The row's part line: agent · person · PR (else branch) · result · undo.
68
+ * With changes from more than one repository, the repository comes first. */
69
+ export declare function changeParts(change: ChangeJson, projects?: boolean): string[];
70
+ /**
71
+ * Consecutive alike changes (same command, target, agent, person, and
72
+ * branch; newest first) as one line, the way the web folds them: 28 pushes
73
+ * read "git push -> main x28". `--json` keeps every change.
74
+ */
75
+ export declare function foldChanges(changes: readonly ChangeJson[]): ChangeJson[][];
76
+ export declare function renderChanges(page: ChangesJson, term: Term, now: number, since: string, links: {
77
+ environments: string | null;
78
+ more: string | null;
79
+ }): string;
80
+ export declare function changes(args: ParsedArgs, runtime: Runtime, deps?: AutopilotDependencies): Promise<CommandResult>;