passport-bridge 0.16.13 → 0.17.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 +20 -20
- package/dist/bridgeExchange.d.ts +7 -1
- package/dist/bridgeExchange.js +11 -2
- package/dist/cli.js +3 -1
- package/dist/cliActions.js +38 -18
- package/dist/cliArgs.js +14 -9
- package/dist/cliAutopilot.js +36 -21
- package/dist/cliAutopilotPolicy.d.ts +22 -0
- package/dist/cliAutopilotPolicy.js +61 -0
- package/dist/cliConnect.js +8 -7
- package/dist/cliDeadline.js +2 -1
- package/dist/cliDescribe.d.ts +4 -0
- package/dist/cliDescribe.js +11 -0
- package/dist/cliEnv.js +5 -4
- package/dist/cliExec.js +13 -5
- package/dist/cliGuardState.d.ts +2 -0
- package/dist/cliGuardState.js +5 -1
- package/dist/cliHelp.d.ts +5 -4
- package/dist/cliHelp.js +2 -27
- package/dist/cliHook.js +6 -2
- package/dist/cliHookGuard.js +5 -11
- package/dist/cliHookInstall.d.ts +3 -0
- package/dist/cliHookInstall.js +17 -7
- package/dist/cliHookStatus.d.ts +2 -1
- package/dist/cliHookStatus.js +26 -17
- package/dist/cliInit.js +5 -3
- package/dist/cliKeys.d.ts +3 -0
- package/dist/cliKeys.js +59 -77
- package/dist/cliKeysShim.js +7 -5
- package/dist/cliLogin.js +44 -24
- package/dist/cliLogout.js +24 -8
- package/dist/cliMain.js +50 -22
- package/dist/cliMemberCall.js +1 -1
- package/dist/cliOffline.d.ts +2 -2
- package/dist/cliOffline.js +32 -9
- package/dist/cliOutput.js +73 -43
- package/dist/cliReady.d.ts +2 -1
- package/dist/cliReady.js +9 -6
- package/dist/cliResult.js +1 -1
- package/dist/cliScan.js +10 -28
- package/dist/cliScriptRead.d.ts +1 -1
- package/dist/cliScriptRead.js +2 -2
- package/dist/cliSessions.d.ts +3 -2
- package/dist/cliSessions.js +19 -17
- package/dist/cliSetup.js +6 -4
- package/dist/cliSetupLock.js +2 -1
- package/dist/cliSetupOrg.js +7 -5
- package/dist/cliStatus.d.ts +2 -4
- package/dist/cliStatus.js +56 -61
- package/dist/cliSuggest.d.ts +3 -2
- package/dist/cliSuggest.js +19 -6
- package/dist/cliSupport.d.ts +1 -1
- package/dist/cliSupport.js +3 -7
- package/dist/cliSync.js +2 -0
- package/dist/cliUndo.d.ts +3 -1
- package/dist/cliUndo.js +14 -11
- package/dist/cliWait.d.ts +3 -2
- package/dist/cliWait.js +10 -18
- package/dist/doctor.d.ts +4 -1
- package/dist/doctor.js +48 -29
- package/dist/execNoKey.d.ts +1 -1
- package/dist/execNoKey.js +3 -2
- package/dist/execShims.js +2 -2
- package/dist/hookFastPath.js +1 -0
- package/dist/initAutopilotStep.js +5 -4
- package/dist/initInstall.js +4 -3
- package/dist/initKeysStep.js +1 -1
- package/dist/initLocalSteps.d.ts +2 -1
- package/dist/initLocalSteps.js +10 -7
- package/dist/initOutro.d.ts +1 -3
- package/dist/initOutro.js +8 -16
- package/dist/initPlan.js +7 -7
- package/dist/initUi.d.ts +2 -4
- package/dist/initUi.js +8 -17
- package/dist/keysLocal.js +3 -3
- package/dist/keysSecret.d.ts +6 -0
- package/dist/keysSecret.js +43 -0
- package/dist/launcherFastPath.js +1 -0
- package/dist/lockedHooks.d.ts +1 -1
- package/dist/lockedHooks.js +1 -1
- package/dist/loginFlow.d.ts +1 -1
- package/dist/loginFlow.js +4 -4
- package/dist/pathLines.d.ts +1 -0
- package/dist/pathLines.js +23 -0
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/plural.d.ts +10 -0
- package/dist/plural.js +14 -0
- package/dist/term.d.ts +49 -5
- package/dist/term.js +200 -26
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/waitingLine.js +2 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ This package installs two binaries that reach a Passport workspace through its g
|
|
|
5
5
|
- `passport`: CLI for terminal agents, scripts, and CI.
|
|
6
6
|
- `passport-bridge`: stdio bridge for agents that launch a local MCP server, so the agent config holds no long-lived token.
|
|
7
7
|
|
|
8
|
-
Member profiles get the same tool access, agent selection, guardrails, approvals, and activity logging as native agents. Agent
|
|
8
|
+
Member profiles get the same tool access, agent selection, guardrails, approvals, and activity logging as native agents. Agent tokens keep their pass, selection, guardrails, and audit trail but never raise a member approval prompt.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
@@ -37,7 +37,7 @@ passport run github_search_issues '{"query":"SSO"}'
|
|
|
37
37
|
|
|
38
38
|
- First time? Bare `passport login` opens `/cli` in your browser. Sign in with Google, GitHub, or an emailed code, then connect a workspace you belong to or create one. No workspace id needed.
|
|
39
39
|
- One screen every time: `Code: HJKT-WQRM`, the pre-filled `Link:`, and `Check the code matches the one in your browser before you approve.` Nothing connects until you click Connect. It ends `Signed in as Erin Park to Acme.`; `--verbose` adds the profile name and where it's saved.
|
|
40
|
-
- Already signed in? On a terminal, `passport login` asks `Already signed in as Erin Park to Acme. Switch? [y/N]`. Enter keeps you signed in; `--switch` skips the question and lets the browser pick again. A sign-in that stopped working just signs in again
|
|
40
|
+
- Already signed in? On a terminal, `passport login` asks `Already signed in as Erin Park to Acme. Switch? [y/N]`. Enter keeps you signed in; `--switch` skips the question and lets the browser pick again. A sign-in that stopped working just signs in again; when Passport can't confirm the current one, login says `Couldn't confirm your current sign-in, so signing in again.`
|
|
41
41
|
- Re-signing in? Bare `passport login` reuses the workspace of the active profile, the sole CLI profile, or the one workspace all saved profiles share. With several workspaces saved it lists them and asks for `--workspace`.
|
|
42
42
|
- `--workspace ws_example` takes the same browser sign-in straight to that workspace, and only that workspace is accepted. Self-hosted: add `--cloud https://passport.example.com` (origin only). A server without browser sign-in falls back to its device flow when the workspace is known, else asks for `--workspace`.
|
|
43
43
|
- Without a terminal (an agent's shell, CI) or with `--json`, login is two steps, like `stripe login --non-interactive`: it prints `{status:"pending", verification_url, code, next_step, login_id}` and exits; once the code is approved in the browser, run `next_step` (`passport login --complete <login_id>`) to save the profile. The poll secret stays in an owner-only file under `~/.passport/login-pending/`.
|
|
@@ -54,8 +54,8 @@ passport run github_search_issues '{"query":"SSO"}'
|
|
|
54
54
|
| `login` | Browser sign-in or sign-up (or device sign-in with `--workspace`); saves a rotating CLI credential and makes the profile active. |
|
|
55
55
|
| `logout` | Revoke the credential and always remove the local profile (warns if revocation fails). |
|
|
56
56
|
| `profiles` / `use <name>` | List stored profiles / select the active one. Offline. |
|
|
57
|
-
| `status` |
|
|
58
|
-
| `doctor` | Check Node,
|
|
57
|
+
| `status` | Your setup on one screen: you, this computer, each agent's guard and its fix; Autopilot; apps; keys in Passport; this folder's environments; the CLI version. |
|
|
58
|
+
| `doctor` | Check Node, how your sign-in is stored, the server, your sign-in, and that this CLI and the server match. Exit 1 on a failed check, 2 when not signed in. |
|
|
59
59
|
| `ready` | Readiness preflight for automation; gate on its `ready` field and exit code. |
|
|
60
60
|
| `search [query] [--app <key>]` | Search permitted tools. Empty query lists the full catalog. |
|
|
61
61
|
| `describe <tool>` | One exact definition with its full parameter schema. |
|
|
@@ -100,7 +100,7 @@ passport connect github --wait 120
|
|
|
100
100
|
|
|
101
101
|
- An approval-required call exits 4 with its approval ID. `--wait <s>` retries only after a definite `approval_pending` response.
|
|
102
102
|
- The CLI never retries after a network failure or timeout, since the outcome is unknown.
|
|
103
|
-
- `connect` with no app names uses one aggregate link when several apps need sign-in. Agent
|
|
103
|
+
- `connect` with no app names uses one aggregate link when several apps need sign-in. Agent tokens get guidance but cannot create sign-in links.
|
|
104
104
|
|
|
105
105
|
### Resources and prompts
|
|
106
106
|
|
|
@@ -132,26 +132,26 @@ npx passport-bridge@latest init --yes --move-keys # also move CLI keys into Pas
|
|
|
132
132
|
npx passport-bridge@latest init --yes --json # one summary object with each step's status and the plan
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
Plan, then apply. Init scans and signs in, then reads every step below without changing anything and shows one plan: **
|
|
135
|
+
Plan, then apply. Init scans and signs in, then reads every step below without changing anything and shows one plan: **Plan** (what the recommended setup changes), **Edits** (every file it edits, each backed up first), **Done** (already set up), **Kept** (not changed, with how to change it later), and **You do**, then the Autopilot presets and **Where** (environments). Labels sit in one column, at least two spaces from their text. One question follows: `Use the recommended setup? (n to choose step by step) [Y/n]`. Enter applies the plan; `n` walks each step with its own question. When nothing is missing it says `Nothing to change.` and asks nothing. It ends with a ✓ list of what's true now and what's left for you, and one next command (the `PATH` line, `passport connect --wait 300`, a first thing to ask your agent, or `passport status`).
|
|
136
136
|
|
|
137
137
|
Eight steps, each reusing the command that owns it:
|
|
138
138
|
|
|
139
139
|
1. **Scan**: the same local scan as `passport scan`, as one summary line (`--verbose` prints the table).
|
|
140
140
|
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`.
|
|
141
141
|
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
|
-
4. **Keys**: the recommended setup keeps them; the plan says `Your
|
|
143
|
-
5. **
|
|
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 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: on a terminal init copies the URL and says `Claude Desktop: Settings → Connectors → Add custom connector
|
|
142
|
+
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
|
+
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 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: 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
145
|
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
146
|
8. **Autopilot**: how much agents can do on their own, per environment:
|
|
147
147
|
|
|
148
148
|
```
|
|
149
|
-
Autopilot
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
Autopilot Production Careful reads run, changes ask
|
|
150
|
+
Staging Balanced reads and changes run, deletes ask
|
|
151
|
+
Development Hands-off everything except irreversible runs
|
|
152
152
|
```
|
|
153
153
|
|
|
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
|
|
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 earlier Safety step instead.
|
|
155
155
|
|
|
156
156
|
What changes on disk, and how to undo it:
|
|
157
157
|
|
|
@@ -220,7 +220,7 @@ Two hooks per agent. `passport hook` runs after each shell command and records t
|
|
|
220
220
|
|
|
221
221
|
- **Allow** (Claude Code `permissionDecision: "allow"`, Cursor `permission: "allow"`) only when every part of the line is understood and allowed: vendor commands in `src/cliHookVendors.ts` read with confidence, and everyday commands (below). Substitutions, heredocs, variables in a path, unknown wrappers or environment prefixes, scripts, aliases, `make`, and programs Passport doesn't know mean no decision, so the agent's own permission rules apply. Codex can't receive allow; its own approvals apply (see `passport sync`).
|
|
222
222
|
- **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.
|
|
223
|
-
- Each reason names its cause in one line: `Passport: railway redeploy changes Production. Approve to run it.`, or `Blocked by
|
|
223
|
+
- Each reason names its cause in one line: `Passport: railway redeploy changes Production. Approve to run it.`, or `Blocked by a team rule: no deletes in Production. Ask an admin to run it, or request an exception in Passport.` (a cause that isn't a rule reads `Blocked by Passport: <cause>`).
|
|
224
224
|
|
|
225
225
|
**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.
|
|
226
226
|
|
|
@@ -253,7 +253,7 @@ An ask becomes one Activity row. In Claude Code, with the audit hook registered,
|
|
|
253
253
|
- 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
254
|
- 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
255
|
|
|
256
|
-
**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 --
|
|
256
|
+
**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
257
|
|
|
258
258
|
**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`.
|
|
259
259
|
|
|
@@ -281,12 +281,12 @@ passport actions sync # propose this repository's .passport/actions.toml
|
|
|
281
281
|
- `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
282
|
|
|
283
283
|
- `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`, after a short first look that names who decides.
|
|
284
|
+
- `wait` long-polls `GET /api/my/approvals/<id>/wait`, after a short first look that names who decides. 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> (up to 100 seconds).` 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. 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`.
|
|
285
285
|
- `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
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`, `setup --org`, every rules refresh, and `passport sync`; `hook uninstall`, `sync --remove`, and signing out of the last profile take the entries out.
|
|
287
287
|
- `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
288
|
- `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
|
-
- `rules test`, `sessions`, `actions`, and `sync` need a member profile. `wait` also works for a cloud agent's
|
|
289
|
+
- `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.
|
|
290
290
|
|
|
291
291
|
### Keys and passport exec
|
|
292
292
|
|
|
@@ -306,9 +306,9 @@ passport keys shim # the CLIs that run through Passport when you type
|
|
|
306
306
|
- 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.
|
|
307
307
|
- `keys move` finds CLI sign-ins (Railway, GitHub CLI, Vercel, Wrangler API tokens, Supabase, Stripe test keys, the AWS `default` profile) and tokens in Claude Code's settings `env`. For each it asks `[y/N]` (Enter keeps it; `--yes` moves them all; `keys move <cli>` only that CLI's), stores the key in Passport (`POST /api/my/keys`), then signs that CLI out by removing only the credential: the token fields of `~/.railway/config.json` (project links stay), `token` in Vercel's `auth.json` (not revoked; the current team stays), Wrangler's sign-in keys in `default.toml`, the Supabase `access-token` file and its keychain token (saved database passwords stay), the Stripe profile's API keys and its live key in the keychain (account, color, and other profiles stay), the AWS profile's key lines, or the one settings entry. Files are written atomically with their mode kept. Vendor sign-outs don't run because they do more (`railway logout` unlinks every project, `vercel logout` revokes the token Passport just stored); only the GitHub CLI's `gh auth logout --hostname github.com` runs, adding `--user <active>` when several accounts are signed in, so other hosts and accounts stay. Keychain items are deleted by exact service and account (`security delete-generic-password` on macOS, `secret-tool clear` on Linux); where that isn't possible the row says which keychain copy may stay. Wrangler OAuth tokens are removed locally, not revoked. A sign-out that fails leaves the key in Passport and says what's left on disk. `.env` files are never touched: "Used by your app, so Passport leaves it." Browser-session sign-ins (Railway, Vercel, Wrangler OAuth) can't move; the line says how to make a token instead. A different key than the one already in Passport is replaced only when the person types the CLI's name at a terminal (`Type railway to confirm, or press Enter to cancel:`); no flag does it, so an agent's script can never swap a key. The CLI then names the key it replaces (`replace: <keyId>` on `POST /api/my/keys`). The server alerts the owner and admins with an Undo, records it in the audit trail, and keeps the old value encrypted for seven days (`POST /api/my/keys/:id/restore` from the browser, or the alert). Without a person at a terminal (`--yes`, no terminal), both keys stay, and the line says `Replacing a key in Passport needs you at a terminal. Run passport keys move railway yourself.` The scan report sent afterwards carries provider counts only.
|
|
308
308
|
- `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`).
|
|
309
|
-
- Asks wait for your approval in Passport (web or push) when you're at the keyboard or with `--wait <sec>`; otherwise exit 4 with the approval id: run `passport wait <id>`, then the command again. While it waits, the approval link prints at once and, on a terminal, one live line counts down (`Waiting for Erin · 1:32 left`); piped, it prints the waiting line and `Open in Passport: <url>`. Ctrl-C exits 4: `The request is still open.
|
|
309
|
+
- Asks wait for your approval in Passport (web or push) when you're at the keyboard or with `--wait <sec>`; otherwise exit 4 with the approval id: run `passport wait <id>`, then the command again. While it waits, the approval link prints at once and, on a terminal, one live line counts down (`Waiting for Erin · 1:32 left`); piped, it prints the waiting line and `Open in Passport: <url>`. Ctrl-C exits 4: `The request is still open. Keep waiting, then run the command again.` and `Run: passport wait <id>`. An approval is used once. Blocked or declined: exit 5. A decline answers the same command for ten minutes, said with who and when: `Declined 2 minutes ago by Erin: Not during the freeze.` and `Run with --ask-again to request again.`; `--ask-again` opens a new request. No key, or it stopped working: exit 3 (`No Railway key in Passport yet. Add a Railway key in Passport → Apps.`, or `Your Railway key in Passport stopped working. Update it in Apps.`). When this computer still has the Railway CLI's own sign-in, the no-key line is `No Railway key in Passport yet, but this computer has one.` with `Run: passport keys move railway` instead (read here; Passport never sees this computer's files). Offline: exit 1, nothing runs, and exec never uses a key on this computer instead. A team that requires the guard refuses exec for an agent whose computer hasn't reported its guard On in 48 hours: exit 5 with `Blocked by Passport: guard required…` and the fix.
|
|
310
310
|
- 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.
|
|
311
|
-
- 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.
|
|
311
|
+
- Cloud agents (Agents → Cloud agents) run exec and MCP with their agent token in `PASSPORT_AGENT_KEY` and `PASSPORT_ENDPOINT`: the owner's rules decide, the owner's keys are used, and approvals go to the owner.
|
|
312
312
|
- 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.
|
|
313
313
|
|
|
314
314
|
### Undo
|
|
@@ -377,7 +377,7 @@ passport ready --json
|
|
|
377
377
|
passport search "deployment status" --json
|
|
378
378
|
```
|
|
379
379
|
|
|
380
|
-
`PASSPORT_ENDPOINT` is Passport's one URL (`https://<host>/mcp`, where the agent
|
|
380
|
+
`PASSPORT_ENDPOINT` is Passport's one URL (`https://<host>/mcp`, where the agent token's own prefix says which workspace) or a workspace's own (`https://<host>/w/<workspace>/mcp`). 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
381
|
|
|
382
382
|
## Managed access
|
|
383
383
|
|
package/dist/bridgeExchange.d.ts
CHANGED
|
@@ -9,7 +9,13 @@ export declare const TENANT_FLIP_MESSAGE = "This computer's Passport sign-in now
|
|
|
9
9
|
* (superseded by a newer rotation that this process cannot see on disk). */
|
|
10
10
|
export declare class BridgeCredentialError extends Error {
|
|
11
11
|
readonly status: 401 | 409;
|
|
12
|
-
|
|
12
|
+
readonly phase: "exchange" | "request";
|
|
13
|
+
/**
|
|
14
|
+
* `request`: the sign-in still works (a fresh token was issued) but
|
|
15
|
+
* Passport refused this one request with it. `exchange`: the sign-in
|
|
16
|
+
* itself was refused, so it expired or was revoked.
|
|
17
|
+
*/
|
|
18
|
+
constructor(status: 401 | 409, phase?: "exchange" | "request");
|
|
13
19
|
}
|
|
14
20
|
export declare function isBridgeCredentialError(error: unknown): error is BridgeCredentialError;
|
|
15
21
|
/** How long a rotating exchange keeps retrying an ambiguous failure (a
|
package/dist/bridgeExchange.js
CHANGED
|
@@ -23,9 +23,16 @@ const ROTATION_PERSISTENCE_MESSAGE = "Passport rotated the credential, but durab
|
|
|
23
23
|
* (superseded by a newer rotation that this process cannot see on disk). */
|
|
24
24
|
export class BridgeCredentialError extends Error {
|
|
25
25
|
status;
|
|
26
|
-
|
|
26
|
+
phase;
|
|
27
|
+
/**
|
|
28
|
+
* `request`: the sign-in still works (a fresh token was issued) but
|
|
29
|
+
* Passport refused this one request with it. `exchange`: the sign-in
|
|
30
|
+
* itself was refused, so it expired or was revoked.
|
|
31
|
+
*/
|
|
32
|
+
constructor(status, phase = "exchange") {
|
|
27
33
|
super(`token exchange failed (${status}); reconnect this agent from the Passport web app (or run \`passport-bridge login\`)`);
|
|
28
34
|
this.status = status;
|
|
35
|
+
this.phase = phase;
|
|
29
36
|
this.name = "BridgeCredentialError";
|
|
30
37
|
}
|
|
31
38
|
}
|
|
@@ -485,7 +492,9 @@ export class TokenManager {
|
|
|
485
492
|
res = await this.fetcher(input, apply(await this.accessToken(true)));
|
|
486
493
|
if (res.status === 401) {
|
|
487
494
|
await res.body?.cancel().catch(() => undefined);
|
|
488
|
-
|
|
495
|
+
// A fresh token was just issued, so the sign-in works: Passport
|
|
496
|
+
// refused this request, not the sign-in.
|
|
497
|
+
throw new BridgeCredentialError(401, "request");
|
|
489
498
|
}
|
|
490
499
|
}
|
|
491
500
|
return res;
|
package/dist/cli.js
CHANGED
|
@@ -70,6 +70,7 @@ async function main() {
|
|
|
70
70
|
process.exit(1);
|
|
71
71
|
}
|
|
72
72
|
function help() {
|
|
73
|
+
// copy-style-allow double-space: help columns line up
|
|
73
74
|
process.stdout.write(`Passport bridge ${VERSION}
|
|
74
75
|
|
|
75
76
|
Usage: passport-bridge [command] [options]
|
|
@@ -354,7 +355,8 @@ async function login() {
|
|
|
354
355
|
});
|
|
355
356
|
out("");
|
|
356
357
|
out(` ✓ Signed in. Saved profile "${profile}" to ${credsPath()}`);
|
|
357
|
-
out(
|
|
358
|
+
out(" Now point your agent at it:");
|
|
359
|
+
out(` passport-bridge serve --profile ${profile}`);
|
|
358
360
|
out("");
|
|
359
361
|
}
|
|
360
362
|
async function status() {
|
package/dist/cliActions.js
CHANGED
|
@@ -21,15 +21,20 @@ import { readBoundedJson } from "./boundedResponse.js";
|
|
|
21
21
|
import { value } from "./cliArgs.js";
|
|
22
22
|
import { memberApi } from "./cliClient.js";
|
|
23
23
|
import { localMachine, NODE_FS } from "./cliHookLocal.js";
|
|
24
|
+
import { CLASS_LABEL } from "./cliAutopilotPolicy.js";
|
|
24
25
|
import { lookupOpaqueId, normalizeRemote, originUrl, remoteFingerprint, sha256 } from "./cliScriptRead.js";
|
|
25
26
|
import { linesDigestInput, makeLines, packageLines, parseRepoActions } from "./cliScriptText.js";
|
|
26
27
|
import { unknownSubcommand } from "./cliSuggest.js";
|
|
27
|
-
import {
|
|
28
|
+
import { joinParts, termOf } from "./term.js";
|
|
28
29
|
import { callerFrom, failure, resolveCliAuth, safeApiError, timeoutMs } from "./cliSupport.js";
|
|
29
30
|
const ENVIRONMENTS = new Set(["production", "staging", "development"]);
|
|
30
31
|
const CLASSES = new Set(["read", "change", "delete", "irreversible"]);
|
|
31
32
|
const RUNNERS = new Set(["make", "npm", "pnpm", "yarn"]);
|
|
32
33
|
const ENV_WORD = { production: "Production", staging: "Staging", development: "Development" };
|
|
34
|
+
/** An action class in the word `rules test` and the web use: "Change". */
|
|
35
|
+
function classWord(actionClass) {
|
|
36
|
+
return actionClass && CLASSES.has(actionClass) ? CLASS_LABEL[actionClass] : "";
|
|
37
|
+
}
|
|
33
38
|
function api(args, runtime, deps) {
|
|
34
39
|
if (deps.api)
|
|
35
40
|
return deps.api;
|
|
@@ -118,7 +123,7 @@ async function post(client, body, args, runtime) {
|
|
|
118
123
|
function line(action, fallback) {
|
|
119
124
|
const label = action.label ?? fallback;
|
|
120
125
|
const where = action.environment ? (ENV_WORD[action.environment] ?? action.environment) : "";
|
|
121
|
-
const what = action.actionClass
|
|
126
|
+
const what = classWord(action.actionClass);
|
|
122
127
|
return action.status === "proposed"
|
|
123
128
|
? `${label}: proposed (${what} in ${where}). An admin approves it in Passport Rules › Environments.`
|
|
124
129
|
: `${label}: ${what} in ${where}. Passport checks it from now on.`;
|
|
@@ -126,11 +131,25 @@ function line(action, fallback) {
|
|
|
126
131
|
function classified(args) {
|
|
127
132
|
const environment = value(args, "environment")?.toLowerCase() ?? "";
|
|
128
133
|
const actionClass = value(args, "class")?.toLowerCase() ?? "";
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
// Say everything that's missing or wrong at once, naming a bad value.
|
|
135
|
+
const shown = (raw) => raw.replace(/[^\w-]/g, "").slice(0, 30);
|
|
136
|
+
const problems = [];
|
|
137
|
+
const missing = [];
|
|
138
|
+
if (!environment)
|
|
139
|
+
missing.push("--environment production|staging|development");
|
|
140
|
+
else if (!ENVIRONMENTS.has(environment))
|
|
141
|
+
problems.push(`--environment takes production, staging, or development, not ${shown(environment)}.`);
|
|
142
|
+
if (!actionClass)
|
|
143
|
+
missing.push("--class read|change|delete|irreversible");
|
|
144
|
+
else if (!CLASSES.has(actionClass))
|
|
145
|
+
problems.push(`--class takes read, change, delete, or irreversible, not ${shown(actionClass)}.`);
|
|
146
|
+
// What's missing, one option a line: each is long, and never splits.
|
|
147
|
+
if (missing.length) {
|
|
148
|
+
const what = [!environment ? "where it acts" : "", !actionClass ? "what it does" : ""].filter(Boolean);
|
|
149
|
+
problems.push([`Add ${what.join(" and ")}:`, ...missing.map((flag) => ` ${flag}`)].join("\n"));
|
|
131
150
|
}
|
|
132
|
-
if (
|
|
133
|
-
return failure(
|
|
151
|
+
if (problems.length)
|
|
152
|
+
return failure(problems.join("\n"), 6, "usage");
|
|
134
153
|
return { environment, class: actionClass };
|
|
135
154
|
}
|
|
136
155
|
async function add(args, runtime, deps) {
|
|
@@ -198,23 +217,24 @@ async function list(args, runtime, deps) {
|
|
|
198
217
|
return failure(await safeApiError(response, "Passport couldn't list them."), 1, "server");
|
|
199
218
|
const body = (await readBoundedJson(response).catch(() => ({})));
|
|
200
219
|
const actions = body.projectActions ?? [];
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
|
|
220
|
+
// Every script laid out the same way, however many there are: its name,
|
|
221
|
+
// then where it acts, its class, its repository, and notes, broken only
|
|
222
|
+
// between those parts.
|
|
223
|
+
const width = termOf((runtime.stdout ?? {}), runtime.env).width;
|
|
224
|
+
const lines = actions.flatMap((action) => [
|
|
204
225
|
action.label ?? "script",
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
226
|
+
...joinParts([
|
|
227
|
+
action.environment ? (ENV_WORD[action.environment] ?? action.environment) : "",
|
|
228
|
+
classWord(action.actionClass),
|
|
229
|
+
action.repoName ?? "Any repository",
|
|
209
230
|
...(action.setByName ? [`Set by ${action.setByName}`] : []),
|
|
210
231
|
...(action.status === "proposed" ? ["Proposed"] : []),
|
|
211
232
|
...(action.changedAt ? ["Changed since set"] : [])
|
|
212
|
-
]
|
|
233
|
+
], width, " ")
|
|
213
234
|
]);
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
: "No project scripts yet. Add one: passport actions add <script> --environment <kind> --class <class>";
|
|
235
|
+
const human = lines.length
|
|
236
|
+
? lines.join("\n")
|
|
237
|
+
: "No project scripts yet. Tell Passport what one does.\nRun: passport actions add <script> --environment <kind> --class <class>";
|
|
218
238
|
return { json: { actions }, human };
|
|
219
239
|
}
|
|
220
240
|
export async function actions(args, runtime, deps = {}) {
|
package/dist/cliArgs.js
CHANGED
|
@@ -68,7 +68,7 @@ const FLAGS = {
|
|
|
68
68
|
alias: { kind: "value", commands: ["connect"] },
|
|
69
69
|
open: { kind: "boolean", commands: ["connect"] },
|
|
70
70
|
out: { kind: "value", commands: ["resources", "prompts"] },
|
|
71
|
-
verbose: { kind: "boolean", commands: ["scan", "init", "exec", "login"] },
|
|
71
|
+
verbose: { kind: "boolean", commands: ["scan", "init", "exec", "login", "hook"] },
|
|
72
72
|
"no-masking": { kind: "boolean", commands: ["exec"] },
|
|
73
73
|
mask: { kind: "boolean", commands: ["exec"] },
|
|
74
74
|
"no-shim": { kind: "boolean", commands: ["keys"] },
|
|
@@ -110,7 +110,7 @@ function optionsFor(command) {
|
|
|
110
110
|
function unknownCommand(raw, help = false) {
|
|
111
111
|
const guess = closest(raw, COMMANDS);
|
|
112
112
|
const argv = guess ? ["passport", ...(help ? ["help"] : []), guess] : undefined;
|
|
113
|
-
return new ArgError(`Unknown command "${raw}". ${argv ? `Did you mean: ${argv.join(" ")}` : "
|
|
113
|
+
return new ArgError(`Unknown command "${raw}". ${argv ? `Did you mean: ${argv.join(" ")}` : "See every command with passport help."}`, argv);
|
|
114
114
|
}
|
|
115
115
|
function unknownOption(raw, command) {
|
|
116
116
|
const given = raw.startsWith("--") ? flagParts(raw).name : raw.replace(/^-+/, "");
|
|
@@ -119,7 +119,7 @@ function unknownOption(raw, command) {
|
|
|
119
119
|
return new ArgError(`Unknown option "${raw}". Did you mean: --${guess}`, command ? ["passport", command, `--${guess}`] : undefined);
|
|
120
120
|
}
|
|
121
121
|
const where = command && command !== "help" ? `passport help ${command}` : "passport help";
|
|
122
|
-
return new ArgError(`Unknown option "${raw}".
|
|
122
|
+
return new ArgError(`Unknown option "${raw}". See the options with ${where}.`);
|
|
123
123
|
}
|
|
124
124
|
function knownCommand(value) {
|
|
125
125
|
return COMMANDS.includes(value);
|
|
@@ -221,6 +221,9 @@ function settle(args) {
|
|
|
221
221
|
}
|
|
222
222
|
if (command === "help" && positionals[0] !== undefined && !knownCommand(positionals[0]))
|
|
223
223
|
throw unknownCommand(positionals[0], true);
|
|
224
|
+
// `help keys add` shows the page for keys, which covers its subcommands.
|
|
225
|
+
if (command === "help")
|
|
226
|
+
positionals.splice(1);
|
|
224
227
|
validateShape(command, positionals);
|
|
225
228
|
validateNumbers(values);
|
|
226
229
|
return { command, positionals, values, repeats, booleans };
|
|
@@ -266,14 +269,16 @@ function validateShape(command, positionals) {
|
|
|
266
269
|
exec: 1
|
|
267
270
|
};
|
|
268
271
|
const needs = {
|
|
269
|
-
run: "a tool name",
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
run: "run needs a tool name.",
|
|
273
|
+
describe: "describe needs a tool name.",
|
|
274
|
+
use: "use needs a profile name. See them with passport profiles.",
|
|
275
|
+
completion: "completion needs bash, zsh, or fish.",
|
|
276
|
+
wait: "wait needs an approval id.",
|
|
277
|
+
rules: 'Use: passport rules test "<command>"',
|
|
278
|
+
exec: "exec needs a command to run.\nUse: passport exec -- railway up"
|
|
274
279
|
};
|
|
275
280
|
if (positionals.length < (minimum[command] ?? 0)) {
|
|
276
|
-
throw new ArgError(`${command}
|
|
281
|
+
throw new ArgError(needs[command] ?? `${command} needs a name.`);
|
|
277
282
|
}
|
|
278
283
|
const cap = max[command];
|
|
279
284
|
if (cap !== undefined && positionals.length > cap)
|
package/dist/cliAutopilot.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { guardStatus } from "./cliStatusGuard.js";
|
|
12
12
|
import { value } from "./cliArgs.js";
|
|
13
|
-
import { OTHER_APPS, PRESET_ROWS, rowLabel } from "./cliAutopilotPolicy.js";
|
|
13
|
+
import { CLASS_LABEL, OTHER_APPS, causeSentence, PRESET_ROWS, rowLabel } from "./cliAutopilotPolicy.js";
|
|
14
14
|
import { classifyLine, localMachine } from "./cliHookLocal.js";
|
|
15
15
|
import { ENV_KINDS, isEnvKind } from "./cliHookEnvironment.js";
|
|
16
16
|
import { decideGuard, guardLabel } from "./cliHookGuard.js";
|
|
@@ -22,17 +22,14 @@ export { actions } from "./cliActions.js";
|
|
|
22
22
|
import { looseningLines } from "./cliLoosening.js";
|
|
23
23
|
import { readCliPolicy } from "./cliPolicy.js";
|
|
24
24
|
import { failure, readBoundedJson, resolveCliAuth, timeoutMs } from "./cliSupport.js";
|
|
25
|
+
import { unknownSubcommand } from "./cliSuggest.js";
|
|
26
|
+
import { mark, termOf } from "./term.js";
|
|
25
27
|
export { api, json } from "./cliMemberCall.js";
|
|
26
28
|
export { wait } from "./cliWait.js";
|
|
27
29
|
import { api, text } from "./cliMemberCall.js";
|
|
28
30
|
// ---- passport rules test ----------------------------------------------------
|
|
29
31
|
const DECISION_WORDS = { allow: "Runs", ask: "Asks first", block: "Blocked" };
|
|
30
|
-
const
|
|
31
|
-
read: "Read",
|
|
32
|
-
change: "Change",
|
|
33
|
-
delete: "Delete",
|
|
34
|
-
irreversible: "Irreversible"
|
|
35
|
-
};
|
|
32
|
+
const DECISION_MARKS = { allow: "done", ask: "warn", block: "fail" };
|
|
36
33
|
function ageText(ms) {
|
|
37
34
|
const minutes = Math.round(ms / 60_000);
|
|
38
35
|
if (minutes < 1)
|
|
@@ -42,24 +39,29 @@ function ageText(ms) {
|
|
|
42
39
|
const hours = Math.round(minutes / 60);
|
|
43
40
|
return hours < 48 ? `${hours} h ago` : `${Math.round(hours / 24)} days ago`;
|
|
44
41
|
}
|
|
45
|
-
|
|
42
|
+
/** Each line of `text` under the command, or nothing. */
|
|
43
|
+
function indented(text) {
|
|
44
|
+
return text ? text.split("\n").map((line) => ` ${line}`) : [];
|
|
45
|
+
}
|
|
46
|
+
function ruleTestLines(term, label, result, source) {
|
|
46
47
|
if (result.decision === "none") {
|
|
47
48
|
return [
|
|
48
49
|
label,
|
|
49
50
|
" No decision: Passport doesn't decide this command, so your agent's own prompt applies.",
|
|
50
|
-
...(source
|
|
51
|
+
...indented(source)
|
|
51
52
|
];
|
|
52
53
|
}
|
|
53
|
-
const explanation = text(result.explanation) ??
|
|
54
|
+
const explanation = text(result.explanation) ??
|
|
55
|
+
`${result.cause ? causeSentence(result.decision, result.cause.label) : DECISION_WORDS[result.decision]}.`;
|
|
54
56
|
const environment = result.environment
|
|
55
57
|
? `${rowLabel(result.environment)}${result.environmentAssumed ? " (assumed)" : ""}`
|
|
56
58
|
: undefined;
|
|
57
59
|
return [
|
|
58
60
|
label,
|
|
59
|
-
` ${explanation}`,
|
|
61
|
+
` ${mark(term, DECISION_MARKS[result.decision])} ${explanation}`,
|
|
60
62
|
...(environment ? [` Environment: ${environment}`] : []),
|
|
61
|
-
...(result.actionClass ? [` Class: ${
|
|
62
|
-
|
|
63
|
+
...(result.actionClass ? [` Class: ${CLASS_LABEL[result.actionClass]}`] : []),
|
|
64
|
+
...indented(source)
|
|
63
65
|
];
|
|
64
66
|
}
|
|
65
67
|
/** Place every finding in the environment the person picked. */
|
|
@@ -121,16 +123,25 @@ async function askServer(body, args, runtime, deps) {
|
|
|
121
123
|
return null;
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
|
-
|
|
126
|
+
/** `rules test "<command>" [--environment <kind>]`, or a usage failure that
|
|
127
|
+
* suggests `test` for a typo. */
|
|
128
|
+
function ruleTestArgs(args) {
|
|
125
129
|
const [action, command] = args.positionals;
|
|
126
|
-
if (action !== "test"
|
|
130
|
+
if (action !== undefined && action !== "test") {
|
|
131
|
+
const unknown = unknownSubcommand("rules", action, ["test"]);
|
|
132
|
+
return failure(unknown.message, 6, "usage", unknown.next ? { next: unknown.next } : {});
|
|
133
|
+
}
|
|
134
|
+
if (!command?.trim()) {
|
|
127
135
|
return failure('Use: passport rules test "<command>" [--environment production|staging|development]', 6, "usage");
|
|
128
136
|
}
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
137
|
+
const environment = value(args, "environment");
|
|
138
|
+
if (environment !== undefined && !isEnvKind(environment)) {
|
|
131
139
|
return failure("--environment must be production, staging, or development.", 6, "usage");
|
|
132
140
|
}
|
|
133
|
-
|
|
141
|
+
return { command, environment: environment };
|
|
142
|
+
}
|
|
143
|
+
export async function rules(args, runtime, deps = {}) {
|
|
144
|
+
const { command, environment } = ruleTestArgs(args);
|
|
134
145
|
// Paths are read where you run this, like the hook reads the agent's folder.
|
|
135
146
|
const machine = deps.machine ?? localMachine(process.cwd(), runtime.env);
|
|
136
147
|
const line = classifyLine(command, machine);
|
|
@@ -151,7 +162,9 @@ export async function rules(args, runtime, deps = {}) {
|
|
|
151
162
|
const result = { decision: "none" };
|
|
152
163
|
return {
|
|
153
164
|
json: { command: null, ...result },
|
|
154
|
-
human: ruleTestLines("This command", result, "")
|
|
165
|
+
human: ruleTestLines(termOf(runtime.stdout, runtime.env), "This command", result, "")
|
|
166
|
+
.filter(Boolean)
|
|
167
|
+
.join("\n")
|
|
155
168
|
};
|
|
156
169
|
}
|
|
157
170
|
const profile = (() => {
|
|
@@ -185,11 +198,13 @@ export async function rules(args, runtime, deps = {}) {
|
|
|
185
198
|
result = local ?? { decision: "none" };
|
|
186
199
|
source = cached
|
|
187
200
|
? `Decided on this computer from rules synced ${ageText(Math.max(0, Date.now() - cached.fetchedAt))}.`
|
|
188
|
-
:
|
|
201
|
+
: profile
|
|
202
|
+
? "Decided on this computer from built-in rules, until yours sync.\nRun: passport status"
|
|
203
|
+
: "Decided on this computer from built-in rules. Sign in to use yours.\nRun: passport login";
|
|
189
204
|
}
|
|
190
205
|
return {
|
|
191
206
|
json: { command: label, ...result, source: source.startsWith("Decided by") ? "server" : "local" },
|
|
192
|
-
human: ruleTestLines(label, result, source).join("\n")
|
|
207
|
+
human: ruleTestLines(termOf(runtime.stdout, runtime.env), label, result, source).join("\n")
|
|
193
208
|
};
|
|
194
209
|
}
|
|
195
210
|
function isPresetName(value) {
|
|
@@ -23,6 +23,28 @@ export type Cause = {
|
|
|
23
23
|
id?: string;
|
|
24
24
|
label: string;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Checked copies of the class words in shared/autopilotContract.ts
|
|
28
|
+
* (cliAutopilotPolicy.test.ts compares them): one class, one word, on every
|
|
29
|
+
* surface. `CLASS_LABEL` names it ("Delete"), `CLASS_EFFECT` says what it does
|
|
30
|
+
* to an environment ("deletes from Production"), `CLASS_EFFECT_OTHER` without one
|
|
31
|
+
* ("deletes data").
|
|
32
|
+
*/
|
|
33
|
+
export declare const CLASS_LABEL: Readonly<Record<ActionClass, string>>;
|
|
34
|
+
export declare const CLASS_EFFECT: Readonly<Record<ActionClass, string>>;
|
|
35
|
+
export declare const CLASS_EFFECT_OTHER: Readonly<Record<ActionClass, string>>;
|
|
36
|
+
export declare const CLASS_OF_RISK: Readonly<Record<"read" | "write" | "destructive", ActionClass>>;
|
|
37
|
+
export declare function riskOfClass(actionClass: ActionClass): "read" | "write" | "destructive";
|
|
38
|
+
/**
|
|
39
|
+
* Checked copies of `ruleParts` and `causeSentence` in shared/collabContract.ts
|
|
40
|
+
* (the CLI can't import shared/; cliAutopilot.test.ts compares them):
|
|
41
|
+
* "Blocked by a workspace rule: no railway volume delete in Production".
|
|
42
|
+
*/
|
|
43
|
+
export declare function ruleParts(label: string): {
|
|
44
|
+
owner: string;
|
|
45
|
+
says: string;
|
|
46
|
+
} | null;
|
|
47
|
+
export declare function causeSentence(decision: Decision, label: string): string;
|
|
26
48
|
/** A CLI-relevant rule, flattened by the server (`CliPolicyRule`). */
|
|
27
49
|
export type CliRule = {
|
|
28
50
|
id: string;
|