passport-bridge 0.16.13 → 0.16.14
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 +15 -15
- package/dist/bridgeExchange.d.ts +7 -1
- package/dist/bridgeExchange.js +11 -2
- package/dist/cli.js +3 -1
- package/dist/cliActions.js +37 -18
- package/dist/cliArgs.js +14 -9
- package/dist/cliAutopilot.js +35 -14
- package/dist/cliAutopilotPolicy.d.ts +10 -0
- package/dist/cliAutopilotPolicy.js +28 -0
- package/dist/cliConnect.js +7 -6
- package/dist/cliDeadline.js +2 -1
- 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 +2 -2
- 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 +23 -7
- package/dist/cliMain.js +48 -20
- package/dist/cliOffline.d.ts +2 -2
- package/dist/cliOffline.js +31 -8
- package/dist/cliOutput.js +72 -42
- 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/cliSessions.d.ts +3 -2
- package/dist/cliSessions.js +19 -17
- package/dist/cliSetup.js +6 -4
- package/dist/cliSetupLock.js +1 -0
- package/dist/cliSetupOrg.js +7 -5
- package/dist/cliStatus.d.ts +2 -4
- package/dist/cliStatus.js +55 -60
- 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 +43 -24
- 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.js +4 -2
- package/dist/initOutro.d.ts +1 -3
- package/dist/initOutro.js +7 -15
- package/dist/initPlan.js +6 -6
- 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/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
package/dist/cliScan.js
CHANGED
|
@@ -4,6 +4,8 @@ import { COMMANDS, bool, value } from "./cliArgs.js";
|
|
|
4
4
|
import { failure, selfCommand } from "./cliSupport.js";
|
|
5
5
|
import { oneLinerNodeProblem } from "./nodeVersion.js";
|
|
6
6
|
import { runScan } from "./scan.js";
|
|
7
|
+
import { countOf } from "./plural.js";
|
|
8
|
+
import { paint as paintText, visibleLength, wrap } from "./term.js";
|
|
7
9
|
const CHECKED = {
|
|
8
10
|
"agent-configs": "agent configs",
|
|
9
11
|
"cli-sign-ins": "CLI sign-ins",
|
|
@@ -77,11 +79,11 @@ function scanRoot(raw, cwd, command) {
|
|
|
77
79
|
hint: "Pick a folder you can read, or run the scan from inside it."
|
|
78
80
|
});
|
|
79
81
|
}
|
|
80
|
-
return failure(`No folder at ${shown}.`, 6, "usage", { hint: `
|
|
82
|
+
return failure(`No folder at ${shown}. Check the path.`, 6, "usage", { hint: `Run: ${usage}` });
|
|
81
83
|
}
|
|
82
84
|
if (!isDirectory) {
|
|
83
|
-
return failure(`${shown} is a file, not a folder.`, 6, "usage", {
|
|
84
|
-
hint: `
|
|
85
|
+
return failure(`${shown} is a file, not a folder. Pass the project folder that holds it.`, 6, "usage", {
|
|
86
|
+
hint: `Run: ${usage}`
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
return root;
|
|
@@ -99,15 +101,14 @@ function terminalWidth(runtime) {
|
|
|
99
101
|
const columns = stream.isTTY && typeof stream.columns === "number" ? stream.columns : 80;
|
|
100
102
|
return Math.max(48, Math.min(columns, 100));
|
|
101
103
|
}
|
|
102
|
-
const STYLE = { bold: "1", dim: "2", red: "31", yellow: "33" };
|
|
103
104
|
export function renderScan(result, options) {
|
|
104
|
-
const paint = (style, text) => options.color
|
|
105
|
+
const paint = (style, text) => paintText({ color: options.color }, style, text);
|
|
105
106
|
const { report } = result;
|
|
106
107
|
const lines = [];
|
|
107
108
|
const count = report.findings.length;
|
|
108
109
|
if (count) {
|
|
109
|
-
lines.push(paint("bold", `Passport scan: ${count
|
|
110
|
-
const labelWidth = Math.max(...report.findings.map((finding) => finding.label.length)) +
|
|
110
|
+
lines.push(paint("bold", `Passport scan: ${countOf(count, "key")} your agents can reach`), "");
|
|
111
|
+
const labelWidth = Math.max(...report.findings.map((finding) => finding.label.length)) + 2;
|
|
111
112
|
for (const finding of report.findings)
|
|
112
113
|
lines.push(...row(finding, labelWidth, options, paint));
|
|
113
114
|
lines.push("");
|
|
@@ -144,14 +145,14 @@ export function renderScan(result, options) {
|
|
|
144
145
|
}
|
|
145
146
|
// Rows wrap themselves; summary lines wrap here for narrow terminals.
|
|
146
147
|
return lines
|
|
147
|
-
.flatMap((line) =>
|
|
148
|
+
.flatMap((line) => line.startsWith(" ") || visibleLength(line) <= options.width ? [line] : wrap(line, options.width))
|
|
148
149
|
.join("\n");
|
|
149
150
|
}
|
|
150
151
|
function row(finding, labelWidth, options, paint) {
|
|
151
152
|
const severity = finding.severity.padEnd(8);
|
|
152
153
|
const tone = finding.severity === "high" ? "red" : finding.severity === "medium" ? "yellow" : "dim";
|
|
153
154
|
const extra = finding.locations.length - 1;
|
|
154
|
-
const more = extra && !options.verbose ? ` +${extra
|
|
155
|
+
const more = extra && !options.verbose ? ` +${countOf(extra, "more place", "more places")}` : "";
|
|
155
156
|
const head = ` ${paint(tone, severity)}${finding.label.padEnd(labelWidth)}`;
|
|
156
157
|
const inline = 2 + 8 + labelWidth + finding.location.length + more.length <= options.width;
|
|
157
158
|
const out = inline
|
|
@@ -199,22 +200,3 @@ function keychainPlace(platform) {
|
|
|
199
200
|
function sentenceList(items) {
|
|
200
201
|
return items.join(", ");
|
|
201
202
|
}
|
|
202
|
-
const ANSI = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
|
|
203
|
-
function visible(text) {
|
|
204
|
-
return text.replace(ANSI, "").length;
|
|
205
|
-
}
|
|
206
|
-
function wrap(text, width) {
|
|
207
|
-
const lines = [];
|
|
208
|
-
let current = "";
|
|
209
|
-
for (const word of text.split(" ")) {
|
|
210
|
-
if (current && visible(current) + 1 + visible(word) > width) {
|
|
211
|
-
lines.push(current);
|
|
212
|
-
current = word;
|
|
213
|
-
}
|
|
214
|
-
else
|
|
215
|
-
current = current ? `${current} ${word}` : word;
|
|
216
|
-
}
|
|
217
|
-
if (current)
|
|
218
|
-
lines.push(current);
|
|
219
|
-
return lines;
|
|
220
|
-
}
|
package/dist/cliSessions.d.ts
CHANGED
|
@@ -28,8 +28,9 @@ type SessionRow = {
|
|
|
28
28
|
/** One session's cells, for the terminal table: status, agent, folder,
|
|
29
29
|
* started, counts, and environments with what's waiting. */
|
|
30
30
|
export declare function sessionCells(row: SessionRow, now: number, unicode?: boolean): string[];
|
|
31
|
-
/** Sessions on a terminal
|
|
32
|
-
*
|
|
31
|
+
/** Sessions on a terminal, every one laid out the same way: its state, agent,
|
|
32
|
+
* and folder; then when it started, what Passport decided, and where, broken
|
|
33
|
+
* only between those parts; then its link. */
|
|
33
34
|
export declare function sessionTable(rows: SessionRow[], links: Array<string | null>, now: number, term: Term): string[];
|
|
34
35
|
export declare function sessionLine(row: SessionRow, now: number, unicode?: boolean): string;
|
|
35
36
|
export declare function sessions(args: ParsedArgs, runtime: Runtime, deps?: AutopilotDependencies): Promise<CommandResult>;
|
package/dist/cliSessions.js
CHANGED
|
@@ -8,7 +8,7 @@ import { value } from "./cliArgs.js";
|
|
|
8
8
|
import { api, json } from "./cliAutopilot.js";
|
|
9
9
|
import { ENV_LABEL, isEnvKind } from "./cliHookEnvironment.js";
|
|
10
10
|
import { failure, timeoutMs } from "./cliSupport.js";
|
|
11
|
-
import { table, termOf, visibleLength, wrap } from "./term.js";
|
|
11
|
+
import { joinParts, mark, table, termOf, visibleLength, wrap } from "./term.js";
|
|
12
12
|
import { sessionLink } from "./webLinks.js";
|
|
13
13
|
function text(raw, max = 200) {
|
|
14
14
|
if (typeof raw !== "string")
|
|
@@ -21,7 +21,8 @@ const CLIENT_NAMES = {
|
|
|
21
21
|
codex: "Codex",
|
|
22
22
|
cursor: "Cursor",
|
|
23
23
|
copilot: "Copilot",
|
|
24
|
-
cli: "Passport CLI"
|
|
24
|
+
cli: "Passport CLI",
|
|
25
|
+
terminal: "Passport CLI"
|
|
25
26
|
};
|
|
26
27
|
function count(raw) {
|
|
27
28
|
return typeof raw === "number" && Number.isFinite(raw) && raw >= 0 ? Math.trunc(raw) : 0;
|
|
@@ -38,7 +39,7 @@ function when(ms, now) {
|
|
|
38
39
|
* started, counts, and environments with what's waiting. */
|
|
39
40
|
export function sessionCells(row, now, unicode = true) {
|
|
40
41
|
const status = row.status === "running" ? "Running" : row.status === "idle" ? "Idle" : "Ended";
|
|
41
|
-
const dot = row.status === "running" ? (unicode ? "● " : "* ") : "
|
|
42
|
+
const dot = row.status === "running" ? (unicode ? "● " : "* ") : unicode ? "– " : "- ";
|
|
42
43
|
const client = text(row.client, 40) ?? "agent";
|
|
43
44
|
const counts = row.counts ?? {};
|
|
44
45
|
const parts = [`${count(counts.ran)} ran`, `${count(counts.asked)} asked`];
|
|
@@ -57,27 +58,28 @@ export function sessionCells(row, now, unicode = true) {
|
|
|
57
58
|
[environments.join(", "), waiting].filter(Boolean).join(" · ")
|
|
58
59
|
];
|
|
59
60
|
}
|
|
60
|
-
/** Sessions on a terminal
|
|
61
|
-
*
|
|
61
|
+
/** Sessions on a terminal, every one laid out the same way: its state, agent,
|
|
62
|
+
* and folder; then when it started, what Passport decided, and where, broken
|
|
63
|
+
* only between those parts; then its link. */
|
|
62
64
|
export function sessionTable(rows, links, now, term) {
|
|
63
65
|
const cells = rows.map((row) => sessionCells(row, now, term.unicode));
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
return rows.flatMap((_, index) => {
|
|
66
|
+
const heads = table(cells.map(([state = "", agent = "", folder = ""]) => [state, agent, folder]), Number.POSITIVE_INFINITY);
|
|
67
|
+
return rows.flatMap((row, index) => {
|
|
67
68
|
const link = links[index];
|
|
68
|
-
const [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
]
|
|
75
|
-
|
|
69
|
+
const [, , , started = "", counts = "", where = ""] = cells[index];
|
|
70
|
+
// ● running, – idle or ended, from the house marks (colored on a terminal).
|
|
71
|
+
const head = heads[index].replace(/^[●*–-]/, mark(term, row.status === "running" ? "live" : "skip"));
|
|
72
|
+
return [
|
|
73
|
+
...(index ? [""] : []),
|
|
74
|
+
...(visibleLength(head) <= term.width ? [head] : wrap(head.trim(), term.width, "", " ")),
|
|
75
|
+
...joinParts([started, ...counts.split(" · "), ...where.split(" · ")], term.width, " "),
|
|
76
|
+
...(link ? [` ${link}`] : [])
|
|
77
|
+
];
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
80
|
export function sessionLine(row, now, unicode = true) {
|
|
79
81
|
const status = row.status === "running" ? "Running" : row.status === "idle" ? "Idle" : "Ended";
|
|
80
|
-
const dot = row.status === "running" ? (unicode ? "● " : "* ") : "
|
|
82
|
+
const dot = row.status === "running" ? (unicode ? "● " : "* ") : unicode ? "– " : "- ";
|
|
81
83
|
const client = text(row.client, 40) ?? "agent";
|
|
82
84
|
const name = CLIENT_NAMES[client] ?? client;
|
|
83
85
|
const folder = text(row.folder, 40) ?? "";
|
package/dist/cliSetup.js
CHANGED
|
@@ -64,7 +64,7 @@ export async function setup(args, runtime, withGateway, install = runManagedSkil
|
|
|
64
64
|
if ((["list", "installed"].includes(action) && (first || apply || value(args, "client"))) ||
|
|
65
65
|
(action === "install" && (!first || !second)) ||
|
|
66
66
|
(["remove", "rollback"].includes(action) && (!first || second || value(args, "client")))) {
|
|
67
|
-
return failure("Invalid setup arguments
|
|
67
|
+
return failure("Invalid setup arguments.\nRun: passport help setup", 6, "usage");
|
|
68
68
|
}
|
|
69
69
|
if (["installed", "remove", "rollback"].includes(action)) {
|
|
70
70
|
const inventory = install({ ...envelope, operation: "list" });
|
|
@@ -77,11 +77,11 @@ export async function setup(args, runtime, withGateway, install = runManagedSkil
|
|
|
77
77
|
? inventory.items
|
|
78
78
|
.map((item) => `${item.skillName} · ${item.source.client} · ${item.state} · version ${item.installedVersion ?? "none"}`)
|
|
79
79
|
.join("\n")
|
|
80
|
-
: "No managed workflows installed
|
|
80
|
+
: "No managed workflows installed.\nRun: passport setup list"
|
|
81
81
|
};
|
|
82
82
|
const chosen = inventory.items?.find((item) => item.skillName === first);
|
|
83
83
|
if (!chosen)
|
|
84
|
-
return failure("That managed workflow is not in the local inventory
|
|
84
|
+
return failure("That managed workflow is not in the local inventory.\nRun: passport setup installed", 6, "usage");
|
|
85
85
|
return previewOrApply({ ...envelope, operation: action === "remove" ? "uninstall" : "rollback", source: chosen.source }, apply, install);
|
|
86
86
|
}
|
|
87
87
|
if (action === "install") {
|
|
@@ -136,7 +136,9 @@ export async function setup(args, runtime, withGateway, install = runManagedSkil
|
|
|
136
136
|
.flatMap((entry) => [
|
|
137
137
|
`${entry.name} (${entry.id})`,
|
|
138
138
|
...entry.workflows.map((workflow) => ` ${workflow.key} · ${workflow.name} · ${workflow.status}`),
|
|
139
|
-
|
|
139
|
+
...(entry.workflows.length
|
|
140
|
+
? [`Run: passport setup install ${entry.id} <workflow-key> --agent <codex|claude-code> --apply`]
|
|
141
|
+
: [" No workflows in this setup yet."])
|
|
140
142
|
])
|
|
141
143
|
.join("\n")
|
|
142
144
|
: "No team setups are assigned yet. Ask your workspace admin to publish a setup for your team."
|
package/dist/cliSetupLock.js
CHANGED
|
@@ -185,6 +185,7 @@ export function mergeCodexRequirements(existing, strict, platform) {
|
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
187
|
// Inside someone's [features] table, before the next one.
|
|
188
|
+
// copy-style-allow double-space: TOML comment spacing in a managed file
|
|
188
189
|
if (features >= 0 && featureHooks === undefined)
|
|
189
190
|
lines.splice(features + 1, 0, "hooks = true # passport");
|
|
190
191
|
const top = strict && strictValue === undefined ? [BEGIN, CODEX_STRICT_LINE, END, ""] : [];
|
package/dist/cliSetupOrg.js
CHANGED
|
@@ -72,13 +72,13 @@ function shortKey(key) {
|
|
|
72
72
|
* is on the clipboard, or the line says where the key goes. */
|
|
73
73
|
function desktopStep(origin, copied) {
|
|
74
74
|
return copied
|
|
75
|
-
? "Settings → Connectors → Add custom connector
|
|
76
|
-
: `Settings → Connectors → Add custom connector
|
|
75
|
+
? "paste the copied URL in Settings → Connectors → Add custom connector"
|
|
76
|
+
: `in Settings → Connectors → Add custom connector, paste ${origin}/mcp?enroll=<your enrollment key>`;
|
|
77
77
|
}
|
|
78
78
|
function mcpLine(line, desktop) {
|
|
79
79
|
switch (line.mcp) {
|
|
80
80
|
case "added":
|
|
81
|
-
return
|
|
81
|
+
return line.next ? "! Passport added: sign in to it once" : "✓ Passport added";
|
|
82
82
|
case "updated":
|
|
83
83
|
return "✓ Passport updated";
|
|
84
84
|
case "already_set_up":
|
|
@@ -199,9 +199,11 @@ function summary(where, key, url, lines, layout) {
|
|
|
199
199
|
return [
|
|
200
200
|
...say(`Passport setup for ${where} (enrollment ${shortKey(key)})`),
|
|
201
201
|
...(lines.length
|
|
202
|
-
? lines.flatMap((line) => wrap(
|
|
202
|
+
? lines.flatMap((line) => wrap(
|
|
203
|
+
// A step left for the person gets its own "Run:" line under the row.
|
|
204
|
+
`${mcpLine(line, layout.desktop)}${guardLine(line)}${line.mcp === "added" && line.next ? `\nRun: ${line.next}` : ""}`, layout.width, line.name.padEnd(width), " ".repeat(width + 2)))
|
|
203
205
|
: say("No supported agents found. Nothing to set up.")),
|
|
204
|
-
...(!url && lines.length ? say("Hooks are on. Add Passport to your agents
|
|
206
|
+
...(!url && lines.length ? say("Hooks are on. Add Passport to your agents.\nRun: passport init") : []),
|
|
205
207
|
...(url && working ? say("Each agent asks you to sign in to Passport the first time it connects.") : [])
|
|
206
208
|
].join("\n");
|
|
207
209
|
}
|
package/dist/cliStatus.d.ts
CHANGED
|
@@ -21,11 +21,10 @@ import type { CliAuth, CliGateway } from "./cliClient.js";
|
|
|
21
21
|
import { type EnvRow } from "./cliEnv.js";
|
|
22
22
|
import { type CommandResult, type Runtime } from "./cliSupport.js";
|
|
23
23
|
import type { AutopilotStatus } from "./cliAutopilot.js";
|
|
24
|
-
import { type Term } from "./term.js";
|
|
24
|
+
import { ago, type Term } from "./term.js";
|
|
25
|
+
export { ago };
|
|
25
26
|
import { type StatusShim } from "./cliStatusLocal.js";
|
|
26
27
|
type WithGateway = <T>(args: ParsedArgs, runtime: Runtime, fn: (gateway: CliGateway, auth: CliAuth) => Promise<T>) => Promise<T>;
|
|
27
|
-
/** "just now", "4 min ago", "3 h ago", "2 days ago". */
|
|
28
|
-
export declare function ago(ms: number): string;
|
|
29
28
|
export type StatusKey = {
|
|
30
29
|
vendor: string;
|
|
31
30
|
name: string;
|
|
@@ -70,4 +69,3 @@ export type StatusView = {
|
|
|
70
69
|
/** The human screen for `passport status`. */
|
|
71
70
|
export declare function statusLines(view: StatusView, term: Term): string[];
|
|
72
71
|
export declare function status(args: ParsedArgs, runtime: Runtime, withGateway: WithGateway, syncCliPolicy: (profile: string, api: (path: string, init: RequestInit) => Promise<Response>) => Promise<void>): Promise<CommandResult>;
|
|
73
|
-
export {};
|
package/dist/cliStatus.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { managePayload } from "./cliConnect.js";
|
|
2
2
|
import { linksHere, envRows } from "./cliEnv.js";
|
|
3
|
-
import {
|
|
4
|
-
import { computerName, KEYS_PATH } from "./cliKeys.js";
|
|
3
|
+
import { fixLines } from "./cliGuardState.js";
|
|
4
|
+
import { computerName, keyUse, KEYS_PATH } from "./cliKeys.js";
|
|
5
5
|
import { PRESET_LABEL, PRESET_ROWS, rowLabel } from "./cliAutopilotPolicy.js";
|
|
6
6
|
import { ENV_LABEL } from "./cliHookEnvironment.js";
|
|
7
7
|
import { readBoundedJson, sanitize, timeoutMs } from "./cliSupport.js";
|
|
8
|
-
import { mark, paint, table, termOf, visibleLength, wrap } from "./term.js";
|
|
8
|
+
import { ago, mark, paint, table, termOf, visibleLength, wrap } from "./term.js";
|
|
9
|
+
export { ago };
|
|
9
10
|
import { localStatus } from "./cliStatusLocal.js";
|
|
10
11
|
import { ruleLink } from "./webLinks.js";
|
|
12
|
+
import { agree, countOf } from "./plural.js";
|
|
13
|
+
import { listOf } from "./initUi.js";
|
|
11
14
|
import { VERSION } from "./version.js";
|
|
12
15
|
const CLI_POLICY_SYNC_MS = 5_000;
|
|
13
16
|
const LABEL = 13;
|
|
@@ -21,16 +24,6 @@ const CONNECTION_STATUS_LABELS = {
|
|
|
21
24
|
function connectionStatusLabel(status) {
|
|
22
25
|
return CONNECTION_STATUS_LABELS[status] ?? status.replace(/_/g, " ");
|
|
23
26
|
}
|
|
24
|
-
/** "just now", "4 min ago", "3 h ago", "2 days ago". */
|
|
25
|
-
export function ago(ms) {
|
|
26
|
-
const minutes = Math.round(Math.max(0, ms) / 60_000);
|
|
27
|
-
if (minutes < 1)
|
|
28
|
-
return "just now";
|
|
29
|
-
if (minutes < 60)
|
|
30
|
-
return `${minutes} min ago`;
|
|
31
|
-
const hours = Math.round(minutes / 60);
|
|
32
|
-
return hours < 48 ? `${hours} h ago` : `${Math.round(hours / 24)} days ago`;
|
|
33
|
-
}
|
|
34
27
|
/** Keys Passport holds for this person, and CLI keys still on this computer. Never throws. */
|
|
35
28
|
async function keysHeld(fetchApi, signal) {
|
|
36
29
|
try {
|
|
@@ -115,17 +108,14 @@ function markedTable(term, rows) {
|
|
|
115
108
|
...(row.note ? wrap(row.note, width, indent) : [])
|
|
116
109
|
]);
|
|
117
110
|
}
|
|
118
|
-
function wrapped(term, text, rest = "") {
|
|
119
|
-
return wrap(text, valueWidth(term), "", rest);
|
|
120
|
-
}
|
|
121
111
|
function youRows(view, term) {
|
|
122
112
|
const host = hostOf(view.auth.endpoint);
|
|
123
113
|
const who = view.auth.kind === "agent-key"
|
|
124
114
|
? `An agent key in ${view.workspace.name}`
|
|
125
115
|
: `${view.signedInAs && view.signedInAs !== view.member.email ? `${view.signedInAs} (${view.member.email})` : view.member.email} in ${view.workspace.name}`;
|
|
126
116
|
return [
|
|
127
|
-
{ label: "You", lines:
|
|
128
|
-
{ label: "Computer", lines:
|
|
117
|
+
{ label: "You", lines: wrap(`${who}${host ? ` (${host})` : ""}`, valueWidth(term)) },
|
|
118
|
+
{ label: "Computer", lines: wrap(view.computer, valueWidth(term)) }
|
|
129
119
|
];
|
|
130
120
|
}
|
|
131
121
|
/** Each agent's guard here and its fix, coverage, time added, and prompts answered. */
|
|
@@ -133,54 +123,56 @@ function guardRow(autopilot, term) {
|
|
|
133
123
|
const guard = autopilot?.guard;
|
|
134
124
|
if (!guard && !autopilot?.answered && !autopilot?.speed)
|
|
135
125
|
return undefined;
|
|
126
|
+
const width = valueWidth(term);
|
|
136
127
|
const lines = [];
|
|
137
128
|
if (guard?.agents.length) {
|
|
138
129
|
lines.push(...markedTable(term, guard.agents.map((agent) => ({
|
|
139
130
|
mark: agent.state === "on" || agent.state === "locked" ? "done" : "warn",
|
|
140
131
|
name: agent.name,
|
|
141
132
|
detail: agent.label,
|
|
142
|
-
...(agent.fix ? { note:
|
|
133
|
+
...(agent.fix ? { note: fixLines(agent.fix) } : {})
|
|
143
134
|
}))));
|
|
144
135
|
}
|
|
145
136
|
if (guard?.coverage) {
|
|
146
|
-
const
|
|
147
|
-
|
|
137
|
+
const days = guard.coverage.days;
|
|
138
|
+
const window = days === 7 ? "this week" : `in the last ${countOf(days, "day")}`;
|
|
139
|
+
lines.push(...wrap(`Checked ${guard.coverage.percent}% of commands Passport saw ${window}`, width));
|
|
148
140
|
}
|
|
149
141
|
const speed = autopilot?.speed;
|
|
150
142
|
if (speed)
|
|
151
|
-
lines.push(...
|
|
143
|
+
lines.push(...wrap(`${speed.line}${speed.source === "this-computer" ? " (this computer)" : ""}`, width));
|
|
144
|
+
// Nothing answered yet says nothing.
|
|
152
145
|
const answered = autopilot?.answered;
|
|
153
|
-
if (answered) {
|
|
154
|
-
const count = answered.today;
|
|
146
|
+
if (answered?.today) {
|
|
155
147
|
const where = answered.source === "this-computer" ? " on this computer" : "";
|
|
156
|
-
lines.push(...
|
|
148
|
+
lines.push(...wrap(`Answered for you: ${countOf(answered.today, "prompt")} today${where}`, width));
|
|
157
149
|
}
|
|
158
|
-
return { label: "Guard", lines };
|
|
150
|
+
return lines.length ? { label: "Guard", lines } : undefined;
|
|
159
151
|
}
|
|
160
|
-
/** Presets, team floors, exceptions, and how old this
|
|
152
|
+
/** Presets, one environment a line, team floors, exceptions, and how old this
|
|
153
|
+
* computer's copy of the rules is. */
|
|
161
154
|
function autopilotRow(autopilot, endpoint, term) {
|
|
162
155
|
if (!autopilot)
|
|
163
156
|
return undefined;
|
|
157
|
+
const width = valueWidth(term);
|
|
164
158
|
const lines = [];
|
|
165
159
|
const presets = autopilot.presets;
|
|
166
160
|
if (presets) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const floors = PRESET_ROWS.filter((row) => autopilot.floors?.[row]).map((row) => `${rowLabel(row)} at least ${PRESET_LABEL[autopilot.floors[row]]}`);
|
|
170
|
-
const reason = autopilot.floorReason ? ` (${sanitize(autopilot.floorReason)})` : "";
|
|
161
|
+
lines.push(...table(PRESET_ROWS.filter((row) => presets[row]).map((row) => [rowLabel(row), PRESET_LABEL[presets[row]]]), width));
|
|
162
|
+
const floors = PRESET_ROWS.filter((row) => autopilot.floors?.[row]).map((row) => `${rowLabel(row)} is at least ${PRESET_LABEL[autopilot.floors[row]]}`);
|
|
171
163
|
if (floors.length)
|
|
172
|
-
lines.push(...
|
|
164
|
+
lines.push(...wrap(`Team ${agree(floors.length, "floor", "floors")}: ${floors.join(" · ")}`, width));
|
|
173
165
|
for (const exception of autopilot.exceptions ?? [])
|
|
174
|
-
lines.push(...
|
|
166
|
+
lines.push(...wrap(exception, width));
|
|
175
167
|
}
|
|
176
168
|
const { cache } = autopilot;
|
|
177
169
|
const older = cache.version === 1 ? " (older server: asks before destructive commands only)" : "";
|
|
178
|
-
lines.push(...
|
|
170
|
+
lines.push(...wrap(cache.fetchedAt === null
|
|
179
171
|
? "Rules on this computer: not synced yet"
|
|
180
|
-
: `Rules on this computer: synced ${ago(cache.ageMs ?? 0)}${older}
|
|
172
|
+
: `Rules on this computer: synced ${ago(cache.ageMs ?? 0)}${older}`, width));
|
|
181
173
|
const rules = ruleLink(endpoint);
|
|
182
174
|
if (rules && presets)
|
|
183
|
-
lines.push(...
|
|
175
|
+
lines.push(...wrap(`Change your rules: ${rules}`, width));
|
|
184
176
|
return { label: "Autopilot", lines };
|
|
185
177
|
}
|
|
186
178
|
function appRow(view, term) {
|
|
@@ -190,13 +182,13 @@ function appRow(view, term) {
|
|
|
190
182
|
? "Needs an interactive member profile, delegation, or a company-managed connection."
|
|
191
183
|
: /^[A-Za-z0-9._-]+$/.test(app)
|
|
192
184
|
? `Run: passport connect ${app} --wait 120`
|
|
193
|
-
: "Run passport status --json
|
|
185
|
+
: "Run: passport status --json";
|
|
194
186
|
return {
|
|
195
187
|
label: "Apps",
|
|
196
188
|
lines: markedTable(term, view.mcps.map((mcp) => {
|
|
197
189
|
const ready = mcp.status === "connected" || mcp.status === "org_managed";
|
|
198
190
|
const signIn = mcp.status === "needs_your_signin";
|
|
199
|
-
const tools =
|
|
191
|
+
const tools = countOf(mcp.toolCount, "tool");
|
|
200
192
|
return {
|
|
201
193
|
mark: ready ? "done" : signIn ? "warn" : "skip",
|
|
202
194
|
name: mcp.name,
|
|
@@ -213,33 +205,33 @@ function keysRow(view, term) {
|
|
|
213
205
|
return undefined;
|
|
214
206
|
const lines = markedTable(term, keys.keys.map((key) => {
|
|
215
207
|
const ok = key.status === "ok";
|
|
216
|
-
const used = key.lastUsedAt ? `used ${ago(view.now - key.lastUsedAt)}` : "not used yet";
|
|
217
208
|
return {
|
|
218
209
|
mark: ok ? "done" : "warn",
|
|
219
210
|
name: key.name,
|
|
220
|
-
detail: ok ?
|
|
211
|
+
detail: ok ? keyUse(key.lastUsedAt, view.now) : key.status.replace(/_/g, " "),
|
|
221
212
|
...(ok ? {} : { note: `Run: passport keys move ${key.vendor}` })
|
|
222
213
|
};
|
|
223
214
|
}));
|
|
224
215
|
if (keys.onThisComputer.length) {
|
|
225
|
-
lines.push(...
|
|
216
|
+
lines.push(...wrap(`Still on this computer: ${listOf(keys.onThisComputer)}.`, valueWidth(term)));
|
|
217
|
+
lines.push("Run: passport keys move");
|
|
226
218
|
}
|
|
227
219
|
return { label: "Keys", lines };
|
|
228
220
|
}
|
|
229
221
|
const SHIM_STATE = {
|
|
230
|
-
active: { mark: "done", detail: "runs through Passport
|
|
222
|
+
active: { mark: "done", detail: "runs through Passport" },
|
|
231
223
|
not_on_path: {
|
|
232
224
|
mark: "warn",
|
|
233
|
-
detail: "Passport's folder isn't on PATH
|
|
234
|
-
note: "Run: passport keys shim
|
|
225
|
+
detail: "still runs the vendor's CLI (Passport's folder isn't on PATH)",
|
|
226
|
+
note: "Run: passport keys shim"
|
|
235
227
|
},
|
|
236
228
|
shadowed: {
|
|
237
229
|
mark: "warn",
|
|
238
|
-
detail: "the vendor's
|
|
239
|
-
note: "Run: passport keys shim
|
|
230
|
+
detail: "still runs the vendor's CLI (it comes first on PATH)",
|
|
231
|
+
note: "Run: passport keys shim"
|
|
240
232
|
}
|
|
241
233
|
};
|
|
242
|
-
/** Vendor commands that run through Passport
|
|
234
|
+
/** Vendor commands you type that run through Passport, and whether they will. */
|
|
243
235
|
function shimRow(view, term) {
|
|
244
236
|
if (!view.shims?.length)
|
|
245
237
|
return undefined;
|
|
@@ -251,10 +243,10 @@ function shimRow(view, term) {
|
|
|
251
243
|
return { mark: state.mark, name: shim.command, detail: state.detail };
|
|
252
244
|
}));
|
|
253
245
|
for (const note of notes)
|
|
254
|
-
lines.push(...
|
|
255
|
-
return { label: "
|
|
246
|
+
lines.push(...wrap(note, valueWidth(term)));
|
|
247
|
+
return { label: "Typing", lines };
|
|
256
248
|
}
|
|
257
|
-
/** This folder's links
|
|
249
|
+
/** This folder's links: "Railway production (linked), counted as Production". */
|
|
258
250
|
function folderRow(view, term) {
|
|
259
251
|
if (!view.folder.length)
|
|
260
252
|
return undefined;
|
|
@@ -262,28 +254,31 @@ function folderRow(view, term) {
|
|
|
262
254
|
label: "This folder",
|
|
263
255
|
lines: view.folder.flatMap((row) => {
|
|
264
256
|
const kind = ENV_LABEL[row.kind] ?? row.kind;
|
|
257
|
+
// "production" counted as Production says nothing new: no "until placed".
|
|
265
258
|
const unplaced = row.assumed && row.resource.toLowerCase() !== row.kind.toLowerCase();
|
|
266
|
-
return
|
|
259
|
+
return wrap(`${row.vendor} ${row.resource} (${row.how}), counted as ${kind}${unplaced ? " until placed" : ""}`, valueWidth(term));
|
|
267
260
|
})
|
|
268
261
|
};
|
|
269
262
|
}
|
|
263
|
+
/** "Claude Code and Codex: 21 commands each, kept in sync". */
|
|
270
264
|
function allowlistRow(autopilot, term) {
|
|
271
265
|
if (!autopilot?.allowlists)
|
|
272
266
|
return undefined;
|
|
273
267
|
const synced = autopilot.allowlists.filter((entry) => entry.entries > 0);
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
:
|
|
279
|
-
|
|
268
|
+
const counts = new Set(synced.map((entry) => entry.entries));
|
|
269
|
+
const text = !synced.length
|
|
270
|
+
? "On, nothing to add yet"
|
|
271
|
+
: counts.size === 1
|
|
272
|
+
? `${listOf(synced.map((entry) => entry.name))}: ${countOf(synced[0].entries, "command")}${synced.length > 1 ? " each" : ""}, kept in sync`
|
|
273
|
+
: `${listOf(synced.map((entry) => `${entry.name} (${countOf(entry.entries, "command")})`))}, kept in sync`;
|
|
274
|
+
return { label: "Allowlists", lines: wrap(text, valueWidth(term)) };
|
|
280
275
|
}
|
|
281
276
|
/** The CLI's version, and how to update when Passport says a guard here is out of date. */
|
|
282
|
-
function cliRow(autopilot
|
|
277
|
+
function cliRow(autopilot) {
|
|
283
278
|
const outdated = autopilot?.guard?.agents.some((agent) => agent.state === "outdated");
|
|
284
279
|
return {
|
|
285
280
|
label: "CLI",
|
|
286
|
-
lines:
|
|
281
|
+
lines: outdated ? [`${VERSION}, out of date`, "Run: npm install -g passport-bridge@latest"] : [VERSION]
|
|
287
282
|
};
|
|
288
283
|
}
|
|
289
284
|
/** The human screen for `passport status`. */
|
|
@@ -297,7 +292,7 @@ export function statusLines(view, term) {
|
|
|
297
292
|
shimRow(view, term),
|
|
298
293
|
folderRow(view, term),
|
|
299
294
|
allowlistRow(view.autopilot, term),
|
|
300
|
-
cliRow(view.autopilot
|
|
295
|
+
cliRow(view.autopilot)
|
|
301
296
|
].filter((row) => Boolean(row));
|
|
302
297
|
return sections(rows, term);
|
|
303
298
|
}
|
package/dist/cliSuggest.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ export declare function editDistance(left: string, right: string): number;
|
|
|
9
9
|
/** The known name closest to `input`, or undefined when none is close. */
|
|
10
10
|
export declare function closest(input: string, names: readonly string[]): string | undefined;
|
|
11
11
|
/** `Unknown keys command "mvoe". Did you mean: passport keys move`, and the
|
|
12
|
-
* suggested argv for --json's `next`.
|
|
13
|
-
|
|
12
|
+
* suggested argv for --json's `next`. `removal` is what to say when someone
|
|
13
|
+
* asks to remove something the command can't remove. */
|
|
14
|
+
export declare function unknownSubcommand(command: string, typed: string, names: readonly string[], removal?: string): {
|
|
14
15
|
message: string;
|
|
15
16
|
next?: Array<{
|
|
16
17
|
argv: string[];
|
package/dist/cliSuggest.js
CHANGED
|
@@ -41,14 +41,27 @@ export function closest(input, names) {
|
|
|
41
41
|
}
|
|
42
42
|
return best;
|
|
43
43
|
}
|
|
44
|
+
/** Words that take something away. A typo of one is never "corrected" to a
|
|
45
|
+
* command that adds or moves something (`remove` is not `move`). */
|
|
46
|
+
const REMOVING = /^(?:remove|rm|delete|del|uninstall|revoke|drop)$/;
|
|
47
|
+
/** "move", "move or add", "list, move, add, or shim". */
|
|
48
|
+
function orList(names) {
|
|
49
|
+
if (names.length <= 2)
|
|
50
|
+
return names.join(" or ");
|
|
51
|
+
return `${names.slice(0, -1).join(", ")}, or ${names.at(-1)}`;
|
|
52
|
+
}
|
|
44
53
|
/** `Unknown keys command "mvoe". Did you mean: passport keys move`, and the
|
|
45
|
-
* suggested argv for --json's `next`.
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
* suggested argv for --json's `next`. `removal` is what to say when someone
|
|
55
|
+
* asks to remove something the command can't remove. */
|
|
56
|
+
export function unknownSubcommand(command, typed, names, removal) {
|
|
57
|
+
const removing = REMOVING.test(typed.toLowerCase());
|
|
58
|
+
const candidate = closest(typed, names);
|
|
59
|
+
const guess = candidate && removing && !REMOVING.test(candidate) ? undefined : candidate;
|
|
60
|
+
if (!guess && removing && removal)
|
|
61
|
+
return { message: `There's no passport ${command} ${typed}. ${removal}` };
|
|
48
62
|
const shown = `Unknown ${command} command "${typed}".`;
|
|
49
|
-
if (!guess)
|
|
50
|
-
return { message: `${shown} Use
|
|
51
|
-
}
|
|
63
|
+
if (!guess)
|
|
64
|
+
return { message: `${shown} Use passport ${command} ${orList(names)}.` };
|
|
52
65
|
const argv = ["passport", command, guess];
|
|
53
66
|
return {
|
|
54
67
|
message: `${shown} Did you mean: ${argv.join(" ")}`,
|
package/dist/cliSupport.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export type CliNextAction = {
|
|
|
28
28
|
};
|
|
29
29
|
/** First sign-in needs nothing: bare `passport login` opens the browser to sign
|
|
30
30
|
* in or sign up and pick a workspace. `passport init` does the same, step by step. */
|
|
31
|
-
export declare const FIRST_LOGIN_HINT = "Run: passport login
|
|
31
|
+
export declare const FIRST_LOGIN_HINT = "Run: passport login";
|
|
32
32
|
export declare const FIRST_LOGIN_NEXT: CliNextAction[];
|
|
33
33
|
export type CliRemediation = {
|
|
34
34
|
action: string;
|
package/dist/cliSupport.js
CHANGED
|
@@ -12,7 +12,7 @@ export function selfCommand(runtime) {
|
|
|
12
12
|
}
|
|
13
13
|
/** First sign-in needs nothing: bare `passport login` opens the browser to sign
|
|
14
14
|
* in or sign up and pick a workspace. `passport init` does the same, step by step. */
|
|
15
|
-
export const FIRST_LOGIN_HINT = "Run: passport login
|
|
15
|
+
export const FIRST_LOGIN_HINT = "Run: passport login";
|
|
16
16
|
export const FIRST_LOGIN_NEXT = [
|
|
17
17
|
{ argv: ["passport", "login"], description: "Sign in or sign up in the browser." },
|
|
18
18
|
{ argv: ["passport", "init"], description: "Set up Passport for your agents, step by step." }
|
|
@@ -161,9 +161,7 @@ export function resolveCliAuth(args, env) {
|
|
|
161
161
|
const profile = selection.profile ?? "";
|
|
162
162
|
if (!profile) {
|
|
163
163
|
const suffix = names.length ? ` Available profiles: ${names.join(", ")}.` : "";
|
|
164
|
-
const hint = names.length
|
|
165
|
-
? `Choose one with: passport use <name> (available: ${names.join(", ")}), or pass --profile <name>.`
|
|
166
|
-
: FIRST_LOGIN_HINT;
|
|
164
|
+
const hint = names.length ? "Run: passport use <name>" : FIRST_LOGIN_HINT;
|
|
167
165
|
return failure(names.length ? `No Passport profile selected.${suffix}` : "Not signed in to Passport.", 2, "auth", {
|
|
168
166
|
hint,
|
|
169
167
|
...(names.length
|
|
@@ -183,9 +181,7 @@ export function resolveCliAuth(args, env) {
|
|
|
183
181
|
const saved = creds[profile];
|
|
184
182
|
if (!saved) {
|
|
185
183
|
const suffix = names.length ? ` Available profiles: ${names.join(", ")}.` : "";
|
|
186
|
-
const hint = names.length
|
|
187
|
-
? `Choose one with: passport use <name> (available: ${names.join(", ")}), or pass --profile <name>.`
|
|
188
|
-
: FIRST_LOGIN_HINT;
|
|
184
|
+
const hint = names.length ? "Run: passport use <name>" : FIRST_LOGIN_HINT;
|
|
189
185
|
return failure(`Passport profile "${profile}" does not exist.${suffix}`, 2, "auth", {
|
|
190
186
|
hint,
|
|
191
187
|
...(names.length
|
package/dist/cliSync.js
CHANGED
|
@@ -13,12 +13,14 @@ import { failure, resolveCliAuth, timeoutMs } from "./cliSupport.js";
|
|
|
13
13
|
import { syncNative } from "./nativeSync.js";
|
|
14
14
|
function line(change, width) {
|
|
15
15
|
const name = change.name.padEnd(width);
|
|
16
|
+
// copy-style-allow double-space: columns line up
|
|
16
17
|
if (change.skipped)
|
|
17
18
|
return `${name} left alone: ${change.skipped}`;
|
|
18
19
|
const parts = [
|
|
19
20
|
...(change.added.length ? [`added ${change.added.length}`] : []),
|
|
20
21
|
...(change.removed.length ? [`removed ${change.removed.length}`] : [])
|
|
21
22
|
];
|
|
23
|
+
// copy-style-allow double-space: columns line up
|
|
22
24
|
return `${name} ${parts.length ? parts.join(", ") : "up to date"} · ${displayPath(change.path)}`;
|
|
23
25
|
}
|
|
24
26
|
export async function sync(args, runtime, deps = {}) {
|