passport-bridge 0.46.1 → 0.47.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/cliGuardHealth.d.ts +5 -0
- package/dist/cliGuardHealth.js +6 -1
- package/dist/cliHook.d.ts +3 -13
- package/dist/cliHook.js +68 -43
- package/dist/cliHookClients.d.ts +3 -0
- package/dist/cliHookClients.js +4 -0
- package/dist/cliHookDecide.d.ts +11 -3
- package/dist/cliHookDecide.js +100 -9
- package/dist/cliHookDeliver.js +5 -2
- package/dist/cliHookInput.d.ts +2 -0
- package/dist/cliHookInput.js +10 -0
- package/dist/cliHookInstall.d.ts +6 -1
- package/dist/cliHookInstall.js +36 -9
- package/dist/cliHookStatus.d.ts +13 -0
- package/dist/cliHookStatus.js +54 -5
- package/dist/cliSetupLock.d.ts +1 -1
- package/dist/cliSetupLock.js +4 -3
- package/dist/cliSigningKeys.d.ts +10 -0
- package/dist/cliSigningKeys.js +10 -0
- package/dist/cliStatus.d.ts +5 -0
- package/dist/cliStatus.js +15 -5
- package/dist/controlPlane.generated.d.ts +9 -24
- package/dist/controlPlane.generated.js +11 -2
- package/dist/controlPlaneCli.js +5 -2
- package/dist/controlPlaneGuard.js +9 -5
- package/dist/controlPlaneModel.generated.js +3 -0
- package/dist/controlPlaneOffline.d.ts +67 -0
- package/dist/controlPlaneOffline.js +213 -0
- package/dist/controlPlanePeople.generated.d.ts +9 -0
- package/dist/controlPlaneRailwayGuard.d.ts +7 -0
- package/dist/controlPlaneRailwayGuard.js +15 -2
- package/dist/controlPlaneRoutes.generated.d.ts +1 -1
- package/dist/controlPlaneRoutes.generated.js +1 -1
- package/dist/controlPlaneSupabase.d.ts +7 -0
- package/dist/controlPlaneSupabase.js +16 -3
- package/dist/cpCli.d.ts +20 -0
- package/dist/cpCli.js +102 -1
- package/dist/cpRefusal.d.ts +8 -0
- package/dist/cpRefusal.js +13 -0
- package/dist/hookAdapters.d.ts +44 -0
- package/dist/hookAdapters.js +106 -0
- package/dist/lockedHooks.d.ts +13 -11
- package/dist/lockedHooks.js +19 -16
- package/dist/managedHooks.d.ts +2 -0
- package/dist/managedHooks.js +24 -3
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/testHookEnv.d.ts +2 -0
- package/dist/testHookEnv.js +26 -0
- package/dist/testSigning.d.ts +5 -0
- package/dist/testSigning.js +19 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/cliHookInstall.js
CHANGED
|
@@ -177,7 +177,8 @@ function missingEvents(spec, settings) {
|
|
|
177
177
|
* Add Passport's entry to every slot a registered kind is missing, with the
|
|
178
178
|
* command it already runs, touching nothing else. Idempotent; never adds a
|
|
179
179
|
* kind that isn't there (the guard someone turned off stays off), and leaves
|
|
180
|
-
* an agent the plugin covers alone.
|
|
180
|
+
* an agent the plugin covers alone. A guard entry from before fail-closed is
|
|
181
|
+
* upgraded in place (not counted). Returns the events added. Throws a
|
|
181
182
|
* CliFailure when the file can't be read.
|
|
182
183
|
*/
|
|
183
184
|
export function repairHookSlots(client, env) {
|
|
@@ -188,18 +189,24 @@ export function repairHookSlots(client, env) {
|
|
|
188
189
|
const { settings } = readSettings(path);
|
|
189
190
|
let next = settings;
|
|
190
191
|
const added = [];
|
|
192
|
+
let upgraded = false;
|
|
191
193
|
for (const kind of ["guard", "audit"]) {
|
|
192
194
|
const command = registered(spec, settings, kind);
|
|
193
195
|
if (!command)
|
|
194
196
|
continue;
|
|
195
197
|
for (const slot of slotsOf(spec, kind)) {
|
|
196
|
-
|
|
198
|
+
const there = registeredAt(spec, settings, slot);
|
|
199
|
+
// A guard installed before fail-closed existed is upgraded in place, with the command it already runs.
|
|
200
|
+
if (there && (kind !== "guard" || entryFailsClosed(spec, entryAt(spec, settings, slot.event, kind)) !== false))
|
|
197
201
|
continue;
|
|
198
|
-
next = withEntry(spec, next, slot, command);
|
|
199
|
-
|
|
202
|
+
next = withEntry(spec, next, slot, there ?? command);
|
|
203
|
+
if (there)
|
|
204
|
+
upgraded = true;
|
|
205
|
+
else
|
|
206
|
+
added.push(slot.event);
|
|
200
207
|
}
|
|
201
208
|
}
|
|
202
|
-
if (added.length)
|
|
209
|
+
if (added.length || upgraded)
|
|
203
210
|
writeSettings(path, next);
|
|
204
211
|
return added;
|
|
205
212
|
}
|
|
@@ -207,6 +214,18 @@ export function repairHookSlots(client, env) {
|
|
|
207
214
|
export function registeredHookCommand(settings) {
|
|
208
215
|
return registered(CLIENTS["claude-code"], settings, "audit");
|
|
209
216
|
}
|
|
217
|
+
/** The guard entry's fail-closed setting, where the agent has one. */
|
|
218
|
+
function guardExtra(spec, kind) {
|
|
219
|
+
return kind === "guard" && spec.failClosed ? { ...spec.failClosed } : {};
|
|
220
|
+
}
|
|
221
|
+
/** Whether a guard entry fails closed: null where the agent can't, false when it could and doesn't. */
|
|
222
|
+
function entryFailsClosed(spec, entry) {
|
|
223
|
+
if (!spec.failClosed)
|
|
224
|
+
return null;
|
|
225
|
+
if (!entry)
|
|
226
|
+
return false;
|
|
227
|
+
return Object.entries(spec.failClosed).every(([key, value]) => entry[key] === value);
|
|
228
|
+
}
|
|
210
229
|
function withEntry(spec, settings, slot, command) {
|
|
211
230
|
const { event } = slot;
|
|
212
231
|
const ours = isOurs(slot.kind);
|
|
@@ -215,12 +234,12 @@ function withEntry(spec, settings, slot, command) {
|
|
|
215
234
|
if (spec.format === "cursor") {
|
|
216
235
|
const at = list.findIndex((entry) => ours(entry?.command));
|
|
217
236
|
const kept = list.filter((entry) => !ours(entry?.command));
|
|
218
|
-
const fresh = { command, timeout: HOOK_TIMEOUT_SECONDS };
|
|
237
|
+
const fresh = { command, timeout: HOOK_TIMEOUT_SECONDS, ...guardExtra(spec, slot.kind) };
|
|
219
238
|
hooks[event] = at === -1 ? [...kept, fresh] : [...kept.slice(0, at), fresh, ...kept.slice(at)];
|
|
220
239
|
const version = typeof settings.version === "number" ? settings.version : 1;
|
|
221
240
|
return { ...settings, version, hooks };
|
|
222
241
|
}
|
|
223
|
-
const entry = { type: "command", command, timeout: HOOK_TIMEOUT_SECONDS };
|
|
242
|
+
const entry = { type: "command", command, timeout: HOOK_TIMEOUT_SECONDS, ...guardExtra(spec, slot.kind) };
|
|
224
243
|
const groups = list;
|
|
225
244
|
// An older Passport entry (another version's path) is replaced where it stands.
|
|
226
245
|
const owner = groups.findIndex((group) => group && Array.isArray(group.hooks) && group.hooks.some((candidate) => ours(candidate?.command)));
|
|
@@ -287,6 +306,8 @@ const LIMITS_LINE = "It can't see inside scripts, aliases, or make targets.";
|
|
|
287
306
|
const CODEX_TRUST_LINE = "Next: Open Codex → /hooks and trust Passport's hooks.";
|
|
288
307
|
/** What the guard does in Codex, in plain words (status, install, init). */
|
|
289
308
|
export const CODEX_BLOCK_ONLY = "In Codex, Passport refuses what your rules block and says why.";
|
|
309
|
+
/** Where the guard fails closed (Claude Code, Cursor): removing Passport first would block every shell command. */
|
|
310
|
+
export const FAIL_CLOSED_WARNING = "The guard fails closed: before removing Passport, run passport hook uninstall, or this agent's shell commands are refused.";
|
|
290
311
|
/** A hook's command as a person reads it: "passport hook guard", not the
|
|
291
312
|
* absolute paths of node and the CLI (those show with --verbose). */
|
|
292
313
|
export function shownHookCommand(command, verbose) {
|
|
@@ -328,7 +349,8 @@ function pendingChanges(spec, settings, wanted) {
|
|
|
328
349
|
// A timeout shorter than the entry needs (hand-edited) is fixed too.
|
|
329
350
|
const timeout = entryAt(spec, settings, entry.event, entry.kind)?.timeout;
|
|
330
351
|
const short = typeof timeout === "number" && timeout < HOOK_TIMEOUT_SECONDS;
|
|
331
|
-
|
|
352
|
+
const opensOnFailure = entry.kind === "guard" && entryFailsClosed(spec, entryAt(spec, settings, entry.event, entry.kind)) === false;
|
|
353
|
+
if (current === entry.command && !short && !opensOnFailure)
|
|
332
354
|
continue;
|
|
333
355
|
changes.push({ action: current ? "update" : "add", event: entry.event, command: entry.command });
|
|
334
356
|
}
|
|
@@ -389,7 +411,8 @@ function installClient(spec, args, runtime) {
|
|
|
389
411
|
? [
|
|
390
412
|
`Guard on for ${spec.name}.`,
|
|
391
413
|
spec.id === "codex" ? CODEX_BLOCK_ONLY : "Passport refuses what your rules block, like railway volume delete.",
|
|
392
|
-
LIMITS_LINE
|
|
414
|
+
LIMITS_LINE,
|
|
415
|
+
...(spec.failClosed ? [FAIL_CLOSED_WARNING] : [])
|
|
393
416
|
]
|
|
394
417
|
: [`${spec.name} now records the CLIs it runs in Passport Activity.`, RECORDS_LINE];
|
|
395
418
|
return {
|
|
@@ -449,12 +472,14 @@ function clientStatus(spec, env) {
|
|
|
449
472
|
let audit = null;
|
|
450
473
|
let guard = null;
|
|
451
474
|
let missing = [];
|
|
475
|
+
let failClosed = spec.failClosed ? false : null;
|
|
452
476
|
let mode;
|
|
453
477
|
try {
|
|
454
478
|
const { settings } = readSettings(path);
|
|
455
479
|
audit = registered(spec, settings, "audit");
|
|
456
480
|
guard = registered(spec, settings, "guard");
|
|
457
481
|
missing = missingEvents(spec, settings);
|
|
482
|
+
failClosed = entryFailsClosed(spec, guard ? entryAt(spec, settings, spec.pre, "guard") : null);
|
|
458
483
|
mode = audit && guard ? "audit + guard" : audit ? "audit" : guard ? "guard" : "not installed";
|
|
459
484
|
}
|
|
460
485
|
catch {
|
|
@@ -473,6 +498,8 @@ function clientStatus(spec, env) {
|
|
|
473
498
|
plugin,
|
|
474
499
|
/** Hook events Passport's entry should be on but isn't. */
|
|
475
500
|
missing: plugin ? [] : missing,
|
|
501
|
+
/** The guard entry fails closed; null where the agent can't (Codex). The plugin's hooks fail open. */
|
|
502
|
+
failClosed: plugin && !guard ? (spec.failClosed ? false : null) : failClosed,
|
|
476
503
|
command: audit,
|
|
477
504
|
guardCommand: guard,
|
|
478
505
|
path,
|
package/dist/cliHookStatus.d.ts
CHANGED
|
@@ -15,7 +15,20 @@ export declare function localGuardStates(env: Env): Promise<{
|
|
|
15
15
|
fix: ProblemFix | null;
|
|
16
16
|
/** Partly set up: the hook events Passport's entry is missing from. */
|
|
17
17
|
missing: string[];
|
|
18
|
+
/** The guard fails closed; null where the agent can't (Codex). */
|
|
19
|
+
failClosed: boolean | null;
|
|
20
|
+
locked: boolean;
|
|
18
21
|
}[]>;
|
|
22
|
+
/** The agents Passport's guard doesn't install into yet (docs/design/v22/visibility.md). */
|
|
23
|
+
export declare const NOT_SUPPORTED_YET: readonly ["Copilot CLI", "VS Code", "Gemini CLI", "Antigravity", "Windsurf", "Devin", "Factory", "Kiro", "Junie", "Cline", "OpenCode", "Amp"];
|
|
24
|
+
export declare const NOT_SUPPORTED_LINE: string;
|
|
25
|
+
/** "fails closed · locked": how hard the guard is to get around on this computer. */
|
|
26
|
+
export declare function safetyText(entry: {
|
|
27
|
+
failClosed?: boolean | null;
|
|
28
|
+
locked?: boolean;
|
|
29
|
+
}): string;
|
|
30
|
+
/** For each agent whose guard is on: "Cursor: the guard fails open." and its fix, or "Codex: can't fail closed." */
|
|
31
|
+
export declare function safetyLines(states: Awaited<ReturnType<typeof localGuardStates>>): string[];
|
|
19
32
|
/** Partly set up, in words: "Passport can't see session starts and prompts." */
|
|
20
33
|
export declare function missingLine(missing: readonly string[]): string | null;
|
|
21
34
|
/** "Codex: Open Codex → /hooks and trust Passport's hooks." for each problem,
|
package/dist/cliHookStatus.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* how old this computer's copy of what Passport decides is. Never writes anything.
|
|
6
6
|
*/
|
|
7
7
|
import { bool, value } from "./cliArgs.js";
|
|
8
|
-
import { GUARD_CLIENT_LABEL, GUARD_STATE_LABEL, fixLines, guardClientReports, guardStateFix, localGuardState, missingHooksText } from "./cliGuardHealth.js";
|
|
8
|
+
import { CAN_FAIL_CLOSED, GUARD_CLIENT_LABEL, GUARD_STATE_LABEL, fixLines, guardClientReports, guardStateFix, localGuardState, missingHooksText } from "./cliGuardHealth.js";
|
|
9
9
|
import { CODEX_BLOCK_ONLY, HOOK_CLIENTS, agentHookStatus, displayPath } from "./cliHookInstall.js";
|
|
10
10
|
import { readCpCli } from "./cpCli.js";
|
|
11
11
|
import { readCreds } from "./credentials.js";
|
|
@@ -56,10 +56,48 @@ export async function localGuardStates(env) {
|
|
|
56
56
|
state,
|
|
57
57
|
label: state ? GUARD_STATE_LABEL[state] : null,
|
|
58
58
|
fix: guardStateFix(state, report.client),
|
|
59
|
-
missing: state === "partial" ? (report.missing ?? []) : []
|
|
59
|
+
missing: state === "partial" ? (report.missing ?? []) : [],
|
|
60
|
+
failClosed: CAN_FAIL_CLOSED.has(report.client) ? report.failClosed === true : null,
|
|
61
|
+
locked: report.locked === true
|
|
60
62
|
};
|
|
61
63
|
});
|
|
62
64
|
}
|
|
65
|
+
/** The agents Passport's guard doesn't install into yet (docs/design/v22/visibility.md). */
|
|
66
|
+
export const NOT_SUPPORTED_YET = [
|
|
67
|
+
"Copilot CLI",
|
|
68
|
+
"VS Code",
|
|
69
|
+
"Gemini CLI",
|
|
70
|
+
"Antigravity",
|
|
71
|
+
"Windsurf",
|
|
72
|
+
"Devin",
|
|
73
|
+
"Factory",
|
|
74
|
+
"Kiro",
|
|
75
|
+
"Junie",
|
|
76
|
+
"Cline",
|
|
77
|
+
"OpenCode",
|
|
78
|
+
"Amp"
|
|
79
|
+
];
|
|
80
|
+
export const NOT_SUPPORTED_LINE = `Not supported yet: ${NOT_SUPPORTED_YET.join(", ")}.`;
|
|
81
|
+
/** "fails closed · locked": how hard the guard is to get around on this computer. */
|
|
82
|
+
export function safetyText(entry) {
|
|
83
|
+
const fail = entry.failClosed === null ? "can't fail closed" : entry.failClosed ? "fails closed" : "fails open";
|
|
84
|
+
return `${fail} · ${entry.locked ? "locked" : "not locked"}`;
|
|
85
|
+
}
|
|
86
|
+
/** For each agent whose guard is on: "Cursor: the guard fails open." and its fix, or "Codex: can't fail closed." */
|
|
87
|
+
export function safetyLines(states) {
|
|
88
|
+
return states.flatMap((entry) => {
|
|
89
|
+
if (entry.state !== "on" && entry.state !== "locked")
|
|
90
|
+
return [];
|
|
91
|
+
const name = GUARD_CLIENT_LABEL[entry.client];
|
|
92
|
+
if (entry.failClosed === null)
|
|
93
|
+
return [`${name}: can't fail closed.`];
|
|
94
|
+
if (entry.failClosed)
|
|
95
|
+
return [];
|
|
96
|
+
if (entry.locked)
|
|
97
|
+
return [`${name}: the locked guard fails open. Run: passport init --org --lock`];
|
|
98
|
+
return [`${name}: the guard fails open.`, `Run: passport hook install --agent ${entry.client} --guard --apply`];
|
|
99
|
+
});
|
|
100
|
+
}
|
|
63
101
|
/** Partly set up, in words: "Passport can't see session starts and prompts." */
|
|
64
102
|
export function missingLine(missing) {
|
|
65
103
|
const words = missingHooksText(missing);
|
|
@@ -97,6 +135,8 @@ export async function hookStatus(args, runtime) {
|
|
|
97
135
|
...status,
|
|
98
136
|
guardState: guard.state,
|
|
99
137
|
guardLabel: guard.label,
|
|
138
|
+
failClosed: guard.failClosed,
|
|
139
|
+
locked: guard.locked,
|
|
100
140
|
...(guard.fix ? { fix: guard.fix } : {})
|
|
101
141
|
};
|
|
102
142
|
});
|
|
@@ -106,7 +146,10 @@ export async function hookStatus(args, runtime) {
|
|
|
106
146
|
// "Audit and guard · On": what's installed, then the guard's state.
|
|
107
147
|
const stateText = (agent) => {
|
|
108
148
|
const mode = MODE_WORDS[agent.mode] ?? agent.mode;
|
|
109
|
-
|
|
149
|
+
if (!agent.guardLabel)
|
|
150
|
+
return mode;
|
|
151
|
+
const on = agent.guardState === "on" || agent.guardState === "locked";
|
|
152
|
+
return on ? `${mode} · ${agent.guardLabel} · ${safetyText(agent)}` : `${mode} · ${agent.guardLabel}`;
|
|
110
153
|
};
|
|
111
154
|
const stateWidth = Math.max(...agents.map((agent) => stateText(agent).length));
|
|
112
155
|
const codexGuarded = agents.some((agent) => agent.client === "codex" && agent.guard);
|
|
@@ -116,7 +159,13 @@ export async function hookStatus(args, runtime) {
|
|
|
116
159
|
policy.line,
|
|
117
160
|
...(codexGuarded ? [CODEX_BLOCK_ONLY] : []),
|
|
118
161
|
...(disabled ? ["PASSPORT_HOOK_DISABLED=1 is set, so hooks do nothing in this shell."] : []),
|
|
119
|
-
...guardFixLines(guards)
|
|
162
|
+
...guardFixLines(guards),
|
|
163
|
+
...safetyLines(guards),
|
|
164
|
+
NOT_SUPPORTED_LINE
|
|
120
165
|
];
|
|
121
|
-
return {
|
|
166
|
+
return {
|
|
167
|
+
json: { agents, policy: policy.json, disabled, notSupported: NOT_SUPPORTED_YET },
|
|
168
|
+
human: lines.join("\n"),
|
|
169
|
+
essential: true
|
|
170
|
+
};
|
|
122
171
|
}
|
package/dist/cliSetupLock.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ type Merge = {
|
|
|
29
29
|
* replaces them. Someone else's `[hooks]`, `managed_dir`, or `hooks = false`
|
|
30
30
|
* needs a person to decide, so it is a conflict.
|
|
31
31
|
*/
|
|
32
|
-
export declare function mergeCodexRequirements(existing: string,
|
|
32
|
+
export declare function mergeCodexRequirements(existing: string, _strict: boolean, platform: "darwin" | "linux"): Merge;
|
|
33
33
|
/** Passport's two entries in Cursor's system hooks.json; everyone else's stay. */
|
|
34
34
|
export declare function mergeCursorHooks(existing: string | undefined, platform: LockPlatform, strict: boolean): Merge;
|
|
35
35
|
export declare function runLock(options: LockOptions): LockReport;
|
package/dist/cliSetupLock.js
CHANGED
|
@@ -125,7 +125,7 @@ function trimBlank(lines) {
|
|
|
125
125
|
* replaces them. Someone else's `[hooks]`, `managed_dir`, or `hooks = false`
|
|
126
126
|
* needs a person to decide, so it is a conflict.
|
|
127
127
|
*/
|
|
128
|
-
export function mergeCodexRequirements(existing,
|
|
128
|
+
export function mergeCodexRequirements(existing, _strict, platform) {
|
|
129
129
|
const fix = "Merge Passport's lines by hand from Agents › Rollout in Passport, then run this again.";
|
|
130
130
|
const kept = [];
|
|
131
131
|
let inside = false;
|
|
@@ -179,7 +179,8 @@ export function mergeCodexRequirements(existing, strict, platform) {
|
|
|
179
179
|
conflict: "requirements.toml turns hooks off ([features] hooks = false). Set it to true, then run this again."
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
-
|
|
182
|
+
// Every lock is managed-only (2026-11-18): someone else's `false` needs a person to decide.
|
|
183
|
+
if (strictValue !== undefined && strictValue !== "true") {
|
|
183
184
|
return {
|
|
184
185
|
conflict: `requirements.toml sets allow_managed_hooks_only = ${strictValue}. Remove it or set it to true, then run this again.`
|
|
185
186
|
};
|
|
@@ -188,7 +189,7 @@ export function mergeCodexRequirements(existing, strict, platform) {
|
|
|
188
189
|
// copy-style-allow double-space: TOML comment spacing in a managed file
|
|
189
190
|
if (features >= 0 && featureHooks === undefined)
|
|
190
191
|
lines.splice(features + 1, 0, "hooks = true # passport");
|
|
191
|
-
const top =
|
|
192
|
+
const top = strictValue === undefined ? [BEGIN, CODEX_STRICT_LINE, END, ""] : [];
|
|
192
193
|
const block = [
|
|
193
194
|
BEGIN,
|
|
194
195
|
...(features < 0 ? ["[features]", "hooks = true", ""] : []),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public halves of Passport's CLI signing keys (`docs/design/v22/visibility.md`, B4), by key id: the first 16 hex
|
|
3
|
+
* characters of the SPKI's SHA-256 (`server/src/controlPlane/cliSigning.ts` `keyIdOf`). A cached copy of the rules for
|
|
4
|
+
* when Passport can't be reached counts only when one of these signed it. Shipped in the CLI, so an agent on the
|
|
5
|
+
* computer can't swap it the way it could a file.
|
|
6
|
+
*
|
|
7
|
+
* Empty until the production key is provisioned: generate it, set `PASSPORT_CLI_SIGNING_KEY` on the server, and add
|
|
8
|
+
* its public key here (base64 SPKI DER) in the release that should trust it. Keep the previous key while rotating.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CLI_SIGNING_KEYS: Readonly<Record<string, string>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public halves of Passport's CLI signing keys (`docs/design/v22/visibility.md`, B4), by key id: the first 16 hex
|
|
3
|
+
* characters of the SPKI's SHA-256 (`server/src/controlPlane/cliSigning.ts` `keyIdOf`). A cached copy of the rules for
|
|
4
|
+
* when Passport can't be reached counts only when one of these signed it. Shipped in the CLI, so an agent on the
|
|
5
|
+
* computer can't swap it the way it could a file.
|
|
6
|
+
*
|
|
7
|
+
* Empty until the production key is provisioned: generate it, set `PASSPORT_CLI_SIGNING_KEY` on the server, and add
|
|
8
|
+
* its public key here (base64 SPKI DER) in the release that should trust it. Keep the previous key while rotating.
|
|
9
|
+
*/
|
|
10
|
+
export const CLI_SIGNING_KEYS = {};
|
package/dist/cliStatus.d.ts
CHANGED
|
@@ -36,9 +36,14 @@ export type GuardStatusAgent = {
|
|
|
36
36
|
fix?: ProblemFix;
|
|
37
37
|
/** Partly set up: "Passport can't see session starts and prompts." */
|
|
38
38
|
missing?: string;
|
|
39
|
+
/** The guard fails closed; null where the agent can't (Codex). */
|
|
40
|
+
failClosed?: boolean | null;
|
|
41
|
+
locked?: boolean;
|
|
39
42
|
};
|
|
40
43
|
export type GuardStatus = {
|
|
41
44
|
agents: GuardStatusAgent[];
|
|
45
|
+
/** "Cursor: the guard fails open." and its fix, "Codex: can't fail closed." */
|
|
46
|
+
safety?: string[];
|
|
42
47
|
/** Hook slots this run added (`hookRepair.ts`), one line per agent. */
|
|
43
48
|
repaired?: string[];
|
|
44
49
|
};
|
package/dist/cliStatus.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { managePayload } from "./cliConnect.js";
|
|
2
2
|
import { fixLines, GUARD_CLIENT_LABEL } from "./cliGuardHealth.js";
|
|
3
|
-
import { localGuardStates, missingLine } from "./cliHookStatus.js";
|
|
3
|
+
import { localGuardStates, missingLine, NOT_SUPPORTED_LINE, safetyLines, safetyText } from "./cliHookStatus.js";
|
|
4
4
|
import { computerName, keyUse, KEYS_PATH } from "./cliKeys.js";
|
|
5
5
|
import { readBoundedJson, sanitize, timeoutMs } from "./cliSupport.js";
|
|
6
6
|
import { ago, mark, paint, table, termOf, visibleLength, wrap } from "./term.js";
|
|
@@ -75,7 +75,8 @@ async function guardStatus(env) {
|
|
|
75
75
|
...repairLines(await repairHooks(env)),
|
|
76
76
|
...(await import("./commandRepair.js")).repairPassportCommand(env)
|
|
77
77
|
];
|
|
78
|
-
const
|
|
78
|
+
const states = await localGuardStates(env);
|
|
79
|
+
const agents = states
|
|
79
80
|
.filter((entry) => entry.state)
|
|
80
81
|
.map((entry) => {
|
|
81
82
|
const missing = missingLine(entry.missing);
|
|
@@ -85,12 +86,15 @@ async function guardStatus(env) {
|
|
|
85
86
|
state: entry.state,
|
|
86
87
|
label: entry.label,
|
|
87
88
|
...(entry.fix ? { fix: entry.fix } : {}),
|
|
88
|
-
...(missing ? { missing } : {})
|
|
89
|
+
...(missing ? { missing } : {}),
|
|
90
|
+
failClosed: entry.failClosed,
|
|
91
|
+
locked: entry.locked
|
|
89
92
|
};
|
|
90
93
|
});
|
|
91
94
|
if (!agents.length && !repaired.length)
|
|
92
95
|
return undefined;
|
|
93
|
-
|
|
96
|
+
const safety = safetyLines(states);
|
|
97
|
+
return { agents, ...(repaired.length ? { repaired } : {}), ...(safety.length ? { safety } : {}) };
|
|
94
98
|
}
|
|
95
99
|
catch {
|
|
96
100
|
return undefined;
|
|
@@ -176,13 +180,19 @@ function guardRow(guard, term) {
|
|
|
176
180
|
lines.push(...markedTable(term, guard.agents.map((agent) => ({
|
|
177
181
|
mark: agent.state === "on" || agent.state === "locked" ? "done" : "warn",
|
|
178
182
|
name: agent.name,
|
|
179
|
-
detail: agent.
|
|
183
|
+
detail: (agent.state === "on" || agent.state === "locked") && agent.failClosed !== undefined
|
|
184
|
+
? `${agent.label} · ${safetyText(agent)}`
|
|
185
|
+
: agent.label,
|
|
180
186
|
...(agent.fix ? { note: [agent.missing, fixLines(agent.fix)].filter(Boolean).join("\n") } : {})
|
|
181
187
|
}))));
|
|
182
188
|
}
|
|
183
189
|
if (guard.repaired)
|
|
184
190
|
for (const line of guard.repaired)
|
|
185
191
|
lines.push(...wrap(line, width));
|
|
192
|
+
for (const line of guard.safety ?? [])
|
|
193
|
+
lines.push(...wrap(line, width));
|
|
194
|
+
if (lines.length)
|
|
195
|
+
lines.push(...wrap(NOT_SUPPORTED_LINE, width));
|
|
186
196
|
return lines.length ? { label: "Guard", lines } : undefined;
|
|
187
197
|
}
|
|
188
198
|
function appRow(view, term) {
|
|
@@ -242,7 +242,7 @@ export declare function resolveRule(path: readonly string[], action: Pick<Action
|
|
|
242
242
|
* never use a credential Passport issued. A server that still sets it from the credential is read by
|
|
243
243
|
* the deprecated `coverageOf`; `managedCoverageOf` (controlPlaneModel.ts) is the definition.
|
|
244
244
|
*/
|
|
245
|
-
export type Through = "passport" | "outside";
|
|
245
|
+
export type Through = "passport" | "outside" | "offline";
|
|
246
246
|
/**
|
|
247
247
|
* What ran the action. `person`: by hand (a dashboard, a person's own terminal). `app`: the customer's own application
|
|
248
248
|
* traffic, left out of coverage. `unknown`: couldn't be told; shown as "Script (unknown)" and Unmanaged.
|
|
@@ -260,59 +260,46 @@ export type PlatformId = {
|
|
|
260
260
|
type: string;
|
|
261
261
|
id: string;
|
|
262
262
|
};
|
|
263
|
-
export declare const OUTCOMES: readonly ["ran", "blocked", "allowed_once", "would_block", "failed", "outside"];
|
|
263
|
+
export declare const OUTCOMES: readonly ["ran", "blocked", "allowed_once", "would_block", "failed", "outside", "offline_blocked", "offline_allowed", "offline_no_rules"];
|
|
264
264
|
export type Outcome =
|
|
265
265
|
/** Passport allowed it and it ran (or the platform reported it done with Passport's credential). */
|
|
266
|
-
"ran"
|
|
267
|
-
/** A rule blocked it; nothing ran. */
|
|
268
|
-
| "blocked"
|
|
269
|
-
/** Blocked, then an admin allowed this one attempt; the retry ran. */
|
|
270
|
-
| "allowed_once"
|
|
271
|
-
/** Observe mode: a rule would have blocked it, and it ran. */
|
|
272
|
-
| "would_block"
|
|
273
|
-
/** It ran and the platform returned an error. */
|
|
274
|
-
| "failed"
|
|
266
|
+
"ran" | "blocked" | "allowed_once" | "would_block" | "failed"
|
|
275
267
|
/** The platform reported it done with Passport's credential, but no Passport rule
|
|
276
268
|
* decided it first (a person's own terminal, a script, a push the helper couldn't read). */
|
|
277
269
|
| "undecided"
|
|
278
270
|
/** The platform reported it; it did not go through Passport. */
|
|
279
|
-
| "outside"
|
|
271
|
+
| "outside"
|
|
272
|
+
/** The CLI's word that its guard decided alone while Passport couldn't be reached (`through: "offline"`): refused
|
|
273
|
+
* by its signed copy of the rules, let run with them, or let run with none known. Shown, never counted as Managed. */
|
|
274
|
+
| "offline_blocked" | "offline_allowed" | "offline_no_rules";
|
|
280
275
|
export type ActionEvent = {
|
|
281
276
|
id: string;
|
|
282
277
|
ts: number;
|
|
283
278
|
platform: PlatformKey;
|
|
284
|
-
/** The most specific node it touched. */
|
|
285
279
|
nodeId: string;
|
|
286
280
|
actionKey: string;
|
|
287
281
|
kind: Kind;
|
|
288
282
|
through: Through;
|
|
289
283
|
interface: Interface;
|
|
290
284
|
outcome: Outcome;
|
|
291
|
-
/** Who, when known. An outside event usually has only `via`. */
|
|
292
285
|
personId?: string;
|
|
293
286
|
agentId?: string;
|
|
294
|
-
/** Passport's credential id when `through` is "passport". */
|
|
295
287
|
credentialId?: string;
|
|
296
288
|
/** Plain words for the identity the platform saw when Passport can't name an agent: "Sam's personal access token". */
|
|
297
289
|
via?: string;
|
|
298
|
-
/** The rule that decided, when Passport decided. */
|
|
299
290
|
rule?: Resolution;
|
|
300
291
|
/** One line: "Merge pull request #1482 into main". Never arguments, bodies or SQL text. */
|
|
301
292
|
summary: string;
|
|
302
|
-
/** The agent session, when known (for the side panel's trace). */
|
|
303
293
|
sessionId?: string;
|
|
304
|
-
/** The platform's own event id, for de-duplication and matching. */
|
|
305
294
|
platformEventId?: string;
|
|
306
295
|
/** An event Passport decided and the platform later confirmed share one id; this records the confirmation. */
|
|
307
296
|
confirmedAt?: number;
|
|
308
297
|
/** When the action's target is an argument (a collaborator, a secret, a tag): its keyed hash, never the
|
|
309
298
|
* target itself. */
|
|
310
299
|
targetHash?: string;
|
|
311
|
-
/** What it touched beneath the node (section 6): a Variable, a domain, a branch. Names only. */
|
|
312
300
|
target?: ActionTarget;
|
|
313
301
|
/** Passport couldn't read what the request bundles in time (staged changes), so it decided the envelope. */
|
|
314
302
|
contextUnread?: true;
|
|
315
|
-
/** What ran it. Absent on events from before it existed. */
|
|
316
303
|
surface?: Surface;
|
|
317
304
|
/** The same-platform event that caused this one (a deploy run caused by a merge). */
|
|
318
305
|
cause?: EventCause;
|
|
@@ -324,15 +311,13 @@ export type ActionEvent = {
|
|
|
324
311
|
/** "Not connected": on an account Passport isn't connected to (a GitHub organization the App isn't installed
|
|
325
312
|
* on). Shown, never counted: `managedCoverageOf` leaves it out (decided 2026-11-13). */
|
|
326
313
|
notConnected?: true;
|
|
327
|
-
/** Supabase database-log events: the role the statement ran as ("service_role"); a name, never a password. */
|
|
328
314
|
dbRole?: string;
|
|
329
|
-
/** Unmanaged events: the credential that made it, worked out when read; never stored. */
|
|
330
315
|
credentialRef?: CpCredentialRef;
|
|
331
316
|
unnamed?: UnnamedHit;
|
|
332
317
|
};
|
|
333
318
|
export declare const OUTSIDE_CREDENTIAL_KINDS: readonly ["personal_token", "deploy_key", "actions_secret", "railway_token", "service_role_key", "database_password"];
|
|
334
319
|
export type OutsideCredentialKind = (typeof OUTSIDE_CREDENTIAL_KINDS)[number];
|
|
335
|
-
export declare const SETUP_GAP_KINDS: readonly ["guard_off", "key_on_computer", "token_in_secrets", "stale_deploy_key"];
|
|
320
|
+
export declare const SETUP_GAP_KINDS: readonly ["guard_off", "key_on_computer", "token_in_secrets", "stale_deploy_key", "guard_offline"];
|
|
336
321
|
export type SetupGapKind = (typeof SETUP_GAP_KINDS)[number] | "account_not_connected";
|
|
337
322
|
/** Where and whose, when known: a computer or a repository's secrets ("payments-api secrets"), the person, the install,
|
|
338
323
|
* the resource it sits on; `expected`: an admin marked it expected (core loop 4): off Needs you, still Unmanaged. */
|
|
@@ -559,7 +544,7 @@ export type CpAgentRow = {
|
|
|
559
544
|
consequential7d: number;
|
|
560
545
|
/** Of those, how many a rule blocked. */
|
|
561
546
|
blocked7d: number;
|
|
562
|
-
guard: "on" | "off" | "outdated" | "na" | "unknown";
|
|
547
|
+
guard: "on" | "off" | "outdated" | "na" | "unknown" | "unsupported";
|
|
563
548
|
unknown?: true;
|
|
564
549
|
/** Passport credentials issued to it that are still live (not revoked, not expired). Every server from v19 sets it. */
|
|
565
550
|
liveCredentials?: number;
|
|
@@ -105,7 +105,10 @@ export const OUTCOMES = [
|
|
|
105
105
|
"allowed_once",
|
|
106
106
|
"would_block",
|
|
107
107
|
"failed",
|
|
108
|
-
"outside"
|
|
108
|
+
"outside",
|
|
109
|
+
"offline_blocked",
|
|
110
|
+
"offline_allowed",
|
|
111
|
+
"offline_no_rules"
|
|
109
112
|
];
|
|
110
113
|
/* ------------------------------------------------------------------ */
|
|
111
114
|
/* v19: credentials outside Passport and their setup gaps (ids, names) */
|
|
@@ -118,7 +121,13 @@ export const OUTSIDE_CREDENTIAL_KINDS = [
|
|
|
118
121
|
"service_role_key",
|
|
119
122
|
"database_password"
|
|
120
123
|
];
|
|
121
|
-
export const SETUP_GAP_KINDS = [
|
|
124
|
+
export const SETUP_GAP_KINDS = [
|
|
125
|
+
"guard_off",
|
|
126
|
+
"key_on_computer",
|
|
127
|
+
"token_in_secrets",
|
|
128
|
+
"stale_deploy_key",
|
|
129
|
+
"guard_offline"
|
|
130
|
+
];
|
|
122
131
|
/** Deprecated: counts `through` as recorded, credential-defined on servers before 2026-11-13. Use `managedCoverageOf`. */
|
|
123
132
|
export function coverageOf(events, observed) {
|
|
124
133
|
let through = 0;
|
package/dist/controlPlaneCli.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { readBoundedJson } from "./boundedResponse.js";
|
|
8
8
|
import { newRequestId } from "./controlPlaneLate.js";
|
|
9
|
-
import { refusalOf } from "./cpRefusal.js";
|
|
9
|
+
import { NO_ANSWER_STATUSES, noAnswer, refusalOf } from "./cpRefusal.js";
|
|
10
10
|
export const CP_DECIDE_CLI_PATH = "/api/cp/decide/cli";
|
|
11
11
|
/** Each decide waits at most this long. */
|
|
12
12
|
const CLI_DECIDE_TIMEOUT_MS = 2_000;
|
|
@@ -37,6 +37,8 @@ export async function askCliVerb(api, vendor, verb, extra, signal) {
|
|
|
37
37
|
await response.body?.cancel().catch(() => undefined);
|
|
38
38
|
return { kind: "unreachable", late: [requestId] };
|
|
39
39
|
}
|
|
40
|
+
if (NO_ANSWER_STATUSES.has(response.status))
|
|
41
|
+
return noAnswer(response, { kind: "unreachable", late: [requestId] });
|
|
40
42
|
if (!response.ok) {
|
|
41
43
|
await response.body?.cancel().catch(() => undefined);
|
|
42
44
|
return { kind: "undecided" };
|
|
@@ -50,7 +52,8 @@ export async function askCliVerb(api, vendor, verb, extra, signal) {
|
|
|
50
52
|
return refused;
|
|
51
53
|
}
|
|
52
54
|
catch {
|
|
53
|
-
|
|
55
|
+
// A 200 that isn't Passport's JSON (a captive portal, a proxy): no answer.
|
|
56
|
+
return { kind: "unreachable", late: [requestId] };
|
|
54
57
|
}
|
|
55
58
|
return { kind: "undecided" };
|
|
56
59
|
}
|
|
@@ -29,7 +29,7 @@ import { readBoundedJson } from "./boundedResponse.js";
|
|
|
29
29
|
import { newRequestId } from "./controlPlaneLate.js";
|
|
30
30
|
import { planKey, planPush, pushPlan } from "./gitPush.js";
|
|
31
31
|
import { beginShadowLine, shadowAlongside, shadowGithubLine, spoolShadow } from "./kitShadow.js";
|
|
32
|
-
import { refusalOf } from "./cpRefusal.js";
|
|
32
|
+
import { NO_ANSWER_STATUSES, noAnswer, refusalOf } from "./cpRefusal.js";
|
|
33
33
|
export const CP_DECIDE_PATH = "/api/cp/decide";
|
|
34
34
|
/** At most this many things one line does are asked about; a line doing more is refused. */
|
|
35
35
|
export const MAX_ASKED = 16;
|
|
@@ -176,13 +176,14 @@ const OLDER = Symbol("older");
|
|
|
176
176
|
/** What a server that drops unknown fields says on a 400 (`INVALID_REQUEST` in the server's decide route). */
|
|
177
177
|
const INVALID_REQUEST = "invalid_request";
|
|
178
178
|
/** A 400's kind: a refusal of the request itself (named), or an older server's bare error. */
|
|
179
|
-
async function refusal(response) {
|
|
179
|
+
async function refusal(response, unreachable) {
|
|
180
180
|
try {
|
|
181
181
|
const body = await readBoundedJson(response);
|
|
182
182
|
return body.code === INVALID_REQUEST ? { kind: "undecided" } : OLDER;
|
|
183
183
|
}
|
|
184
184
|
catch {
|
|
185
|
-
|
|
185
|
+
// Not Passport's JSON (a proxy's page): no answer.
|
|
186
|
+
return unreachable;
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
async function askOnce(api, classification, extra, signal, requestId) {
|
|
@@ -215,7 +216,9 @@ async function askOnce(api, classification, extra, signal, requestId) {
|
|
|
215
216
|
if (response.status >= 500)
|
|
216
217
|
return unreachable;
|
|
217
218
|
if (response.status === 400)
|
|
218
|
-
return refusal(response);
|
|
219
|
+
return refusal(response, unreachable);
|
|
220
|
+
if (NO_ANSWER_STATUSES.has(response.status))
|
|
221
|
+
return noAnswer(response, unreachable);
|
|
219
222
|
if (!response.ok)
|
|
220
223
|
return { kind: "undecided" };
|
|
221
224
|
let body;
|
|
@@ -223,7 +226,8 @@ async function askOnce(api, classification, extra, signal, requestId) {
|
|
|
223
226
|
body = await readBoundedJson(response);
|
|
224
227
|
}
|
|
225
228
|
catch {
|
|
226
|
-
|
|
229
|
+
// A 200 that isn't Passport's JSON (a captive portal, a proxy): no answer.
|
|
230
|
+
return unreachable;
|
|
227
231
|
}
|
|
228
232
|
if (body.allow === true) {
|
|
229
233
|
const decisionId = typeof body.decisionId === "string" && /^cpd1\.[A-Za-z0-9_.-]{1,590}$/.test(body.decisionId)
|
|
@@ -135,6 +135,9 @@ export function managedCoverageOf(events, observed) {
|
|
|
135
135
|
let appExcluded = 0;
|
|
136
136
|
let notConnectedExcluded = 0;
|
|
137
137
|
for (const event of events) {
|
|
138
|
+
// Refused by the guard alone while Passport was unreachable: it didn't run, so nothing counts it.
|
|
139
|
+
if (event.outcome === "offline_blocked")
|
|
140
|
+
continue;
|
|
138
141
|
if (event.notConnected === true) {
|
|
139
142
|
notConnectedExcluded += 1;
|
|
140
143
|
}
|