passport-bridge 0.9.0 → 0.11.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.
Files changed (50) hide show
  1. package/README.md +174 -342
  2. package/dist/bridge.d.ts +31 -61
  3. package/dist/bridge.js +154 -313
  4. package/dist/bridgeExchange.d.ts +108 -0
  5. package/dist/bridgeExchange.js +473 -0
  6. package/dist/bridgeHeal.d.ts +61 -0
  7. package/dist/bridgeHeal.js +142 -0
  8. package/dist/bridgeLog.d.ts +2 -0
  9. package/dist/bridgeLog.js +4 -0
  10. package/dist/bridgePoller.d.ts +34 -0
  11. package/dist/bridgePoller.js +123 -0
  12. package/dist/bridgeShutdown.d.ts +37 -0
  13. package/dist/bridgeShutdown.js +77 -1
  14. package/dist/cli.js +68 -14
  15. package/dist/cliArgs.d.ts +1 -1
  16. package/dist/cliArgs.js +6 -1
  17. package/dist/cliConnect.js +6 -6
  18. package/dist/cliHook.d.ts +58 -0
  19. package/dist/cliHook.js +200 -0
  20. package/dist/cliHookClassify.d.ts +30 -0
  21. package/dist/cliHookClassify.js +354 -0
  22. package/dist/cliHookInstall.d.ts +34 -0
  23. package/dist/cliHookInstall.js +246 -0
  24. package/dist/cliHookParse.d.ts +40 -0
  25. package/dist/cliHookParse.js +325 -0
  26. package/dist/cliHookVendors.d.ts +23 -0
  27. package/dist/cliHookVendors.js +578 -0
  28. package/dist/cliOutput.js +8 -2
  29. package/dist/cliSetup.d.ts +10 -0
  30. package/dist/cliSetup.js +157 -0
  31. package/dist/cliSupport.d.ts +3 -0
  32. package/dist/completion.js +6 -2
  33. package/dist/credentialStorage.d.ts +47 -1
  34. package/dist/credentialStorage.js +231 -52
  35. package/dist/credentials.d.ts +1 -1
  36. package/dist/managedSkills.d.ts +7 -0
  37. package/dist/managedSkills.js +268 -0
  38. package/dist/managedSkillsContract.generated.d.ts +82 -0
  39. package/dist/managedSkillsContract.generated.js +32 -0
  40. package/dist/managedSkillsFiles.d.ts +23 -0
  41. package/dist/managedSkillsFiles.js +215 -0
  42. package/dist/managedSkillsIpc.d.ts +5 -0
  43. package/dist/managedSkillsIpc.js +44 -0
  44. package/dist/managedSkillsValidation.d.ts +14 -0
  45. package/dist/managedSkillsValidation.js +118 -0
  46. package/dist/passport.js +6 -2
  47. package/dist/version.d.ts +1 -1
  48. package/dist/version.js +1 -1
  49. package/npm-shrinkwrap.json +5 -5
  50. package/package.json +2 -2
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Passport CLI and bridge
2
2
 
3
- `passport-bridge` connects MCP clients to a Passport workspace without putting a long-lived token in the client configuration. The same package also installs `passport`, a polished command-line client for terminal agents, scripts, and CI.
3
+ This package installs two binaries that reach a Passport workspace through its governed gateway:
4
4
 
5
- Both binaries use the Passport gateway. Member-authenticated CLI calls share tool access, client selection, guardrails, approvals, and activity logging with native MCP clients. Non-interactive agent keys still use their assigned pass, client selection, guardrails, middleware, and audit trail, but do not raise a member's interactive approval prompt.
5
+ - `passport`: CLI for terminal agents, scripts, and CI.
6
+ - `passport-bridge`: stdio bridge for agents that launch a local MCP server, so the agent config holds no long-lived token.
7
+
8
+ Member profiles get the same tool access, agent selection, guardrails, approvals, and activity logging as native agents. Agent keys keep their pass, selection, guardrails, and audit trail but never raise a member approval prompt.
6
9
 
7
10
  ## Install
8
11
 
@@ -10,155 +13,109 @@ Both binaries use the Passport gateway. Member-authenticated CLI calls share too
10
13
  npm install --global passport-bridge
11
14
  ```
12
15
 
13
- Node.js 22.23.2 or newer is required.
14
-
15
- ## Passport CLI
16
+ Requires Node.js 22.23.2 or newer. The CLI makes no background registry request, telemetry, or self-update; check with `npm view passport-bridge version` and upgrade with `npm install --global passport-bridge@latest`.
16
17
 
17
- Sign in once, then search and run the tools your workspace permits:
18
+ ## Quick start
18
19
 
19
20
  ```sh
20
- passport login --cloud https://passport.example.com --workspace ws_example --profile cli@ws_example
21
+ passport login --workspace ws_example --profile cli@ws_example
21
22
  passport status
22
23
  passport search "open issues"
23
24
  passport describe github_search_issues
24
25
  passport run github_search_issues '{"query":"SSO"}'
