passport-bridge 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -287,7 +287,7 @@ passport actions sync # propose this repository's .passport/actions.toml
287
287
  - `wait` long-polls `GET /api/my/approvals/<id>/wait` (30 s per request), after a short first look that names who decides, until a person decides or the request expires; `--timeout <s>` caps it. Agents run it as a background command and are woken when it exits. Once Passport says the request is still pending (never for one that doesn't exist or is already decided), on a terminal it prints the approval link and one live line (`Waiting for Erin · 1:32 left`); piped, `Waiting for a decision on <id> (until it expires at 14:05).` and `Open in Passport: <url>`. Ctrl-C exits 4 with `The request is still open. Keep waiting any time.` and `Run: passport wait <id>`. Approved: `Approved by Ramish (once). Run the command again.`, or `… for this session. Matching commands in this session run without asking.` (exit 0). Declined: the person's note, cleaned and labelled, `Declined by Ramish. Their note: "Use staging first"` (exit 5, cause `approval_denied`). Expired: `Expired at 14:05 with no decision. Run the command again to ask again.` (exit 5, cause `approval_expired`). Still waiting at `--timeout`: exit 4 with the same command as `next`.
288
288
  - `sessions` lists recent sessions (`GET /api/my/agent-sessions`): status, agent, folder, start, `42 ran · 2 asked · 1 blocked`, environments touched, and `Waiting for you` when approvals are pending.
289
289
  - `sync` writes the allows Passport is sure of into each agent's own permission settings, so those prompts disappear offline and in Codex (`src/nativeSync.ts`). Only reads, test runners, builds and type checks, linters that only check, `git status`, `git add`, and `git commit`, checked against the person's rules. Formatters, fixing linters, `mv`/`cp`, and package scripts stay with the hook, which sees what they touch; deletes, installs, pushes, and Production never sync. Claude Code: `Bash(npm test *)` in `permissions.allow` of `~/.claude/settings.json`. Codex: `prefix_rule(pattern = ["npm", "test"], decision = "allow")` in `~/.codex/rules/passport.rules`, a file Passport owns. Cursor CLI: `Shell(npm:test*)` in `permissions.allow` of `~/.cursor/cli-config.json`. Cursor: `npm test` in `terminalAllowlist` of `~/.cursor/permissions.json`, only when that list already exists there (defining it replaces Cursor's in-app list). Entries Passport added are listed in `$PASSPORT_HOME/native-sync.json`; an entry you had before is never claimed or removed, and a file Passport can't parse exactly (JSONC) is left alone. Sync runs on `init`, `init --org`, every rules refresh, and `passport sync`; `hook uninstall`, `sync --remove`, and signing out of the last profile take the entries out.
290
- - `status` is one screen, like `gh auth status`, with a label per row (`You` with the name you signed in as, `Computer`, `Guard`, `Autopilot`, `Apps`, `Keys`, `Shims`, `This folder`, `Allowlists`, `CLI`); under 60 columns each label gets its own row, and piped it never wraps. `Guard` lists each agent's guard (`✓ Claude Code On`, `! Codex Not trusted`) with its fix on the line under it, the coverage line, and sends the daily guard report when due. It also adds today's speed line, `Passport added 0.3 s and asked you twice today. 412 actions ran on their own.` (across your computers when the server keeps speed numbers, else `(this computer)`), and `Answered for you: N prompts today` (allows the hook gave in Claude Code and Cursor, and Codex commands Passport synced, counted only when the agent would have prompted) and which agents' allowlists are synced. Under the presets, one line per exception that lets something run your presets would ask about, in the web's words: `! 1 exception: deletes run in Production without asking, even without a backup.` Counts are appended locally (`$PASSPORT_HOME/answered/`) and sent in batches at most every five minutes as `answered: {batch, count}` on `POST /api/my/cli-activity`.
290
+ - `status` is one screen, like `gh auth status`, with a label per row (`You` with the name you signed in as, `Computer`, `Guard`, `Autopilot`, `Apps`, `Keys`, `Shims`, `This folder`, `Allowlists`, `CLI`); under 60 columns each label gets its own row, and piped it never wraps. `Guard` lists each agent's guard (`✓ Claude Code On`, `! Codex Not trusted`) with its fix on the line under it, the coverage line, and sends the daily guard report when due. It also adds today's speed line, `Passport adds ~20 ms per action and asked you twice today. 412 actions ran on their own.` (across your computers when the server keeps speed numbers, else `(this computer)`), and `Answered for you: N prompts today` (allows the hook gave in Claude Code and Cursor, and Codex commands Passport synced, counted only when the agent would have prompted) and which agents' allowlists are synced. Under the presets, one line per exception that lets something run your presets would ask about, in the web's words: `! 1 exception: deletes run in Production without asking, even without a backup.` Counts are appended locally (`$PASSPORT_HOME/answered/`) and sent in batches at most every five minutes as `answered: {batch, count}` on `POST /api/my/cli-activity`.
291
291
  - `actions` tells Passport what a project script does (`src/cliActions.ts`): `actions add <script> [args…] --environment <kind> --class <class>` sends the path in the repository (or `make`, `npm`, `pnpm`, `yarn` with the target), an argument glob, the repository's remote fingerprint and name, and the SHA-256 of what it runs, never its contents, to `POST /api/my/project-actions`. `--id <op_…>` resolves a Session row's **Tell Passport what this does** from this computer's scan cache. `actions sync` proposes each entry of `.passport/actions.toml`. A change, delete, or irreversible in Production applies at once; anything looser waits for an admin. The guard then decides a matching run as vendor `project` with that class and environment; it never makes a line allowed on its own, and a changed script stops matching (`projectChanged`) until it's set again. `.passport/actions.toml` entries apply locally only when they ask or block.
292
292
  - `rules test`, `sessions`, `actions`, and `sync` need a member profile. `wait` also works for a cloud agent's agent token, on the approval its own `passport exec` opened.
293
293
 
@@ -37,7 +37,7 @@ export type AutopilotStatus = {
37
37
  today: number;
38
38
  source: "workspace" | "this-computer";
39
39
  };
40
- /** "Passport added 0.3 s and asked you twice today. …": across your
40
+ /** "Passport adds ~20 ms per action and asked you twice today. …": across your
41
41
  * computers when Passport keeps the numbers, else this computer's own. */
42
42
  speed?: {
43
43
  line: string;
@@ -11,6 +11,7 @@
11
11
  import { guardStatus } from "./cliStatusGuard.js";
12
12
  import { value } from "./cliArgs.js";
13
13
  import { CLASS_LABEL, OTHER_APPS, causeSentence, PRESET_ROWS, rowLabel } from "./cliAutopilotPolicy.js";
14
+ import { unknownVerb } from "./cliHookClassify.js";
14
15
  import { classifyLine, localMachine } from "./cliHookLocal.js";
15
16
  import { ENV_KINDS, isEnvKind } from "./cliHookEnvironment.js";
16
17
  import { decideGuard, guardLabel } from "./cliHookGuard.js";
@@ -92,7 +93,7 @@ function localTest(command, findings, complete, policy, machine) {
92
93
  */
93
94
  function testBody(lead, label, target, environment) {
94
95
  if (lead.local) {
95
- const finding = { vendor: lead.vendor, verb: lead.verb ?? "invoke", risk: lead.risk };
96
+ const finding = { vendor: lead.vendor, verb: lead.verb ?? unknownVerb(lead.args), risk: lead.risk };
96
97
  return { finding: { ...finding, environment: environment ?? lead.local.environment } };
97
98
  }
98
99
  // Where this computer placed it: a flag, the folder's link, or a mapping.
package/dist/cliExec.js CHANGED
@@ -23,7 +23,7 @@ import { basename, dirname, join, resolve } from "node:path";
23
23
  import { bool, value } from "./cliArgs.js";
24
24
  import { memberApi } from "./cliClient.js";
25
25
  import { passportUnreachable } from "./cliOutput.js";
26
- import { classifyCommand } from "./cliHookClassify.js";
26
+ import { classifyCommand, UNRECOGNIZED_VERB } from "./cliHookClassify.js";
27
27
  import { reportedEnvironment } from "./cliHookEnvironment.js";
28
28
  import { localMachine } from "./cliHookLocal.js";
29
29
  import { NODE_LINK_FS } from "./envLinkFs.js";
@@ -75,7 +75,7 @@ export function execFinding(vendor, binary, args, policy, where) {
75
75
  const environment = reportedEnvironment(target);
76
76
  return {
77
77
  vendor,
78
- verb: verb || "invoke",
78
+ verb: verb || UNRECOGNIZED_VERB,
79
79
  risk: found?.risk ?? "unknown",
80
80
  ...(environment ? { environment } : {}),
81
81
  // Where it lands, for a server that reads it (Phase 4.5).
package/dist/cliHook.js CHANGED
@@ -15,7 +15,7 @@
15
15
  * open: the agent must never notice this hook going wrong.
16
16
  */
17
17
  import { value } from "./cliArgs.js";
18
- import { summarize } from "./cliHookClassify.js";
18
+ import { summarize, unknownVerb, UNRECOGNIZED_VERB } from "./cliHookClassify.js";
19
19
  import { classifyLine, localMachine, workingFolder, worthReporting } from "./cliHookLocal.js";
20
20
  import { projectOf } from "./cliHookProject.js";
21
21
  import { codexAskBlocked, planGuard } from "./cliHookDecide.js";
@@ -69,7 +69,7 @@ export function safeVerb(raw) {
69
69
  .split(/\s+/)
70
70
  .filter((token) => VERB_TOKEN.test(token))
71
71
  .slice(0, 4);
72
- return tokens.join(" ").slice(0, 80).trim() || "invoke";
72
+ return tokens.join(" ").slice(0, 80).trim() || UNRECOGNIZED_VERB;
73
73
  }
74
74
  function isCursorEvent(input) {
75
75
  return input.hook_event_name === "beforeShellExecution" || input.hook_event_name === "afterShellExecution";
@@ -146,7 +146,7 @@ function reportable(findings, decided = [], local = false) {
146
146
  const entry = decided.find((candidate) => candidate.finding === finding);
147
147
  return {
148
148
  vendor: finding.vendor,
149
- verb: safeVerb(finding.verbKey ?? finding.verb),
149
+ verb: safeVerb(finding.verbKey ?? finding.verb ?? unknownVerb(finding.args)),
150
150
  risk: finding.risk,
151
151
  ...(entry?.reported ? { environment: entry.reported } : {}),
152
152
  ...entry?.placement,
@@ -68,6 +68,16 @@ export type CliSummary = {
68
68
  maxRisk: CliRisk | "none";
69
69
  opaque: boolean;
70
70
  };
71
+ /** The verb a command the vendor map doesn't know reports when it has no
72
+ * subcommand to name. The web app reads it as "command not recognized". */
73
+ export declare const UNRECOGNIZED_VERB = "unrecognized";
74
+ /**
75
+ * What to call a command the vendor map doesn't know: its subcommand, the
76
+ * word right after the program (`foo bar --x` is "bar"), else
77
+ * UNRECOGNIZED_VERB. Only lowercase letters and hyphens count as a
78
+ * subcommand, so a path, a value, or a secret is never reported.
79
+ */
80
+ export declare function unknownVerb(args: readonly string[] | undefined): string;
71
81
  /** One simple command's words, wrappers and all, through the vendor map. */
72
82
  export declare function classifyArgv(raw: string[], viaOuter?: string[], depth?: number): CliFinding[];
73
83
  /** Nested text: a heredoc body reaching a shell, psql, or an interpreter. */
@@ -38,6 +38,20 @@ function finding(vendor, verb, risk, via, confidence, envInjected) {
38
38
  ...(envInjected.length ? { envInjected: envInjected.map((entry) => entry.split("=")[0]) } : {})
39
39
  };
40
40
  }
41
+ /** The verb a command the vendor map doesn't know reports when it has no
42
+ * subcommand to name. The web app reads it as "command not recognized". */
43
+ export const UNRECOGNIZED_VERB = "unrecognized";
44
+ const SUBCOMMAND_WORD = /^[a-z][a-z-]{0,23}$/;
45
+ /**
46
+ * What to call a command the vendor map doesn't know: its subcommand, the
47
+ * word right after the program (`foo bar --x` is "bar"), else
48
+ * UNRECOGNIZED_VERB. Only lowercase letters and hyphens count as a
49
+ * subcommand, so a path, a value, or a secret is never reported.
50
+ */
51
+ export function unknownVerb(args) {
52
+ const first = args?.[0];
53
+ return first && SUBCOMMAND_WORD.test(first) ? first : UNRECOGNIZED_VERB;
54
+ }
41
55
  function opaque(via, note) {
42
56
  return { vendor: null, verb: null, risk: "unknown", confidence: "low", via, note };
43
57
  }
@@ -21,6 +21,7 @@ import { isEnvKind } from "./cliHookEnvironment.js";
21
21
  import { askMessage, guardOutput, waitingMessage } from "./cliHookGuard.js";
22
22
  import { OFFLINE_CACHE_MAX_MS, OFFLINE_DEFAULT, OFFLINE_NOTES, offlineDecision } from "./cliGuardState.js";
23
23
  import { commandKey } from "./cliHookKey.js";
24
+ import { unknownVerb, UNRECOGNIZED_VERB } from "./cliHookClassify.js";
24
25
  import { redactCommand } from "./cliHookRedact.js";
25
26
  export const CLI_DECIDE_PATH = "/api/my/cli/decide";
26
27
  const MAX_RESPONSE_BYTES = 16 * 1024;
@@ -82,7 +83,7 @@ function safeVerbOf(raw) {
82
83
  .split(/\s+/)
83
84
  .filter((token) => VERB_TOKEN.test(token))
84
85
  .slice(0, 4);
85
- return tokens.join(" ").slice(0, 80).trim() || "invoke";
86
+ return tokens.join(" ").slice(0, 80).trim() || UNRECOGNIZED_VERB;
86
87
  }
87
88
  export function decideRequest(decision, context, command, local = false) {
88
89
  const findings = (decision.decided ?? [])
@@ -92,7 +93,7 @@ export function decideRequest(decision, context, command, local = false) {
92
93
  .slice(0, MAX_FINDINGS)
93
94
  .map((entry) => ({
94
95
  vendor: entry.finding.vendor,
95
- verb: safeVerbOf(entry.finding.verbKey ?? entry.finding.verb),
96
+ verb: safeVerbOf(entry.finding.verbKey ?? entry.finding.verb ?? unknownVerb(entry.finding.args)),
96
97
  risk: entry.finding.risk,
97
98
  ...(entry.reported ? { environment: entry.reported } : {}),
98
99
  ...entry.placement
@@ -78,11 +78,12 @@ export declare function settleSpeedBatch(profile: string, batch: string, now?: n
78
78
  export type SpeedToday = {
79
79
  checks: number;
80
80
  addedMs: number;
81
+ p50Ms: number;
81
82
  asked: number;
82
83
  ranOnTheirOwn: number;
83
84
  };
84
85
  export declare function summarizeToday(entries: readonly SpeedClientBatch[]): SpeedToday;
85
- /** "Passport added 0.3 s and asked you twice today. 412 actions ran on their own." */
86
+ /** "Passport adds ~20 ms per action and asked you twice today. 412 actions ran on their own." */
86
87
  export declare function speedLine(today: SpeedToday): string | null;
87
88
  /** Today on this computer, for `passport status` when Passport can't say. */
88
89
  export declare function speedToday(profile: string, now?: number): SpeedClientBatch[];
package/dist/cliSpeed.js CHANGED
@@ -222,21 +222,39 @@ export function settleSpeedBatch(profile, batch, now = Date.now()) {
222
222
  /* Sent again next time, under the same batch id. */
223
223
  }
224
224
  }
225
+ /** The bucket bound holding the median run (`percentileMs` in shared/speedContract.ts). */
226
+ function medianMs(buckets) {
227
+ const total = buckets.reduce((sum, n) => sum + n, 0);
228
+ if (!total)
229
+ return 0;
230
+ const wanted = Math.max(1, Math.ceil(total * 0.5));
231
+ let seen = 0;
232
+ for (let index = 0; index < buckets.length; index++) {
233
+ seen += buckets[index] ?? 0;
234
+ if (seen >= wanted)
235
+ return index < SPEED_BUCKETS_MS.length ? SPEED_BUCKETS_MS[index] : 5000;
236
+ }
237
+ return 5000;
238
+ }
225
239
  export function summarizeToday(entries) {
226
240
  const sum = (pick) => entries.reduce((total, entry) => total + pick(entry), 0);
241
+ const buckets = SPEED_BUCKETS_MS.map((_, index) => sum((entry) => entry.buckets[index] ?? 0));
242
+ buckets.push(sum((entry) => entry.buckets[SPEED_BUCKETS_MS.length] ?? 0));
227
243
  return {
228
244
  checks: sum((entry) => entry.count),
229
245
  addedMs: sum((entry) => entry.sumMs),
246
+ p50Ms: medianMs(buckets),
230
247
  asked: sum((entry) => entry.ask),
231
248
  ranOnTheirOwn: sum((entry) => entry.allow + entry.none)
232
249
  };
233
250
  }
234
- function seconds(ms) {
235
- if (ms < 50)
236
- return "under 0.1 s";
237
- if (ms < 60_000)
238
- return `${(ms / 1000).toFixed(1)} s`;
239
- return `${Math.round(ms / 60_000)} min`;
251
+ function perAction(p50Ms) {
252
+ const last = SPEED_BUCKETS_MS[SPEED_BUCKETS_MS.length - 1];
253
+ if (p50Ms > last)
254
+ return `over ${last / 1000} s`;
255
+ if (p50Ms >= 1000)
256
+ return `~${p50Ms / 1000} s`;
257
+ return `~${p50Ms} ms`;
240
258
  }
241
259
  function times(count) {
242
260
  if (count === 0)
@@ -247,13 +265,13 @@ function times(count) {
247
265
  return "asked you twice";
248
266
  return `asked you ${count.toLocaleString("en-US")} times`;
249
267
  }
250
- /** "Passport added 0.3 s and asked you twice today. 412 actions ran on their own." */
268
+ /** "Passport adds ~20 ms per action and asked you twice today. 412 actions ran on their own." */
251
269
  export function speedLine(today) {
252
270
  if (!today.checks)
253
271
  return null;
254
272
  const ran = today.ranOnTheirOwn;
255
273
  const own = `${ran.toLocaleString("en-US")} ${ran === 1 ? "action ran on its own" : "actions ran on their own"}.`;
256
- return `Passport added ${seconds(today.addedMs)} and ${times(today.asked)} today. ${own}`;
274
+ return `Passport adds ${perAction(today.p50Ms)} per action and ${times(today.asked)} today. ${own}`;
257
275
  }
258
276
  /** Today on this computer, for `passport status` when Passport can't say. */
259
277
  export function speedToday(profile, now = Date.now()) {
@@ -302,6 +320,7 @@ export async function todayStatus(fetchApi, profile, signal, now) {
302
320
  ? {
303
321
  checks: amount(reported.checks) ?? 0,
304
322
  addedMs: amount(reported.addedMs) ?? 0,
323
+ p50Ms: amount(reported.p50Ms) ?? 0,
305
324
  asked: amount(reported.asked) ?? 0,
306
325
  ranOnTheirOwn: amount(reported.ranOnTheirOwn) ?? 0
307
326
  }
@@ -4,4 +4,4 @@
4
4
  * the version, then runs `npm run set-version -- <version>` in the plugin repo
5
5
  * and pushes (docs/RELEASING.md). `pluginPin.test.ts` fails when it drifts.
6
6
  */
7
- export declare const PLUGIN_PIN = "0.21.0";
7
+ export declare const PLUGIN_PIN = "0.22.0";
package/dist/pluginPin.js CHANGED
@@ -4,4 +4,4 @@
4
4
  * the version, then runs `npm run set-version -- <version>` in the plugin repo
5
5
  * and pushes (docs/RELEASING.md). `pluginPin.test.ts` fails when it drifts.
6
6
  */
7
- export const PLUGIN_PIN = "0.21.0";
7
+ export const PLUGIN_PIN = "0.22.0";
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.21.0";
1
+ export declare const VERSION = "0.22.0";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Keep in lockstep with bridge/package.json.
2
- export const VERSION = "0.21.0";
2
+ export const VERSION = "0.22.0";
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "passport-bridge",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "passport-bridge",
9
- "version": "0.21.0",
9
+ "version": "0.22.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@modelcontextprotocol/sdk": "1.32.1"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passport-bridge",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Passport CLI for governed terminal and CI agents, plus the local stdio-to-cloud MCP bridge.",
5
5
  "license": "MIT",
6
6
  "repository": {