passport-bridge 0.16.8 → 0.16.10
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 +34 -24
- package/dist/cliArgs.js +9 -2
- package/dist/cliAutopilot.d.ts +3 -40
- package/dist/cliAutopilot.js +8 -240
- package/dist/cliExec.d.ts +27 -0
- package/dist/cliExec.js +153 -38
- package/dist/cliHelp.d.ts +11 -0
- package/dist/cliHelp.js +37 -0
- package/dist/cliInit.d.ts +22 -5
- package/dist/cliInit.js +147 -107
- package/dist/cliKeys.d.ts +8 -1
- package/dist/cliKeys.js +75 -20
- package/dist/cliKeysShim.d.ts +40 -0
- package/dist/cliKeysShim.js +110 -0
- package/dist/cliLogin.d.ts +2 -14
- package/dist/cliLogin.js +197 -213
- package/dist/cliLogout.d.ts +8 -0
- package/dist/cliLogout.js +57 -0
- package/dist/cliMemberCall.d.ts +22 -0
- package/dist/cliMemberCall.js +38 -0
- package/dist/cliOutput.js +17 -12
- package/dist/cliSessions.d.ts +36 -0
- package/dist/cliSessions.js +129 -0
- package/dist/cliSetupOrg.d.ts +2 -0
- package/dist/cliSetupOrg.js +30 -9
- package/dist/cliStatus.d.ts +73 -0
- package/dist/cliStatus.js +387 -0
- package/dist/cliStatusGuard.d.ts +0 -2
- package/dist/cliStatusGuard.js +1 -18
- package/dist/cliStatusLocal.d.ts +22 -0
- package/dist/cliStatusLocal.js +18 -0
- package/dist/cliSupport.d.ts +4 -0
- package/dist/cliWait.d.ts +14 -0
- package/dist/cliWait.js +180 -0
- package/dist/completion.js +17 -6
- package/dist/execMask.d.ts +55 -0
- package/dist/execMask.js +189 -0
- package/dist/execShims.d.ts +59 -0
- package/dist/execShims.js +258 -0
- package/dist/initAppsStep.d.ts +26 -5
- package/dist/initAppsStep.js +73 -65
- package/dist/initAutopilotStep.d.ts +42 -11
- package/dist/initAutopilotStep.js +160 -86
- package/dist/initInstall.d.ts +9 -2
- package/dist/initInstall.js +31 -4
- package/dist/initKeysStep.d.ts +16 -1
- package/dist/initKeysStep.js +66 -38
- package/dist/initLocalSteps.d.ts +65 -4
- package/dist/initLocalSteps.js +273 -169
- package/dist/initOutro.d.ts +10 -0
- package/dist/initOutro.js +147 -0
- package/dist/initPlan.d.ts +39 -0
- package/dist/initPlan.js +193 -0
- package/dist/initState.d.ts +32 -0
- package/dist/initUi.d.ts +36 -9
- package/dist/initUi.js +155 -96
- package/dist/loginFlow.d.ts +71 -0
- package/dist/loginFlow.js +235 -0
- package/dist/loginIdentity.d.ts +27 -0
- package/dist/loginIdentity.js +131 -0
- package/dist/loginPending.d.ts +23 -0
- package/dist/loginPending.js +89 -0
- package/dist/passport.js +10 -134
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/releaseTooling.d.ts +7 -0
- package/dist/releaseTooling.js +29 -0
- package/dist/term.d.ts +104 -0
- package/dist/term.js +209 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/waitingLine.d.ts +38 -0
- package/dist/waitingLine.js +78 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -36,9 +36,11 @@ passport run github_search_issues '{"query":"SSO"}'
|
|
|
36
36
|
```
|
|
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
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`.
|
|
41
|
-
- `--workspace ws_example`
|
|
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
|
+
- 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/`.
|
|
42
44
|
- `--no-open` (or `PASSPORT_NO_OPEN=1`) prints the sign-in link instead of opening a browser. Use it over SSH and in headless sessions; open the link on any device.
|
|
43
45
|
- Remote servers must use HTTPS. Plain HTTP works only on `localhost`, `127.0.0.0/8`, or `::1`.
|
|
44
46
|
- Requires a gateway reporting serverInfo `passport` 0.5.0 or newer with the four-tool CLI protocol; older servers fail before any tool call.
|
|
@@ -52,7 +54,7 @@ passport run github_search_issues '{"query":"SSO"}'
|
|
|
52
54
|
| `login` | Browser sign-in or sign-up (or device sign-in with `--workspace`); saves a rotating CLI credential and makes the profile active. |
|
|
53
55
|
| `logout` | Revoke the credential and always remove the local profile (warns if revocation fails). |
|
|
54
56
|
| `profiles` / `use <name>` | List stored profiles / select the active one. Offline. |
|
|
55
|
-
| `status` |
|
|
57
|
+
| `status` | One screen: you, your workspace, and this computer; each agent's guard and its fix; Autopilot; apps; keys in Passport; this folder's environments; the CLI version. |
|
|
56
58
|
| `doctor` | Check Node, credential-file safety, HTTPS policy, `/healthz`, auth, serverInfo, and CLI protocol. Exit 1 on a failed check, with the full report. |
|
|
57
59
|
| `ready` | Readiness preflight for automation; gate on its `ready` field and exit code. |
|
|
58
60
|
| `search [query] [--app <key>]` | Search permitted tools. Empty query lists the full catalog. |
|
|
@@ -124,31 +126,32 @@ Reads agent MCP configs (Claude Desktop, Claude Code, Cursor, VS Code, Codex), C
|
|
|
124
126
|
|
|
125
127
|
```sh
|
|
126
128
|
npx passport-bridge@latest init # or: passport init
|
|
127
|
-
npx passport-bridge@latest init --
|
|
129
|
+
npx passport-bridge@latest init --dry-run # the plan only; nothing changes (so does --json without --yes)
|
|
130
|
+
npx passport-bridge@latest init --yes # the recommended setup without asking; needed without a terminal. Keys stay put
|
|
128
131
|
npx passport-bridge@latest init --yes --move-keys # also move CLI keys into Passport and sign those CLIs out
|
|
129
|
-
npx passport-bridge@latest init --yes --json # one summary object with each step's status
|
|
132
|
+
npx passport-bridge@latest init --yes --json # one summary object with each step's status and the plan
|
|
130
133
|
```
|
|
131
134
|
|
|
135
|
+
Plan, then apply. Init scans and signs in, then reads every step below without changing anything and shows one plan: **Will** (what the recommended setup changes), **Edits** (every file it edits, each backed up first), **Already set up**, **Not changed** (with how to change it later), and **You do**, then the Autopilot presets and Environments. 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
|
+
|
|
132
137
|
Eight steps, each reusing the command that owns it:
|
|
133
138
|
|
|
134
139
|
1. **Scan**: the same local scan as `passport scan`, as one summary line (`--verbose` prints the table).
|
|
135
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`.
|
|
136
|
-
3. **Apps**: Railway, Vercel, Supabase, Cloudflare, GitHub, and Stripe, when the scan found a key or its CLI is on PATH. Missing apps are added through the same catalog rules as the web (an app your workspace reviews first says `! Stripe needs approval from your admin.`), then one sign-in page covers the rest. In a terminal init waits until they connect (Enter stops waiting); without
|
|
137
|
-
4. **Keys**:
|
|
138
|
-
5. **Environments**: the environments Passport has placed for your apps,
|
|
139
|
-
6. **Agents**: Passport's one MCP URL with this workspace as its hint (`https://passportmcp.com/mcp?ws=<workspace>`), with each agent's own browser sign-in; a server that doesn't serve `/mcp` yet (read from its OAuth protected-resource metadata) gets the workspace's own URL (`https://<host>/w/<workspace>/mcp`). An existing entry at either URL for this workspace counts as set up, so no token lands in a config file. Claude Code and Codex through their own CLIs (`claude mcp add --transport http --scope user`, `codex mcp add --url`), Cursor through `~/.cursor/mcp.json`, VS Code through `code --add-mcp` or its user `mcp.json`. Claude Desktop connects through Settings → Connectors
|
|
140
|
-
7. **Guard**:
|
|
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 Railway and GitHub keys stay on this computer. Move them any time: passport keys move`. Step by step asks the same question as `passport keys move` for each: `Store your Railway account token in Passport and sign the Railway CLI out on this computer? [y/n]`. It has no default: Enter asks again (`Type y or n.`). 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 `Replace the Railway key in Passport with the one on this computer? [y/n]` (no default): yes replaces it and signs the CLI out, keeping links; no prints `Kept the key in Passport. This computer's Railway CLI stays signed in.` `--yes` never replaces a key. Quiet when there's nothing to move.
|
|
143
|
+
5. **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 · 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: Settings → Connectors → Add custom connector → paste the URL (copied)`; without one it names the URL.
|
|
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 (Codex: blocks only), pointing at the launcher `$PASSPORT_HOME/cli/bin/passport` (`passport.cmd` on Windows), which runs a stable copy of the CLI in `$PASSPORT_HOME/cli/<version>/` (never npm's cache), or at a global `passport-bridge` of the same version or newer. An upgrade rewrites the launcher and the `cli/current` link in one rename each, so hooks follow without being edited; the launcher runs the recorded node, or the node on PATH once that one is removed. A hook from an older init that names a version folder is replaced where it stands, next to your other hooks. Once the new copy is in place, older copies are deleted unless a hook still runs them.
|
|
141
146
|
8. **Autopilot**: how much agents can do on their own, per environment:
|
|
142
147
|
|
|
143
148
|
```
|
|
144
|
-
Autopilot
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
Development Hands-off everything except irreversible runs
|
|
148
|
-
Keep these? [Y/n]
|
|
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
|
|
149
152
|
```
|
|
150
153
|
|
|
151
|
-
|
|
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 Already set up without asking. The closing list says what will ask: `Autopilot on. You'll be asked only for Production changes, deletes outside Development, and irreversible actions.` A server without Autopilot gets the earlier Safety step instead.
|
|
152
155
|
|
|
153
156
|
What changes on disk, and how to undo it:
|
|
154
157
|
|
|
@@ -162,7 +165,7 @@ What changes on disk, and how to undo it:
|
|
|
162
165
|
| VS Code user `mcp.json` | `servers.passport` | `MCP: List Servers`, then remove it |
|
|
163
166
|
| `~/.claude/settings.json`, `~/.codex/hooks.json`, `~/.cursor/hooks.json` | Passport's audit and guard hooks | `passport hook uninstall --agent <agent> --apply` |
|
|
164
167
|
|
|
165
|
-
|
|
168
|
+
The plan names every file init edits before it edits any, and it keeps one copy of each original as `<file>.passport-backup`. It changes only Passport's own entries, writes atomically, refuses a malformed file with one line, and leaves an existing Passport entry alone unless it points at npm's cache or a file that's gone. Ctrl-C at any point stops cleanly; run init again to pick up where it left off. A question only takes keys typed after it appears, so an Enter pressed during a pause never answers it. Any wait longer than a moment shows what it's for in the step's row (`Sign in Checking your sign-in…`), clipped to one row so it's always replaced cleanly, and work that holds the terminal (an agent's own CLI, copying the CLI for the hooks) says so before it starts; off a terminal nothing extra prints. Everything wraps to the terminal's width, at least 40 columns. If Passport can't be reached, init says `Couldn't reach Passport at <origin>. Check your connection, then run passport init again.` and exits 1. Without a terminal, `init` needs `--yes` or `--dry-run` (exit 6 otherwise); `--json` without `--yes` is a dry run. It never edits your shell profile: it prints the one `PATH` line to add if you want `passport` everywhere.
|
|
166
169
|
|
|
167
170
|
### Company rollout
|
|
168
171
|
|
|
@@ -276,10 +279,10 @@ passport actions sync # propose this repository's .passport/actions.toml
|
|
|
276
279
|
- `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.
|
|
277
280
|
|
|
278
281
|
- `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.
|
|
279
|
-
- `wait` long-polls `GET /api/my/approvals/<id>/wait
|
|
282
|
+
- `wait` long-polls `GET /api/my/approvals/<id>/wait`, after a short first look that names who decides. On a terminal it prints the approval link at once 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>` once Passport says it's still pending. Ctrl-C exits 4 with `The request is still open. Run passport wait <id> to keep waiting.` 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`.
|
|
280
283
|
- `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.
|
|
281
284
|
- `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.
|
|
282
|
-
- `status`
|
|
285
|
+
- `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`.
|
|
283
286
|
- `actions` tells Passport what a project script does (`src/cliActions.ts`): `actions add <script> [args…] --environment <kind> --class <class>` sends the path in the repository (or `make`, `npm`, `pnpm`, `yarn` with the target), an argument glob, the repository's remote fingerprint and name, and the SHA-256 of what it runs, never its contents, to `POST /api/my/project-actions`. `--id <op_…>` resolves a Session row's **Tell Passport what this does** from this computer's scan cache. `actions sync` proposes each entry of `.passport/actions.toml`. A change, delete, or irreversible in Production applies at once; anything looser waits for an admin. The guard then decides a matching run as vendor `project` with that class and environment; it never makes a line allowed on its own, and a changed script stops matching (`projectChanged`) until it's set again. `.passport/actions.toml` entries apply locally only when they ask or block.
|
|
284
287
|
- `rules test`, `sessions`, `actions`, and `sync` need a member profile. `wait` also works for a cloud agent's key, on the approval its own `passport exec` opened.
|
|
285
288
|
|
|
@@ -290,12 +293,17 @@ passport keys move # confirm each key [y/n], store it in Passport, si
|
|
|
290
293
|
passport keys # what Passport holds, and what's still on this computer
|
|
291
294
|
passport keys add railway # store a key you paste (stdin, never echoed)
|
|
292
295
|
passport exec -- railway up -e staging
|
|
296
|
+
passport keys shim # the CLIs that run through Passport when you type them
|
|
293
297
|
```
|
|
294
298
|
|
|
299
|
+
- Shims keep a moved CLI working when you type it. After each key it moves, `keys move` asks `Keep typing railway in your terminal? Passport runs it with the key it now holds. [Y/n]` (`--yes` installs, `--no-shim` skips) and writes `~/.passport/cli/bin/railway`, which runs `passport exec -- railway "$@"` through the stable launcher. Put that folder ahead of the vendor's on PATH; when it isn't, the CLI prints the same `export PATH=…` line init prints (it never edits your shell profile). `passport keys shim <cli>` adds one, `--remove <cli|all>` takes them out, and `status --json` lists them under `shims`. `exec` never runs a shim: it finds the vendor's own CLI past Passport's folder and anything carrying the shim marker, and a shim stops after three nested calls. A shim goes by itself when Passport no longer holds that vendor's key and when the last profile signs out. POSIX only.
|
|
300
|
+
- 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.
|
|
301
|
+
- 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`.
|
|
302
|
+
|
|
295
303
|
- After a move, `keys move` remembers where each removed key was in `$PASSPORT_HOME/keys-moved.json` (vendor, `~/…` location, file, field names, size, modified time; never a value or hash). With the daily guard report, files that changed are read again; a key that's back is reported as `reappeared: [vendor]` on `POST /api/my/keys/report`, so the key reads "Back on <computer>" in Apps with the fix `passport keys move`. Kept keys are never listed. The report's computer is the CLI's own sign-in (its Device); the name it sends stays for older servers.
|
|
296
304
|
- `keys move` finds CLI sign-ins (Railway, GitHub CLI, Vercel, Wrangler API tokens, Supabase, Stripe test keys, the AWS `default` profile) and tokens in Claude Code's settings `env`. For each it asks `[y/n]` with no default (an empty answer asks again; `--yes` moves them all), stores the key in Passport (`POST /api/my/keys`), then signs that CLI out by removing only the credential: the token fields of `~/.railway/config.json` (project links stay), `token` in Vercel's `auth.json` (not revoked; the current team stays), Wrangler's sign-in keys in `default.toml`, the Supabase `access-token` file and its keychain token (saved database passwords stay), the Stripe profile's API keys and its live key in the keychain (account, color, and other profiles stay), the AWS profile's key lines, or the one settings entry. Files are written atomically with their mode kept. Vendor sign-outs don't run because they do more (`railway logout` unlinks every project, `vercel logout` revokes the token Passport just stored); only the GitHub CLI's `gh auth logout --hostname github.com` runs, adding `--user <active>` when several accounts are signed in, so other hosts and accounts stay. Keychain items are deleted by exact service and account (`security delete-generic-password` on macOS, `secret-tool clear` on Linux); where that isn't possible the row says which keychain copy may stay. Wrangler OAuth tokens are removed locally, not revoked. A sign-out that fails leaves the key in Passport and says what's left on disk. `.env` files are never touched: "Used by your app, so Passport leaves it." Browser-session sign-ins (Railway, Vercel, Wrangler OAuth) can't move; the line says how to make a token instead. A different key than the one already in Passport is replaced only when the person answers yes to `Replace the <CLI> key in Passport with the one on this computer? [y/n]`; the CLI then names the key it replaces (`replace: <keyId>` on `POST /api/my/keys`). The server alerts the owner and admins with an Undo, records it in the audit trail, and keeps the old value encrypted for seven days (`POST /api/my/keys/:id/restore` from the browser, or the alert). Without a person (`--yes`, no terminal), both keys stay. The scan report sent afterwards carries provider counts only.
|
|
297
305
|
- `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`).
|
|
298
|
-
- Asks wait for your approval in Passport (web or push) when you're at the keyboard or with `--wait <sec>`; otherwise exit 4 with the approval id: run `passport wait <id>`, then the command again. An approval is used once. Blocked or declined: exit 5. No key, or it stopped working: exit 3 ("Your Railway key in Passport stopped working. Update it in Apps."). Offline: exit 1, nothing runs, and exec never uses a key on this computer instead. A team that requires the guard refuses exec for an agent whose computer hasn't reported its guard On in 48 hours: exit 5 with `Blocked by Passport: guard required…` and the fix.
|
|
306
|
+
- 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. Run passport wait <id> to keep waiting, then run the command again.` 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 ("Your Railway key in Passport stopped working. Update it in Apps."). Offline: exit 1, nothing runs, and exec never uses a key on this computer instead. A team that requires the guard refuses exec for an agent whose computer hasn't reported its guard On in 48 hours: exit 5 with `Blocked by Passport: guard required…` and the fix.
|
|
299
307
|
- 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.
|
|
300
308
|
- 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.
|
|
301
309
|
- 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.
|
|
@@ -411,15 +419,17 @@ const actions = await client.actions(); // or client.actions(delegationId)
|
|
|
411
419
|
|
|
412
420
|
## Output contract
|
|
413
421
|
|
|
414
|
-
With `--json`, stdout is exactly one JSON value; hints and warnings go to stderr.
|
|
422
|
+
With `--json`, stdout is exactly one JSON value; hints and warnings go to stderr. JSON shapes only gain fields.
|
|
423
|
+
|
|
424
|
+
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.
|
|
415
425
|
|
|
416
426
|
| Command | JSON value |
|
|
417
427
|
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
418
|
-
| `login` | `{profile,endpoint,client,surface,active,workspaceId,workspaceName?,next}
|
|
428
|
+
| `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}` |
|
|
419
429
|
| `profiles` | `{profiles:[{name,active,client?}],active?}` |
|
|
420
430
|
| `use` | `{profile,active:true}` |
|
|
421
|
-
| `logout` | `{profile,removed,revoked}`
|
|
422
|
-
| `status` | `{workspace,member,endpoint,auth,profile?,client,mcps,autopilot?:{presets,floors,floorReason?,exceptions?,cache:{version,fetchedAt,ageMs}},next
|
|
431
|
+
| `logout` | `{profile,removed,revoked,shimsRemoved?}` |
|
|
432
|
+
| `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}]}` |
|
|
423
433
|
| `wait` | `{approvalId,status:"approved",scope?,message}`; declined, expired, and still-waiting are errors with `approvalId` |
|
|
424
434
|
| `rules` | `{command,decision,cause?,explanation?,environment?,environmentAssumed?,actionClass?,source}` |
|
|
425
435
|
| `sessions` | `{sessions:[{id,client,folder,status,startedAt,lastActivityAt,counts,environments,waiting}],nextCursor}` |
|
package/dist/cliArgs.js
CHANGED
|
@@ -54,6 +54,8 @@ const FLAGS = {
|
|
|
54
54
|
"skip-agents": { kind: "boolean", commands: ["init"] },
|
|
55
55
|
"skip-guard": { kind: "boolean", commands: ["init"] },
|
|
56
56
|
"move-keys": { kind: "boolean", commands: ["init"] },
|
|
57
|
+
"dry-run": { kind: "boolean", commands: ["init"] },
|
|
58
|
+
"ask-again": { kind: "boolean", commands: ["exec"] },
|
|
57
59
|
app: { kind: "value", commands: ["search"] },
|
|
58
60
|
args: { kind: "value", commands: ["run", "actions"] },
|
|
59
61
|
id: { kind: "value", commands: ["actions"] },
|
|
@@ -65,7 +67,12 @@ const FLAGS = {
|
|
|
65
67
|
alias: { kind: "value", commands: ["connect"] },
|
|
66
68
|
open: { kind: "boolean", commands: ["connect"] },
|
|
67
69
|
out: { kind: "value", commands: ["resources", "prompts"] },
|
|
68
|
-
verbose: { kind: "boolean", commands: ["scan", "init", "exec"] },
|
|
70
|
+
verbose: { kind: "boolean", commands: ["scan", "init", "exec", "login"] },
|
|
71
|
+
"no-masking": { kind: "boolean", commands: ["exec"] },
|
|
72
|
+
mask: { kind: "boolean", commands: ["exec"] },
|
|
73
|
+
"no-shim": { kind: "boolean", commands: ["keys"] },
|
|
74
|
+
switch: { kind: "boolean", commands: ["login"] },
|
|
75
|
+
complete: { kind: "value", commands: ["login"] },
|
|
69
76
|
path: { kind: "value", commands: ["scan"] },
|
|
70
77
|
check: { kind: "boolean", commands: ["scan"] },
|
|
71
78
|
input: { kind: "value", commands: ["access"] },
|
|
@@ -76,7 +83,7 @@ const FLAGS = {
|
|
|
76
83
|
"client-id": { kind: "value", commands: ["access"] },
|
|
77
84
|
environment: { kind: "value", commands: ["rules", "actions"] },
|
|
78
85
|
status: { kind: "value", commands: ["sessions"] },
|
|
79
|
-
remove: { kind: "boolean", commands: ["sync"] },
|
|
86
|
+
remove: { kind: "boolean", commands: ["sync", "keys"] },
|
|
80
87
|
last: { kind: "boolean", commands: ["undo"] },
|
|
81
88
|
option: { kind: "value", commands: ["undo"] }
|
|
82
89
|
};
|
package/dist/cliAutopilot.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Autopilot from the terminal:
|
|
3
3
|
*
|
|
4
|
-
* passport wait <approval-id> [--timeout <sec>] wait for a person to decide
|
|
5
4
|
* passport rules test "<command>" [--environment <kind>]
|
|
6
|
-
* passport sessions [--status running|idle|ended]
|
|
7
5
|
*
|
|
8
6
|
* plus the Autopilot lines `passport status` adds. Every command here uses the
|
|
9
7
|
* member API with a saved profile; agent keys have no person to wait for.
|
|
@@ -13,47 +11,14 @@
|
|
|
13
11
|
import { type GuardStatus } from "./cliStatusGuard.js";
|
|
14
12
|
import { type ParsedArgs } from "./cliArgs.js";
|
|
15
13
|
import { type Preset, type PresetRow } from "./cliAutopilotPolicy.js";
|
|
16
|
-
import { type MemberApi } from "./cliClient.js";
|
|
17
|
-
import { type LocalMachine } from "./cliHookLocal.js";
|
|
18
14
|
import { type EnvKind } from "./cliHookEnvironment.js";
|
|
19
|
-
import { type LinkFs } from "./envLinkFs.js";
|
|
20
15
|
export { env } from "./cliEnv.js";
|
|
21
16
|
export { actions } from "./cliActions.js";
|
|
22
17
|
import { type CommandResult, type Runtime } from "./cliSupport.js";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export type AutopilotDependencies = {
|
|
27
|
-
api?: MemberApi;
|
|
28
|
-
now?: () => number;
|
|
29
|
-
/** The machine `rules test` reads paths on; tests pass a pretend one. */
|
|
30
|
-
machine?: LocalMachine;
|
|
31
|
-
/** Where folder links are read from; tests pass a pretend one. */
|
|
32
|
-
linkFs?: LinkFs;
|
|
33
|
-
};
|
|
34
|
-
export declare function api(args: ParsedArgs, runtime: Runtime, deps: AutopilotDependencies, waitMs?: number, agentKeyOk?: boolean): MemberApi;
|
|
35
|
-
export declare function json<T>(response: Response, fallback: string): Promise<T>;
|
|
36
|
-
export declare function wait(args: ParsedArgs, runtime: Runtime, deps?: AutopilotDependencies): Promise<CommandResult>;
|
|
18
|
+
export { api, json, type AutopilotDependencies } from "./cliMemberCall.js";
|
|
19
|
+
export { wait } from "./cliWait.js";
|
|
20
|
+
import { type AutopilotDependencies } from "./cliMemberCall.js";
|
|
37
21
|
export declare function rules(args: ParsedArgs, runtime: Runtime, deps?: AutopilotDependencies): Promise<CommandResult>;
|
|
38
|
-
type SessionRow = {
|
|
39
|
-
id?: unknown;
|
|
40
|
-
client?: unknown;
|
|
41
|
-
folder?: unknown;
|
|
42
|
-
status?: unknown;
|
|
43
|
-
startedAt?: unknown;
|
|
44
|
-
lastActivityAt?: unknown;
|
|
45
|
-
counts?: {
|
|
46
|
-
ran?: unknown;
|
|
47
|
-
asked?: unknown;
|
|
48
|
-
approved?: unknown;
|
|
49
|
-
declined?: unknown;
|
|
50
|
-
blocked?: unknown;
|
|
51
|
-
};
|
|
52
|
-
environments?: unknown;
|
|
53
|
-
waiting?: unknown;
|
|
54
|
-
};
|
|
55
|
-
export declare function sessionLine(row: SessionRow, now: number, unicode?: boolean): string;
|
|
56
|
-
export declare function sessions(args: ParsedArgs, runtime: Runtime, deps?: AutopilotDependencies): Promise<CommandResult>;
|
|
57
22
|
export type AutopilotStatus = {
|
|
58
23
|
/** The three environments, and "other" (Other apps) when the server has it. */
|
|
59
24
|
presets: (Record<EnvKind, Preset> & Partial<Record<PresetRow, Preset>>) | null;
|
|
@@ -90,5 +55,3 @@ export type AutopilotStatus = {
|
|
|
90
55
|
export { localMidnight } from "./cliSpeed.js";
|
|
91
56
|
/** Read presets and floors for `passport status`. Never throws. */
|
|
92
57
|
export declare function autopilotStatus(fetchApi: (path: string, init: RequestInit) => Promise<Response>, profile: string | undefined, signal: AbortSignal, now?: number): Promise<AutopilotStatus>;
|
|
93
|
-
/** `passport status` lines; with the web origin, a link to change the rules. */
|
|
94
|
-
export declare function autopilotLines(status: AutopilotStatus, webOrigin?: string): string[];
|
package/dist/cliAutopilot.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Autopilot from the terminal:
|
|
3
3
|
*
|
|
4
|
-
* passport wait <approval-id> [--timeout <sec>] wait for a person to decide
|
|
5
4
|
* passport rules test "<command>" [--environment <kind>]
|
|
6
|
-
* passport sessions [--status running|idle|ended]
|
|
7
5
|
*
|
|
8
6
|
* plus the Autopilot lines `passport status` adds. Every command here uses the
|
|
9
7
|
* member API with a saved profile; agent keys have no person to wait for.
|
|
10
8
|
* `rules test` classifies the command on this machine and sends only the
|
|
11
9
|
* vendor and verb (and the environment kind), never the command line.
|
|
12
10
|
*/
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { OTHER_APPS,
|
|
16
|
-
import { memberApi } from "./cliClient.js";
|
|
11
|
+
import { guardStatus } from "./cliStatusGuard.js";
|
|
12
|
+
import { value } from "./cliArgs.js";
|
|
13
|
+
import { OTHER_APPS, PRESET_ROWS, rowLabel } from "./cliAutopilotPolicy.js";
|
|
17
14
|
import { classifyLine, localMachine } from "./cliHookLocal.js";
|
|
18
|
-
import { ENV_KINDS,
|
|
15
|
+
import { ENV_KINDS, isEnvKind } from "./cliHookEnvironment.js";
|
|
19
16
|
import { decideGuard, guardLabel } from "./cliHookGuard.js";
|
|
20
17
|
import { NODE_LINK_FS } from "./envLinkFs.js";
|
|
21
18
|
import { resolveTarget } from "./envResolve.js";
|
|
@@ -24,135 +21,10 @@ export { env } from "./cliEnv.js";
|
|
|
24
21
|
export { actions } from "./cliActions.js";
|
|
25
22
|
import { looseningLines } from "./cliLoosening.js";
|
|
26
23
|
import { readCliPolicy } from "./cliPolicy.js";
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export const WAIT_DEFAULT_SECONDS = 100;
|
|
32
|
-
const WAIT_POLL_SECONDS = 30;
|
|
33
|
-
const APPROVAL_ID = /^[A-Za-z0-9_-]{1,80}$/;
|
|
34
|
-
export function api(args, runtime, deps, waitMs = 0, agentKeyOk = false) {
|
|
35
|
-
if (deps.api)
|
|
36
|
-
return deps.api;
|
|
37
|
-
const auth = resolveCliAuth(args, runtime.env);
|
|
38
|
-
if (auth.kind !== "profile" && !agentKeyOk) {
|
|
39
|
-
return failure("This needs a member profile. Agent keys have no person to ask.", 6, "member_profile_required", {
|
|
40
|
-
hint: "Run: passport login"
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return memberApi({
|
|
44
|
-
auth,
|
|
45
|
-
caller: callerFrom(args, runtime.env),
|
|
46
|
-
timeoutMs: Math.max(timeoutMs(args), waitMs),
|
|
47
|
-
signal: runtime.signal
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
export async function json(response, fallback) {
|
|
51
|
-
if (response.status === 401 || response.status === 403) {
|
|
52
|
-
return failure(await safeApiError(response, "Passport refused this profile."), 2, "auth", {
|
|
53
|
-
hint: "Run: passport login"
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
if (response.status === 404) {
|
|
57
|
-
await response.body?.cancel().catch(() => undefined);
|
|
58
|
-
return failure(fallback, 1, "not_found");
|
|
59
|
-
}
|
|
60
|
-
if (!response.ok)
|
|
61
|
-
return failure(await safeApiError(response, "Passport couldn't answer."), 1, "server");
|
|
62
|
-
return readBoundedJson(response);
|
|
63
|
-
}
|
|
64
|
-
function text(raw, max = 200) {
|
|
65
|
-
if (typeof raw !== "string")
|
|
66
|
-
return undefined;
|
|
67
|
-
const cleaned = raw.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").trim();
|
|
68
|
-
return cleaned ? cleaned.slice(0, max) : undefined;
|
|
69
|
-
}
|
|
70
|
-
function waitOutcome(id, body) {
|
|
71
|
-
const status = body.status;
|
|
72
|
-
const message = text(body.message);
|
|
73
|
-
// The server names who decided: approver, approvedBy, decidedBy, or by.
|
|
74
|
-
const by = text(body.approver) ?? text(body.approvedBy) ?? text(body.decidedBy) ?? text(body.by);
|
|
75
|
-
const scope = typeof body.scope === "string" ? body.scope : undefined;
|
|
76
|
-
if (status === "allowed" || status === "approved") {
|
|
77
|
-
// "Approved by Ramish." or "Now allowed by your rules.", then the next step.
|
|
78
|
-
const lead = message ?? `Approved${by ? ` by ${by}` : ""}.`;
|
|
79
|
-
const next = /run the command again/i.test(lead) ? lead : `${lead} Run the command again.`;
|
|
80
|
-
// Once, when this approval reaches the threshold: "Tip: You've approved
|
|
81
|
-
// railway redeploy in Staging 3 times. ... Make it a rule: <link>".
|
|
82
|
-
const suggestion = text(body.suggestion, 400);
|
|
83
|
-
const human = suggestion ? `${next}\n${suggestion}` : next;
|
|
84
|
-
return {
|
|
85
|
-
json: {
|
|
86
|
-
approvalId: id,
|
|
87
|
-
status: "approved",
|
|
88
|
-
...(scope ? { scope } : {}),
|
|
89
|
-
...(by ? { decidedBy: by } : {}),
|
|
90
|
-
message: next,
|
|
91
|
-
...(suggestion ? { suggestion } : {})
|
|
92
|
-
},
|
|
93
|
-
human,
|
|
94
|
-
essential: true
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
if (status === "denied" || status === "declined") {
|
|
98
|
-
const human = message ?? `Declined${by ? ` by ${by}` : ""}.`;
|
|
99
|
-
return failure(human, 5, "approval_denied", { approvalId: id });
|
|
100
|
-
}
|
|
101
|
-
if (status === "expired") {
|
|
102
|
-
return failure(message ?? "Expired. The agent can ask again.", 5, "approval_expired", { approvalId: id });
|
|
103
|
-
}
|
|
104
|
-
if (status === "missing") {
|
|
105
|
-
return failure(`No approval request ${id}. Check the id, or ask again.`, 6, "unknown_approval", { approvalId: id });
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
export async function wait(args, runtime, deps = {}) {
|
|
110
|
-
const id = args.positionals[0];
|
|
111
|
-
if (!id || !APPROVAL_ID.test(id))
|
|
112
|
-
return failure("passport wait needs an approval id, like apr_123.", 6, "usage");
|
|
113
|
-
const totalSeconds = value(args, "timeout") ? Number(value(args, "timeout")) : WAIT_DEFAULT_SECONDS;
|
|
114
|
-
const now = deps.now ?? Date.now;
|
|
115
|
-
const deadline = now() + totalSeconds * 1000;
|
|
116
|
-
// A cloud agent waits on the approval its own `passport exec` opened; the
|
|
117
|
-
// request went to its owner.
|
|
118
|
-
const agentKey = !deps.api && Boolean(runtime.env.PASSPORT_AGENT_KEY);
|
|
119
|
-
const client = api(args, runtime, deps, (WAIT_POLL_SECONDS + 10) * 1000, true);
|
|
120
|
-
const base = agentKey ? "/api/my/exec/approvals/" : "/api/my/approvals/";
|
|
121
|
-
let announced = false;
|
|
122
|
-
for (;;) {
|
|
123
|
-
const left = Math.ceil((deadline - now()) / 1000);
|
|
124
|
-
const poll = Math.max(1, Math.min(WAIT_POLL_SECONDS, left));
|
|
125
|
-
const response = await client.fetchApi(`${base}${encodeURIComponent(id)}/wait?timeout=${poll}`, {
|
|
126
|
-
method: "GET",
|
|
127
|
-
headers: { accept: "application/json" },
|
|
128
|
-
signal: AbortSignal.any([runtime.signal, AbortSignal.timeout((poll + 10) * 1000)])
|
|
129
|
-
});
|
|
130
|
-
if (response.status === 404) {
|
|
131
|
-
// "No such approval." from a server that waits; anything else is an older server.
|
|
132
|
-
const message = await safeApiError(response, "");
|
|
133
|
-
if (/approval/i.test(message))
|
|
134
|
-
return waitOutcome(id, { status: "missing" });
|
|
135
|
-
return failure("This Passport server can't wait on approvals yet. Check Approvals on the web.", 1, "not_found");
|
|
136
|
-
}
|
|
137
|
-
const body = await json(response, "Passport couldn't find that approval.");
|
|
138
|
-
const outcome = waitOutcome(id, body);
|
|
139
|
-
if (outcome)
|
|
140
|
-
return outcome;
|
|
141
|
-
if (now() >= deadline) {
|
|
142
|
-
return failure(`Still waiting for approval. Run \`passport wait ${id}\` again, or continue with other work.`, 4, "approval_pending", {
|
|
143
|
-
approvalId: id,
|
|
144
|
-
next: [{ argv: ["passport", "wait", id], description: "Keep waiting for this approval." }]
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
if (!announced && !bool(args, "quiet") && !bool(args, "json")) {
|
|
148
|
-
runtime.stderr.write(`Waiting for a decision on ${id} (up to ${totalSeconds} seconds)...\n`);
|
|
149
|
-
announced = true;
|
|
150
|
-
}
|
|
151
|
-
// A server that answers at once instead of holding the request is polled gently.
|
|
152
|
-
if (response.headers.get("x-passport-long-poll") === "0")
|
|
153
|
-
await sleep(2_000, runtime.signal);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
24
|
+
import { failure, readBoundedJson, resolveCliAuth, timeoutMs } from "./cliSupport.js";
|
|
25
|
+
export { api, json } from "./cliMemberCall.js";
|
|
26
|
+
export { wait } from "./cliWait.js";
|
|
27
|
+
import { api, text } from "./cliMemberCall.js";
|
|
156
28
|
// ---- passport rules test ----------------------------------------------------
|
|
157
29
|
const DECISION_WORDS = { allow: "Runs", ask: "Asks first", block: "Blocked" };
|
|
158
30
|
const CLASS_WORDS = {
|
|
@@ -320,74 +192,6 @@ export async function rules(args, runtime, deps = {}) {
|
|
|
320
192
|
human: ruleTestLines(label, result, source).join("\n")
|
|
321
193
|
};
|
|
322
194
|
}
|
|
323
|
-
const CLIENT_NAMES = {
|
|
324
|
-
"claude-code": "Claude Code",
|
|
325
|
-
codex: "Codex",
|
|
326
|
-
cursor: "Cursor",
|
|
327
|
-
copilot: "Copilot",
|
|
328
|
-
cli: "Passport CLI"
|
|
329
|
-
};
|
|
330
|
-
function count(raw) {
|
|
331
|
-
return typeof raw === "number" && Number.isFinite(raw) && raw >= 0 ? Math.trunc(raw) : 0;
|
|
332
|
-
}
|
|
333
|
-
function when(ms, now) {
|
|
334
|
-
if (typeof ms !== "number")
|
|
335
|
-
return "";
|
|
336
|
-
const date = new Date(ms);
|
|
337
|
-
const sameDay = new Date(now).toDateString() === date.toDateString();
|
|
338
|
-
const time = date.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
|
|
339
|
-
return sameDay ? time : `${date.toLocaleDateString("en-US", { month: "short", day: "numeric" })} ${time}`;
|
|
340
|
-
}
|
|
341
|
-
export function sessionLine(row, now, unicode = true) {
|
|
342
|
-
const status = row.status === "running" ? "Running" : row.status === "idle" ? "Idle" : "Ended";
|
|
343
|
-
const dot = row.status === "running" ? (unicode ? "● " : "* ") : " ";
|
|
344
|
-
const client = text(row.client, 40) ?? "agent";
|
|
345
|
-
const name = CLIENT_NAMES[client] ?? client;
|
|
346
|
-
const folder = text(row.folder, 40) ?? "";
|
|
347
|
-
const counts = row.counts ?? {};
|
|
348
|
-
const parts = [`${count(counts.ran)} ran`, `${count(counts.asked)} asked`];
|
|
349
|
-
if (count(counts.blocked))
|
|
350
|
-
parts.push(`${count(counts.blocked)} blocked`);
|
|
351
|
-
const environments = Array.isArray(row.environments)
|
|
352
|
-
? row.environments.filter(isEnvKind).map((env) => ENV_LABEL[env])
|
|
353
|
-
: [];
|
|
354
|
-
const waiting = count(row.waiting) ? ` Waiting for you (${count(row.waiting)})` : "";
|
|
355
|
-
return [
|
|
356
|
-
`${dot}${status.padEnd(7)}`,
|
|
357
|
-
name.padEnd(12),
|
|
358
|
-
folder.padEnd(18),
|
|
359
|
-
`started ${when(row.startedAt, now)}`.padEnd(18),
|
|
360
|
-
parts.join(" · "),
|
|
361
|
-
environments.length ? ` ${environments.join(", ")}` : ""
|
|
362
|
-
]
|
|
363
|
-
.join(" ")
|
|
364
|
-
.trimEnd()
|
|
365
|
-
.concat(waiting);
|
|
366
|
-
}
|
|
367
|
-
export async function sessions(args, runtime, deps = {}) {
|
|
368
|
-
const status = value(args, "status");
|
|
369
|
-
if (status !== undefined && !["running", "idle", "ended"].includes(status)) {
|
|
370
|
-
return failure("--status must be running, idle, or ended.", 6, "usage");
|
|
371
|
-
}
|
|
372
|
-
const client = api(args, runtime, deps);
|
|
373
|
-
const response = await client.fetchApi(`/api/my/agent-sessions${status ? `?status=${status}` : ""}`, {
|
|
374
|
-
method: "GET",
|
|
375
|
-
headers: { accept: "application/json" },
|
|
376
|
-
signal: AbortSignal.any([runtime.signal, AbortSignal.timeout(timeoutMs(args))])
|
|
377
|
-
});
|
|
378
|
-
const page = await json(response, "This Passport server doesn't have sessions yet.");
|
|
379
|
-
const rows = (Array.isArray(page.sessions) ? page.sessions : []).slice(0, 50);
|
|
380
|
-
const now = (deps.now ?? Date.now)();
|
|
381
|
-
const human = rows.length
|
|
382
|
-
? rows
|
|
383
|
-
.map((row) => {
|
|
384
|
-
const link = sessionLink(client.origin, typeof row.id === "string" ? row.id : undefined);
|
|
385
|
-
return link ? `${sessionLine(row, now)}\n ${link}` : sessionLine(row, now);
|
|
386
|
-
})
|
|
387
|
-
.join("\n")
|
|
388
|
-
: "No sessions yet. Start your agent and its actions will show up here.";
|
|
389
|
-
return { json: { sessions: rows, nextCursor: page.nextCursor ?? null }, human };
|
|
390
|
-
}
|
|
391
195
|
function isPresetName(value) {
|
|
392
196
|
return value === "careful" || value === "balanced" || value === "handsoff";
|
|
393
197
|
}
|
|
@@ -474,39 +278,3 @@ export async function autopilotStatus(fetchApi, profile, signal, now = Date.now(
|
|
|
474
278
|
return { presets: null, floors: null, cache };
|
|
475
279
|
}
|
|
476
280
|
}
|
|
477
|
-
/** `passport status` lines; with the web origin, a link to change the rules. */
|
|
478
|
-
export function autopilotLines(status, webOrigin) {
|
|
479
|
-
const lines = [];
|
|
480
|
-
if (status.presets) {
|
|
481
|
-
const presets = status.presets;
|
|
482
|
-
const rows = PRESET_ROWS.filter((row) => presets[row]);
|
|
483
|
-
lines.push(`Autopilot: ${rows.map((row) => `${rowLabel(row)} ${PRESET_LABEL[presets[row]]}`).join(" · ")}`);
|
|
484
|
-
const floors = PRESET_ROWS.filter((row) => status.floors?.[row]).map((row) => `${rowLabel(row)} at least ${PRESET_LABEL[status.floors[row]]}`);
|
|
485
|
-
if (floors.length)
|
|
486
|
-
lines.push(`Team floors: ${floors.join(" · ")}${status.floorReason ? ` (${sanitize(status.floorReason)})` : ""}`);
|
|
487
|
-
lines.push(...(status.exceptions ?? []));
|
|
488
|
-
const rules = ruleLink(webOrigin);
|
|
489
|
-
if (rules)
|
|
490
|
-
lines.push(`Change your rules: ${rules}`);
|
|
491
|
-
}
|
|
492
|
-
const { cache } = status;
|
|
493
|
-
lines.push(cache.fetchedAt === null
|
|
494
|
-
? "Rules on this computer: not synced yet"
|
|
495
|
-
: `Rules on this computer: synced ${ageText(cache.ageMs ?? 0)}${cache.version === 1 ? " (older server: asks before destructive commands only)" : ""}`);
|
|
496
|
-
if (status.speed) {
|
|
497
|
-
lines.push(`${status.speed.line}${status.speed.source === "this-computer" ? " (this computer)" : ""}`);
|
|
498
|
-
}
|
|
499
|
-
// The guard state sits next to the speed line: both say how the guard is doing here.
|
|
500
|
-
lines.push(...guardLines(status.guard));
|
|
501
|
-
if (status.answered) {
|
|
502
|
-
const count = status.answered.today;
|
|
503
|
-
lines.push(`Answered for you: ${count.toLocaleString("en-US")} ${count === 1 ? "prompt" : "prompts"} today${status.answered.source === "this-computer" ? " on this computer" : ""}`);
|
|
504
|
-
}
|
|
505
|
-
if (status.allowlists) {
|
|
506
|
-
const synced = status.allowlists.filter((entry) => entry.entries > 0);
|
|
507
|
-
lines.push(synced.length
|
|
508
|
-
? `Agent allowlists: ${synced.map((entry) => `${entry.name} (${entry.entries})`).join(", ")}, kept in sync by passport sync`
|
|
509
|
-
: "Agent allowlists: on, nothing to add yet");
|
|
510
|
-
}
|
|
511
|
-
return lines;
|
|
512
|
-
}
|
package/dist/cliExec.d.ts
CHANGED
|
@@ -54,6 +54,12 @@ type Authorized = {
|
|
|
54
54
|
/** Phase 4: a backup was taken right before, or couldn't be (with the reason). */
|
|
55
55
|
backup?: unknown;
|
|
56
56
|
backupNote?: unknown;
|
|
57
|
+
/** A recent decline answered this command: who, the note, and when. */
|
|
58
|
+
declined?: {
|
|
59
|
+
by?: unknown;
|
|
60
|
+
note?: unknown;
|
|
61
|
+
at?: unknown;
|
|
62
|
+
};
|
|
57
63
|
};
|
|
58
64
|
export { execTarget };
|
|
59
65
|
/** The classified finding the server decides on: vendor, verb, risk, environment. */
|
|
@@ -70,6 +76,27 @@ export declare function checkedCredential(vendor: ExecVendor, raw: unknown): Rec
|
|
|
70
76
|
/** The child's environment: this shell's, minus every other credential the
|
|
71
77
|
* vendor CLI could pick up and Passport's own, plus the issued one. */
|
|
72
78
|
export declare function childEnvironment(base: NodeJS.ProcessEnv, credential: Record<string, string>): NodeJS.ProcessEnv;
|
|
79
|
+
/** Where masked output goes; the real streams unless a test captures them. */
|
|
80
|
+
export type MaskTarget = {
|
|
81
|
+
needles: readonly Buffer[];
|
|
82
|
+
stdout: Runtime["stdout"];
|
|
83
|
+
stderr: Runtime["stderr"];
|
|
84
|
+
};
|
|
85
|
+
/** Run the vendor CLI. With `mask`, its stdout and stderr are pipes read
|
|
86
|
+
* through the masker; stdin stays the terminal. The exit code is the
|
|
87
|
+
* child's, or 128 + the signal that ended it. */
|
|
88
|
+
export declare function spawnVendor(command: string, args: string[], options: SpawnOptions, mask?: MaskTarget): Promise<number>;
|
|
89
|
+
/**
|
|
90
|
+
* Masking is on when stdout isn't a terminal: an agent's shell, a pipe, a CI
|
|
91
|
+
* log, a transcript, where a printed key would be kept and read later. In a
|
|
92
|
+
* terminal the vendor CLI gets the terminal itself (colors, prompts,
|
|
93
|
+
* progress), unmasked, since a person watching their own screen is not that
|
|
94
|
+
* risk. `--mask` forces it on there; `--no-masking` (or
|
|
95
|
+
* PASSPORT_EXEC_NO_MASKING=1 through a shim) turns it off everywhere.
|
|
96
|
+
*/
|
|
97
|
+
export declare function maskingWanted(args: ParsedArgs, env: NodeJS.ProcessEnv, stdout: unknown): boolean;
|
|
98
|
+
/** Ctrl-C while waiting: the request stays open in Passport. */
|
|
99
|
+
export declare function stillOpen(approvalId: string): never;
|
|
73
100
|
/** "Passport: railway redeploy changes Production. Waiting up to 120 seconds for Ramish. Approve it on your phone or in Passport." */
|
|
74
101
|
export declare function waitingLine(message: string, seconds: number): string;
|
|
75
102
|
export declare function exec(args: ParsedArgs, runtime: Runtime, deps?: ExecDependencies): Promise<CommandResult>;
|