25
26
  ```
26
27
 
27
- A successful login makes the new profile active. On a machine with more than
28
- one stored profile, inspect or switch the active profile without a network
29
- request:
28
+ - `--workspace` alone signs in to Passport Cloud. Self-hosted: add `--cloud https://passport.example.com` (origin only).
29
+ - `--no-open` (or `PASSPORT_NO_OPEN=1`) prints the device URL instead of opening a browser. Use it over SSH and in headless sessions.
30
+ - Remote servers must use HTTPS. Plain HTTP works only on `localhost`, `127.0.0.0/8`, or `::1`.
31
+ - Requires a gateway reporting serverInfo `passport` 0.5.0 or newer with the four-tool CLI protocol; older servers fail before any tool call.
32
+ - `passport help [command]` documents every option. `help`, `version`, `profiles`, `use`, and `completion` work offline.
33
+
34
+ ## Commands
35
+
36
+ | Command | Purpose |
37
+ | --- | --- |
38
+ | `login` | Device sign-in; saves a rotating CLI credential and makes the profile active. |
39
+ | `logout` | Revoke the credential and always remove the local profile (warns if revocation fails). |
40
+ | `profiles` / `use <name>` | List stored profiles / select the active one. Offline. |
41
+ | `status` | Workspace, member, agent, and app connection states. |
42
+ | `doctor` | Check Node, credential-file safety, HTTPS policy, `/healthz`, auth, serverInfo, and CLI protocol. Exit 1 on a failed check, with the full report. |
43
+ | `ready` | Readiness preflight for automation; gate on its `ready` field and exit code. |
44
+ | `search [query] [--app <key>]` | Search permitted tools. Empty query lists the full catalog. |
45
+ | `describe <tool>` | One exact definition with its full parameter schema. |
46
+ | `run <tool> [json]` | Run a tool through Passport governance. |
47
+ | `connect [app...] [--alias <name>] [--open] [--wait <s>]` | Show member sign-in links and optionally wait for completion. |
48
+ | `resources [uri] [--out <file>]` | List or read MCP resources. |
49
+ | `prompts [name] [--set k=v] [--out <file>]` | List or get MCP prompts. |
50
+ | `discover` | Scan local MCP configuration and submit a privacy-minimized fleet report. Exit 5 on a managed-policy violation. |
51
+ | `hook` | Audit-only shell-command recorder for agent `PostToolUse` events (`install`, `uninstall`, `status`). |
52
+ | `setup` | Install and maintain assigned team workflows as managed skills. |
53
+ | `session` | Run NDJSON commands over one authenticated MCP session. |
54
+ | `access` | Signed managed access: `keygen`, `actions`, `run`, `invoke`, `status`, `cancel`. |
55
+ | `completion <bash\|zsh\|fish>` | Print a completion script. Offline. |
56
+ | `help [command]`, `version` | Help; package version and local profile context. |
57
+
58
+ Global options: `--profile <name>`, `--json`, `--timeout <seconds>` (default 30), `--quiet`, `--caller <id>`.
30
59
 
31
- ```sh
32
- passport profiles
33
- passport use cli@ws_example
34
- passport status
35
- ```
60
+ ### Tool arguments
36
61
 
37
- For Passport Cloud, `passport login --workspace <id>` can omit `--cloud`.
38
- Self-hosted deployments pass their origin explicitly. Add `--no-open` to print
39
- the device URL without launching a browser. This is the required form for SSH,
40
- CI, and other headless sessions:
62
+ Use exactly one form:
41
63
 
42
64
  ```sh
43
- passport login --workspace ws_example --profile cli@ws_example --no-open
65
+ passport run github_search_issues '{"query":"SSO","limit":10}'
66
+ printf '%s' '{"query":"SSO"}' | passport run github_search_issues --args -
67
+ passport run github_search_issues --set query=SSO --set-json limit=10
44
68
  ```
45
69
 
