passport-bridge 0.45.0 → 0.46.1

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 (74) hide show
  1. package/dist/cliArgs.d.ts +1 -1
  2. package/dist/cliArgs.js +3 -0
  3. package/dist/cliConnect.d.ts +3 -1
  4. package/dist/cliConnect.js +58 -6
  5. package/dist/cliConnections.d.ts +3 -3
  6. package/dist/cliConnections.js +13 -5
  7. package/dist/cliExec.js +1 -5
  8. package/dist/cliGitCredential.d.ts +2 -0
  9. package/dist/cliGitCredential.js +15 -7
  10. package/dist/cliGuardHealth.js +2 -1
  11. package/dist/cliHook.js +5 -1
  12. package/dist/cliHookAfter.js +2 -2
  13. package/dist/cliHookNotices.d.ts +7 -0
  14. package/dist/cliHookNotices.js +14 -0
  15. package/dist/cliMain.js +33 -3
  16. package/dist/cliOutput.js +4 -6
  17. package/dist/cliRequest.d.ts +65 -0
  18. package/dist/cliRequest.js +135 -0
  19. package/dist/cliScan.js +1 -1
  20. package/dist/cliSession.d.ts +0 -1
  21. package/dist/cliSession.js +0 -2
  22. package/dist/cliStatus.d.ts +4 -2
  23. package/dist/cliStatus.js +21 -4
  24. package/dist/cliSupport.d.ts +0 -8
  25. package/dist/completion.js +1 -0
  26. package/dist/connectorKit/engine.generated.d.ts +2 -2
  27. package/dist/connectorKit/engine.generated.js +23 -3
  28. package/dist/connectorKit/manifest.generated.d.ts +1 -1
  29. package/dist/connectorKit/manifests/github.generated.js +26 -3
  30. package/dist/connectorKit/manifests/githubCapture.generated.js +41 -10
  31. package/dist/connectorKit/manifests/githubHooks.generated.js +21 -1
  32. package/dist/connectorKit/manifests/githubReads.generated.d.ts +2 -0
  33. package/dist/connectorKit/manifests/githubReads.generated.js +30 -5
  34. package/dist/connectorKit/manifests/railway.generated.js +3 -3
  35. package/dist/connectorKit/manifests/supabase.generated.js +1 -1
  36. package/dist/connectorKit/manifests/supabaseCatalog.generated.js +3 -3
  37. package/dist/controlPlane.generated.d.ts +19 -18
  38. package/dist/controlPlane.generated.js +12 -17
  39. package/dist/controlPlaneGithub.generated.d.ts +2 -2
  40. package/dist/controlPlaneGithub.generated.js +12 -2
  41. package/dist/controlPlaneGithubApi.generated.d.ts +2 -0
  42. package/dist/controlPlaneGithubApi.generated.js +56 -1
  43. package/dist/controlPlaneGithubCatalog.generated.d.ts +9 -3
  44. package/dist/controlPlaneGithubCatalog.generated.js +19 -13
  45. package/dist/controlPlaneGithubCli.generated.d.ts +2 -0
  46. package/dist/controlPlaneGithubCli.generated.js +65 -12
  47. package/dist/controlPlaneGuard.js +2 -0
  48. package/dist/controlPlanePeople.generated.d.ts +117 -0
  49. package/dist/controlPlanePeople.generated.js +6 -0
  50. package/dist/controlPlaneRoutes.generated.d.ts +63 -0
  51. package/dist/controlPlaneRoutes.generated.js +111 -0
  52. package/dist/controlPlaneSupabase.js +3 -1
  53. package/dist/controlPlaneUnnamed.generated.d.ts +58 -0
  54. package/dist/controlPlaneUnnamed.generated.js +225 -0
  55. package/dist/cpCli.js +5 -1
  56. package/dist/gitCredentialRetire.d.ts +25 -0
  57. package/dist/gitCredentialRetire.js +143 -0
  58. package/dist/initAppsStep.d.ts +1 -1
  59. package/dist/initAppsStep.js +7 -5
  60. package/dist/initOutro.js +13 -10
  61. package/dist/initState.d.ts +3 -2
  62. package/dist/initState.js +7 -18
  63. package/dist/localNotices.d.ts +22 -0
  64. package/dist/localNotices.js +100 -0
  65. package/dist/pluginPin.d.ts +1 -1
  66. package/dist/pluginPin.js +1 -1
  67. package/dist/version.d.ts +1 -1
  68. package/dist/version.js +1 -1
  69. package/dist/webLinks.d.ts +23 -6
  70. package/dist/webLinks.js +21 -22
  71. package/npm-shrinkwrap.json +8 -8
  72. package/package.json +1 -1
  73. package/dist/cliApprovalLink.d.ts +0 -5
  74. package/dist/cliApprovalLink.js +0 -21
package/dist/cliArgs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const COMMANDS: readonly ["init", "login", "logout", "profiles", "use", "status", "doctor", "ready", "search", "describe", "run", "connect", "connections", "resources", "prompts", "discover", "scan", "hook", "exec", "kube-credential", "git-credential", "keys", "setup", "session", "access", "update", "completion", "help", "version"];
1
+ export declare const COMMANDS: readonly ["init", "login", "logout", "profiles", "use", "status", "doctor", "ready", "search", "describe", "run", "connect", "connections", "request", "resources", "prompts", "discover", "scan", "hook", "exec", "kube-credential", "git-credential", "keys", "setup", "session", "access", "update", "completion", "help", "version"];
2
2
  export type Command = (typeof COMMANDS)[number];
