passport-bridge 0.35.0 → 0.36.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 (108) hide show
  1. package/README.md +1 -1
  2. package/dist/cliAutopilotPolicy.d.ts +2 -0
  3. package/dist/cliExec.d.ts +1 -2
  4. package/dist/cliExec.js +17 -38
  5. package/dist/cliGitCredential.d.ts +2 -0
  6. package/dist/cliGitCredential.js +56 -14
  7. package/dist/cliHookDecide.js +36 -16
  8. package/dist/cliInit.js +4 -0
  9. package/dist/cliPolicyV2.js +6 -4
  10. package/dist/cliStatusGuard.js +4 -1
  11. package/dist/commandRepair.d.ts +13 -0
  12. package/dist/commandRepair.js +73 -0
  13. package/dist/connectorKit/cli.generated.d.ts +15 -0
  14. package/dist/connectorKit/cli.generated.js +244 -0
  15. package/dist/connectorKit/engine.generated.d.ts +50 -0
  16. package/dist/connectorKit/engine.generated.js +475 -0
  17. package/dist/connectorKit/manifest.generated.d.ts +317 -0
  18. package/dist/connectorKit/manifest.generated.js +18 -0
  19. package/dist/connectorKit/manifests/flagSpec.generated.d.ts +6 -0
  20. package/dist/connectorKit/manifests/flagSpec.generated.js +20 -0
  21. package/dist/connectorKit/manifests/github.generated.d.ts +17 -0
  22. package/dist/connectorKit/manifests/github.generated.js +82 -0
  23. package/dist/connectorKit/manifests/githubCapture.generated.d.ts +2 -0
  24. package/dist/connectorKit/manifests/githubCapture.generated.js +307 -0
  25. package/dist/connectorKit/manifests/githubHooks.generated.d.ts +23 -0
  26. package/dist/connectorKit/manifests/githubHooks.generated.js +401 -0
  27. package/dist/connectorKit/manifests/githubReads.generated.d.ts +6 -0
  28. package/dist/connectorKit/manifests/githubReads.generated.js +200 -0
  29. package/dist/connectorKit/manifests/railway.generated.d.ts +6 -0
  30. package/dist/connectorKit/manifests/railway.generated.js +121 -0
  31. package/dist/connectorKit/manifests/railwayCapture.generated.d.ts +3 -0
  32. package/dist/connectorKit/manifests/railwayCapture.generated.js +375 -0
  33. package/dist/connectorKit/manifests/railwayHooks.generated.d.ts +25 -0
  34. package/dist/connectorKit/manifests/railwayHooks.generated.js +487 -0
  35. package/dist/connectorKit/manifests/supabase.generated.d.ts +3 -0
  36. package/dist/connectorKit/manifests/supabase.generated.js +34 -0
  37. package/dist/connectorKit/manifests/supabaseApi.generated.d.ts +3 -0
  38. package/dist/connectorKit/manifests/supabaseApi.generated.js +632 -0
  39. package/dist/connectorKit/manifests/supabaseCapture.generated.d.ts +9 -0
  40. package/dist/connectorKit/manifests/supabaseCapture.generated.js +421 -0
  41. package/dist/connectorKit/manifests/supabaseCatalog.generated.d.ts +11 -0
  42. package/dist/connectorKit/manifests/supabaseCatalog.generated.js +70 -0
  43. package/dist/connectorKit/manifests/supabaseCli.generated.d.ts +10 -0
  44. package/dist/connectorKit/manifests/supabaseCli.generated.js +581 -0
  45. package/dist/connectorKit/manifests/supabasePlatform.generated.d.ts +7 -0
  46. package/dist/connectorKit/manifests/supabasePlatform.generated.js +283 -0
  47. package/dist/connectorKit/manifests/supabaseProbes.generated.d.ts +5 -0
  48. package/dist/connectorKit/manifests/supabaseProbes.generated.js +580 -0
  49. package/dist/connectorKit/params.generated.d.ts +25 -0
  50. package/dist/connectorKit/params.generated.js +193 -0
  51. package/dist/connectorKit/pgParser.d.ts +9 -0
  52. package/dist/connectorKit/pgParser.js +13 -0
  53. package/dist/connectorKit/shadow.generated.d.ts +58 -0
  54. package/dist/connectorKit/shadow.generated.js +184 -0
  55. package/dist/connectorKit/shell.generated.d.ts +73 -0
  56. package/dist/connectorKit/shell.generated.js +516 -0
  57. package/dist/connectorKit/sourcegen.generated.d.ts +50 -0
  58. package/dist/connectorKit/sourcegen.generated.js +208 -0
  59. package/dist/connectorKit/sources/supabase/api-operations.generated.d.ts +187 -0
  60. package/dist/connectorKit/sources/supabase/api-operations.generated.js +2 -0
  61. package/dist/connectorKit/sources/supabase/cli-flags.generated.d.ts +1236 -0
  62. package/dist/connectorKit/sources/supabase/cli-flags.generated.js +2 -0
  63. package/dist/connectorKit/sources/supabase/mcp-tools.generated.d.ts +35 -0
  64. package/dist/connectorKit/sources/supabase/mcp-tools.generated.js +2 -0
  65. package/dist/connectorKit/sql.generated.d.ts +29 -0
  66. package/dist/connectorKit/sql.generated.js +420 -0
  67. package/dist/connectorKit/sqlFingerprint.generated.d.ts +8 -0
  68. package/dist/connectorKit/sqlFingerprint.generated.js +105 -0
  69. package/dist/connectorKit/template.generated.d.ts +21 -0
  70. package/dist/connectorKit/template.generated.js +89 -0
  71. package/dist/connectorKit/types.generated.d.ts +81 -0
  72. package/dist/connectorKit/types.generated.js +6 -0
  73. package/dist/controlPlane.generated.d.ts +46 -2
  74. package/dist/controlPlane.generated.js +10 -1
  75. package/dist/controlPlaneExec.d.ts +21 -2
  76. package/dist/controlPlaneExec.js +83 -5
  77. package/dist/controlPlaneGithub.generated.js +4 -8
  78. package/dist/controlPlaneGuard.js +29 -4
  79. package/dist/controlPlaneIds.d.ts +39 -0
  80. package/dist/controlPlaneIds.js +175 -0
  81. package/dist/controlPlaneModel.generated.d.ts +67 -0
  82. package/dist/controlPlaneModel.generated.js +153 -0
  83. package/dist/controlPlaneRailwayGuard.js +13 -3
  84. package/dist/controlPlaneSupabase.d.ts +84 -0
  85. package/dist/controlPlaneSupabase.js +278 -0
  86. package/dist/execGithubRepo.d.ts +2 -0
  87. package/dist/execGithubRepo.js +30 -0
  88. package/dist/execShims.d.ts +4 -2
  89. package/dist/execShims.js +9 -3
  90. package/dist/gitCredentialSetup.d.ts +3 -0
  91. package/dist/gitCredentialSetup.js +19 -0
  92. package/dist/gitPush.d.ts +20 -0
  93. package/dist/gitPush.js +45 -7
  94. package/dist/initInstall.js +19 -13
  95. package/dist/kitShadow.d.ts +90 -0
  96. package/dist/kitShadow.js +261 -0
  97. package/dist/kitShadowBudget.d.ts +10 -0
  98. package/dist/kitShadowBudget.js +15 -0
  99. package/dist/launcherHealth.d.ts +11 -0
  100. package/dist/launcherHealth.js +49 -0
  101. package/dist/pluginPin.d.ts +1 -1
  102. package/dist/pluginPin.js +1 -1
  103. package/dist/supabaseDecisions.d.ts +9 -0
  104. package/dist/supabaseDecisions.js +98 -0
  105. package/dist/version.d.ts +1 -1
  106. package/dist/version.js +1 -1
  107. package/npm-shrinkwrap.json +2 -2
  108. package/package.json +1 -1