46
- `passport help [command]` documents every option. `passport help` and `passport version` work without a profile or network connection.
47
-
48
- Remote Passport servers must use HTTPS. Plain HTTP is accepted only for local
49
- development on `localhost`, `127.0.0.0/8`, or `::1`. Self-hosted deployments
50
- should terminate HTTPS before using interactive profiles or agent keys.
51
-
52
- Passport CLI 0.9.0 requires gateway MCP serverInfo `passport` version 0.5.0 or
53
- newer and the exact four-tool governed CLI protocol. Older servers fail clearly
54
- before the CLI makes a tool call.
55
-
56
- ### Commands
57
-
58
- | Command | Purpose |
59
- | -------------------- | -------------------------------------------------------------------------------------------------------------------- |
60
- | `login` | Complete device sign-in and save a rotating CLI credential. |
61
- | `logout` | Revoke the credential and remove its local profile. |
62
- | `status` | Show the workspace, member, client, and visible MCP connection states. |
63
- | `doctor` | Check runtime, credential-store safety, configuration, reachability, authentication, and CLI protocol compatibility. |
64
- | `ready` | Report whether the local CLI is ready for the requested operation. |
65
- | `search [query]` | Search permitted tool definitions. An empty query lists the complete catalog. |
66
- | `describe <tool>` | Print one exact definition and its full parameter schema. JSON also exposes `name` and `inputSchema` aliases. |
67
- | `run <tool> [json]` | Run a tool through Passport governance. |
68
- | `connect [app...]` | Show secure member connection links and optionally wait for completion. |
69
- | `resources [uri]` | List or read MCP resources. |
70
- | `prompts [name]` | List or get MCP prompts. |
71
- | `discover` | Scan supported global MCP configuration and submit a privacy-minimized fleet report. |
72
- | `session` | Process NDJSON commands through one authenticated MCP session. |
73
- | `access` | Use signed managed access (`keygen`, `actions`, `run`, `invoke`, `status`, or `cancel`). |
74
- | `completion <shell>` | Generate completion for Bash, Zsh, or Fish without a profile or network. |
75
- | `profiles` | List stored profiles and show the active profile without a network request. |
76
- | `use <name>` | Select the active stored profile without a network request. |
77
- | `help [command]` | Show general or command-specific help. |
78
- | `version` | Show the package version and locally resolvable profile context. `--json` includes readiness fields. |
79
-
80
- Every command accepts `--profile <name>`, `--json`, `--timeout <seconds>`, `--quiet`, and `--caller <id>` where applicable.
81
-
82
- `passport discover` is the cross-platform, headless Passport Discover scanner.
83
- It uploads no paths, commands or arguments, environment values, headers,
84
- credentials, endpoint paths or query strings, prompts, files, tool payloads,
85
- or traffic. Managed-policy violations return exit `5`, so endpoint management
86
- can use it as a compliance gate without Passport silently editing client
87
- configuration.
88
-
89
- ### Diagnostics
90
-
91
- Run diagnostics before opening a support ticket or promoting a CLI release:
70
+ `--set` values are strings; `--set-json` takes any JSON value. Both repeat.
71
+
72
+ ### Approvals and connections
92
73
 
93
74
  ```sh
94
- passport doctor --profile cli@ws_example
95
- passport doctor --profile cli@ws_example --json
75
+ passport run github_create_issue '{"title":"Customer report"}' --wait 90
76
+ passport connect github --wait 120
96
77
  ```
97
78
 
98
- `passport version --json` works without a profile or network and returns
99
- `version`, `profileCount`, `profileSelected`, `selectionSource`, `next`, and
100
- optional endpoint/profile fields. `passport ready --json` runs the local,
101
- authentication, server, and exact CLI-protocol preflight and returns `ready`,
102
- `ok`, auth/profile context, `server`, and `checks`; use its `ready` value and
103
- exit code as the automation gate rather than parsing human output.
104
-
105
- When profile selection is unclear, start with `passport profiles` and choose
106
- one with `passport use <name>`. Use `--profile <name>` for a one-off command or
107
- `PASSPORT_PROFILE=<name>` for a shell scope; explicit selectors take precedence
108
- over the active profile.
109
-
110
- `doctor` checks Node.js, the credential file's shape/ownership/mode, auth
111
- configuration, HTTPS policy, `/healthz`, the authenticated MCP handshake,
112
- serverInfo compatibility, and the exact four-tool CLI protocol. It never prints
113
- credential values, response bodies, member identity, or all stored profile
114
- names. A failed required check returns exit 1 while still emitting the complete
115
- diagnostic report; configuration errors include a concrete fix.
116
-
117
- ### Shell completion
79
+ - An approval-required call exits 4 with its approval ID. `--wait <s>` retries only after a definite `approval_pending` response.
80
+ - The CLI never retries after a network failure or timeout, since the outcome is unknown.
81
+ - `connect` with no app names uses one aggregate link when several apps need sign-in. Agent keys get guidance but cannot create sign-in links.
118
82
 
119
- Completion is generated locally and performs no profile or network lookup:
83
+ ### Resources and prompts
120
84
 
121
85
  ```sh
122
- # Bash
123
- mkdir -p ~/.local/share/bash-completion/completions
124
- passport completion bash > ~/.local/share/bash-completion/completions/passport
125
-
126
- # Zsh (ensure ~/.zfunc is in fpath before compinit)
127
- mkdir -p ~/.zfunc
128
- passport completion zsh > ~/.zfunc/_passport
129
-
130
- # Fish
131
- mkdir -p ~/.config/fish/completions
132
- passport completion fish > ~/.config/fish/completions/passport.fish
86
+ passport resources passport+github://welcome
87
+ passport resources passport+github://image --out image.png
88
+ passport prompts github_summarize --set note=welcome
133
89
  ```
134
90
 
135
- ### Tool arguments
91
+ Human mode prints text content. Binary content needs `--out <file>` or `--json`.
136
92
 
137
- Pass a JSON object positionally:
93
+ ### Team workflows
138
94
 
