passport-bridge 0.21.0 → 0.24.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 +62 -57
- package/dist/cliArgs.js +7 -1
- package/dist/cliAutopilot.d.ts +1 -1
- package/dist/cliAutopilot.js +2 -1
- package/dist/cliAutopilotPolicy.d.ts +9 -0
- package/dist/cliExec.js +7 -3
- package/dist/cliGuardHealth.js +1 -1
- package/dist/cliGuardState.js +2 -2
- package/dist/cliHook.js +31 -16
- package/dist/cliHookClassify.d.ts +14 -0
- package/dist/cliHookClassify.js +14 -0
- package/dist/cliHookClients.d.ts +23 -0
- package/dist/cliHookClients.js +52 -0
- package/dist/cliHookDecide.d.ts +5 -1
- package/dist/cliHookDecide.js +8 -3
- package/dist/cliHookDeliver.d.ts +24 -8
- package/dist/cliHookDeliver.js +59 -2
- package/dist/cliHookExtras.d.ts +8 -3
- package/dist/cliHookExtras.js +16 -3
- package/dist/cliHookGuard.d.ts +5 -0
- package/dist/cliHookGuard.js +12 -6
- package/dist/cliHookInput.d.ts +5 -0
- package/dist/cliHookInstall.d.ts +6 -6
- package/dist/cliHookInstall.js +16 -40
- package/dist/cliHookLifecycle.d.ts +22 -0
- package/dist/cliHookLifecycle.js +101 -0
- package/dist/cliHookLocal.d.ts +3 -0
- package/dist/cliHookLocal.js +20 -2
- package/dist/cliHookLocalCode.d.ts +2 -0
- package/dist/cliHookLocalCode.js +1 -1
- package/dist/cliHookRepo.d.ts +20 -0
- package/dist/cliHookRepo.js +36 -0
- package/dist/cliHookRewrite.d.ts +15 -1
- package/dist/cliHookRewrite.js +50 -1
- package/dist/cliHookScripts.d.ts +1 -0
- package/dist/cliHookScripts.js +14 -6
- package/dist/cliHookStep.d.ts +19 -0
- package/dist/cliHookStep.js +76 -0
- package/dist/cliKeys.d.ts +6 -58
- package/dist/cliKeys.js +72 -41
- package/dist/cliKeysBack.d.ts +31 -15
- package/dist/cliKeysBack.js +70 -47
- package/dist/cliKeysKeep.d.ts +34 -0
- package/dist/cliKeysKeep.js +110 -0
- package/dist/cliKeysSignOut.d.ts +33 -0
- package/dist/cliKeysSignOut.js +72 -0
- package/dist/cliKeysTypes.d.ts +74 -0
- package/dist/cliKeysTypes.js +1 -0
- package/dist/cliOutput.js +10 -4
- package/dist/cliPolicyV2.js +29 -2
- package/dist/cliScriptRead.d.ts +8 -1
- package/dist/cliScriptRead.js +22 -11
- package/dist/cliSeen.d.ts +77 -15
- package/dist/cliSeen.js +171 -34
- package/dist/cliSessions.d.ts +23 -45
- package/dist/cliSessions.js +135 -147
- package/dist/cliSessionsJson.d.ts +192 -0
- package/dist/cliSessionsJson.js +353 -0
- package/dist/cliSessionsRender.d.ts +35 -0
- package/dist/cliSessionsRender.js +350 -0
- package/dist/cliSpeed.d.ts +2 -1
- package/dist/cliSpeed.js +27 -8
- package/dist/cliStatus.js +5 -1
- package/dist/cliStatusGuard.d.ts +5 -1
- package/dist/cliStatusGuard.js +4 -0
- package/dist/cliUsage.d.ts +71 -0
- package/dist/cliUsage.js +333 -0
- package/dist/completion.js +2 -2
- package/dist/execVendors.d.ts +27 -2
- package/dist/execVendors.js +74 -23
- package/dist/hookFastPath.js +3 -2
- package/dist/initKeysStep.js +1 -0
- package/dist/keysKept.d.ts +17 -0
- package/dist/keysKept.js +92 -0
- package/dist/keysLocal.d.ts +2 -0
- package/dist/keysLocal.js +6 -0
- package/dist/keysReport.d.ts +32 -0
- package/dist/keysReport.js +72 -0
- package/dist/localReach.d.ts +30 -0
- package/dist/localReach.js +94 -0
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/scanStores.js +50 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +55 -161
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,33 +48,33 @@ passport run github_search_issues '{"query":"SSO"}'
|
|
|
48
48
|
|
|
49
49
|
## Commands
|
|
50
50
|
|
|
51
|
-
| Command | Purpose
|
|
52
|
-
| --------------------------------------------------------------------------------------------------------------------------- |
|
|
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]]`
|
|
55
|
-
| `login` | Browser sign-in or sign-up (or device sign-in with `--workspace`); saves a rotating CLI credential and makes the profile active.
|
|
56
|
-
| `logout` | Revoke the credential and always remove the local profile (warns if revocation fails).
|
|
57
|
-
| `profiles` / `use <name>` | List stored profiles / select the active one. Offline.
|
|
58
|
-
| `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.
|
|
59
|
-
| `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.
|
|
60
|
-
| `ready` | Readiness preflight for automation; gate on its `ready` field and exit code.
|
|
61
|
-
| `search [query] [--app <key>]` | Search permitted tools. Empty query lists the full catalog.
|
|
62
|
-
| `describe <tool>` | One exact definition with its full parameter schema.
|
|
63
|
-
| `run <tool> [json]` | Run a tool through Passport governance.
|
|
64
|
-
| `connect [app...] [--alias <name>] [--open] [--wait <s>]` | Show member sign-in links and optionally wait for completion.
|
|
65
|
-
| `resources [uri] [--out <file>]` | List or read MCP resources.
|
|
66
|
-
| `prompts [name] [--set k=v] [--out <file>]` | List or get MCP prompts.
|
|
67
|
-
| `scan [--path <dir>] [--verbose] [--check]`
|
|
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, until they do or it expires. Agents run it in the background.
|
|
70
|
-
| `rules test "<command>" [--environment <kind>]` | What Autopilot decides for a command, why, and which environment it acts on.
|
|
71
|
-
| `sessions [--
|
|
72
|
-
| `undo <action-id>\|--last [--option <id>] [--yes]` | Undo an action Passport took a backup before, within 7 days. See [Undo](#undo).
|
|
73
|
-
| `setup` | Install and maintain assigned team workflows as managed skills.
|
|
74
|
-
| `session` | Run NDJSON commands over one authenticated MCP session.
|
|
75
|
-
| `access` | Signed managed access: `keygen`, `actions`, `run`, `invoke`, `status`, `cancel`.
|
|
76
|
-
| `completion <bash\|zsh\|fish>` | Print a completion script. Offline.
|
|
77
|
-
| `help [command]`, `version` | Help; package version and local profile context.
|
|
51
|
+
| Command | Purpose |
|
|
52
|
+
| --------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
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). |
|
|
55
|
+
| `login` | Browser sign-in or sign-up (or device sign-in with `--workspace`); saves a rotating CLI credential and makes the profile active. |
|
|
56
|
+
| `logout` | Revoke the credential and always remove the local profile (warns if revocation fails). |
|
|
57
|
+
| `profiles` / `use <name>` | List stored profiles / select the active one. Offline. |
|
|
58
|
+
| `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. |
|
|
59
|
+
| `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. |
|
|
60
|
+
| `ready` | Readiness preflight for automation; gate on its `ready` field and exit code. |
|
|
61
|
+
| `search [query] [--app <key>]` | Search permitted tools. Empty query lists the full catalog. |
|
|
62
|
+
| `describe <tool>` | One exact definition with its full parameter schema. |
|
|
63
|
+
| `run <tool> [json]` | Run a tool through Passport governance. |
|
|
64
|
+
| `connect [app...] [--alias <name>] [--open] [--wait <s>]` | Show member sign-in links and optionally wait for completion. |
|
|
65
|
+
| `resources [uri] [--out <file>]` | List or read MCP resources. |
|
|
66
|
+
| `prompts [name] [--set k=v] [--out <file>]` | List or get MCP prompts. |
|
|
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
|
+
| `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, until they do or it expires. Agents run it in the background. |
|
|
70
|
+
| `rules test "<command>" [--environment <kind>]` | What Autopilot decides for a command, why, and which environment it acts on. |
|
|
71
|
+
| `sessions [--all\|--running\|--production-changes] [--project <name>] [--pr <n>] [--since <when>]`, `sessions <id>` | Your agents' work items by project, Notable first; the Production changes ledger; or one session's outcome and recent actions. |
|
|
72
|
+
| `undo <action-id>\|--last [--option <id>] [--yes]` | Undo an action Passport took a backup before, within 7 days. See [Undo](#undo). |
|
|
73
|
+
| `setup` | Install and maintain assigned team workflows as managed skills. |
|
|
74
|
+
| `session` | Run NDJSON commands over one authenticated MCP session. |
|
|
75
|
+
| `access` | Signed managed access: `keygen`, `actions`, `run`, `invoke`, `status`, `cancel`. |
|
|
76
|
+
| `completion <bash\|zsh\|fish>` | Print a completion script. Offline. |
|
|
77
|
+
| `help [command]`, `version` | Help; package version and local profile context. |
|
|
78
78
|
|
|
79
79
|
Global options: `--profile <name>`, `--json`, `--timeout <seconds>` (default 30), `--quiet`, `--caller <id>`.
|
|
80
80
|
|
|
@@ -119,7 +119,7 @@ passport scan --path ../api --verbose
|
|
|
119
119
|
passport scan --check # CI and pre-commit: files only, exit 5 on a high or medium key
|
|
120
120
|
```
|
|
121
121
|
|
|
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.
|
|
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, Composer), 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
123
|
|
|
124
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.
|
|
125
125
|
|
|
@@ -266,6 +266,8 @@ An ask becomes one Activity row. In Claude Code, with the audit hook registered,
|
|
|
266
266
|
|
|
267
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.
|
|
268
268
|
|
|
269
|
+
Token numbers (`src/cliUsage.ts`, 0.24.0+): Claude Code's SessionStart and SessionEnd hooks note the session's `transcript_path` under `$PASSPORT_HOME/usage/<profile>/`; the detached `passport hook flush` reads what each transcript (and its subagents' files) added since the last byte offset, bounded per run, and sends per-session, per-model token counts and model ids as `usage` batches. No message content is kept or sent. Only when cli-policy v2 carries `usage: true` (the workspace keeps them); `PASSPORT_TOKEN_USAGE=off` turns it off on one computer.
|
|
270
|
+
|
|
269
271
|
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`.
|
|
270
272
|
|
|
271
273
|
### Autopilot from the terminal
|
|
@@ -274,7 +276,8 @@ The Passport plugin (`rsyed94/passport-plugins`) runs the same two hooks from th
|
|
|
274
276
|
passport rules test "railway redeploy -e staging"
|
|
275
277
|
passport rules test "rm -rf ~/"
|
|
276
278
|
passport wait apr_123
|
|
277
|
-
passport sessions
|
|
279
|
+
passport sessions # or: --all, --running, --production-changes
|
|
280
|
+
passport sessions ses_123
|
|
278
281
|
passport sync # or: passport sync --remove
|
|
279
282
|
passport env # or: passport env set railway qa staging
|
|
280
283
|
passport actions add scripts/deploy.py --environment production --class change
|
|
@@ -285,9 +288,9 @@ passport actions sync # propose this repository's .passport/actions.toml
|
|
|
285
288
|
|
|
286
289
|
- `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.
|
|
287
290
|
- `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`.
|
|
288
|
-
- `sessions` lists
|
|
291
|
+
- `sessions` lists work items the way the Sessions page does (`GET /api/my/work-items`): a pull request or branch with every session on it rolled up, grouped by project (or, for app connections, by the apps they used). Each item has its agents, then one shape line: actions, active time, failed, confirmed Production changes, unplaced changes, asks with how they ended, blocked, data checks, undone, and the share Passport couldn't check. Notable items come first; the rest fold into `14 routine work items · 3,200 reads · nothing needed you`. `--all` lists every item, `--running` only those with a running session, and `--production-changes` prints the ledger (`GET /api/my/production-ledger`, 7 days unless `--since`): changes to confirmed Production by app and target, then the unplaced count with a link to set environments. `--project`, `--pr`, `--since` (`today`, `24h`, `7d`, `30d`, `90d`, or a date read in local time), and `--status running|ended` go to the server, which applies them to every session in the window, never to a loaded page. The CLI follows up to five pages and then links the rest. `sessions <id>` reads one session (`GET /api/my/agent-sessions/<id>`): its title, place, agent, and active time; the web page's summary strip (actions, shipped, Production, failed, asked, not checked, undo, data checks); and its 15 latest actions with what each acted on, where it landed, and how it ended. On a terminal parts wrap only between `·` and the timeline stacks when it doesn't fit; piped output never wraps and has no color.
|
|
289
292
|
- `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.
|
|
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
|
|
293
|
+
- `status` is one screen, like `gh auth status`, with a label per row (`You` with the name you signed in as, `Computer`, `Guard`, `Autopilot`, `Apps`, `Keys`, `Shims`, `This folder`, `Allowlists`, `CLI`); under 60 columns each label gets its own row, and piped it never wraps. `Guard` lists each agent's guard (`✓ Claude Code On`, `! Codex Not trusted`) with its fix on the line under it, the coverage line, and sends the daily guard report when due. It also adds today's speed line, `Passport adds ~20 ms per action and asked you twice today. 412 actions ran on their own.` (across your computers when the server keeps speed numbers, else `(this computer)`), and `Answered for you: N prompts today` (allows the hook gave in Claude Code and Cursor, and Codex commands Passport synced, counted only when the agent would have prompted) and which agents' allowlists are synced. Under the presets, one line per exception that lets something run your presets would ask about, in the web's words: `! 1 exception: deletes run in Production without asking, even without a backup.` Counts are appended locally (`$PASSPORT_HOME/answered/`) and sent in batches at most every five minutes as `answered: {batch, count}` on `POST /api/my/cli-activity`.
|
|
291
294
|
- `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.
|
|
292
295
|
- `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.
|
|
293
296
|
|
|
@@ -306,7 +309,9 @@ passport keys shim # the CLIs that run through Passport when you type
|
|
|
306
309
|
- Masking, like `op run`, when stdout isn't a terminal (an agent's shell, a pipe, a CI log, where output is kept and read later): `exec` reads the CLI's stdout and stderr and replaces each issued value (raw, base64, URL-encoded) with `<hidden by Passport>`. Output streams; the exit code (or 128 + signal) passes through. In a terminal the CLI gets the terminal itself (colors, prompts), unmasked: a person watching their own screen isn't the risk. `--mask` masks in a terminal too (the CLI then writes to a pipe); `--no-masking` (or `PASSPORT_EXEC_NO_MASKING=1` through a shim) never masks. Cost on an M-series Mac (`npm run bench:mask`): about 625 MB/s through the masker against 1,155 MB/s for a bare pipe, and a few microseconds per line.
|
|
307
310
|
- Releases: Passport's own release computer keeps its Railway sign-in, so releases never depend on Passport. In a repository with `scripts/lib/local-release-controller.mjs`, `keys move` and `init` ask `This computer deploys Passport with the Railway CLI. Moving the key will stop releases. Keep it here? [Y/n]` (Enter, `--yes`, and no terminal keep it). Release attestation checks the exact Railway CLI binary on PATH with a throwaway HOME, so a shim in front of it fails closed. See `docs/DEPLOY.md`.
|
|
308
311
|
|
|
309
|
-
- 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
|
|
312
|
+
- 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 the CLI reads those files again and always posts `POST /api/my/keys/report`: `reappeared` (keys back, so the key reads "Back on <computer>" with the fix `passport keys move`), `checked` (every vendor it looked at; one not back stops reading "back"), `remaining` and `kept` counts, and `autoRemoved`. 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, and an older server that refuses the newer fields gets the report without them.
|
|
313
|
+
- Keys stay in Passport: while Passport holds a working key for a CLI (the exec marker), the guard denies that CLI's own sign-in (`railway login`, `gh auth login`, `aws sso login`, `fly auth login`, …) in Claude Code, Codex, and Cursor with `Passport holds your Railway key; run it through Passport: passport exec -- railway <command>.`, and `exec` (so a shim) refuses it the same way. `keys move` signs a browser sign-in out (Railway, Vercel, and Wrangler session fields only) when Passport already holds a working key, without sending it anywhere. The first interactive `keys move` asks once, `Keep my CLIs signed out? … [y/N]`; with yes, the daily check removes a returned key while Passport holds a working one and reports it as `autoRemoved` (the server records a `cli_key_removed` silent fix for each). `passport keys signed-out [on|off]` changes the answer. Both choices live in `$PASSPORT_HOME/keys-choices/<profile>.json` (vendor names and the answer only).
|
|
314
|
+
- Dev loops: `railway run|shell|connect`, `vercel dev|build`, and `supabase functions serve` stay refused by `exec`; `wrangler dev` runs through it only when Passport hands out a short-lived Cloudflare key (otherwise exec refuses before the command runs). `passport keys keep <cli> [--remove]` keeps a CLI signed in here on purpose: the guard lets its sign-in run, Passport never removes it, its shim goes, and the report counts it under `kept` (with local copy `dev` on the key), never as a key left to move. The release computer's Railway key is kept the same way (`releases`). `remaining` is counted one way everywhere: one per CLI sign-in `keys move` can act on, by provider.
|
|
310
315
|
- `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.
|
|
311
316
|
- `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`).
|
|
312
317
|
- Asks wait for your approval in Passport (web or push) when you're at the keyboard or with `--wait <sec>`; otherwise exit 4 with the approval id: run `passport wait <id>`, then the command again. While it waits, the approval link prints at once and, on a terminal, one live line counts down (`Waiting for Erin · 1:32 left`); piped, it prints the waiting line and `Open in Passport: <url>`. Ctrl-C exits 4: `The request is still open. Keep waiting, then run the command again.` and `Run: passport wait <id>`. An approval is used once. Blocked or declined: exit 5. A decline answers the same command for ten minutes, said with who and when: `Declined 2 minutes ago by Erin: Not during the freeze.` and `Run with --ask-again to request again.`; `--ask-again` opens a new request. No key, or it stopped working: exit 3 (`No Railway key in Passport yet. Add a Railway key in Passport → Apps.`, or `Your Railway key in Passport stopped working. Update it in Apps.`). When this computer still has the Railway CLI's own sign-in, the no-key line is `No Railway key in Passport yet, but this computer has one.` with `Run: passport keys move railway` instead (read here; Passport never sees this computer's files). Offline: exit 1, nothing runs, and exec never uses a key on this computer instead. A team that requires the guard refuses exec for an agent whose computer hasn't reported its guard On in 48 hours: exit 5 with `Blocked by Passport: guard required…` and the fix.
|
|
@@ -433,31 +438,31 @@ Questions follow one convention (`src/cliAsk.ts`), only on a terminal: `[Y/n]` f
|
|
|
433
438
|
|
|
434
439
|
On a terminal, human output comes from one renderer (`src/term.ts`): it wraps to the window's width (at least 40 columns, at most 100) without breaking a URL or a `passport` command, hangs wrapped lines under their label or mark, stacks a table one row at a time when its columns don't fit, and clips a live line (a countdown, a "Checking…" row) to one row so it's always replaced cleanly. Marks always sit next to words (`✓ On`, `! Not trusted`, `– skipped`), with `+`, `!`, `-` where the terminal can't show them. Piped output never wraps, has no color, and draws no live lines. `NO_COLOR` and `TERM=dumb` turn color off.
|
|
435
440
|
|
|
436
|
-
| Command | JSON value
|
|
437
|
-
| ---------------------- |
|
|
438
|
-
| `login` | `{profile,endpoint,client,surface,active,workspaceId,workspaceName?,memberName?,next}`; without a terminal or with `--json`, step one is `{status:"pending",verification_url,code,expires_in,next_step,login_id,next}`
|
|
439
|
-
| `profiles` | `{profiles:[{name,active,client?}],active?}`
|
|
440
|
-
| `use` | `{profile,active:true}`
|
|
441
|
-
| `logout` | `{profile,removed,revoked,shimsRemoved?}`
|
|
442
|
-
| `status` | `{workspace,member,endpoint,auth,profile?,client,mcps,autopilot?:{presets,floors,floorReason?,exceptions?,cache:{version,fetchedAt,ageMs}},next?,computer,keys?,keysOnThisComputer?,folder,cli:{version},signedInAs?,shims?:[{vendor,command,state}]}`
|
|
443
|
-
| `wait` | `{approvalId,status:"approved",scope?,message}`; declined, expired, and still-waiting are errors with `approvalId`
|
|
444
|
-
| `rules` | `{command,decision,cause?,explanation?,environment?,environmentAssumed?,actionClass?,source}`
|
|
445
|
-
| `sessions` | `{
|
|
446
|
-
| `undo` | `{actionId,status,message,steps:[{label,ok,detail?}],option,undoActionId?}`; without `--yes` off a terminal, `{actionId,status:"preview",preview,next}`; pending, blocked, and declined are errors
|
|
447
|
-
| `doctor` | `{version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}`, also on failure
|
|
448
|
-
| `ready` | `{ready,version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}`
|
|
449
|
-
| `search` | Gateway payload with `results` or `catalog`, and `note`
|
|
450
|
-
| `describe` | Tool definition (`tool`, `parameters`) plus `name`/`inputSchema` aliases
|
|
451
|
-
| `run` | Full governed MCP tool result, including `structuredContent`
|
|
452
|
-
| `connect` | Gateway payload with `connections` and optional `connectAllUrl`
|
|
453
|
-
| `resources`, `prompts` | MCP list, read, or get result
|
|
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
|
|
456
|
-
| `session` | NDJSON `{id?,ok,exitCode,result?}` or `{id?,ok:false,error,cause,exitCode,...}`
|
|
457
|
-
| `access` | `keygen`: algorithm, paths, public JWK; `actions`: `{actions}`; `run`/`cancel`: `{run}`; `invoke`: governed result; `status`: `{receipt}`
|
|
458
|
-
| `completion` | `{shell,script}`
|
|
459
|
-
| `help` | `{command,help}`
|
|
460
|
-
| `version` | `{version,profileCount,profileSelected,selectionSource,next,endpoint?,profile?}`
|
|
441
|
+
| Command | JSON value |
|
|
442
|
+
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
443
|
+
| `login` | `{profile,endpoint,client,surface,active,workspaceId,workspaceName?,memberName?,next}`; without a terminal or with `--json`, step one is `{status:"pending",verification_url,code,expires_in,next_step,login_id,next}` |
|
|
444
|
+
| `profiles` | `{profiles:[{name,active,client?}],active?}` |
|
|
445
|
+
| `use` | `{profile,active:true}` |
|
|
446
|
+
| `logout` | `{profile,removed,revoked,shimsRemoved?}` |
|
|
447
|
+
| `status` | `{workspace,member,endpoint,auth,profile?,client,mcps,autopilot?:{presets,floors,floorReason?,exceptions?,cache:{version,fetchedAt,ageMs}},next?,computer,keys?,keysOnThisComputer?,folder,cli:{version},signedInAs?,shims?:[{vendor,command,state}]}` |
|
|
448
|
+
| `wait` | `{approvalId,status:"approved",scope?,message}`; declined, expired, and still-waiting are errors with `approvalId` |
|
|
449
|
+
| `rules` | `{command,decision,cause?,explanation?,environment?,environmentAssumed?,actionClass?,source}` |
|
|
450
|
+
| `sessions` | `{view,groups:[{key,kind,label,apps,running,production,unplaced,items:[{key,title,project,branch,pull,agents,sessions,sessionIds,startedAt,lastActivityAt,activeMs,running,waiting,shape,reasons,severity,link}],routine:{count,sessions,actions,reads,items}\|null}],totals,complete,nextCursor}`; `--production-changes`: `{view,sinceTs,untilTs,total,unplaced,apps:[{appKey,appName,count,lastTs,targets:[{target,tool,actionClass,count,failed,firstTs,lastTs}]}]}`; `<id>`: `{view,session,outcome,approvals,timeline,nextCursor}` |
|
|
451
|
+
| `undo` | `{actionId,status,message,steps:[{label,ok,detail?}],option,undoActionId?}`; without `--yes` off a terminal, `{actionId,status:"preview",preview,next}`; pending, blocked, and declined are errors |
|
|
452
|
+
| `doctor` | `{version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}`, also on failure |
|
|
453
|
+
| `ready` | `{ready,version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}` |
|
|
454
|
+
| `search` | Gateway payload with `results` or `catalog`, and `note` |
|
|
455
|
+
| `describe` | Tool definition (`tool`, `parameters`) plus `name`/`inputSchema` aliases |
|
|
456
|
+
| `run` | Full governed MCP tool result, including `structuredContent` |
|
|
457
|
+
| `connect` | Gateway payload with `connections` and optional `connectAllUrl` |
|
|
458
|
+
| `resources`, `prompts` | MCP list, read, or get result |
|
|
459
|
+
| `discover` | `{snapshot,report,compliant}` (the old name of `scan`'s inventory step, for one release) |
|
|
460
|
+
| `scan` | `{version:1,findings:[{id,provider,kind,label,severity,location,locations,blastRadius}],agents,unreadable,checked,inventory?:{snapshot,report,compliant}}`; `inventory` only when signed in, or `{error}` when it couldn't be sent |
|
|
461
|
+
| `session` | NDJSON `{id?,ok,exitCode,result?}` or `{id?,ok:false,error,cause,exitCode,...}` |
|
|
462
|
+
| `access` | `keygen`: algorithm, paths, public JWK; `actions`: `{actions}`; `run`/`cancel`: `{run}`; `invoke`: governed result; `status`: `{receipt}` |
|
|
463
|
+
| `completion` | `{shell,script}` |
|
|
464
|
+
| `help` | `{command,help}` |
|
|
465
|
+
| `version` | `{version,profileCount,profileSelected,selectionSource,next,endpoint?,profile?}` |
|
|
461
466
|
|
|
462
467
|
Errors: `{"error":"...","cause":"blocked","exitCode":5,"app":"github"}`, optionally with `approvalId`, `hint`, `profiles`, `next` (`argv` plus description), `remediation`, `retry`, `requiredInput`, or `connectUrl`.
|
|
463
468
|
|
package/dist/cliArgs.js
CHANGED
|
@@ -91,6 +91,12 @@ const FLAGS = {
|
|
|
91
91
|
"client-id": { kind: "value", commands: ["access"] },
|
|
92
92
|
environment: { kind: "value", commands: ["rules", "actions"] },
|
|
93
93
|
status: { kind: "value", commands: ["sessions"] },
|
|
94
|
+
all: { kind: "boolean", commands: ["sessions"] },
|
|
95
|
+
running: { kind: "boolean", commands: ["sessions"] },
|
|
96
|
+
"production-changes": { kind: "boolean", commands: ["sessions"] },
|
|
97
|
+
project: { kind: "value", commands: ["sessions"] },
|
|
98
|
+
pr: { kind: "value", commands: ["sessions"] },
|
|
99
|
+
since: { kind: "value", commands: ["sessions"] },
|
|
94
100
|
remove: { kind: "boolean", commands: ["sync", "keys"] },
|
|
95
101
|
last: { kind: "boolean", commands: ["undo"] },
|
|
96
102
|
option: { kind: "value", commands: ["undo"] }
|
|
@@ -254,7 +260,7 @@ function validateShape(command, positionals) {
|
|
|
254
260
|
hook: 1,
|
|
255
261
|
wait: 1,
|
|
256
262
|
rules: 2,
|
|
257
|
-
sessions:
|
|
263
|
+
sessions: 1,
|
|
258
264
|
env: 4,
|
|
259
265
|
sync: 0,
|
|
260
266
|
undo: 1,
|
package/dist/cliAutopilot.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type AutopilotStatus = {
|
|
|
37
37
|
today: number;
|
|
38
38
|
source: "workspace" | "this-computer";
|
|
39
39
|
};
|
|
40
|
-
/** "Passport
|
|
40
|
+
/** "Passport adds ~20 ms per action and asked you twice today. …": across your
|
|
41
41
|
* computers when Passport keeps the numbers, else this computer's own. */
|
|
42
42
|
speed?: {
|
|
43
43
|
line: string;
|
package/dist/cliAutopilot.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { guardStatus } from "./cliStatusGuard.js";
|
|
12
12
|
import { value } from "./cliArgs.js";
|
|
13
13
|
import { CLASS_LABEL, OTHER_APPS, causeSentence, PRESET_ROWS, rowLabel } from "./cliAutopilotPolicy.js";
|
|
14
|
+
import { unknownVerb } from "./cliHookClassify.js";
|
|
14
15
|
import { classifyLine, localMachine } from "./cliHookLocal.js";
|
|
15
16
|
import { ENV_KINDS, isEnvKind } from "./cliHookEnvironment.js";
|
|
16
17
|
import { decideGuard, guardLabel } from "./cliHookGuard.js";
|
|
@@ -92,7 +93,7 @@ function localTest(command, findings, complete, policy, machine) {
|
|
|
92
93
|
*/
|
|
93
94
|
function testBody(lead, label, target, environment) {
|
|
94
95
|
if (lead.local) {
|
|
95
|
-
const finding = { vendor: lead.vendor, verb: lead.verb ??
|
|
96
|
+
const finding = { vendor: lead.vendor, verb: lead.verb ?? unknownVerb(lead.args), risk: lead.risk };
|
|
96
97
|
return { finding: { ...finding, environment: environment ?? lead.local.environment } };
|
|
97
98
|
}
|
|
98
99
|
// Where this computer placed it: a flag, the folder's link, or a mapping.
|
|
@@ -142,6 +142,11 @@ export type AutopilotPolicy = {
|
|
|
142
142
|
localCommands?: boolean;
|
|
143
143
|
/** The server keeps the hook's speed numbers (cli-policy v2 `speed`). */
|
|
144
144
|
reportsSpeed?: boolean;
|
|
145
|
+
/** The workspace keeps per-session token numbers (cli-policy v2 `usage`). */
|
|
146
|
+
reportsUsage?: boolean;
|
|
147
|
+
/** The workspace keeps the agent's own step descriptions (cli-policy v2
|
|
148
|
+
* `descriptions`, "Show what agents say they're doing"). Off when absent. */
|
|
149
|
+
reportsSteps?: boolean;
|
|
145
150
|
/** Production classes someone else must approve: never run here, and never
|
|
146
151
|
* approved in the agent's own prompt. "Maya or Sam" names who approves. */
|
|
147
152
|
secondPerson?: {
|
|
@@ -166,6 +171,10 @@ export type AutopilotPolicy = {
|
|
|
166
171
|
/** The label came from the connected app, not from a link file. */
|
|
167
172
|
confirmed?: boolean;
|
|
168
173
|
}>;
|
|
174
|
+
/** Where code that reaches each repository's default branch lands, by
|
|
175
|
+
* repository name (lowercase): Production for one that deploys on merge.
|
|
176
|
+
* Present only when the server places git and gh by reach (`localReach.ts`). */
|
|
177
|
+
repos?: Record<string, EnvKind>;
|
|
169
178
|
/** Known project scripts (Batch A item 5), vendor `project`: they set class
|
|
170
179
|
* and environment only, never an allow. */
|
|
171
180
|
project?: {
|
package/dist/cliExec.js
CHANGED
|
@@ -23,7 +23,7 @@ import { basename, dirname, join, resolve } from "node:path";
|
|
|
23
23
|
import { bool, value } from "./cliArgs.js";
|
|
24
24
|
import { memberApi } from "./cliClient.js";
|
|
25
25
|
import { passportUnreachable } from "./cliOutput.js";
|
|
26
|
-
import { classifyCommand } from "./cliHookClassify.js";
|
|
26
|
+
import { classifyCommand, UNRECOGNIZED_VERB } from "./cliHookClassify.js";
|
|
27
27
|
import { reportedEnvironment } from "./cliHookEnvironment.js";
|
|
28
28
|
import { localMachine } from "./cliHookLocal.js";
|
|
29
29
|
import { NODE_LINK_FS } from "./envLinkFs.js";
|
|
@@ -33,7 +33,7 @@ import { execBackupTarget } from "./execBackupTarget.js";
|
|
|
33
33
|
import { readCliPolicy } from "./cliPolicy.js";
|
|
34
34
|
import { noteExecVendor } from "./execMarker.js";
|
|
35
35
|
import { CliFailure, callerFrom, failure, readBoundedJson, resolveCliAuth, safeApiError, sleep, timeoutMs } from "./cliSupport.js";
|
|
36
|
-
import { EXEC_ENV_NAMES, EXEC_PASSPORT_ENV, EXEC_SHADOWED_ENV, EXEC_VENDOR_NAMES, execVendorOf } from "./execVendors.js";
|
|
36
|
+
import { EXEC_ENV_NAMES, EXEC_PASSPORT_ENV, EXEC_SHADOWED_ENV, EXEC_VENDOR_NAMES, devLoopRefusal, execVendorOf } from "./execVendors.js";
|
|
37
37
|
import { execTarget } from "./execTarget.js";
|
|
38
38
|
import { maskChildOutput, secretNeedles } from "./execMask.js";
|
|
39
39
|
import { findVendorBinary, removeShims } from "./execShims.js";
|
|
@@ -75,7 +75,7 @@ export function execFinding(vendor, binary, args, policy, where) {
|
|
|
75
75
|
const environment = reportedEnvironment(target);
|
|
76
76
|
return {
|
|
77
77
|
vendor,
|
|
78
|
-
verb: verb ||
|
|
78
|
+
verb: verb || UNRECOGNIZED_VERB,
|
|
79
79
|
risk: found?.risk ?? "unknown",
|
|
80
80
|
...(environment ? { environment } : {}),
|
|
81
81
|
// Where it lands, for a server that reads it (Phase 4.5).
|
|
@@ -504,6 +504,10 @@ export async function exec(args, runtime, deps = {}) {
|
|
|
504
504
|
return pendingFailure(decided, "Passport didn't allow this command yet.");
|
|
505
505
|
const credential = checkedCredential(vendor, decided.credential?.env);
|
|
506
506
|
remember(true);
|
|
507
|
+
// A dev loop runs only with a key that expires within minutes.
|
|
508
|
+
const devLoop = devLoopRefusal(vendor, args.positionals.slice(1), decided.credential?.issuance);
|
|
509
|
+
if (devLoop)
|
|
510
|
+
return failure(devLoop, 6, "exec_refused");
|
|
507
511
|
if (bool(args, "verbose") && typeof decided.credential?.label === "string") {
|
|
508
512
|
// "Your stored Railway key" reads "Passport: used your stored Railway key."
|
|
509
513
|
const label = decided.credential.label.slice(0, 120);
|
package/dist/cliGuardHealth.js
CHANGED
|
@@ -149,6 +149,6 @@ export async function guardHeartbeat(api, profile, env, signal, now = Date.now()
|
|
|
149
149
|
return null;
|
|
150
150
|
const sent = await sendGuardHealth(api, profile, env, signal);
|
|
151
151
|
// Once a day too: has a key `passport keys move` removed come back?
|
|
152
|
-
await (await import("./cliKeysBack.js")).checkKeysBack(api, signal).catch(() => undefined);
|
|
152
|
+
await (await import("./cliKeysBack.js")).checkKeysBack(api, signal, process.env, profile).catch(() => undefined);
|
|
153
153
|
return sent;
|
|
154
154
|
}
|
package/dist/cliGuardState.js
CHANGED
|
@@ -79,9 +79,9 @@ export function problemFix(kind, client) {
|
|
|
79
79
|
};
|
|
80
80
|
case "coverage-drop":
|
|
81
81
|
return {
|
|
82
|
-
text: "Open the agent's sessions and look at what
|
|
82
|
+
text: "Open the agent's sessions and look at what Passport couldn't tell.",
|
|
83
83
|
link: agent,
|
|
84
|
-
docs: `${DOCS_BASE}/member/cli-hook#
|
|
84
|
+
docs: `${DOCS_BASE}/member/cli-hook#decided-placed-and-blind`
|
|
85
85
|
};
|
|
86
86
|
case "key-back":
|
|
87
87
|
return {
|
package/dist/cliHook.js
CHANGED
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
* open: the agent must never notice this hook going wrong.
|
|
16
16
|
*/
|
|
17
17
|
import { value } from "./cliArgs.js";
|
|
18
|
-
import { summarize } from "./cliHookClassify.js";
|
|
18
|
+
import { summarize, unknownVerb, UNRECOGNIZED_VERB } from "./cliHookClassify.js";
|
|
19
19
|
import { classifyLine, localMachine, workingFolder, worthReporting } from "./cliHookLocal.js";
|
|
20
20
|
import { projectOf } from "./cliHookProject.js";
|
|
21
21
|
import { codexAskBlocked, planGuard } from "./cliHookDecide.js";
|
|
22
|
-
import { decideGuard, guardMachineOf } from "./cliHookGuard.js";
|
|
22
|
+
import { decideEach, decideGuard, guardMachineOf } from "./cliHookGuard.js";
|
|
23
23
|
import { detectMode } from "./cliHookMode.js";
|
|
24
24
|
import { cappedHold, holdSeconds } from "./cliHookHold.js";
|
|
25
25
|
import { readInput } from "./cliHookInput.js";
|
|
@@ -32,6 +32,7 @@ import { hasExpired, holdAsk, takeAsk } from "./cliHookPending.js";
|
|
|
32
32
|
import { readCliPolicy } from "./cliPolicy.js";
|
|
33
33
|
import { saveScriptCache, scriptReader, scriptReport } from "./cliScriptRead.js";
|
|
34
34
|
import { standDownForManaged } from "./managedHooks.js";
|
|
35
|
+
import { withStep } from "./cliHookStep.js";
|
|
35
36
|
const MAX_FINDINGS = 8;
|
|
36
37
|
const MAX_OPAQUE_KINDS = 6;
|
|
37
38
|
const SHELL_TOOLS = new Set(["Bash", "bash", "shell", "Shell"]);
|
|
@@ -46,6 +47,15 @@ function text(candidate, max) {
|
|
|
46
47
|
.slice(0, max);
|
|
47
48
|
return cleaned || undefined;
|
|
48
49
|
}
|
|
50
|
+
/** This machine for the guard, with the repository's name for code to main. */
|
|
51
|
+
function guardAtFor(machine, input, env) {
|
|
52
|
+
const repo = projectOf(workingFolder(input)).project;
|
|
53
|
+
return { ...guardMachineOf(machine, workingFolder(input), env), ...(repo ? { repo } : {}) };
|
|
54
|
+
}
|
|
55
|
+
/** The agent's own session id, as the hook input names it. */
|
|
56
|
+
function sessionOfInput(input) {
|
|
57
|
+
return text(input.session_id, 128) ?? text(input.conversation_id, 128);
|
|
58
|
+
}
|
|
49
59
|
/** The last path segment only. A full working directory is never reported. */
|
|
50
60
|
function directoryName(candidate) {
|
|
51
61
|
if (typeof candidate !== "string")
|
|
@@ -69,7 +79,7 @@ export function safeVerb(raw) {
|
|
|
69
79
|
.split(/\s+/)
|
|
70
80
|
.filter((token) => VERB_TOKEN.test(token))
|
|
71
81
|
.slice(0, 4);
|
|
72
|
-
return tokens.join(" ").slice(0, 80).trim() ||
|
|
82
|
+
return tokens.join(" ").slice(0, 80).trim() || UNRECOGNIZED_VERB;
|
|
73
83
|
}
|
|
74
84
|
function isCursorEvent(input) {
|
|
75
85
|
return input.hook_event_name === "beforeShellExecution" || input.hook_event_name === "afterShellExecution";
|
|
@@ -146,7 +156,7 @@ function reportable(findings, decided = [], local = false) {
|
|
|
146
156
|
const entry = decided.find((candidate) => candidate.finding === finding);
|
|
147
157
|
return {
|
|
148
158
|
vendor: finding.vendor,
|
|
149
|
-
verb: safeVerb(finding.verbKey ?? finding.verb),
|
|
159
|
+
verb: safeVerb(finding.verbKey ?? finding.verb ?? unknownVerb(finding.args)),
|
|
150
160
|
risk: finding.risk,
|
|
151
161
|
...(entry?.reported ? { environment: entry.reported } : {}),
|
|
152
162
|
...entry?.placement,
|
|
@@ -286,6 +296,9 @@ async function runAudit(args, runtime, deps) {
|
|
|
286
296
|
const input = await readInput(runtime, budget);
|
|
287
297
|
if (!input)
|
|
288
298
|
return;
|
|
299
|
+
// A session started or ended: one marker, queued like any report.
|
|
300
|
+
if (await (await import("./cliHookLifecycle.js")).lifecycle(input, args, runtime, deps))
|
|
301
|
+
return;
|
|
289
302
|
// A PreToolUse event gets no opinion from the audit hook: that is the guard's job.
|
|
290
303
|
const event = hookEvent(input, "post", args, runtime);
|
|
291
304
|
if (!event)
|
|
@@ -304,13 +317,14 @@ async function runAudit(args, runtime, deps) {
|
|
|
304
317
|
const findings = line.findings;
|
|
305
318
|
saveScriptCache(scripts);
|
|
306
319
|
// v2: the same decision the guard made, so the row says why it ran.
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
: null;
|
|
320
|
+
const guardAt = guardAtFor(machine, input, runtime.env);
|
|
321
|
+
const decision = policy?.version === 2 ? decideGuard(findings, policy, event.command, line.complete, guardAt) : null;
|
|
310
322
|
const local = policy?.version === 2 && policy.autopilot.localCommands === true;
|
|
311
|
-
|
|
323
|
+
// Where each command landed, even when the line got no decision.
|
|
324
|
+
const decided = policy?.version === 2 ? (decision?.decided ?? decideEach(findings, policy, guardAt)) : undefined;
|
|
325
|
+
let report = buildReport(input, findings, runtime.env, value(args, "client"), decided, local, scripts);
|
|
312
326
|
if (report && policy?.version === 2) {
|
|
313
|
-
report = { ...report, ...autopilotDecision(decision) };
|
|
327
|
+
report = withStep({ ...report, ...autopilotDecision(decision) }, input, policy);
|
|
314
328
|
}
|
|
315
329
|
const now = (deps.now ?? Date.now)();
|
|
316
330
|
// The guard parked what it decided before this exact command: send one row
|
|
@@ -464,20 +478,21 @@ async function runGuard(args, runtime, deps) {
|
|
|
464
478
|
const scripts = scriptReader({ phase: "pre", project: projectContext(policy), now: deps.budget?.scriptClock });
|
|
465
479
|
const machine = { ...localMachine(workingFolder(input), runtime.env), scripts };
|
|
466
480
|
const line = classifyLine(event.command, machine);
|
|
467
|
-
const decision = decideGuard(line.findings, policy, event.command, line.complete,
|
|
481
|
+
const decision = decideGuard(line.findings, policy, event.command, line.complete, guardAtFor(machine, input, runtime.env));
|
|
468
482
|
const local = policy?.version === 2 && policy.autopilot.localCommands === true;
|
|
469
483
|
const declared = value(args, "client");
|
|
470
484
|
const client = outputClient(event, detectRuntime(input, runtime.env, declared));
|
|
471
485
|
const mode = detectMode(input, runtime.env).mode;
|
|
472
486
|
const canReport = Boolean(profile) && !runtime.env.PASSPORT_AGENT_KEY && !runtime.env.PASSPORT_ENDPOINT;
|
|
473
|
-
//
|
|
474
|
-
const rewritten =
|
|
475
|
-
? await (await import("./cliHookRewrite.js")).
|
|
487
|
+
// A sign-in for a CLI whose key Passport holds (any agent), or the rewrite to exec (Claude Code).
|
|
488
|
+
const rewritten = profile
|
|
489
|
+
? await (await import("./cliHookRewrite.js")).guardEarlyAnswer({
|
|
476
490
|
command: event.command,
|
|
477
491
|
toolInput: record(input.tool_input),
|
|
478
492
|
sessionId: text(input.session_id, 128),
|
|
479
493
|
named: value(args, "profile"),
|
|
480
|
-
...{ decision, profile
|
|
494
|
+
...{ decision, profile, machine, env: runtime.env, invocation: deps.invocation, client, canReport },
|
|
495
|
+
cursorImported: Boolean(event.cursorImported),
|
|
481
496
|
attended: mode === "attended"
|
|
482
497
|
})
|
|
483
498
|
: null;
|
|
@@ -511,7 +526,7 @@ async function runGuard(args, runtime, deps) {
|
|
|
511
526
|
saveScriptCache(scripts);
|
|
512
527
|
const runtimeName = detectRuntime(input, runtime.env, declared);
|
|
513
528
|
// Coverage: count what the guard saw, once even when Cursor runs both copies.
|
|
514
|
-
await (await import("./cliHookExtras.js")).countSeen(profile, runtimeName, line
|
|
529
|
+
await (await import("./cliHookExtras.js")).countSeen(profile, runtimeName, line, clock(), () => (event.cursorImported ? cursorHasOwnEntry(runtime, "guard") : Promise.resolve(false)), sessionOfInput(input));
|
|
515
530
|
if (profile) {
|
|
516
531
|
await afterAnswer(profile, {
|
|
517
532
|
timing: { began, readAt, localAt, answeredAt: clock() },
|
|
@@ -530,7 +545,7 @@ async function runGuard(args, runtime, deps) {
|
|
|
530
545
|
// records nothing; Passport's own Cursor entry does.
|
|
531
546
|
if (!profile || !canReport)
|
|
532
547
|
return;
|
|
533
|
-
const report = await guardReport(base && plan.output ? base : null, plan, {
|
|
548
|
+
const report = await guardReport(withStep(base && plan.output ? base : null, input, policy), plan, {
|
|
534
549
|
v2: policy?.version === 2,
|
|
535
550
|
runtime,
|
|
536
551
|
now: clock()
|
|
@@ -39,6 +39,10 @@ export type CliFinding = {
|
|
|
39
39
|
cwd: string | null;
|
|
40
40
|
prefix?: Record<string, string>;
|
|
41
41
|
};
|
|
42
|
+
/** An unknown part whose class and environment Passport knows (the
|
|
43
|
+
* project's own code read only partly): Placed, not Blind, for coverage.
|
|
44
|
+
* Local only; never reported. */
|
|
45
|
+
placed?: true;
|
|
42
46
|
/** Read from the project's own script (`cliScriptRead.ts`): its name as a
|
|
43
47
|
* person knows it, "deploy.sh" or "make deploy". Reported as provenance. */
|
|
44
48
|
from?: string;
|
|
@@ -68,6 +72,16 @@ export type CliSummary = {
|
|
|
68
72
|
maxRisk: CliRisk | "none";
|
|
69
73
|
opaque: boolean;
|
|
70
74
|
};
|
|
75
|
+
/** The verb a command the vendor map doesn't know reports when it has no
|
|
76
|
+
* subcommand to name. The web app reads it as "command not recognized". */
|
|
77
|
+
export declare const UNRECOGNIZED_VERB = "unrecognized";
|
|
78
|
+
/**
|
|
79
|
+
* What to call a command the vendor map doesn't know: its subcommand, the
|
|
80
|
+
* word right after the program (`foo bar --x` is "bar"), else
|
|
81
|
+
* UNRECOGNIZED_VERB. Only lowercase letters and hyphens count as a
|
|
82
|
+
* subcommand, so a path, a value, or a secret is never reported.
|
|
83
|
+
*/
|
|
84
|
+
export declare function unknownVerb(args: readonly string[] | undefined): string;
|
|
71
85
|
/** One simple command's words, wrappers and all, through the vendor map. */
|
|
72
86
|
export declare function classifyArgv(raw: string[], viaOuter?: string[], depth?: number): CliFinding[];
|
|
73
87
|
/** Nested text: a heredoc body reaching a shell, psql, or an interpreter. */
|
package/dist/cliHookClassify.js
CHANGED
|
@@ -38,6 +38,20 @@ function finding(vendor, verb, risk, via, confidence, envInjected) {
|
|
|
38
38
|
...(envInjected.length ? { envInjected: envInjected.map((entry) => entry.split("=")[0]) } : {})
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
+
/** The verb a command the vendor map doesn't know reports when it has no
|
|
42
|
+
* subcommand to name. The web app reads it as "command not recognized". */
|
|
43
|
+
export const UNRECOGNIZED_VERB = "unrecognized";
|
|
44
|
+
const SUBCOMMAND_WORD = /^[a-z][a-z-]{0,23}$/;
|
|
45
|
+
/**
|
|
46
|
+
* What to call a command the vendor map doesn't know: its subcommand, the
|
|
47
|
+
* word right after the program (`foo bar --x` is "bar"), else
|
|
48
|
+
* UNRECOGNIZED_VERB. Only lowercase letters and hyphens count as a
|
|
49
|
+
* subcommand, so a path, a value, or a secret is never reported.
|
|
50
|
+
*/
|
|
51
|
+
export function unknownVerb(args) {
|
|
52
|
+
const first = args?.[0];
|
|
53
|
+
return first && SUBCOMMAND_WORD.test(first) ? first : UNRECOGNIZED_VERB;
|
|
54
|
+
}
|
|
41
55
|
function opaque(via, note) {
|
|
42
56
|
return { vendor: null, verb: null, risk: "unknown", confidence: "low", via, note };
|
|
43
57
|
}
|