passport-bridge 0.41.0 → 0.44.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 (72) hide show
  1. package/README.md +16 -56
  2. package/dist/callingAgent.d.ts +64 -0
  3. package/dist/callingAgent.js +163 -0
  4. package/dist/cliExec.d.ts +13 -29
  5. package/dist/cliExec.js +71 -173
  6. package/dist/cliGitCredential.d.ts +2 -1
  7. package/dist/cliGitCredential.js +28 -4
  8. package/dist/cliGuardHealth.js +2 -0
  9. package/dist/cliHook.d.ts +4 -1
  10. package/dist/cliHook.js +12 -5
  11. package/dist/cliHookDecide.js +4 -13
  12. package/dist/cliHookRewrite.d.ts +3 -2
  13. package/dist/cliHookRewrite.js +10 -6
  14. package/dist/cliKeys.js +10 -9
  15. package/dist/cliKeysBack.d.ts +3 -5
  16. package/dist/cliKeysBack.js +6 -23
  17. package/dist/cliKeysShim.d.ts +4 -1
  18. package/dist/cliKeysShim.js +9 -1
  19. package/dist/cliKubeCredential.d.ts +6 -1
  20. package/dist/cliKubeCredential.js +10 -0
  21. package/dist/cliOutput.js +14 -23
  22. package/dist/cliScan.js +3 -4
  23. package/dist/cliStatus.js +1 -3
  24. package/dist/cliSupport.js +7 -10
  25. package/dist/commandRepair.d.ts +1 -1
  26. package/dist/commandRepair.js +1 -1
  27. package/dist/completion.js +4 -4
  28. package/dist/connectorKit/manifests/github.generated.d.ts +1 -1
  29. package/dist/connectorKit/manifests/github.generated.js +13 -7
  30. package/dist/connectorKit/manifests/githubHooks.generated.js +1 -1
  31. package/dist/connectorKit/manifests/railway.generated.js +8 -8
  32. package/dist/connectorKit/manifests/supabase.generated.js +1 -1
  33. package/dist/connectorKit/manifests/supabaseCatalog.generated.js +4 -4
  34. package/dist/controlPlane.generated.d.ts +40 -13
  35. package/dist/controlPlane.generated.js +18 -23
  36. package/dist/controlPlaneBasic.generated.d.ts +2 -5
  37. package/dist/controlPlaneBasic.generated.js +2 -7
  38. package/dist/controlPlaneExec.js +1 -3
  39. package/dist/controlPlaneGithub.generated.d.ts +1 -1
  40. package/dist/controlPlaneGithub.generated.js +1 -1
  41. package/dist/controlPlaneGithubCatalog.generated.d.ts +2 -2
  42. package/dist/controlPlaneGithubCatalog.generated.js +1 -1
  43. package/dist/controlPlaneGithubCli.generated.d.ts +1 -2
  44. package/dist/controlPlaneGithubCli.generated.js +2 -3
  45. package/dist/controlPlaneGuard.d.ts +2 -2
  46. package/dist/controlPlaneGuard.js +2 -2
  47. package/dist/controlPlaneModel.generated.d.ts +2 -1
  48. package/dist/controlPlaneModel.generated.js +10 -2
  49. package/dist/controlPlaneSupabase.js +1 -1
  50. package/dist/execGit.d.ts +14 -10
  51. package/dist/execGit.js +33 -19
  52. package/dist/execVendors.js +3 -6
  53. package/dist/initKeysStep.js +15 -0
  54. package/dist/initPlan.d.ts +1 -1
  55. package/dist/initPlan.js +14 -3
  56. package/dist/initState.d.ts +2 -1
  57. package/dist/keysHere.js +3 -2
  58. package/dist/keysInV1.d.ts +9 -0
  59. package/dist/keysInV1.js +48 -0
  60. package/dist/keysLocal.js +4 -0
  61. package/dist/keysV1Cleanup.d.ts +3 -0
  62. package/dist/keysV1Cleanup.js +37 -0
  63. package/dist/offInV1.d.ts +26 -0
  64. package/dist/offInV1.js +28 -0
  65. package/dist/pluginPin.d.ts +1 -1
  66. package/dist/pluginPin.js +1 -1
  67. package/dist/statusKeys.d.ts +2 -2
  68. package/dist/statusKeys.js +3 -8
  69. package/dist/version.d.ts +1 -1
  70. package/dist/version.js +1 -1
  71. package/npm-shrinkwrap.json +2 -2
  72. package/package.json +1 -1