139
- ```sh
140
- passport run github_search_issues '{"query":"SSO","limit":10}'
141
- ```
142
-
143
- Read the object from stdin:
95
+ Codex and Claude Code on macOS and Linux. Requires a member profile.
144
96
 
145
97
  ```sh
146
- printf '%s' '{"query":"SSO"}' | passport run github_search_issues --args -
98
+ passport setup list
99
+ passport setup install <setup-id> <workflow-key> --client codex # preview
100
+ passport setup install <setup-id> <workflow-key> --client codex --apply
101
+ passport setup installed
102
+ passport setup rollback <skill-name> --apply
103
+ passport setup remove <skill-name> --apply
147
104
  ```
148
105
 
149
- Or build it without shell JSON escaping:
106
+ Changes preview unless `--apply` is passed. Personal edits are preserved. `installed`, `remove`, and `rollback` work offline. Installing a workflow never grants app permissions or provisions accounts.
107
+
108
+ ### Shell hook
150
109
 
151
110
  ```sh
152
- passport run github_search_issues --set query=SSO --set-json limit=10
111
+ passport hook install --client claude-code --apply
112
+ passport hook status
113
+ passport hook uninstall --client claude-code --apply
153
114
  ```
154
115
 
155
- These forms are mutually exclusive. `--set` produces strings and `--set-json` accepts any valid JSON value.
156
-
157
- ### Persistent agent sessions
116
+ Bare `passport hook` reads one `PostToolUse` event on stdin, classifies the shell command locally, and records the vendor, a coarse verb, and a risk class in Activity. It never blocks and never sends the command line, output, folder path, or environment. `install` defaults to Claude Code; for Codex, add a `PostToolUse` hook that runs `passport hook` by hand. `PASSPORT_HOOK_DISABLED=1` turns it off.
158
117
 
159
- Agents performing several operations can avoid repeated process startup, token
160
- exchange, MCP initialization, and protocol checks by keeping one CLI process
161
- open:
118
+ ### Persistent sessions
162
119
 
163
120
  ```sh
164
121
  printf '%s\n' \
@@ -167,277 +124,152 @@ printf '%s\n' \
167
124
  | passport session --profile cli@ws_example
168
125
  ```
169
126
 
170
- `passport session` reads one `{"id"?:string|number,"argv":string[]}` request
171
- per line and emits one JSON response per non-empty line. Requests run
172
- sequentially. Each response contains `ok`, `exitCode`, and either `result` or
173
- the standard CLI error fields; `id` is echoed for every valid request. A request failure
174
- does not close the session. EOF or SIGINT/SIGTERM closes the MCP transport
175
- cleanly.
176
-
177
- Session input is limited to 1 MiB per line and 128 arguments. Set global
178
- `--profile`, `--caller`, and `--timeout` options on `passport session`, not in
179
- individual request `argv` values. Supported request commands are `status`,
180
- `search`, `describe`, `run`, `connect`, `resources`, `prompts`, and `discover`.
181
- The mode does not weaken authorization: every operation still executes through
182
- the governed gateway, and cached access tokens retain the normal expiry and
183
- 401-refresh behavior.
184
-
185
- ### Managed access
186
-
187
- Managed access uses a registered workload credential and a signed
188
- `private_key_jwt` client assertion. It is separate from the interactive profile
189
- commands above. Generate a key pair on the workload machine; `keygen` refuses
190
- to overwrite existing files, writes the private PEM with owner-only
191
- permissions, and writes the public JWK to a separate file:
192
-
193
- ```sh
194
- passport access keygen --algorithm ES256
195
- ```
196
-
197
- Register only the public JWK in **Agents & access**, then configure the
198
- workload with the generated workspace-prefixed client ID and the local private
199
- key path. Set the endpoint to the Passport origin, for example:
127
+ - One `{"id"?:string|number,"argv":string[]}` request per line, run in order; one JSON response per line with `ok`, `exitCode`, and `result` or error fields. `id` is echoed.
128
+ - A failed request does not close the session. EOF, SIGINT, or SIGTERM closes it cleanly.
129
+ - Limits: 1 MiB per line, 128 arguments. Set `--profile`, `--caller`, and `--timeout` on `passport session`, not per request.
130
+ - Allowed commands: `status`, `search`, `describe`, `run`, `connect`, `resources`, `prompts`, `discover`.
131
+ - Governance is unchanged; access tokens keep normal expiry and refresh.
200
132
 
201
- ```sh
202
- export PASSPORT_ENDPOINT=https://passport.example.com
203
- export PASSPORT_WORKSPACE_ID=ws_example
204
- export PASSPORT_CLIENT_ID=ws_example~awc_example
205
- export PASSPORT_PRIVATE_KEY_FILE=/run/secrets/passport-access.pem
206
- export PASSPORT_CALLER_ID=build-job-1
207
- ```
208
-
209
- The client assertion uses `iss` and `sub` equal to `PASSPORT_CLIENT_ID` and
210
- `aud` equal to `${PASSPORT_ENDPOINT}/oauth/token`. Passport returns a
211
- short-lived access token for the protected resource
212
- `${PASSPORT_ENDPOINT}/w/${PASSPORT_WORKSPACE_ID}/mcp`; the CLI and SDK do not
213
- print that token.
214
-
215
- Inspect the exact actions allowed by the credential and its grants, create a
216
- bounded run, and invoke one action:
133
+ ### Shell completion
217
134
 
