passport-bridge 0.28.0 → 0.29.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.
@@ -53,7 +53,9 @@ function repository(cwd, runtime, fs) {
53
53
  return {
54
54
  root,
55
55
  cwd: machine.cwd,
56
- ...(remote ? { repo: remoteFingerprint(remote), repoName: remote.split("/").pop() } : {})
56
+ ...(remote
57
+ ? { repo: remoteFingerprint(remote), repoName: remote.split("/").pop(), repoHost: remote.split("/")[0] }
58
+ : {})
57
59
  };
58
60
  }
59
61
  /** What `<script> [args…]` names, with the hash of what it runs today. */
@@ -64,7 +66,7 @@ function describeScript(words, explicitArgs, repo, fs) {
64
66
  const cwd = repo.cwd ?? repo.root;
65
67
  if (!cwd)
66
68
  return "Run this inside the project.";
67
- const ids = { ...(repo.repo ? { repo: repo.repo, repoName: repo.repoName } : {}) };
69
+ const ids = repo.repo ? { repo: repo.repo, repoName: repo.repoName, repoHost: repo.repoHost } : {};
68
70
  if (RUNNERS.has(first)) {
69
71
  // `make deploy`, `npm run deploy`: what the target or package script runs.
70
72
  const target = first === "make" ? rest.join(" ") : `run ${rest.filter((word) => word !== "run").join(" ")}`;
@@ -115,8 +117,15 @@ async function post(client, body, args, runtime) {
115
117
  body: JSON.stringify(body),
116
118
  signal: AbortSignal.any([runtime.signal, AbortSignal.timeout(timeoutMs(args))])
117
119
  });
118
- if (!response.ok)
119
- return { error: await safeApiError(response, "Passport couldn't save it."), status: response.status };
120
+ if (!response.ok) {
121
+ const error = await safeApiError(response, "Passport couldn't save it.");
122
+ // A server from before repository hosts refuses the field: send it without.
123
+ if (response.status === 400 && body.repoHost && error.includes('"repoHost"')) {
124
+ const { repoHost: _host, ...older } = body;
125
+ return post(client, older, args, runtime);
126
+ }
127
+ return { error, status: response.status };
128
+ }
120
129
  const parsed = (await readBoundedJson(response).catch(() => ({})));
121
130
  return { action: parsed.action ?? {} };
122
131
  }
@@ -125,7 +134,7 @@ function line(action, fallback) {
125
134
  const where = action.environment ? (ENV_WORD[action.environment] ?? action.environment) : "";
126
135
  const what = classWord(action.actionClass);
127
136
  return action.status === "proposed"
128
- ? `${label}: proposed (${what} in ${where}). An admin approves it in Passport Rules › Environments.`
137
+ ? `${label}: proposed (${what} in ${where}). An admin approves it on the app's page in Passport.`
129
138
  : `${label}: ${what} in ${where}. Passport checks it from now on.`;
130
139
  }