package/dist/cliExec.js CHANGED
@@ -1,41 +1,34 @@
1
1
  /**
2
- * `passport exec -- <cli> [args…]`: run one vendor CLI command with a key
3
- * Passport holds, after Passport decides.
2
+ * `passport exec -- <cli> [args…]`: run one vendor CLI command after Passport decides it.
4
3
  *
5
- * classify here → (a vendor CLI that is a basic platform: POST
6
- * /api/cp/decide/cli) → POST /api/my/exec/authorize → allow: credential for
7
- * this one command, injected into the child's environment only → run → pass
8
- * the output and exit code through unchanged.
4
+ * classify here → (a vendor CLI that is a basic platform: POST /api/cp/decide/cli) → POST
5
+ * /api/my/exec/authorize → allow: run the CLI with this shell's own environment and sign-in → pass the output and
6
+ * exit code through unchanged.
9
7
  *
10
- * Nothing waits for a person: anything but an allow is refused at once with
11
- * Passport's own words. Offline, nothing runs: exec never falls back to a key
12
- * on this computer. `--wait` is accepted and ignored (it once waited for an
8
+ * Passport issues no credential (decided 2026-11-16, docs/design/control-plane.md "Credentials"): exec is a decision
9
+ * point, not a key handover. Nothing waits for a person: a block or an undecided answer is refused at once with
10
+ * Passport's own words (exit 5). Offline, nothing runs. `--wait` is accepted and ignored (it once waited for an
13
11
  * approval).
14
12
  *
15
- * Guarantees (each is tested): the credential is never written to disk,
16
- * printed, or passed on the command line; Passport's own credentials never
17
- * reach the child; only the variables listed for the vendor are set; shells,
18
- * `env`, and subcommands that would print the key or run another program
19
- * with it are refused before anything is sent.
13
+ * The child gets this shell's environment, minus Passport's own sign-in variables (`EXEC_PASSPORT_ENV`). Shells,
14
+ * `env`, and subcommands that would run another program are refused before anything is sent.
20
15
  */
21
- import { homedir } from "node:os";
22
16
  import { basename } from "node:path";
23
17
  import { bool, value } from "./cliArgs.js";
24
18
  import { memberApi } from "./cliClient.js";
25
19
  import { passportUnreachable } from "./cliOutput.js";
26
- import { execControlPlaneRefusal, execIdsWanted, execRailwayScope, execRelease, execSupabaseProject } from "./controlPlaneExec.js";
20
+ import { execControlPlaneRefusal, execIdsWanted, execRailwayScope, execSupabaseProject } from "./controlPlaneExec.js";
27
21
  import { classifyCommand, UNRECOGNIZED_VERB } from "./cliHookClassify.js";
28
22
  import { GH_VALUES, ghApiMethod, parseArgs as parseGhArgs } from "./controlPlaneGithubCli.generated.js";
29
23
  import { redactCommand } from "./cliHookRedact.js";
30
- import { noteExecVendor } from "./execMarker.js";
31
- import { CliFailure, callerFrom, failure, readBoundedJson, resolveCliAuth, safeApiError, timeoutMs } from "./cliSupport.js";
32
- import { EXEC_ENV_NAMES, EXEC_PASSPORT_ENV, EXEC_SHADOWED_ENV, EXEC_CARRIERS, EXEC_VENDOR_NAMES, devLoopRefusal, execVendorOf } from "./execVendors.js";
24
+ import { callerFrom, failure, readBoundedJson, resolveCliAuth, safeApiError, timeoutMs } from "./cliSupport.js";
25
+ import { EXEC_PASSPORT_ENV, EXEC_CARRIERS, EXEC_VENDOR_NAMES, execVendorOf } from "./execVendors.js";
33
26
  import { execTarget } from "./execTarget.js";
34
- import { secretNeedles } from "./execMask.js";
27
+ import * as callingAgentModule from "./callingAgent.js";
35
28
  import { spawnVendor } from "./execSpawn.js";
36
29
  import { shadowAfterDecision } from "./kitShadow.js";
37
30
  export { spawnVendor } from "./execSpawn.js";
38
- import { findVendorBinary, removeShims } from "./execShims.js";
31
+ import { findVendorBinary } from "./execShims.js";
39
32
  import { hashLink } from "./webLinks.js";
40
33
  export const EXEC_AUTHORIZE_PATH = "/api/my/exec/authorize";
41
34
  export const EXEC_RESULT_PATH = "/api/my/exec/result";
@@ -78,50 +71,15 @@ export function execFinding(vendor, binary, args) {
78
71
  const { method, read } = ghApiMethod(parsed);
79
72
  return { ...finding, method: read ? method : method === "GET" || method === "HEAD" ? "POST" : method };
80
73
  }