package/README.md CHANGED
@@ -364,7 +364,7 @@ passport git-credential setup --remove # back to your own GitHub sign-in
364
364
 
365
365
  When your workspace's GitHub App covers a repository, `gh` and `git` use tokens Passport issues from it, so GitHub reports their pushes, PRs and merges as the App (`<app>[bot]`; commit authors stay you) and the control plane counts them through Passport. `passport exec -- gh …` (the guard's rewrite in Claude Code, and the `gh` shim) already gets one; `passport keys` lists `gh` as going through Passport and says when git doesn't yet.
366
366
 
367
- `setup` adds Passport as git's credential helper for `https://github.com/` in your global git config (`GIT_CONFIG_GLOBAL` is honored), after an empty `helper =` so no helper set before it (osxkeychain, `gh auth git-credential`) answers for github.com. Those earlier helpers (from your system and global config only, never a repository's own) are remembered (names only, in `$PASSPORT_HOME/git-credential.json`) and still answer for repositories the App doesn't cover; running setup again keeps them. Pushes from SSH remotes go over HTTPS (`url.https://github.com/<owner>/.pushInsteadOf`) only for the accounts the App covers, and only when one of those helpers can answer over HTTPS; fetches stay on SSH. The file is copied once to `<file>.passport-backup`. `--remove` puts Passport's section back exactly as it was and removes only what setup added. If `gh auth setup-git` runs afterwards, git asks gh first again; `passport keys` says so, and setup again fixes it. `passport init` offers it in the Keys step when the App covers you (asked step by step, done with `--move-keys`, otherwise the next command). Not on Windows: setup refuses there, since its reset would stop Git Credential Manager answering for github.com.
367
+ `setup` adds Passport as git's credential helper for `https://github.com/` in your global git config (`GIT_CONFIG_GLOBAL` is honored), after an empty `helper =` so no helper set before it (osxkeychain, `gh auth git-credential`) answers for github.com. Those earlier helpers (from your system and global config only, never a repository's own) are remembered (names only, in `$PASSPORT_HOME/git-credential.json`) and still answer for repositories the App doesn't cover; running setup again keeps them. Pushes from SSH remotes go over HTTPS (`url.https://github.com/<owner>/.pushInsteadOf`) only for the accounts the App covers, and only when one of those helpers can answer over HTTPS; fetches stay on SSH. The file is copied once to `<file>.passport-backup`. `--remove` puts Passport's section back exactly as it was and removes only what setup added. If `gh auth setup-git` runs afterwards, git asks gh first again; `passport keys` says so, and setup again fixes it. Setup says done only once git's helper answers as this Passport (it runs the helper with `probe`); otherwise git goes back to how it was. If the helper or the launcher it runs falls behind (a global npm update leaves an old copy behind it), `passport init` and `passport status` point it at this Passport again. `passport init` offers it in the Keys step when the App covers you (asked step by step, done with `--move-keys`, otherwise the next command). Not on Windows: setup refuses there, since its reset would stop Git Credential Manager answering for github.com.
368
368
 
