passport-bridge 0.17.0 → 0.18.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.
package/dist/cliScan.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { statSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
3
  import { COMMANDS, bool, value } from "./cliArgs.js";
4
- import { failure, selfCommand } from "./cliSupport.js";
4
+ import { CliFailure, failure, selfCommand } from "./cliSupport.js";
5
5
  import { oneLinerNodeProblem } from "./nodeVersion.js";
6
6
  import { runScan } from "./scan.js";
7
7
  import { countOf } from "./plural.js";
@@ -15,13 +15,16 @@ const CHECKED = {
15
15
  const INDENT = " ";
16
16
  /** The scan's closing pitch names `init` only once that command ships. */
17
17
  const INIT_AVAILABLE = COMMANDS.includes("init");
18
- /** `passport scan` / `npx passport-bridge@latest scan`. Local only: no account, no network. */
18
+ /** `passport scan` / `npx passport-bridge@latest scan`. The key scan is local
19
+ * only: no account, no network. Signed in (`inventory`), it then sends the
20
+ * MCP-config inventory `passport discover` used to send: server names and how
21
+ * they connect, never a key. `--check` (CI, pre-commit) stays local. */
19
22
  export async function scan(args, runtime, context = {
20
23
  cwd: process.cwd(),
21
24
  initAvailable: INIT_AVAILABLE,
22
25
  platform: process.platform,
23
26
  nodeVersion: process.versions.node
24
- }) {
27
+ }, inventory) {
25
28
  const { cwd } = context;
26
29
  const nodeProblem = oneLinerNodeProblem(context.nodeVersion);
27
30
  if (nodeProblem)
@@ -39,12 +42,14 @@ export async function scan(args, runtime, context = {
39
42
  });
40
43
  }
41
44
  const { report } = result;
45
+ const sent = inventory && !bool(args, "check") ? await sendInventory(inventory) : undefined;
42
46
  const human = renderScan(result, {
43
47
  color: colorEnabled(runtime),
44
48
  width: terminalWidth(runtime),
45
49
  verbose: bool(args, "verbose"),
46
50
  initCommand: context.initAvailable ? `${self} init` : undefined,
47
- platform: context.platform
51
+ platform: context.platform,
52
+ ...(sent ? { inventory: sent.lines } : {})
48
53
  });
49
54
  // Last line of defense: nothing that reaches stdout may hold a fragment of a key.
50
55
  if (result.leaks(human) || result.leaks(JSON.stringify(report))) {
@@ -53,13 +58,25 @@ export async function scan(args, runtime, context = {
53
58
  });
54
59
  }
55
60
  const serious = report.findings.some((finding) => finding.severity !== "low");
61
+ const blocked = sent?.outcome?.compliant === false;
56
62
  return {
57
- json: report,
63
+ json: sent ? { ...report, inventory: sent.outcome?.json ?? { error: sent.lines[0] } } : report,
58
64
  human,
59
- essential: report.findings.length > 0,
60
- exitCode: bool(args, "check") && serious ? 5 : 0
65
+ essential: report.findings.length > 0 || Boolean(sent),
66
+ exitCode: (bool(args, "check") && serious) || blocked ? 5 : 0
61
67
  };
62
68
  }
