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
@@ -0,0 +1,143 @@
1
+ /**
2
+ * `passport git-credential` is retired (off in v1: Passport issues no git
3
+ * tokens). A config left from an older setup still points git at it, and the
4
+ * empty `helper =` reset that setup added drops the helpers git had before, so
5
+ * git would get an empty answer and stop at a sign-in prompt. When git asks,
6
+ * the CLI unsets only its own values from the global config (one stderr line),
7
+ * then answers from the person's own helpers so this git command works too.
8
+ */
9
+ import { spawn } from "node:child_process";
10
+ import { rmSync } from "node:fs";
11
+ import { PASSPORT_CREDENTIAL_KEY, defaultRunGit, isPassportHelper, statePath } from "./gitCredentialSetup.js";
12
+ const USE_HTTP_PATH_KEY = "credential.https://github.com/.useHttpPath";
13
+ /** Set on the nested `git credential fill`, so a Passport entry that couldn't be removed never recurses. */
14
+ export const RETIRED_FILL_GUARD = "PASSPORT_GIT_CREDENTIAL_RETIRED";
15
+ const MAX_ANSWER_BYTES = 64 * 1024;
16
+ const FILL_TIMEOUT_MS = 15_000;
17
+ export const RETIRED_NOTICE = "passport: git-credential is retired, so Passport took itself out of your global git config; git uses your own sign-in.";
18
+ export const RETIRE_FAILED_NOTICE = "passport: git-credential is retired, but your global git config couldn't be updated; git uses your own sign-in, and Passport tries again next time.";
19
+ function globalValues(run, env, key) {
20
+ const got = run(["config", "--global", "--get-all", key], env);
21
+ return got.ok ? got.stdout.replace(/\n$/, "").split("\n") : null;
22
+ }
23
+ /** The values setup's record says the section held for `key` before Passport wrote it. */
24
+ function recorded(state, key) {
25
+ const found = Object.entries(state.restore ?? {}).find(([existing]) => existing.toLowerCase() === key.toLowerCase());
26
+ return found?.[1] ?? [];
27
+ }
28
+ /**
29
+ * Takes Passport's own entries out of the global git config and nothing else.
30
+ * In order, so a failure part-way is retried on the next call (Passport's
31
+ * helper, removed last, keeps bringing git back here):
32
+ * 1. what setup moved out of the section goes back (it lives only in the record);
33
+ * 2. the pushInsteadOf rewrites the record lists, each by its exact value;
34
+ * 3. useHttpPath, unless the record shows the section had it before;
35
+ * 4. the empty `helper =` reset: with a record, when the recorded helpers had no
36
+ * reset; without one, when every reset sits right before a Passport line (as
37
+ * setup writes them). This reset is what left git with no answer;
38
+ * 5. Passport's helper value(s) last.
39
+ * Each removal is one `--fixed-value --unset-all` of an exact value, so a
40
+ * concurrent writer is never undone. A failed write prints one line and stops;
41
+ * git is still answered through the fallback.
42
+ */
43
+ export function retireGitCredential(runtime, state, run = defaultRunGit) {
44
+ const env = runtime.env;
45
+ const helpers = globalValues(run, env, PASSPORT_CREDENTIAL_KEY) ?? [];
46
+ const ours = [...new Set(helpers.filter(isPassportHelper))];
47
+ if (!ours.length)
48
+ return false;
49
+ const unset = (key, value) => run(["config", "--global", "--fixed-value", "--unset-all", key, value], env).ok;
50
+ const failed = () => (runtime.stderr.write(`${RETIRE_FAILED_NOTICE}\n`), false);
51
+ for (const [key, values] of Object.entries(state?.restore ?? {})) {
52
+ const present = globalValues(run, env, key) ?? [];
53
+ for (const value of values) {
54
+ if (!present.includes(value) && !run(["config", "--global", "--add", key, value], env).ok)
55
+ return failed();
56
+ }
57
+ }
58
+ for (const { key, value } of state?.pushInsteadOf ?? []) {
59
+ if (globalValues(run, env, key)?.includes(value) && !unset(key, value))
60
+ return failed();
61
+ }
62
+ const pathOurs = state ? !recorded(state, USE_HTTP_PATH_KEY).includes("true") : true;
63
+ if (pathOurs && globalValues(run, env, USE_HTTP_PATH_KEY)?.includes("true") && !unset(USE_HTTP_PATH_KEY, "true")) {
64
+ return failed();
65
+ }
66
+ const resets = helpers.filter((value) => value === "").length;
67
+ const resetsBeforeOurs = helpers.filter((value, index) => value === "" && isPassportHelper(helpers[index + 1] ?? ""));
68
+ const resetOurs = state
69
+ ? !recorded(state, PASSPORT_CREDENTIAL_KEY).includes("")
70
+ : resets > 0 && resetsBeforeOurs.length === resets;
71
+ if (resetOurs && resets > 0 && !unset(PASSPORT_CREDENTIAL_KEY, ""))
72
+ return failed();
73
+ if (!ours.every((value) => unset(PASSPORT_CREDENTIAL_KEY, value)))
74
+ return failed();
75
+ try {
76
+ rmSync(statePath(), { force: true });
77
+ }
78
+ catch {
79
+ /* the record only matters to setup */
80
+ }
81
+ runtime.stderr.write(`${RETIRED_NOTICE}\n`);
82
+ return true;
83
+ }
84
+ /** The credential git's remaining helpers give for this request, never prompting: the lines git needs from
85
+ * a helper (username, password, expiry), or "" when none answers in time. */
86
+ export function fillFromOwnHelpers(input, env, cwd = process.cwd(), timeoutMs = FILL_TIMEOUT_MS) {
87
+ const vars = env;
88
+ // git always hands a helper its HOME; without one, git would read the OS account's real config instead.
89
+ if (vars[RETIRED_FILL_GUARD] || !vars.HOME)
90
+ return Promise.resolve("");
91
+ const request = input
92
+ .split("\n")
93
+ .filter((line) => /^(?:protocol|host|username|path)=/.test(line))
94
+ .join("\n");
95
+ if (!/^host=/m.test(request))
96
+ return Promise.resolve("");
97
+ return new Promise((resolve) => {
98
+ const run = { settled: false };
99
+ const finish = (answer) => {
100
+ if (run.settled)
101
+ return;
102
+ run.settled = true;
103
+ clearTimeout(run.timer);
104
+ resolve(answer);
105
+ };
106
+ const child = spawn("git", ["-c", "credential.interactive=false", "credential", "fill"], {
107
+ cwd,
108
+ detached: true,
109
+ env: {
110
+ ...env,
111
+ GIT_TERMINAL_PROMPT: "0",
112
+ GIT_ASKPASS: "",
113
+ SSH_ASKPASS: "",
114
+ GCM_INTERACTIVE: "never",
115
+ [RETIRED_FILL_GUARD]: "1"
116
+ },
117
+ stdio: ["pipe", "pipe", "ignore"]
118
+ });
119
+ // A helper's own child can hold stdout open: the timer answers git anyway and ends the whole group.
120
+ run.timer = setTimeout(() => {
121
+ try {
122
+ if (child.pid)
123
+ process.kill(-child.pid, "SIGKILL");
124
+ }
125
+ catch {
126
+ /* already gone */
127
+ }
128
+ finish("");
129
+ }, timeoutMs);
130
+ let out = "";
131
+ child.stdout.on("data", (chunk) => {
132
+ if (out.length < MAX_ANSWER_BYTES)
133
+ out += chunk.toString("utf8");
134
+ });
135
+ child.on("error", () => finish(""));
136
+ child.on("close", (code) => {
137
+ const lines = out.split("\n").filter((line) => /^(?:username|password|password_expiry_utc)=/.test(line));
138
+ finish(code === 0 && lines.some((line) => line.startsWith("password=")) ? `${lines.join("\n")}\n` : "");
139
+ });
140
+ child.stdin.on("error", () => undefined);
141
+ child.stdin.end(`${request}\n\n`);
142
+ });
143
+ }
@@ -20,7 +20,7 @@ export type AppsPlan = {
20
20
  };
