passport-bridge 0.16.4 → 0.16.8
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 +47 -26
- package/dist/bridgeExchange.d.ts +1 -1
- package/dist/bridgeExchange.js +1 -1
- package/dist/cli.js +6 -6
- package/dist/cliActions.d.ts +28 -0
- package/dist/cliActions.js +224 -0
- package/dist/cliAnswered.d.ts +5 -0
- package/dist/cliAnswered.js +27 -2
- package/dist/cliApprovalLink.d.ts +5 -0
- package/dist/cliApprovalLink.js +21 -0
- package/dist/cliArgs.d.ts +1 -1
- package/dist/cliArgs.js +17 -7
- package/dist/cliAutopilot.d.ts +13 -3
- package/dist/cliAutopilot.js +25 -34
- package/dist/cliAutopilotPolicy.d.ts +20 -0
- package/dist/cliCodexTrust.d.ts +42 -0
- package/dist/cliCodexTrust.js +145 -0
- package/dist/cliEnv.d.ts +9 -2
- package/dist/cliEnv.js +30 -20
- package/dist/cliExec.d.ts +2 -8
- package/dist/cliExec.js +15 -25
- package/dist/cliExecGuard.d.ts +10 -0
- package/dist/cliExecGuard.js +36 -0
- package/dist/cliGuardHealth.d.ts +42 -0
- package/dist/cliGuardHealth.js +154 -0
- package/dist/cliGuardState.d.ts +60 -0
- package/dist/cliGuardState.js +121 -0
- package/dist/cliHook.d.ts +5 -59
- package/dist/cliHook.js +158 -158
- package/dist/cliHookClassify.d.ts +12 -0
- package/dist/cliHookDecide.d.ts +13 -0
- package/dist/cliHookDecide.js +35 -2
- package/dist/cliHookDeliver.d.ts +153 -0
- package/dist/cliHookDeliver.js +281 -0
- package/dist/cliHookExtras.d.ts +26 -0
- package/dist/cliHookExtras.js +34 -0
- package/dist/cliHookGuard.d.ts +7 -4
- package/dist/cliHookGuard.js +65 -10
- package/dist/cliHookInstall.d.ts +14 -0
- package/dist/cliHookInstall.js +10 -70
- package/dist/cliHookLocal.d.ts +6 -0
- package/dist/cliHookLocal.js +56 -3
- package/dist/cliHookLocalCode.d.ts +11 -0
- package/dist/cliHookLocalCode.js +18 -5
- package/dist/cliHookRewrite.js +1 -1
- package/dist/cliHookScripts.d.ts +51 -0
- package/dist/cliHookScripts.js +247 -0
- package/dist/cliHookStatus.d.ts +18 -0
- package/dist/cliHookStatus.js +111 -0
- package/dist/cliInit.d.ts +3 -0
- package/dist/cliInit.js +18 -6
- package/dist/cliKeys.d.ts +8 -0
- package/dist/cliKeys.js +71 -20
- package/dist/cliKeysBack.d.ts +41 -0
- package/dist/cliKeysBack.js +124 -0
- package/dist/cliLogin.js +1 -1
- package/dist/cliOpaqueId.d.ts +10 -0
- package/dist/cliOpaqueId.js +48 -0
- package/dist/cliOutput.js +18 -10
- package/dist/cliPolicy.d.ts +3 -0
- package/dist/cliPolicy.js +17 -0
- package/dist/cliPolicyV2.js +76 -3
- package/dist/cliScan.js +3 -3
- package/dist/cliScriptRead.d.ts +199 -0
- package/dist/cliScriptRead.js +512 -0
- package/dist/cliScriptText.d.ts +78 -0
- package/dist/cliScriptText.js +412 -0
- package/dist/cliSeen.d.ts +40 -0
- package/dist/cliSeen.js +203 -0
- package/dist/cliSession.d.ts +1 -0
- package/dist/cliSession.js +2 -0
- package/dist/cliSetup.js +3 -3
- package/dist/cliSetupLock.d.ts +37 -0
- package/dist/cliSetupLock.js +330 -0
- package/dist/cliSetupOrg.d.ts +2 -0
- package/dist/cliSetupOrg.js +28 -2
- package/dist/cliSpeed.d.ts +104 -0
- package/dist/cliSpeed.js +320 -0
- package/dist/cliStatusGuard.d.ts +28 -0
- package/dist/cliStatusGuard.js +77 -0
- package/dist/cliSupport.d.ts +4 -0
- package/dist/completion.js +8 -4
- package/dist/credentials.js +8 -0
- package/dist/envResolve.d.ts +9 -5
- package/dist/envResolve.js +27 -8
- package/dist/execTarget.d.ts +8 -0
- package/dist/execTarget.js +28 -0
- package/dist/fastPathFlag.d.ts +38 -0
- package/dist/fastPathFlag.js +90 -0
- package/dist/hookFastPath.d.ts +44 -0
- package/dist/hookFastPath.js +234 -0
- package/dist/hookMain.d.ts +2 -0
- package/dist/hookMain.js +53 -0
- package/dist/hookOutbox.d.ts +27 -0
- package/dist/hookOutbox.js +176 -0
- package/dist/initAutopilotStep.js +6 -8
- package/dist/initInstall.d.ts +6 -3
- package/dist/initInstall.js +44 -5
- package/dist/initKeysStep.js +5 -0
- package/dist/initLocalSteps.js +7 -7
- package/dist/initUi.d.ts +10 -0
- package/dist/initUi.js +27 -0
- package/dist/launcherFastPath.d.ts +55 -0
- package/dist/launcherFastPath.js +347 -0
- package/dist/lockedHooks.d.ts +99 -0
- package/dist/lockedHooks.js +178 -0
- package/dist/managedHooks.d.ts +10 -0
- package/dist/managedHooks.js +80 -0
- package/dist/managedSkills.js +4 -4
- package/dist/passport.js +5 -4
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/recoveryIdentity.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/webLinks.d.ts +5 -0
- package/dist/webLinks.js +49 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ passport run github_search_issues '{"query":"SSO"}'
|
|
|
68
68
|
| `rules test "<command>" [--environment <kind>]` | What Autopilot decides for a command, why, and which environment it acts on. |
|
|
69
69
|
| `sessions [--status running\|idle\|ended]` | Your agents' recent sessions with what Passport decided. |
|
|
70
70
|
| `undo <action-id>\|--last [--option <id>] [--yes]` | Undo an action Passport took a backup before, within 7 days. See [Undo](#undo). |
|
|
71
|
-
| `setup --org <pek_key> [--yes] [--
|
|
71
|
+
| `setup --org <pek_key> [--yes] [--agents <list>] [--lock [--strict]]` | Set up every agent on this computer for your company without asking anything (MDM and scripts); `--lock` (root) locks the guard on. See [Company rollout](#company-rollout). |
|
|
72
72
|
| `setup` | Install and maintain assigned team workflows as managed skills. |
|
|
73
73
|
| `session` | Run NDJSON commands over one authenticated MCP session. |
|
|
74
74
|
| `access` | Signed managed access: `keygen`, `actions`, `run`, `invoke`, `status`, `cancel`. |
|
|
@@ -134,7 +134,7 @@ Eight steps, each reusing the command that owns it:
|
|
|
134
134
|
1. **Scan**: the same local scan as `passport scan`, as one summary line (`--verbose` prints the table).
|
|
135
135
|
2. **Sign in**: reuses the active or only CLI profile, asks which one when there are several, or runs the browser sign-in from `passport login`.
|
|
136
136
|
3. **Apps**: Railway, Vercel, Supabase, Cloudflare, GitHub, and Stripe, when the scan found a key or its CLI is on PATH. Missing apps are added through the same catalog rules as the web (an app your workspace reviews first says `! Stripe needs approval from your admin.`), then one sign-in page covers the rest. In a terminal init waits until they connect (Enter stops waiting); without one it prints the page and `Next: passport connect --wait 300` and moves on.
|
|
137
|
-
4. **Keys**: for each CLI sign-in on this computer, the same question as `passport keys move`: `Store your Railway account token in Passport and sign the Railway CLI out on this computer? [y/n]`. It has no default: Enter asks again (`Type y or n.`). `--yes` never moves a key: the step prints `Keys stayed on this computer. Run passport keys move to move them.` Add `--move-keys` to move every key it finds unasked; the closing summary then says which (`Moved your Railway key into Passport and signed that CLI out on this computer.`). Quiet when there's nothing to move.
|
|
137
|
+
4. **Keys**: for each CLI sign-in on this computer, the same question as `passport keys move`: `Store your Railway account token in Passport and sign the Railway CLI out on this computer? [y/n]`. It has no default: Enter asks again (`Type y or n.`). `--yes` never moves a key: the step prints `Keys stayed on this computer. Run passport keys move to move them.` Add `--move-keys` to move every key it finds unasked; the closing summary then says which (`Moved your Railway key into Passport and signed that CLI out on this computer.`) and which old keys to rotate (`Rotate the old Railway key once your agents don't need it.`, only when a key moved in that run). When Passport already holds a different key for that CLI, an interactive run asks `Replace the Railway key in Passport with the one on this computer? [y/n]` (no default): yes replaces it and signs the CLI out, keeping links; no prints `Kept the key in Passport. This computer's Railway CLI stays signed in.` `--yes` never replaces a key. Quiet when there's nothing to move.
|
|
138
138
|
5. **Environments**: the environments Passport has placed for your apps, each with its kind: `Found 3 environments: production (Railway), preview (Vercel), qa (Railway)`. Anything Passport can't place counts as Production; change it any time in Rules. With no app connected yet it says `Environments appear once an app is connected.`
|
|
139
139
|
6. **Agents**: Passport's one MCP URL with this workspace as its hint (`https://passportmcp.com/mcp?ws=<workspace>`), with each agent's own browser sign-in; a server that doesn't serve `/mcp` yet (read from its OAuth protected-resource metadata) gets the workspace's own URL (`https://<host>/w/<workspace>/mcp`). An existing entry at either URL for this workspace counts as set up, so no token lands in a config file. Claude Code and Codex through their own CLIs (`claude mcp add --transport http --scope user`, `codex mcp add --url`), Cursor through `~/.cursor/mcp.json`, VS Code through `code --add-mcp` or its user `mcp.json`. Claude Desktop connects through Settings → Connectors, so init prints that step.
|
|
140
140
|
7. **Guard**: asks `Apply your Autopilot rules before each shell command in <agents>? [Y/n]`, then runs `passport hook install --guard` for Claude Code, Codex, and Cursor (Codex: blocks only), pointing at the launcher `$PASSPORT_HOME/cli/bin/passport` (`passport.cmd` on Windows), which runs a stable copy of the CLI in `$PASSPORT_HOME/cli/<version>/` (never npm's cache), or at a global `passport-bridge` of the same version or newer. An upgrade rewrites the launcher and the `cli/current` link in one rename each, so hooks follow without being edited; the launcher runs the recorded node, or the node on PATH once that one is removed. A hook from an older init that names a version folder is replaced where it stands, next to your other hooks. Once the new copy is in place, older copies are deleted unless a hook still runs them.
|
|
@@ -152,15 +152,15 @@ Eight steps, each reusing the command that owns it:
|
|
|
152
152
|
|
|
153
153
|
What changes on disk, and how to undo it:
|
|
154
154
|
|
|
155
|
-
| Where | What | Undo
|
|
156
|
-
| ------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |
|
|
157
|
-
| `~/.passport/credentials.json` | A `cli@<workspace>` profile, as `passport login` writes | `passport logout`
|
|
158
|
-
| `~/.passport/cli/` | A copy of this CLI, the `bin/passport` launchers hooks run, and a `current` link | Delete the folder (after removing the hooks)
|
|
159
|
-
| `~/.claude.json` | A `passport` MCP server entry, via `claude mcp add` | `claude mcp remove --scope user passport`
|
|
160
|
-
| `~/.codex/config.toml` | `[mcp_servers.passport]`, via `codex mcp add` | `codex mcp remove passport`
|
|
161
|
-
| `~/.cursor/mcp.json` | `mcpServers.passport` | Delete that entry
|
|
162
|
-
| VS Code user `mcp.json` | `servers.passport` | `MCP: List Servers`, then remove it
|
|
163
|
-
| `~/.claude/settings.json`, `~/.codex/hooks.json`, `~/.cursor/hooks.json` | Passport's audit and guard hooks | `passport hook uninstall --
|
|
155
|
+
| Where | What | Undo |
|
|
156
|
+
| ------------------------------------------------------------------------ | -------------------------------------------------------------------------------- | ------------------------------------------------- |
|
|
157
|
+
| `~/.passport/credentials.json` | A `cli@<workspace>` profile, as `passport login` writes | `passport logout` |
|
|
158
|
+
| `~/.passport/cli/` | A copy of this CLI, the `bin/passport` launchers hooks run, and a `current` link | Delete the folder (after removing the hooks) |
|
|
159
|
+
| `~/.claude.json` | A `passport` MCP server entry, via `claude mcp add` | `claude mcp remove --scope user passport` |
|
|
160
|
+
| `~/.codex/config.toml` | `[mcp_servers.passport]`, via `codex mcp add` | `codex mcp remove passport` |
|
|
161
|
+
| `~/.cursor/mcp.json` | `mcpServers.passport` | Delete that entry |
|
|
162
|
+
| VS Code user `mcp.json` | `servers.passport` | `MCP: List Servers`, then remove it |
|
|
163
|
+
| `~/.claude/settings.json`, `~/.codex/hooks.json`, `~/.cursor/hooks.json` | Passport's audit and guard hooks | `passport hook uninstall --agent <agent> --apply` |
|
|
164
164
|
|
|
165
165
|
Before editing a file it didn't create, init says which file and keeps one copy of the original as `<file>.passport-backup`. It changes only Passport's own entries, writes atomically, refuses a malformed file with one line, and leaves an existing Passport entry alone unless it points at npm's cache or a file that's gone. Ctrl-C at any point stops cleanly; run init again to pick up where it left off. A question only takes keys typed after it appears, so an Enter pressed during a pause never answers it. Any wait longer than a moment shows what it's for in the step's row (`Sign in Checking your sign-in…`); off a terminal nothing extra prints. If Passport can't be reached, init says `Couldn't reach Passport at <origin>. Check your connection, then run passport init again.` and exits 1. Without a terminal, `init` needs `--yes` (exit 6 otherwise), and `--json` needs `--yes`. It never edits your shell profile: it prints the one `PATH` line to add if you want `passport` everywhere.
|
|
166
166
|
|
|
@@ -168,7 +168,7 @@ Before editing a file it didn't create, init says which file and keeps one copy
|
|
|
168
168
|
|
|
169
169
|
```sh
|
|
170
170
|
npx passport-bridge@latest setup --org pek_example --yes # Jamf, Kandji, Intune, or any script
|
|
171
|
-
npx passport-bridge@latest setup --org pek_example --
|
|
171
|
+
npx passport-bridge@latest setup --org pek_example --agents claude-code,codex
|
|
172
172
|
```
|
|
173
173
|
|
|
174
174
|
`init` for MDM: it never asks anything and never signs in. It installs the stable copy of the CLI, adds Passport to every detected agent (Claude Code, Cursor, Codex, VS Code; Claude Desktop gets the connector step) at the one URL with the enrollment key as its hint (`https://passportmcp.com/mcp?enroll=pek_…`), turns on the guard and audit hooks for Claude Code, Codex, and Cursor, and records the key in `$PASSPORT_HOME/enrollment.json` (mode 600). It prints one line per agent:
|
|
@@ -181,7 +181,14 @@ Codex ✓ Passport added · sign in: codex mcp login passport · guard o
|
|
|
181
181
|
Each agent asks you to sign in to Passport the first time it connects.
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
-
The first line names the workspace the key pre-selects (`GET /api/auth/enrollment/<key>`, public, no credential). It exits 0 even with no agents (`No supported agents found. Nothing to set up.`), so an MDM run never fails a computer without them. A malformed key or `--
|
|
184
|
+
The first line names the workspace the key pre-selects (`GET /api/auth/enrollment/<key>`, public, no credential). It exits 0 even with no agents (`No supported agents found. Nothing to set up.`), so an MDM run never fails a computer without them. A malformed key or `--agents` list (`--clients` still works) exits 6, and so does a key the server doesn't know or has revoked, with the server's one line (`This enrollment key isn't valid.` or `This enrollment key was revoked. Ask your admin for a new one.`) before anything changes. `passport login` on that computer later passes the recorded key: as the browser sign-in hint (`POST /api/auth/cli/start { enroll }`) and for rollout attribution when the CLI credential is minted (`enrollmentKey`). A server that doesn't serve the one URL yet still gets the CLI, hooks, and key, and the agents wait for `passport init`. Run it again any time: it changes nothing that's in place and repairs what drifted (a removed hook, an entry pointing at npm's cache). The enrollment key is a workspace hint, not a credential: people still sign in as themselves. `--cloud <origin>` (or `PASSPORT_CLOUD`) points it at a self-hosted Passport. `--json` prints `{version,origin,universal,url?,workspace?:{id,name},enrollment,clients:[{agent,name,mcp,guard,message?,next?}]}`.
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
sudo npx passport-bridge@latest setup --org pek_example --yes --lock # lock the guard on
|
|
188
|
+
sudo npx passport-bridge@latest setup --org pek_example --yes --lock --strict # and allow only managed hooks
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
`--lock`, run as root, puts the guard and audit hooks in each agent's managed settings instead of the per-person steps (as root those would write into root's home), so people can't turn them off (`src/cliSetupLock.ts`, `src/lockedHooks.ts`, a checked copy of `shared/lockedHooks.ts`). It writes a root-owned launcher (`/Library/Application Support/Passport/bin/passport` on macOS, `/opt/passport/bin/passport` on Linux, 0755) that sets `PASSPORT_HOOK_VIA=managed` and runs the person's own `$PASSPORT_HOME/cli/bin/passport`; without one it lets the command run, or with `--strict` blocks it with `Passport's guard isn't set up for you yet. Run: npx passport-bridge@latest init`. Then per agent: Claude Code gets the drop-in `managed-settings.d/50-passport.json`; Codex's `/etc/codex/requirements.toml` gets Passport's `[features]`/`[hooks]` lines between `# >>> passport` and `# <<< passport`; Cursor's system `hooks.json` gets Passport's two entries beside everyone else's. `--strict` adds `allowManagedHooksOnly` and `onFailure: "block"` (Claude Code), `allow_managed_hooks_only = true` (Codex), and `failClosed` (Cursor). A file it can't merge safely (someone else's drop-in or `[hooks]`, `hooks = false`, `disableAllHooks`, invalid JSON) is left untouched with the fix. Atomic writes, files 0644. Without root, or on Windows, it writes nothing and prints `Locking needs administrator rights. Run it with sudo, or deploy these through MDM:` with each path. `--clients` narrows it; `--strict` without `--lock` exits 6. It exits 0 and prints one line per agent (`Claude Code Locked · <path>`, `Already locked`, or `! Not locked: <reason>`); `--json` prints `{version,lock:{strict,shim,agents:[{agent,state,path,message?}]}}` with `state` one of `locked`, `already_locked`, `conflict`, `needs_admin`, `failed`. A hook from the person's own settings stands down when managed settings already run Passport's guard (`src/managedHooks.ts`). `PASSPORT_MANAGED_ROOT` puts every managed path under a folder (tests). Vendor docs: code.claude.com/docs/en/settings, code.claude.com/docs/en/hooks, learn.chatgpt.com/docs/enterprise/managed-configuration, cursor.com/docs/agent/hooks.
|
|
185
192
|
|
|
186
193
|
### Team workflows
|
|
187
194
|
|
|
@@ -189,8 +196,8 @@ Codex and Claude Code on macOS and Linux. Requires a member profile.
|
|
|
189
196
|
|
|
190
197
|
```sh
|
|
191
198
|
passport setup list
|
|
192
|
-
passport setup install <setup-id> <workflow-key> --
|
|
193
|
-
passport setup install <setup-id> <workflow-key> --
|
|
199
|
+
passport setup install <setup-id> <workflow-key> --agent codex # preview
|
|
200
|
+
passport setup install <setup-id> <workflow-key> --agent codex --apply
|
|
194
201
|
passport setup installed
|
|
195
202
|
passport setup rollback <skill-name> --apply
|
|
196
203
|
passport setup remove <skill-name> --apply
|
|
@@ -201,9 +208,9 @@ Changes preview unless `--apply` is passed. Personal edits are preserved. `insta
|
|
|
201
208
|
### Shell hook
|
|
202
209
|
|
|
203
210
|
```sh
|
|
204
|
-
passport hook install --
|
|
211
|
+
passport hook install --agent claude-code --guard --apply # or codex, cursor
|
|
205
212
|
passport hook status
|
|
206
|
-
passport hook uninstall --
|
|
213
|
+
passport hook uninstall --agent claude-code --guard --apply # guard only
|
|
207
214
|
```
|
|
208
215
|
|
|
209
216
|
Two hooks per agent. `passport hook` runs after each shell command and records the vendor, a coarse verb, a risk class, and (with Autopilot) the environment name the flags gave and the guard's decision in Activity; the server works out the class and cause. `passport hook guard` runs before it and decides from the member's Autopilot rules (`src/cliHookGuard.ts`):
|
|
@@ -212,6 +219,10 @@ Two hooks per agent. `passport hook` runs after each shell command and records t
|
|
|
212
219
|
- **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.
|
|
213
220
|
- Each reason names its cause in one line: `Passport: railway redeploy changes Production. Approve to run it.`, or `Blocked by Passport: Team rule, no deletes in Production. Ask an admin to run it, or request an exception in Passport.`
|
|
214
221
|
|
|
222
|
+
**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.
|
|
223
|
+
|
|
224
|
+
**Script reading** (`src/cliScriptRead.ts`, `src/cliScriptText.ts`). For the project's own code, `./x.sh`, `bash x.sh`, `source x.sh`, `make <targets>` (prerequisites first, variables resolved once), and `npm|pnpm|yarn run <name>` or `npm test` (with `pre`/`post` scripts), the guard reads the file and classifies every line like a typed command; the strictest finding wins and says where it came from (`railway up changes Production (from --environment, in deploy.sh)`; Sessions shows `· from deploy.sh`). A line it can't follow makes that part **Partly checked**: no allow, reported as unchecked, with a hash (`opaqueIds`) instead of its name, keyed with 32 random bytes made on the computer and kept in `$PASSPORT_HOME/opaque-salt` (0600), never sent; suggestion counts are therefore per computer. Limits: 256 KB a file, 20 files and 3 levels a command, 30 ms a call. Results are cached in `$PASSPORT_HOME/scan-cache.json` (0600) by path, mtime, and size, then SHA-256; findings only. The after-hook reads it again and reports `drift` when it changed in between. Package scripts no longer take the launcher's fast path, since Node reads them. With a warm cache, a 60-line script adds a few milliseconds; `bench:guard --check` fails over 20 ms.
|
|
225
|
+
|
|
215
226
|
**Everyday commands** (`src/cliHookLocal.ts`, tables in `src/localCommands.ts`, `localTools.ts`, `localFiles.ts`, `localGit.ts`, `localNetwork.ts`). Local commands are placed by what they touch on this computer. The project folder (the git root, else the agent's folder; never `/` or the home folder) is Development: reads such as `ls`, `rg`, `git status`, test runners, linters, builds, and type checks are Reads; `git commit`, formatters with `--write`, package scripts, and `mv`/`cp` are Changes; `rm`, `git clean -fd`, and `git reset --hard` are Deletes. Package installs (`npm install`, `pip install`, `brew install`) are Changes in Other apps. `git push` to the default branch (origin's HEAD, else `main`/`master`) is a Change in Production, to any other branch a Change in Development; deleting a remote branch (`--delete`, `:branch`) is a Delete in Other apps because teammates share it. Temporary folders (`/tmp`, `$TMPDIR`) count as Development; deleting one whole is Irreversible. Outside the project: deleting the home folder, `/`, system paths, or the whole project is Irreversible; other writes are Changes and deletes are Deletes in Other apps; writes to keys, shell startup files, or an agent's own settings are Deletes, and reads of them are no decision. `curl`/`wget` GETs are Reads and anything that sends data is a Change, in Other apps (Development for localhost). docker `ps`/`logs` read, `run`/`build`/`compose up` change, `rm`/`prune` delete. `sudo` never runs silently. The project's own code run directly (`node scripts/check.mjs`, `npx tsx scripts/x.ts`, `bash scripts/ci.sh`, `./scripts/ci.sh`, `make test`) is a Change in Development, like a package script; Passport can't read inside it, so it is never allowed and never recorded as opaque. `tsx --test` and `./node_modules/.bin/<tool>` are their tools, `bash -lc '…'` and `sh -c '…'` are read as the line inside, and Codex's `apply_patch <<'PATCH'` is a change to the files the patch names. A checkout an agent keeps for itself (`~/.codex/worktrees/…`, `~/.cursor/worktrees/…`) is the project, not the agent's settings. Symlinks are resolved before deciding, `cd` is followed through `&&`, `;`, and subshells, and redirects are writes where they land. The server keeps a generated copy of the tables (`node scripts/generate-local-commands.mjs`) for `rules test` on the web. Allowed project work and reads are counted on the machine ("Answered for you") rather than recorded one by one; installs, pushes, and anything that asks or blocks are recorded like vendor commands, with the environment kind and never a path.
|
|
216
227
|
|
|
217
228
|
The environment comes from each vendor's own flags (`src/cliHookEnvironment.ts`): Railway `-e/--environment`, Wrangler and Sentry `-e/--env`, Vercel `--prod`/`--target` (a deploy without either is a preview), Supabase `--local`/`--linked`/`--project-ref` (`db reset` is local unless `--linked`), Stripe `--live` (test mode otherwise), `git push <remote> <branch>`, `psql` hosts (`localhost` is Development), fly and Heroku `-a/--app`, kubectl `--context`/`-n`, helm `--kube-context`/`-n`, AWS `--profile`, gcloud `--project`, plus any flags the server adds. Names follow Passport's rules (`prod|production|live|main` → Production, `stag|qa|uat|preview` → Staging, `dev|local|test|sandbox|feature|branch` → Development), and the workspace's own placement of a name wins. Anything else, or no flag at all (a linked project the hook can't see), counts as Production, and the reason says `Environment unknown, treated as Production.`
|
|
@@ -231,14 +242,20 @@ Codex has no field for `codex exec`; its prompt-free modes count as unattended,
|
|
|
231
242
|
|
|
232
243
|
The approval request carries a command summary with secrets removed on this computer (`src/cliHookRedact.ts`, using `passport scan`'s key formats plus secret-named flags, variables, JSON fields, URL credentials, and long opaque values; heredoc bodies are dropped). It is the only part of a command line that ever leaves the machine, and only approvers see it.
|
|
233
244
|
|
|
234
|
-
The guard decides from local data inside `HOOK_BUDGET_MS` (1.5 s) and prints first; only an unattended ask waits for the server, within the same budget.
|
|
245
|
+
The guard decides from local data inside `HOOK_BUDGET_MS` (1.5 s) and prints first; only an unattended ask waits for the server, within the same budget. After answering it never waits on the network: its report, the batches, and, at most every ten minutes, a refresh of a policy cache older than an hour go through the detached `passport hook flush`. Any failure is silent and fails open. Neither hook sends the raw command line, output, folder path, or environment. Both hooks exchange the profile's refresh credential without rotating it and keep the short-lived access token in `$PASSPORT_HOME/.<profile>.access.json` (`src/accessTokenCache.ts`, mode 600, atomic replace), so most runs send one request instead of an exchange and then the request. A cached token is used only with more than a minute left; a 401 on it drops it, exchanges once, and retries once.
|
|
235
246
|
|
|
236
247
|
An ask becomes one Activity row. In Claude Code, with the audit hook registered, the guard parks its report in `$PASSPORT_HOME/hook-pending/` (`src/cliHookPending.ts`, mode 600, claimed by atomic rename). The audit hook for the same tool-use id sends the run with `decision: "ask", ran: true` ("asked first, then ran"). An ask nobody claims within 30 minutes (no agent fires a hook for a declined prompt) is sent by the next hook run as `ran: false` ("asked first, not run"). An allow the server gave is parked the same way, so the run's row says `Approved earlier this session`. Cursor has no tool-use id to match, so its asks are sent at once as their own "asked first" row. Denies are always sent at once; asks and blocks the server decided are recorded by the server.
|
|
237
248
|
|
|
238
249
|
- Claude Code: `PreToolUse`, plus `PostToolUse` and `PostToolUseFailure` (failed or interrupted calls, recorded as ran with a non-zero exit), in `~/.claude/settings.json` (`CLAUDE_CONFIG_DIR` honored).
|
|
239
|
-
- Codex: the same events in `~/.codex/hooks.json` (`CODEX_HOME` honored). Codex sends every shell command as `tool_name: "Bash"` with the model's raw command string in `tool_input.command` (never shell-wrapped), so it is read exactly like Claude Code's; its `apply_patch` tool is a file edit, not a shell command, and isn't recorded. Codex supports deny only (ask fails the hook, and its allow rewrites commands), so
|
|
250
|
+
- Codex: the same events in `~/.codex/hooks.json` (`CODEX_HOME` honored). Codex sends every shell command as `tool_name: "Bash"` with the model's raw command string in `tool_input.command` (never shell-wrapped), so it is read exactly like Claude Code's; its `apply_patch` tool is a file edit, not a shell command, and isn't recorded. Codex supports deny only (an ask fails the hook open, and its allow rewrites commands), so an ask is a deny there that says why (`Codex can't ask from a hook, so Passport blocked it. Approve it in Passport or run it yourself.`), recorded as a block. With a member profile and Autopilot, it goes to Passport like an unattended ask: an approval request, then the waiting line. Trust the hooks in Codex's `/hooks`.
|
|
240
251
|
- Cursor: `beforeShellExecution`/`afterShellExecution` in `~/.cursor/hooks.json`. Cursor also imports Claude Code's hooks by default; that imported copy records nothing when Passport's own Cursor entry exists, so rows aren't doubled.
|
|
241
252
|
|
|
253
|
+
**Guard health** (`src/cliGuardHealth.ts`, states and fixes in `src/cliGuardState.ts`, a checked copy of `shared/guardContract.ts`). `passport hook status` and `passport status` show each agent's guard in the web's words, **On**, **Off**, **Outdated**, **Not trusted**, or **Locked**, and each problem's fix: `passport hook install --client <agent> --guard --apply`, `npx passport-bridge@latest init`, or `Open Codex → /hooks and trust Passport's hooks.` At most once a day (`$PASSPORT_HOME/guard/.<profile>.heartbeat`) the CLI sends `POST /api/my/guard-health` with `{cliVersion, launcherTarget?, clients: [{client, present, mode, guard, plugin, codexTrust?, locked?, disabledEnv?}]}`: flags only, never a command, path, or value. It goes from a guard run with at least 300 ms of its budget left (a hook's first one waits a day), from `passport exec`, and from `passport status`. Codex trust (`src/cliCodexTrust.ts`) compares `trusted_hash` in `~/.codex/config.toml` `[hooks.state."<hooks.json>:pre_tool_use:<group>:<handler>"]` with Codex's own hash of Passport's guard entry: SHA-256 of the sorted-key JSON of `{event_name, matcher?, hooks: [{type, command, timeout (600 when unset), async, statusMessage?, additionalContextLimit? (when not 2500)}]}`, as in openai/codex `hook_hash`/`version_for_toml`, checked against codex-cli 0.146.0's `hooks/list`. Missing is **Not trusted**, a different hash is **Not trusted** (modified), `enabled = false` is **Off**. **Locked** means managed settings hold Passport's guard: `/Library/Application Support/ClaudeCode/managed-settings.json` (and `managed-settings.d/`), `/etc/claude-code/…`, `/etc/codex/requirements.toml`, `/Library/Application Support/Cursor/hooks.json`, or `/etc/cursor/hooks.json` (`PASSPORT_MANAGED_ROOT` points tests elsewhere).
|
|
254
|
+
|
|
255
|
+
**Coverage** (`src/cliSeen.ts`). The guard counts every command it saw, per agent per day, one character per command in `$PASSPORT_HOME/seen/<profile>.<agent>.<day>.log` (an app's action, not checked, or neither), and Cursor's imported copy of Claude Code's hook doesn't count twice. Counts go in their own batches, at most every five minutes, as `seen: {batch, day, count, governed, opaque}` on `POST /api/my/cli-activity`, never inside a report that can expire. `passport status` prints `Checked: 94% of commands Passport saw this week`.
|
|
256
|
+
|
|
257
|
+
**When Passport can't be reached.** 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 (Production asks, the rest run, by default). Allow never covers an irreversible action, a second-person action is always blocked, Codex's ask is a block, and a policy synced more than 7 days ago uses the defaults. The reason ends with `Passport couldn't be reached, so this computer decided.`
|
|
258
|
+
|
|
242
259
|
`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.
|
|
243
260
|
|
|
244
261
|
The Passport plugin (`rsyed94/passport-plugins`) runs the same two hooks from the agent's plugin folder, with `PASSPORT_HOOK_VIA=plugin`. `passport hook status` shows those agents as `via plugin`, and `hook install`, `init`, and `setup --org` skip them (`Claude Code: already covered by the Passport plugin.`) so nothing is recorded twice. The plugin pins the CLI version in `src/pluginPin.ts`.
|
|
@@ -252,16 +269,19 @@ passport wait apr_123
|
|
|
252
269
|
passport sessions
|
|
253
270
|
passport sync # or: passport sync --remove
|
|
254
271
|
passport env # or: passport env set railway qa staging
|
|
272
|
+
passport actions add scripts/deploy.py --environment production --class change
|
|
273
|
+
passport actions sync # propose this repository's .passport/actions.toml
|
|
255
274
|
```
|
|
256
275
|
|
|
257
|
-
- `env` lists where commands in this folder land, read the way each vendor's own CLI reads it (`src/envResolve.ts`; order: flag, the folder's link, the vendor's default, the workspace's saved mapping, the whole-word naming rule, else Production). Link readers: `src/envLinksHosting.ts` (Railway `~/.railway/config.json`, Vercel `.vercel/project.json` / `repo.json`, Supabase `supabase/.temp/project-ref`, Wrangler config, Netlify `.netlify/state.json`, Firebase `.firebaserc` + configstore, Convex `CONVEX_DEPLOYMENT`, Neon `.neon`), `src/envLinksCloud.ts` (Fly, Heroku git remotes, kubeconfig, AWS profile, gcloud configuration, Terraform workspace, Stripe key mode), and `src/envDatabase.ts` (database URLs: only `DATABASE_URL`, `DIRECT_URL`, `POSTGRES_URL*`, `DATABASE_URL_UNPOOLED`, reduced to a host-derived key; the URL, user, and password never leave the function). Files are read fresh for every command, size-capped, and a link file symlinked out of the project is ignored (`src/envLinkFs.ts`). A name in a link file never loosens anything: an unplaced id is
|
|
276
|
+
- `env` lists where commands in this folder land, read the way each vendor's own CLI reads it (`src/envResolve.ts`; order: flag, the folder's link, the vendor's default, the workspace's saved mapping, the whole-word naming rule, else Production). Link readers: `src/envLinksHosting.ts` (Railway `~/.railway/config.json`, Vercel `.vercel/project.json` / `repo.json`, Supabase `supabase/.temp/project-ref`, Wrangler config, Netlify `.netlify/state.json`, Firebase `.firebaserc` + configstore, Convex `CONVEX_DEPLOYMENT`, Neon `.neon`), `src/envLinksCloud.ts` (Fly, Heroku git remotes, kubeconfig, AWS profile, gcloud configuration, Terraform workspace, Stripe key mode), and `src/envDatabase.ts` (database URLs: only `DATABASE_URL`, `DIRECT_URL`, `POSTGRES_URL*`, `DATABASE_URL_UNPOOLED`, reduced to a host-derived key; the URL, user, and password never leave the function). Files are read fresh for every command, size-capped, and a link file symlinked out of the project is ignored (`src/envLinkFs.ts`). For a placed id its mapping decides, and a different name in the link file is treated as a rename (sent as the new label, which the server stores). A name in a link file never loosens anything: an unplaced id is named only by a label the server confirmed through the connected app (`resources[].confirmed`), which the naming rule then reads (`source: "name"`, shown as `Staging (from its name)`); without one, or when it says nothing, it is assumed Production. The table keeps its columns when every row fits the terminal and stacks each row otherwise. Findings to a server that sends `resources` in cli-policy v2 carry `{kind, source, resourceKey?, label?, platform?, flag?, via}`. `env set` calls `PUT /api/my/environments/:platform/:key`; members may only say Production.
|
|
258
277
|
|
|
259
278
|
- `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.
|
|
260
279
|
- `wait` long-polls `GET /api/my/approvals/<id>/wait`. Approved: `Approved by Ramish. Run the command again.` (exit 0). Declined: the note for the agent, `Declined by Ramish: <note>` (exit 5, cause `approval_denied`). Expired: `Expired. The agent can ask again.` (exit 5, cause `approval_expired`). Still waiting at `--timeout` (default 100 seconds, under an agent's 2-minute command limit): exit 4 with the same command as `next`.
|
|
261
280
|
- `sessions` lists recent sessions (`GET /api/my/agent-sessions`): status, agent, folder, start, `42 ran · 2 asked · 1 blocked`, environments touched, and `Waiting for you` when approvals are pending.
|
|
262
281
|
- `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`, `setup --org`, every rules refresh, and `passport sync`; `hook uninstall`, `sync --remove`, and signing out of the last profile take the entries out.
|
|
263
|
-
- `status` adds `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`.
|
|
264
|
-
- `
|
|
282
|
+
- `status` adds each agent's guard (`Guard: Claude Code On · Codex Not trusted`), the coverage line, and each fix, and sends the daily guard report when due. It also adds today's speed line, `Passport added 0.3 s 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`.
|
|
283
|
+
- `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.
|
|
284
|
+
- `rules test`, `sessions`, `actions`, and `sync` need a member profile. `wait` also works for a cloud agent's key, on the approval its own `passport exec` opened.
|
|
265
285
|
|
|
266
286
|
### Keys and passport exec
|
|
267
287
|
|
|
@@ -272,9 +292,10 @@ passport keys add railway # store a key you paste (stdin, never echoed)
|
|
|
272
292
|
passport exec -- railway up -e staging
|
|
273
293
|
```
|
|
274
294
|
|
|
275
|
-
-
|
|
295
|
+
- After a move, `keys move` remembers where each removed key was in `$PASSPORT_HOME/keys-moved.json` (vendor, `~/…` location, file, field names, size, modified time; never a value or hash). With the daily guard report, files that changed are read again; a key that's back is reported as `reappeared: [vendor]` on `POST /api/my/keys/report`, so the key reads "Back on <computer>" in Apps with the fix `passport keys move`. Kept keys are never listed. The report's computer is the CLI's own sign-in (its Device); the name it sends stays for older servers.
|
|
296
|
+
- `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]` with no default (an empty answer asks again; `--yes` moves them all), 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 answers yes to `Replace the <CLI> key in Passport with the one on this computer? [y/n]`; 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 (`--yes`, no terminal), both keys stay. The scan report sent afterwards carries provider counts only.
|
|
276
297
|
- `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`).
|
|
277
|
-
- 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. An approval is used once. Blocked or declined: exit 5. No key, or it stopped working: exit 3 ("Your Railway key in Passport stopped working. Update it in Apps."). Offline: exit 1, nothing runs, and exec never uses a key on this computer instead.
|
|
298
|
+
- 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. An approval is used once. Blocked or declined: exit 5. No key, or it stopped working: exit 3 ("Your Railway key in Passport stopped working. Update it in Apps."). 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.
|
|
278
299
|
- 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.
|
|
279
300
|
- Cloud agents (Agents → Cloud agents) run exec and MCP with `PASSPORT_AGENT_KEY` and `PASSPORT_ENDPOINT`: the owner's rules decide, the owner's keys are used, and approvals go to the owner.
|
|
280
301
|
- 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.
|
|
@@ -329,7 +350,7 @@ Otherwise Passport refuses to guess: run `passport profiles`, then `passport use
|
|
|
329
350
|
A distinct agent identity for policy, selection, devices, and activity, while keeping the CLI credential surface:
|
|
330
351
|
|
|
331
352
|
```sh
|
|
332
|
-
passport login --workspace ws_example --
|
|
353
|
+
passport login --workspace ws_example --agent claude-code --profile claude-code@ws_example
|
|
333
354
|
```
|
|
334
355
|
|
|
335
356
|
### Caller attribution
|
|
@@ -434,7 +455,7 @@ Errors: `{"error":"...","cause":"blocked","exitCode":5,"app":"github"}`, optiona
|
|
|
434
455
|
|
|
435
456
|
```sh
|
|
436
457
|
passport-bridge login --cloud https://passport.example.com --workspace ws_example \
|
|
437
|
-
--
|
|
458
|
+
--agent cursor --profile cursor@ws_example
|
|
438
459
|
```
|
|
439
460
|
|
|
440
461
|
Configure the agent to launch:
|
package/dist/bridgeExchange.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* started serving. We fail closed rather than silently attribute activity to the
|
|
5
5
|
* wrong workspace.
|
|
6
6
|
*/
|
|
7
|
-
export declare const TENANT_FLIP_MESSAGE = "This
|
|
7
|
+
export declare const TENANT_FLIP_MESSAGE = "This computer's Passport sign-in now belongs to a different workspace. Reconnect this agent from the Passport web app or run `passport-bridge login`.";
|
|
8
8
|
/** The saved credential itself was refused: 401 (revoked or expired) or 409
|
|
9
9
|
* (superseded by a newer rotation that this process cannot see on disk). */
|
|
10
10
|
export declare class BridgeCredentialError extends Error {
|
package/dist/bridgeExchange.js
CHANGED
|
@@ -17,7 +17,7 @@ function safeHostname() {
|
|
|
17
17
|
* started serving. We fail closed rather than silently attribute activity to the
|
|
18
18
|
* wrong workspace.
|
|
19
19
|
*/
|
|
20
|
-
export const TENANT_FLIP_MESSAGE = "This
|
|
20
|
+
export const TENANT_FLIP_MESSAGE = "This computer's Passport sign-in now belongs to a different workspace. Reconnect this agent from the Passport web app or run `passport-bridge login`.";
|
|
21
21
|
const ROTATION_PERSISTENCE_MESSAGE = "Passport rotated the credential, but durable local recovery is still pending. Repair the credential store and retry.";
|
|
22
22
|
/** The saved credential itself was refused: 401 (revoked or expired) or 409
|
|
23
23
|
* (superseded by a newer rotation that this process cannot see on disk). */
|
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import { ensureOneLinerRuntime, oneLinerNodeProblem } from "./nodeVersion.js";
|
|
|
14
14
|
/**
|
|
15
15
|
* passport-bridge — the local tier.
|
|
16
16
|
*
|
|
17
|
-
* passport-bridge login [--cloud URL] [--
|
|
17
|
+
* passport-bridge login [--cloud URL] [--agent NAME] [--profile NAME] [--target T]
|
|
18
18
|
* passport-bridge serve [--profile NAME] (what agents launch)
|
|
19
19
|
* passport-bridge status
|
|
20
20
|
* passport-bridge logout [--profile NAME]
|
|
@@ -72,7 +72,7 @@ Usage: passport-bridge [command] [options]
|
|
|
72
72
|
|
|
73
73
|
Commands:
|
|
74
74
|
serve Connect an agent using a saved profile (default)
|
|
75
|
-
login Sign in and save a rotating bridge
|
|
75
|
+
login Sign in and save a rotating bridge sign-in
|
|
76
76
|
status Check saved bridge profiles
|
|
77
77
|
logout Revoke and remove a saved profile
|
|
78
78
|
scan Find keys your agents can reach. Local, no account
|
|
@@ -83,8 +83,8 @@ Options:
|
|
|
83
83
|
--profile <name> Use a named profile (default: default)
|
|
84
84
|
--cloud <url> Passport URL for login
|
|
85
85
|
--workspace <id> Workspace for login
|
|
86
|
-
--
|
|
87
|
-
--target <target>
|
|
86
|
+
--agent <name> agent identity for login (--client still works)
|
|
87
|
+
--target <target> Sign-in target for login
|
|
88
88
|
-h, --help Show this help
|
|
89
89
|
-V, --version Show the package version
|
|
90
90
|
`);
|
|
@@ -103,7 +103,7 @@ async function serve() {
|
|
|
103
103
|
if (!refreshToken || !endpoint) {
|
|
104
104
|
const saved = getProfile(profile);
|
|
105
105
|
if (!saved) {
|
|
106
|
-
log(`no
|
|
106
|
+
log(`no sign-in for profile "${profile}". Run: passport-bridge login --profile ${profile}`);
|
|
107
107
|
process.exit(1);
|
|
108
108
|
}
|
|
109
109
|
endpoint = saved.endpoint;
|
|
@@ -274,7 +274,7 @@ async function login() {
|
|
|
274
274
|
// The agent this credential is for (claude-code, cursor, …). Defaults to
|
|
275
275
|
// the profile name for back-compat; the install instructions always pass it
|
|
276
276
|
// explicitly so the gateway labels the device and applies policy correctly.
|
|
277
|
-
const client = arg("--client", profile);
|
|
277
|
+
const client = arg("--agent", arg("--client", profile));
|
|
278
278
|
// Which workspace to sign into. A multi-tenant cloud with the demo off can't
|
|
279
279
|
// resolve a tenant from a bare device/start (there's no session yet), so the
|
|
280
280
|
// install instructions always pass this; the whole approve chain stays in it.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `passport actions` (Batch A item 5): tell Passport what a project's own
|
|
3
|
+
* script does, so the guard can check it.
|
|
4
|
+
*
|
|
5
|
+
* passport actions the workspace's project scripts
|
|
6
|
+
* passport actions add <script> [args…] --environment <kind> --class <class>
|
|
7
|
+
* passport actions add --id <op_…> --environment <kind> --class <class>
|
|
8
|
+
* passport actions sync propose this repository's .passport/actions.toml
|
|
9
|
+
*
|
|
10
|
+
* The CLI sends the script's path in the repository, its arguments as a glob,
|
|
11
|
+
* the repository's remote fingerprint and name, and the SHA-256 of what it runs
|
|
12
|
+
* (so Passport can say "changed since set"). Never the script's contents.
|
|
13
|
+
* `--id` resolves a Session row's "Tell Passport what this does" on this
|
|
14
|
+
* computer, from the scan cache: the server only ever had the keyed hash.
|
|
15
|
+
*
|
|
16
|
+
* A member may say a script changes, deletes, or can't be undone in
|
|
17
|
+
* Production; anything else is proposed until an admin approves it.
|
|
18
|
+
*/
|
|
19
|
+
import { type ParsedArgs } from "./cliArgs.js";
|
|
20
|
+
import { type MemberApi } from "./cliClient.js";
|
|
21
|
+
import { type LocalFs } from "./cliHookLocal.js";
|
|
22
|
+
import { type CommandResult, type Runtime } from "./cliSupport.js";
|
|
23
|
+
export type ActionsDependencies = {
|
|
24
|
+
api?: MemberApi;
|
|
25
|
+
fs?: LocalFs;
|
|
26
|
+
cwd?: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function actions(args: ParsedArgs, runtime: Runtime, deps?: ActionsDependencies): Promise<CommandResult>;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `passport actions` (Batch A item 5): tell Passport what a project's own
|
|
3
|
+
* script does, so the guard can check it.
|
|
4
|
+
*
|
|
5
|
+
* passport actions the workspace's project scripts
|
|
6
|
+
* passport actions add <script> [args…] --environment <kind> --class <class>
|
|
7
|
+
* passport actions add --id <op_…> --environment <kind> --class <class>
|
|
8
|
+
* passport actions sync propose this repository's .passport/actions.toml
|
|
9
|
+
*
|
|
10
|
+
* The CLI sends the script's path in the repository, its arguments as a glob,
|
|
11
|
+
* the repository's remote fingerprint and name, and the SHA-256 of what it runs
|
|
12
|
+
* (so Passport can say "changed since set"). Never the script's contents.
|
|
13
|
+
* `--id` resolves a Session row's "Tell Passport what this does" on this
|
|
14
|
+
* computer, from the scan cache: the server only ever had the keyed hash.
|
|
15
|
+
*
|
|
16
|
+
* A member may say a script changes, deletes, or can't be undone in
|
|
17
|
+
* Production; anything else is proposed until an admin approves it.
|
|
18
|
+
*/
|
|
19
|
+
import { posix } from "node:path";
|
|
20
|
+
import { readBoundedJson } from "./boundedResponse.js";
|
|
21
|
+
import { value } from "./cliArgs.js";
|
|
22
|
+
import { memberApi } from "./cliClient.js";
|
|
23
|
+
import { localMachine, NODE_FS } from "./cliHookLocal.js";
|
|
24
|
+
import { lookupOpaqueId, normalizeRemote, originUrl, remoteFingerprint, sha256 } from "./cliScriptRead.js";
|
|
25
|
+
import { linesDigestInput, makeLines, packageLines, parseRepoActions } from "./cliScriptText.js";
|
|
26
|
+
import { callerFrom, failure, resolveCliAuth, safeApiError, timeoutMs } from "./cliSupport.js";
|
|
27
|
+
const ENVIRONMENTS = new Set(["production", "staging", "development"]);
|
|
28
|
+
const CLASSES = new Set(["read", "change", "delete", "irreversible"]);
|
|
29
|
+
const RUNNERS = new Set(["make", "npm", "pnpm", "yarn"]);
|
|
30
|
+
const ENV_WORD = { production: "Production", staging: "Staging", development: "Development" };
|
|
31
|
+
function api(args, runtime, deps) {
|
|
32
|
+
if (deps.api)
|
|
33
|
+
return deps.api;
|
|
34
|
+
const auth = resolveCliAuth(args, runtime.env);
|
|
35
|
+
if (auth.kind !== "profile") {
|
|
36
|
+
return failure("This needs a member profile.", 6, "member_profile_required", { hint: "Run: passport login" });
|
|
37
|
+
}
|
|
38
|
+
return memberApi({ auth, caller: callerFrom(args, runtime.env), timeoutMs: timeoutMs(args), signal: runtime.signal });
|
|
39
|
+
}
|
|
40
|
+
/** The repository here: its root, fingerprint, and name. */
|
|
41
|
+
function repository(cwd, runtime, fs) {
|
|
42
|
+
const machine = localMachine(cwd, runtime.env, fs);
|
|
43
|
+
const root = machine.projectRoot;
|
|
44
|
+
const read = (path) => fs.readScript?.(path)?.text ?? fs.readText(path);
|
|
45
|
+
const remote = root ? normalizeRemote(originUrl(root, read) ?? "") : null;
|
|
46
|
+
return {
|
|
47
|
+
root,
|
|
48
|
+
cwd: machine.cwd,
|
|
49
|
+
...(remote ? { repo: remoteFingerprint(remote), repoName: remote.split("/").pop() } : {})
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** What `<script> [args…]` names, with the hash of what it runs today. */
|
|
53
|
+
function describeScript(words, explicitArgs, repo, fs) {
|
|
54
|
+
const [first, ...rest] = words;
|
|
55
|
+
if (!first)
|
|
56
|
+
return "Name the script: passport actions add scripts/deploy.sh --environment production --class change";
|
|
57
|
+
const cwd = repo.cwd ?? repo.root;
|
|
58
|
+
if (!cwd)
|
|
59
|
+
return "Run this inside the project.";
|
|
60
|
+
const ids = { ...(repo.repo ? { repo: repo.repo, repoName: repo.repoName } : {}) };
|
|
61
|
+
if (RUNNERS.has(first)) {
|
|
62
|
+
// `make deploy`, `npm run deploy`: what the target or package script runs.
|
|
63
|
+
const target = first === "make" ? rest.join(" ") : `run ${rest.filter((word) => word !== "run").join(" ")}`;
|
|
64
|
+
const args = explicitArgs ?? target;
|
|
65
|
+
const file = first === "make"
|
|
66
|
+
? ["GNUmakefile", "makefile", "Makefile"].map((name) => posix.join(cwd, name)).find((path) => fs.isFile(path))
|
|
67
|
+
: posix.join(cwd, "package.json");
|
|
68
|
+
const text = file ? fs.readScript?.(file)?.text : undefined;
|
|
69
|
+
const lines = text
|
|
70
|
+
? first === "make"
|
|
71
|
+
? makeLines(text, rest)
|
|
72
|
+
: packageLines(text, rest.filter((word) => word !== "run")[0] ?? "")
|
|
73
|
+
: null;
|
|
74
|
+
return {
|
|
75
|
+
program: first,
|
|
76
|
+
args,
|
|
77
|
+
...ids,
|
|
78
|
+
...(lines && !lines.partial ? { contentHash: sha256(linesDigestInput(lines)) } : {})
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const path = first.startsWith("/") ? posix.normalize(first) : posix.join(cwd, first);
|
|
82
|
+
if (!fs.isFile(path))
|
|
83
|
+
return `There's no ${first} here.`;
|
|
84
|
+
const real = fs.realpath(path) ?? path;
|
|
85
|
+
const relative = repo.root ? posix.relative(fs.realpath(repo.root) ?? repo.root, real) : posix.basename(real);
|
|
86
|
+
if (!relative || relative.startsWith(".."))
|
|
87
|
+
return "That script is outside this project.";
|
|
88
|
+
const file = fs.readScript?.(real);
|
|
89
|
+
return {
|
|
90
|
+
program: relative,
|
|
91
|
+
args: explicitArgs ?? (rest.length ? rest.join(" ") : "*"),
|
|
92
|
+
...ids,
|
|
93
|
+
...(file ? { contentHash: sha256(file.text) } : {})
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function fromOpaque(target) {
|
|
97
|
+
return {
|
|
98
|
+
program: target.program,
|
|
99
|
+
args: target.args || "*",
|
|
100
|
+
...(target.repo ? { repo: target.repo } : {}),
|
|
101
|
+
...(target.hash ? { contentHash: target.hash } : {})
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async function post(client, body, args, runtime) {
|
|
105
|
+
const response = await client.fetchApi("/api/my/project-actions", {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers: { "content-type": "application/json", accept: "application/json" },
|
|
108
|
+
body: JSON.stringify(body),
|
|
109
|
+
signal: AbortSignal.any([runtime.signal, AbortSignal.timeout(timeoutMs(args))])
|
|
110
|
+
});
|
|
111
|
+
if (!response.ok)
|
|
112
|
+
return { error: await safeApiError(response, "Passport couldn't save it."), status: response.status };
|
|
113
|
+
const parsed = (await readBoundedJson(response).catch(() => ({})));
|
|
114
|
+
return { action: parsed.action ?? {} };
|
|
115
|
+
}
|
|
116
|
+
function line(action, fallback) {
|
|
117
|
+
const label = action.label ?? fallback;
|
|
118
|
+
const where = action.environment ? (ENV_WORD[action.environment] ?? action.environment) : "";
|
|
119
|
+
const what = action.actionClass ?? "";
|
|
120
|
+
return action.status === "proposed"
|
|
121
|
+
? `${label}: proposed (${what} in ${where}). An admin approves it in Passport Rules › Environments.`
|
|
122
|
+
: `${label}: ${what} in ${where}. Passport checks it from now on.`;
|
|
123
|
+
}
|
|
124
|
+
function classified(args) {
|
|
125
|
+
const environment = value(args, "environment")?.toLowerCase() ?? "";
|
|
126
|
+
const actionClass = value(args, "class")?.toLowerCase() ?? "";
|
|
127
|
+
if (!ENVIRONMENTS.has(environment)) {
|
|
128
|
+
return failure("--environment takes production, staging, or development.", 6, "usage");
|
|
129
|
+
}
|
|
130
|
+
if (!CLASSES.has(actionClass))
|
|
131
|
+
return failure("--class takes read, change, delete, or irreversible.", 6, "usage");
|
|
132
|
+
return { environment, class: actionClass };
|
|
133
|
+
}
|
|
134
|
+
async function add(args, runtime, deps) {
|
|
135
|
+
const kind = classified(args);
|
|
136
|
+
const fs = deps.fs ?? NODE_FS;
|
|
137
|
+
const id = value(args, "id");
|
|
138
|
+
let target;
|
|
139
|
+
if (id) {
|
|
140
|
+
const known = lookupOpaqueId(id);
|
|
141
|
+
if (!known) {
|
|
142
|
+
return failure("This computer doesn't know that script. Run the command on the computer that ran it, or name the script.", 6, "unknown_id");
|
|
143
|
+
}
|
|
144
|
+
target = fromOpaque(known);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
target = describeScript(args.positionals.slice(1), value(args, "args"), repository(deps.cwd ?? process.cwd(), runtime, fs), fs);
|
|
148
|
+
}
|
|
149
|
+
if (typeof target === "string")
|
|
150
|
+
return failure(target, 6, "usage");
|
|
151
|
+
const client = api(args, runtime, deps);
|
|
152
|
+
const saved = await post(client, { ...target, ...kind, source: id ? "session" : "cli" }, args, runtime);
|
|
153
|
+
if ("error" in saved) {
|
|
154
|
+
return failure(saved.error, saved.status === 403 ? 5 : saved.status === 400 ? 6 : 1, "server");
|
|
155
|
+
}
|
|
156
|
+
return { json: { action: saved.action }, human: line(saved.action, target.program), essential: true };
|
|
157
|
+
}
|
|
158
|
+
/** Propose every entry of this repository's `.passport/actions.toml`. */
|
|
159
|
+
async function sync(args, runtime, deps) {
|
|
160
|
+
const fs = deps.fs ?? NODE_FS;
|
|
161
|
+
const repo = repository(deps.cwd ?? process.cwd(), runtime, fs);
|
|
162
|
+
if (!repo.root)
|
|
163
|
+
return failure("Run this inside the project.", 6, "usage");
|
|
164
|
+
const text = fs.readScript?.(posix.join(repo.root, ".passport", "actions.toml"))?.text;
|
|
165
|
+
if (!text)
|
|
166
|
+
return failure("This project has no .passport/actions.toml.", 6, "usage");
|
|
167
|
+
const entries = parseRepoActions(text).filter((entry) => ENVIRONMENTS.has(entry.environment) && CLASSES.has(entry.class));
|
|
168
|
+
if (!entries.length)
|
|
169
|
+
return failure(".passport/actions.toml has no actions Passport can read.", 6, "usage");
|
|
170
|
+
const client = api(args, runtime, deps);
|
|
171
|
+
const lines = [];
|
|
172
|
+
const results = [];
|
|
173
|
+
for (const entry of entries) {
|
|
174
|
+
const target = describeScript([entry.program], entry.args, repo, fs);
|
|
175
|
+
if (typeof target === "string") {
|
|
176
|
+
lines.push(`${entry.program}: ${target}`);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const saved = await post(client, { ...target, environment: entry.environment, class: entry.class, source: "repo" }, args, runtime);
|
|
180
|
+
if ("error" in saved)
|
|
181
|
+
lines.push(`${entry.program}: ${saved.error}`);
|
|
182
|
+
else {
|
|
183
|
+
results.push(saved.action);
|
|
184
|
+
lines.push(line(saved.action, entry.program));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return { json: { actions: results }, human: lines.join("\n"), essential: true };
|
|
188
|
+
}
|
|
189
|
+
async function list(args, runtime, deps) {
|
|
190
|
+
const client = api(args, runtime, deps);
|
|
191
|
+
const response = await client.fetchApi("/api/my/autopilot", {
|
|
192
|
+
headers: { accept: "application/json" },
|
|
193
|
+
signal: AbortSignal.any([runtime.signal, AbortSignal.timeout(timeoutMs(args))])
|
|
194
|
+
});
|
|
195
|
+
if (!response.ok)
|
|
196
|
+
return failure(await safeApiError(response, "Passport couldn't list them."), 1, "server");
|
|
197
|
+
const body = (await readBoundedJson(response).catch(() => ({})));
|
|
198
|
+
const actions = body.projectActions ?? [];
|
|
199
|
+
const human = actions.length
|
|
200
|
+
? actions
|
|
201
|
+
.map((action) => {
|
|
202
|
+
const where = action.environment ? (ENV_WORD[action.environment] ?? action.environment) : "";
|
|
203
|
+
const notes = [
|
|
204
|
+
action.repoName ?? "Any repository",
|
|
205
|
+
...(action.setByName ? [`Set by ${action.setByName}`] : []),
|
|
206
|
+
...(action.status === "proposed" ? ["Proposed"] : []),
|
|
207
|
+
...(action.changedAt ? ["Changed since set"] : [])
|
|
208
|
+
];
|
|
209
|
+
return `${action.label ?? "script"} ${where} · ${action.actionClass ?? ""} ${notes.join(" · ")}`;
|
|
210
|
+
})
|
|
211
|
+
.join("\n")
|
|
212
|
+
: "No project scripts yet. Add one: passport actions add <script> --environment <kind> --class <class>";
|
|
213
|
+
return { json: { actions }, human };
|
|
214
|
+
}
|
|
215
|
+
export async function actions(args, runtime, deps = {}) {
|
|
216
|
+
const action = args.positionals[0];
|
|
217
|
+
if (action === undefined || action === "list")
|
|
218
|
+
return list(args, runtime, deps);
|
|
219
|
+
if (action === "add")
|
|
220
|
+
return add(args, runtime, deps);
|
|
221
|
+
if (action === "sync")
|
|
222
|
+
return sync(args, runtime, deps);
|
|
223
|
+
return failure("Use passport actions, actions add, or actions sync.", 6, "usage");
|
|
224
|
+
}
|
package/dist/cliAnswered.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ export declare function localDay(now: number): string;
|
|
|
19
19
|
export declare function noteAnswered(profile: string, now?: number): void;
|
|
20
20
|
/** Prompts answered on this computer today. */
|
|
21
21
|
export declare function answeredToday(profile: string, now?: number): number;
|
|
22
|
+
/** Whether a batch report is due, without claiming it. Never throws. */
|
|
23
|
+
export declare function reportIntervalDue(profile: string, now?: number): boolean;
|
|
24
|
+
/** At most one batch report (answered counts and speed numbers) per interval
|
|
25
|
+
* per profile, claimed before any network. Never throws. */
|
|
26
|
+
export declare function claimReportInterval(profile: string, now?: number): boolean;
|
|
22
27
|
/** The next batch to report, or null. A batch that wasn't confirmed is sent again as is. */
|
|
23
28
|
export declare function claimAnsweredBatch(profile: string, now?: number, force?: boolean): {
|
|
24
29
|
batch: string;
|