131
140
  function classified(args) {
@@ -147,6 +147,9 @@ export type AutopilotPolicy = {
147
147
  /** The workspace keeps the agent's own step descriptions (cli-policy v2
148
148
  * `descriptions`, "Show what agents say they're doing"). Off when absent. */
149
149
  reportsSteps?: boolean;
150
+ /** The server answers an attended ask with its reason line and short link
151
+ * (cli-policy v2 `asks`), so the guard asks it before the agent's prompt. */
152
+ askLines?: boolean;
150
153
  /** Production classes someone else must approve: never run here, and never
151
154
  * approved in the agent's own prompt. "Maya or Sam" names who approves. */
152
155
  secondPerson?: {
@@ -17,7 +17,7 @@ import { failure, timeoutMs } from "./cliSupport.js";
17
17
  import { appName, clientName, count, list, oneOf, record, text, time, windowOf } from "./cliSessionsJson.js";
18
18
  import { countOf } from "./plural.js";
19
19
  import { joinParts, mark, visibleLength, wrap, termOf } from "./term.js";
20
- import { hashLink } from "./webLinks.js";
20
+ import { APPS_LINK, hashLink } from "./webLinks.js";
21
21
  const DATE = /^\d{4}-\d{2}-\d{2}$/;
22
22
  const RANGES = ["1h", "6h", "24h", "7d", "30d", "today"];
23
23
  const DEFAULT_SINCE = "7d";
@@ -344,7 +344,7 @@ export async function changes(args, runtime, deps = {}) {
344
344
  return {
345
345
  json: page,
346
346
  human: renderChanges(page, term, now, since, {
347
- environments: hashLink(client.origin, "#rules?section=environments"),
347
+ environments: hashLink(client.origin, APPS_LINK),
348
348
  more: hashLink(client.origin, `#sessions${web}`)
349
349
  })
350
350
  };
@@ -87,7 +87,7 @@ export function problemFix(kind, client) {
87
87
  return {
88
88
  text: "Move it back into Passport.",
89
89
  command: "passport keys move",
90
- link: "#settings/keys",
90
+ link: "#apps",
91
91
  docs: `${DOCS_BASE}/member/cli-hook#keys-in-passport`
92
92
  };
93
93
  }
@@ -51,6 +51,8 @@ export type ServerDecision = {
51
51
  /** A pending approval: when it expires, and who decides. */
52
52
  expiresAt?: number;
53
53
  waitingFor?: string;
54
+ /** An attended ask's reason line, ending with its short link (≤ 240). */
55
+ askLine?: string;
54
56
  };
55
57
  type ApiCall = (path: string, init: RequestInit) => Promise<Response>;
56
58
  /** Validate what the server said. Anything unexpected is no answer at all. */
@@ -61,7 +63,10 @@ export declare function decideRequest(decision: GuardDecision, context: {
61
63
  toolUseId?: string;
62
64
  folder?: string;
63
65
  project?: string;
64
- }, command: string, local?: boolean): CliDecideRequest & {
66
+ }, command: string, local?: boolean,
67
+ /** Someone is at the keyboard: the agent's own prompt answers, and Passport
68
+ * only supplies its reason line (cli-policy `asks`). */
69
+ interactive?: boolean): CliDecideRequest & {
65
70
  project?: string;
66
71
  };
67
72
  /** Ask the server, or null when it couldn't answer in time. Never throws. */
@@ -60,6 +60,7 @@ export function parseServerDecision(raw) {
60
60
  const explanation = line(body.explanation, 240);
61
61
  const message = line(body.message, 400);
62
62
  const waitingFor = line(body.waitingFor, 80);
63
+ const askLine = line(body.askLine, 240);
63
64
  const expiresAt = typeof body.expiresAt === "number" && Number.isSafeInteger(body.expiresAt) && body.expiresAt > 0
64
65
  ? body.expiresAt
65
66
  : undefined;
@@ -74,7 +75,8 @@ export function parseServerDecision(raw) {
74
75
  ...(approvalId ? { approvalId } : {}),
75
76
  ...(message ? { message } : {}),
76
77
  ...(expiresAt !== undefined ? { expiresAt } : {}),
77
- ...(waitingFor ? { waitingFor } : {})
78
+ ...(waitingFor ? { waitingFor } : {}),
79
+ ...(askLine ? { askLine } : {})
78
80
  };
79
81
  }
80
82
  const VERB_TOKEN = /^-{0,2}[A-Za-z0-9][A-Za-z0-9._:+-]{0,39}$/;
@@ -86,7 +88,10 @@ function safeVerbOf(raw) {
86
88
  .slice(0, 4);
87
89
  return tokens.join(" ").slice(0, 80).trim() || UNRECOGNIZED_VERB;
88
90
  }
89
- export function decideRequest(decision, context, command, local = false) {
91
+ export function decideRequest(decision, context, command, local = false,
92
+ /** Someone is at the keyboard: the agent's own prompt answers, and Passport
93
+ * only supplies its reason line (cli-policy `asks`). */
94
+ interactive = false) {
90
95
  const findings = (decision.decided ?? [])
91
96
  .filter((entry) => entry.finding.vendor)
92
97
  // Everyday commands go only to a server that places them.
@@ -110,7 +115,7 @@ export function decideRequest(decision, context, command, local = false) {
110
115
  ...(context.folder ? { folder: context.folder } : {}),
111
116
  // The repository's name, for code that reaches its default branch.
112
117
  ...(context.project ? { project: context.project } : {}),
113
- interactive: false,
118
+ interactive,
114
119
  findings,
115
120
  ...(summary ? { commandSummary: summary } : {}),
116
121
  ...(key ? { commandKey: key } : {})
@@ -286,7 +291,7 @@ async function decidePlan(decision, policy, context) {
286
291
  // Codex can't ask from a hook: like an unattended run, the ask goes to
287
292
  // Passport as an approval request instead of a prompt nobody would see.
288
293
  if (staysLocal(context, secondPerson || irreversible))
289
- return local;
294
+ return attendedPlan(decision, policy, context, local);
290
295
  if (!context.canAsk)
291
296
  return local;
292
297
  const request = decideRequest(decision, {
@@ -323,6 +328,41 @@ async function decidePlan(decision, policy, context) {
323
328
  ? heldPlan(decision, server, request, api, context)
324
329
  : { output: serverOutput(context.client, decision, server), server, offline: false };
325
330
  }
331
+ /**
332
+ * An attended ask the agent's own prompt answers. Passport, when it answers in
333
+ * time, supplies the reason line (the ask, ending with its short link to every
334
+ * other choice) and anything it knows better: an answer already given there
335
+ * ("It’s Staging, always run", Run for this task) runs, a stop refuses. Out
336
+ * of time, or no answer: the local prompt, unchanged.
337
+ */
338
+ async function attendedPlan(decision, policy, context, local) {
339
+ // Only a server that sends ask lines (cli-policy `asks`) is asked, and only signed in.
340
+ if (policy.version !== 2 || !policy.autopilot.askLines || !context.canAsk)
341
+ return local;
342
+ const request = decideRequest(decision, {
343
+ runtime: context.report?.runtime ?? "other",
344
+ ...(context.report?.sessionId ? { sessionId: context.report.sessionId } : {}),
345
+ ...(context.report?.toolUseId ? { toolUseId: context.report.toolUseId } : {}),
346
+ ...(context.report?.cwdName ? { folder: context.report.cwdName } : {}),
347
+ ...(context.report?.project && policy.autopilot.repos ? { project: context.report.project } : {})
348
+ }, context.command, context.local === true, true);
349
+ if (!request.findings.length)
350
+ return local;
351
+ const api = await context.openApi();
352
+ const left = context.deadline - context.now();
353
+ const server = api && left > 50
354
+ ? await decideOnServer(api, request, AbortSignal.any([context.budget, AbortSignal.timeout(left)]))
355
+ : null;
356
+ if (!server || server.decision === "none")
357
+ return local;
358
+ if (server.decision === "ask" && !server.approvalId) {
359
+ const output = guardOutput(context.client, decision, server.askLine ? { askReason: server.askLine } : {});
360
+ return { output, server, offline: false, ...(api ? { api } : {}) };
361
+ }
362
+ return api
363
+ ? heldPlan(decision, server, request, api, context)
364
+ : { output: serverOutput(context.client, decision, server), server, offline: false };
365
+ }
326
366
  /**
327
367
  * The server's answer as a plan. A request a person can answer: hold for them (Claude Code and Cursor run
328
368
  * the original command when they approve in time); otherwise, or when the
@@ -133,6 +133,9 @@ export declare const CODEX_ASK_NOTE = "Codex can't ask from a hook, so Passport
133
133
  export type GuardOutputOptions = {
134
134
  /** Replaces the reason entirely: an approval request is waiting. */
135
135
  waiting?: string;
136
+ /** An ask's reason line from Passport (its short link to every other
137
+ * choice at the end), in place of the local one. */
138
+ askReason?: string;
136
139
  /** One line added to the reason, e.g. OFFLINE_NOTE. */
137
140
  note?: string;
138
141
  /** Who to ask, for a block. */
@@ -469,7 +469,7 @@ export function guardOutput(client, decision, options = {}) {
469
469
  return { permission: "allow" };
470
470
  return verdict === "deny"
471
471
  ? { permission: "deny", user_message: deny, agent_message: agentDeny }
472
- : { permission: "ask", user_message: withNote(askMessage(decision), options.note) };
472
+ : { permission: "ask", user_message: withNote(options.askReason ?? askMessage(decision), options.note) };
473
473
  }
474
474
  if (client === "codex") {
475
475
  if (verdict === "ask") {
@@ -518,7 +518,7 @@ export function guardOutput(client, decision, options = {}) {
518
518
  hookSpecificOutput: {
519
519
  hookEventName: "PreToolUse",
520
520
  permissionDecision: "ask",
521
- permissionDecisionReason: withNote(askMessage(decision), options.note)
521
+ permissionDecisionReason: withNote(options.askReason ?? askMessage(decision), options.note)
522
522
  }
523
523
  };
524
524
  }
package/dist/cliOutput.js CHANGED
@@ -144,7 +144,7 @@ function helpText(verb) {
144
144
  status: "passport status\nShows you, your workspace, and this computer; each agent's guard and its fix; Autopilot presets, team floors, and how old this computer's copy of your rules is; apps; keys Passport holds and when each was last used; this folder's environments; and the CLI version.\nJSON: {workspace,member,endpoint,auth,profile?,client,mcps:[{app,name,status,toolCount}],autopilot?:{presets,floors,cache},computer,keys?,folder,cli}",
145
145
  wait: "passport wait <approval-id> [--timeout <sec>]\nWaits for a person to decide an approval request, until they do or it expires. Agents run it as a background command. While it is still waiting, prints the approval link; on a terminal, one live line counts down. Ctrl-C stops waiting and the request stays open (exit 4).\n Approved: prints who approved it and for how long; run the command again. Exit 0.\n Declined: prints the person's note for the agent. Exit 5.\n Expired: run the command again to ask again. Exit 5.\n Still waiting at --timeout: exit 4; run it again.",
146
146
  rules: 'passport rules test "<command>" [--environment production|staging|development]\nShows what Autopilot decides for a command, why, and which environment it acts on. The command is read on this computer; only its app and verb are sent to Passport.',
147
- actions: "passport actions\npassport actions add <script> [args…] --environment production|staging|development --class read|change|delete|irreversible [--args <glob>]\npassport actions add --id <op_…> --environment <kind> --class <class>\npassport actions sync\nTells Passport what a project script does, so the guard checks it: its environment and action class. Your presets and exceptions still decide what runs; a project script never runs on its say-so alone. <script> is a file in the project, or make, npm, pnpm, or yarn with the target or script name. --args is a glob over its arguments (* is any). --id is the id a Session row shows under \"Tell Passport what this does\"; this computer resolves it, since the script's name never left it. sync proposes each entry of the project's .passport/actions.toml. You can say Production for a change, delete, or irreversible action; anything else waits for an admin in Rules › Environments › Project scripts. Sends the script's path in the repository, the repository's fingerprint and name, and a SHA-256 of what it runs, never its contents.\nJSON: {action} | {actions:[…]}",
147
+ actions: "passport actions\npassport actions add <script> [args…] --environment production|staging|development --class read|change|delete|irreversible [--args <glob>]\npassport actions add --id <op_…> --environment <kind> --class <class>\npassport actions sync\nTells Passport what a project script does, so the guard checks it: its environment and action class. Your presets and exceptions still decide what runs; a project script never runs on its say-so alone. <script> is a file in the project, or make, npm, pnpm, or yarn with the target or script name. --args is a glob over its arguments (* is any). --id is the id a Session row shows under \"Tell Passport what this does\"; this computer resolves it, since the script's name never left it. sync proposes each entry of the project's .passport/actions.toml. You can say Production for a change, delete, or irreversible action; anything else waits for an admin in the app's Project scripts in Passport. Sends the script's path in the repository, the repository's fingerprint, name, and host, and a SHA-256 of what it runs, never its contents.\nJSON: {action} | {actions:[…]}",
148
148
  // copy-style-allow double-space: help columns line up
149
149
  sync: "passport sync [--remove]\nAdds what your Autopilot rules run without asking (reads, and changes inside the project: tests, builds, formatters, git add, git commit) to each agent's own allowlist, so those prompts stop even offline and in Codex. Claude Code: permissions.allow in ~/.claude/settings.json. Codex: ~/.codex/rules/passport.rules. Cursor CLI: permissions.allow in ~/.cursor/cli-config.json; Cursor: terminalAllowlist in ~/.cursor/permissions.json when you keep one there. Deletes, installs, and Production never sync. Your own entries are never changed. Runs again on its own when your rules change.\n --remove take Passport's entries out and stop syncing\nJSON: {action,agents:[{agent,name,path,added,removed,skipped?}]}",
150
150
  // copy-style-allow double-space: help columns line up
@@ -464,6 +464,7 @@ export function serializeCliPolicyV2(policy) {
464
464
  ...(autopilot.reportsSpeed ? { speed: true } : {}),
465
465
  ...(autopilot.reportsUsage ? { usage: true } : {}),
466
466
  ...(autopilot.reportsSteps ? { descriptions: true } : {}),
467
+ ...(autopilot.askLines ? { asks: true } : {}),
467
468
  ...(autopilot.repos ? { repos: autopilot.repos } : {}),
468
469
  ...(autopilot.project
469
470
  ? {
@@ -481,7 +482,8 @@ function keptReports(body) {
481
482
  return {
482
483
  ...(body.speed === true ? { reportsSpeed: true } : {}),
483
484
  ...(body.usage === true ? { reportsUsage: true } : {}),
484
- ...(body.descriptions === true ? { reportsSteps: true } : {})
485
+ ...(body.descriptions === true ? { reportsSteps: true } : {}),
486
+ ...(body.asks === true ? { askLines: true } : {})
485
487
  };
486
488
  }
487
489
  export function parseCliPolicyV2(value) {
@@ -22,7 +22,7 @@ import { bool, value } from "./cliArgs.js";
22
22
  import { api, json } from "./cliAutopilot.js";
23
23
  import { failure, timeoutMs } from "./cliSupport.js";
24
24
  import { termOf } from "./term.js";
25
- import { hashLink } from "./webLinks.js";
25
+ import { APPS_LINK, hashLink } from "./webLinks.js";
26
26
  import { count, ID, ledgerOf, list, mergeGroups, record, sessionOf, text, windowOf, workCountsOf, workGroupOf } from "./cliSessionsJson.js";
27
27
  import { renderLedger, renderSession, renderWork } from "./cliSessionsRender.js";
28
28
  import { projectOf, renderProject } from "./cliProjectSummary.js";
@@ -134,7 +134,7 @@ export async function sessions(args, runtime, deps = {}) {
134
134
  }
135
135
  if (views[0] === "production-changes") {
136
136
  const ledger = ledgerOf(await read(client, `/api/my/production-ledger${query(filters)}`, args, runtime, "This Passport server doesn't have the Production changes ledger yet."));
137
- const link = hashLink(client.origin, "#rules?section=environments");
137
+ const link = hashLink(client.origin, APPS_LINK);
138
138
  return { json: ledger, human: renderLedger(ledger, term, now, value(args, "since"), link) };
139
139
  }
140
140
  const view = views[0] === "all" ? "all" : views[0] === "running" ? "running" : "notable";
@@ -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.28.0";
7
+ export declare const PLUGIN_PIN = "0.29.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.28.0";
7
+ export const PLUGIN_PIN = "0.29.0";
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.28.0";
1
+ export declare const VERSION = "0.29.0";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Keep in lockstep with bridge/package.json.
2
- export const VERSION = "0.28.0";
2
+ export const VERSION = "0.29.0";
@@ -5,3 +5,6 @@ export declare function approvalLink(origin: string | undefined, approvalId: str
5
5
  /** A page the server named by its hash (`#apps/railway/access`), or null. */
6
6
  export declare function hashLink(origin: string | undefined, hash: unknown): string | null;
7
7
  export declare function ruleLink(origin: string | undefined, ruleId?: string): string | null;
8
+ /** Apps: each app's page holds its environments, keys, and project scripts
9
+ * (shared/appPageLinks.ts APPS_LINK; the CLI can't import shared/). */
10
+ export declare const APPS_LINK = "#apps";
package/dist/webLinks.js CHANGED
@@ -54,3 +54,6 @@ export function ruleLink(origin, ruleId) {
54
54
  return `${base}/#rules`;
55
55
  return usable(ruleId) ? `${base}/#rules?${new URLSearchParams({ rule: ruleId }).toString()}` : null;
56
56
  }
57
+ /** Apps: each app's page holds its environments, keys, and project scripts
58
+ * (shared/appPageLinks.ts APPS_LINK; the CLI can't import shared/). */
59
+ export const APPS_LINK = "#apps";
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "passport-bridge",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "passport-bridge",
9
- "version": "0.28.0",
9
+ "version": "0.29.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.28.0",
3
+ "version": "0.29.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": {