218
135
  ```sh
219
- passport access actions --json
220
- passport access run --input run.json --json
221
- passport access invoke --input invocation.json --caller build-job-1 --json
222
- passport access status <invocation-id> --json
223
- passport access cancel <run-id> --json
136
+ passport completion bash > ~/.local/share/bash-completion/completions/passport
137
+ passport completion zsh > ~/.zfunc/_passport # ~/.zfunc must be in fpath before compinit
138
+ passport completion fish > ~/.config/fish/completions/passport.fish
224
139
  ```
225
140
 
226
- `run.json` contains a non-empty `capabilities` list copied from `actions`,
227
- with optional `delegationId`, `expiresInSeconds` (60 seconds to 24 hours), and
228
- `callLimit` (1 to 10,000). `invocation.json` contains `runId`, a stable unique
229
- `invocationId`, the selected `appId`, `tool`, `resource`, `connectionId`, and
230
- the tool's `args` object. Keep the same invocation file when resuming a
231
- definite approval-pending result. After a human approves it in Passport,
232
- invoke again with the same caller and exact arguments. For a timeout or
233
- unknown result, inspect `access status` before considering another write; the
234
- CLI and SDK never retry provider writes automatically.
235
-
236
- For delegated work, first run `passport access actions --delegation-id <id> --json`.
237
- Copy those capabilities into the run input and include the same `delegationId`.
238
- The agent and the delegated person both need matching allow grants.
239
-
240
- The SDK is available from either the package root or the explicit access
241
- subpath:
141
+ ## Profiles
242
142
 
243
- ```js
244
- import { accessClientFromEnv } from "passport-bridge/access";
143
+ Credentials live in `~/.passport/credentials.json` (mode `0600`, atomic updates); `PASSPORT_HOME` changes the directory. The store is shared with `passport-bridge`, and refreshes are coordinated across processes.
245
144
 
246
- const client = accessClientFromEnv(process.env, { callerId: "build-job-1" });
247
- const actions = await client.actions();
248
- ```
249
-
250
- `AccessGatewayClient` exposes `actions`, `createRun`, `invoke`, `status`, and
251
- `cancel`. Invocations require a stable caller ID; pass it in the constructor or
252
- to `invoke`. Inputs are read from bounded files by the CLI, and authentication
253
- failures are reported without response bodies or credential values.
254
- For delegated discovery, call `client.actions(delegationId)` and include that
255
- same `delegationId` when calling `createRun`.
145
+ Resolution order:
256
146
 
257
- Managed execution requires PostgreSQL and Enterprise workspace controls. Set up
258
- organization connections, grants, and delegations in **Agents & access** before
259
- the workload requests actions.
147
+ 1. `--profile <name>`
148
+ 2. `PASSPORT_PROFILE`
149
+ 3. Active profile (`passport use <name>`)
150
+ 4. Exactly one CLI-owned profile, which becomes active
151
+ 5. The sole stored profile
260
152
 
261
- ### Approvals and connections
153
+ Otherwise Passport refuses to guess: run `passport profiles`, then `passport use <name>`. Names are 1-80 letters, numbers, `.`, `_`, `@`, or `-`, starting with a letter or number.
262
154
 
263
- An approval-required `passport run` call exits immediately with code 4 and its approval ID. `--wait <seconds>` retries only after a definite structured `approval_pending` response:
155
+ A distinct agent identity for policy, selection, devices, and activity, while keeping the CLI credential surface:
264
156
 
265
157
  ```sh
266
- passport run github_create_issue '{"title":"Customer report"}' --wait 90
158
+ passport login --workspace ws_example --client claude-code --profile claude-code@ws_example
267
159
  ```
268
160
 
269
- The CLI never retries a call after a network failure or timeout because the execution outcome may be unknown.
270
-
271
- For an MCP that needs member sign-in:
161
+ ### Caller attribution
272
162
 
273
- ```sh
274
- passport connect github --wait 120
275
- ```
163
+ `--caller <id>` (1-24 lowercase letters, numbers, hyphens) adds activity detail for the agent behind a call. Without it, the CLI detects Claude Code, Codex, OpenCode, Cursor, or Gemini CLI from environment markers. Attribution is self-reported, not attested, and is accepted only from CLI-surface credentials or CLI agent-key requests.
276
164
 
277
- Without app names, `connect` uses one aggregate link when several visible MCPs need sign-in. Agent-key principals receive status and member guidance but cannot mint browser links.
278
-
279
- ### Resources and prompts
165
+ ## Headless and CI
280
166
 
