passport-bridge 0.35.1 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +13 -0
  2. package/dist/cliArgs.d.ts +1 -1
  3. package/dist/cliArgs.js +2 -1
  4. package/dist/cliAutopilotPolicy.d.ts +2 -0
  5. package/dist/cliConnections.d.ts +40 -0
  6. package/dist/cliConnections.js +125 -0
  7. package/dist/cliExec.d.ts +1 -2
  8. package/dist/cliExec.js +17 -38
  9. package/dist/cliGitCredential.js +28 -10
  10. package/dist/cliHookDecide.js +36 -16
  11. package/dist/cliMain.js +2 -0
  12. package/dist/cliOutput.js +6 -0
  13. package/dist/cliPolicyV2.js +6 -4
  14. package/dist/cliResult.js +6 -2
  15. package/dist/completion.js +1 -0
  16. package/dist/connectorKit/cli.generated.d.ts +15 -0
  17. package/dist/connectorKit/cli.generated.js +244 -0
  18. package/dist/connectorKit/engine.generated.d.ts +50 -0
  19. package/dist/connectorKit/engine.generated.js +475 -0
  20. package/dist/connectorKit/manifest.generated.d.ts +317 -0
  21. package/dist/connectorKit/manifest.generated.js +18 -0
  22. package/dist/connectorKit/manifests/flagSpec.generated.d.ts +6 -0
  23. package/dist/connectorKit/manifests/flagSpec.generated.js +20 -0
  24. package/dist/connectorKit/manifests/github.generated.d.ts +17 -0
  25. package/dist/connectorKit/manifests/github.generated.js +82 -0
  26. package/dist/connectorKit/manifests/githubCapture.generated.d.ts +2 -0
  27. package/dist/connectorKit/manifests/githubCapture.generated.js +307 -0
  28. package/dist/connectorKit/manifests/githubHooks.generated.d.ts +23 -0
  29. package/dist/connectorKit/manifests/githubHooks.generated.js +401 -0
  30. package/dist/connectorKit/manifests/githubReads.generated.d.ts +6 -0
  31. package/dist/connectorKit/manifests/githubReads.generated.js +200 -0
  32. package/dist/connectorKit/manifests/railway.generated.d.ts +6 -0
  33. package/dist/connectorKit/manifests/railway.generated.js +121 -0
  34. package/dist/connectorKit/manifests/railwayCapture.generated.d.ts +3 -0
  35. package/dist/connectorKit/manifests/railwayCapture.generated.js +375 -0
  36. package/dist/connectorKit/manifests/railwayHooks.generated.d.ts +25 -0
  37. package/dist/connectorKit/manifests/railwayHooks.generated.js +487 -0
  38. package/dist/connectorKit/manifests/supabase.generated.d.ts +3 -0
  39. package/dist/connectorKit/manifests/supabase.generated.js +34 -0
  40. package/dist/connectorKit/manifests/supabaseApi.generated.d.ts +3 -0
  41. package/dist/connectorKit/manifests/supabaseApi.generated.js +632 -0
  42. package/dist/connectorKit/manifests/supabaseCapture.generated.d.ts +9 -0
  43. package/dist/connectorKit/manifests/supabaseCapture.generated.js +421 -0
  44. package/dist/connectorKit/manifests/supabaseCatalog.generated.d.ts +11 -0
  45. package/dist/connectorKit/manifests/supabaseCatalog.generated.js +70 -0
  46. package/dist/connectorKit/manifests/supabaseCli.generated.d.ts +10 -0
  47. package/dist/connectorKit/manifests/supabaseCli.generated.js +581 -0
  48. package/dist/connectorKit/manifests/supabasePlatform.generated.d.ts +7 -0
  49. package/dist/connectorKit/manifests/supabasePlatform.generated.js +283 -0
  50. package/dist/connectorKit/manifests/supabaseProbes.generated.d.ts +5 -0
  51. package/dist/connectorKit/manifests/supabaseProbes.generated.js +580 -0
  52. package/dist/connectorKit/params.generated.d.ts +25 -0
  53. package/dist/connectorKit/params.generated.js +193 -0
  54. package/dist/connectorKit/pgParser.d.ts +9 -0
  55. package/dist/connectorKit/pgParser.js +13 -0
  56. package/dist/connectorKit/shadow.generated.d.ts +58 -0
  57. package/dist/connectorKit/shadow.generated.js +184 -0
  58. package/dist/connectorKit/shell.generated.d.ts +73 -0
  59. package/dist/connectorKit/shell.generated.js +516 -0
  60. package/dist/connectorKit/sourcegen.generated.d.ts +50 -0
  61. package/dist/connectorKit/sourcegen.generated.js +208 -0
  62. package/dist/connectorKit/sources/supabase/api-operations.generated.d.ts +187 -0
  63. package/dist/connectorKit/sources/supabase/api-operations.generated.js +2 -0
  64. package/dist/connectorKit/sources/supabase/cli-flags.generated.d.ts +1236 -0
  65. package/dist/connectorKit/sources/supabase/cli-flags.generated.js +2 -0
  66. package/dist/connectorKit/sources/supabase/mcp-tools.generated.d.ts +35 -0
  67. package/dist/connectorKit/sources/supabase/mcp-tools.generated.js +2 -0
  68. package/dist/connectorKit/sql.generated.d.ts +29 -0
  69. package/dist/connectorKit/sql.generated.js +420 -0
  70. package/dist/connectorKit/sqlFingerprint.generated.d.ts +8 -0
  71. package/dist/connectorKit/sqlFingerprint.generated.js +105 -0
  72. package/dist/connectorKit/template.generated.d.ts +21 -0
  73. package/dist/connectorKit/template.generated.js +89 -0
  74. package/dist/connectorKit/types.generated.d.ts +81 -0
  75. package/dist/connectorKit/types.generated.js +6 -0
  76. package/dist/controlPlane.generated.d.ts +46 -2
  77. package/dist/controlPlane.generated.js +10 -1
  78. package/dist/controlPlaneExec.d.ts +21 -2
  79. package/dist/controlPlaneExec.js +83 -5
  80. package/dist/controlPlaneGithub.generated.js +4 -8
  81. package/dist/controlPlaneGuard.js +29 -4
  82. package/dist/controlPlaneIds.d.ts +39 -0
  83. package/dist/controlPlaneIds.js +175 -0
  84. package/dist/controlPlaneModel.generated.d.ts +67 -0
  85. package/dist/controlPlaneModel.generated.js +153 -0
  86. package/dist/controlPlaneRailwayGuard.js +13 -3
  87. package/dist/controlPlaneSupabase.d.ts +84 -0
  88. package/dist/controlPlaneSupabase.js +278 -0
  89. package/dist/execGithubRepo.d.ts +2 -0
  90. package/dist/execGithubRepo.js +30 -0
  91. package/dist/gitPush.d.ts +20 -0
  92. package/dist/gitPush.js +45 -7
  93. package/dist/kitShadow.d.ts +90 -0
  94. package/dist/kitShadow.js +261 -0
  95. package/dist/kitShadowBudget.d.ts +10 -0
  96. package/dist/kitShadowBudget.js +15 -0
  97. package/dist/pluginPin.d.ts +1 -1
  98. package/dist/pluginPin.js +1 -1
  99. package/dist/supabaseDecisions.d.ts +9 -0
  100. package/dist/supabaseDecisions.js +98 -0
  101. package/dist/version.d.ts +1 -1
  102. package/dist/version.js +1 -1
  103. package/npm-shrinkwrap.json +2 -2
  104. package/package.json +1 -1