369
369
  Then for each fetch or push git runs `passport git-credential get`:
370
370
 
@@ -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?: {
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();
@@ -19,6 +19,8 @@ export type GitCredentialDependencies = {
19
19
  fallback?: (helper: string, operation: string, input: string, env: Runtime["env"]) => Promise<string>;
20
20
  run?: RunGit;
21
21
  command?: readonly string[];
22
+ /** What a helper line answers (tests); the default runs it as git would. */
23
+ probe?: (line: string, env: Runtime["env"]) => string | null;
22
24
  mintTimeoutMs?: number;
23
25
  decideTimeoutMs?: number;
24
26
  cwd?: string;
@@ -32,11 +32,14 @@ import { accessCachePath, cachedAccessApi } from "./accessTokenCache.js";
32
32
  import { bool } from "./cliArgs.js";
33
33
  import { memberApi } from "./cliClient.js";
34
34
  import { callerFrom, failure, readBoundedJson, resolveCliAuth, sanitize, timeoutMs } from "./cliSupport.js";
35
- import { defaultPassportCommand } from "./execShims.js";
35
+ import { defaultPassportCommand, thisCliCommand } from "./execShims.js";
36
+ import { compareVersions } from "./launcherHealth.js";
37
+ import { VERSION } from "./version.js";
36
38
  import { askingGitCommand, execGitCommand, isPush } from "./gitInvocation.js";
37
39
  import { MAX_PUSH_REFS, planKey, planPush } from "./gitPush.js";
40
+ import { beginShadowLine, shadowAfterDecision, shadowAlongside, shadowGithubLine } from "./kitShadow.js";
38
41
  import { takePushDecisions } from "./gitPushDecisions.js";
39
- import { installGitCredential, readGitCredentialState, removeGitCredential } from "./gitCredentialSetup.js";
42
+ import { helperLine, helperProgram, installGitCredential, probeHelper, readGitCredentialState, removeGitCredential } from "./gitCredentialSetup.js";
40
43
  export const GIT_CREDENTIAL_PATH = "/api/my/github/git-credential";
41
44
  export const TOKEN_USERNAME = "x-access-token";
42
45
  const REPO_PATH = /^([A-Za-z0-9_.-]{1,100})\/([A-Za-z0-9_.-]{1,100}?)(?:\.git)?\/?$/;
@@ -266,10 +269,12 @@ async function get(args, runtime, deps, input) {
266
269
  }
267
270
  // A push: what it changes, ref by ref. Only the classification leaves this computer.
268
271
  const [owner, name] = repo.split("/");
272
+ const lines = [];
269
273
  const plan = planPush(asking, {
270
274
  cwd: deps.cwd ?? process.cwd(),
271
275
  env: runtime.env,
272
276
  repo: { owner, repo: name },
277
+ onLine: (line) => void lines.push(line),
273
278
  ...(deps.run ? { run: deps.run } : {})
274
279
  });
275
280
  if (!plan)
@@ -280,26 +285,41 @@ async function get(args, runtime, deps, input) {
280
285
  if (got.kind !== "refused" || got.code !== "undecided")
281
286
  return got.kind === "token" ? answer(got.minted) : refused(got);
282
287
  // Passport would issue a push token once it decides the push: every ref, and
283
- // a block on any stops git here.
284
- const decisionIds = [];
285
- 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)) {
286
307
  const wait = Math.min(deps.decideTimeoutMs ?? DECIDE_TIMEOUT_MS, left());
287
308
  if (wait <= 0)
288
- 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" };
289
310
  const decided = await within(wait, runtime.signal, (bounded) => askControlPlane(api, classification, {}, bounded));
290
311
  if (decided.kind === "block") {
291
312
  runtime.stderr.write(`passport: ${decided.message.replace(/\s*\n\s*/g, " ")}\n`);
292
313
  // quit=1: git stops here, without trying another helper or asking for a password.
293
- return "quit=1\n";
314
+ return { kind: "block" };
294
315
  }
295
316
  if (decided.kind !== "allow")
296
- 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" };
297
318
  if (!decided.decisionId)
298
- return ownSignIn("Passport didn't record a decision for this push, so");
299
- decisionIds.push(decided.decisionId);
319
+ return { kind: "own", why: "Passport didn't record a decision for this push, so" };
320
+ ids.push(decided.decisionId);
300
321
  }
301
- got = await mint(api, repo, "write", runtime.signal, left(), { decisionIds });
302
- return got.kind === "token" ? answer(got.minted) : refused(got);
322
+ return { kind: "ids", ids };
303
323
  }