69
+ /** The inventory never fails the scan: a problem is one line instead. */
70
+ async function sendInventory(inventory) {
71
+ try {
72
+ const outcome = await inventory();
73
+ return { outcome, lines: outcome.lines };
74
+ }
75
+ catch (error) {
76
+ const why = error instanceof CliFailure ? ` ${error.message}` : "";
77
+ return { lines: [`Couldn't send this computer's MCP setup to Passport.${why}`] };
78
+ }
79
+ }
63
80
  function scanRoot(raw, cwd, command) {
64
81
  if (raw === undefined)
65
82
  return cwd;
@@ -139,7 +156,11 @@ export function renderScan(result, options) {
139
156
  : "Stopped early to stay fast.";
140
157
  lines.push(`${why} Use --path to scan one project.`);
141
158
  }
142
- lines.push(paint("dim", "Nothing left this computer."));
159
+ if (options.inventory) {
160
+ lines.push(paint("dim", "No key left this computer."), ...options.inventory);
161
+ }
162
+ else
163
+ lines.push(paint("dim", "Nothing left this computer."));
143
164
  if (count && options.initCommand) {
144
165
  lines.push("", `Give agents access without these keys: ${paint("bold", options.initCommand)}`);
145
166
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `passport setup --org <pek_…> --lock [--strict] [--yes]`, run as root:
2
+ * `passport init --org <pek_…> --yes --lock [--strict]`, run as root:
3
3
  * Passport's guard and audit hooks in each agent's managed (system) settings,
4
4
  * where people can't turn them off. Managed settings run a root-owned launcher
5
5
  * (the shim) that hands off to each person's own CLI.
@@ -1,7 +1,8 @@
1
1
  /**
2
- * `passport setup --org <pek_…> [--yes] [--clients claude-code,cursor,…]`:
2
+ * `passport init --org <pek_…> --yes [--agents claude-code,cursor,…]`:
3
3
  * `passport init` for MDM and scripts. It never asks anything and never signs
4
4
  * in; each agent's own sign-in (or `passport login`) does that later.
5
+ * `passport setup --org` is its old name and still runs it for one release.
5
6
  *
6
7
  * 1. A stable copy of the CLI in `$PASSPORT_HOME/cli/<version>/`.
7
8
  * 2. Passport in every detected agent, at the one URL with the enrollment
@@ -207,18 +208,27 @@ function summary(where, key, url, lines, layout) {
207
208
  ...(url && working ? say("Each agent asks you to sign in to Passport the first time it connects.") : [])
208
209
  ].join("\n");
209
210
  }
210
- export async function setupOrg(args, runtime, deps = {}) {
211
- ensureOneLinerRuntime();
211
+ /** The rollout's own options, checked before anything is read or written. */
212
+ function orgArgs(args) {
212
213
  const key = value(args, "org")?.trim() ?? "";
213
214
  if (!isEnrollmentKey(key)) {
214
215
  return failure("--org takes your company's enrollment key, which starts with pek_.", 6, "usage");
215
216
  }
217
+ const verb = args.command === "setup" ? "passport setup --org" : "passport init --org";
216
218
  if (args.positionals.length)
217
- return failure("passport setup --org takes no other arguments.", 6, "usage");
219
+ return failure(`${verb} takes no other arguments.`, 6, "usage");
220
+ // init's own steps (sign-in, apps, keys, the plan) aren't part of a company rollout.
221
+ const own = ["dry-run", "move-keys", "skip-apps", "skip-agents", "skip-guard", "no-open", "verbose"].find((flag) => bool(args, flag));
222
+ if (own)
223
+ return failure(`--${own} doesn't go with --org.`, 6, "usage");
218
224
  const lock = bool(args, "lock");
219
225
  if (bool(args, "strict") && !lock)
220
226
  return failure("--strict goes with --lock.", 6, "usage");
221
- const only = requestedClients(value(args, "clients"));
227
+ return { key, lock, only: requestedClients(value(args, "clients")) };
228
+ }
229
+ export async function setupOrg(args, runtime, deps = {}) {
230
+ ensureOneLinerRuntime();
231
+ const { key, lock, only } = orgArgs(args);
222
232
  const env = runtime.env;
223
233
  const home = deps.home ?? homedir();
224
234
  const platform = deps.platform ?? process.platform;
@@ -258,7 +268,9 @@ export async function setupOrg(args, runtime, deps = {}) {
258
268
  home,
259
269
  platform,
260
270
  url: url ?? `${origin}/mcp`,
261
- workspaceId: "",
271
+ // The key's workspace, so its own old URL moves to the one URL and
272
+ // another workspace's entry is left alone.
273
+ workspaceId: lookup.kind === "ok" ? lookup.workspaceId : "",
262
274
  version: VERSION,
263
275
  ...deps.agents
264
276
  };
@@ -1,4 +1,4 @@
1
- import { COMMANDS } from "./cliArgs.js";
1
+ import { VISIBLE_COMMANDS } from "./cliArgs.js";
2
2
  const DESCRIPTIONS = {
3
3
  init: "Set up Passport for your agents, step by step",
4
4
  login: "Sign in or sign up in the browser",
@@ -14,8 +14,8 @@ const DESCRIPTIONS = {
14
14
  connect: "Connect member app accounts",
15
15
  resources: "List or read MCP resources",
16
16
  prompts: "List or get MCP prompts",
17
- scan: "Find keys your agents can reach. Local, no account",
18
- discover: "Scan local MCP configuration for fleet governance",
17
+ scan: "Find the keys and MCP servers your agents can reach",
18
+ discover: "Now part of scan",
19
19
  hook: "Record the CLIs your agents run, and decide before they run",
20
20
  wait: "Wait for a person to decide an approval request",
21
21
  rules: "Test what Autopilot decides for a command",
@@ -44,7 +44,11 @@ const COMMAND_FLAGS = {
44
44
  "--skip-guard",
45
45
  "--move-keys",
46
46
  "--dry-run",
47
- "--verbose"
47
+ "--verbose",
48
+ "--org",
49
+ "--agents",
50
+ "--lock",
51
+ "--strict"
48
52
  ],
49
53
  login: ["--cloud", "--workspace", "--agent", "--no-open", "--switch", "--complete", "--verbose"],
50
54
  search: ["--app"],
@@ -54,7 +58,7 @@ const COMMAND_FLAGS = {
54
58
  connect: ["--alias", "--open", "--wait"],
55
59
  resources: ["--out"],
56
60
  prompts: ["--set", "--out"],
57
- setup: ["--agent", "--apply", "--org", "--agents", "--yes", "--cloud", "--lock", "--strict"],
61
+ setup: ["--agent", "--apply"],
58
62
  hook: ["--agent", "--guard", "--apply"],
59
63
  rules: ["--environment"],
60
64
  sessions: ["--status"],
@@ -107,8 +111,8 @@ function flagsFor(command) {
107
111
  return [...GLOBAL, ...(command ? (COMMAND_FLAGS[command] ?? []) : [])];
108
112
  }
109
113
  function bash() {
110
- const commandWords = COMMANDS.join(" ");
111
- const cases = COMMANDS.map((command) => ` ${command}) opts="${flagsFor(command).join(" ")}" ;;`).join("\n");
114
+ const commandWords = VISIBLE_COMMANDS.join(" ");
115
+ const cases = VISIBLE_COMMANDS.map((command) => ` ${command}) opts="${flagsFor(command).join(" ")}" ;;`).join("\n");
112
116
  const valueFlags = [...VALUE_FLAGS].join("|");
113
117
  return `# bash completion for Passport CLI
114
118
  _passport_completion() {
@@ -137,8 +141,8 @@ complete -F _passport_completion passport
137
141
  `;
138
142
  }
139
143
  function zsh() {
140
- const commands = COMMANDS.map((command) => ` '${command}:${DESCRIPTIONS[command]}'`).join("\n");
141
- const cases = COMMANDS.map((command) => {
144
+ const commands = VISIBLE_COMMANDS.map((command) => ` '${command}:${DESCRIPTIONS[command]}'`).join("\n");
145
+ const cases = VISIBLE_COMMANDS.map((command) => {
142
146
  const flags = (COMMAND_FLAGS[command] ?? [])
143
147
  .map((flag) => ` '${flag}[${flag.slice(2).replaceAll("-", " ")}]${VALUE_FLAGS.has(flag) ? ":value:" : ""}'`)
144
148
  .join("");
@@ -178,7 +182,7 @@ compdef _passport passport
178
182
  }
179
183
  function fish() {
180
184
  const lines = ["# fish completion for Passport CLI", "complete -c passport -f"];
181
- for (const command of COMMANDS) {
185
+ for (const command of VISIBLE_COMMANDS) {
182
186
  lines.push(`complete -c passport -n '__fish_use_subcommand' -a ${command} -d '${DESCRIPTIONS[command]}'`);
183
187
  }
184
188
  const global = [
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * A company's enrollment key (`pek_…`) on this computer: recorded by
3
- * `passport setup --org`, then passed as a sign-in hint by `passport login`
3
+ * `passport init --org`, then passed as a sign-in hint by `passport login`
4
4
  * (`POST /api/auth/cli/start { enroll }`) and for attribution when the CLI
5
5
  * credential is minted (`POST /api/my/bridge-credential { enrollmentKey }`).
6
6
  * It is a workspace hint, never a credential: it grants nothing.
@@ -15,7 +15,7 @@ export type AgentContext = {
15
15
  /** The MCP URL agents get: the universal `{origin}/mcp?…` with a hint, or
16
16
  * the workspace's own `{origin}/w/{ws}/mcp` on a server without it. */
17
17
  url: string;
18
- /** Empty when not known yet (`passport setup --org` before any sign-in). */
18
+ /** Empty when not known yet (`passport init --org` before any sign-in). */
19
19
  workspaceId: string;
20
20
  /** The running Passport version, to tell an older Passport install from this one. */
21
21
  version: string;
@@ -26,9 +26,13 @@ export type AgentState = {
26
26
  kind: "absent";
27
27
  } | {
28
28
  kind: "current";
29
- } | {
29
+ }
30
+ /** `move`: an older setup that still works (a workspace's own URL, a local
31
+ * bridge), moved to the one URL. */
32
+ | {
30
33
  kind: "stale";
31
34
  why: string;
35
+ move?: true;
32
36
  } | {
33
37
  kind: "other";
34
38
  message: string;
@@ -69,7 +73,9 @@ export declare function claudeDesktopConfigPath(env: NodeJS.ProcessEnv, home: st
69
73
  */
70
74
  export declare function detectAgents(scanAgents: string[], context: Pick<AgentContext, "env" | "home" | "platform" | "which">): AgentId[];
71
75
  export declare function displayHome(path: string, home: string): string;
72
- /** Where an existing `passport` entry points, and whether init should replace it. */
76
+ /** Where an existing `passport` entry points, and whether init should replace
77
+ * it. Once this Passport serves its one URL, a workspace's own URL
78
+ * (`/w/<ws>/mcp`) and a local bridge entry for this workspace both move to it. */
73
79
  export declare function classifyEntry(raw: unknown, context: AgentContext, agent: AgentId): AgentState;
74
80
  /** The `[mcp_servers.passport]` table of a Codex config, if any. */
75
81
  export declare function codexEntry(text: string): Record<string, string> | undefined;
@@ -81,5 +87,8 @@ export declare function needsWork(plan: AgentPlan): boolean;
81
87
  export declare function backupOnce(path: string): string | undefined;
82
88
  /** Same-folder temporary file, fsync, rename: never half-written. */
83
89
  export declare function writeAtomic(path: string, contents: string, mode?: number): void;
90
+ /** The Codex config without Passport's `[mcp_servers.passport]` table and its
91
+ * subtables (`[mcp_servers.passport.env]`). Everything else stays as written. */
92
+ export declare function withoutCodexEntry(text: string): string;
84
93
  /** Add or update Passport in one agent. Never throws for a config problem. */
85
94
  export declare function applyAgent(plan: AgentPlan, context: AgentContext): ApplyResult;
@@ -159,7 +159,19 @@ function sameUrl(a, b) {
159
159
  return false;
160
160
  }
161
161
  }
162
- /** Where an existing `passport` entry points, and whether init should replace it. */
162
+ /** Is the URL agents get Passport's one URL (`/mcp`), not a workspace's own? */
163
+ function givesOneUrl(context) {
164
+ try {
165
+ const path = passportMcpPath(new URL(context.url));
166
+ return Boolean(path && "universal" in path);
167
+ }
168
+ catch {
169
+ return false;
170
+ }
171
+ }
172
+ /** Where an existing `passport` entry points, and whether init should replace
173
+ * it. Once this Passport serves its one URL, a workspace's own URL
174
+ * (`/w/<ws>/mcp`) and a local bridge entry for this workspace both move to it. */
163
175
  export function classifyEntry(raw, context, agent) {
164
176
  const entry = record(raw);
165
177
  const name = AGENT_NAMES[agent];
@@ -176,7 +188,11 @@ export function classifyEntry(raw, context, agent) {
176
188
  if (theirs && "workspace" in theirs && context.workspaceId && theirs.workspace !== context.workspaceId) {
177
189
  return { kind: "other", message: `${name} uses Passport for another workspace. Left as is.` };
178
190
  }
179
- // Already on this Passport, by the one URL or this workspace's own: it works.
191
+ // This workspace's own URL still works, but agents move to the one URL.
192
+ if (theirs && "workspace" in theirs && context.workspaceId && givesOneUrl(context)) {
193
+ return { kind: "stale", why: "uses this workspace's old URL", move: true };
194
+ }
195
+ // Already on this Passport by the one URL (any hint): it works.
180
196
  if (theirs)
181
197
  return { kind: "current" };
182
198
  }
@@ -208,7 +224,9 @@ export function classifyEntry(raw, context, agent) {
208
224
  if (profileWorkspace && profileWorkspace !== context.workspaceId) {
209
225
  return { kind: "other", message: `${name} uses Passport for another workspace. Left as is.` };
210
226
  }
211
- // A working local bridge entry.
227
+ // A working local bridge entry: the one URL replaces it, with the agent's own sign-in.
228
+ if (givesOneUrl(context))
229
+ return { kind: "stale", why: "runs a local bridge", move: true };
212
230
  return { kind: "current" };
213
231
  }
214
232
  function jsonState(path, rootKey, context, agent) {
@@ -423,18 +441,31 @@ function writeCodexEntry(path, context) {
423
441
  return { ok: false, message: `Passport can't read ${displayHome(path, context.home)}.` };
424
442
  }
425
443
  }
426
- if (codexEntry(text)) {
427
- return {
428
- ok: false,
429
- message: `Update Codex yourself: codex mcp add ${ENTRY_NAME} --url ${context.url}`
430
- };
431
- }
432
444
  const backup = text ? backupOnce(path) : undefined;
445
+ // An older entry (a local bridge, a workspace's own URL) is replaced in place.
446
+ if (codexEntry(text))
447
+ text = withoutCodexEntry(text);
433
448
  const section = `[mcp_servers.${ENTRY_NAME}]\nurl = ${tomlString(context.url)}\n`;
434
449
  const joined = text ? `${text.replace(/\s*$/, "")}\n\n${section}` : section;
435
450
  writeAtomic(path, joined);
436
451
  return { ok: true, changed: true, ...(backup ? { backup } : {}) };
437
452
  }
453
+ /** The Codex config without Passport's `[mcp_servers.passport]` table and its
454
+ * subtables (`[mcp_servers.passport.env]`). Everything else stays as written. */
455
+ export function withoutCodexEntry(text) {
456
+ const kept = [];
457
+ let inside = false;
458
+ for (const line of text.split(/\r?\n/)) {
459
+ const header = /^\s*\[([^\]]+)\]\s*(?:#.*)?$/.exec(line);
460
+ if (header) {
461
+ const name = header[1].trim().replace(/"/g, "");
462
+ inside = name === `mcp_servers.${ENTRY_NAME}` || name.startsWith(`mcp_servers.${ENTRY_NAME}.`);
463
+ }
464
+ if (!inside)
465
+ kept.push(line);
466
+ }
467
+ return kept.join("\n").replace(/\n{3,}/g, "\n\n");
468
+ }
438
469
  function runOk(context, command, args) {
439
470
  const result = (context.run ?? defaultRun)(command, args);
440
471
  return !result.failed && result.status === 0;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * `passport init`: Environments and Autopilot. Both read `GET /api/my/autopilot`
3
3
  * once, so the plan shows what's already set. An older server without
4
- * Autopilot keeps the old Safety step.
4
+ * Autopilot gets no rules step.
5
5
  *
6
6
  * Autopilot Production Careful reads run, changes ask
7
7
  * Staging Balanced reads and changes run, deletes ask
@@ -12,7 +12,6 @@
12
12
  * Staging qa and staging (Railway), preview (Vercel)
13
13
  */
14
14
  import { type Preset } from "./cliAutopilotPolicy.js";
15
- import { type SafetyPlan } from "./initLocalSteps.js";
16
15
  import { type AutopilotView, type InitSession } from "./initState.js";
17
16
  import { type EnvRow } from "./cliEnv.js";
18
17
  export declare const AUTOPILOT_PATH = "/api/my/autopilot";
@@ -36,8 +35,7 @@ export type AutopilotPlan = {
36
35
  view: AutopilotView;
37
36
  already: boolean;
38
37
  } | {
39
- kind: "safety";
40
- safety: SafetyPlan;
38
+ kind: "unavailable";
41
39
  } | {
42
40
  kind: "failed";
43
41
  };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * `passport init`: Environments and Autopilot. Both read `GET /api/my/autopilot`
3
3
  * once, so the plan shows what's already set. An older server without
4
- * Autopilot keeps the old Safety step.
4
+ * Autopilot gets no rules step.
5
5
  *
6
6
  * Autopilot Production Careful reads run, changes ask
7
7
  * Staging Balanced reads and changes run, deletes ask
@@ -14,7 +14,6 @@
14
14
  import { OTHER_APPS, PRESETS, PRESET_LABEL, PRESET_ROWS, presetStrictness, rowLabel } from "./cliAutopilotPolicy.js";
15
15
  import { ENV_KINDS, ENV_LABEL, isEnvKind } from "./cliHookEnvironment.js";
16
16
  import { readBoundedJson, safeApiError } from "./cliSupport.js";
17
- import { applySafety, detectSafety } from "./initLocalSteps.js";
18
17
  import { printable } from "./initState.js";
19
18
  import { envRows } from "./cliEnv.js";
20
19
  import { localMachine } from "./cliHookLocal.js";
@@ -235,7 +234,7 @@ export function environmentLines(plan, width) {
235
234
  export async function detectAutopilot(s) {
236
235
  const view = await readView(s, true);
237
236
  if (view === null)
238
- return { kind: "safety", safety: await detectSafety(s) };
237
+ return { kind: "unavailable" };
239
238
  if (view === "failed")
240
239
  return { kind: "failed" };
241
240
  return { kind: "autopilot", view, already: PRESET_ROWS.some((env) => view.chosen[env] !== undefined) };
@@ -325,8 +324,10 @@ async function savePresets(s, presets) {
325
324
  /** "apply" saves the recommended presets, "ask" (Customize) lets the person
326
325
  * pick each first, "skip" saves nothing. Already chosen presets stay. */
327
326
  export async function applyAutopilot(s, plan, mode) {
328
- if (plan.kind === "safety")
329
- return applySafety(s, plan.safety, mode);
327
+ if (plan.kind === "unavailable") {
328
+ s.record("autopilot", "unavailable");
329
+ return;
330
+ }
330
331
  if (plan.kind === "failed") {
331
332
  s.screen.result("warn", "Passport couldn't read your Autopilot presets. Set them any time in Rules.", "Autopilot");
332
333
  s.record("autopilot", "failed");
@@ -51,22 +51,4 @@ export type GuardPlan = {
51
51
  };
52
52
  export declare function detectGuard(s: InitSession): GuardPlan;
53
53
  export declare function applyGuard(s: InitSession, plan: GuardPlan, mode: "apply" | "ask" | "skip"): Promise<void>;
54
- export type SafetyPlan = {
55
- kind: "unavailable";
56
- } | {
57
- kind: "failed";
58
- message: string;
59
- } | {
60
- kind: "ok";
61
- profile: "off" | "ask" | "block";
62
- floor?: "ask" | "block";
63
- where: string;
64
- };
65
- export declare function detectSafety(s: InitSession): Promise<SafetyPlan>;
66
- export declare function applySafety(s: InitSession, plan: SafetyPlan, mode: "apply" | "ask" | "skip"): Promise<void>;
67
- /** "Deletes in Stripe and GitHub ask first (set by your workspace)". Irreversible
68
- * actions always ask, so the class word a person sees here is Delete. */
69
- export declare function safetyLine(plan: Extract<SafetyPlan, {
70
- kind: "ok";
71
- }>): string;
72
54
  export { coveredByPlugin };
@@ -8,10 +8,10 @@
8
8
  import { spawnSync } from "node:child_process";
9
9
  import { bool } from "./cliArgs.js";
10
10
  import { HOOK_CLIENTS, applyGuardInstall, stableInvocation, planGuardInstall, registeredEntries } from "./cliHookInstall.js";
11
- import { CliFailure, readBoundedJson, safeApiError } from "./cliSupport.js";
11
+ import { CliFailure } from "./cliSupport.js";
12
12
  import { AGENT_NAMES, applyAgent, backupOnce, detectAgents, displayHome, needsWork, planAgent } from "./initAgents.js";
13
13
  import { copyVersionsIn, ensureStableCommand, findOnPath, planStableCommand, pruneCopies } from "./initInstall.js";
14
- import { SAFETY_APPS, appLabel, packageRootOf } from "./initState.js";
14
+ import { packageRootOf } from "./initState.js";
15
15
  import { listOf } from "./initUi.js";
16
16
  import { coveredByPlugin, pluginInstalled } from "./hookPlugin.js";
17
17
  import { supportsUniversalUrl, universalUrl, workspaceUrl } from "./universalUrl.js";
@@ -366,80 +366,4 @@ async function guardSetup(s, plan, mode) {
366
366
  s.summary.changed = true;
367
367
  s.record("guard", failedPlans.length ? "failed" : plan.problems.length ? "needs_attention" : "done", detail("done", plan.plans, invocation));
368
368
  }
369
- export async function detectSafety(s) {
370
- const appNames = [...new Set([...s.candidates, ...s.connected])]
371
- .filter((app) => SAFETY_APPS.has(app))
372
- .map((app) => appLabel(app));
373
- const where = appNames.length ? `in ${listOf(appNames)}` : "in production apps";
374
- const response = await s.api("/api/my/safety-profile", {
375
- method: "GET",
376
- headers: { accept: "application/json" },
377
- signal: s.signal
378
- });
379
- if (response.status === 404 || response.status === 401) {
380
- await response.body?.cancel().catch(() => undefined);
381
- return { kind: "unavailable" };
382
- }
383
- if (!response.ok)
384
- return { kind: "failed", message: await safeApiError(response, "Passport couldn't read your rules.") };
385
- const state = await readBoundedJson(response);
386
- const profile = state.profile === "block" ? "block" : state.profile === "ask" ? "ask" : "off";
387
- const floor = state.floor === "ask" || state.floor === "block" ? state.floor : undefined;
388
- return { kind: "ok", profile, ...(floor ? { floor } : {}), where };
389
- }
390
- export async function applySafety(s, plan, mode) {
391
- if (plan.kind === "unavailable") {
392
- s.record("safety", "unavailable");
393
- return;
394
- }
395
- if (plan.kind === "failed") {
396
- s.screen.result("warn", plan.message, "Rules");
397
- s.record("safety", "failed");
398
- return;
399
- }
400
- let profile = plan.profile;
401
- let floor = plan.floor;
402
- let changed = false;
403
- if (profile === "off") {
404
- // Off may be a choice the person made on the web, so it changes only on a yes.
405
- const yes = mode === "apply" ||
406
- (mode === "ask" && (await s.screen.confirm(`Ask before deletes ${plan.where}?`, s.signal, "Rules")));
407
- if (!yes) {
408
- if (mode === "ask")
409
- s.screen.result("skip", "Left off. Turn it on any time in Rules.", "Rules");
410
- s.record("safety", "skipped", { profile: "off" });
411
- return;
412
- }
413
- const saved = await s.api("/api/my/safety-profile", {
414
- method: "PUT",
415
- headers: { "content-type": "application/json" },
416
- body: JSON.stringify({ profile: "ask" }),
417
- signal: s.signal
418
- });
419
- if (!saved.ok) {
420
- s.screen.result("warn", await safeApiError(saved, "Passport couldn't turn on Ask first."), "Rules");
421
- s.record("safety", "failed");
422
- return;
423
- }
424
- const state = await readBoundedJson(saved);
425
- profile = state.profile === "block" ? "block" : state.profile === "ask" ? "ask" : "off";
426
- floor = state.floor === "ask" || state.floor === "block" ? state.floor : undefined;
427
- changed = true;
428
- s.summary.changed = true;
429
- s.screen.result("done", `Deletes ${plan.where} ${profile === "block" ? "are blocked" : "ask first"}`, "Rules");
430
- }
431
- s.record("safety", changed ? "done" : "already_set_up", { profile, ...(floor ? { floor } : {}) });
432
- // The hook guard reads a local copy of these rules; bring it up to date.
433
- const { refreshRules: refreshCliPolicy } = await import("./cliPolicyRefresh.js");
434
- await refreshCliPolicy(s.profile, AbortSignal.any([s.signal, AbortSignal.timeout(5_000)]), {
435
- api: (path, init) => s.api(path, init)
436
- });
437
- }
438
- /** "Deletes in Stripe and GitHub ask first (set by your workspace)". Irreversible
439
- * actions always ask, so the class word a person sees here is Delete. */
440
- export function safetyLine(plan) {
441
- const verb = plan.profile === "block" ? "are blocked" : "ask first";
442
- const suffix = plan.floor && plan.floor === plan.profile ? " (set by your workspace)" : "";
443
- return `Deletes ${plan.where} ${verb}${suffix}`;
444
- }
445
369
  export { coveredByPlugin };
package/dist/initOutro.js CHANGED
@@ -93,8 +93,6 @@ export function outro(s) {
93
93
  items.push(...apps.items, ...keyItems(movedVendors(s.summary)).done, ...agentItems(steps));
94
94
  if (s.autopilotSummary && steps.autopilot?.status === "done")
95
95
  items.push(done(s.autopilotSummary));
96
- if (steps.safety?.status === "done")
97
- items.push(done("Deletes ask first"));
98
96
  items.push(...keyItems(movedVendors(s.summary)).rotate, ...agentFollowUps(s));
99
97
  s.summary.next.push({ argv: ["passport", "status"], description: "Check your workspace and app connections." });
100
98
  const lines = items.flatMap((item) => wrap(s.screen.text(item.text), s.terminal.width, ` ${s.screen.symbol(item.mark)} `, " "));
package/dist/initPlan.js CHANGED
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { appsTodo } from "./initAppsStep.js";
17
17
  import { environmentLines, floorLines, presetLines } from "./initAutopilotStep.js";
18
- import { agentFiles, safetyLine } from "./initLocalSteps.js";
18
+ import { agentFiles } from "./initLocalSteps.js";
19
19
  import { appLabel } from "./initState.js";
20
20
  import { listOf } from "./initUi.js";
21
21
  import { AGENT_NAMES, displayHome } from "./initAgents.js";
@@ -85,10 +85,14 @@ function planAgents(b, s, agents) {
85
85
  b.kept("agents", "No supported agents found. Passport works with Claude Code, Codex, Cursor, and VS Code.");
86
86
  return;
87
87
  }
88
- if (agents.todo.length) {
89
- b.will("agents", `Add Passport to ${names(agents.todo)}`);
88
+ const moving = agents.todo.filter((plan) => plan.state.kind === "stale" && plan.state.move);
89
+ const adding = agents.todo.filter((plan) => !moving.includes(plan));
90
+ if (adding.length)
91
+ b.will("agents", `Add Passport to ${names(adding)}`);
92
+ if (moving.length)
93
+ b.will("agents", `Move ${names(moving)} to Passport's one URL`);
94
+ if (agents.todo.length)
90
95
  b.edit(agentFiles(s, agents.todo));
91
- }
92
96
  if (agents.ready.length)
93
97
  b.already("agents", `Passport in ${names(agents.ready)}`);
94
98
  for (const agent of agents.leftAlone) {
@@ -130,16 +134,8 @@ function planAutopilot(b, autopilot) {
130
134
  else
131
135
  b.will("autopilot", "Save the Autopilot presets below");
132
136
  }
133
- else if (autopilot?.kind === "safety") {
134
- const safety = autopilot.safety;
135
- if (safety.kind === "unavailable")
136
- b.kept("rules", "Rules need a newer Passport server.");
137
- else if (safety.kind === "failed")
138
- b.you("rules", safety.message);
139
- else if (safety.profile === "off")
140
- b.will("rules", `Ask before deletes ${safety.where}`);
141
- else
142
- b.already("rules", safetyLine(safety));
137
+ else if (autopilot?.kind === "unavailable") {
138
+ b.kept("autopilot", "Autopilot needs a newer Passport server.");
143
139
  }
144
140
  else if (autopilot?.kind === "failed") {
145
141
  b.you("autopilot", "Passport couldn't read your Autopilot presets. Set them any time in Rules.");
@@ -23,8 +23,6 @@ export declare const APP_BY_PROVIDER: Record<string, InitApp>;
23
23
  export declare const APP_BY_CLI: Array<[string, InitApp]>;
24
24
  /** A read-only first request per app, for the closing "Try it" line. */
25
25
  export declare const TRY_IT: Record<InitApp, string>;
26
- /** Safety packs cover these apps (server/src/safetyPacks.ts). */
27
- export declare const SAFETY_APPS: Set<string>;
28
26
  export declare const WAIT_INTERACTIVE_MS: number;
29
27
  /** How long the printed `passport connect --wait` command waits. */
30
28
  export declare const WAIT_NEXT_SECONDS = 300;
package/dist/initState.js CHANGED
@@ -47,16 +47,6 @@ export const TRY_IT = {
47
47
  github: "list your open GitHub pull requests",
48
48
  stripe: "show your Stripe balance"
49
49
  };
50
- /** Safety packs cover these apps (server/src/safetyPacks.ts). */
51
- export const SAFETY_APPS = new Set([
52
- "railway",
53
- "vercel",
54
- "supabase",
55
- "cloudflare",
56
- "cloudflare-bindings",
57
- "github",
58
- "stripe"
59
- ]);
60
50
  export const WAIT_INTERACTIVE_MS = 10 * 60 * 1000;
61
51
  /** How long the printed `passport connect --wait` command waits. */
62
52
  export const WAIT_NEXT_SECONDS = 300;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Locked hooks: Passport's guard and audit hooks in each agent's managed
3
3
  * (system) settings, where a person can't turn them off. Pure and secretless,
4
- * shared by the web's Agents › Rollout tab and `passport setup --org --lock`.
4
+ * shared by the web's Agents › Rollout tab and `passport init --org --lock`.
5
5
  *
6
6
  * A checked copy of shared/lockedHooks.ts: the bridge never imports shared/
7
7
  * in shipped code, and lockedHooks.test.ts proves the two say the same thing.