passport-bridge 0.17.0 → 0.19.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.
- package/README.md +23 -20
- package/dist/approvalLines.d.ts +17 -0
- package/dist/approvalLines.js +40 -0
- package/dist/approvalNote.d.ts +20 -0
- package/dist/approvalNote.js +33 -0
- package/dist/cli.js +5 -5
- package/dist/cliArgs.d.ts +5 -0
- package/dist/cliArgs.js +12 -5
- package/dist/cliGuardHealth.d.ts +1 -1
- package/dist/cliGuardHealth.js +1 -1
- package/dist/cliHook.js +31 -10
- package/dist/cliHookDecide.d.ts +14 -0
- package/dist/cliHookDecide.js +61 -3
- package/dist/cliHookDeliver.d.ts +8 -1
- package/dist/cliHookDeliver.js +3 -3
- package/dist/cliHookHold.d.ts +91 -0
- package/dist/cliHookHold.js +168 -0
- package/dist/cliHookInstall.d.ts +8 -1
- package/dist/cliHookInstall.js +58 -12
- package/dist/cliHookKey.d.ts +25 -0
- package/dist/cliHookKey.js +160 -0
- package/dist/cliHookRedact.d.ts +13 -0
- package/dist/cliHookRedact.js +60 -0
- package/dist/cliInit.js +6 -1
- package/dist/cliMain.js +96 -38
- package/dist/cliOutput.js +11 -11
- package/dist/cliPolicyRefresh.d.ts +1 -1
- package/dist/cliPolicyRefresh.js +1 -1
- package/dist/cliScan.d.ts +17 -2
- package/dist/cliScan.js +29 -8
- package/dist/cliSetupLock.js +1 -1
- package/dist/cliSetupOrg.js +18 -6
- package/dist/cliWait.d.ts +7 -8
- package/dist/cliWait.js +50 -19
- package/dist/completion.js +14 -10
- package/dist/doctor.js +14 -0
- package/dist/enrollment.js +1 -1
- package/dist/holdNotice.d.ts +23 -0
- package/dist/holdNotice.js +73 -0
- package/dist/initAgents.d.ts +12 -3
- package/dist/initAgents.js +40 -9
- package/dist/initAutopilotStep.d.ts +2 -4
- package/dist/initAutopilotStep.js +6 -5
- package/dist/initLocalSteps.d.ts +0 -18
- package/dist/initLocalSteps.js +2 -78
- package/dist/initOutro.js +0 -2
- package/dist/initPlan.js +10 -14
- package/dist/initState.d.ts +0 -2
- package/dist/initState.js +0 -10
- package/dist/launcherFastPath.js +11 -4
- package/dist/lockedHooks.d.ts +1 -1
- package/dist/lockedHooks.js +3 -3
- package/dist/loginFlow.js +1 -1
- package/dist/managedHooks.js +1 -1
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ passport run github_search_issues '{"query":"SSO"}'
|
|
|
51
51
|
| Command | Purpose |
|
|
52
52
|
| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
53
53
|
| `init [--yes] [--move-keys] [--no-open] [--cloud <origin>] [--skip-apps\|--skip-agents\|--skip-guard] [--verbose] [--json]` | Set up Passport for this computer's agents in one pass. Every step asks first, can be skipped, and is safe to run again. |
|
|
54
|
+
| `init --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). |
|
|
54
55
|
| `login` | Browser sign-in or sign-up (or device sign-in with `--workspace`); saves a rotating CLI credential and makes the profile active. |
|
|
55
56
|
| `logout` | Revoke the credential and always remove the local profile (warns if revocation fails). |
|
|
56
57
|
| `profiles` / `use <name>` | List stored profiles / select the active one. Offline. |
|
|
@@ -63,14 +64,12 @@ passport run github_search_issues '{"query":"SSO"}'
|
|
|
63
64
|
| `connect [app...] [--alias <name>] [--open] [--wait <s>]` | Show member sign-in links and optionally wait for completion. |
|
|
64
65
|
| `resources [uri] [--out <file>]` | List or read MCP resources. |
|
|
65
66
|
| `prompts [name] [--set k=v] [--out <file>]` | List or get MCP prompts. |
|
|
66
|
-
| `scan [--path <dir>] [--verbose] [--check]`
|
|
67
|
-
| `discover` | Scan local MCP configuration and submit a privacy-minimized fleet report. Exit 5 on a managed-policy violation. |
|
|
67
|
+
| `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. |
|
|
68
68
|
| `hook` | Records the CLIs agents run and, with `--guard`, decides each one before it runs from your Autopilot rules (`install`, `uninstall`, `status`). |
|
|
69
|
-
| `wait <approval-id> [--timeout <s>]` | Wait for a person to decide an approval request
|
|
69
|
+
| `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
70
|
| `rules test "<command>" [--environment <kind>]` | What Autopilot decides for a command, why, and which environment it acts on. |
|
|
71
71
|
| `sessions [--status running\|idle\|ended]` | Your agents' recent sessions with what Passport decided. |
|
|
72
72
|
| `undo <action-id>\|--last [--option <id>] [--yes]` | Undo an action Passport took a backup before, within 7 days. See [Undo](#undo). |
|
|
73
|
-
| `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). |
|
|
74
73
|
| `setup` | Install and maintain assigned team workflows as managed skills. |
|
|
75
74
|
| `session` | Run NDJSON commands over one authenticated MCP session. |
|
|
76
75
|
| `access` | Signed managed access: `keygen`, `actions`, `run`, `invoke`, `status`, `cancel`. |
|
|
@@ -120,7 +119,9 @@ passport scan --path ../api --verbose
|
|
|
120
119
|
passport scan --check # CI and pre-commit: files only, exit 5 on a high or medium key
|
|
121
120
|
```
|
|
122
121
|
|
|
123
|
-
Reads agent MCP configs (Claude Desktop, Claude Code, Cursor, VS Code, Codex), CLI sign-in files (GitHub CLI, Railway, Vercel, Wrangler, AWS, Stripe CLI, Supabase, npm), well-known shell variable names, and `.env*` files up to three folders deep in the project. It never prints or
|
|
122
|
+
Reads agent MCP configs (Claude Desktop, Claude Code, Cursor, VS Code, Codex), CLI sign-in files (GitHub CLI, Railway, Vercel, Wrangler, AWS, Stripe CLI, Supabase, npm), well-known shell variable names, and `.env*` files up to three folders deep in the project. It never prints, saves, or sends any part of a key, needs no profile, and skips `.env` files in your home folder. Sign-ins held by the OS keychain are named but not flagged. `passport-bridge scan` and `passport-bridge init` run the `passport` CLI's own implementation.
|
|
123
|
+
|
|
124
|
+
Signed in (a member profile, never an agent token), scan then sends the MCP-config inventory to `POST /api/my/discovery/scan` for **Agents → Discovered**: each MCP server's name and how it connects, never paths, commands, arguments, environment values, or keys. The closing line becomes `No key left this computer.` followed by what Passport made of it (`Sent the MCP setup on <computer> to Passport: …`), and a workspace that requires MCP servers to go through Passport makes it exit 5. A problem sending it is one line and never fails the scan. Without a profile, and with `--check`, nothing leaves the computer (`Nothing left this computer.`). `passport discover` is its old name: it still sends the inventory alone, with the same output and exit code, and says `passport discover is now part of passport scan.` on stderr.
|
|
124
125
|
|
|
125
126
|
### Set up with init
|
|
126
127
|
|
|
@@ -141,7 +142,7 @@ Eight steps, each reusing the command that owns it:
|
|
|
141
142
|
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); with `--yes` or without a terminal it prints the page, adds `passport connect --wait 300` to `next`, and moves on.
|
|
142
143
|
4. **Keys**: the recommended setup keeps them; the plan says `Your GitHub and Railway keys stay on this computer. Move them any time.` with `Run: passport keys move` under it. Step by step asks the same question as `passport keys move` for each: `Move your Railway account token into Passport and sign the Railway CLI out on this computer? [y/N]` (a long question wraps; `[y/N]` stays on its last line). Enter keeps the key here; an answer that isn't y or n asks again (`Type y or n.`). Add `--move-keys` to move every key it finds without asking; the closing list then says which (`Moved your Railway key into Passport and signed that CLI out here`) and, once per moved key, where to rotate the old one (`Rotate the old Railway key, since copies may exist elsewhere: https://railway.com/account/tokens`). When Passport already holds a different key for that CLI, an interactive run asks `Passport already holds a different Railway key. Replace it with this computer's? Every agent that uses it switches to this one.` then `Type railway to confirm, or press Enter to cancel:`: only the name replaces it and signs the CLI out, keeping links; anything else 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.
|
|
143
144
|
5. **Where** (environments): the environments Passport has placed for your apps, grouped by kind (`Production production (Railway), production (Vercel)`), one row per resource. Anything Passport can't place counts as Production and is listed once: `Treated as Production until placed: blue (Railway). Change it in Rules.` A resource named for its kind (`production` in Production) is never called assumed. This folder's links follow (`This folder: Railway production (linked), counted as Production`). With no app connected yet it says they appear once one is.
|
|
144
|
-
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
|
|
145
|
+
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 entry already at the one URL counts as set up. Once the server serves `/mcp`, an entry at this workspace's own URL or a local bridge entry for this workspace (`passport-bridge serve --profile <agent>@<workspace>`) moves to the one URL: the plan says `Move Cursor and Codex to Passport's one URL`, and each row's status is `updated`. Codex without its CLI gets its `[mcp_servers.passport]` table (and subtables) replaced in place. An entry for another workspace is left as is. No token lands in a config file. **Agents** shows `Uses an old URL` on an agent still on the workspace's own URL until init moves it. 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: on a terminal init copies the URL and says `Claude Desktop: paste the copied URL in Settings → Connectors → Add custom connector`; without one it names the URL.
|
|
145
146
|
7. **Guard**: (step by step asks `Check each shell command in <agents> before it runs? [Y/n]`) runs `passport hook install --guard` for Claude Code, Codex, and Cursor (in Codex, a command your rules ask about is blocked with how to approve it, since Codex can't show Passport's questions), 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.
|
|
146
147
|
8. **Autopilot**: how much agents can do on their own, per environment:
|
|
147
148
|
|
|
@@ -151,7 +152,7 @@ Eight steps, each reusing the command that owns it:
|
|
|
151
152
|
Development Hands-off everything except irreversible runs
|
|
152
153
|
```
|
|
153
154
|
|
|
154
|
-
The plan shows them once. Step by step asks one compact question per environment where a choice is left (`Staging: 1 Careful 2 Balanced 3 Hands-off [2]`, Enter keeps it); the recommended setup and `--yes` keep the defaults. A team floor stricter than a default is shown with why (`Your team requires Careful or stricter in Staging.`), and choices below it aren't offered. A CLI credential can only make presets stricter; a looser pick says so in one line and keeps the current ones. A re-run lists them under Done without asking. The closing list says what will ask: `Autopilot on: asks only for Production changes, deletes outside Development, and irreversible actions`. A server without Autopilot gets the
|
|
155
|
+
The plan shows them once. Step by step asks one compact question per environment where a choice is left (`Staging: 1 Careful 2 Balanced 3 Hands-off [2]`, Enter keeps it); the recommended setup and `--yes` keep the defaults. A team floor stricter than a default is shown with why (`Your team requires Careful or stricter in Staging.`), and choices below it aren't offered. A CLI credential can only make presets stricter; a looser pick says so in one line and keeps the current ones. A re-run lists them under Done without asking. The closing list says what will ask: `Autopilot on: asks only for Production changes, deletes outside Development, and irreversible actions`. A server without Autopilot gets no rules step (`Autopilot needs a newer Passport server.`); init never writes the retired safety profile.
|
|
155
156
|
|
|
156
157
|
What changes on disk, and how to undo it:
|
|
157
158
|
|
|
@@ -170,11 +171,11 @@ The plan names every file init edits before it edits any, and it keeps one copy
|
|
|
170
171
|
### Company rollout
|
|
171
172
|
|
|
172
173
|
```sh
|
|
173
|
-
npx passport-bridge@latest
|
|
174
|
-
npx passport-bridge@latest
|
|
174
|
+
npx passport-bridge@latest init --org pek_example --yes # Jamf, Kandji, Intune, or any script
|
|
175
|
+
npx passport-bridge@latest init --org pek_example --yes --agents claude-code,codex
|
|
175
176
|
```
|
|
176
177
|
|
|
177
|
-
`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:
|
|
178
|
+
`init --org` is `init` for MDM: it never asks anything and never signs in. `passport setup --org` is its old name and still runs it for one release, saying `passport setup --org is now passport init --org.` on stderr. init's own step flags (`--dry-run`, `--move-keys`, `--skip-*`, `--no-open`, `--verbose`) don't go with `--org` (exit 6), and `--agents`, `--lock`, and `--strict` need `--org`. 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:
|
|
178
179
|
|
|
179
180
|
```
|
|
180
181
|
Passport setup for passportmcp.com (enrollment pek_…mple)
|
|
@@ -184,11 +185,11 @@ Codex ✓ Passport added · sign in: codex mcp login passport · guard o
|
|
|
184
185
|
Each agent asks you to sign in to Passport the first time it connects.
|
|
185
186
|
```
|
|
186
187
|
|
|
187
|
-
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?}]}`.
|
|
188
|
+
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). When the key names its workspace, an agent on that workspace's own URL or a local bridge for it moves to the one URL (`✓ Passport updated`). 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?}]}`.
|
|
188
189
|
|
|
189
190
|
```sh
|
|
190
|
-
sudo npx passport-bridge@latest
|
|
191
|
-
sudo npx passport-bridge@latest
|
|
191
|
+
sudo npx passport-bridge@latest init --org pek_example --yes --lock # lock the guard on
|
|
192
|
+
sudo npx passport-bridge@latest init --org pek_example --yes --lock --strict # and allow only managed hooks
|
|
192
193
|
```
|
|
193
194
|
|
|
194
195
|
`--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.
|
|
@@ -253,6 +254,8 @@ An ask becomes one Activity row. In Claude Code, with the audit hook registered,
|
|
|
253
254
|
- 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`.
|
|
254
255
|
- 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.
|
|
255
256
|
|
|
257
|
+
**Hold for approval** (`src/cliHookHold.ts`). When nobody is at the keyboard and Passport opens an approval request, the guard holds for a person before answering: `hook install --guard` and `init` write `passport hook guard --hold 25` with the entry's `timeout` at 40 seconds for Claude Code (`--hold <0-45>` changes it; `0` writes today's entry; `hook install` also fixes a timeout that's too short). At runtime the hold is capped by the timeout Claude Code enforces on that entry, read from its settings, and an entry the guard can't find means no hold. If someone approves in time, the guard asks Passport again with the same request, which consumes the approval once and re-checks every rule, and only that allow runs the original command, with no retry. Anything else (no decision, a decline, expiry, an error, or a slow answer) declines the command with one line: who decides, when the request expires, and `Run "passport wait <id>" as a background command; it exits when someone decides. Then run this command again.` A decline during the hold carries the person's note. An entry without `--hold` never holds, because Claude Code runs a command when its hook outlives the timeout; `PASSPORT_HOOK_HOLD` can shorten a hold, never lengthen it. Codex never holds (its hook can't run an approved command), and neither does Cursor (what it does when a hook outlives its timeout isn't documented). Managed installs (`init --org`) don't hold yet, since a person's older CLI wouldn't know the flag. A guard from before the hold (no `--hold`, or a timeout too short for it) is named once a day, and once per CLI version, after an interactive command on a terminal: `Approvals can now continue automatically. Run: passport hook install --apply` (stderr; never from the hook, piped, or with `--json`). `passport doctor` shows the same as a warning, and `hook install --apply` keeps an existing guard current without `--guard`. Each approval binds to a normalized command key (`src/cliHookKey.ts`): every word and redirect target is redacted first, then quoting, pipes into read-only filters whose flags are all on that filter's harmless list, `2>&1`, output sent to /dev/null, and a trailing `|| true` are ignored, so an equivalent retry matches the same request. A key that still shows anything the summary hides falls back to the summary, and a key over 400 characters is sent as a SHA-256 of the whole key.
|
|
258
|
+
|
|
256
259
|
**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 (on a terminal the command goes on its own `Run:` line): `passport hook install --agent <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).
|
|
257
260
|
|
|
258
261
|
**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`.
|
|
@@ -263,7 +266,7 @@ An ask becomes one Activity row. In Claude Code, with the audit hook registered,
|
|
|
263
266
|
|
|
264
267
|
`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.
|
|
265
268
|
|
|
266
|
-
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 `
|
|
269
|
+
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 `init --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`.
|
|
267
270
|
|
|
268
271
|
### Autopilot from the terminal
|
|
269
272
|
|
|
@@ -281,9 +284,9 @@ passport actions sync # propose this repository's .passport/actions.toml
|
|
|
281
284
|
- `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.
|
|
282
285
|
|
|
283
286
|
- `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.
|
|
284
|
-
- `wait` long-polls `GET /api/my/approvals/<id>/wait
|
|
287
|
+
- `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`.
|
|
285
288
|
- `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.
|
|
286
|
-
- `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`, `
|
|
289
|
+
- `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.
|
|
287
290
|
- `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 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`.
|
|
288
291
|
- `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.
|
|
289
292
|
- `rules test`, `sessions`, `actions`, and `sync` need a member profile. `wait` also works for a cloud agent's agent token, on the approval its own `passport exec` opened.
|
|
@@ -333,7 +336,7 @@ printf '%s\n' \
|
|
|
333
336
|
- One `{"id"?:string|number,"argv":string[]}` request per line, run in order; one JSON response per line with `ok`, `exitCode`, and `result` or error fields. `id` is echoed.
|
|
334
337
|
- A failed request does not close the session. EOF, SIGINT, or SIGTERM closes it cleanly.
|
|
335
338
|
- Limits: 1 MiB per line, 128 arguments. Set `--profile`, `--caller`, and `--timeout` on `passport session`, not per request.
|
|
336
|
-
- Allowed commands: `status`, `search`, `describe`, `run`, `connect`, `resources`, `prompts
|
|
339
|
+
- Allowed commands: `status`, `search`, `describe`, `run`, `connect`, `resources`, `prompts` (and `discover`, the old inventory name, for one release).
|
|
337
340
|
- Governance is unchanged; access tokens keep normal expiry and refresh.
|
|
338
341
|
|
|
339
342
|
### Shell completion
|
|
@@ -377,7 +380,7 @@ passport ready --json
|
|
|
377
380
|
passport search "deployment status" --json
|
|
378
381
|
```
|
|
379
382
|
|
|
380
|
-
`PASSPORT_ENDPOINT` is Passport's one URL (`https://<host>/mcp
|
|
383
|
+
`PASSPORT_ENDPOINT` is Passport's one URL (`https://<host>/mcp`): the agent token's own prefix says which workspace. A workspace's own older URL (`https://<host>/w/<workspace>/mcp`) still works. Set both variables together. Environment auth overrides stored profiles, persists nothing, and cannot be combined with `--profile` or `login`/`logout`. Agent tokens skip member approval prompts; use a member profile for work that must pause for a human.
|
|
381
384
|
|
|
382
385
|
## Managed access
|
|
383
386
|
|
|
@@ -448,8 +451,8 @@ On a terminal, human output comes from one renderer (`src/term.ts`): it wraps to
|
|
|
448
451
|
| `run` | Full governed MCP tool result, including `structuredContent` |
|
|
449
452
|
| `connect` | Gateway payload with `connections` and optional `connectAllUrl` |
|
|
450
453
|
| `resources`, `prompts` | MCP list, read, or get result |
|
|
451
|
-
| `discover` | `{snapshot,report,compliant}`
|
|
452
|
-
| `scan` | `{version:1,findings:[{id,provider,kind,label,severity,location,locations,blastRadius}],agents,unreadable,checked}`
|
|
454
|
+
| `discover` | `{snapshot,report,compliant}` (the old name of `scan`'s inventory step, for one release) |
|
|
455
|
+
| `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 |
|
|
453
456
|
| `session` | NDJSON `{id?,ok,exitCode,result?}` or `{id?,ok:false,error,cause,exitCode,...}` |
|
|
454
457
|
| `access` | `keygen`: algorithm, paths, public JWK; `actions`: `{actions}`; `run`/`cancel`: `{run}`; `invoke`: governed result; `status`: `{receipt}` |
|
|
455
458
|
| `completion` | `{shell,script}` |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the agent reads about an approval request, from the hook's hold and
|
|
3
|
+
* from `passport wait`: who decides and when it expires, a decline with the
|
|
4
|
+
* person's note, or an expiry. Light on purpose: `passport wait` loads it.
|
|
5
|
+
*/
|
|
6
|
+
/** `Declined by Erin. Their note: "Use staging"`, rebuilt from parts so nothing else rides along. */
|
|
7
|
+
export declare function declinedFrom(message: unknown): string;
|
|
8
|
+
/** "14:05" today, or "14:05 tomorrow", or a date further out; in this computer's time. */
|
|
9
|
+
export declare function expiryTime(expiresAt: number, now: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* What the agent reads when the hold ends with no decision: who decides, when
|
|
12
|
+
* the request expires, and to wait in the background, then run it again.
|
|
13
|
+
* Starts "Waiting for approval from <who>. Run `passport wait" like the
|
|
14
|
+
* server's own line, so `waitingParts` still reads it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function pendingMessage(approvalId: string, who: string | undefined, expiresAt: number | undefined, now: number): string;
|
|
17
|
+
export declare const EXPIRED_MESSAGE = "Expired with no decision. Run the command again to ask again.";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the agent reads about an approval request, from the hook's hold and
|
|
3
|
+
* from `passport wait`: who decides and when it expires, a decline with the
|
|
4
|
+
* person's note, or an expiry. Light on purpose: `passport wait` loads it.
|
|
5
|
+
*/
|
|
6
|
+
import { cleanLine, declineNoteSuffix } from "./approvalNote.js";
|
|
7
|
+
/** `Declined by Erin. Their note: "Use staging"`, rebuilt from parts so nothing else rides along. */
|
|
8
|
+
export function declinedFrom(message) {
|
|
9
|
+
const text = cleanLine(message, 320);
|
|
10
|
+
// `Declined by Erin. Their note: "…"`, or an older server's `Declined by Erin: …`.
|
|
11
|
+
const match = text?.match(/^Declined by (.{1,80}?)\. Their note: "(.*)"$/) ??
|
|
12
|
+
text?.match(/^Declined by (.{1,80}?)(?:: "?(.*?)"?)?\.?$/);
|
|
13
|
+
if (!match)
|
|
14
|
+
return "Declined.";
|
|
15
|
+
return `Declined by ${match[1]}${declineNoteSuffix(match[2])}`;
|
|
16
|
+
}
|
|
17
|
+
/** "14:05" today, or "14:05 tomorrow", or a date further out; in this computer's time. */
|
|
18
|
+
export function expiryTime(expiresAt, now) {
|
|
19
|
+
const at = new Date(expiresAt);
|
|
20
|
+
const clock = `${String(at.getHours()).padStart(2, "0")}:${String(at.getMinutes()).padStart(2, "0")}`;
|
|
21
|
+
const today = new Date(now);
|
|
22
|
+
const startOfDay = (date) => new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
|
|
23
|
+
const days = Math.round((startOfDay(at) - startOfDay(today)) / 86_400_000);
|
|
24
|
+
if (days <= 0)
|
|
25
|
+
return clock;
|
|
26
|
+
if (days === 1)
|
|
27
|
+
return `${clock} tomorrow`;
|
|
28
|
+
return `${clock} on ${at.getFullYear()}-${String(at.getMonth() + 1).padStart(2, "0")}-${String(at.getDate()).padStart(2, "0")}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What the agent reads when the hold ends with no decision: who decides, when
|
|
32
|
+
* the request expires, and to wait in the background, then run it again.
|
|
33
|
+
* Starts "Waiting for approval from <who>. Run `passport wait" like the
|
|
34
|
+
* server's own line, so `waitingParts` still reads it.
|
|
35
|
+
*/
|
|
36
|
+
export function pendingMessage(approvalId, who, expiresAt, now) {
|
|
37
|
+
const expires = expiresAt !== undefined && expiresAt > now ? ` (it expires at ${expiryTime(expiresAt, now)})` : "";
|
|
38
|
+
return `Waiting for approval from ${who ?? "your approver"}. Run \`passport wait ${approvalId}\` as a background command; it exits when someone decides${expires}. Then run this command again.`;
|
|
39
|
+
}
|
|
40
|
+
export const EXPIRED_MESSAGE = "Expired with no decision. Run the command again to ask again.";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A decline note is the approver's own words, relayed to the agent verbatim.
|
|
3
|
+
* Before it is stored or shown, anything that could disguise it goes: control
|
|
4
|
+
* characters and terminal escapes, bidi overrides, and zero-width characters.
|
|
5
|
+
* Whitespace collapses and the note keeps at most 200 characters.
|
|
6
|
+
*
|
|
7
|
+
* A checked copy of shared/approvalNote.ts (the CLI can't import shared/).
|
|
8
|
+
*/
|
|
9
|
+
export declare const APPROVAL_NOTE_MAX = 200;
|
|
10
|
+
/** One line with nothing hidden in it, at most `max` characters, or undefined when nothing is left. */
|
|
11
|
+
export declare function cleanLine(raw: unknown, max: number): string | undefined;
|
|
12
|
+
/** The note as it may be stored and relayed, or undefined when nothing is left. */
|
|
13
|
+
export declare function cleanApprovalNote(raw: unknown): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* After "Declined by Erin": `. Their note: "Not during the freeze."`, or "."
|
|
16
|
+
* with no note. The note is labelled as the approver's words, and its own
|
|
17
|
+
* double quotes and backticks become single quotes, so it can't close the
|
|
18
|
+
* quotes or read as a command.
|
|
19
|
+
*/
|
|
20
|
+
export declare function declineNoteSuffix(raw: unknown): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A decline note is the approver's own words, relayed to the agent verbatim.
|
|
3
|
+
* Before it is stored or shown, anything that could disguise it goes: control
|
|
4
|
+
* characters and terminal escapes, bidi overrides, and zero-width characters.
|
|
5
|
+
* Whitespace collapses and the note keeps at most 200 characters.
|
|
6
|
+
*
|
|
7
|
+
* A checked copy of shared/approvalNote.ts (the CLI can't import shared/).
|
|
8
|
+
*/
|
|
9
|
+
export const APPROVAL_NOTE_MAX = 200;
|
|
10
|
+
// Terminal escapes first (CSI, OSC, and lone ESC pairs), then single characters.
|
|
11
|
+
const ESCAPES = /\u001b\[[0-?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)?|\u001b[@-_]?|\u009b[0-?]*[ -/]*[@-~]/g;
|
|
12
|
+
const INVISIBLE = /[\u0000-\u0008\u000e-\u001f\u007f-\u009f\u00ad\u061c\u180e\u200b-\u200f\u202a-\u202e\u2060-\u206f\ufeff\ufff9-\ufffb]/g;
|
|
13
|
+
/** One line with nothing hidden in it, at most `max` characters, or undefined when nothing is left. */
|
|
14
|
+
export function cleanLine(raw, max) {
|
|
15
|
+
if (typeof raw !== "string")
|
|
16
|
+
return undefined;
|
|
17
|
+
const cleaned = raw.replace(ESCAPES, "").replace(INVISIBLE, "").replace(/\s+/g, " ").trim();
|
|
18
|
+
return cleaned ? Array.from(cleaned).slice(0, max).join("").trim() : undefined;
|
|
19
|
+
}
|
|
20
|
+
/** The note as it may be stored and relayed, or undefined when nothing is left. */
|
|
21
|
+
export function cleanApprovalNote(raw) {
|
|
22
|
+
return cleanLine(raw, APPROVAL_NOTE_MAX);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* After "Declined by Erin": `. Their note: "Not during the freeze."`, or "."
|
|
26
|
+
* with no note. The note is labelled as the approver's words, and its own
|
|
27
|
+
* double quotes and backticks become single quotes, so it can't close the
|
|
28
|
+
* quotes or read as a command.
|
|
29
|
+
*/
|
|
30
|
+
export function declineNoteSuffix(raw) {
|
|
31
|
+
const note = cleanApprovalNote(raw)?.replace(/["`]/g, "'");
|
|
32
|
+
return note ? `. Their note: "${note}"` : ".";
|
|
33
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -27,8 +27,9 @@ function arg(flag, fallback = "") {
|
|
|
27
27
|
const i = process.argv.indexOf(flag);
|
|
28
28
|
return i >= 0 && process.argv[i + 1] ? process.argv[i + 1] : fallback;
|
|
29
29
|
}
|
|
30
|
-
/** `npx passport-bridge@latest scan
|
|
31
|
-
* `passport` CLI's own implementation, so both bins behave identically.
|
|
30
|
+
/** `npx passport-bridge@latest scan` and `init` (with `--org` for MDM) run the
|
|
31
|
+
* `passport` CLI's own implementation, so both bins behave identically.
|
|
32
|
+
* `setup` is here for `setup --org`, init's old name for one release. */
|
|
32
33
|
const PASSPORT_ONE_LINERS = new Set(["scan", "init", "setup"]);
|
|
33
34
|
async function passportOneLiner() {
|
|
34
35
|
const problem = oneLinerNodeProblem();
|
|
@@ -80,9 +81,8 @@ Commands:
|
|
|
80
81
|
login Sign in and save a rotating bridge sign-in
|
|
81
82
|
status Check saved bridge profiles
|
|
82
83
|
logout Revoke and remove a saved profile
|
|
83
|
-
scan Find keys your agents can reach
|
|
84
|
-
init Set up Passport for your agents
|
|
85
|
-
setup setup --org <key>: set up every agent here for your company (MDM)
|
|
84
|
+
scan Find the keys and MCP servers your agents can reach
|
|
85
|
+
init Set up Passport for your agents (--org <key> for company computers)
|
|
86
86
|
|
|
87
87
|
Options:
|
|
88
88
|
--profile <name> Use a named profile (default: default)
|
package/dist/cliArgs.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
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"];
|
|
2
2
|
export type Command = (typeof COMMANDS)[number];
|
|
3
|
+
/** Old names that still run for one release, left out of help, completion,
|
|
4
|
+
* and suggestions. `discover` is part of `scan` now. */
|
|
5
|
+
export declare const HIDDEN_COMMANDS: readonly Command[];
|
|
6
|
+
/** Every command help, completion, and suggestions name. */
|
|
7
|
+
export declare const VISIBLE_COMMANDS: readonly Command[];
|
|
3
8
|
/** A usage mistake. `suggestion` is the command the person most likely meant. */
|
|
4
9
|
export declare class ArgError extends Error {
|
|
5
10
|
readonly suggestion?: string[] | undefined;
|
package/dist/cliArgs.js
CHANGED
|
@@ -33,6 +33,11 @@ export const COMMANDS = [
|
|
|
33
33
|
"help",
|
|
34
34
|
"version"
|
|
35
35
|
];
|
|
36
|
+
/** Old names that still run for one release, left out of help, completion,
|
|
37
|
+
* and suggestions. `discover` is part of `scan` now. */
|
|
38
|
+
export const HIDDEN_COMMANDS = ["discover"];
|
|
39
|
+
/** Every command help, completion, and suggestions name. */
|
|
40
|
+
export const VISIBLE_COMMANDS = COMMANDS.filter((command) => !HIDDEN_COMMANDS.includes(command));
|
|
36
41
|
const FLAGS = {
|
|
37
42
|
profile: { kind: "value" },
|
|
38
43
|
json: { kind: "boolean" },
|
|
@@ -45,12 +50,14 @@ const FLAGS = {
|
|
|
45
50
|
client: { kind: "value", commands: ["login", "setup", "hook", "exec"] },
|
|
46
51
|
apply: { kind: "boolean", commands: ["setup", "hook"] },
|
|
47
52
|
guard: { kind: "boolean", commands: ["hook"] },
|
|
53
|
+
hold: { kind: "value", commands: ["hook"] },
|
|
48
54
|
"no-open": { kind: "boolean", commands: ["login", "init"] },
|
|
49
55
|
yes: { kind: "boolean", commands: ["init", "setup", "keys", "undo"] },
|
|
50
|
-
org
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
// `init --org` is setup for MDM; `setup --org` still runs it for one release.
|
|
57
|
+
org: { kind: "value", commands: ["init", "setup"] },
|
|
58
|
+
clients: { kind: "value", commands: ["init", "setup"] },
|
|
59
|
+
lock: { kind: "boolean", commands: ["init", "setup"] },
|
|
60
|
+
strict: { kind: "boolean", commands: ["init", "setup"] },
|
|
54
61
|
"skip-apps": { kind: "boolean", commands: ["init"] },
|
|
55
62
|
"skip-agents": { kind: "boolean", commands: ["init"] },
|
|
56
63
|
"skip-guard": { kind: "boolean", commands: ["init"] },
|
|
@@ -108,7 +115,7 @@ function optionsFor(command) {
|
|
|
108
115
|
return [...new Set(names)];
|
|
109
116
|
}
|
|
110
117
|
function unknownCommand(raw, help = false) {
|
|
111
|
-
const guess = closest(raw,
|
|
118
|
+
const guess = closest(raw, VISIBLE_COMMANDS);
|
|
112
119
|
const argv = guess ? ["passport", ...(help ? ["help"] : []), guess] : undefined;
|
|
113
120
|
return new ArgError(`Unknown command "${raw}". ${argv ? `Did you mean: ${argv.join(" ")}` : "See every command with passport help."}`, argv);
|
|
114
121
|
}
|
package/dist/cliGuardHealth.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare const GUARD_HEALTH_PATH = "/api/my/guard-health";
|
|
|
13
13
|
type ApiCall = (path: string, init: RequestInit) => Promise<Response>;
|
|
14
14
|
/** Managed settings hold Passport's guard for this agent: one reader for
|
|
15
15
|
* guard health and the hooks' stand-down (`managedHooks.ts`, which
|
|
16
|
-
* `passport
|
|
16
|
+
* `passport init --org --lock` writes for). */
|
|
17
17
|
export declare function managedGuard(client: GuardClient, env: Env): boolean;
|
|
18
18
|
/** Each agent on this computer, as the report sends it. */
|
|
19
19
|
export declare function guardClientReports(env: Env): Promise<GuardClientReport[]>;
|
package/dist/cliGuardHealth.js
CHANGED
|
@@ -19,7 +19,7 @@ import { VERSION } from "./version.js";
|
|
|
19
19
|
export const GUARD_HEALTH_PATH = "/api/my/guard-health";
|
|
20
20
|
/** Managed settings hold Passport's guard for this agent: one reader for
|
|
21
21
|
* guard health and the hooks' stand-down (`managedHooks.ts`, which
|
|
22
|
-
* `passport
|
|
22
|
+
* `passport init --org --lock` writes for). */
|
|
23
23
|
export function managedGuard(client, env) {
|
|
24
24
|
return managedPassportHook(client, env);
|
|
25
25
|
}
|
package/dist/cliHook.js
CHANGED
|
@@ -20,6 +20,7 @@ import { classifyLine, localMachine, workingFolder, worthReporting } from "./cli
|
|
|
20
20
|
import { codexAskBlocked, planGuard } from "./cliHookDecide.js";
|
|
21
21
|
import { decideGuard, guardMachineOf } from "./cliHookGuard.js";
|
|
22
22
|
import { detectMode } from "./cliHookMode.js";
|
|
23
|
+
import { cappedHold, holdSeconds } from "./cliHookHold.js";
|
|
23
24
|
import { readInput } from "./cliHookInput.js";
|
|
24
25
|
import { budgetSignal, expiredAsks, HOOK_BUDGET_MS, HOOK_RUNTIMES, leftovers, localProfile, localSelection, profileApi, queueAfterCommand, reportSender, runFlush, startFlushIfDue } from "./cliHookDeliver.js";
|
|
25
26
|
export { HOOK_BUDGET_MS, HOOK_RUNTIMES, legacyReport } from "./cliHookDeliver.js";
|
|
@@ -276,7 +277,7 @@ function isPassportExec(command) {
|
|
|
276
277
|
async function runAudit(args, runtime, deps) {
|
|
277
278
|
if (runtime.env.PASSPORT_HOOK_DISABLED === "1")
|
|
278
279
|
return;
|
|
279
|
-
const budget = budgetSignal(runtime);
|
|
280
|
+
const budget = budgetSignal(runtime, deps);
|
|
280
281
|
const input = await readInput(runtime, budget);
|
|
281
282
|
if (!input)
|
|
282
283
|
return;
|
|
@@ -292,7 +293,7 @@ async function runAudit(args, runtime, deps) {
|
|
|
292
293
|
const policy = profile ? readCliPolicy(profile) : null;
|
|
293
294
|
// The post-hook reads the same scripts again: a change since the guard's
|
|
294
295
|
// check is drift (item 6).
|
|
295
|
-
const scripts = scriptReader({ phase: "post", project: projectContext(policy) });
|
|
296
|
+
const scripts = scriptReader({ phase: "post", project: projectContext(policy), now: deps.budget?.scriptClock });
|
|
296
297
|
const machine = { ...localMachine(workingFolder(input), runtime.env), scripts };
|
|
297
298
|
const line = classifyLine(event.command, machine);
|
|
298
299
|
const findings = line.findings;
|
|
@@ -352,7 +353,7 @@ function outputClient(event, runtime) {
|
|
|
352
353
|
* allow, or an ask parked until the command runs). */
|
|
353
354
|
async function guardReport(base, plan, context) {
|
|
354
355
|
if (plan.server && base)
|
|
355
|
-
return serverDecidedReport(base, plan.server, context.now);
|
|
356
|
+
return serverDecidedReport(base, plan.server, context.now, plan.held);
|
|
356
357
|
// Offline, this computer's answer replaces the local Ask on the record.
|
|
357
358
|
const decided = base && plan.offline && plan.verdict ? { ...base, decision: plan.verdict } : base;
|
|
358
359
|
const report = decided && context.v2 && decided.decision === "allow" ? null : codexAskBlocked(decided);
|
|
@@ -371,9 +372,18 @@ async function guardReport(base, plan, context) {
|
|
|
371
372
|
* earlier) is parked for the run's own row; a waiting request is "asked"; a
|
|
372
373
|
* declined one is "asked, not run"; a block is a block.
|
|
373
374
|
*/
|
|
374
|
-
function serverDecidedReport(base, server, now) {
|
|
375
|
+
function serverDecidedReport(base, server, now, held) {
|
|
375
376
|
if (server.decision === "none")
|
|
376
377
|
return null;
|
|
378
|
+
// Held, and approved in time: "asked first, then ran", once the run reports.
|
|
379
|
+
if (held === "approved") {
|
|
380
|
+
const asked = { ...base, decision: "ask" };
|
|
381
|
+
if (base.toolUseId && holdAsk(base.runtime, base.sessionId, base.toolUseId, asked, now))
|
|
382
|
+
return null;
|
|
383
|
+
return { ...asked, ran: true };
|
|
384
|
+
}
|
|
385
|
+
if (held === "declined" || held === "expired")
|
|
386
|
+
return { ...base, decision: "ask", ran: false };
|
|
377
387
|
if (server.decision === "allow") {
|
|
378
388
|
if (base.toolUseId)
|
|
379
389
|
holdAsk(base.runtime, base.sessionId, base.toolUseId, { ...base, decision: "allow" }, now);
|
|
@@ -402,12 +412,14 @@ function answeredWith(decision, plan) {
|
|
|
402
412
|
async function afterAnswer(profile, context) {
|
|
403
413
|
const { timing, plan, decision, clock } = context;
|
|
404
414
|
const asked = plan.server !== null || plan.offline;
|
|
415
|
+
// A hold is a person's time, counted as an approval wait, not the guard's.
|
|
416
|
+
const answeredAt = timing.answeredAt - (plan.heldMs ?? 0);
|
|
405
417
|
(await import("./cliSpeed.js")).noteGuard(profile, {
|
|
406
418
|
client: context.runtimeName,
|
|
407
|
-
totalMs:
|
|
419
|
+
totalMs: answeredAt - timing.began,
|
|
408
420
|
readMs: timing.readAt - timing.began,
|
|
409
|
-
localMs: timing.localAt - timing.readAt + (asked ? 0 :
|
|
410
|
-
serverMs: asked ?
|
|
421
|
+
localMs: timing.localAt - timing.readAt + (asked ? 0 : answeredAt - timing.localAt),
|
|
422
|
+
serverMs: asked ? answeredAt - timing.localAt : 0,
|
|
411
423
|
decision: answeredWith(decision, plan),
|
|
412
424
|
offline: plan.offline
|
|
413
425
|
}, timing.answeredAt);
|
|
@@ -432,7 +444,7 @@ async function runGuard(args, runtime, deps) {
|
|
|
432
444
|
const clock = deps.now ?? Date.now;
|
|
433
445
|
const startedAt = clock();
|
|
434
446
|
const began = startOf(deps);
|
|
435
|
-
const budget = budgetSignal(runtime);
|
|
447
|
+
const budget = budgetSignal(runtime, deps);
|
|
436
448
|
const input = await readInput(runtime, budget);
|
|
437
449
|
if (!input || budget.aborted)
|
|
438
450
|
return;
|
|
@@ -444,7 +456,7 @@ async function runGuard(args, runtime, deps) {
|
|
|
444
456
|
const { profile, byDefault } = localSelection(args, runtime.env);
|
|
445
457
|
const policy = profile ? readCliPolicy(profile) : null;
|
|
446
458
|
// The project's own scripts are read inside the budget (item 6).
|
|
447
|
-
const scripts = scriptReader({ phase: "pre", project: projectContext(policy) });
|
|
459
|
+
const scripts = scriptReader({ phase: "pre", project: projectContext(policy), now: deps.budget?.scriptClock });
|
|
448
460
|
const machine = { ...localMachine(workingFolder(input), runtime.env), scripts };
|
|
449
461
|
const line = classifyLine(event.command, machine);
|
|
450
462
|
const decision = decideGuard(line.findings, policy, event.command, line.complete, guardMachineOf(machine, workingFolder(input), runtime.env));
|
|
@@ -478,7 +490,16 @@ async function runGuard(args, runtime, deps) {
|
|
|
478
490
|
command: event.command,
|
|
479
491
|
budget,
|
|
480
492
|
deadline: startedAt + HOOK_BUDGET_MS - PRINT_RESERVE_MS,
|
|
481
|
-
now: deps.now ?? Date.now
|
|
493
|
+
now: deps.now ?? Date.now,
|
|
494
|
+
hold: async () => {
|
|
495
|
+
const seconds = holdSeconds(value(args, "hold"), runtime.env);
|
|
496
|
+
if (seconds <= 0)
|
|
497
|
+
return 0;
|
|
498
|
+
// Never longer than the timeout Claude Code will enforce on this entry.
|
|
499
|
+
const { guardEntryOf } = await import("./cliHookInstall.js");
|
|
500
|
+
return cappedHold(seconds, guardEntryOf("claude-code", runtime.env));
|
|
501
|
+
},
|
|
502
|
+
holdSignal: runtime.signal
|
|
482
503
|
});
|
|
483
504
|
if (plan.output)
|
|
484
505
|
runtime.stdout.write(`${JSON.stringify(plan.output)}\n`);
|
package/dist/cliHookDecide.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export type CliDecideRequest = {
|
|
|
36
36
|
environment?: string;
|
|
37
37
|
} & Record<string, string>>;
|
|
38
38
|
commandSummary?: string;
|
|
39
|
+
/** The governed part, normalized and redacted (`cliHookKey.ts`): equivalent retries share it. */
|
|
40
|
+
commandKey?: string;
|
|
39
41
|
};
|
|
40
42
|
export type ServerDecision = {
|
|
41
43
|
decision: "allow" | "ask" | "block" | "none";
|
|
@@ -46,6 +48,9 @@ export type ServerDecision = {
|
|
|
46
48
|
approvalId?: string;
|
|
47
49
|
/** What to tell the agent, e.g. "Waiting for approval from Ramish. …" */
|
|
48
50
|
message?: string;
|
|
51
|
+
/** A pending approval: when it expires, and who decides. */
|
|
52
|
+
expiresAt?: number;
|
|
53
|
+
waitingFor?: string;
|
|
49
54
|
};
|
|
50
55
|
type ApiCall = (path: string, init: RequestInit) => Promise<Response>;
|
|
51
56
|
/** Validate what the server said. Anything unexpected is no answer at all. */
|
|
@@ -64,6 +69,10 @@ export type GuardPlan = {
|
|
|
64
69
|
offline: boolean;
|
|
65
70
|
/** Offline: what this computer decided in place of the local Ask. */
|
|
66
71
|
verdict?: GuardDecision["verdict"];
|
|
72
|
+
/** How the hold ended, when the guard held for a person (`cliHookHold.ts`). */
|
|
73
|
+
held?: "approved" | "declined" | "expired" | "pending";
|
|
74
|
+
/** How long it held: a person's time, kept out of the guard's own speed. */
|
|
75
|
+
heldMs?: number;
|
|
67
76
|
};
|
|
68
77
|
/** Codex can't ask from a hook, so an ask it read is recorded as the block it was. */
|
|
69
78
|
export declare function codexAskBlocked<T extends {
|
|
@@ -111,6 +120,11 @@ export declare function planGuard(decision: GuardDecision | null, policy: Cached
|
|
|
111
120
|
budget: AbortSignal;
|
|
112
121
|
deadline: number;
|
|
113
122
|
now: () => number;
|
|
123
|
+
/** Seconds to hold for a person after an approval request opens (0: don't);
|
|
124
|
+
* asked only when a request opens, since it reads the agent's settings. */
|
|
125
|
+
hold?: () => Promise<number>;
|
|
126
|
+
/** Ends the hold early (the process is stopping). */
|
|
127
|
+
holdSignal?: AbortSignal;
|
|
114
128
|
}): Promise<GuardPlan & {
|
|
115
129
|
api?: ApiCall;
|
|
116
130
|
}>;
|