304
324
  /**
305
325
  * The asker is unknown: a read-only token, which Passport records as an
@@ -362,13 +382,27 @@ async function setup(args, runtime, deps) {
362
382
  api = undefined;
363
383
  }
364
384
  const owners = await coveredOwners(api, runtime.signal);
365
- const result = installGitCredential({
366
- command: deps.command ?? defaultPassportCommand(),
385
+ const install = (command) => installGitCredential({
386
+ command,
367
387
  env,
368
388
  owners,
369
389
  ...(deps.run ? { run: deps.run } : {}),
370
390
  ...(deps.platform ? { platform: deps.platform } : {})
371
391
  });
392
+ const first = deps.command ?? defaultPassportCommand();
393
+ let result = install(first);
394
+ // git must get an answer from the helper it now runs, or every github.com fetch and push fails: else this CLI
395
+ // itself, else git goes back to how it was.
396
+ if (result.ok && first && !answers(helperLine(first), env, deps)) {
397
+ const self = deps.command ? undefined : thisCliCommand();
398
+ const retried = self && helperLine(self) !== helperLine(first) ? install(self) : null;
399
+ if (!retried?.ok || !self || !answers(helperLine(self), env, deps)) {
400
+ removeGitCredential({ env, ...(deps.run ? { run: deps.run } : {}) });
401
+ const program = helperProgram(helperLine(first)) ?? first[0];
402
+ return failure(`git's helper didn't answer: ${program} isn't a Passport that knows git-credential. git is back as it was. Run passport init, then passport git-credential setup.`, 1, "helper_unanswered");
403
+ }
404
+ result = retried;
405
+ }
372
406
  if (!result.ok) {
373
407
  const messages = {
374
408
  no_git: "git isn't installed here, so there's nothing to set up.",
@@ -403,11 +437,19 @@ async function setup(args, runtime, deps) {
403
437
  human: lines.join("\n")
404
438
  };
405
439
  }
440
+ /** Whether a helper line answers as this version of Passport or a newer one. */
441
+ function answers(line, env, deps) {
442
+ const version = (deps.probe ?? probeHelper)(line, env);
443
+ return version !== null && compareVersions(version, VERSION) >= 0;
444
+ }
406
445
  /* -------------------------------- entry --------------------------------- */