3
3
  /** Old names that still run for one release, left out of help, completion,
4
4
  * and suggestions. `discover` is part of `scan` now; `setup --org` is
package/dist/cliArgs.js CHANGED
@@ -13,6 +13,7 @@ export const COMMANDS = [
13
13
  "run",
14
14
  "connect",
15
15
  "connections",
16
+ "request",
16
17
  "resources",
17
18
  "prompts",
18
19
  "discover",
@@ -72,6 +73,8 @@ const FLAGS = {
72
73
  session: { kind: "value", commands: ["exec"] },
73
74
  alias: { kind: "value", commands: ["connect"] },
74
75
  open: { kind: "boolean", commands: ["connect"] },
76
+ reason: { kind: "value", commands: ["request"] },
77
+ cancel: { kind: "boolean", commands: ["request"] },
75
78
  out: { kind: "value", commands: ["resources", "prompts"] },
76
79
  verbose: { kind: "boolean", commands: ["scan", "init", "exec", "login", "hook"] },
77
80
  "no-masking": { kind: "boolean", commands: ["exec"] },
@@ -7,9 +7,11 @@ export type ManagePayload = {
7
7
  id: string;
8
8
  name: string;
9
9
  };
10
+ /** Newer servers send the name and never the email; older ones send the email. */
10
11
  member: {
11
12
  id: string;
12
- email: string;
13
+ name?: string;
14
+ email?: string;
13
15
  };
14
16
  client: string;
15
17
  surface: string;
@@ -1,8 +1,9 @@
1
1
  import { bool, value } from "./cliArgs.js";
2
2
  import { SERVER_TOO_OLD } from "./cliProtocol.js";
3
3
  import { firstText, payloadOf, requireSuccess } from "./cliResult.js";
4
- import { failure, openUrl, sleep } from "./cliSupport.js";
4
+ import { failure, openUrl, readBoundedJson, sleep } from "./cliSupport.js";
5
5
  import { countOf } from "./plural.js";
6
+ import { CONNECT_LINK_LIFETIME } from "./webLinks.js";
6
7
  export function managePayload(result) {
7
8
  requireSuccess(result);
8
9
  const payload = payloadOf(result, "connection");
@@ -18,6 +19,46 @@ export function managePayload(result) {
18
19
  }
19
20
  return payload;
20
21
  }