281
167
  ```sh
282
- passport resources
283
- passport resources passport+github://welcome
284
- passport resources passport+github://image --out image.png
285
-
286
- passport prompts
287
- passport prompts github_summarize --set note=welcome
288
- ```
289
-
290
- Human mode writes text content to stdout. Binary or other non-text content requires `--out <file>` or `--json`.
291
-
292
- ## Output contract
293
-
294
- With `--json`, stdout contains exactly one JSON value and no progress text. Hints and warnings use stderr. The success value for each command is:
295
-
296
- | Command | JSON value |
297
- | ------------ | --------------------------------------------------------------------------------------------------------- |
298
- | `login` | `{profile, endpoint, client, surface, active, next}` |
299
- | `profiles` | `{profiles:[{name,active,client?}],active?}` |
300
- | `use` | `{profile,active:true}` |
301
- | `logout` | `{profile, removed, revoked}` |
302
- | `status` | `{workspace, member, endpoint, auth, profile?, client, mcps, next?}` |
303
- | `doctor` | `{version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}` (also emitted when checks fail). |
304
- | `ready` | `{ready,version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}` |
305
- | `search` | The gateway search payload, including `results` or `catalog` and `note`. |
306
- | `describe` | One tool definition; JSON keeps `tool`/`parameters` and adds `name`/`inputSchema` compatibility aliases. |
307
- | `run` | The complete governed MCP tool result, preserving every content block and upstream `structuredContent`. |
308
- | `connect` | The gateway connection payload, including `connections` and optional `connectAllUrl`. |
309
- | `resources` | The MCP list or read result. |
310
- | `prompts` | The MCP list or get result. |
311
- | `discover` | `{snapshot,report,compliant}`. The snapshot contains privacy-minimized metadata only. |
312
- | `session` | NDJSON envelopes: `{id?,ok,exitCode,result?}` or `{id?,ok:false,error,cause,exitCode,...}`. |
313
- | `access` | `keygen` returns algorithm, file paths, and the public JWK; `actions` returns `{actions}`; `run` returns `{run}`; `invoke` returns the governed result; `status` returns `{receipt}`; `cancel` returns `{run}`. |
314
- | `completion` | `{shell,script}`. Human mode emits the raw completion script. |
315
- | `help` | `{command, help}` |
316
- | `version` | `{version,profileCount,profileSelected,selectionSource,next,requiredInput?,endpoint?,profile?}` |
317
-
318
- JSON errors have a stable base shape and may add safe remediation fields such
319
- as `hint`, `profiles`, `next` (`argv` plus a description), `remediation`,
320
- `retry`, `requiredInput`, or `connectUrl`:
321
-
322
- ```json
323
- { "error": "...", "cause": "blocked", "exitCode": 5, "app": "github" }
168
+ export PASSPORT_ENDPOINT=https://passport.example.com/mcp
169
+ export PASSPORT_AGENT_KEY="$CI_PASSPORT_AGENT_KEY"
170
+ passport ready --json
171
+ passport search "deployment status" --json
324
172
  ```
325
173
 
326
- `approvalId` and `app` are included when supplied by the gateway.
327
-
328
- | Exit | Meaning |
329
- | ---: | ------------------------------------------------------ |
330
- | 0 | Success |
331
- | 1 | Network, timeout, server, or unsupported-content error |
332
- | 2 | Missing, expired, or revoked authentication |
333
- | 3 | The MCP needs member sign-in |
334
- | 4 | Approval is pending |
335
- | 5 | Policy, guardrail, selection, or approval denial |
336
- | 6 | Invalid usage or unknown tool/app |
337
-
338
- ## Profiles
339
-
340
- Credentials are named slots in one file, `~/.passport/credentials.json`, with mode `0600`. Set `PASSPORT_HOME` to change its directory. Profile resolution is:
341
-
342
- 1. `--profile <name>`
343
- 2. `PASSPORT_PROFILE`
344
- 3. the active profile selected by `passport use <name>`
345
- 4. the sole stored profile
346
-
347
- If several profiles exist and none is active, select one explicitly. The
348
- credential store is shared with `passport-bridge` and refresh exchanges are
349
- coordinated across processes. The active-profile pointer contains no
350
- credential and is local to this Passport credential store.
351
-
352
- When no explicit, environment, or active selector is present, CLI 0.9.0
353
- detects exactly one CLI-owned profile (`client: "cli"` or the exact legacy
354
- `cli@<workspace>` shape) and makes that existing profile active. If more than
355
- one CLI candidate remains, run `passport profiles`, choose with `passport use <name>`,
356
- or pass an explicit `--profile`; Passport refuses to guess.
174
+ Set both variables together. Environment auth overrides stored profiles, persists nothing, and cannot be combined with `--profile` or `login`/`logout`. Agent keys skip member approval prompts; use a member profile for work that must pause for a human.
357
175
 
358
- Profile names are 1-80 letters, numbers, dots, underscores, `@` signs, or hyphens, and must start with a letter or number. Credential updates are atomically replaced at mode `0600`, including when several profiles rotate concurrently.
176
+ ## Managed access
359
177
 