407
446
  export async function gitCredential(args, runtime, deps = {}) {
408
447
  const [operation] = args.positionals;
409
448
  if (operation === "setup")
410
449
  return setup(args, runtime, deps);
450
+ // Setup, init and status ask the helper line this, to know it runs a Passport that answers git.
451
+ if (operation === "probe")
452
+ return { json: { version: VERSION }, human: `passport git-credential ${VERSION}` };
411
453
  if (operation !== "get" && operation !== "store" && operation !== "erase") {
412
454
  return failure(`Unknown: ${sanitize(operation ?? "")}. git runs passport git-credential get|store|erase; you run passport git-credential setup.`, 6, "usage");
413
455
  }
@@ -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/cliInit.js CHANGED
@@ -148,6 +148,10 @@ export class Init {
148
148
  const mode = await this.choose(plan.will.length > 0);
149
149
  this.screen.endStep();
150
150
  await this.apply(detected, mode);
151
+ // What still runs an older Passport (the launcher, git's helper) runs this one.
152
+ for (const line of (await import("./commandRepair.js")).repairPassportCommand(this.env)) {
153
+ this.screen.result("done", line, "Keys");
154
+ }
151
155
  this.screen.idle();
152
156
  this.outro();
153
157
  }
@@ -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) {
@@ -59,7 +59,10 @@ export async function guardStatus(api, profile, signal, now = Date.now(), env =
59
59
  // Someone is looking: finish any setup an upgrade left half done first, so
60
60
  // what follows is the state as it now is.
61
61
  const { repairHooks, repairLines } = await import("./hookRepair.js");
62
- const repaired = repairLines(await repairHooks(env));
62
+ const repaired = [
63
+ ...repairLines(await repairHooks(env)),
64
+ ...(await import("./commandRepair.js")).repairPassportCommand(env)
65
+ ];
63
66
  const local = (await localGuardStates(env)).filter((entry) => entry.state);
64
67
  const reported = api && profile ? await guardHeartbeat(api, profile, env, signal, now, true) : null;
65
68
  const agents = local.map((entry) => {
@@ -0,0 +1,13 @@
1
+ import type { Env } from "./cliSupport.js";
2
+ import { type RunGit } from "./gitCredentialSetup.js";
3
+ import { type InstallContext } from "./initInstall.js";
4
+ export type CommandRepairDeps = {
5
+ probe?: (line: string, env: Env) => string | null;
6
+ install?: (context: InstallContext) => unknown;
7
+ run?: RunGit;
8
+ context?: Partial<InstallContext>;
9
+ };
10
+ export declare const LAUNCHER_REPAIRED = "Updated Passport's launcher to this version: git's helper and your shims had been running an older Passport.";
11
+ export declare const HELPER_REPAIRED = "Pointed git's helper for github.com at this Passport, so fetches and pushes work again.";
12
+ export declare const HELPER_BROKEN = "git's helper for github.com runs a Passport that doesn't answer, so github.com fetches and pushes fail. Run passport git-credential setup.";
13
+ export declare function repairPassportCommand(env: Env, deps?: CommandRepairDeps): string[];
@@ -0,0 +1,73 @@
1
+ /**
2
+ * `passport init` and `passport status` point what still runs an older
3
+ * Passport at this one (dogfooding 0.35.0: a global npm install left
4
+ * `$PASSPORT_HOME/cli/bin/passport` on 0.16.8, so git's helper answered
5
+ * "Unknown command: git-credential" and every github.com fetch and push
6
+ * failed, and the Railway shim ran the old CLI too):
7
+ *
8
+ * - the launcher git's helper and the shims run, when it runs an older CLI
9
+ * than this one: installed again as init installs it (`ensureStableCommand`);
10
+ * - git's helper line, when it doesn't answer `probe` as this version or a
11
+ * newer one: pointed at the command setup would use now, once that answers.
12
+ *
13
+ * Only for a person's own signed-in CLI (`mayRepairHooks`), never on Windows,
14
+ * and never throws.
15
+ */
16
+ import { existsSync } from "node:fs";
17
+ import { homedir } from "node:os";
18
+ import { defaultPassportCommand, shimDir } from "./execShims.js";
19
+ import { helperLine, installGitCredential, probeHelper, readGitCredentialState } from "./gitCredentialSetup.js";
20
+ import { mayRepairHooks } from "./hookRepair.js";
21
+ import { ensureStableCommand, launcherPath } from "./initInstall.js";
22
+ import { packageRootOf } from "./initState.js";
23
+ import { compareVersions, launcherCurrent } from "./launcherHealth.js";
24
+ import { VERSION } from "./version.js";
25
+ export const LAUNCHER_REPAIRED = "Updated Passport's launcher to this version: git's helper and your shims had been running an older Passport.";
26
+ export const HELPER_REPAIRED = "Pointed git's helper for github.com at this Passport, so fetches and pushes work again.";
27
+ export const HELPER_BROKEN = "git's helper for github.com runs a Passport that doesn't answer, so github.com fetches and pushes fail. Run passport git-credential setup.";
28
+ export function repairPassportCommand(env, deps = {}) {
29
+ const lines = [];
30
+ try {
31
+ const context = {
32
+ env: env,
33
+ home: homedir(),
34
+ platform: process.platform,
35
+ packageRoot: packageRootOf(),
36
+ execPath: process.execPath,
37
+ nodeVersion: process.versions.node,
38
+ ...deps.context
39
+ };
40
+ if (context.platform === "win32" || !mayRepairHooks(env))
41
+ return lines;
42
+ const launcher = launcherPath(shimDir(), context.platform);
43
+ if (existsSync(launcher) && !launcherCurrent(launcher, VERSION)) {
44
+ try {
45
+ (deps.install ?? ensureStableCommand)(context);
46
+ if (launcherCurrent(launcher, VERSION))
47
+ lines.push(LAUNCHER_REPAIRED);
48
+ }
49
+ catch {
50
+ // No usable Node or no room: setup and init say why when run.
51
+ }
52
+ }
53
+ const state = readGitCredentialState();
54
+ if (!state)
55
+ return lines;
56
+ const probe = deps.probe ?? probeHelper;
57
+ const current = (line) => {
58
+ const version = probe(line, env);
59
+ return version !== null && compareVersions(version, VERSION) >= 0;
60
+ };
61
+ if (current(state.helper))
62
+ return lines;
63
+ const command = defaultPassportCommand();
64
+ const result = command && current(helperLine(command))
65
+ ? installGitCredential({ command, env, ...(deps.run ? { run: deps.run } : {}) })
66
+ : null;
67
+ lines.push(result?.ok ? HELPER_REPAIRED : HELPER_BROKEN);
68
+ }
69
+ catch {
70
+ // Never in the way of what was asked.
71
+ }
72
+ return lines;
73
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A CLI line, normalized: the program found behind its launchers, the command
3
+ * (aliases resolved), flags parsed with the vendor's own tables the way its
4
+ * framework does, positional arguments as $1..$n. Anything the vendor's spec
5
+ * wouldn't accept is a `problem`: the request fails closed.
6
+ */
7
+ import type { Manifest } from "./manifest.generated.js";
8
+ import type { Normalized, Value } from "./types.generated.js";
9
+ /** Every command the manifest knows, longest first. */
10
+ export declare function knownOps(m: Manifest): string[];
11
+ export declare const present: (value: Value | undefined) => boolean;
12
+ export declare const programName: (word: string) => string;
13
+ /** Strip what runs a program without changing it: env assignments, env, sudo, time, package runners. */
14
+ export declare function stripLaunchers(words: string[], programs: readonly string[]): void;
15
+ export declare function normalizeCli(m: Manifest, argv: readonly string[], given?: string): Normalized | null;