22
+ /** The app a refusal says isn't offered to this person ("\"jira\" isn't offered to you at Northwind."). */
23
+ function notOfferedApp(error) {
24
+ if (!(error instanceof Error))
25
+ return undefined;
26
+ return /^"([^"]{1,64})" isn't offered to you at /.exec(error.message)?.[1];
27
+ }
28
+ /** "Jira isn't offered to you at Northwind." and how to ask, or that they already did (docs/design/v21/requests.md). */
29
+ async function notOffered(app, message, auth, runtime) {
30
+ const workspace = /isn't offered to you at (.+?)\. Ask for it/.exec(message)?.[1] ?? "your company";
31
+ const name = app.charAt(0).toUpperCase() + app.slice(1);
32
+ let waiting;
33
+ if (auth.kind === "profile") {
34
+ try {
35
+ const { memberApi } = await import("./cliClient.js");
36
+ const response = await memberApi({ auth, timeoutMs: 5_000, signal: runtime.signal }).fetchApi("/api/my/app-requests", {
37
+ headers: { accept: "application/json" },
38
+ signal: runtime.signal
39
+ });
40
+ if (response.ok) {
41
+ const body = await readBoundedJson(response);
42
+ waiting = body.requests?.find((row) => row.status === "pending" && row.app.key === app.toLowerCase());
43
+ }
44
+ else
45
+ await response.body?.cancel().catch(() => undefined);
46
+ }
47
+ catch {
48
+ /* Without the list, it says how to ask. */
49
+ }
50
+ }
51
+ if (waiting) {
52
+ const { shortDate } = await import("./cliRequest.js");
53
+ const who = waiting.statusLine.replace(/^Waiting for /, "");
54
+ return failure(`${name} isn't offered to you at ${workspace} yet. You asked on ${shortDate(waiting.askedAt)}; ${who} decides.`, 6, "not_offered", { app });
55
+ }
56
+ return failure(`${name} isn't offered to you at ${workspace}.`, 6, "not_offered", {
57
+ app,
58
+ hint: `Ask for it: passport request ${app} --reason "…"`,
59
+ next: [{ argv: ["passport", "request", app, "--reason", "<what it's for>"], description: "Ask for the app." }]
60
+ });
61
+ }
21
62
  function assertConnectionCanStart(auth, needSignin, urls, human, shouldOpen, shouldAct) {
22
63
  if (auth.kind === "agent-key" && needSignin.length && shouldAct) {
23
64
  return failure("Agent-token authentication cannot create a person's sign-in link.", 3, "member_profile_required", {
@@ -46,10 +87,19 @@ export async function connect(args, runtime, withGateway) {
46
87
  return failure("--alias must contain 1-32 letters, numbers, spaces, or hyphens.", 6, "usage");
47
88
  const requested = args.positionals;
48
89
  return withGateway(args, runtime, async (gateway, auth) => {
49
- let managed = managePayload(await gateway.callTool("passport_manage_connections", {
50
- ...(alias !== undefined ? { alias: alias.trim() } : {}),
51
- ...(requested.length ? { apps: requested } : {})
52
- }));
90
+ let managed;
91
+ try {
92
+ managed = managePayload(await gateway.callTool("passport_manage_connections", {
93
+ ...(alias !== undefined ? { alias: alias.trim() } : {}),
94
+ ...(requested.length ? { apps: requested } : {})
95
+ }));
96
+ }
97
+ catch (error) {
98
+ const app = notOfferedApp(error);
99
+ if (app)
100
+ return notOffered(app, error instanceof Error ? error.message : "", auth, runtime);
101
+ throw error;
102
+ }
53
103
  const rows = requested.length
54
104
  ? requested.map((app) => findConnection(managed.connections, app))
55
105
  : managed.connections;
@@ -119,7 +169,7 @@ function connectionUrls(managed, rows, explicitlyNamed) {
119
169
  function connectionLines(managed, rows, explicitlyNamed) {
120
170
  const urls = connectionUrls(managed, rows, explicitlyNamed);
121
171
  if (!explicitlyNamed && urls.length === 1 && rows.filter((row) => row.status === "needs_your_signin").length >= 2) {
122
- return ["Sign in to your apps on one page:", ` ${urls[0]}`];
172
+ return ["Sign in to your apps on one page:", ` ${urls[0]}`, CONNECT_LINK_LIFETIME];
123
173
  }
124
174
  const lines = [];
125
175
  for (const row of rows) {
@@ -135,6 +185,8 @@ function connectionLines(managed, rows, explicitlyNamed) {
135
185
  }
136
186
  if (!lines.length || (!explicitlyNamed && !rows.some((row) => row.status === "needs_your_signin")))
137
187
  lines.push(managed.note || "Nothing needs connecting.");
188
+ else if (urls.length)
189
+ lines.push(CONNECT_LINK_LIFETIME);
138
190
  return lines;
139
191
  }
140
192
  async function waitForConnections(gateway, apps, seconds, signal) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * `passport connections [app] [--no-open]`: the developer's own connections, in the terminal and
3
3
  * in the browser. It prints what's connected for this person and what still needs them, then opens
4
- * their connections page with a link that lasts ten minutes (`POST /api/my/connections-link`). The
4
+ * their connections page with a link that lasts fifteen minutes (`POST /api/my/connections-link`). The
5
5
  * link never signs a browser in by itself: the page still needs the person's own sign-in.
6
6
  *
7
7
  * passport connections every app, and the page
@@ -27,7 +27,7 @@ export type ConnectionsJson = {
27
27
  workspace: string;
28
28
  apps: ConnectionsRow[];
29
29
  needsYou: number;
30
- /** The page's link: lasts ten minutes. Absent when Passport couldn't make one. */
30
+ /** The page's link: lasts fifteen minutes. Absent when Passport couldn't make one. */
31
31
  url?: string;
32
32
  expiresAt?: number;
33
33
  opened: boolean;
@@ -36,5 +36,5 @@ export type ConnectionsDependencies = MemberCallDependencies & {
36
36
  open?: (url: string) => boolean;
37
37
  term?: Term;
38
38
  };
39
- export declare function connectionsScreen(term: Term, view: ConnectionsJson, focus: string | undefined, linkNote: "opened" | "printed" | "none"): string;
39
+ export declare function connectionsScreen(term: Term, view: ConnectionsJson, focus: string | undefined, linkNote: "opened" | "printed" | "none", now?: number): string;
40
40
  export declare function connections(args: ParsedArgs, runtime: Runtime, withGateway: GatewayRunner, deps?: ConnectionsDependencies): Promise<CommandResult>;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * `passport connections [app] [--no-open]`: the developer's own connections, in the terminal and
3
3
  * in the browser. It prints what's connected for this person and what still needs them, then opens
4
- * their connections page with a link that lasts ten minutes (`POST /api/my/connections-link`). The
4
+ * their connections page with a link that lasts fifteen minutes (`POST /api/my/connections-link`). The
5
5
  * link never signs a browser in by itself: the page still needs the person's own sign-in.
6
6
  *
7
7
  * passport connections every app, and the page
@@ -32,11 +32,11 @@ function said(row) {
32
32
  case "connected":
33
33
  return { mark: "done", words: row.connectedAs ? `Connected as you · ${row.connectedAs}` : "Connected as you" };
34
34
  case "org_managed":
35
- return { mark: "done", words: "Ready · connected by your company" };
35
+ return { mark: "done", words: "Connected by your company" };
36
36
  case "needs_your_signin":
37
37
  return { mark: "warn", words: row.reconnect ? "Needs reconnecting" : "Needs connecting" };
38
38
  case "needs_setup":
39
- return { mark: "skip", words: "Waiting on your admin" };
39
+ return { mark: "skip", words: "Not set up yet" };
40
40
  default:
41
41
  return { mark: "skip", words: row.status.replace(/_/g, " ") };
42
42
  }
@@ -65,7 +65,13 @@ async function mintLink(args, runtime, deps, app) {
65
65
  return undefined;
66
66
  }
67
67
  }
68
- export function connectionsScreen(term, view, focus, linkNote) {
68
+ /** "10 minutes": what's left of the link, from the server's own expiresAt (docs/design/v21/words.md, row 6). */
69
+ function linkLifetime(expiresAt, now) {
70
+ if (!expiresAt || expiresAt <= now)
71
+ return undefined;
72
+ return countOf(Math.max(1, Math.round((expiresAt - now) / 60_000)), "minute");
73
+ }
74
+ export function connectionsScreen(term, view, focus, linkNote, now = Date.now()) {
69
75
  const lines = [];
70
76
  const width = term.width;
71
77
  lines.push(...wrap(`Your connections in ${view.workspace}`, width));
@@ -85,7 +91,9 @@ export function connectionsScreen(term, view, focus, linkNote) {
85
91
  lines.push(...wrap("Opened your connections page in your browser.", width));
86
92
  if (view.url && linkNote !== "none") {
87
93
  lines.push(linkNote === "opened" ? "If it didn't open:" : "Open your connections page:", ` ${view.url}`);
88
- lines.push(...wrap("The link works for 10 minutes.", width));
94
+ const lifetime = linkLifetime(view.expiresAt, now);
95
+ if (lifetime)
96
+ lines.push(...wrap(`The link expires in ${lifetime}.`, width));
89
97
  }
90
98
  else if (!view.url) {
91
99
  lines.push(...wrap("Couldn't make a link to your connections page. Connect from here instead:", width));
package/dist/cliExec.js CHANGED
@@ -29,7 +29,6 @@ import { spawnVendor } from "./execSpawn.js";
29
29
  import { shadowAfterDecision } from "./kitShadow.js";
30
30
  export { spawnVendor } from "./execSpawn.js";
31
31
  import { findVendorBinary } from "./execShims.js";
32
- import { hashLink } from "./webLinks.js";
33
32
  export const EXEC_AUTHORIZE_PATH = "/api/my/exec/authorize";
34
33
  export const EXEC_RESULT_PATH = "/api/my/exec/result";
35
34
  const SESSION = /^[A-Za-z0-9._:-]{1,128}$/;
@@ -226,10 +225,7 @@ export async function exec(args, runtime, deps = {}) {
226
225
  const message = typeof decided.message === "string" && decided.message ? decided.message : "Passport didn't allow this command.";
227
226
  if (decided.decision === "undecided")
228
227
  return failure(message, 5, "undecided");
229
- // Blocked by the app's access: say where an admin changes it.
230
- const link = decided.decision === "block" ? hashLink(auth.endpoint, decided.link) : null;
231
- if (link)
232
- return failure(message, 5, "no_access", { hint: `Access: ${link}` });
228
+ // A block's message carries the person's Why blocked link itself.
233
229
  return failure(message, 5, "blocked");
234
230
  }
235
231
  let code;
@@ -20,6 +20,8 @@ export type GitCredentialDependencies = CredentialsSwitch & {
20
20
  fallback?: (helper: string, operation: string, input: string, env: Runtime["env"]) => Promise<string>;
21
21
  run?: RunGit;
22
22
  command?: readonly string[];
23
+ /** The person's own helpers' answer once Passport's entry is gone (tests). */
24
+ fillFromOwnHelpers?: (input: string, env: Runtime["env"]) => Promise<string>;
23
25
  /** What a helper line answers (tests); the default runs it as git would. */
24
26
  probe?: (line: string, env: Runtime["env"]) => string | null;
25
27
  mintTimeoutMs?: number;
@@ -48,6 +48,7 @@ import { beginShadowLine, shadowAfterDecision, shadowAlongside, shadowGithubLine
48
48
  import { takePushDecisions } from "./gitPushDecisions.js";
49
49
  import { helperLine, helperProgram, installGitCredential, probeHelper, readGitCredentialState, removeGitCredential } from "./gitCredentialSetup.js";
50
50
  import { GIT_OFF, issuesCredentials, offResult } from "./offInV1.js";
51
+ import { fillFromOwnHelpers, retireGitCredential } from "./gitCredentialRetire.js";
51
52
  export const GIT_CREDENTIAL_PATH = "/api/my/github/git-credential";
52
53
  export const TOKEN_USERNAME = "x-access-token";
53
54
  const REPO_PATH = /^([A-Za-z0-9_.-]{1,100})\/([A-Za-z0-9_.-]{1,100}?)(?:\.git)?\/?$/;
@@ -119,8 +120,7 @@ const runFallback = (helper, operation, input, env) => new Promise((resolve) =>
119
120
  });
120
121
  /** Ask the helpers git used before setup, in order, as git would; the first that answers wins. `quit`: whether
121
122
  * a helper's quit stops there (in v1 it doesn't: the next helper is asked). */
122
- async function delegate(operation, input, runtime, deps, quit = true) {
123
- const helpers = readGitCredentialState()?.fallback ?? [];
123
+ async function delegate(operation, input, runtime, deps, quit = true, helpers = readGitCredentialState()?.fallback ?? []) {
124
124
  const run = deps.fallback ?? runFallback;
125
125
  // The path is there for Passport (useHttpPath); the earlier helpers stored their
126
126
  // passwords per host, so they get the request as git sent it before setup.
@@ -476,15 +476,23 @@ export async function gitCredential(args, runtime, deps = {}) {
476
476
  const input = await readInput(runtime);
477
477
  let out = "";
478
478
  try {
479
- // Off in v1: no token from Passport. The helpers git used before setup answer, else nothing, so git
480
- // asks the next helper or the person. Never quit=1: Passport doesn't stop git here.
481
- if (operation === "get" && !on)
482
- out = withoutQuit(await delegate("get", input, runtime, deps, false));
479
+ // Off in v1: no token from Passport, and this helper is retired: it takes its own entries out of the
480
+ // global config, then the helpers git used before setup answer, else the person's own helpers, so git
481
+ // is never left with an empty answer. Never quit=1: Passport doesn't stop git here.
482
+ // The recorded helpers are read before the retire step deletes the record.
483
+ const recorded = on ? null : readGitCredentialState();
484
+ if (!on)
485
+ retireGitCredential(runtime, recorded, deps.run);
486
+ if (operation === "get" && !on) {
487
+ out = withoutQuit(await delegate("get", input, runtime, deps, false, recorded?.fallback ?? []));
488
+ if (!/^password=/m.test(out))
489
+ out = await (deps.fillFromOwnHelpers ?? fillFromOwnHelpers)(input, runtime.env);
490
+ }
483
491
  else if (operation === "get")
484
492
  out = await get(args, runtime, deps, input);
485
493
  // A token Passport issued is never stored: git would offer an expired one next time.
486
494
  else if (parseCredentialRequest(input).get("username") !== TOKEN_USERNAME) {
487
- out = await delegate(operation, input, runtime, deps);
495
+ out = await delegate(operation, input, runtime, deps, true, recorded?.fallback);
488
496
  }
489
497
  }
490
498
  catch (error) {
@@ -71,7 +71,8 @@ export function localGuardState(report, cliVersion) {
71
71
  export function guardStateFix(state, client) {
72
72
  if (!state || state === "on" || state === "locked")
73
73
  return null;
74
- const link = "#cp/agents";
74
+ // My activity: its strip shows each agent's guard here.
75
+ const link = "#p";
75
76
  const docs = `${DOCS_BASE}/member/cli-hook#guard-health`;
76
77
  switch (state) {
77
78
  case "off":
package/dist/cliHook.js CHANGED
@@ -216,7 +216,11 @@ async function runAudit(args, runtime, deps) {
216
216
  const findings = classifyLine(command, localMachine(workingFolder(input), runtime.env)).findings;
217
217
  const built = buildReport(input, findings, runtime.env, declared);
218
218
  // A sign-in that expired, what it created, a retry loop: the report, and what Claude Code reads.
219
- const { report, output } = await after.afterCommand({ ...facts, command, findings, report: built, base });
219
+ const { report, output: learned } = await after.afterCommand({ ...facts, command, findings, report: built, base });
220
+ // A command Passport handled in Claude Code carries this person's waiting notices to them (never to the model).
221
+ const output = report && profile && runtimeName === "claude-code" && !event.cursorImported
222
+ ? (await import("./cliHookNotices.js")).withNotices(learned, profile)
223
+ : learned;
220
224
  if (output)
221
225
  runtime.stdout.write(`${JSON.stringify(output)}\n`);
222
226
  if (!report)
@@ -21,7 +21,7 @@
21
21
  import { classifyLine, localMachine, workingFolder } from "./hookLine.js";
22
22
  import { execInner } from "./cliHookRewrite.js";
23
23
  import { nextRetry, readSessionState, writeSessionState } from "./cliHookSessionState.js";
24
- import { EXEC_VENDOR_NAMES, vendorCommand } from "./execVendors.js";
24
+ import { EXEC_LOGIN_COMMAND, EXEC_VENDOR_NAMES, vendorCommand } from "./execVendors.js";
25
25
  import { outcomeOfInput } from "./cliHookOutcome.js";
26
26
  /** The agent hears about a retry loop from this many failures in a row. */
27
27
  export const RETRY_TELL_AT = 3;
@@ -32,7 +32,7 @@ export function signInContext(vendor, held, rerouted) {
32
32
  if (held) {
33
33
  return `Passport: the ${name} sign-in on this computer expired. Passport holds your ${name} key, so run it as \`passport exec -- ${command} <command>\`${rerouted ? " or just rerun it" : ""}.`;
34
34
  }
35
- return `Passport: the ${name} sign-in on this computer expired, and Passport doesn't hold a ${name} key for this person. Passport asked them to add one. Don't retry ${command} until they have; tell them what you were about to do.`;
35
+ return `Passport: the ${name} sign-in on this computer expired. Ask the user to run \`${EXEC_LOGIN_COMMAND[vendor]}\`, then retry.`;
36
36
  }
37
37
  /** What the agent reads when the same command keeps failing. */
38
38
  export function retryContext(streak, program) {
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Claude Code's after-command output with this person's waiting notices as a system message (shown to the person,
3
+ * not the model, so it never steers the agent). A notice prints once: taking it removes it for the CLI too.
4
+ * Cursor and Codex have no person-only field on a command that ran, so their people see notices in the CLI,
5
+ * Slack and email instead (docs/design/v21/people.md, section 4).
6
+ */
7
+ export declare function withNotices(output: Record<string, unknown> | null, profile: string): Record<string, unknown> | null;
@@ -0,0 +1,14 @@
1
+ import { noticeLine, takeLocalNotices } from "./localNotices.js";
2
+ /**
3
+ * Claude Code's after-command output with this person's waiting notices as a system message (shown to the person,
4
+ * not the model, so it never steers the agent). A notice prints once: taking it removes it for the CLI too.
5
+ * Cursor and Codex have no person-only field on a command that ran, so their people see notices in the CLI,
6
+ * Slack and email instead (docs/design/v21/people.md, section 4).
7
+ */
8
+ export function withNotices(output, profile) {
9
+ const notices = takeLocalNotices(profile);
10
+ if (!notices.length)
11
+ return output;
12
+ const message = notices.map((notice) => noticeLine(notice, "Passport")).join("\n");
13
+ return { ...(output ?? {}), systemMessage: message };
14
+ }
package/dist/cliMain.js CHANGED
@@ -8,13 +8,14 @@ import { VERSION } from "./version.js";
8
8
  import { ensureNodeRuntime, nodeVersionProblem } from "./nodeVersion.js";
9
9
  import { login } from "./cliLogin.js";
10
10
  import { asFailure, emitFailure, emitResult } from "./cliOutput.js";
11
+ import { noticeLine, takeLocalNotices } from "./localNotices.js";
11
12
  import { completionResult, profilesResult, useProfileResult, versionResult } from "./cliOffline.js";
12
13
  import { describedToolPayload, toolClassWord } from "./cliDescribe.js";
13
14
  import { connect } from "./cliConnect.js";
14
15
  import { firstText, hasNonText, payloadOf, refusalOf, requireSuccess } from "./cliResult.js";
15
- import { callerFrom, endpoint, failure, FIRST_LOGIN_NEXT, firstSentence, holdForCommand, NOT_SIGNED_IN, passportOrigin, resolveCliAuth, sanitize, sleep, timeoutMs } from "./cliSupport.js";
16
+ import { callerFrom, endpoint, failure, FIRST_LOGIN_NEXT, firstSentence, holdForCommand, NOT_SIGNED_IN, passportOrigin, resolveCliAuth, sanitize, selectStoredProfile, sleep, timeoutMs } from "./cliSupport.js";
16
17
  import { readBoundedUtf8Descriptor } from "./boundedFile.js";
17
- import { linkApproval, runCliSession, writeCliSessionFailure } from "./cliSession.js";
18
+ import { runCliSession, writeCliSessionFailure } from "./cliSession.js";
18
19
  export { refusalOf } from "./cliResult.js";
19
20
  export { callerFrom, sanitize } from "./cliSupport.js";
20
21
  const APPROVAL_RETRY_MS = 3_000;
@@ -451,6 +452,8 @@ async function dispatch(args, runtime) {
451
452
  return connect(args, runtime, withGateway);
452
453
  case "connections":
453
454
  return (await import("./cliConnections.js")).connections(args, runtime, withGateway);
455
+ case "request":
456
+ return (await import("./cliRequest.js")).request(args, runtime);
454
457
  case "resources":
455
458
  return resources(args, runtime);
456
459
  case "prompts":
@@ -515,6 +518,32 @@ async function updateCheckAfter(args, runtime, exitCode) {
515
518
  /* The next command tries again. */
516
519
  }
517
520
  }
521
+ /** Commands that never print Passport's one-time notices: machine output, the guard, and helpers other programs read. */
522
+ const QUIET_COMMANDS = new Set([
523
+ "hook",
524
+ "session",
525
+ "completion",
526
+ "git-credential",
527
+ "kube-credential",
528
+ "exec",
529
+ "access",
530
+ "version"
531
+ ]);
532
+ /** A request decided, a setup nudge: printed once after a human-readable command (localNotices.ts). */
533
+ function printNotices(args, runtime, result) {
534
+ if (result.silent || QUIET_COMMANDS.has(args.command) || bool(args, "json") || bool(args, "quiet"))
535
+ return;
536
+ try {
537
+ const selection = selectStoredProfile(args, runtime.env);
538
+ if (!selection.profile || runtime.env.PASSPORT_AGENT_KEY)
539
+ return;
540
+ for (const notice of takeLocalNotices(selection.profile))
541
+ runtime.stderr.write(`${noticeLine(notice)}\n`);
542
+ }
543
+ catch {
544
+ /* Notices wait for the next command. */
545
+ }
546
+ }
518
547
  export async function main(argv = process.argv.slice(2), env = process.env, io = {
519
548
  stdin: process.stdin,
520
549
  stdout: process.stdout,
@@ -545,11 +574,12 @@ export async function main(argv = process.argv.slice(2), env = process.env, io =
545
574
  const result = await dispatch(args, runtime);
546
575
  if (args.command !== "session")
547
576
  emitResult(result, args, runtime);
577
+ printNotices(args, runtime, result);
548
578
  await updateCheckAfter(args, runtime, result.exitCode ?? 0);
549
579
  return result.exitCode ?? 0;
550
580
  }
551
581
  catch (error) {
552
- let cliError = linkApproval(asFailure(error, args && passportOrigin(args, env)), args, env);
582
+ let cliError = asFailure(error, args && passportOrigin(args, env));
553
583
  // Signed out on a computer with nothing set up: the next step is init, not login.
554
584
  if (cliError.message === NOT_SIGNED_IN && cliError.details.next === FIRST_LOGIN_NEXT) {
555
585
  cliError = (await import("./firstRun.js")).firstRunFailure(cliError, env);
package/dist/cliOutput.js CHANGED
@@ -113,6 +113,7 @@ const HELP_GROUPS = [
113
113
  ["hook", "Record the CLIs your agents run, and decide before they run"],
114
114
  ["connections", "Your connections: what's connected and what needs you"],
115
115
  ["connect", "Sign in to your apps"],
116
+ ["request", "Ask for an app"],
116
117
  ["search", "Find tools you can run"],
117
118
  ["describe", "Show one tool and its parameters"],
118
119
  ["run", "Run a tool through your rules"]
@@ -177,15 +178,16 @@ function helpText(verb, all = false) {
177
178
  describe: "passport describe <tool>\nShows one tool: what it does and every parameter it takes.",
178
179
  // copy-style-allow double-space: help columns line up
179
180
  run: "passport run <tool> [json-object]\n --args - read the JSON object from stdin\n --set key=value set a string argument (repeatable)\n --set-json key=<json> set a typed argument (repeatable)\n --wait <sec> retry only a definite approval_pending call\nWithout --json, prints the tool's text as it returned it. JSON: the tool's whole result.",
180
- connections: "passport connections [app] [--no-open]\nLists what's connected for you and what still needs you, then opens your connections page in your browser. The link works for 10 minutes and still needs your own sign-in.\nJSON: {workspace,apps,needsYou,url?,expiresAt?,opened}",
181
+ connections: "passport connections [app] [--no-open]\nLists what's connected for you and what still needs you, then opens your connections page in your browser. The link is only for you and still needs your own sign-in.\nJSON: {workspace,apps,needsYou,url?,expiresAt?,opened}",
181
182
  connect: "passport connect [app…] [--alias <name>] [--open] [--wait <sec>]\nShows the link to sign in to your apps, and can wait for the sign-in to finish.\nJSON: each app's status and its sign-in link.",
183
+ request: "passport request <app> --reason \"<what it's for>\"\npassport request\npassport request <app> --cancel\nAsks for an app your company doesn't offer you yet. Its owner or an admin decides; you hear back in your next command, in Slack and by email. With no app, lists your requests. --cancel takes one back.\nJSON: the request (status, who decides) or your requests.",
182
184
  resources: "passport resources [uri] [--out <file>]\nLists or reads workspace MCP resources. Binary content requires --out or --json.",
183
185
  prompts: "passport prompts [name] [--set key=value] [--out <file>]\nLists or gets workspace MCP prompts. Binary content requires --out or --json.",
184
186
  // copy-style-allow double-space: help columns line up
185
187
  scan: "passport scan [--path <folder>] [--verbose] [--check] [--local] [--json]\nnpx passport-bridge@latest scan [same options]\nFinds keys your agents can reach: agent configs, CLI sign-ins, your shell environment, and this project's .env files. Runs locally with no account, and no part of a key is ever printed or sent. It ends with the CLI keys Passport could hold for your agents, the same list passport status shows, and the step to move them.\nSigned in, it then sends Passport this computer's name, each MCP server's name and how it connects (a host, or a command like npx), and how many keys each app has here. Never env values, arguments, files, or keys. It exits 5 when your workspace's policy doesn't allow an MCP server.\n --path <folder> scan this project instead of the current folder\n --verbose show every place a key was found, files it couldn't read, and each key's file and fingerprint\n --check files only, no shell environment; exit 5 on a high or medium key (CI, pre-commit); sends nothing\n --local send nothing, even when signed in\n --json one JSON document: {version,findings,agents,unreadable,checked,keys,inventory?}",
186
188
  discover: "passport discover\nNow part of passport scan, which reports the same MCP servers when you're signed in.\nRun: passport scan",
187
189
  setup: "passport setup --org <pek_key> --yes\nNow passport init --org, which sets up a company's computers.\nRun: passport init --org <key> --yes",
188
- hook: "passport hook install [--agent claude-code|codex|cursor] [--guard] [--apply] [--verbose]\npassport hook uninstall [--agent claude-code|codex|cursor] [--guard] [--apply] [--verbose]\npassport hook status\nThe audit hook runs after each shell command an agent runs and records the vendor, a coarse verb, a risk class, and the environment in Activity. With --guard, Passport also decides each command before it runs, from your rules: it runs what your rules allow without a prompt (only when it recognizes every part of the command), asks first, or blocks. When nobody is at the keyboard, an ask becomes an approval request you answer on the web or your phone. Neither hook sends the command line, its output, your folder path, or your environment; an approval request carries a summary with secrets removed on this computer. It reads the project's own shell scripts, make targets, and package scripts (npm, pnpm, yarn) before they run, up to 256 KB a file and 30 ms a command, and decides from what they run; a script it can't follow to the end is partly checked and gets no allow. Changes are previewed unless --apply is supplied; --verbose shows each hook's full command. uninstall --guard removes only the guard.",
190
+ hook: "passport hook install [--agent claude-code|codex|cursor] [--guard] [--apply] [--verbose]\npassport hook uninstall [--agent claude-code|codex|cursor] [--guard] [--apply] [--verbose]\npassport hook status\nThe audit hook runs after each shell command an agent runs and records the vendor, a coarse verb, a risk class, and the environment in Activity. With --guard, Passport also decides each command before it runs, from your rules: it runs what your rules allow and blocks what they block. Neither hook sends the command line, its output, your folder path, or your environment. It reads the project's own shell scripts, make targets, and package scripts (npm, pnpm, yarn) before they run, up to 256 KB a file and 30 ms a command, and decides from what they run; a script it can't follow to the end is partly checked and gets no allow. Changes are previewed unless --apply is supplied; --verbose shows each hook's full command. uninstall --guard removes only the guard.",
189
191
  session: 'passport session\nReads newline-delimited {"id"?:string|number,"argv":string[]} requests from stdin and emits one JSON response per line. Reuses one authenticated MCP session. Supported request commands: status, search, describe, run, connect, resources, prompts.',
190
192
  access: "passport access <keygen|actions|run|invoke|status|cancel>\nkeygen writes a new owner-only private key and separate public JWK. Other commands use PASSPORT_ENDPOINT, PASSPORT_CLIENT_ID, and PASSPORT_PRIVATE_KEY_FILE.\n access actions [--delegation-id <id>]\n access run --input <json-file>\n access invoke --input <json-file> --caller <stable-id>\n access status <invocation-id>\n access cancel <run-id>",
191
193
  completion: "passport completion <bash|zsh|fish>\nPrints an offline shell-completion script to stdout.",
@@ -352,9 +354,6 @@ export function emitFailure(error, json, quiet, runtime) {
352
354
  }
353
355
  if (error.details.hint && !quiet)
354
356
  say(under(error.details.hint));
355
- if (error.details.approvalUrl && !json && !quiet && !error.details.linkShown) {
356
- say(under(`Open in Passport: ${error.details.approvalUrl}`));
357
- }
358
357
  }
359
358
  export function failurePayload(error) {
360
359
  return {
@@ -362,7 +361,6 @@ export function failurePayload(error) {
362
361
  cause: error.cause,
363
362
  exitCode: error.exitCode,
364
363
  ...(error.details.approvalId ? { approvalId: error.details.approvalId } : {}),
365
- ...(error.details.approvalUrl ? { approvalUrl: error.details.approvalUrl } : {}),
366
364
  ...(error.details.app ? { app: error.details.app } : {}),
367
365
  ...(error.details.connectUrl ? { connectUrl: error.details.connectUrl } : {}),
368
366
  ...(error.details.hint ? { hint: error.details.hint } : {}),
@@ -0,0 +1,65 @@
1
+ /**
2
+ * `passport request`: ask for an app, see your requests, take one back (docs/design/v21/requests.md, section 4).
3
+ *
4
+ * passport request <app> --reason "<what it's for>" ask; an admin or the app's owner decides
5
+ * passport request your requests
6
+ * passport request <app> --cancel take back your request
7
+ *
8
+ * The answer arrives later as a one-time line in the next command's output (localNotices.ts), and by Slack and email.
9
+ * A person asks; an agent token can't.
10
+ */
11
+ import { type ParsedArgs } from "./cliArgs.js";
12
+ import { type MemberCallDependencies } from "./cliMemberCall.js";
13
+ import { type CommandResult, type Runtime } from "./cliSupport.js";
14
+ type AppRef = {
15
+ key: string;
16
+ name: string;
17
+ };
18
+ export type RequestFiled = {
19
+ filed: true;
20
+ created: boolean;
21
+ requestId: string;
22
+ status: "pending" | "approved_pending_setup";
23
+ app: AppRef;
24
+ deciders: string[];
25
+ decidersLine: string;
26
+ askedAt: number;
27
+ reach: {
28
+ slack: boolean;
29
+ email: boolean;
30
+ };
31
+ workspace: string;
32
+ } | {
33
+ filed: true;
34
+ created: boolean;
35
+ requestId: string;
36
+ status: "auto_approved";
37
+ app: AppRef;
38
+ connectUrl?: string;
39
+ workspace: string;
40
+ } | {
41
+ filed: false;
42
+ reason: "connected" | "blocked_by_policy" | "not_requestable";
43
+ message: string;
44
+ };
45
+ export type MyRequest = {
46
+ id: string;
47
+ app: AppRef;
48
+ status: string;
49
+ statusLine: string;
50
+ askedAt: number;
51
+ decidedAt?: number;
52
+ };
53
+ export type RequestDependencies = MemberCallDependencies & {
54
+ /** Asks "What's it for?" on a terminal; absent: no terminal. */
55
+ ask?: (prompt: string) => Promise<string>;
56
+ };
57
+ /** "Nov 16" in the person's own time zone. */
58
+ export declare function shortDate(at: number): string;
59
+ /** "You'll hear back here, in Slack and by email." without the ways that don't reach them. */
60
+ export declare function hearBackLine(reach: {
61
+ slack: boolean;
62
+ email: boolean;
63
+ }): string;
64
+ export declare function request(args: ParsedArgs, runtime: Runtime, deps?: RequestDependencies): Promise<CommandResult>;
65
+ export {};