package/README.md CHANGED
@@ -63,6 +63,7 @@ passport run github_search_issues '{"query":"SSO"}'
63
63
  | `describe <tool>` | One exact definition with its full parameter schema. |
64
64
  | `run <tool> [json]` | Run a tool through Passport governance. |
65
65
  | `connect [app...] [--alias <name>] [--open] [--wait <s>]` | Show member sign-in links and optionally wait for completion. |
66
+ | `connections [app] [--no-open]` | What's connected for you and what still needs you, then your connections page in the browser. See [Your connections](#your-connections). |
66
67
  | `request <app> [--full] --reason "<why>"` | Ask an admin for an app you don't have, or for Full access where you have Read-only. A person decides in Passport; nothing is granted here. See [Asking for access](#asking-for-access). |
67
68
  | `resources [uri] [--out <file>]` | List or read MCP resources. |
68
69
  | `prompts [name] [--set k=v] [--out <file>]` | List or get MCP prompts. |
@@ -105,6 +106,18 @@ passport connect github --wait 120
105
106
  - The CLI never retries after a network failure or timeout, since the outcome is unknown.
106
107
  - `connect` with no app names uses one aggregate link when several apps need sign-in. Agent tokens get guidance but cannot create sign-in links.
107
108
 
109
+ ### Your connections
110
+
111
+ ```sh
112
+ passport connections
113
+ passport connections github
114
+ ```
115
+
116
+ - Lists every app you're granted: `Connected as you`, `Needs connecting`, `Ready · connected by your company` (no sign-in of yours), or `Waiting on your admin`. Apps that need you come first; a named app comes before them.
117
+ - Then opens your connections page in the browser (`#cp/connections`), where Connect and Reconnect start your own sign-in with the app. `--no-open` and `--json` print the link instead. The link works for 10 minutes and never signs a browser in: it goes through your workspace's sign-in when the browser isn't signed in, and refuses a browser signed in as someone else.
118
+ - When the CLI or an agent is refused because an app needs connecting, the refusal names `passport connections <app>`; the MCP's `passport_manage_connections` returns the same page as `connectionsUrl`.
119
+ - `--json`: `{workspace,apps:[{app,name,status,connectedAs?}],needsYou,url?,expiresAt?,opened}`. Agent tokens have no connections page (exit 6, `member_profile_required`).
120
+
108
121
  ### Asking for access
109
122
 