360
- `logout` always removes the local slot. If Passport cannot be reached to confirm server-side revocation, it prints a warning so the user knows the remote credential could not be revoked.
361
-
362
- Use a distinct policy identity for a particular agent while keeping the CLI protocol:
178
+ Workload credentials that sign `private_key_jwt` assertions. Requires PostgreSQL and Enterprise workspace controls, with connections and grants set up in **Agents & access**. Creating new delegations is retired; existing delegation IDs still work.
363
179
 
364
180
  ```sh
365
- passport login \
366
- --cloud https://passport.example.com \
367
- --workspace ws_example \
368
- --client claude-code \
369
- --profile claude-code@ws_example
181
+ passport access keygen --algorithm ES256 # or RS256; never overwrites; private PEM is owner-only
370
182
  ```
371
183
 
372
- The credential surface remains `cli`; `claude-code` is the separate client identity used for policy, selection, devices, and activity attribution.
373
-
374
- ## Caller attribution
375
-
376
- `--caller <id>` adds cooperative activity detail for the agent behind the CLI call. Values use lowercase letters, numbers, and hyphens, up to 24 characters. The CLI otherwise detects Claude Code, Codex, OpenCode, Cursor, or Gemini CLI from their environment markers.
377
-
378
- Caller attribution is self-reported, not an attested identity. The gateway only accepts it from a CLI-surface credential or a CLI agent-key request.
379
-
380
- ## Headless and CI authentication
381
-
382
- Supply an existing Passport agent key from the job's secret manager:
184
+ Register only the public JWK in **Agents & access**, then configure the workload:
383
185
 
384
186
  ```sh
385
- export PASSPORT_ENDPOINT=https://passport.example.com/mcp
386
- export PASSPORT_AGENT_KEY="$CI_PASSPORT_AGENT_KEY"
387
- passport search "deployment status" --json
388
- passport version --json
389
- passport ready --json
390
- ```
187
+ export PASSPORT_ENDPOINT=https://passport.example.com
188
+ export PASSPORT_CLIENT_ID=ws_example~awc_example
189
+ export PASSPORT_PRIVATE_KEY_FILE=/run/secrets/passport-access.pem
190
+ export PASSPORT_WORKSPACE_ID=ws_example # optional; defaults to the client ID prefix
191
+ export PASSPORT_CALLER_ID=build-job-1 # or --caller; required for invoke
391
192
 
392
- Environment authentication wins over stored profiles, persists nothing, and sends the agent key directly to the gateway. Do not combine it with `--profile`. `PASSPORT_PROFILE` is only for stored interactive credentials.
193
+ passport access actions --json
194
+ passport access run --input run.json --json
195
+ passport access invoke --input invocation.json --json
196
+ passport access status <invocation-id> --json
197
+ passport access cancel <run-id> --json
198
+ ```
393
199
 
394
- Agent keys are deliberately non-interactive. Their assigned pass, app selection,
395
- guardrails, middleware, and audit trail still apply, but action-time member
396
- approval prompts do not. Use a member profile for work that must pause for a
397
- human's one-off approval.
200
+ - `run.json`: non-empty `capabilities` copied from `actions`; optional `delegationId`, `expiresInSeconds` (60 to 86,400), `callLimit` (1 to 10,000).
201
+ - `invocation.json`: `runId`, a stable unique `invocationId`, `appId`, `tool`, `resource`, `connectionId`, and `args`.
202
+ - Approval pending: after a human approves, invoke again with the same file and caller. Timeout or unknown result: check `access status` before any new write. Provider writes are never retried automatically.
203
+ - Delegated work: `passport access actions --delegation-id <id> --json`, then include the same `delegationId` in `run.json`. The agent and the delegated person both need matching allow grants.
204
+ - Tokens are never printed.
398
205
 
399
- ## Package verification and updates
206
+ SDK, from the package root or `passport-bridge/access`:
400
207
 
401
- Maintainers can build the exact npm tarball, validate its required files, and
402
- write a SHA-256 sidecar without registry credentials:
208
+ ```js
209
+ import { accessClientFromEnv } from "passport-bridge/access";
403
210
 
404
- ```sh
405
- npm run pack:verified
406
- sha256sum -c passport-bridge-<version>.tgz.sha256
211
+ const client = accessClientFromEnv(process.env, { callerId: "build-job-1" });
212
+ const actions = await client.actions(); // or client.actions(delegationId)
407
213
  ```
408
214
 
409
- The command also reports npm's SHA-1 shasum and SHA-512 integrity value for
410
- release notes or an external artifact manifest. The package declares public
411
- access and points support/source inquiries at Passport's public release repo.
215
+ `AccessGatewayClient` exposes `actions`, `createRun`, `invoke`, `status`, and `cancel`.
412
216
 
413
- The CLI deliberately performs no background registry request, telemetry, or
414
- automatic self-update. Check explicitly with `npm view passport-bridge version`
415
- and upgrade with `npm install --global passport-bridge@latest`. Releases publish
416
- only through the repository's npm trusted-publisher workflow with short-lived
417
- OIDC credentials, exact-source gates, verified tarball integrity, and registry
418
- signature checks. npm does not expose public provenance attestations for a
419
- private source repository, so Passport does not claim one. Platform signing is
420
- not applicable to these JavaScript npm bins.
217
+ ## Output contract
421
218
 