21
21
  /** Apps to connect, in the order the scan found them. */
22
22
  export declare function appsTodo(plan: AppsPlan): InitApp[];
23
- export declare function detectApps(s: InitSession, candidates?: ("github" | "railway" | "supabase" | "vercel" | "stripe" | "cloudflare-bindings")[]): AppsPlan;
23
+ export declare function detectApps(s: InitSession, candidates?: ("github" | "railway" | "supabase")[]): AppsPlan;
24
24
  export declare function pickApps(s: InitSession): Promise<InitApp[]>;
25
25
  export declare function addApp(s: InitSession, app: InitApp): Promise<{
26
26
  state: "pending" | "connected" | "attention";
@@ -11,7 +11,7 @@ import { firstText } from "./cliResult.js";
11
11
  import { openUrl, readBoundedJson, safeApiError, sleep } from "./cliSupport.js";
12
12
  import { APP_LABELS, INIT_APPS, appLabel, WAIT_CHUNK_SECONDS, WAIT_INTERACTIVE_MS, WAIT_NEXT_SECONDS, printable } from "./initState.js";
13
13
  import { listOf } from "./initUi.js";
14
- import { APPS_LINK } from "./webLinks.js";
14
+ import { CONNECT_LINK_LIFETIME, myAppLink } from "./webLinks.js";
15
15
  export function connectionRows(managed) {
16
16
  const rows = new Map();
17
17
  for (const raw of managed.connections) {
@@ -46,7 +46,7 @@ export function detectApps(s, candidates = s.candidates) {
46
46
  else if (row.status === "needs_your_signin")
47
47
  plan.pending.push(app);
48
48
  else
49
- plan.attention.push({ app, message: `${appLabel(app)} needs a one-time setup by your admin.` });
49
+ plan.attention.push({ app, message: `Your company doesn't have ${appLabel(app)} in Passport yet.` });
50
50
  }
51
51
  s.connected = [...plan.already];
52
52
  return plan;
@@ -80,7 +80,7 @@ export async function addApp(s, app) {
80
80
  const name = appLabel(app);
81
81
  if (response.status === 401 || response.status === 403 || response.status === 405) {
82
82
  await response.body?.cancel().catch(() => undefined);
83
- return { state: "attention", message: `Add ${name} in Passport first: ${s.gateway.origin}/${APPS_LINK}` };
83
+ return { state: "attention", message: `Add ${name} in Passport first: ${s.gateway.origin}/${myAppLink(app)}` };
84
84
  }
85
85
  if (response.status === 404) {
86
86
  const message = await safeApiError(response, "");
@@ -88,7 +88,7 @@ export async function addApp(s, app) {
88
88
  state: "attention",
89
89
  message: /catalog/i.test(message)
90
90
  ? `${name} isn't in this Passport's catalog.`
91
- : `Add ${name} in Passport first: ${s.gateway.origin}/${APPS_LINK}`
91
+ : `Add ${name} in Passport first: ${s.gateway.origin}/${myAppLink(app)}`
92
92
  };
93
93
  }
94
94
  if (response.status === 429) {
@@ -102,7 +102,7 @@ export async function addApp(s, app) {
102
102
  if (body.lifecycle === "waiting_on_admin") {
103
103
  const reason = typeof body.statusReason === "string" ? body.statusReason : "";
104
104
  if (body.request?.kind === "company_setup")
105
- return { state: "attention", message: `${name} needs a one-time setup by your admin.` };
105
+ return { state: "attention", message: `Your company doesn't have ${name} in Passport yet.` };
106
106
  if (/blocked/i.test(reason))
107
107
  return { state: "attention", message: `${name} is blocked by your workspace's app rules.` };
108
108
  return { state: "attention", message: `${name} needs approval from your admin.` };
@@ -256,6 +256,7 @@ export async function connectApps(s, apps) {
256
256
  else {
257
257
  s.screen.line("Open this link to sign in:", "Apps");
258
258
  s.screen.line(url);
259
+ s.screen.line(CONNECT_LINK_LIFETIME);
259
260
  }
260
261
  return "not_waited";
261
262
  }
@@ -268,6 +269,7 @@ export async function connectApps(s, apps) {
268
269
  else {
269
270
  s.screen.line(`Open this link to sign in.${stopHint}`, "Apps");
270
271
  s.screen.line(url);
272
+ s.screen.line(CONNECT_LINK_LIFETIME);
271
273
  }
272
274
  return waitForApps(s, apps, enter);
273
275
  }
package/dist/initOutro.js CHANGED
@@ -7,8 +7,7 @@
7
7
  * ! Railway connects to Passport once you finish signing in
8
8
  *
9
9
  * Next: ask your agent to work with one of your apps, like GitHub or
10
- * Railway. You'll see each step in Activity:
11
- * https://passportmcp.com/#cp/activity
10
+ * Railway. See what your agents do: https://passportmcp.com/#p
12
11
  */
13
12
  import { EXEC_TOKEN_PAGES, EXEC_VENDOR_NAMES } from "./execVendors.js";
14
13
  import { AGENT_NAMES } from "./initAgents.js";
@@ -19,7 +18,7 @@ import { desktopLine } from "./initLocalSteps.js";
19
18
  import { TRY_IT, appLabel } from "./initState.js";
20
19
  import { listOf } from "./initUi.js";
21
20
  import { wrap } from "./term.js";
22
- import { ACTIVITY_LINK, hashLink } from "./webLinks.js";
21
+ import { MY_ACTIVITY_LINK, hashLink } from "./webLinks.js";
23
22
  const done = (text) => ({ mark: "done", text });
24
23
  const warn = (text) => ({ mark: "warn", text });
25
24
  /** Apps this run connected, left waiting for a sign-in, skipped, or sent to an admin. */
@@ -114,15 +113,15 @@ function agentFollowUps(s) {
114
113
  }
115
114
  return items;
116
115
  }
117
- /** The one next step: put passport on PATH (then Activity), finish app
118
- * sign-ins, try an agent, or watch its work in Activity. A command or link is
116
+ /** The one next step: put passport on PATH (then My activity), finish app
117
+ * sign-ins, try an agent, or watch its work in My activity. A command or link is
119
118
  * never wrapped. */
120
119
  function nextCommand(s, waiting) {
121
120
  const stable = s.stable;
122
121
  if (stable?.binDir && !stable.onPath) {
123
122
  const line = pathLine(stable.binDir, s.env, s.home, s.platform);
124
123
  s.summary.pathLine = line;
125
- // PATH first, then Activity, so a first npx run still ends there.
124
+ // PATH first, then My activity, so a first npx run still ends there.
126
125
  const work = workNext(s, "Then");
127
126
  return [...pathNext(line, s.terminal.width), ...(work.length ? ["", ...work] : [])];
128
127
  }
@@ -137,13 +136,17 @@ function nextCommand(s, waiting) {
137
136
  const work = workNext(s, "Next:");
138
137
  return work.length ? work : ["Run: passport status"];
139
138
  }
140
- /** "Next: ask your agent to work with an app…" and the Activity link; nothing without a server to link to. */
139
+ /** "Next: ask your agent to work with an app…" and the My activity link; nothing without a server to link to. The
140
+ * link is never wrapped. */
141
141
  function workNext(s, lead) {
142
- const work = hashLink(s.gateway?.origin, ACTIVITY_LINK);
142
+ const work = hashLink(s.gateway?.origin, MY_ACTIVITY_LINK);
143
143
  if (!work)
144
144
  return [];
145
- const step = `${lead} ask your agent to work with one of your apps, like GitHub or Railway. You'll see each step in Activity:`;
146
- return [...wrap(step, s.terminal.width), work];
145
+ const step = `${lead} ask your agent to work with one of your apps, like GitHub or Railway.`;
146
+ const see = `See what your agents do: ${work}`;
147
+ // Narrow, the link gets a line of its own.
148
+ const tail = [...see].length <= s.terminal.width ? [see] : ["See what your agents do:", work];
149
+ return [...wrap(step, s.terminal.width), ...tail];
147
150
  }
148
151
  /** What to do next about PATH: the step, then the command on its own line. */
149
152
  export function pathNext(line, width) {
@@ -9,8 +9,9 @@ import type { InitScreen, InitTerminal } from "./initUi.js";
9
9
  import type { CredentialsSwitch } from "./offInV1.js";
10
10
  import type { ScanOptions, ScanResult } from "./scan.js";
11
11
  export declare const PASSPORT_CLOUD = "https://passportmcp.com";
12
- /** The production apps init looks for, in the order it lists them. */
13
- export declare const INIT_APPS: readonly ["railway", "vercel", "supabase", "cloudflare-bindings", "github", "stripe"];
12
+ /** The production apps init looks for, in the order it lists them: the deep apps (gateway apps were removed on
13
+ * 2026-11-17). */
14
+ export declare const INIT_APPS: readonly ["railway", "supabase", "github"];
14
15
  export type InitApp = (typeof INIT_APPS)[number];
15
16
  export declare const APP_LABELS: Record<InitApp, string>;
16
17
  /** The short name init uses for an app in its copy. */
package/dist/initState.js CHANGED
@@ -6,15 +6,13 @@
6
6
  import { dirname, join } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  export const PASSPORT_CLOUD = "https://passportmcp.com";
9
- /** The production apps init looks for, in the order it lists them. */
10
- export const INIT_APPS = ["railway", "vercel", "supabase", "cloudflare-bindings", "github", "stripe"];
9
+ /** The production apps init looks for, in the order it lists them: the deep apps (gateway apps were removed on
10
+ * 2026-11-17). */
11
+ export const INIT_APPS = ["railway", "supabase", "github"];
11
12
  export const APP_LABELS = {
12
13
  railway: "Railway",
13
- vercel: "Vercel",
14
14
  supabase: "Supabase",
15
- "cloudflare-bindings": "Cloudflare",
16
- github: "GitHub",
17
- stripe: "Stripe"
15
+ github: "GitHub"
18
16
  };
19
17
  /** The short name init uses for an app in its copy. */
20
18
  export function appLabel(app) {
@@ -23,29 +21,20 @@ export function appLabel(app) {
23
21
  /** A scan finding's provider → the catalog app that replaces the key. */
24
22
  export const APP_BY_PROVIDER = {
25
23
  Railway: "railway",
26
- Vercel: "vercel",
27
24
  Supabase: "supabase",
28
- Cloudflare: "cloudflare-bindings",
29
- GitHub: "github",
30
- Stripe: "stripe"
25
+ GitHub: "github"
31
26
  };
32
27
  /** A vendor CLI on PATH → its catalog app. */
33
28
  export const APP_BY_CLI = [
34
29
  ["railway", "railway"],
35
- ["vercel", "vercel"],
36
30
  ["supabase", "supabase"],
37
- ["wrangler", "cloudflare-bindings"],
38
- ["gh", "github"],
39
- ["stripe", "stripe"]
31
+ ["gh", "github"]
40
32
  ];
41
33
  /** A read-only first request per app, for the closing "Try it" line. */
42
34
  export const TRY_IT = {
43
35
  railway: "list your Railway services",
44
- vercel: "list your Vercel deployments",
45
36
  supabase: "list your Supabase projects",
46
- "cloudflare-bindings": "list your Cloudflare Workers",
47
- github: "list your open GitHub pull requests",
48
- stripe: "show your Stripe balance"
37
+ github: "list your open GitHub pull requests"
49
38
  };
50
39
  export const WAIT_INTERACTIVE_MS = 10 * 60 * 1000;
51
40
  /** How long the printed `passport connect --wait` command waits. */
@@ -0,0 +1,22 @@
1
+ /**
2
+ * One-time notices for this person (docs/design/v21/requests.md section 9b; docs/design/v21/people.md section 4):
3
+ * `GET /api/cp/cli` hands them over once (`notices`, marked delivered by that read), the CLI keeps them in a private
4
+ * local file, and whichever prints first takes them: the CLI at the end of a command, or the Claude Code hook as a
5
+ * system message after a command Passport handled. Taking is a rename, so two processes never print the same notice.
6
+ *
7
+ * Reading and taking never throw: a missing, corrupt or foreign-owned file is treated as empty.
8
+ */
9
+ export type LocalNotice = {
10
+ id: string;
11
+ text: string;
12
+ url?: string;
13
+ linkLabel?: string;
14
+ };
15
+ /** Validate notices from the server or the file; anything malformed is dropped, never thrown. */
16
+ export declare function parseNotices(value: unknown): LocalNotice[];
17
+ /** Keep notices the server just handed over, beside any not yet printed (newest kept when over the cap). */
18
+ export declare function saveLocalNotices(profile: string, notices: readonly LocalNotice[]): void;
19
+ /** Take every waiting notice, once: the file is renamed away first, so a parallel process finds nothing. */
20
+ export declare function takeLocalNotices(profile: string): LocalNotice[];
21
+ /** One notice as a person reads it: "Northwind · Priya Sharma asked you to … Open setup: https://…". */
22
+ export declare function noticeLine(notice: LocalNotice, workspace?: string): string;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * One-time notices for this person (docs/design/v21/requests.md section 9b; docs/design/v21/people.md section 4):
3
+ * `GET /api/cp/cli` hands them over once (`notices`, marked delivered by that read), the CLI keeps them in a private
4
+ * local file, and whichever prints first takes them: the CLI at the end of a command, or the Claude Code hook as a
5
+ * system message after a command Passport handled. Taking is a rename, so two processes never print the same notice.
6
+ *
7
+ * Reading and taking never throw: a missing, corrupt or foreign-owned file is treated as empty.
8
+ */
9
+ import { lstatSync, renameSync, rmSync } from "node:fs";
10
+ import { join } from "node:path";
11
+ import { readBoundedUtf8File } from "./boundedFile.js";
12
+ import { credentialDir, enforceOwner, writePrivateAtomic } from "./credentialStorage.js";
13
+ import { assertProfileName } from "./credentials.js";
14
+ const MAX_BYTES = 16 * 1024;
15
+ const MAX_KEPT = 10;
16
+ const ID = /^nt_[0-9a-f]{8,32}$/;
17
+ function safeUrl(value) {
18
+ if (typeof value !== "string" || value.length > 600)
19
+ return undefined;
20
+ try {
21
+ const url = new URL(value);
22
+ return url.protocol === "https:" || (url.protocol === "http:" && ["localhost", "127.0.0.1"].includes(url.hostname))
23
+ ? url.toString()
24
+ : undefined;
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ }
30
+ /** Validate notices from the server or the file; anything malformed is dropped, never thrown. */
31
+ export function parseNotices(value) {
32
+ if (!Array.isArray(value))
33
+ return [];
34
+ const out = [];
35
+ for (const entry of value.slice(0, MAX_KEPT)) {
36
+ if (!entry || typeof entry !== "object")
37
+ continue;
38
+ const { id, text, url, linkLabel } = entry;
39
+ if (typeof id !== "string" || !ID.test(id) || typeof text !== "string")
40
+ continue;
41
+ const line = text
42
+ .replace(/[\u0000-\u001f\u007f]+/g, " ")
43
+ .trim()
44
+ .slice(0, 200);
45
+ if (!line)
46
+ continue;
47
+ const link = safeUrl(url);
48
+ const label = typeof linkLabel === "string" ? linkLabel.replace(/[^\p{L}\p{N} ]+/gu, "").slice(0, 24) : undefined;
49
+ out.push({ id, text: line, ...(link ? { url: link } : {}), ...(link && label ? { linkLabel: label } : {}) });
50
+ }
51
+ return out;
52
+ }
53
+ function noticesPath(profile) {
54
+ assertProfileName(profile);
55
+ return join(credentialDir(), `notices-${profile}.json`);
56
+ }
57
+ function readFile(path) {
58
+ try {
59
+ enforceOwner(lstatSync(path), "notices");
60
+ return parseNotices(JSON.parse(readBoundedUtf8File(path, MAX_BYTES)));
61
+ }
62
+ catch {
63
+ return [];
64
+ }
65
+ }
66
+ /** Keep notices the server just handed over, beside any not yet printed (newest kept when over the cap). */
67
+ export function saveLocalNotices(profile, notices) {
68
+ if (!notices.length)
69
+ return;
70
+ try {
71
+ const path = noticesPath(profile);
72
+ const kept = readFile(path);
73
+ for (const notice of notices)
74
+ if (!kept.some((existing) => existing.id === notice.id))
75
+ kept.push(notice);
76
+ writePrivateAtomic(path, ".notices", `${JSON.stringify(kept.slice(-MAX_KEPT))}\n`, "notices");
77
+ }
78
+ catch {
79
+ /* A notice lost here is one line someone doesn't see; Slack and email still carry setup asks. */
80
+ }
81
+ }
82
+ /** Take every waiting notice, once: the file is renamed away first, so a parallel process finds nothing. */
83
+ export function takeLocalNotices(profile) {
84
+ try {
85
+ const path = noticesPath(profile);
86
+ const claimed = `${path}.${process.pid}.taking`;
87
+ renameSync(path, claimed);
88
+ const notices = readFile(claimed);
89
+ rmSync(claimed, { force: true });
90
+ return notices;
91
+ }
92
+ catch {
93
+ return [];
94
+ }
95
+ }
96
+ /** One notice as a person reads it: "Northwind · Priya Sharma asked you to … Open setup: https://…". */
97
+ export function noticeLine(notice, workspace) {
98
+ const link = notice.url ? ` ${notice.linkLabel || "Open"}: ${notice.url}` : "";
99
+ return `${workspace ? `${workspace} · ` : ""}${notice.text}${link}`;
100
+ }
@@ -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.45.0";
7
+ export declare const PLUGIN_PIN = "0.46.1";
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.45.0";
7
+ export const PLUGIN_PIN = "0.46.1";
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.45.0";
1
+ export declare const VERSION = "0.46.1";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Keep in lockstep with bridge/package.json.
2
- export const VERSION = "0.45.0";
2
+ export const VERSION = "0.46.1";
@@ -1,10 +1,27 @@
1
- export declare const ACTIVITY_LINK = "#cp/activity";
1
+ /**
2
+ * Links into the Passport web app for things the CLI names. The web app is
3
+ * served from the same origin as the profile's endpoint, and routes by hash.
4
+ * A member's own pages (docs/design/v21/member.md):
5
+ *
6
+ * #p My activity: what your agents did, and your apps
7
+ * #p?app=<key> My activity with one app highlighted under Your apps
8
+ * #cp/rules Allow and Block rules (an admin's page)
9
+ *
10
+ * A block's message carries the person's Why blocked link itself
11
+ * (`<origin>/b/<eventId>`), so the CLI prints no link of its own for it.
12
+ * Each returns null when the origin or page is unusable, so callers print a
13
+ * link only when they know exactly what it points at.
14
+ */
15
+ /** How long a connect or connections link lasts (the server's default; docs/design/v21/member.md, link lifetimes). */
16
+ export declare const LINK_MINUTES = 15;
17
+ /** The line under a connect link. */
18
+ export declare const CONNECT_LINK_LIFETIME = "Link expires in 15 minutes.";
19
+ /** My activity. */
20
+ export declare const MY_ACTIVITY_LINK = "#p";
2
21
  export declare const RULES_LINK = "#cp/rules";
3
- /** Apps: your connections page. */
4
- export declare const APPS_LINK = "#cp/connections";
22
+ /** My activity with `app` highlighted under Your apps (just My activity for a key that isn't one). */
23
+ export declare function myAppLink(app: string): string;
5
24
  /** `https://passportmcp.com` from an endpoint or origin, or null. */
6
25
  export declare function webOrigin(endpointOrOrigin: string | undefined): string | null;
7
- /** Where a block is answered: Blocked, in Passport. */
8
- export declare function approvalLink(origin: string | undefined, approvalId: string | undefined, _workspaceId?: string): string | null;
9
- /** A page the server named by its hash (`#cp/connections`), or null. */
26
+ /** A page the server named by its hash (`#p`), or null. */
10
27
  export declare function hashLink(origin: string | undefined, hash: unknown): string | null;
package/dist/webLinks.js CHANGED
@@ -1,20 +1,29 @@
1
1
  /**
2
2
  * Links into the Passport web app for things the CLI names. The web app is
3
- * served from the same origin as the profile's endpoint, and routes by hash:
3
+ * served from the same origin as the profile's endpoint, and routes by hash.
4
+ * A member's own pages (docs/design/v21/member.md):
4
5
  *
5
- * #cp/activity what agents did
6
- * #cp/rules Allow and Block rules
7
- * #cp/connections your apps and connections
8
- * #cp/blocked where an admin answers a block
6
+ * #p My activity: what your agents did, and your apps
7
+ * #p?app=<key> My activity with one app highlighted under Your apps
8
+ * #cp/rules Allow and Block rules (an admin's page)
9
9
  *
10
- * Each returns null when the origin or id is unusable, so callers print a link
11
- * only when they know exactly what it points at.
10
+ * A block's message carries the person's Why blocked link itself
11
+ * (`<origin>/b/<eventId>`), so the CLI prints no link of its own for it.
12
+ * Each returns null when the origin or page is unusable, so callers print a
13
+ * link only when they know exactly what it points at.
12
14
  */
13
- const ID = /^[A-Za-z0-9_.:~-]{1,128}$/;
14
- export const ACTIVITY_LINK = "#cp/activity";
15
+ /** How long a connect or connections link lasts (the server's default; docs/design/v21/member.md, link lifetimes). */
16
+ export const LINK_MINUTES = 15;
17
+ /** The line under a connect link. */
18
+ export const CONNECT_LINK_LIFETIME = `Link expires in ${LINK_MINUTES} minutes.`;
19
+ /** My activity. */
20
+ export const MY_ACTIVITY_LINK = "#p";
15
21
  export const RULES_LINK = "#cp/rules";
16
- /** Apps: your connections page. */
17
- export const APPS_LINK = "#cp/connections";
22
+ const APP_KEY = /^[a-z0-9][a-z0-9._-]{0,63}$/;
23
+ /** My activity with `app` highlighted under Your apps (just My activity for a key that isn't one). */
24
+ export function myAppLink(app) {
25
+ return APP_KEY.test(app) ? `${MY_ACTIVITY_LINK}?app=${encodeURIComponent(app)}` : MY_ACTIVITY_LINK;
26
+ }
18
27
  /** `https://passportmcp.com` from an endpoint or origin, or null. */
19
28
  export function webOrigin(endpointOrOrigin) {
20
29
  if (!endpointOrOrigin)
@@ -27,17 +36,7 @@ export function webOrigin(endpointOrOrigin) {
27
36
  return null;
28
37
  }
29
38
  }
30
- function usable(id) {
31
- return typeof id === "string" && ID.test(id);
32
- }
33
- /** Where a block is answered: Blocked, in Passport. */
34
- export function approvalLink(origin, approvalId, _workspaceId) {
35
- const base = webOrigin(origin);
36
- if (!base || !usable(approvalId))
37
- return null;
38
- return `${base}/#cp/blocked`;
39
- }
40
- /** A page the server named by its hash (`#cp/connections`), or null. */
39
+ /** A page the server named by its hash (`#p`), or null. */
41
40
  export function hashLink(origin, hash) {
42
41
  const base = webOrigin(origin);
43
42
  if (!base || typeof hash !== "string" || !/^#[A-Za-z0-9_.~%/?=&-]{1,200}$/.test(hash))
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "passport-bridge",
3
- "version": "0.45.0",
3
+ "version": "0.46.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "passport-bridge",
9
- "version": "0.45.0",
9
+ "version": "0.46.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@modelcontextprotocol/sdk": "1.32.1"
@@ -363,9 +363,9 @@
363
363
  }
364
364
  },
365
365
  "node_modules/@hono/node-server": {
366
- "version": "2.1.5",
367
- "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.5.tgz",
368
- "integrity": "sha512-MgP/I06GdvsilDspMk/qmRzpk8LOUStP6jFAbSRi40W09DhoyUn+Mj7eyKICPqeYKybOjVFLVIAQzvu1bfIa7Q==",
366
+ "version": "2.1.6",
367
+ "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.6.tgz",
368
+ "integrity": "sha512-p/KH9MnfNcsm3sR6x4lNgm5j+QN4Et8srKredl9DZfXiyZ1UQ3aQ2YVpFLbqktYN5JI+DB+VZFKM2PqE5hLKjQ==",
369
369
  "license": "MIT",
370
370
  "engines": {
371
371
  "node": ">=20"
@@ -998,9 +998,9 @@
998
998
  }
999
999
  },
1000
1000
  "node_modules/hono": {
1001
- "version": "4.13.7",
1002
- "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.7.tgz",
1003
- "integrity": "sha512-c8/gF9ac8Y78/agExVocyLevgR+JlpNB444Py0FSX8pJoPdYUfUzRcXtYEYGwt6l19qIlVZPN5Mfsw9jFShmQQ==",
1001
+ "version": "4.13.16",
1002
+ "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.16.tgz",
1003
+ "integrity": "sha512-AOLOEhvrV+iH92xXCnFr/5+3KjPKcI3xP63XJtX5spAnkznPdHijlIsUTpi7/9EhWqrTCekw5c5zh1K+YsVw7A==",
1004
1004
  "license": "MIT",
1005
1005
  "engines": {
1006
1006
  "node": ">=16.9.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passport-bridge",
3
- "version": "0.45.0",
3
+ "version": "0.46.1",
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": {
@@ -1,5 +0,0 @@
1
- import type { ParsedArgs } from "./cliArgs.js";
2
- import { type CliFailure, type Env } from "./cliSupport.js";
3
- /** A failure that names an approval also names where to answer it. Returns
4
- * the same failure, so the CLI's catch can link it in one step. */
5
- export declare function linkApproval(error: CliFailure, args: ParsedArgs | undefined, env: Env): CliFailure;