110
123
  ```sh
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", "request", "resources", "prompts", "discover", "scan", "hook", "wait", "rules", "actions", "tasks", "changes", "env", "where", "sync", "exec", "kube-credential", "git-credential", "undo", "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", "wait", "rules", "actions", "tasks", "changes", "env", "where", "sync", "exec", "kube-credential", "git-credential", "undo", "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. */
package/dist/cliArgs.js CHANGED
@@ -12,6 +12,7 @@ export const COMMANDS = [
12
12
  "describe",
13
13
  "run",
14
14
  "connect",
15
+ "connections",
15
16
  "request",
16
17
  "resources",
17
18
  "prompts",
@@ -57,7 +58,7 @@ const FLAGS = {
57
58
  apply: { kind: "boolean", commands: ["setup", "hook"] },
58
59
  guard: { kind: "boolean", commands: ["hook"] },
59
60
  hold: { kind: "value", commands: ["hook"] },
60
- "no-open": { kind: "boolean", commands: ["login", "init"] },
61
+ "no-open": { kind: "boolean", commands: ["login", "init", "connections"] },
61
62
  yes: { kind: "boolean", commands: ["init", "setup", "keys", "undo", "actions"] },
62
63
  // `init --org` is setup for MDM; `setup --org` still runs it for one release.
63
64
  org: { kind: "value", commands: ["init", "setup"] },
@@ -236,6 +236,8 @@ export type AutopilotPolicy = {
236
236
  controlPlaneGithub?: boolean;
237
237
  /** The control plane: Railway is connected (cli-policy v2 `controlPlane.railway`). */
238
238
  controlPlaneRailway?: boolean;
239
+ /** The control plane: Supabase is connected (cli-policy v2 `controlPlane.supabase`). */
240
+ controlPlaneSupabase?: boolean;
239
241
  /** Known project scripts (Batch A item 5), vendor `project`: they set class
240
242
  * and environment only, never an allow. */
241
243
  project?: {
@@ -0,0 +1,40 @@
1
+ /**
2
+ * `passport connections [app] [--no-open]`: the developer's own connections, in the terminal and
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
5
+ * link never signs a browser in by itself: the page still needs the person's own sign-in.
6
+ *
7
+ * passport connections every app, and the page
8
+ * passport connections github the page with GitHub highlighted
9
+ *
10
+ * Agent hooks and the MCP point here when a connection is missing.
11
+ */
12
+ import { type ParsedArgs } from "./cliArgs.js";
13
+ import { type GatewayRunner } from "./cliConnect.js";
14
+ import { type AutopilotDependencies } from "./cliMemberCall.js";
15
+ import { type CommandResult, type Runtime } from "./cliSupport.js";
16
+ import { type Term } from "./term.js";
17
+ /** One app as `passport connections --json` reports it. */
18
+ export type ConnectionsRow = {
19
+ app: string;
20
+ name: string;
21
+ status: "connected" | "needs_your_signin" | "needs_setup" | "org_managed" | string;
22
+ connectedAs?: string;
23
+ /** Signed in before, but the sign-in stopped working. */
24
+ reconnect?: true;
25
+ };
26
+ export type ConnectionsJson = {
27
+ workspace: string;
28
+ apps: ConnectionsRow[];
29
+ needsYou: number;
30
+ /** The page's link: lasts ten minutes. Absent when Passport couldn't make one. */
31
+ url?: string;
32
+ expiresAt?: number;
33
+ opened: boolean;
34
+ };
35
+ export type ConnectionsDependencies = AutopilotDependencies & {
36
+ open?: (url: string) => boolean;
37
+ term?: Term;
38
+ };
39
+ export declare function connectionsScreen(term: Term, view: ConnectionsJson, focus: string | undefined, linkNote: "opened" | "printed" | "none"): string;
40
+ export declare function connections(args: ParsedArgs, runtime: Runtime, withGateway: GatewayRunner, deps?: ConnectionsDependencies): Promise<CommandResult>;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * `passport connections [app] [--no-open]`: the developer's own connections, in the terminal and
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
5
+ * link never signs a browser in by itself: the page still needs the person's own sign-in.
6
+ *
7
+ * passport connections every app, and the page
8
+ * passport connections github the page with GitHub highlighted
9
+ *
10
+ * Agent hooks and the MCP point here when a connection is missing.
11
+ */
12
+ import { bool } from "./cliArgs.js";
13
+ import { managePayload } from "./cliConnect.js";
14
+ import { api } from "./cliMemberCall.js";
15
+ import { failure, openUrl, readBoundedJson, resolveCliAuth, timeoutMs } from "./cliSupport.js";
16
+ import { countOf } from "./plural.js";
17
+ import { mark, table, termOf, wrap } from "./term.js";
18
+ const USAGE = "Use: passport connections [app] [--no-open]";
19
+ const APP_KEY = /^[a-z0-9][a-z0-9._-]{0,63}$/;
20
+ function rowsOf(connections) {
21
+ return connections.map((row) => ({
22
+ app: String(row.app ?? ""),
23
+ name: String(row.name ?? row.app ?? "app"),
24
+ status: String(row.status ?? "unknown"),
25
+ ...(typeof row.connectedAs === "string" && row.connectedAs ? { connectedAs: row.connectedAs } : {}),
26
+ ...(row.reconnect === true ? { reconnect: true } : {})
27
+ }));
28
+ }
29
+ /** The status in the page's words, and the house mark for it. */
30
+ function said(row) {
31
+ switch (row.status) {
32
+ case "connected":
33
+ return { mark: "done", words: row.connectedAs ? `Connected as you · ${row.connectedAs}` : "Connected as you" };
34
+ case "org_managed":
35
+ return { mark: "done", words: "Ready · connected by your company" };
36
+ case "needs_your_signin":
37
+ return { mark: "warn", words: row.reconnect ? "Needs reconnecting" : "Needs connecting" };
38
+ case "needs_setup":
39
+ return { mark: "skip", words: "Waiting on your admin" };
40
+ default:
41
+ return { mark: "skip", words: row.status.replace(/_/g, " ") };
42
+ }
43
+ }
44
+ const ORDER = { needs_your_signin: 0, connected: 1, org_managed: 2, needs_setup: 3 };
45
+ async function mintLink(args, runtime, deps, app) {
46
+ try {
47
+ const response = await api(args, runtime, deps).fetchApi("/api/my/connections-link", {
48
+ method: "POST",
49
+ headers: { "content-type": "application/json", accept: "application/json" },
50
+ body: JSON.stringify(app ? { app } : {}),
51
+ signal: AbortSignal.any([runtime.signal, AbortSignal.timeout(timeoutMs(args))])
52
+ });
53
+ if (!response.ok) {
54
+ await response.body?.cancel().catch(() => undefined);
55
+ return undefined;
56
+ }
57
+ const answer = await readBoundedJson(response);
58
+ if (typeof answer.url !== "string" || !/^https?:\/\//.test(answer.url))
59
+ return undefined;
60
+ return { url: answer.url, expiresAt: typeof answer.expiresAt === "number" ? answer.expiresAt : 0 };
61
+ }
62
+ catch (error) {
63
+ if (runtime.signal.aborted)
64
+ throw error;
65
+ return undefined;
66
+ }
67
+ }
68
+ export function connectionsScreen(term, view, focus, linkNote) {
69
+ const lines = [];
70
+ const width = term.width;
71
+ lines.push(...wrap(`Your connections in ${view.workspace}`, width));
72
+ const rows = [...view.apps].sort((a, b) => Number(b.app === focus) - Number(a.app === focus) ||
73
+ (ORDER[a.status] ?? 9) - (ORDER[b.status] ?? 9) ||
74
+ a.name.localeCompare(b.name));
75
+ if (!rows.length)
76
+ lines.push(" No apps yet. Your admin adds them.");
77
+ lines.push(...table(rows.map((row) => {
78
+ const { mark: kind, words } = said(row);
79
+ return [` ${mark(term, kind)} ${row.name}`, words];
80
+ }), width));
81
+ lines.push("");
82
+ if (view.needsYou)
83
+ lines.push(...wrap(`${countOf(view.needsYou, "app")} need${view.needsYou === 1 ? "s" : ""} you.`, width));
84
+ if (linkNote === "opened")
85
+ lines.push(...wrap("Opened your connections page in your browser.", width));
86
+ if (view.url && linkNote !== "none") {
87
+ 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));
89
+ }
90
+ else if (!view.url) {
91
+ lines.push(...wrap("Couldn't make a link to your connections page. Connect from here instead:", width));
92
+ lines.push(`Run: passport connect${focus ? ` ${focus}` : ""}`);
93
+ }
94
+ return lines.join("\n");
95
+ }
96
+ export async function connections(args, runtime, withGateway, deps = {}) {
97
+ const [requested, extra] = args.positionals;
98
+ const focus = requested?.trim().toLowerCase();
99
+ if (extra !== undefined || (focus !== undefined && !APP_KEY.test(focus))) {
100
+ return failure("Name one app by its key, like github or linear.", 6, "usage", { hint: USAGE });
101
+ }
102
+ if (!deps.api && resolveCliAuth(args, runtime.env).kind !== "profile") {
103
+ return failure("Your connections page is a person's. Agent tokens have none.", 6, "member_profile_required", {
104
+ hint: "Run: passport login"
105
+ });
106
+ }
107
+ const managed = await withGateway(args, runtime, async (gateway) => managePayload(await gateway.callTool("passport_manage_connections", { includeLinks: false })));
108
+ // An app that isn't granted still opens the page, which offers Request when the catalog has it.
109
+ const apps = rowsOf(managed.connections);
110
+ const link = await mintLink(args, runtime, deps, focus);
111
+ const shouldOpen = Boolean(link) && !bool(args, "no-open") && !bool(args, "json");
112
+ const opened = shouldOpen ? (deps.open ?? openUrl)(link.url) : false;
113
+ const view = {
114
+ workspace: managed.workspace.name,
115
+ apps,
116
+ needsYou: apps.filter((row) => row.status === "needs_your_signin").length,
117
+ ...(link ? { url: link.url, expiresAt: link.expiresAt } : {}),
118
+ opened
119
+ };
120
+ const term = deps.term ?? termOf(runtime.stdout, runtime.env);
121
+ return {
122
+ json: view,
123
+ human: connectionsScreen(term, view, focus, link ? (opened ? "opened" : "printed") : "none")
124
+ };
125
+ }
package/dist/cliExec.d.ts CHANGED
@@ -42,6 +42,7 @@ export type ExecDependencies = {
42
42
  home?: string;
43
43
  };
44
44
  export { execTarget };
45
+ export { githubRepo } from "./execGithubRepo.js";
45
46
  /** The classified finding the server decides on: vendor, verb, risk, environment. */
46
47
  export declare function execFinding(vendor: ExecVendor, binary: string, args: readonly string[], policy: ReturnType<typeof readCliPolicy>, where?: WhereContext): {
47
48
  vendor: string;
@@ -49,8 +50,6 @@ export declare function execFinding(vendor: ExecVendor, binary: string, args: re
49
50
  risk: string;
50
51
  environment?: string;
51
52
  } & Record<string, string>;
52
- /** gh acts on `--repo owner/name`, or the folder's GitHub origin. */
53
- export declare function githubRepo(args: readonly string[], cwd: string): string | undefined;
54
53
  /** Only the vendor's own variables, as plain single-line strings. None for a Railway read Passport sends with the
55
54
  * person's own sign-in (`ownSignIn`: Passport mints only for actions). */
56
55
  export declare function checkedCredential(vendor: ExecVendor, raw: unknown, ownSignIn?: unknown): Record<string, string>;
package/dist/cliExec.js CHANGED
@@ -18,13 +18,12 @@
18
18
  * with it are refused before anything is sent.
19
19
  */
20
20
  import { projectOf } from "./cliHookProject.js";
21
- import { readFileSync } from "node:fs";
22
21
  import { homedir } from "node:os";
23
- import { basename, dirname, join, resolve } from "node:path";
22
+ import { basename } from "node:path";
24
23
  import { bool, value } from "./cliArgs.js";
25
24
  import { memberApi } from "./cliClient.js";
26
25
  import { passportUnreachable } from "./cliOutput.js";
27
- import { execControlPlaneRefusal, execRailwayScope, execRelease } from "./controlPlaneExec.js";
26
+ import { execControlPlaneRefusal, execIdsWanted, execRailwayScope, execRelease } from "./controlPlaneExec.js";
28
27
  import { classifyCommand, UNRECOGNIZED_VERB } from "./cliHookClassify.js";
29
28
  import { reportedEnvironment } from "./cliHookEnvironment.js";
30
29
  import { localMachine } from "./cliHookLocal.js";
@@ -40,6 +39,7 @@ import { execTarget } from "./execTarget.js";
40
39
  import { carrierOf, ownFinding, withExecPlan } from "./execPlan.js";
41
40
  import { secretNeedles } from "./execMask.js";
42
41
  import { spawnVendor } from "./execSpawn.js";
42
+ import { shadowAfterDecision } from "./kitShadow.js";
43
43
  export { spawnVendor } from "./execSpawn.js";
44
44
  import { findVendorBinary, removeShims } from "./execShims.js";
45
45
  import { approvalLink, hashLink } from "./webLinks.js";
@@ -52,8 +52,9 @@ export const EXEC_WAIT_DEFAULT_SECONDS = 100;
52
52
  const WAIT_POLL_SECONDS = 30;
53
53
  const SESSION = /^[A-Za-z0-9._:-]{1,128}$/;
54
54
  const RUNTIME = /^[a-z0-9-]{1,24}$/;
55
- const REPO = /^[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.-]{1,100}$/;
56
55
  export { execTarget };
56
+ export { githubRepo } from "./execGithubRepo.js";
57
+ import { githubRepo } from "./execGithubRepo.js";
57
58
  function quote(part) {
58
59
  return /^[A-Za-z0-9_@%+=:,./-]+$/.test(part) ? part : `'${part.replaceAll("'", `'\\''`)}'`;