422
- ## MCP stdio bridge
219
+ With `--json`, stdout is exactly one JSON value; hints and warnings go to stderr.
220
+
221
+ | Command | JSON value |
222
+ | --- | --- |
223
+ | `login` | `{profile,endpoint,client,surface,active,next}` |
224
+ | `profiles` | `{profiles:[{name,active,client?}],active?}` |
225
+ | `use` | `{profile,active:true}` |
226
+ | `logout` | `{profile,removed,revoked}` |
227
+ | `status` | `{workspace,member,endpoint,auth,profile?,client,mcps,next?}` |
228
+ | `doctor` | `{version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}`, also on failure |
229
+ | `ready` | `{ready,version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}` |
230
+ | `search` | Gateway payload with `results` or `catalog`, and `note` |
231
+ | `describe` | Tool definition (`tool`, `parameters`) plus `name`/`inputSchema` aliases |
232
+ | `run` | Full governed MCP tool result, including `structuredContent` |
233
+ | `connect` | Gateway payload with `connections` and optional `connectAllUrl` |
234
+ | `resources`, `prompts` | MCP list, read, or get result |
235
+ | `discover` | `{snapshot,report,compliant}` |
236
+ | `session` | NDJSON `{id?,ok,exitCode,result?}` or `{id?,ok:false,error,cause,exitCode,...}` |
237
+ | `access` | `keygen`: algorithm, paths, public JWK; `actions`: `{actions}`; `run`/`cancel`: `{run}`; `invoke`: governed result; `status`: `{receipt}` |
238
+ | `completion` | `{shell,script}` |
239
+ | `help` | `{command,help}` |
240
+ | `version` | `{version,profileCount,profileSelected,selectionSource,next,requiredInput?,endpoint?,profile?}` |
241
+
242
+ Errors: `{"error":"...","cause":"blocked","exitCode":5,"app":"github"}`, optionally with `approvalId`, `hint`, `profiles`, `next` (`argv` plus description), `remediation`, `retry`, `requiredInput`, or `connectUrl`.
243
+
244
+ | Exit | Meaning |
245
+ | ---: | --- |
246
+ | 0 | Success |
247
+ | 1 | Network, timeout, server, or unsupported-content error |
248
+ | 2 | Missing, expired, or revoked authentication |
249
+ | 3 | App needs member sign-in |
250
+ | 4 | Approval pending |
251
+ | 5 | Policy, guardrail, selection, or approval denial |
252
+ | 6 | Invalid usage or unknown tool/app |
423
253
 
424
- Create a bridge profile:
254
+ ## MCP stdio bridge
425
255
 
426
256
  ```sh
427
- passport-bridge login \
428
- --cloud https://passport.example.com \
429
- --workspace ws_example \
430
- --client cursor \
431
- --profile cursor@ws_example
257
+ passport-bridge login --cloud https://passport.example.com --workspace ws_example \
258
+ --client cursor --profile cursor@ws_example
432
259
  ```
433
260
 
434
- Configure the MCP client to launch:
261
+ Configure the agent to launch:
435
262
 
436
263
  ```sh
437
264
  passport-bridge serve --profile cursor@ws_example
438
265
  ```
439
266
 
440
- The bridge exchanges its file-backed refresh credential for short-lived access tokens, persists rotations, coordinates concurrent processes, and forwards tools, resources, prompts, cancellation, progress, and tool-list changes over stdio. `passport-bridge status` checks stored bridge profiles, and `passport-bridge logout --profile <name>` revokes one.
267
+ - `serve` is the default command. It exchanges the stored refresh credential for short-lived access tokens, persists rotations, and forwards tools, resources, prompts, cancellation, progress, and tool-list changes over stdio.
268
+ - Agents that share a profile coordinate through it. If Passport is unreachable or the saved credential is refused, `serve` stays up with one reconnect tool and recovers on its own when Passport returns or a valid credential is saved, then tells the agent its tools changed.
269
+ - `PASSPORT_REFRESH_TOKEN` plus `PASSPORT_ENDPOINT` supply a credential without a profile; rotations are not persisted.
270
+ - `passport-bridge status` checks stored profiles and reports `needs re-login` only when Passport refused the credential. `passport-bridge logout --profile <name>` revokes one. `--profile` defaults to `default`.
271
+ - `passport-bridge --help` lists all options; `--version` prints the package version.
272
+
273
+ ## Maintainers
441
274
 
442
- Run `passport-bridge --help` for the complete bridge command surface or
443
- `passport-bridge --version` to print the installed package version.
275
+ `npm run pack:verified` builds the npm tarball, checks required files, and writes a `.sha256` sidecar (verify with `sha256sum -c passport-bridge-<version>.tgz.sha256`). Releases publish only through the repository's npm trusted-publisher workflow.