81
- /** Only the vendor's own variables, as plain single-line strings. None for a Railway read Passport sends with the
82
- * person's own sign-in (`ownSignIn`: Passport mints only for actions). */
83
- export function checkedCredential(vendor, raw, ownSignIn) {
84
- if (vendor === "railway" && ownSignIn === true)
85
- return {};
86
- const allowed = new Set(EXEC_ENV_NAMES[vendor]);
87
- const env = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
88
- if (!env || !Object.keys(env).length) {
89
- return failure("Passport returned no key for this command. Nothing ran.", 1, "invalid_server_response");
90
- }
91
- const out = {};
92
- for (const [name, entry] of Object.entries(env)) {
93
- if (!allowed.has(name) || typeof entry !== "string" || !entry || entry.length > 8192 || /[\0\r\n]/.test(entry)) {
94
- return failure("Passport returned a key this CLI can't use. Nothing ran.", 1, "invalid_server_response");
95
- }
96
- out[name] = entry;
97
- }
98
- return out;
99
- }
100
- /** The child's environment: this shell's, minus every other credential the
101
- * vendor CLI could pick up and Passport's own, plus the issued one. */
102
- export function childEnvironment(base, credential) {
74
+ /** The child's environment: this shell's own, with the person's own sign-ins, minus Passport's own sign-in. */
75
+ export function childEnvironment(base) {
103
76
  const env = { ...base };
104
- for (const name of [...EXEC_SHADOWED_ENV, ...EXEC_PASSPORT_ENV])
77
+ for (const name of EXEC_PASSPORT_ENV)
105
78
  delete env[name];
106
- return { ...env, ...credential };
107
- }
108
- /**
109
- * Masking is on when stdout isn't a terminal: an agent's shell, a pipe, a CI
110
- * log, a transcript, where a printed key would be kept and read later. In a
111
- * terminal the vendor CLI gets the terminal itself (colors, prompts,
112
- * progress), unmasked, since a person watching their own screen is not that
113
- * risk. `--mask` forces it on there; `--no-masking` (or
114
- * PASSPORT_EXEC_NO_MASKING=1 through a shim) turns it off everywhere.
115
- */
116
- export function maskingWanted(args, env, stdout) {
117
- if (bool(args, "no-masking") || env.PASSPORT_EXEC_NO_MASKING === "1")
118
- return false;
119
- if (bool(args, "mask"))
120
- return true;
121
- return !stdout?.isTTY;
79
+ return env;
122
80
  }
123
81
  function offline(binary) {
124
- return failure(`Passport couldn't be reached, so ${binary} didn't run. passport exec never uses a key on this computer instead.`, 1, "offline");
82
+ return failure(`Passport couldn't be reached, so ${binary} didn't run.`, 1, "offline");
125
83
  }
126
84
  async function post(client, body, runtime, ms, binary) {
127
85
  let response;
@@ -158,8 +116,8 @@ async function post(client, body, runtime, ms, binary) {
158
116
  }
159
117
  if (response.status === 409) {
160
118
  const body409 = await readBoundedJson(response).catch(() => ({}));
161
- const code = typeof body409?.code === "string" ? body409.code : "no_key";
162
- const message = typeof body409?.error === "string" ? body409.error : "Passport holds no key for this CLI.";
119
+ const code = typeof body409?.code === "string" ? body409.code : "refused";
120
+ const message = typeof body409?.error === "string" ? body409.error : "Passport refused this command. Nothing ran.";
163
121
  return failure(message, 3, code);
164
122
  }
165
123
  if (response.status >= 500) {
@@ -180,7 +138,7 @@ function locate(vendor, binary, runtime, deps) {
180
138
  return failure(`${name} isn't installed on this computer.`, 1, "not_installed");
181
139
  }
182
140
  /** Everything about the command that is decided here, before any request. */
183
- function prepare(args, runtime, deps, auth) {
141
+ function prepare(args, runtime, deps, auth, caller) {
184
142
  const target = execTarget(args.positionals);
185
143
  if ("refused" in target)
186
144
  return failure(target.refused, 6, "exec_refused");
@@ -200,7 +158,8 @@ function prepare(args, runtime, deps, auth) {
200
158
  .replace(/[\u0000-\u001f\u007f]/g, "")
201
159
  .slice(0, 80);
202
160
  const summary = redactCommand([binary, ...rest].map(quote).join(" "));
203
- const runtimeName = declared ?? (auth.kind === "agent-key" ? "cloud" : (callerFrom(args, runtime.env) ?? "terminal"));
161
+ // The agent that ran it (Passport records the action as that agent's), else a person in a terminal.
162
+ const runtimeName = declared ?? (auth.kind === "agent-key" ? "cloud" : (caller ?? "terminal"));
204
163
  return {
205
164
  vendor,
206
165
  binary,
@@ -222,8 +181,20 @@ function prepare(args, runtime, deps, auth) {
222
181
  }
223
182
  };
224
183
  }
184
+ /** The agent that ran this command: `--caller` or its environment markers, else (a member's own sign-in) the
185
+ * processes above this one. Only the kind is sent. */
186
+ function execCaller(args, env, auth, deps) {
187
+ const named = callerFrom(args, env);
188
+ if (named || auth.kind === "agent-key" || value(args, "client") !== undefined)
189
+ return named;
190
+ if (deps.agentAbove)
191
+ return deps.agentAbove();
192
+ const { readProcessTable, agentAbove } = callingAgentModule;
193
+ const table = readProcessTable();
194
+ return table ? agentAbove(table, process.ppid) : undefined;
195
+ }
225
196
  export async function exec(args, runtime, deps = {}) {
226
- // git holds no key: its helper decides once exec names the command (execGit.ts).
197
+ // git: the guard decides every push itself; exec doesn't run git in v1 (execGit.ts).
227
198
  if (args.positionals[0] === "git")
228
199
  return (await import("./execGit.js")).execGit(args, runtime, deps);
229
200
  // Refusals come first: nothing is read or sent for a command exec won't run.
@@ -232,103 +203,64 @@ export async function exec(args, runtime, deps = {}) {
232
203
  return failure(target.refused, 6, "exec_refused");
233
204
  locate(target.vendor, target.binary, runtime, deps);
234
205
  const auth = resolveCliAuth(args, runtime.env);
235
- const prepared = prepare(args, runtime, deps, auth);
206
+ const caller = execCaller(args, runtime.env, auth, deps);
207
+ const prepared = prepare(args, runtime, deps, auth, caller);
236
208
  await execRailwayScope(prepared, auth, runtime.env, deps.home, value(args, "decision"));
237
209
  await execSupabaseProject(prepared, runtime.env);
238
210
  const { vendor, binary } = prepared;
239
211
  const client = deps.api ??
240
- memberApi({ auth, caller: callerFrom(args, runtime.env), timeoutMs: timeoutMs(args), signal: runtime.signal });
241
- const remember = (present) => {
242
- if (auth.kind === "profile")
243
- noteExecVendor(auth.profile, vendor, present);
244
- };
245
- const ask = async () => {
246
- try {
247
- return await post(client, prepared.body, runtime, timeoutMs(args), binary);
248
- }
249
- catch (error) {
250
- // The guard stops sending this CLI through exec once Passport has no key
251
- // for it, and its shim goes, so the CLI runs on its own again.
252
- if (error instanceof CliFailure && error.cause === "no_key") {
253
- remember(false);
254
- const removed = removeShims([vendor]);
255
- if (removed.length && !bool(args, "quiet")) {
256
- runtime.stderr.write(`Removed Passport's ${removed.join(" and ")} shim, so ${binary} runs on its own again.\n`);
257
- }
258
- if (auth.kind === "profile") {
259
- throw (await import("./execNoKey.js")).keyHereFailure(error, vendor, runtime, deps.home);
260
- }
261
- }
262
- throw error;
263
- }
264
- };
212
+ memberApi({
213
+ auth,
214
+ caller: value(args, "client") ?? caller,
215
+ timeoutMs: timeoutMs(args),
216
+ signal: runtime.signal
217
+ });
265
218
  // Batch A: the daily guard report, so a team's Guard required sees this computer.
266
219
  if (auth.kind === "profile" && !deps.api) {
267
220
  await (await import("./cliExecGuard.js")).execHeartbeat(client.fetchApi, auth.profile, runtime.signal);
268
221
  }
269
222
  // A vendor CLI that is a basic platform for this person: the control plane decides its verb first.
270
223
  await basicDecision(client.fetchApi, auth.kind === "profile" ? auth.profile : null, prepared, runtime, args);
271
- const decided = await ask();
224
+ const decided = await post(client, prepared.body, runtime, timeoutMs(args), binary);
272
225
  if (decided.decision !== "allow") {
273
226
  const message = typeof decided.message === "string" && decided.message ? decided.message : "Passport didn't allow this command.";
227
+ if (decided.decision === "undecided")
228
+ return failure(message, 5, "undecided");
274
229
  // Blocked by the app's access: say where an admin changes it.
275
230
  const link = decided.decision === "block" ? hashLink(auth.endpoint, decided.link) : null;
276
231
  if (link)
277
232
  return failure(message, 5, "no_access", { hint: `Access: ${link}` });
278
233
  return failure(message, 5, "blocked");
279
234
  }
280
- // A Railway token Passport minted is revoked however the command ends: it exits, is refused, or never starts.
281
- const issued = execRelease(client.fetchApi, vendor, decided);
282
235
  let code;
283
236
  const startedAt = (deps.now ?? Date.now)();
284
237
  // Links (bridge 0.32.0): a bounded copy of what it prints, only when that isn't a terminal.
285
238
  const capture = execCapture(execIdsWanted(vendor, decided, true), runtime.stdout);
239
+ // The control plane decides a gh command (unless authorize did), and a supabase command (unless the guard did).
240
+ const ids = await execControlPlaneRefusal(client.fetchApi, prepared, decided, timeoutMs(args), {
241
+ ...(runtime.signal ? { signal: runtime.signal } : {}),
242
+ asks: auth.kind === "profile",
243
+ env: runtime.env
244
+ });
245
+ const piped = outputTarget(runtime, [], capture);
246
+ const options = {
247
+ stdio: piped ? ["inherit", "pipe", "pipe"] : "inherit",
248
+ env: childEnvironment(runtime.env),
249
+ shell: false,
250
+ cwd: prepared.cwd
251
+ };
286
252
  try {
287
- const credential = checkedCredential(vendor, decided.credential?.env, decided.credential?.ownSignIn);
288
- remember(true);
289
- // The control plane decides a gh command with its token's id, and a supabase command (unless the guard did).
290
- const ids = await execControlPlaneRefusal(client.fetchApi, prepared, decided, timeoutMs(args), {
291
- ...(runtime.signal ? { signal: runtime.signal } : {}),
292
- asks: auth.kind === "profile",
293
- env: runtime.env
294
- });
295
- // A dev loop runs only with a key that expires within minutes.
296
- const devLoop = devLoopRefusal(vendor, args.positionals.slice(1), decided.credential?.issuance);
297
- if (devLoop)
298
- return failure(devLoop, 6, "exec_refused");
299
- if (bool(args, "verbose") && typeof decided.credential?.label === "string") {
300
- // "Your stored Railway key" reads "Passport: used your stored Railway key."
301
- const label = decided.credential.label.slice(0, 120);
302
- runtime.stderr.write(`Passport: used ${label.charAt(0).toLowerCase()}${label.slice(1)}.\n`);
303
- }
304
- const needles = maskingWanted(args, runtime.env, runtime.stdout) ? secretNeedles(credential) : [];
305
- const piped = outputTarget(runtime, needles, capture);
306
- const handed = await handOver(prepared, credential, decided.credential?.expiresAt, runtime, deps);
307
- const options = {
308
- stdio: piped ? ["inherit", "pipe", "pipe"] : "inherit",
309
- env: { ...childEnvironment(runtime.env, handed.env), ...issued.env },
310
- shell: false,
311
- cwd: prepared.cwd
312
- };
313
- try {
314
- const running = deps.spawn
315
- ? deps.spawn(prepared.executable, prepared.rest, options)
316
- : spawnVendor(prepared.executable, prepared.rest, options, piped);
317
- // Decided and started: the kit's shadow run reads the command now (`kitShadow.ts`), off both.
318
- shadowAfterDecision();
319
- code = await running;
320
- }
321
- catch {
322
- return failure(`${binary} couldn't start.`, 1, "not_installed");
323
- }
324
- finally {
325
- await handed.stop();
326
- }
327
- await ids.report(capture, code);
253
+ const running = deps.spawn
254
+ ? deps.spawn(prepared.executable, prepared.rest, options)
255
+ : spawnVendor(prepared.executable, prepared.rest, options, piped);
256
+ // Decided and started: the kit's shadow run reads the command now (`kitShadow.ts`), off both.
257
+ shadowAfterDecision();
258
+ code = await running;
328
259
  }
329
- finally {
330
- await issued.release();
260
+ catch {
261
+ return failure(`${binary} couldn't start.`, 1, "not_installed");
331
262
  }
263
+ await ids.report(capture, code);
332
264
  if (typeof decided.actionId === "string") {
333
265
  const durationMs = Math.max(0, Math.round((deps.now ?? Date.now)() - startedAt));
334
266
  const links = execLinks(true, prepared, capture, deps.home);
@@ -336,40 +268,6 @@ export async function exec(args, runtime, deps = {}) {
336
268
  }
337
269
  return { json: { exitCode: code }, silent: true, exitCode: code };
338
270
  }
339
- /** How the credential reaches the CLI: its variables, or for CLIs that read
340
- * none (Firebase, az, azd) a local endpoint that serves the token while it
341
- * runs (execGoogle.ts, execAzure.ts). */
342
- async function handOver(prepared, credential, expiresAt, runtime, deps) {
343
- const { vendor } = prepared;
344
- if (vendor === "firebase") {
345
- const token = credential.GOOGLE_OAUTH_ACCESS_TOKEN;
346
- if (!token)
347
- return failure("Passport returned no key for this command. Nothing ran.", 1, "invalid_server_response");
348
- const { serveGoogleToken } = await import("./execGoogle.js");
349
- try {
350
- return await serveGoogleToken(token, typeof expiresAt === "number" ? expiresAt : undefined);
351
- }
352
- catch {
353
- return failure("Passport couldn't hand Firebase its token on this computer. Nothing ran.", 1, "not_installed");
354
- }
355
- }
356
- if (vendor !== "az" && vendor !== "azd")
357
- return { env: credential, stop: async () => undefined };
358
- const which = deps.which ?? ((name) => findVendorBinary(name, runtime.env, process.platform));
359
- const start = deps.spawn ?? spawnVendor;
360
- const handed = await (await import("./execAzure.js")).azureExecHandOver({
361
- vendor,
362
- credential,
363
- expiresAt,
364
- args: prepared.rest,
365
- env: runtime.env,
366
- childEnv: childEnvironment(runtime.env, {}),
367
- home: deps.home ?? homedir(),
368
- az: vendor === "az" ? prepared.executable : which("az"),
369
- step: (command, args, env) => start(command, args, { stdio: "ignore", env, shell: false, cwd: prepared.cwd })
370
- });
371
- return "error" in handed ? failure(handed.error, 1, handed.code) : handed;
372
- }
373
271
  import { execCapture, execLinks, outputTarget, reportExecResult } from "./execLinks.js";
374
272
  /** How long exec waits to refresh which vendors are basic platforms. */
375
273
  const VENDORS_REFRESH_MS = 2_000;
@@ -419,7 +317,7 @@ async function basicDecision(api, profile, prepared, runtime, args) {
419
317
  return;
420
318
  const { askCliVerb } = await import("./controlPlaneCli.js");
421
319
  const session = value(args, "session");
422
- // Authorize decides it again and spends an Allow once with the credential: this ask only finds it.
320
+ // Authorize decides it again; `exec` tells the server this ask comes first.
423
321
  const extra = { exec: true, ...(session ? { sessionId: session } : {}) };
424
322
  const answer = await askCliVerb(api, vendor, verb, extra, runtime.signal);
425
323
  if (answer.kind === "block")
@@ -2,6 +2,7 @@ import { type ParsedArgs } from "./cliArgs.js";
2
2
  import { type CommandResult, type Runtime } from "./cliSupport.js";
3
3
  import { type ReadProcess } from "./gitInvocation.js";
4
4
  import { type RunGit } from "./gitCredentialSetup.js";
5
+ import { type CredentialsSwitch } from "./offInV1.js";
5
6
  export declare const GIT_CREDENTIAL_PATH = "/api/my/github/git-credential";
6
7
  export declare const TOKEN_USERNAME = "x-access-token";
7
8
  /** git waits on us for every fetch and push: past this in all, the push uses this computer's own sign-in. */
@@ -9,7 +10,7 @@ export declare const MINT_TIMEOUT_MS = 5000;
9
10
  /** Each decision gets at most this long, within what's left of the whole. */
10
11
  export declare const DECIDE_TIMEOUT_MS = 1000;
11
12
  type ApiCall = (path: string, init: RequestInit) => Promise<Response>;
12
- export type GitCredentialDependencies = {
13
+ export type GitCredentialDependencies = CredentialsSwitch & {
13
14
  api?: ApiCall;
14
15
  /** Which git command asked (tests); the default walks this process's parents. */
15
16
  clock?: () => number;
@@ -25,6 +25,13 @@
25
25
  * on stdout only: never to disk, a log or stderr.
26
26
  *
27
27
  * passport git-credential setup [--remove] point git at Passport for github.com (or undo it)
28
+ *
29
+ * Off in v1 (offInV1.ts): Passport issues no git tokens and this file never
30
+ * calls the server. `get` hands the request to the helpers git used before
31
+ * setup (else answers nothing), never `quit=1`, always exit 0; `store` and
32
+ * `erase` go to them too; `setup` prints one line and changes nothing;
33
+ * `setup --remove` and `probe` work as before. The token path above is
34
+ * switched off, not deleted.
28
35
  */
29
36
  import { spawn } from "node:child_process";
30
37
  import { askControlPlane } from "./controlPlaneGuard.js";
@@ -40,6 +47,7 @@ import { MAX_PUSH_REFS, planKey, planPush } from "./gitPush.js";
40
47
  import { beginShadowLine, shadowAfterDecision, shadowAlongside, shadowGithubLine } from "./kitShadow.js";
41
48
  import { takePushDecisions } from "./gitPushDecisions.js";
42
49
  import { helperLine, helperProgram, installGitCredential, probeHelper, readGitCredentialState, removeGitCredential } from "./gitCredentialSetup.js";
50
+ import { GIT_OFF, issuesCredentials, offResult } from "./offInV1.js";
43
51
  export const GIT_CREDENTIAL_PATH = "/api/my/github/git-credential";
44
52
  export const TOKEN_USERNAME = "x-access-token";
45
53
  const REPO_PATH = /^([A-Za-z0-9_.-]{1,100})\/([A-Za-z0-9_.-]{1,100}?)(?:\.git)?\/?$/;
@@ -109,8 +117,9 @@ const runFallback = (helper, operation, input, env) => new Promise((resolve) =>
109
117
  child.stdin.on("error", () => undefined);
110
118
  child.stdin.end(input);
111
119
  });
112
- /** Ask the helpers git used before setup, in order, as git would; the first that answers wins. */
113
- async function delegate(operation, input, runtime, deps) {
120
+ /** Ask the helpers git used before setup, in order, as git would; the first that answers wins. `quit`: whether
121
+ * a helper's quit stops there (in v1 it doesn't: the next helper is asked). */
122
+ async function delegate(operation, input, runtime, deps, quit = true) {
114
123
  const helpers = readGitCredentialState()?.fallback ?? [];
115
124
  const run = deps.fallback ?? runFallback;
116
125
  // The path is there for Passport (useHttpPath); the earlier helpers stored their
@@ -126,11 +135,18 @@ async function delegate(operation, input, runtime, deps) {
126
135
  }
127
136
  for (const helper of helpers) {
128
137
  const answer = await run(helper, operation, input, runtime.env);
129
- if (/^(?:password|quit)=/m.test(answer))
138
+ if ((quit ? /^(?:password|quit)=/m : /^password=/m).test(answer))
130
139
  return answer;
131
140
  }
132
141
  return "";
133
142
  }
143
+ /** A helper's answer without `quit`: in v1 git always moves on to its next helper or asks. */
144
+ function withoutQuit(answer) {
145
+ return answer
146
+ .split("\n")
147
+ .filter((line) => !line.startsWith("quit="))
148
+ .join("\n");
149
+ }
134
150
  /**
135
151
  * `work` with a signal aborted after `ms`. The timer holds the process open
136
152
  * (`AbortSignal.timeout`'s doesn't), so git always gets an answer by the
@@ -445,6 +461,10 @@ function answers(line, env, deps) {
445
461
  /* -------------------------------- entry --------------------------------- */
446
462
  export async function gitCredential(args, runtime, deps = {}) {
447
463
  const [operation] = args.positionals;
464
+ // Off in v1: setup changes nothing; --remove still takes Passport out of git's config.
465
+ const on = issuesCredentials(deps);
466
+ if (operation === "setup" && !on && !bool(args, "remove"))
467
+ return offResult("git-credential setup", GIT_OFF);
448
468
  if (operation === "setup")
449
469
  return setup(args, runtime, deps);
450
470
  // Setup, init and status ask the helper line this, to know it runs a Passport that answers git.
@@ -456,7 +476,11 @@ export async function gitCredential(args, runtime, deps = {}) {
456
476
  const input = await readInput(runtime);
457
477
  let out = "";
458
478
  try {
459
- if (operation === "get")
479
+ // Off in v1: no token from Passport. The helpers git used before setup answer, else nothing, so git
480
+ // asks the next helper or the person. Never quit=1: Passport doesn't stop git here.
481
+ if (operation === "get" && !on)
482
+ out = withoutQuit(await delegate("get", input, runtime, deps, false));
483
+ else if (operation === "get")
460
484
  out = await get(args, runtime, deps, input);
461
485
  // A token Passport issued is never stored: git would offer an expired one next time.
462
486
  else if (parseCredentialRequest(input).get("username") !== TOKEN_USERNAME) {
@@ -259,6 +259,8 @@ export async function sendGuardHealth(api, profile, env, signal) {
259
259
  * so Agents shows each agent's guard without waiting a day.
260
260
  */
261
261
  export async function guardHeartbeat(api, profile, env, signal, now = Date.now(), force = false) {
262
+ // Once, on the first run with credentials off in v1: clear the old key custody's state (keysV1Cleanup.ts).
263
+ (await import("./keysV1Cleanup.js")).clearKeyCustodyOnce(now);
262
264
  const due = claimGuardHeartbeat(profile, now);
263
265
  if (!due && !(force && stampHeartbeat(profile, now)))
264
266
  return null;
package/dist/cliHook.d.ts CHANGED
@@ -17,8 +17,9 @@
17
17
  */
18
18
  import { type ParsedArgs } from "./cliArgs.js";
19
19
  import { type CliFinding } from "./cliHookClassify.js";
20
+ import { type GuardClient } from "./cliHookGuard.js";
20
21
  import { type HookInput } from "./cliHookInput.js";
21
- import { type CliHookReport, type HookDependencies, type HookRuntime } from "./cliHookDeliver.js";
22
+ import { type ApiCall, type CliHookReport, type HookDependencies, type HookRuntime } from "./cliHookDeliver.js";
22
23
  export { HOOK_BUDGET_MS, HOOK_RUNTIMES, type CliHookReport, type HookDependencies, type HookRuntime, type ReportedFinding } from "./cliHookDeliver.js";
23
24
  export { outcomeOf } from "./cliHookOutcome.js";
24
25
  import type { CommandResult, Env, Runtime } from "./cliSupport.js";
@@ -48,4 +49,6 @@ export declare function buildReport(input: HookInput, findings: CliFinding[], en
48
49
  export declare function shellEvent(input: HookInput): ShellEvent | null;
49
50
  /** `passport exec` records its own action, with its decision and credential. */
50
51
  export declare function isPassportExec(command: string): boolean;
52
+ /** Calls that name the agent (`x-passport-caller`): its kind only. */
53
+ export declare function asCaller(api: ApiCall | null, client: GuardClient): ApiCall | null;
51
54
  export declare function hook(args: ParsedArgs, runtime: Runtime, deps?: HookDependencies): Promise<CommandResult>;
package/dist/cliHook.js CHANGED
@@ -288,6 +288,16 @@ async function runGuard(args, runtime, deps) {
288
288
  refuseLocal();
289
289
  }
290
290
  }
291
+ /** Calls that name the agent (`x-passport-caller`): its kind only. */
292
+ export function asCaller(api, client) {
293
+ if (!api)
294
+ return null;
295
+ return (path, init) => {
296
+ const headers = new Headers(init.headers);
297
+ headers.set("x-passport-caller", client);
298
+ return api(path, { ...init, headers });
299
+ };
300
+ }
291
301
  /** The guard's answer for a classified line; throws only before it has written an answer. */
292
302
  async function guardLine(at) {
293
303
  const { args, runtime, deps, input, event, machine, line, local, declared, client, budget } = at;
@@ -298,11 +308,8 @@ async function guardLine(at) {
298
308
  const deadline = at.startedAt + HOOK_BUDGET_MS - PRINT_RESERVE_MS;
299
309
  // An agent key asks with its own key: what it may run is decided like anyone's (cli:local's Always allow included).
300
310
  const agentApi = agentKeyApi(runtime.env, deps.fetch ?? fetch);
301
- const openApi = () => agentApi
302
- ? Promise.resolve(agentApi)
303
- : profile
304
- ? profileApi(profile, budget, deps.fetch ?? fetch).catch(() => null)
305
- : Promise.resolve(null);
311
+ // Every decision names the agent this hook runs in, so Passport records the action as that agent's.
312
+ const openApi = async () => asCaller(agentApi ?? (profile ? await profileApi(profile, budget, deps.fetch ?? fetch).catch(() => null) : null), client);
306
313
  // A sign-in for a CLI whose key Passport holds (any agent), or the rewrite to exec (Claude Code).
307
314
  const early = profile
308
315
  ? await (await import("./cliHookRewrite.js")).guardEarlyAnswer({
@@ -140,8 +140,7 @@ async function askVerbs(verbs, open, extra, signal) {
140
140
  const { askCliVerb } = await import("./controlPlaneCli.js");
141
141
  return Promise.all(verbs.map(([vendor, verb]) => askCliVerb(api, vendor, verb, extra, signal)));
142
142
  }
143
- /** GitHub's part of a line. Every `git push` is decided here, ref by ref, resolved as git will in this folder; with
144
- * `passport git-credential` set up, the helper spends these decisions on the push token instead of asking again. */
143
+ /** GitHub's part of a line. Every `git push` is decided here, ref by ref, resolved as git will in this folder. */
145
144
  async function githubLinePlan(context, open, extra, signal) {
146
145
  const cp = await import("./controlPlaneGuard.js");
147
146
  const where = context.cwd ? { cwd: context.cwd } : undefined;
@@ -157,19 +156,11 @@ async function holdLate(answers, report, now) {
157
156
  if (late.length && report?.toolUseId)
158
157
  (await import("./controlPlaneLateHold.js")).holdLate(report.sessionId, report.toolUseId, late, now);
159
158
  }
160
- /** An allowed line that runs: Railway's decision waits for exec, each push's for `passport git-credential` when it is
161
- * set up (`gitPushDecisions.ts`), and the ids of decides left unanswered for the after-hook. */
159
+ /** An allowed line that runs: Railway's decision waits for exec, and the ids of decides left unanswered for the
160
+ * after-hook. */
162
161
  async function leaveDecisions(github, railway, context, others) {
162
+ // A push's decisions are no longer left for `passport git-credential`: it issues no token in v1 (2026-11-16).
163
163
  if (railway)
164
164
  await railway.leave();
165
- if (github?.pushes.length) {
166
- const [{ gitHelperInstalled }, { leavePushDecisions }] = await Promise.all([
167
- import("./gitCredentialSetup.js"),
168
- import("./gitPushDecisions.js")
169
- ]);
170
- if (gitHelperInstalled())
171
- for (const push of github.pushes)
172
- leavePushDecisions(push.key, push.decisionIds);
173
- }
174
165
  await holdLate([github?.answer, railway?.answer, ...others], context.report, context.now());
175
166
  }
@@ -83,7 +83,8 @@ export type GuardEarlyInput = GuardRewriteInput & {
83
83
  cursorImported: boolean;
84
84
  canReport: boolean;
85
85
  };
86
- /** Before the guard asks Passport: a vendor sign-in while Passport holds
87
- * the key (every agent), or the rewrite to `passport exec` (Claude Code). */
86
+ /** Before the guard asks Passport: the allow for a `passport exec` the agent wrote (Claude Code), which decides
87
+ * through Passport itself. Since v1 (decided 2026-11-16) Passport holds no keys, so the guard never rewrites a vendor
88
+ * command to `passport exec` and never denies a vendor sign-in: it decides the command in place. */
88
89
  export declare function guardEarlyAnswer(input: GuardEarlyInput): Promise<Record<string, unknown> | null>;
89
90
  export {};
@@ -1,4 +1,7 @@
1
1
  /**
2
+ * Off in v1 (decided 2026-11-16): Passport holds no keys, so `guardEarlyAnswer` no longer rewrites or denies sign-ins;
3
+ * it only allows a `passport exec` the agent wrote. The rewrite below is kept until a later cleanup deletes it.
4
+ *
2
5
  * Guard rewrite: when an agent runs a vendor CLI whose key lives in Passport,
3
6
  * the guard sends the command through `passport exec` instead, so the key is
4
7
  * released only after Passport decides.
@@ -342,11 +345,12 @@ export async function guardLogin(command, profile, client) {
342
345
  const { readKeysChoices } = await import("./keysKept.js");
343
346
  return loginDenyOutput(client, heldLogins(command, vendors, readKeysChoices(profile).kept));
344
347
  }
345
- /** Before the guard asks Passport: a vendor sign-in while Passport holds
346
- * the key (every agent), or the rewrite to `passport exec` (Claude Code). */
348
+ /** Before the guard asks Passport: the allow for a `passport exec` the agent wrote (Claude Code), which decides
349
+ * through Passport itself. Since v1 (decided 2026-11-16) Passport holds no keys, so the guard never rewrites a vendor
350
+ * command to `passport exec` and never denies a vendor sign-in: it decides the command in place. */
347
351
  export async function guardEarlyAnswer(input) {
348
- const login = await guardLogin(input.command, input.profile, input.client);
349
- if (login)
350
- return login;
351
- return input.canReport && input.client === "claude-code" && !input.cursorImported ? guardRewrite(input) : null;
352
+ if (!input.canReport || input.client !== "claude-code" || input.cursorImported)
353
+ return null;
354
+ const inner = execInner(input.command);
355
+ return inner ? execCommandOutput(inner) : null;
352
356
  }
package/dist/cliKeys.js CHANGED
@@ -1,16 +1,12 @@
1
1
  /**
2
- * `passport keys`: keys leave this computer and live in Passport.
3
- *
2
+ * `passport keys`. Off in v1 (keysInV1.ts): the list shows the keys found here, which stay; the commands below are
3
+ * switched off, not deleted. What they did:
4
4
  * passport keys [list] what Passport holds, and what's still here
5
5
  * passport keys move [--yes] confirm each key, store it, sign that CLI out
6
- * passport keys add <cli> store a key you paste (stdin, never echoed);
7
- * gcloud and firebase take a key file's path
6
+ * passport keys add <cli> store a key you paste (stdin, never echoed); gcloud and firebase take a key file
8
7
  * passport keys rotate <app> replace a key Passport holds, checked first (cliKeysRotate.ts)
9
- *
10
- * A key is stored first and removed from this computer second, so nothing is
11
- * ever lost: a sign-out that fails leaves the key in Passport and says what is
12
- * left on disk. `.env` files are never touched. The server only ever gets the
13
- * value once, in the request that stores it; reports carry counts only.
8
+ * A key is stored first and removed from this computer second, so nothing is ever lost. `.env` files are never
9
+ * touched. The server only ever gets the value once, in the request that stores it; reports carry counts only.
14
10
  */
15
11
  import { execFileSync } from "node:child_process";
16
12
  import { hostname } from "node:os";
@@ -38,6 +34,8 @@ import { unknownSubcommand } from "./cliSuggest.js";
38
34
  import { ago, layout, mark, promptRows, table, termOf } from "./term.js";
39
35
  import { pathLines } from "./pathLines.js";
40
36
  import { countOf } from "./plural.js";
37
+ import { issuesCredentials } from "./offInV1.js";
38
+ import { keysInV1 } from "./keysInV1.js";
41
39
  export const KEYS_PATH = "/api/my/keys";
42
40
  export { SIGNED_OUT_OFF, SIGNED_OUT_ON, heldKeys };
43
41
  const KEY_CLIS = "railway|gh|vercel|wrangler|supabase|stripe|aws|neonctl|flyctl|gcloud|firebase|az|azd";
@@ -573,6 +571,9 @@ async function storeAdded(api, args, runtime, deps, vendor, secret) {
573
571
  }
574
572
  export async function keys(args, runtime, deps = {}) {
575
573
  const action = args.positionals[0] ?? "list";
574
+ const off = issuesCredentials(deps) ? undefined : keysInV1(action, runtime, deps);
575
+ if (off)
576
+ return off;
576
577
  if (action === "list")
577
578
  return list(args, runtime, deps);
578
579
  if (action === "move")