59
60
  }
@@ -108,33 +109,6 @@ function execWhere(cwd, env) {
108
109
  fs: NODE_LINK_FS
109
110
  };
110
111
  }
111
- /** gh acts on `--repo owner/name`, or the folder's GitHub origin. */
112
- export function githubRepo(args, cwd) {
113
- for (let index = 0; index < args.length; index++) {
114
- const arg = args[index];
115
- const inline = arg.match(/^(?:--repo|-R)=(.+)$/);
116
- const candidate = inline ? inline[1] : arg === "--repo" || arg === "-R" ? args[index + 1] : undefined;
117
- if (candidate)
118
- return REPO.test(candidate) ? candidate : undefined;
119
- }
120
- let dir = resolve(cwd);
121
- for (let depth = 0; depth < 20; depth++) {
122
- try {
123
- const text = readFileSync(join(dir, ".git", "config"), "utf8").slice(0, 64 * 1024);
124
- const origin = text.match(/\[remote "origin"\][^[]*?url\s*=\s*(\S+)/);
125
- const match = origin?.[1]?.match(/github\.com[:/]([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/);
126
- const repo = match ? `${match[1]}/${match[2]}` : undefined;
127
- return repo && REPO.test(repo) ? repo : undefined;
128
- }
129
- catch {
130
- const parent = dirname(dir);
131
- if (parent === dir)
132
- return undefined;
133
- dir = parent;
134
- }
135
- }
136
- return undefined;
137
- }
138
112
  /** Only the vendor's own variables, as plain single-line strings. None for a Railway read Passport sends with the
139
113
  * person's own sign-in (`ownSignIn`: Passport mints only for actions). */
140
114
  export function checkedCredential(vendor, raw, ownSignIn) {
@@ -489,14 +463,15 @@ export async function exec(args, runtime, deps = {}) {
489
463
  const startedAt = (deps.now ?? Date.now)();
490
464
  // Links (bridge 0.32.0): a bounded copy of what it prints, only when that isn't a terminal.
491
465
  const wanted = linksWanted(auth.kind === "profile" ? readCliPolicy(auth.profile) : null);
492
- const capture = execCapture(wanted, runtime.stdout);
466
+ const capture = execCapture(execIdsWanted(vendor, decided, wanted), runtime.stdout);
493
467
  try {
494
468
  const credential = checkedCredential(vendor, decided.credential?.env, decided.credential?.ownSignIn);
495
469
  remember(true);
496
- // The control plane (GitHub connected) decides a gh command with its token's id.
497
- await execControlPlaneRefusal(client.fetchApi, prepared, decided, timeoutMs(args), {
470
+ // The control plane decides a gh command with its token's id, and a supabase command (unless the guard did).
471
+ const ids = await execControlPlaneRefusal(client.fetchApi, prepared, decided, timeoutMs(args), {
498
472
  ...(runtime.signal ? { signal: runtime.signal } : {}),
499
- asks: auth.kind === "profile"
473
+ asks: auth.kind === "profile",
474
+ env: runtime.env
500
475
  });
501
476
  // A dev loop runs only with a key that expires within minutes.
502
477
  const devLoop = devLoopRefusal(vendor, args.positionals.slice(1), decided.credential?.issuance);
@@ -519,9 +494,12 @@ export async function exec(args, runtime, deps = {}) {
519
494
  // One deploy at a time: renew the lease Passport took while it runs, release it after.
520
495
  const lease = (await import("./execLease.js")).keepLease(client.fetchApi, decided.leaseId);
521
496
  try {
522
- code = deps.spawn
523
- ? await deps.spawn(prepared.executable, prepared.rest, options)
524
- : await spawnVendor(prepared.executable, prepared.rest, options, piped);
497
+ const running = deps.spawn
498
+ ? deps.spawn(prepared.executable, prepared.rest, options)
499
+ : spawnVendor(prepared.executable, prepared.rest, options, piped);
500
+ // Decided and started: the kit's shadow run reads the command now (`kitShadow.ts`), off both.
501
+ shadowAfterDecision();
502
+ code = await running;
525
503
  }
526
504
  catch {
527
505
  return failure(`${binary} couldn't start.`, 1, "not_installed");
@@ -530,6 +508,7 @@ export async function exec(args, runtime, deps = {}) {
530
508
  await lease.stop();
531
509
  await handed.stop();
532
510
  }
511
+ await ids.report(capture, code);
533
512
  }
534
513
  finally {
535
514
  await issued.release();
@@ -37,6 +37,7 @@ import { compareVersions } from "./launcherHealth.js";
37
37
  import { VERSION } from "./version.js";
38
38
  import { askingGitCommand, execGitCommand, isPush } from "./gitInvocation.js";
39
39
  import { MAX_PUSH_REFS, planKey, planPush } from "./gitPush.js";
40
+ import { beginShadowLine, shadowAfterDecision, shadowAlongside, shadowGithubLine } from "./kitShadow.js";
40
41
  import { takePushDecisions } from "./gitPushDecisions.js";
41
42
  import { helperLine, helperProgram, installGitCredential, probeHelper, readGitCredentialState, removeGitCredential } from "./gitCredentialSetup.js";
42
43
  export const GIT_CREDENTIAL_PATH = "/api/my/github/git-credential";
@@ -268,10 +269,12 @@ async function get(args, runtime, deps, input) {
268
269
  }
269
270
  // A push: what it changes, ref by ref. Only the classification leaves this computer.
270
271
  const [owner, name] = repo.split("/");
272
+ const lines = [];
271
273
  const plan = planPush(asking, {
272
274
  cwd: deps.cwd ?? process.cwd(),
273
275
  env: runtime.env,
274
276
  repo: { owner, repo: name },
277
+ onLine: (line) => void lines.push(line),
275
278
  ...(deps.run ? { run: deps.run } : {})
276
279
  });
277
280
  if (!plan)
@@ -282,26 +285,41 @@ async function get(args, runtime, deps, input) {
282
285
  if (got.kind !== "refused" || got.code !== "undecided")
283
286
  return got.kind === "token" ? answer(got.minted) : refused(got);
284
287
  // Passport would issue a push token once it decides the push: every ref, and
285
- // a block on any stops git here.
286
- const decisionIds = [];
287
- for (const classification of plan.classifications.slice(0, MAX_PUSH_REFS)) {
288
+ // a block on any stops git here. Deciding it here (no guard did), the shadow run reads it too.
289
+ beginShadowLine();
290
+ for (const line of lines)
291
+ shadowGithubLine(line.argv, line.place, line.found);
292
+ // The shadow's counts ride along with these decisions, never waited on: stopped once they're answered.
293
+ const stopShadow = shadowAlongside(api, runtime.signal);
294
+ const decided = await decidePush(api, plan.classifications, runtime, deps, left).finally(stopShadow);
295
+ shadowAfterDecision();
296
+ if (decided.kind === "block")
297
+ return "quit=1\n";
298
+ if (decided.kind === "own")
299
+ return ownSignIn(decided.why);
300
+ got = await mint(api, repo, "write", runtime.signal, left(), { decisionIds: decided.ids });
301
+ return got.kind === "token" ? answer(got.minted) : refused(got);
302
+ }
303
+ /** Every ref of a push decided, in order: its decision ids, a block (git stops), or why it runs with the person's own sign-in. */
304
+ async function decidePush(api, classifications, runtime, deps, left) {
305
+ const ids = [];
306
+ for (const classification of classifications.slice(0, MAX_PUSH_REFS)) {
288
307
  const wait = Math.min(deps.decideTimeoutMs ?? DECIDE_TIMEOUT_MS, left());
289
308
  if (wait <= 0)
290
- return ownSignIn("Passport couldn't decide this push in time, so");
309
+ return { kind: "own", why: "Passport couldn't decide this push in time, so" };
291
310
  const decided = await within(wait, runtime.signal, (bounded) => askControlPlane(api, classification, {}, bounded));
292
311
  if (decided.kind === "block") {
293
312
  runtime.stderr.write(`passport: ${decided.message.replace(/\s*\n\s*/g, " ")}\n`);
294
313
  // quit=1: git stops here, without trying another helper or asking for a password.
295
- return "quit=1\n";
314
+ return { kind: "block" };
296
315
  }
297
316
  if (decided.kind !== "allow")
298
- return ownSignIn("Passport couldn't decide this push in time, so");
317
+ return { kind: "own", why: "Passport couldn't decide this push in time, so" };
299
318
  if (!decided.decisionId)
300
- return ownSignIn("Passport didn't record a decision for this push, so");
301
- decisionIds.push(decided.decisionId);
319
+ return { kind: "own", why: "Passport didn't record a decision for this push, so" };
320
+ ids.push(decided.decisionId);
302
321
  }
303
- got = await mint(api, repo, "write", runtime.signal, left(), { decisionIds });
304
- return got.kind === "token" ? answer(got.minted) : refused(got);
322
+ return { kind: "ids", ids };
305
323
  }
306
324
  /**
307
325
  * The asker is unknown: a read-only token, which Passport records as an
@@ -24,6 +24,8 @@ import { endedSessionLine, haltOnEnded, haltsOnEnd } from "./cliHookSessionEnd.j
24
24
  import { decideRequest, requestPlace } from "./cliHookDecideRequest.js";
25
25
  export { decideRequest };
26
26
  import { decideOnServer } from "./cliHookServerDecision.js";
27
+ import { setShadowDeadline } from "./kitShadowBudget.js";
28
+ import { shadowAfterDecision } from "./kitShadow.js";
27
29
  export { CLI_DECIDE_PATH, decideOnServer, parseServerDecision } from "./cliHookServerDecision.js";
28
30
  /** Codex can't ask from a hook, so an ask it read is recorded as the block it was. */
29
31
  export function codexAskBlocked(report) {
@@ -203,10 +205,13 @@ const GITHUB_WORD = /(?:^|[\s;&|(/])(?:gh\s|git\s(?:[^;&|]*\s)?push\b)/;
203
205
  * the classifier, which reads the line as the shell would, decides what is really railway. */
204
206
  const RAILWAY_WORD = /railway/i;
205
207
  const railwayWord = (command) => RAILWAY_WORD.test(command.replace(/["'\\]/g, ""));
208
+ /** The same for `supabase` (and a `curl` to Supabase's API): the kit's resolver decides what is really Supabase. */
209
+ const supabaseWord = (command) => /supabase/i.test(command.replace(/["'\\]/g, ""));
206
210
  /**
207
- * The control plane (GitHub or Railway connected): a consequential `gh`,
208
- * `git push` or `railway` command that the rest of the plan lets through is
209
- * asked about once more (`controlPlaneGuard.ts`, `controlPlaneRailwayGuard.ts`).
211
+ * The control plane (GitHub, Railway or Supabase connected): a consequential
212
+ * `gh`, `git push`, `railway` or `supabase` command that the rest of the plan
213
+ * lets through is asked about once more (`controlPlaneGuard.ts`,
214
+ * `controlPlaneRailwayGuard.ts`, `controlPlaneSupabase.ts`).
210
215
  * A block replaces the plan with the exact block message. Unanswered in time,
211
216
  * the plan stands, as for any guard decision without Passport, and when the
212
217
  * command runs Passport is told so (`controlPlaneLate.ts`).
@@ -217,30 +222,32 @@ async function controlPlanePlan(plan, decision, policy, context) {
217
222
  // Only once the platform is connected (cli-policy `controlPlane`): no request otherwise.
218
223
  const github = Boolean(policy.autopilot.controlPlaneGithub) && GITHUB_WORD.test(context.command);
219
224
  const railway = Boolean(policy.autopilot.controlPlaneRailway) && railwayWord(context.command);
225
+ const supabase = Boolean(policy.autopilot.controlPlaneSupabase) && supabaseWord(context.command);
220
226
  const left = context.deadline - context.now();
221
- if ((!github && !railway) || left <= 0)
227
+ if ((!github && !railway && !supabase) || left <= 0)
222
228
  return plan;
229
+ // The kit's shadow run (`kitShadow.ts`) stops before the guard's deadline.
230
+ setShadowDeadline(context.deadline, context.now);
223
231
  let api = plan.api;
224
232
  const open = async () => (api ??= (await context.openApi()) ?? undefined) ?? null;
225
233
  const signal = AbortSignal.any([context.budget, AbortSignal.timeout(left)]);
226
234
  const extra = { sessionId: context.report?.sessionId };
227
- const [githubLine, railwayAnswer] = await Promise.all([
228
- github ? githubLinePlan(context, open, extra, signal) : null,
229
- railway
230
- ? (await import("./controlPlaneRailwayGuard.js")).railwayLinePlan(context.command, { cwd: context.cwd, env: context.env ?? process.env, home: homedir() }, open, extra, signal)
231
- : null
232
- ]);
235
+ const [githubLine, railwayAnswer, supabaseAnswer] = await askPlatforms({ github, railway, supabase }, context, open, extra, signal);
236
+ // Decided: the kit's shadow run reads what was asked about, off the decision's path.
237
+ shadowAfterDecision();
233
238
  const githubAnswer = githubLine?.decided?.answer;
234
- const blocked = githubAnswer?.kind === "block" ? githubAnswer : railwayAnswer?.answer;
239
+ const blocked = [githubAnswer, railwayAnswer?.answer, supabaseAnswer?.answer].find((answer) => answer?.kind === "block");
235
240
  if (blocked?.kind !== "block") {
236
241
  // Only once the whole line is allowed (nothing in it blocked, nothing left to ask) is a decision left for exec.
237
- if (!decision || runs(plan, decision))
238
- await leaveDecisions(githubLine?.decided ?? null, railwayAnswer, context);
242
+ if (!decision || runs(plan, decision)) {
243
+ await supabaseAnswer?.leave();
244
+ await leaveDecisions(githubLine?.decided ?? null, railwayAnswer, context, supabaseAnswer?.answer);
245
+ }
239
246
  return api ? { ...plan, api } : plan;
240
247
  }
241
248
  const fallback = {
242
249
  verdict: "deny",
243
- label: githubLine?.label ?? railwayAnswer?.label ?? "",
250
+ label: githubLine?.label ?? railwayAnswer?.label ?? supabaseAnswer?.label ?? "",
244
251
  findings: [],
245
252
  destructive: true
246
253
  };
@@ -252,6 +259,19 @@ async function controlPlanePlan(plan, decision, policy, context) {
252
259
  offline: false
253
260
  };
254
261
  }
262
+ /** Each connected platform's part of a line, asked at once. */
263
+ async function askPlatforms(asking, context, open, extra, signal) {
264
+ const { github, railway, supabase } = asking;
265
+ return Promise.all([
266
+ github ? githubLinePlan(context, open, extra, signal) : null,
267
+ railway
268
+ ? (await import("./controlPlaneRailwayGuard.js")).railwayLinePlan(context.command, { cwd: context.cwd, env: context.env ?? process.env, home: homedir() }, open, extra, signal)
269
+ : null,
270
+ supabase
271
+ ? (await import("./controlPlaneSupabase.js")).supabaseLinePlan(context.command, { cwd: context.cwd ?? null, env: context.env ?? process.env }, open, extra, signal)
272
+ : null
273
+ ]);
274
+ }
255
275
  /** GitHub's part of a line. Every `git push` is decided here, ref by ref, resolved as git will in this folder; with
256
276
  * `passport git-credential` set up, the helper spends these decisions on the push token instead of asking again. */
257
277
  async function githubLinePlan(context, open, extra, signal) {
@@ -271,7 +291,7 @@ async function holdLate(answers, report, now) {
271
291
  }
272
292
  /** An allowed line that runs: Railway's decision waits for exec, each push's for `passport git-credential` when it is
273
293
  * set up (`gitPushDecisions.ts`), and the ids of decides left unanswered for the after-hook. */
274
- async function leaveDecisions(github, railway, context) {
294
+ async function leaveDecisions(github, railway, context, supabase) {
275
295
  if (railway)
276
296
  await railway.leave();
277
297
  if (github?.pushes.length) {
@@ -283,7 +303,7 @@ async function leaveDecisions(github, railway, context) {
283
303
  for (const push of github.pushes)
284
304
  leavePushDecisions(push.key, push.decisionIds);
285
305
  }
286
- await holdLate([github?.answer, railway?.answer], context.report, context.now());
306
+ await holdLate([github?.answer, railway?.answer, supabase], context.report, context.now());
287
307
  }
288
308
  /** Whether the command runs after this plan, as far as the guard decides it. */
289
309
  function runs(plan, decision) {
package/dist/cliMain.js CHANGED
@@ -456,6 +456,8 @@ async function dispatch(args, runtime) {
456
456
  return run(args, runtime);
457
457
  case "connect":
458
458
  return connect(args, runtime, withGateway);
459
+ case "connections":
460
+ return (await import("./cliConnections.js")).connections(args, runtime, withGateway);
459
461
  case "resources":
460
462
  return resources(args, runtime);
461
463
  case "prompts":
package/dist/cliOutput.js CHANGED
@@ -112,6 +112,10 @@ const EXAMPLES = {
112
112
  describe: [["passport describe github_search_issues", "One tool's parameters"]],
113
113
  run: [['passport run github_search_issues \'{"query":"SSO"}\'', "Run a tool through your rules"]],
114
114
  connect: [["passport connect github --wait 120", "Sign in to an app and wait for it"]],
115
+ connections: [
116
+ ["passport connections", "What's connected for you, and your connections page"],
117
+ ["passport connections github", "The page with GitHub first"]
118
+ ],
115
119
  completion: [["passport completion zsh", "Print zsh completion"]],
116
120
  update: [
117
121
  ["passport update", "Install the version Passport names"],
@@ -170,6 +174,7 @@ const HELP_GROUPS = [
170
174
  [
171
175
  ["keys", "Move CLI keys from this computer into Passport"],
172
176
  ["exec", "Run a vendor CLI with a key Passport holds"],
177
+ ["connections", "Your connections: what's connected and what needs you"],
173
178
  ["connect", "Sign in to your apps"],
174
179
  ["search", "Find tools you can run"],
175
180
  ["describe", "Show one tool and its parameters"],
@@ -266,6 +271,7 @@ function helpText(verb, all = false) {
266
271
  describe: "passport describe <tool>\nShows one tool: what it does and every parameter it takes.",
267
272
  // copy-style-allow double-space: help columns line up
268
273
  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.",
274
+ 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}",
269
275
  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.",
270
276
  resources: "passport resources [uri] [--out <file>]\nLists or reads workspace MCP resources. Binary content requires --out or --json.",
271
277
  prompts: "passport prompts [name] [--set key=value] [--out <file>]\nLists or gets workspace MCP prompts. Binary content requires --out or --json.",
@@ -584,14 +584,15 @@ function productionKeys(value) {
584
584
  const vendors = value.filter((entry) => typeof entry === "string" && VENDOR_KEY.test(entry));
585
585
  return vendors.length ? [...new Set(vendors)].slice(0, MAX_VENDORS) : undefined;
586
586
  }
587
- /** The control plane's gates as cli-policy sends them: `railway` only when true. */
587
+ /** The control plane's gates as cli-policy sends them: `railway` and `supabase` only when true. */
588
588
  function controlPlaneOut(autopilot) {
589
- if (!autopilot.controlPlaneGithub && !autopilot.controlPlaneRailway)
589
+ if (!autopilot.controlPlaneGithub && !autopilot.controlPlaneRailway && !autopilot.controlPlaneSupabase)
590
590
  return {};
591
591
  return {
592
592
  controlPlane: {
593
593
  github: Boolean(autopilot.controlPlaneGithub),
594
- ...(autopilot.controlPlaneRailway ? { railway: true } : {})
594
+ ...(autopilot.controlPlaneRailway ? { railway: true } : {}),
595
+ ...(autopilot.controlPlaneSupabase ? { supabase: true } : {})
595
596
  }
596
597
  };
597
598
  }
@@ -603,7 +604,8 @@ function taskScope(body) {
603
604
  ...(allowances ? { allowances } : {}),
604
605
  ...(body.leases === true ? { leases: true } : {}),
605
606
  ...(gate?.github === true ? { controlPlaneGithub: true } : {}),
606
- ...(gate?.railway === true ? { controlPlaneRailway: true } : {})
607
+ ...(gate?.railway === true ? { controlPlaneRailway: true } : {}),
608
+ ...(gate?.supabase === true ? { controlPlaneSupabase: true } : {})
607
609
  };
608
610
  }
609
611
  export function parseCliPolicyV2(value) {
package/dist/cliResult.js CHANGED
@@ -63,15 +63,19 @@ export function refusalOf(result) {
63
63
  ? `Open: ${connectUrl}\nFinish the browser sign-in, then retry the command.`
64
64
  : app
65
65
  ? "Run the connect action below, then retry the command."
66
- : "See which app needs connecting.\nRun: passport status",
66
+ : "See what needs connecting on your connections page.\nRun: passport connections",
67
67
  next: app
68
68
  ? [
69
69
  {
70
70
  argv: ["passport", "connect", app, "--wait", "120"],
71
71
  description: "Connect the required app, then retry the tool call."
72
+ },
73
+ {
74
+ argv: ["passport", "connections", app],
75
+ description: "Open your connections page with this app first."
72
76
  }
73
77
  ]
74
- : [{ argv: ["passport", "status"], description: "Identify the app that needs connecting." }]
78
+ : [{ argv: ["passport", "connections"], description: "See what needs connecting, and connect it." }]
75
79
  });
76
80
  }
77
81
  if (cause === "approval_pending") {