passport-bridge 0.16.13 → 0.17.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/README.md +20 -20
- package/dist/bridgeExchange.d.ts +7 -1
- package/dist/bridgeExchange.js +11 -2
- package/dist/cli.js +3 -1
- package/dist/cliActions.js +38 -18
- package/dist/cliArgs.js +14 -9
- package/dist/cliAutopilot.js +36 -21
- package/dist/cliAutopilotPolicy.d.ts +22 -0
- package/dist/cliAutopilotPolicy.js +61 -0
- package/dist/cliConnect.js +8 -7
- package/dist/cliDeadline.js +2 -1
- package/dist/cliDescribe.d.ts +4 -0
- package/dist/cliDescribe.js +11 -0
- package/dist/cliEnv.js +5 -4
- package/dist/cliExec.js +13 -5
- package/dist/cliGuardState.d.ts +2 -0
- package/dist/cliGuardState.js +5 -1
- package/dist/cliHelp.d.ts +5 -4
- package/dist/cliHelp.js +2 -27
- package/dist/cliHook.js +6 -2
- package/dist/cliHookGuard.js +5 -11
- package/dist/cliHookInstall.d.ts +3 -0
- package/dist/cliHookInstall.js +17 -7
- package/dist/cliHookStatus.d.ts +2 -1
- package/dist/cliHookStatus.js +26 -17
- package/dist/cliInit.js +5 -3
- package/dist/cliKeys.d.ts +3 -0
- package/dist/cliKeys.js +59 -77
- package/dist/cliKeysShim.js +7 -5
- package/dist/cliLogin.js +44 -24
- package/dist/cliLogout.js +24 -8
- package/dist/cliMain.js +50 -22
- package/dist/cliMemberCall.js +1 -1
- package/dist/cliOffline.d.ts +2 -2
- package/dist/cliOffline.js +32 -9
- package/dist/cliOutput.js +73 -43
- package/dist/cliReady.d.ts +2 -1
- package/dist/cliReady.js +9 -6
- package/dist/cliResult.js +1 -1
- package/dist/cliScan.js +10 -28
- package/dist/cliScriptRead.d.ts +1 -1
- package/dist/cliScriptRead.js +2 -2
- package/dist/cliSessions.d.ts +3 -2
- package/dist/cliSessions.js +19 -17
- package/dist/cliSetup.js +6 -4
- package/dist/cliSetupLock.js +2 -1
- package/dist/cliSetupOrg.js +7 -5
- package/dist/cliStatus.d.ts +2 -4
- package/dist/cliStatus.js +56 -61
- package/dist/cliSuggest.d.ts +3 -2
- package/dist/cliSuggest.js +19 -6
- package/dist/cliSupport.d.ts +1 -1
- package/dist/cliSupport.js +3 -7
- package/dist/cliSync.js +2 -0
- package/dist/cliUndo.d.ts +3 -1
- package/dist/cliUndo.js +14 -11
- package/dist/cliWait.d.ts +3 -2
- package/dist/cliWait.js +10 -18
- package/dist/doctor.d.ts +4 -1
- package/dist/doctor.js +48 -29
- package/dist/execNoKey.d.ts +1 -1
- package/dist/execNoKey.js +3 -2
- package/dist/execShims.js +2 -2
- package/dist/hookFastPath.js +1 -0
- package/dist/initAutopilotStep.js +5 -4
- package/dist/initInstall.js +4 -3
- package/dist/initKeysStep.js +1 -1
- package/dist/initLocalSteps.d.ts +2 -1
- package/dist/initLocalSteps.js +10 -7
- package/dist/initOutro.d.ts +1 -3
- package/dist/initOutro.js +8 -16
- package/dist/initPlan.js +7 -7
- package/dist/initUi.d.ts +2 -4
- package/dist/initUi.js +8 -17
- package/dist/keysLocal.js +3 -3
- package/dist/keysSecret.d.ts +6 -0
- package/dist/keysSecret.js +43 -0
- package/dist/launcherFastPath.js +1 -0
- package/dist/lockedHooks.d.ts +1 -1
- package/dist/lockedHooks.js +1 -1
- package/dist/loginFlow.d.ts +1 -1
- package/dist/loginFlow.js +4 -4
- package/dist/pathLines.d.ts +1 -0
- package/dist/pathLines.js +23 -0
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/plural.d.ts +10 -0
- package/dist/plural.js +14 -0
- package/dist/term.d.ts +49 -5
- package/dist/term.js +200 -26
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/waitingLine.js +2 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -14,6 +14,67 @@
|
|
|
14
14
|
import { ENV_LABEL } from "./cliHookEnvironment.js";
|
|
15
15
|
export const PRESETS = ["careful", "balanced", "handsoff"];
|
|
16
16
|
export const ACTION_CLASSES = ["read", "change", "delete", "irreversible"];
|
|
17
|
+
/**
|
|
18
|
+
* Checked copies of the class words in shared/autopilotContract.ts
|
|
19
|
+
* (cliAutopilotPolicy.test.ts compares them): one class, one word, on every
|
|
20
|
+
* surface. `CLASS_LABEL` names it ("Delete"), `CLASS_EFFECT` says what it does
|
|
21
|
+
* to an environment ("deletes from Production"), `CLASS_EFFECT_OTHER` without one
|
|
22
|
+
* ("deletes data").
|
|
23
|
+
*/
|
|
24
|
+
export const CLASS_LABEL = {
|
|
25
|
+
read: "Read",
|
|
26
|
+
change: "Change",
|
|
27
|
+
delete: "Delete",
|
|
28
|
+
irreversible: "Irreversible"
|
|
29
|
+
};
|
|
30
|
+
export const CLASS_EFFECT = {
|
|
31
|
+
read: "reads",
|
|
32
|
+
change: "changes",
|
|
33
|
+
delete: "deletes from",
|
|
34
|
+
irreversible: "can't be undone in"
|
|
35
|
+
};
|
|
36
|
+
export const CLASS_EFFECT_OTHER = {
|
|
37
|
+
read: "reads data",
|
|
38
|
+
change: "makes a change",
|
|
39
|
+
delete: "deletes data",
|
|
40
|
+
irreversible: "can't be undone"
|
|
41
|
+
};
|
|
42
|
+
export const CLASS_OF_RISK = {
|
|
43
|
+
read: "read",
|
|
44
|
+
write: "change",
|
|
45
|
+
destructive: "delete"
|
|
46
|
+
};
|
|
47
|
+
export function riskOfClass(actionClass) {
|
|
48
|
+
return actionClass === "read" ? "read" : actionClass === "change" ? "write" : "destructive";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Checked copies of `ruleParts` and `causeSentence` in shared/collabContract.ts
|
|
52
|
+
* (the CLI can't import shared/; cliAutopilot.test.ts compares them):
|
|
53
|
+
* "Blocked by a workspace rule: no railway volume delete in Production".
|
|
54
|
+
*/
|
|
55
|
+
export function ruleParts(label) {
|
|
56
|
+
const said = /^A rule says (.+)$/.exec(label);
|
|
57
|
+
if (said)
|
|
58
|
+
return { owner: "a rule", says: said[1] };
|
|
59
|
+
const match = /^(Your rule|Workspace rule|Team rule|(.{1,60}) team rule), (.+)$/.exec(label);
|
|
60
|
+
if (!match)
|
|
61
|
+
return null;
|
|
62
|
+
const owner = match[1] === "Your rule"
|
|
63
|
+
? "your rule"
|
|
64
|
+
: match[1] === "Workspace rule"
|
|
65
|
+
? "a workspace rule"
|
|
66
|
+
: match[1] === "Team rule"
|
|
67
|
+
? "a team rule"
|
|
68
|
+
: `the ${match[2]} team rule`;
|
|
69
|
+
return { owner, says: match[3] };
|
|
70
|
+
}
|
|
71
|
+
export function causeSentence(decision, label) {
|
|
72
|
+
const rule = ruleParts(label);
|
|
73
|
+
if (decision === "block")
|
|
74
|
+
return rule ? `Blocked by ${rule.owner}: ${rule.says}` : `Blocked by Passport: ${label}`;
|
|
75
|
+
const lead = decision === "ask" ? "Asks first" : "Runs";
|
|
76
|
+
return rule ? `${lead} under ${rule.owner}: ${rule.says}` : `${lead}: ${label}`;
|
|
77
|
+
}
|
|
17
78
|
/** The second-person rule's cause lines, as the server words them. */
|
|
18
79
|
export const SECOND_PERSON_LABEL = {
|
|
19
80
|
change: "Production changes need someone else to approve",
|
package/dist/cliConnect.js
CHANGED
|
@@ -2,6 +2,7 @@ import { bool, value } from "./cliArgs.js";
|
|
|
2
2
|
import { SERVER_TOO_OLD } from "./cliProtocol.js";
|
|
3
3
|
import { firstText, payloadOf, requireSuccess } from "./cliResult.js";
|
|
4
4
|
import { failure, openUrl, sleep } from "./cliSupport.js";
|
|
5
|
+
import { countOf } from "./plural.js";
|
|
5
6
|
export function managePayload(result) {
|
|
6
7
|
requireSuccess(result);
|
|
7
8
|
const payload = payloadOf(result, "connection");
|
|
@@ -19,7 +20,7 @@ export function managePayload(result) {
|
|
|
19
20
|
}
|
|
20
21
|
function assertConnectionCanStart(auth, needSignin, urls, human, shouldOpen, shouldAct) {
|
|
21
22
|
if (auth.kind === "agent-key" && needSignin.length && shouldAct) {
|
|
22
|
-
return failure("Agent-
|
|
23
|
+
return failure("Agent-token authentication cannot create a person's sign-in link.", 3, "member_profile_required", {
|
|
23
24
|
app: needSignin.length === 1 ? String(needSignin[0].app ?? "") || undefined : undefined,
|
|
24
25
|
hint: "Use an interactive member profile, delegate the agent to a member, or configure a company-managed connection.",
|
|
25
26
|
remediation: {
|
|
@@ -62,7 +63,7 @@ export async function connect(args, runtime, withGateway) {
|
|
|
62
63
|
return failure("--open requires a single connect URL. Name one app, or use the aggregate connect flow.", 6, "usage");
|
|
63
64
|
if (urls[0]) {
|
|
64
65
|
if (!bool(args, "quiet"))
|
|
65
|
-
runtime.stderr.write("Opening the
|
|
66
|
+
runtime.stderr.write("Opening the sign-in page in your browser…\n");
|
|
66
67
|
if (!openUrl(urls[0]))
|
|
67
68
|
runtime.stderr.write(`Could not open a browser automatically. Open: ${urls[0]}\n`);
|
|
68
69
|
}
|
|
@@ -87,7 +88,7 @@ export async function connect(args, runtime, withGateway) {
|
|
|
87
88
|
if (!bool(args, "json") && (!bool(args, "quiet") || !bool(args, "open")))
|
|
88
89
|
runtime.stdout.write(`${human.join("\n")}\n`);
|
|
89
90
|
if (!bool(args, "quiet")) {
|
|
90
|
-
runtime.stderr.write(`Waiting up to ${waitSeconds}
|
|
91
|
+
runtime.stderr.write(`Waiting up to ${countOf(waitSeconds, "second")} for ${targets.length === 1 ? targets[0] : "the connections"}…\n`);
|
|
91
92
|
}
|
|
92
93
|
const waitResult = await waitForConnections(gateway, targets, waitSeconds, runtime.signal);
|
|
93
94
|
if (!waitResult.connected) {
|
|
@@ -102,7 +103,7 @@ function findConnection(rows, requested) {
|
|
|
102
103
|
const needle = requested.trim().toLowerCase();
|
|
103
104
|
const row = rows.find((entry) => String(entry.app ?? "").toLowerCase() === needle || String(entry.name ?? "").toLowerCase() === needle);
|
|
104
105
|
if (!row)
|
|
105
|
-
return failure(`Unknown app "${requested}".
|
|
106
|
+
return failure(`Unknown app "${requested}". See the apps you can connect with passport status.`, 6, "unknown_app", {
|
|
106
107
|
app: requested,
|
|
107
108
|
hint: "Run: passport status",
|
|
108
109
|
next: [{ argv: ["passport", "status"], description: "List visible app connections." }]
|
|
@@ -118,19 +119,19 @@ function connectionUrls(managed, rows, explicitlyNamed) {
|
|
|
118
119
|
function connectionLines(managed, rows, explicitlyNamed) {
|
|
119
120
|
const urls = connectionUrls(managed, rows, explicitlyNamed);
|
|
120
121
|
if (!explicitlyNamed && urls.length === 1 && rows.filter((row) => row.status === "needs_your_signin").length >= 2) {
|
|
121
|
-
return [
|
|
122
|
+
return ["Sign in to your apps on one page:", ` ${urls[0]}`];
|
|
122
123
|
}
|
|
123
124
|
const lines = [];
|
|
124
125
|
for (const row of rows) {
|
|
125
126
|
const name = String(row.name ?? row.app ?? "app");
|
|
126
127
|
if (row.status === "needs_your_signin" && typeof row.connectUrl === "string")
|
|
127
|
-
lines.push(`${name}: ${row.connectUrl}`);
|
|
128
|
+
lines.push(`${name}: sign in here`, ` ${row.connectUrl}`);
|
|
128
129
|
else if (row.status === "connected" || row.status === "org_managed")
|
|
129
130
|
lines.push(`${name}: already connected`);
|
|
130
131
|
else if (typeof row.action === "string")
|
|
131
132
|
lines.push(`${name}: ${row.action}`);
|
|
132
133
|
else
|
|
133
|
-
lines.push(`${name}: ${String(row.status ?? "unknown")}`);
|
|
134
|
+
lines.push(`${name}: ${String(row.status ?? "unknown").replace(/_/g, " ")}`);
|
|
134
135
|
}
|
|
135
136
|
if (!lines.length || (!explicitlyNamed && !rows.some((row) => row.status === "needs_your_signin")))
|
|
136
137
|
lines.push(managed.note || "Nothing needs connecting.");
|
package/dist/cliDeadline.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { countOf } from "./plural.js";
|
|
1
2
|
const systemClock = {
|
|
2
3
|
set: (callback, ms) => setTimeout(callback, ms),
|
|
3
4
|
clear: (timer) => clearTimeout(timer)
|
|
@@ -12,7 +13,7 @@ export async function withCliDeadline(promise, ms, onTimeout, clock = systemCloc
|
|
|
12
13
|
const expired = new Promise((_, reject) => {
|
|
13
14
|
timer = clock.set(() => {
|
|
14
15
|
onTimeout();
|
|
15
|
-
const error = new Error(`Request timed out after ${Math.ceil(ms / 1000)}
|
|
16
|
+
const error = new Error(`Request timed out after ${countOf(Math.ceil(ms / 1000), "second")}.`);
|
|
16
17
|
error.name = "TimeoutError";
|
|
17
18
|
reject(error);
|
|
18
19
|
}, ms);
|
package/dist/cliDescribe.d.ts
CHANGED
|
@@ -6,3 +6,7 @@
|
|
|
6
6
|
* conventional MCP vocabulary. Keep all server-provided fields intact.
|
|
7
7
|
*/
|
|
8
8
|
export declare function describedToolPayload(exact: Record<string, unknown>, fallbackName: string): Record<string, unknown>;
|
|
9
|
+
/** A search hit's class in the word every surface uses: Read, Change, Delete,
|
|
10
|
+
* or Irreversible. A server older than the class sent only `readonly`; a tool
|
|
11
|
+
* it didn't call read-only reads as a change. */
|
|
12
|
+
export declare function toolClassWord(hit: Record<string, unknown>): string;
|
package/dist/cliDescribe.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ACTION_CLASSES, CLASS_LABEL } from "./cliAutopilotPolicy.js";
|
|
1
2
|
/**
|
|
2
3
|
* Normalize a search result for the CLI's describe contract.
|
|
3
4
|
*
|
|
@@ -16,3 +17,13 @@ export function describedToolPayload(exact, fallbackName) {
|
|
|
16
17
|
inputSchema: parameters
|
|
17
18
|
};
|
|
18
19
|
}
|
|
20
|
+
/** A search hit's class in the word every surface uses: Read, Change, Delete,
|
|
21
|
+
* or Irreversible. A server older than the class sent only `readonly`; a tool
|
|
22
|
+
* it didn't call read-only reads as a change. */
|
|
23
|
+
export function toolClassWord(hit) {
|
|
24
|
+
const sent = hit.actionClass;
|
|
25
|
+
if (typeof sent === "string" && ACTION_CLASSES.includes(sent)) {
|
|
26
|
+
return CLASS_LABEL[sent];
|
|
27
|
+
}
|
|
28
|
+
return CLASS_LABEL[hit.readonly === true ? "read" : "change"];
|
|
29
|
+
}
|
package/dist/cliEnv.js
CHANGED
|
@@ -19,7 +19,8 @@ import { readCliPolicy } from "./cliPolicy.js";
|
|
|
19
19
|
import { NODE_LINK_FS } from "./envLinkFs.js";
|
|
20
20
|
import { detectLinks } from "./envResolve.js";
|
|
21
21
|
import { vendorName } from "./envTarget.js";
|
|
22
|
-
import { columns
|
|
22
|
+
import { columns } from "./initUi.js";
|
|
23
|
+
import { wrap } from "./term.js";
|
|
23
24
|
import { callerFrom, failure, resolveCliAuth, safeApiError, timeoutMs } from "./cliSupport.js";
|
|
24
25
|
const HOW = {
|
|
25
26
|
flag: "flag",
|
|
@@ -57,8 +58,8 @@ function environmentCell(row) {
|
|
|
57
58
|
const HEADER = ["App", "Resource", "How", "Environment"];
|
|
58
59
|
/** A row too wide for the table: the app and resource, then how and where. */
|
|
59
60
|
function stacked(row, width) {
|
|
60
|
-
const detail =
|
|
61
|
-
return [...
|
|
61
|
+
const detail = wrap(`${row.how}, ${environmentCell(row)}`, Math.max(20, width - 2)).map((line) => ` ${line}`);
|
|
62
|
+
return [...wrap(`${row.vendor} ${row.resource}`, width), ...detail];
|
|
62
63
|
}
|
|
63
64
|
function whereHere(runtime, deps) {
|
|
64
65
|
const cwd = deps.cwd ?? process.cwd();
|
|
@@ -105,7 +106,7 @@ export function envTableLines(rows, width = Number.POSITIVE_INFINITY) {
|
|
|
105
106
|
const body = columns([HEADER, ...cells], width) ?? rows.flatMap((row) => stacked(row, width));
|
|
106
107
|
const notes = rows
|
|
107
108
|
.filter((row) => row.note)
|
|
108
|
-
.flatMap((row) =>
|
|
109
|
+
.flatMap((row) => wrap(`${row.vendor} ${row.resource}: ${row.note}`, width));
|
|
109
110
|
return [...body, ...notes];
|
|
110
111
|
}
|
|
111
112
|
async function setEnvironment(args, runtime, deps) {
|
package/dist/cliExec.js
CHANGED
|
@@ -40,6 +40,7 @@ import { findVendorBinary, removeShims } from "./execShims.js";
|
|
|
40
40
|
import { approvalLink, hashLink } from "./webLinks.js";
|
|
41
41
|
import { workspaceOfToken } from "./tokenWorkspace.js";
|
|
42
42
|
import { declinedLine, waitingParts } from "./waitingLine.js";
|
|
43
|
+
import { countOf } from "./plural.js";
|
|
43
44
|
export const EXEC_AUTHORIZE_PATH = "/api/my/exec/authorize";
|
|
44
45
|
export const EXEC_RESULT_PATH = "/api/my/exec/result";
|
|
45
46
|
export const EXEC_WAIT_DEFAULT_SECONDS = 100;
|
|
@@ -253,8 +254,9 @@ async function post(client, body, runtime, ms, binary) {
|
|
|
253
254
|
}
|
|
254
255
|
/** Ctrl-C while waiting: the request stays open in Passport. */
|
|
255
256
|
export function stillOpen(approvalId) {
|
|
256
|
-
return failure(
|
|
257
|
+
return failure("The request is still open. Keep waiting, then run the command again.", 4, "approval_pending", {
|
|
257
258
|
approvalId,
|
|
259
|
+
hint: `Run: passport wait ${approvalId}`,
|
|
258
260
|
next: [{ argv: ["passport", "wait", approvalId], description: "Keep waiting for this approval." }]
|
|
259
261
|
});
|
|
260
262
|
}
|
|
@@ -264,8 +266,9 @@ async function waitFor(client, approvalId, seconds, runtime, now) {
|
|
|
264
266
|
for (;;) {
|
|
265
267
|
const left = Math.ceil((deadline - now()) / 1000);
|
|
266
268
|
if (left <= 0) {
|
|
267
|
-
return failure(
|
|
269
|
+
return failure("Still waiting for approval. Keep waiting, then run the command again, or continue with other work.", 4, "approval_pending", {
|
|
268
270
|
approvalId,
|
|
271
|
+
hint: `Run: passport wait ${approvalId}`,
|
|
269
272
|
next: [{ argv: ["passport", "wait", approvalId], description: "Keep waiting for this approval." }]
|
|
270
273
|
});
|
|
271
274
|
}
|
|
@@ -281,7 +284,10 @@ async function waitFor(client, approvalId, seconds, runtime, now) {
|
|
|
281
284
|
catch {
|
|
282
285
|
if (runtime.signal.aborted)
|
|
283
286
|
return stillOpen(approvalId);
|
|
284
|
-
return failure(
|
|
287
|
+
return failure("Passport couldn't be reached while waiting. Keep waiting once you're back online.", 1, "offline", {
|
|
288
|
+
approvalId,
|
|
289
|
+
hint: `Run: passport wait ${approvalId}`
|
|
290
|
+
});
|
|
285
291
|
}
|
|
286
292
|
if (!response.ok) {
|
|
287
293
|
return failure(await safeApiError(response, "Passport couldn't read that approval."), 1, "server", {
|
|
@@ -388,7 +394,7 @@ export function waitingLine(message, seconds) {
|
|
|
388
394
|
const match = message.match(/^(.*?)\s*Waiting for approval from (.+?)\. Run `passport wait/);
|
|
389
395
|
const lead = match?.[1] ? `${match[1]} ` : "";
|
|
390
396
|
const who = match?.[2] ?? "a person";
|
|
391
|
-
return `${lead}Waiting up to ${seconds}
|
|
397
|
+
return `${lead}Waiting up to ${countOf(seconds, "second")} for ${who}. Approve it on your phone or in Passport.`;
|
|
392
398
|
}
|
|
393
399
|
/** The approval's page in the web app, from the signed-in profile. */
|
|
394
400
|
function approvalUrl(auth, approvalId) {
|
|
@@ -499,7 +505,9 @@ export async function exec(args, runtime, deps = {}) {
|
|
|
499
505
|
const credential = checkedCredential(vendor, decided.credential?.env);
|
|
500
506
|
remember(true);
|
|
501
507
|
if (bool(args, "verbose") && typeof decided.credential?.label === "string") {
|
|
502
|
-
|
|
508
|
+
// "Your stored Railway key" reads "Passport: used your stored Railway key."
|
|
509
|
+
const label = decided.credential.label.slice(0, 120);
|
|
510
|
+
runtime.stderr.write(`Passport: used ${label.charAt(0).toLowerCase()}${label.slice(1)}.\n`);
|
|
503
511
|
}
|
|
504
512
|
let code;
|
|
505
513
|
const startedAt = (deps.now ?? Date.now)();
|
package/dist/cliGuardState.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export declare function problemFix(kind: ProblemKind, client?: string): ProblemF
|
|
|
47
47
|
/** The fix for a local guard state, or null when there's nothing to do. */
|
|
48
48
|
export declare function guardStateFix(state: GuardState | null, client: GuardClient): ProblemFix | null;
|
|
49
49
|
export declare function fixLine(fix: ProblemFix): string;
|
|
50
|
+
/** A fix on a terminal: the sentence, then "Run: <command>" on its own line. */
|
|
51
|
+
export declare function fixLines(fix: ProblemFix): string;
|
|
50
52
|
export type OfflineDecision = "ask" | "block" | "allow";
|
|
51
53
|
export type OfflineRow = "production" | "staging" | "development" | "other";
|
|
52
54
|
/** Every environment asks unless the person chose otherwise (`OFFLINE_DEFAULT`
|
package/dist/cliGuardState.js
CHANGED
|
@@ -58,7 +58,7 @@ export function agentLink(client) {
|
|
|
58
58
|
}
|
|
59
59
|
export function problemFix(kind, client) {
|
|
60
60
|
const agent = client ? agentLink(client) : "#agents";
|
|
61
|
-
const install = `passport hook install --
|
|
61
|
+
const install = `passport hook install --agent ${client ?? "claude-code"} --guard --apply`;
|
|
62
62
|
const guardDocs = `${DOCS_BASE}/member/cli-hook#guard-health`;
|
|
63
63
|
switch (kind) {
|
|
64
64
|
case "guard-off":
|
|
@@ -101,6 +101,10 @@ export function guardStateFix(state, client) {
|
|
|
101
101
|
export function fixLine(fix) {
|
|
102
102
|
return fix.command ? `${fix.text} Run: ${fix.command}` : fix.text;
|
|
103
103
|
}
|
|
104
|
+
/** A fix on a terminal: the sentence, then "Run: <command>" on its own line. */
|
|
105
|
+
export function fixLines(fix) {
|
|
106
|
+
return fix.command ? `${fix.text}\nRun: ${fix.command}` : fix.text;
|
|
107
|
+
}
|
|
104
108
|
/** Every environment asks unless the person chose otherwise (`OFFLINE_DEFAULT`
|
|
105
109
|
* in shared/guardContract.ts); used only without a fresh policy. */
|
|
106
110
|
export const OFFLINE_DEFAULT = "ask";
|
package/dist/cliHelp.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `passport help` on a terminal: the same text,
|
|
3
|
-
* A line too long for the terminal
|
|
4
|
-
* (" status Show …", " --yes
|
|
5
|
-
* `[--flag <value>]` whole. Piped and
|
|
2
|
+
* `passport help` on a terminal: the same text, laid out to the real width by
|
|
3
|
+
* the shared renderer (term.ts `layout`). A line too long for the terminal
|
|
4
|
+
* wraps under its own description column (" status Show …", " --yes
|
|
5
|
+
* accept …"), and a usage line keeps each `[--flag <value>]` whole. Piped and
|
|
6
|
+
* `--json` help are unchanged.
|
|
6
7
|
*/
|
|
7
8
|
import type { ParsedArgs } from "./cliArgs.js";
|
|
8
9
|
import type { CommandResult, Runtime } from "./cliSupport.js";
|
package/dist/cliHelp.js
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
import { helpResult } from "./cliOutput.js";
|
|
2
|
-
import {
|
|
3
|
-
const NBSP = " ";
|
|
4
|
-
/** Spaces inside `[…]` and `<…>` stay, so an option never splits from its value. */
|
|
5
|
-
function keepGroups(line) {
|
|
6
|
-
return line.replace(/\[[^\]]*\]|<[^>]*>/g, (group) => group.replace(/ /g, NBSP));
|
|
7
|
-
}
|
|
2
|
+
import { layout, termOf } from "./term.js";
|
|
8
3
|
export function layoutHelp(text, term) {
|
|
9
|
-
|
|
10
|
-
return text;
|
|
11
|
-
return text
|
|
12
|
-
.split("\n")
|
|
13
|
-
.flatMap((line) => {
|
|
14
|
-
if (visibleLength(line) <= term.width)
|
|
15
|
-
return [line];
|
|
16
|
-
// " status Show …" or " --yes accept …": hang under the description.
|
|
17
|
-
const column = line.match(/^(\s*\S+(?: \S+)*?\s{2,})\S/);
|
|
18
|
-
if (column && column[1].length < term.width / 2) {
|
|
19
|
-
const lead = column[1];
|
|
20
|
-
return wrap(keepGroups(line.slice(lead.length)), term.width, lead, " ".repeat(lead.length));
|
|
21
|
-
}
|
|
22
|
-
const indent = line.match(/^\s*/)[0];
|
|
23
|
-
// A usage line hangs its options under the command, an option line its
|
|
24
|
-
// description under the option; prose keeps its indent.
|
|
25
|
-
const hang = /^\s*(?:passport|npx) /.test(line) ? " " : /^\s+-/.test(line) ? " " : "";
|
|
26
|
-
return wrap(keepGroups(line.trimStart()), term.width, indent, `${indent}${hang}`);
|
|
27
|
-
})
|
|
28
|
-
.map((line) => line.split(NBSP).join(" "))
|
|
29
|
-
.join("\n");
|
|
4
|
+
return layout(text, term.width, { groups: true });
|
|
30
5
|
}
|
|
31
6
|
export function help(args, runtime) {
|
|
32
7
|
const result = helpResult(args);
|
package/dist/cliHook.js
CHANGED
|
@@ -538,8 +538,12 @@ export async function hook(args, runtime, deps = {}) {
|
|
|
538
538
|
return hookRegistration(action, value(args, "client"), args, runtime);
|
|
539
539
|
}
|
|
540
540
|
if (action !== undefined && action !== "guard" && action !== "flush") {
|
|
541
|
-
const { failure } = await
|
|
542
|
-
|
|
541
|
+
const [{ failure }, { unknownSubcommand }] = await Promise.all([
|
|
542
|
+
import("./cliSupport.js"),
|
|
543
|
+
import("./cliSuggest.js")
|
|
544
|
+
]);
|
|
545
|
+
const unknown = unknownSubcommand("hook", action, ["install", "uninstall", "status"]);
|
|
546
|
+
return failure(unknown.message, 6, "usage", unknown.next ? { next: unknown.next } : {});
|
|
543
547
|
}
|
|
544
548
|
try {
|
|
545
549
|
if (action === "guard")
|
package/dist/cliHookGuard.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* With a v1 policy (an older server) or none at all, the guard keeps its old
|
|
14
14
|
* shape: ask or deny, never allow.
|
|
15
15
|
*/
|
|
16
|
-
import { decideAction, decisionRank, envLabel } from "./cliAutopilotPolicy.js";
|
|
16
|
+
import { CLASS_EFFECT, CLASS_EFFECT_OTHER, CLASS_OF_RISK as CLASS_OF_HOOK_RISK, causeSentence, decideAction, decisionRank, envLabel } from "./cliAutopilotPolicy.js";
|
|
17
17
|
import { reportedEnvironment } from "./cliHookEnvironment.js";
|
|
18
18
|
import { placementOf, resolveTarget, targetNote } from "./envResolve.js";
|
|
19
19
|
import { NODE_LINK_FS } from "./envLinkFs.js";
|
|
@@ -52,7 +52,7 @@ const OPAQUE_SHELL = /[<>`$\\\n]|\$\(/;
|
|
|
52
52
|
/** Built in, whatever the server sends: these can't be taken back. */
|
|
53
53
|
const BUILT_IN_IRREVERSIBLE = { gh: ["repo delete"] };
|
|
54
54
|
/** Classes the guard decides; anything else (http, api, sql, local) is no decision. */
|
|
55
|
-
const CLASS_OF_RISK =
|
|
55
|
+
const CLASS_OF_RISK = CLASS_OF_HOOK_RISK;
|
|
56
56
|
/** `fly` and `flyctl` share one map; the server may key either spelling. */
|
|
57
57
|
function vendorKeys(vendor) {
|
|
58
58
|
const spec = Object.hasOwn(VENDORS, vendor) ? VENDORS[vendor] : undefined;
|
|
@@ -329,12 +329,6 @@ export function decideGuard(findings, policy, command = "", complete, machine) {
|
|
|
329
329
|
return decideV1(findings, policy);
|
|
330
330
|
}
|
|
331
331
|
// ---- What the agent shows ---------------------------------------------------
|
|
332
|
-
const EFFECT = {
|
|
333
|
-
read: (env) => `reads ${env}`,
|
|
334
|
-
change: (env) => `changes ${env}`,
|
|
335
|
-
delete: (env) => `deletes from ${env}`,
|
|
336
|
-
irreversible: (env) => `can't be undone in ${env}`
|
|
337
|
-
};
|
|
338
332
|
/** How the environment was found: a short aside after the effect
|
|
339
333
|
* (" (linked in this folder)") or a sentence at the end (" Environment
|
|
340
334
|
* unknown, treated as Production."). */
|
|
@@ -395,13 +389,13 @@ export function askMessage(decision) {
|
|
|
395
389
|
}
|
|
396
390
|
if (decision.cause && decision.environment && decision.actionClass) {
|
|
397
391
|
const branch = decision.deciding?.pushEnvironment === "production" ? " (the default branch)" : "";
|
|
398
|
-
const effect = `${
|
|
392
|
+
const effect = `${CLASS_EFFECT[decision.actionClass]} ${envLabel(decision.environment)}${branch}`;
|
|
399
393
|
const because = decision.cause.kind === "preset" ? "" : ` ${decision.cause.label}.`;
|
|
400
394
|
const notes = sourceNotes(decision);
|
|
401
395
|
return `Passport: ${decision.label} ${effect}${notes.aside}.${because}${notes.sentence} Approve to run it.`;
|
|
402
396
|
}
|
|
403
397
|
return decision.destructive
|
|
404
|
-
? `Passport: ${decision.label}
|
|
398
|
+
? `Passport: ${decision.label} ${CLASS_EFFECT_OTHER.delete}. Run it only if you meant to.`
|
|
405
399
|
: `Passport: your Autopilot rules ask before ${decision.label}. Run it only if you meant to.`;
|
|
406
400
|
}
|
|
407
401
|
export function denyMessage(decision, owner) {
|
|
@@ -415,7 +409,7 @@ export function denyMessage(decision, owner) {
|
|
|
415
409
|
: `${owner ? `Ask ${owner} to run it` : "Ask an admin to run it"}, or request an exception in Passport.`;
|
|
416
410
|
const deciding = decision.findings[0];
|
|
417
411
|
const from = deciding?.from && !deciding.project ? ` (${decision.label}, from ${deciding.from})` : "";
|
|
418
|
-
return
|
|
412
|
+
return `${causeSentence("block", decision.cause.label)}${from}. ${next}`;
|
|
419
413
|
}
|
|
420
414
|
return `Passport: your Autopilot rules block ${decision.label}. Change this in Passport › Rules.`;
|
|
421
415
|
}
|
package/dist/cliHookInstall.d.ts
CHANGED
|
@@ -58,6 +58,9 @@ export type Change = {
|
|
|
58
58
|
event: string;
|
|
59
59
|
command: string;
|
|
60
60
|
};
|
|
61
|
+
/** A hook's command as a person reads it: "passport hook guard", not the
|
|
62
|
+
* absolute paths of node and the CLI (those show with --verbose). */
|
|
63
|
+
export declare function shownHookCommand(command: string, verbose: boolean): string;
|
|
61
64
|
/** What `passport init` would change to turn on audit + guard for one agent. */
|
|
62
65
|
export type GuardInstallPlan = {
|
|
63
66
|
client: HookClient;
|
package/dist/cliHookInstall.js
CHANGED
|
@@ -22,6 +22,7 @@ import { syncNative } from "./nativeSync.js";
|
|
|
22
22
|
import { credentialDir } from "./credentialStorage.js";
|
|
23
23
|
import { launcherPath } from "./initInstall.js";
|
|
24
24
|
import { failure } from "./cliSupport.js";
|
|
25
|
+
import { countOf } from "./plural.js";
|
|
25
26
|
export const HOOK_CLIENTS = ["claude-code", "codex", "cursor"];
|
|
26
27
|
const SETTINGS_MAX_BYTES = 1024 * 1024;
|
|
27
28
|
const HOOK_TIMEOUT_SECONDS = 5;
|
|
@@ -326,16 +327,25 @@ const LIMITS_LINE = "It can't see inside scripts, aliases, or make targets.";
|
|
|
326
327
|
const CODEX_TRUST_LINE = "Next: Open Codex → /hooks and trust Passport's hooks.";
|
|
327
328
|
/** What the guard does in Codex, in plain words (status, install, init). */
|
|
328
329
|
export const CODEX_BLOCK_ONLY = "Codex can't show Passport's questions, so Passport blocks a command your rules ask about and tells you how to approve it.";
|
|
329
|
-
|
|
330
|
+
/** A hook's command as a person reads it: "passport hook guard", not the
|
|
331
|
+
* absolute paths of node and the CLI (those show with --verbose). */
|
|
332
|
+
export function shownHookCommand(command, verbose) {
|
|
333
|
+
if (verbose)
|
|
334
|
+
return command.split(" ").map(displayPath).join(" ");
|
|
335
|
+
return command.replace(/^(?:"?\S*node(?:\.exe)?"?\s+)?"?\S*passport(?:\.js|\.mjs|\.cmd)?"?(?=\s)/, "passport");
|
|
336
|
+
}
|
|
337
|
+
function planLines(changes, verbose) {
|
|
330
338
|
const width = Math.max(...changes.map((change) => change.event.length));
|
|
331
|
-
return changes.map((change) =>
|
|
339
|
+
return changes.map((change) =>
|
|
340
|
+
// copy-style-allow double-space: preview columns line up
|
|
341
|
+
` ${change.action.padEnd(6)} ${change.event.padEnd(width)} ${shownHookCommand(change.command, verbose)}`);
|
|
332
342
|
}
|
|
333
|
-
function previewResult(spec, action, path, changes, guard) {
|
|
343
|
+
function previewResult(spec, action, path, changes, guard, verbose = false) {
|
|
334
344
|
return {
|
|
335
345
|
json: { preview: true, action, client: spec.id, path, guard, changes },
|
|
336
346
|
human: [
|
|
337
347
|
`Would change ${spec.name}:`,
|
|
338
|
-
...planLines(changes),
|
|
348
|
+
...planLines(changes, verbose),
|
|
339
349
|
...(action === "uninstall" ? ["Other hooks stay as they are."] : []),
|
|
340
350
|
`File: ${displayPath(path)}`,
|
|
341
351
|
"Re-run with --apply to make this change."
|
|
@@ -403,7 +413,7 @@ function installClient(spec, args, runtime) {
|
|
|
403
413
|
};
|
|
404
414
|
}
|
|
405
415
|
if (!bool(args, "apply"))
|
|
406
|
-
return previewResult(spec, "install", path, changes, guard);
|
|
416
|
+
return previewResult(spec, "install", path, changes, guard, bool(args, "verbose"));
|
|
407
417
|
let next = settings;
|
|
408
418
|
for (const entry of wanted)
|
|
409
419
|
next = withEntry(spec, next, entry, entry.command);
|
|
@@ -441,7 +451,7 @@ function uninstallClient(spec, args, runtime) {
|
|
|
441
451
|
};
|
|
442
452
|
}
|
|
443
453
|
if (!bool(args, "apply"))
|
|
444
|
-
return previewResult(spec, "uninstall", path, changes, guardOnly);
|
|
454
|
+
return previewResult(spec, "uninstall", path, changes, guardOnly, bool(args, "verbose"));
|
|
445
455
|
writeSettings(path, withoutEntries(spec, settings, kinds));
|
|
446
456
|
const stillAudits = guardOnly && registered(spec, settings, "audit") !== null;
|
|
447
457
|
const allowlist = removeAllowlist(spec.id, runtime.env);
|
|
@@ -464,7 +474,7 @@ function removeAllowlist(client, env) {
|
|
|
464
474
|
try {
|
|
465
475
|
const agents = client === "cursor" ? ["cursor", "cursor-cli"] : [client];
|
|
466
476
|
const removed = syncNative(null, { env, remove: true, agents: [...agents] }).reduce((sum, change) => sum + change.removed.length, 0);
|
|
467
|
-
return removed ?
|
|
477
|
+
return removed ? countOf(removed, "entry", "entries") : null;
|
|
468
478
|
}
|
|
469
479
|
catch {
|
|
470
480
|
return null;
|
package/dist/cliHookStatus.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare function localGuardStates(env: Env): Promise<{
|
|
|
13
13
|
label: string | null;
|
|
14
14
|
fix: ProblemFix | null;
|
|
15
15
|
}[]>;
|
|
16
|
-
/** "Codex: Open Codex → /hooks and trust Passport's hooks." for each problem
|
|
16
|
+
/** "Codex: Open Codex → /hooks and trust Passport's hooks." for each problem,
|
|
17
|
+
* and its command on a line of its own: "Run: passport hook install …". */
|
|
17
18
|
export declare function guardFixLines(states: Awaited<ReturnType<typeof localGuardStates>>): string[];
|
|
18
19
|
export declare function hookStatus(args: ParsedArgs, runtime: Runtime): Promise<CommandResult>;
|
package/dist/cliHookStatus.js
CHANGED
|
@@ -5,23 +5,24 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { bool, value } from "./cliArgs.js";
|
|
7
7
|
import { guardClientReports } from "./cliGuardHealth.js";
|
|
8
|
-
import { GUARD_CLIENT_LABEL, GUARD_STATE_LABEL,
|
|
8
|
+
import { GUARD_CLIENT_LABEL, GUARD_STATE_LABEL, fixLines, guardStateFix, localGuardState } from "./cliGuardState.js";
|
|
9
9
|
import { CODEX_BLOCK_ONLY, HOOK_CLIENTS, agentHookStatus, displayPath } from "./cliHookInstall.js";
|
|
10
10
|
import { readCliPolicy } from "./cliPolicy.js";
|
|
11
11
|
import { readCreds } from "./credentials.js";
|
|
12
12
|
import { failure, selectStoredProfile } from "./cliSupport.js";
|
|
13
13
|
import { VERSION } from "./version.js";
|
|
14
|
+
import { countOf } from "./plural.js";
|
|
14
15
|
function ageText(ms) {
|
|
15
16
|
const minutes = Math.floor(ms / 60_000);
|
|
16
17
|
if (minutes < 1)
|
|
17
18
|
return "just now";
|
|
18
19
|
if (minutes < 60)
|
|
19
|
-
return `${minutes
|
|
20
|
+
return `${countOf(minutes, "minute")} ago`;
|
|
20
21
|
const hours = Math.floor(minutes / 60);
|
|
21
22
|
if (hours < 48)
|
|
22
|
-
return `${hours
|
|
23
|
+
return `${countOf(hours, "hour")} ago`;
|
|
23
24
|
const days = Math.floor(hours / 24);
|
|
24
|
-
return `${days}
|
|
25
|
+
return `${countOf(days, "day")} ago`;
|
|
25
26
|
}
|
|
26
27
|
function policyStatus(args, env, now) {
|
|
27
28
|
let profile;
|
|
@@ -38,8 +39,8 @@ function policyStatus(args, env, now) {
|
|
|
38
39
|
const line = !profile
|
|
39
40
|
? "Rules: built-in, asks before destructive commands (not signed in)."
|
|
40
41
|
: !cached
|
|
41
|
-
? "Rules: built-in until synced
|
|
42
|
-
: `${cached.version === 2 ? "Autopilot rules" : "Rules"}: synced ${ageText(ageMs ?? 0)}
|
|
42
|
+
? "Rules: built-in until synced.\nRun: passport status"
|
|
43
|
+
: `${cached.version === 2 ? "Autopilot rules" : "Rules"}: synced ${ageText(ageMs ?? 0)}.`;
|
|
43
44
|
return {
|
|
44
45
|
json: {
|
|
45
46
|
profile: profile ?? null,
|
|
@@ -65,10 +66,20 @@ export async function localGuardStates(env) {
|
|
|
65
66
|
};
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
|
-
/** "Codex: Open Codex → /hooks and trust Passport's hooks." for each problem
|
|
69
|
+
/** "Codex: Open Codex → /hooks and trust Passport's hooks." for each problem,
|
|
70
|
+
* and its command on a line of its own: "Run: passport hook install …". */
|
|
69
71
|
export function guardFixLines(states) {
|
|
70
|
-
return states.flatMap((entry) =>
|
|
72
|
+
return states.flatMap((entry) => entry.fix ? `${GUARD_CLIENT_LABEL[entry.client]}: ${fixLines(entry.fix)}`.split("\n") : []);
|
|
71
73
|
}
|
|
74
|
+
/** How an agent's hooks read in the list: "Audit and guard", "Not installed". */
|
|
75
|
+
const MODE_WORDS = {
|
|
76
|
+
"audit + guard": "Audit and guard",
|
|
77
|
+
audit: "Audit",
|
|
78
|
+
guard: "Guard",
|
|
79
|
+
"via plugin": "Via the Passport plugin",
|
|
80
|
+
"not installed": "Not installed",
|
|
81
|
+
unreadable: "Couldn't read its settings"
|
|
82
|
+
};
|
|
72
83
|
export async function hookStatus(args, runtime) {
|
|
73
84
|
if (value(args, "client"))
|
|
74
85
|
return failure("passport hook status takes no --agent.", 6, "usage");
|
|
@@ -88,17 +99,15 @@ export async function hookStatus(args, runtime) {
|
|
|
88
99
|
const policy = policyStatus(args, runtime.env, Date.now());
|
|
89
100
|
const disabled = runtime.env.PASSPORT_HOOK_DISABLED === "1";
|
|
90
101
|
const nameWidth = Math.max(...agents.map((agent) => agent.name.length));
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
102
|
+
// "Audit and guard · On": what's installed, then the guard's state.
|
|
103
|
+
const stateText = (agent) => {
|
|
104
|
+
const mode = MODE_WORDS[agent.mode] ?? agent.mode;
|
|
105
|
+
return agent.guardLabel ? `${mode} · ${agent.guardLabel}` : mode;
|
|
106
|
+
};
|
|
107
|
+
const stateWidth = Math.max(...agents.map((agent) => stateText(agent).length));
|
|
94
108
|
const codexGuarded = agents.some((agent) => agent.client === "codex" && agent.guard);
|
|
95
109
|
const lines = [
|
|
96
|
-
...agents.map((agent) => [
|
|
97
|
-
agent.name.padEnd(nameWidth),
|
|
98
|
-
agent.mode.padEnd(modeWidth),
|
|
99
|
-
guardText(agent).padEnd(guardWidth),
|
|
100
|
-
displayPath(agent.path)
|
|
101
|
-
].join(" ")),
|
|
110
|
+
...agents.map((agent) => [agent.name.padEnd(nameWidth), stateText(agent).padEnd(stateWidth), displayPath(agent.path)].join(" ")),
|
|
102
111
|
"",
|
|
103
112
|
policy.line,
|
|
104
113
|
...(codexGuarded ? [CODEX_BLOCK_ONLY] : []),
|
package/dist/cliInit.js
CHANGED
|
@@ -31,6 +31,7 @@ import { APP_BY_CLI, APP_BY_PROVIDER, APP_LABELS, INIT_APPS, PASSPORT_CLOUD, hea
|
|
|
31
31
|
import { InitPaused, InitScreen, listOf, processTerminal } from "./initUi.js";
|
|
32
32
|
import { outro } from "./initOutro.js";
|
|
33
33
|
import { ensureOneLinerRuntime, oneLinerNodeProblem } from "./nodeVersion.js";
|
|
34
|
+
import { countOf } from "./plural.js";
|
|
34
35
|
import { runScan } from "./scan.js";
|
|
35
36
|
import { workspaceOfToken } from "./tokenWorkspace.js";
|
|
36
37
|
export { APP_LABELS, INIT_APPS, PASSPORT_CLOUD };
|
|
@@ -224,7 +225,7 @@ export class Init {
|
|
|
224
225
|
detected.apps = await this.soft("apps", "Apps", () => detectApps(this));
|
|
225
226
|
detected.keys = await this.soft("keys", "Keys", async () => (await import("./initKeysStep.js")).detectKeys(this));
|
|
226
227
|
detected.autopilot = await this.soft("autopilot", "Autopilot", () => detectAutopilot(this));
|
|
227
|
-
detected.environments = await this.soft("environments", "
|
|
228
|
+
detected.environments = await this.soft("environments", "Where", () => detectEnvironments(this));
|
|
228
229
|
detected.agents = await this.soft("agents", "Agents", () => detectAgentsPlan(this));
|
|
229
230
|
detected.guard = await this.soft("guard", "Guard", () => detectGuard(this));
|
|
230
231
|
this.screen.idle();
|
|
@@ -309,10 +310,11 @@ export class Init {
|
|
|
309
310
|
return;
|
|
310
311
|
}
|
|
311
312
|
const findings = this.scan.report.findings;
|
|
312
|
-
|
|
313
|
+
// Key names read the same everywhere: alphabetical, joined with "and".
|
|
314
|
+
const providers = [...new Set(findings.map((finding) => finding.provider))].sort((a, b) => a.localeCompare(b));
|
|
313
315
|
const shownProviders = providers.length > 4 ? [...providers.slice(0, 3), `${providers.length - 3} more`] : providers;
|
|
314
316
|
const line = findings.length
|
|
315
|
-
? `${findings.length
|
|
317
|
+
? `${countOf(findings.length, "key")} your agents can reach: ${listOf(shownProviders)}`
|
|
316
318
|
: "No keys found. You can still connect apps.";
|
|
317
319
|
// The scan's own last line of defense applies here too.
|
|
318
320
|
this.screen.step("Scan", this.scan.leaks(line) ? "Found keys your agents can reach." : line);
|