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
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 = {}) {
|
package/dist/cliUndo.d.ts
CHANGED
|
@@ -20,7 +20,9 @@ export declare function backupAge(takenAt: number, now?: number): string;
|
|
|
20
20
|
export declare function undoWindowLeft(expiresAt: number, now?: number): string;
|
|
21
21
|
export type UndoDependencies = AutopilotDependencies & {
|
|
22
22
|
/** The terminal that asks; tests script it. */
|
|
23
|
-
terminal?: Pick<InitTerminal, "interactive" | "unicode" | "question"
|
|
23
|
+
terminal?: Pick<InitTerminal, "interactive" | "unicode" | "question"> & {
|
|
24
|
+
color?: boolean;
|
|
25
|
+
};
|
|
24
26
|
};
|
|
25
27
|
type Option = {
|
|
26
28
|
id: string;
|
package/dist/cliUndo.js
CHANGED
|
@@ -14,6 +14,8 @@ import { api, json } from "./cliAutopilot.js";
|
|
|
14
14
|
import { failure, safeApiError, timeoutMs } from "./cliSupport.js";
|
|
15
15
|
import { processTerminal } from "./initUi.js";
|
|
16
16
|
import { askYesNo } from "./cliAsk.js";
|
|
17
|
+
import { mark as markOf } from "./term.js";
|
|
18
|
+
import { countOf } from "./plural.js";
|
|
17
19
|
/* Checked copies of shared/undoContract.ts (the CLI can't import shared/);
|
|
18
20
|
* cliUndo.test.ts fails if they drift. */
|
|
19
21
|
export const UNDO_RETENTION_DAYS = 7;
|
|
@@ -24,12 +26,12 @@ export function backupAge(takenAt, now = Date.now()) {
|
|
|
24
26
|
if (minutes < 1)
|
|
25
27
|
return "just now";
|
|
26
28
|
if (minutes < 60)
|
|
27
|
-
return `${minutes
|
|
29
|
+
return `${countOf(minutes, "minute")} ago`;
|
|
28
30
|
const hours = Math.round(minutes / 60);
|
|
29
31
|
if (hours < 24)
|
|
30
|
-
return `${hours
|
|
32
|
+
return `${countOf(hours, "hour")} ago`;
|
|
31
33
|
const days = Math.round(hours / 24);
|
|
32
|
-
return `${days
|
|
34
|
+
return `${countOf(days, "day")} ago`;
|
|
33
35
|
}
|
|
34
36
|
/** "Undo available for 6 more days", "Undo available for 3 more hours". */
|
|
35
37
|
export function undoWindowLeft(expiresAt, now = Date.now()) {
|
|
@@ -39,12 +41,12 @@ export function undoWindowLeft(expiresAt, now = Date.now()) {
|
|
|
39
41
|
const hours = Math.floor(left / 3_600_000);
|
|
40
42
|
if (hours >= 24) {
|
|
41
43
|
const days = Math.floor(hours / 24);
|
|
42
|
-
return `Undo available for ${days
|
|
44
|
+
return `Undo available for ${countOf(days, "more day")}.`;
|
|
43
45
|
}
|
|
44
46
|
if (hours >= 1)
|
|
45
|
-
return `Undo available for ${hours
|
|
47
|
+
return `Undo available for ${countOf(hours, "more hour")}.`;
|
|
46
48
|
const minutes = Math.max(1, Math.floor(left / 60_000));
|
|
47
|
-
return `Undo available for ${minutes
|
|
49
|
+
return `Undo available for ${countOf(minutes, "more minute")}.`;
|
|
48
50
|
}
|
|
49
51
|
const ACTION_ID = /^[A-Za-z0-9_-]{1,80}$/;
|
|
50
52
|
const OPTION_ID = /^[a-z-]{1,40}$/;
|
|
@@ -176,7 +178,7 @@ async function load(client, requested, args, runtime) {
|
|
|
176
178
|
}
|
|
177
179
|
const body = (await fetchPreview(client, "/api/my/undo/last", args, runtime));
|
|
178
180
|
if (typeof body.actionId !== "string" || !ACTION_ID.test(body.actionId)) {
|
|
179
|
-
return failure(`Nothing to undo. ${
|
|
181
|
+
return failure(`Nothing to undo. Passport keeps backups for ${UNDO_RETENTION_DAYS} days.`, 6, "no_backup");
|
|
180
182
|
}
|
|
181
183
|
const actionId = body.actionId;
|
|
182
184
|
return {
|
|
@@ -233,7 +235,7 @@ function steps(raw) {
|
|
|
233
235
|
.slice(0, 20);
|
|
234
236
|
}
|
|
235
237
|
/** What the server answered, as this command's result or failure. */
|
|
236
|
-
function outcome(result, preview, option,
|
|
238
|
+
function outcome(result, preview, option, term) {
|
|
237
239
|
const { actionId } = preview;
|
|
238
240
|
const status = typeof result.status === "string" ? result.status : "failed";
|
|
239
241
|
const message = clean(result.message, 400) ?? "Passport couldn't run the undo.";
|
|
@@ -241,8 +243,9 @@ function outcome(result, preview, option, unicode) {
|
|
|
241
243
|
const chosen = preview.options.length > 1 ? option.id : undefined;
|
|
242
244
|
if (status === "pending") {
|
|
243
245
|
const again = `passport undo ${actionId}${chosen ? ` --option ${chosen}` : ""} --yes`;
|
|
244
|
-
return failure(/passport undo/.test(message) ? message : `${message} Once it's approved, run
|
|
246
|
+
return failure(/passport undo/.test(message) ? message : `${message} Once it's approved, run the undo again.`, 4, "approval_pending", {
|
|
245
247
|
...(approvalId ? { approvalId } : {}),
|
|
248
|
+
...(/passport undo/.test(message) ? {} : { hint: `Run: ${again}` }),
|
|
246
249
|
next: [
|
|
247
250
|
...(approvalId
|
|
248
251
|
? [{ argv: ["passport", "wait", approvalId], description: "Wait for a person to approve the undo." }]
|
|
@@ -256,7 +259,7 @@ function outcome(result, preview, option, unicode) {
|
|
|
256
259
|
if (status === "declined")
|
|
257
260
|
return failure(message, 5, "approval_denied", approvalId ? { approvalId } : {});
|
|
258
261
|
const ran = steps(result.steps);
|
|
259
|
-
const mark = (ok) => (
|
|
262
|
+
const mark = (ok) => markOf({ color: term.color ?? false, unicode: term.unicode }, ok ? "done" : "fail");
|
|
260
263
|
const undoActionId = typeof result.undoActionId === "string" && ACTION_ID.test(result.undoActionId) ? result.undoActionId : undefined;
|
|
261
264
|
return {
|
|
262
265
|
json: { actionId, status, message, steps: ran, option: option.id, ...(undoActionId ? { undoActionId } : {}) },
|
|
@@ -303,5 +306,5 @@ export async function undo(args, runtime, deps = {}) {
|
|
|
303
306
|
});
|
|
304
307
|
if (response.status === 404)
|
|
305
308
|
return failure(await safeApiError(response, NO_BACKUP), 6, "no_backup");
|
|
306
|
-
return outcome(await json(response, NO_BACKUP), preview, confirmed.option, terminal
|
|
309
|
+
return outcome(await json(response, NO_BACKUP), preview, confirmed.option, terminal);
|
|
307
310
|
}
|
package/dist/cliWait.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `passport wait <approval-id> [--timeout <sec>]`: wait for a person to
|
|
3
|
-
* decide an approval request.
|
|
4
|
-
*
|
|
3
|
+
* decide an approval request. Once Passport says it is still waiting, on a
|
|
4
|
+
* terminal it prints the approval link and keeps one live line ("Waiting for
|
|
5
|
+
* Erin · 1:32 left"); piped, one
|
|
5
6
|
* line once Passport says it's still pending. Light on purpose: it loads
|
|
6
7
|
* before anything prints.
|
|
7
8
|
*/
|
package/dist/cliWait.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `passport wait <approval-id> [--timeout <sec>]`: wait for a person to
|
|
3
|
-
* decide an approval request.
|
|
4
|
-
*
|
|
3
|
+
* decide an approval request. Once Passport says it is still waiting, on a
|
|
4
|
+
* terminal it prints the approval link and keeps one live line ("Waiting for
|
|
5
|
+
* Erin · 1:32 left"); piped, one
|
|
5
6
|
* line once Passport says it's still pending. Light on purpose: it loads
|
|
6
7
|
* before anything prints.
|
|
7
8
|
*/
|
|
@@ -9,6 +10,7 @@ import { bool, value } from "./cliArgs.js";
|
|
|
9
10
|
import { CliFailure, failure, resolveCliAuth, safeApiError, sleep } from "./cliSupport.js";
|
|
10
11
|
import { workspaceOfToken } from "./tokenWorkspace.js";
|
|
11
12
|
import { approvalLink } from "./webLinks.js";
|
|
13
|
+
import { countOf } from "./plural.js";
|
|
12
14
|
/** Long enough to be useful, short enough for an agent's default 2-minute
|
|
13
15
|
* command timeout. */
|
|
14
16
|
export const WAIT_DEFAULT_SECONDS = 100;
|
|
@@ -83,14 +85,12 @@ export async function wait(args, runtime, deps = {}) {
|
|
|
83
85
|
env: runtime.env,
|
|
84
86
|
seconds: Math.max(0, Math.ceil((deadline - now()) / 1000)),
|
|
85
87
|
...(url ? { url } : {}),
|
|
86
|
-
pipedLine: `Waiting for a decision on ${id} (up to ${totalSeconds
|
|
88
|
+
pipedLine: `Waiting for a decision on ${id} (up to ${countOf(totalSeconds, "second")}).`,
|
|
87
89
|
now
|
|
88
90
|
});
|
|
89
91
|
};
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
if (runtime.stderr.isTTY && (deps.api || signedIn(args, runtime)))
|
|
93
|
-
await announce();
|
|
92
|
+
// The link and the countdown come only once Passport says the request is
|
|
93
|
+
// still waiting: never for one that doesn't exist or is already decided.
|
|
94
94
|
const { api, json } = await import("./cliMemberCall.js");
|
|
95
95
|
const client = api(args, runtime, deps, (WAIT_POLL_SECONDS + 10) * 1000, true);
|
|
96
96
|
try {
|
|
@@ -160,21 +160,13 @@ function approvalUrlFor(args, runtime, origin, id) {
|
|
|
160
160
|
}
|
|
161
161
|
return approvalLink(endpoint, id, workspace || undefined) ?? undefined;
|
|
162
162
|
}
|
|
163
|
-
function signedIn(args, runtime) {
|
|
164
|
-
try {
|
|
165
|
-
resolveCliAuth(args, runtime.env);
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
catch {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
163
|
/** Out of time, or Ctrl-C: the request is still open in Passport. */
|
|
173
164
|
function stillWaiting(id, interrupted) {
|
|
174
165
|
return failure(interrupted
|
|
175
|
-
?
|
|
176
|
-
:
|
|
166
|
+
? "The request is still open. Keep waiting any time."
|
|
167
|
+
: "Still waiting for approval. Keep waiting, or continue with other work.", 4, "approval_pending", {
|
|
177
168
|
approvalId: id,
|
|
169
|
+
hint: `Run: passport wait ${id}`,
|
|
178
170
|
next: [{ argv: ["passport", "wait", id], description: "Keep waiting for this approval." }]
|
|
179
171
|
});
|
|
180
172
|
}
|
package/dist/doctor.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Term } from "./term.js";
|
|
1
2
|
export type DoctorStatus = "pass" | "warn" | "fail" | "skip";
|
|
2
3
|
export type DoctorCheck = {
|
|
3
4
|
id: string;
|
|
@@ -30,5 +31,7 @@ type DoctorOptions = {
|
|
|
30
31
|
};
|
|
31
32
|
export declare function nodeRuntimeSupported(version: string): boolean;
|
|
32
33
|
export declare function runDoctor(options: DoctorOptions): Promise<DoctorReport>;
|
|
33
|
-
|
|
34
|
+
/** Nobody is signed in here: not a fault to fix, just the next step. */
|
|
35
|
+
export declare function signedOut(report: DoctorReport): boolean;
|
|
36
|
+
export declare function formatDoctorReport(report: DoctorReport, term?: Pick<Term, "color" | "unicode">): string;
|
|
34
37
|
export {};
|
package/dist/doctor.js
CHANGED
|
@@ -3,6 +3,13 @@ import { readBoundedUtf8File } from "./boundedFile.js";
|
|
|
3
3
|
import { CliGateway, CLI_PROTOCOL_TOOLS, MIN_CLI_SERVER_VERSION } from "./cliClient.js";
|
|
4
4
|
import { activeProfilePath, assertProfileName, credsPath } from "./credentials.js";
|
|
5
5
|
import { ensurePrivateDirectory } from "./credentialStorage.js";
|
|
6
|
+
import { countOf } from "./plural.js";
|
|
7
|
+
import { mark } from "./term.js";
|
|
8
|
+
/** Piped: the house marks without color. */
|
|
9
|
+
const PLAIN = { color: false, unicode: true };
|
|
10
|
+
const SIGN_IN = "Run: passport login";
|
|
11
|
+
const NO_SIGN_IN = "No sign-in is saved on this computer.";
|
|
12
|
+
const NO_PROFILE = "No usable profile is configured.";
|
|
6
13
|
const DOCTOR_CREDENTIAL_MAX_BYTES = 1024 * 1024;
|
|
7
14
|
const DOCTOR_ACTIVE_PROFILE_MAX_BYTES = 512;
|
|
8
15
|
function check(checks, id, status, summary, action) {
|
|
@@ -25,9 +32,9 @@ function inspectStore(checks, agentMode) {
|
|
|
25
32
|
const missing = error.code === "ENOENT";
|
|
26
33
|
check(checks, "credential_store", agentMode && missing ? "skip" : "fail", missing
|
|
27
34
|
? agentMode
|
|
28
|
-
? "No local credential store is needed in agent-
|
|
29
|
-
:
|
|
30
|
-
: "The credential store could not be inspected.", missing && !agentMode ?
|
|
35
|
+
? "No local credential store is needed in agent-token mode."
|
|
36
|
+
: NO_SIGN_IN
|
|
37
|
+
: "The credential store could not be inspected.", missing && !agentMode ? SIGN_IN : undefined);
|
|
31
38
|
return { profiles: empty, count: 0 };
|
|
32
39
|
}
|
|
33
40
|
if (stat.isSymbolicLink() || !stat.isFile()) {
|
|
@@ -84,10 +91,10 @@ function inspectStore(checks, agentMode) {
|
|
|
84
91
|
}
|
|
85
92
|
const count = Object.keys(profiles).length;
|
|
86
93
|
if (invalid.length) {
|
|
87
|
-
check(checks, "credential_store", "fail", `The credential store
|
|
94
|
+
check(checks, "credential_store", "fail", `The credential store has ${countOf(invalid.length, "damaged profile")}.`, "Remove the damaged profile, or sign in again to replace it.\nRun: passport login");
|
|
88
95
|
}
|
|
89
96
|
else {
|
|
90
|
-
check(checks, "credential_store", "pass", `
|
|
97
|
+
check(checks, "credential_store", "pass", `Your saved sign-ins are readable: ${countOf(count, "profile")}.`);
|
|
91
98
|
}
|
|
92
99
|
return { profiles, count };
|
|
93
100
|
}
|
|
@@ -127,10 +134,10 @@ function inspectActiveProfile(checks, store) {
|
|
|
127
134
|
return undefined;
|
|
128
135
|
}
|
|
129
136
|
if (!store.profiles[active]) {
|
|
130
|
-
check(checks, "active_profile", "fail", `The active profile
|
|
137
|
+
check(checks, "active_profile", "fail", `The active profile, ${active}, isn't saved on this computer.`, "Run `passport profiles`, then `passport use <name>`.");
|
|
131
138
|
return undefined;
|
|
132
139
|
}
|
|
133
|
-
check(checks, "active_profile", "pass", `Active profile
|
|
140
|
+
check(checks, "active_profile", "pass", `Active profile: ${active}.`);
|
|
134
141
|
return active;
|
|
135
142
|
}
|
|
136
143
|
function errorText(error, redact) {
|
|
@@ -165,7 +172,7 @@ export async function runDoctor(options) {
|
|
|
165
172
|
const agentMode = hasAgentKey && hasAgentEndpoint;
|
|
166
173
|
const store = agentMode
|
|
167
174
|
? (() => {
|
|
168
|
-
check(checks, "credential_store", "skip", "Local profiles are not inspected in agent-
|
|
175
|
+
check(checks, "credential_store", "skip", "Local profiles are not inspected in agent-token mode.");
|
|
169
176
|
return { profiles: Object.create(null), count: 0 };
|
|
170
177
|
})()
|
|
171
178
|
: inspectStore(checks, false);
|
|
@@ -173,17 +180,17 @@ export async function runDoctor(options) {
|
|
|
173
180
|
let auth;
|
|
174
181
|
let selectedProfile;
|
|
175
182
|
if (hasAgentKey !== hasAgentEndpoint) {
|
|
176
|
-
check(checks, "auth_config", "fail", "Agent-
|
|
183
|
+
check(checks, "auth_config", "fail", "Agent-token configuration is incomplete.", "Set both PASSPORT_AGENT_KEY and PASSPORT_ENDPOINT, or unset both.");
|
|
177
184
|
}
|
|
178
185
|
else if (agentMode) {
|
|
179
186
|
if (options.profile !== undefined) {
|
|
180
|
-
check(checks, "auth_config", "fail", "--profile cannot be combined with agent-
|
|
187
|
+
check(checks, "auth_config", "fail", "--profile cannot be combined with agent-token environment authentication.", "Remove --profile or unset the agent-token variables.");
|
|
181
188
|
}
|
|
182
189
|
else {
|
|
183
190
|
try {
|
|
184
191
|
const normalized = options.normalizeEndpoint(options.env.PASSPORT_ENDPOINT);
|
|
185
192
|
auth = { kind: "agent-key", endpoint: normalized, agentKey: options.env.PASSPORT_AGENT_KEY };
|
|
186
|
-
check(checks, "auth_config", "pass", "
|
|
193
|
+
check(checks, "auth_config", "pass", "PASSPORT_AGENT_KEY and PASSPORT_ENDPOINT are both set.");
|
|
187
194
|
}
|
|
188
195
|
catch (error) {
|
|
189
196
|
check(checks, "auth_config", "fail", errorText(error, options.redactError), "Set PASSPORT_ENDPOINT to the HTTPS workspace MCP endpoint.");
|
|
@@ -194,24 +201,20 @@ export async function runDoctor(options) {
|
|
|
194
201
|
const names = Object.keys(store.profiles).sort();
|
|
195
202
|
const candidate = selectedProfileCandidate(options, store, active);
|
|
196
203
|
if (!candidate) {
|
|
197
|
-
check(checks, "auth_config", "fail", names.length > 1
|
|
198
|
-
? `No profile was selected from ${names.length} stored profiles.`
|
|
199
|
-
: "No usable profile is configured.", names.length > 1
|
|
200
|
-
? "Run `passport profiles`, then `passport use <name>` or retry with `--profile <name>`."
|
|
201
|
-
: "Run `passport login`, or `passport init` to set up step by step.");
|
|
204
|
+
check(checks, "auth_config", "fail", names.length > 1 ? `No profile was selected from ${names.length} stored profiles.` : NO_PROFILE, names.length > 1 ? "Pick one, or add --profile <name>.\nRun: passport use <name>" : SIGN_IN);
|
|
202
205
|
}
|
|
203
206
|
else {
|
|
204
207
|
try {
|
|
205
208
|
assertProfileName(candidate);
|
|
206
209
|
const saved = store.profiles[candidate];
|
|
207
210
|
if (!saved) {
|
|
208
|
-
check(checks, "auth_config", "fail", "The selected profile does not exist or is malformed.", "
|
|
211
|
+
check(checks, "auth_config", "fail", "The selected profile does not exist or is malformed.", "Pick another profile, or sign in again.\nRun: passport login");
|
|
209
212
|
}
|
|
210
213
|
else {
|
|
211
214
|
const normalized = options.normalizeEndpoint(saved.endpoint);
|
|
212
215
|
selectedProfile = candidate;
|
|
213
216
|
auth = { kind: "profile", endpoint: normalized, profile: candidate, refreshToken: saved.refreshToken };
|
|
214
|
-
check(checks, "auth_config", "pass", `Profile
|
|
217
|
+
check(checks, "auth_config", "pass", `Profile ${candidate} has a saved sign-in for ${new URL(normalized).host}.`);
|
|
215
218
|
}
|
|
216
219
|
}
|
|
217
220
|
catch (error) {
|
|
@@ -222,8 +225,8 @@ export async function runDoctor(options) {
|
|
|
222
225
|
let endpointOrigin;
|
|
223
226
|
let server;
|
|
224
227
|
if (!auth) {
|
|
225
|
-
check(checks, "server_reachability", "skip", "
|
|
226
|
-
check(checks, "server_protocol", "skip", "CLI
|
|
228
|
+
check(checks, "server_reachability", "skip", "Skipped the server checks: not signed in.");
|
|
229
|
+
check(checks, "server_protocol", "skip", "Skipped checking that this CLI and the server match.");
|
|
227
230
|
}
|
|
228
231
|
else {
|
|
229
232
|
endpointOrigin = new URL(auth.endpoint).origin;
|
|
@@ -252,12 +255,12 @@ export async function runDoctor(options) {
|
|
|
252
255
|
}
|
|
253
256
|
catch (error) {
|
|
254
257
|
check(checks, "authentication", "fail", `Authenticated MCP handshake failed: ${errorText(error, options.redactError)}`, auth.kind === "profile"
|
|
255
|
-
? "
|
|
256
|
-
: "
|
|
258
|
+
? "Sign in again, then try this once more.\nRun: passport login"
|
|
259
|
+
: "Check the agent token in PASSPORT_AGENT_KEY and its workspace access.");
|
|
257
260
|
check(checks, "server_protocol", "skip", "CLI protocol checks could not run because the authenticated handshake failed.");
|
|
258
261
|
}
|
|
259
262
|
if (gateway) {
|
|
260
|
-
check(checks, "authentication", "pass", `
|
|
263
|
+
check(checks, "authentication", "pass", `Passport accepted ${auth.kind === "profile" ? `the sign-in for ${auth.profile}` : "the agent token"}.`);
|
|
261
264
|
try {
|
|
262
265
|
const protocol = await gateway.protocolDiagnostics();
|
|
263
266
|
const safeServer = protocol.server
|
|
@@ -305,14 +308,30 @@ export async function runDoctor(options) {
|
|
|
305
308
|
checks
|
|
306
309
|
};
|
|
307
310
|
}
|
|
308
|
-
|
|
309
|
-
|
|
311
|
+
const MARK_OF = { pass: "done", warn: "warn", fail: "fail", skip: "skip" };
|
|
312
|
+
/** Nobody is signed in here: not a fault to fix, just the next step. */
|
|
313
|
+
export function signedOut(report) {
|
|
314
|
+
const failed = report.checks.filter((item) => item.status === "fail");
|
|
315
|
+
return (!report.ok &&
|
|
316
|
+
report.auth === "none" &&
|
|
317
|
+
report.profileCount === 0 &&
|
|
318
|
+
failed.every((item) => item.summary === NO_SIGN_IN || item.summary === NO_PROFILE));
|
|
319
|
+
}
|
|
320
|
+
export function formatDoctorReport(report, term = PLAIN) {
|
|
310
321
|
const lines = [`Passport doctor ${report.version}`];
|
|
322
|
+
const shown = new Set();
|
|
311
323
|
for (const item of report.checks) {
|
|
312
|
-
lines.push(`${
|
|
313
|
-
|
|
314
|
-
|
|
324
|
+
lines.push(`${mark(term, MARK_OF[item.status])} ${item.summary}`);
|
|
325
|
+
// Each fix once, under the first check it fixes.
|
|
326
|
+
if (item.action && !shown.has(item.action)) {
|
|
327
|
+
shown.add(item.action);
|
|
328
|
+
lines.push(...item.action.split("\n").map((line) => ` ${line}`));
|
|
329
|
+
}
|
|
315
330
|
}
|
|
316
|
-
lines.push(report.ok
|
|
331
|
+
lines.push(report.ok
|
|
332
|
+
? "Healthy: all required checks passed."
|
|
333
|
+
: signedOut(report)
|
|
334
|
+
? "Not signed in to Passport."
|
|
335
|
+
: "Needs attention: fix the failed checks above.");
|
|
317
336
|
return lines.join("\n");
|
|
318
337
|
}
|
package/dist/execNoKey.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `passport exec` with no key in Passport. Passport can't see this computer,
|
|
3
3
|
* so its answer says to add one in Apps; when this computer still has the
|
|
4
4
|
* CLI's own sign-in, the fix is one command here instead:
|
|
5
|
-
* "Run passport keys move railway". Read here only; nothing is sent.
|
|
5
|
+
* "Run: passport keys move railway". Read here only; nothing is sent.
|
|
6
6
|
*/
|
|
7
7
|
import { CliFailure, type Runtime } from "./cliSupport.js";
|
|
8
8
|
import { type ExecVendor } from "./execVendors.js";
|
package/dist/execNoKey.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `passport exec` with no key in Passport. Passport can't see this computer,
|
|
3
3
|
* so its answer says to add one in Apps; when this computer still has the
|
|
4
4
|
* CLI's own sign-in, the fix is one command here instead:
|
|
5
|
-
* "Run passport keys move railway". Read here only; nothing is sent.
|
|
5
|
+
* "Run: passport keys move railway". Read here only; nothing is sent.
|
|
6
6
|
*/
|
|
7
7
|
import { CliFailure } from "./cliSupport.js";
|
|
8
8
|
import { EXEC_VENDOR_NAMES } from "./execVendors.js";
|
|
@@ -13,7 +13,8 @@ export function keyHereFailure(error, vendor, runtime, home) {
|
|
|
13
13
|
if (!here)
|
|
14
14
|
return error;
|
|
15
15
|
const name = EXEC_VENDOR_NAMES[vendor];
|
|
16
|
-
return new CliFailure(`No ${name} key in Passport yet, but this computer has one
|
|
16
|
+
return new CliFailure(`No ${name} key in Passport yet, but this computer has one.`, 3, "no_key", {
|
|
17
|
+
hint: `Run: passport keys move ${vendor}`,
|
|
17
18
|
next: [
|
|
18
19
|
{ argv: ["passport", "keys", "move", vendor], description: `Move this computer's ${name} key into Passport.` }
|
|
19
20
|
]
|
package/dist/execShims.js
CHANGED
|
@@ -249,10 +249,10 @@ export function shimPathAdvice(shims, env, platform = process.platform) {
|
|
|
249
249
|
const home = env.HOME || homedir();
|
|
250
250
|
const line = pathLine(shimDir(), env, home, platform);
|
|
251
251
|
if (shims.some((shim) => shim.state === "not_on_path"))
|
|
252
|
-
return
|
|
252
|
+
return line;
|
|
253
253
|
const shadowed = shims.find((shim) => shim.state === "shadowed");
|
|
254
254
|
if (shadowed) {
|
|
255
|
-
return `Your PATH finds the ${EXEC_VENDOR_NAMES[shadowed.vendor]} CLI before Passport's folder. ${line}
|
|
255
|
+
return `Your PATH finds the ${EXEC_VENDOR_NAMES[shadowed.vendor]} CLI before Passport's folder. ${line}`;
|
|
256
256
|
}
|
|
257
257
|
return undefined;
|
|
258
258
|
}
|
package/dist/hookFastPath.js
CHANGED
|
@@ -221,13 +221,14 @@ export function environmentLines(plan, width) {
|
|
|
221
221
|
lines.push(...wrap(namesByApp(entries), width, ENV_LABEL[kind].padEnd(pad), " ".repeat(pad)));
|
|
222
222
|
}
|
|
223
223
|
if (unplaced.length) {
|
|
224
|
-
|
|
224
|
+
const pronoun = unplaced.length === 1 ? "it" : "them";
|
|
225
|
+
lines.push(...wrap(`Treated as Production until placed: ${namesByApp(unplaced)}. Change ${pronoun} in Rules.`, width));
|
|
225
226
|
}
|
|
226
227
|
for (const row of plan.project) {
|
|
227
228
|
const kind = ENV_LABEL[row.kind] ?? row.kind;
|
|
228
229
|
const note = row.assumed && !namedForItsKind(row.resource, row.kind) ? `${kind} until placed` : kind;
|
|
229
230
|
const how = row.how === "unreadable" ? `unreadable: ${row.note ?? ""}` : row.how;
|
|
230
|
-
lines.push(...wrap(`This folder: ${row.vendor} ${row.resource}
|
|
231
|
+
lines.push(...wrap(`This folder: ${row.vendor} ${row.resource} (${how}), counted as ${note}`, width));
|
|
231
232
|
}
|
|
232
233
|
return lines;
|
|
233
234
|
}
|
|
@@ -357,7 +358,7 @@ export async function applyAutopilot(s, plan, mode) {
|
|
|
357
358
|
changed = true;
|
|
358
359
|
s.summary.changed = true;
|
|
359
360
|
}
|
|
360
|
-
s.autopilotSummary = `Autopilot on
|
|
361
|
+
s.autopilotSummary = `Autopilot on: asks only for ${askedFor(presets)}`;
|
|
361
362
|
s.record("autopilot", changed ? "done" : "already_set_up", {
|
|
362
363
|
presets,
|
|
363
364
|
floors: view.floors
|
|
@@ -387,7 +388,7 @@ function allowlists(s, policy) {
|
|
|
387
388
|
}));
|
|
388
389
|
if (touched.length) {
|
|
389
390
|
s.allowlistsTouched = touched.map((change) => change.name);
|
|
390
|
-
s.screen.result("done", `Added your everyday commands to ${listOf(touched.map((change) => change.name))}
|
|
391
|
+
s.screen.result("done", `Added your everyday commands to the allowlists in ${listOf(touched.map((change) => change.name))}, so tests, builds, and commits run without a prompt.`, "Autopilot");
|
|
391
392
|
}
|
|
392
393
|
}
|
|
393
394
|
catch {
|
package/dist/initInstall.js
CHANGED
|
@@ -509,11 +509,12 @@ export function isOtherPassportInstall(path, version) {
|
|
|
509
509
|
/** One line a person can paste to put `passport` on PATH. Printed, never run. */
|
|
510
510
|
export function pathLine(binDir, env, home, platform) {
|
|
511
511
|
if (platform === "win32")
|
|
512
|
-
return `Add ${binDir} to your PATH to run
|
|
512
|
+
return `Add ${binDir} to your PATH to run Passport from any terminal.`;
|
|
513
513
|
const shown = binDir === home || binDir.startsWith(`${home}/`) ? `$HOME${binDir.slice(home.length)}` : binDir;
|
|
514
514
|
const shell = basename(env.SHELL ?? "");
|
|
515
515
|
if (shell === "fish")
|
|
516
|
-
return
|
|
516
|
+
return `${PATH_LEAD}: fish_add_path ${shown.replace("$HOME", "~")}`;
|
|
517
517
|
const rc = shell === "bash" ? (platform === "darwin" ? "~/.bash_profile" : "~/.bashrc") : "~/.zshrc";
|
|
518
|
-
return
|
|
518
|
+
return `${PATH_LEAD}: echo 'export PATH="${shown}:$PATH"' >> ${rc}`;
|
|
519
519
|
}
|
|
520
|
+
const PATH_LEAD = "Add Passport's folder to your PATH, then open a new terminal";
|
package/dist/initKeysStep.js
CHANGED
|
@@ -35,7 +35,7 @@ export async function detectKeys(s) {
|
|
|
35
35
|
}
|
|
36
36
|
const plan = {
|
|
37
37
|
local,
|
|
38
|
-
names: [...new Set(local.map((key) => EXEC_VENDOR_NAMES[key.vendor]))],
|
|
38
|
+
names: [...new Set(local.map((key) => EXEC_VENDOR_NAMES[key.vendor]))].sort((a, b) => a.localeCompare(b)),
|
|
39
39
|
support: "ok",
|
|
40
40
|
envFiles
|
|
41
41
|
};
|
package/dist/initLocalSteps.d.ts
CHANGED
|
@@ -64,7 +64,8 @@ export type SafetyPlan = {
|
|
|
64
64
|
};
|
|
65
65
|
export declare function detectSafety(s: InitSession): Promise<SafetyPlan>;
|
|
66
66
|
export declare function applySafety(s: InitSession, plan: SafetyPlan, mode: "apply" | "ask" | "skip"): Promise<void>;
|
|
67
|
-
/** "
|
|
67
|
+
/** "Deletes in Stripe and GitHub ask first (set by your workspace)". Irreversible
|
|
68
|
+
* actions always ask, so the class word a person sees here is Delete. */
|
|
68
69
|
export declare function safetyLine(plan: Extract<SafetyPlan, {
|
|
69
70
|
kind: "ok";
|
|
70
71
|
}>): string;
|
package/dist/initLocalSteps.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `passport init`, the steps that change this computer and the member's
|
|
3
3
|
* settings: add Passport to each agent, turn on the hook guard, and (on an
|
|
4
|
-
* older server without Autopilot) make
|
|
4
|
+
* older server without Autopilot) make deletes ask first. Each
|
|
5
5
|
* has a `detect…` that reads what's there for the plan, and an `apply…` that
|
|
6
6
|
* changes it once the person agreed.
|
|
7
7
|
*/
|
|
@@ -203,7 +203,9 @@ export async function applyAgents(s, plan, mode) {
|
|
|
203
203
|
}
|
|
204
204
|
/** Claude Desktop's custom connector: copy its URL, never print a key. */
|
|
205
205
|
export function desktopLine(copied) {
|
|
206
|
-
return
|
|
206
|
+
return copied
|
|
207
|
+
? "Claude Desktop: paste the copied URL in Settings → Connectors → Add custom connector"
|
|
208
|
+
: "Claude Desktop: paste the URL in Settings → Connectors → Add custom connector";
|
|
207
209
|
}
|
|
208
210
|
/** Put Claude Desktop's connector URL on the clipboard. Returns whether it did. */
|
|
209
211
|
export function copyDesktopUrl(s, plan) {
|
|
@@ -325,7 +327,7 @@ async function guardSetup(s, plan, mode) {
|
|
|
325
327
|
return;
|
|
326
328
|
}
|
|
327
329
|
// Copying the CLI holds the event loop for a second or two: say so first.
|
|
328
|
-
s.screen.working("Installing a stable copy of
|
|
330
|
+
s.screen.working("Installing a stable copy of Passport for the hooks…", "Guard", true);
|
|
329
331
|
let stable;
|
|
330
332
|
try {
|
|
331
333
|
stable = (s.deps.install ?? ensureStableCommand)(installContext(s));
|
|
@@ -401,7 +403,7 @@ export async function applySafety(s, plan, mode) {
|
|
|
401
403
|
if (profile === "off") {
|
|
402
404
|
// Off may be a choice the person made on the web, so it changes only on a yes.
|
|
403
405
|
const yes = mode === "apply" ||
|
|
404
|
-
(mode === "ask" && (await s.screen.confirm(`Ask before
|
|
406
|
+
(mode === "ask" && (await s.screen.confirm(`Ask before deletes ${plan.where}?`, s.signal, "Rules")));
|
|
405
407
|
if (!yes) {
|
|
406
408
|
if (mode === "ask")
|
|
407
409
|
s.screen.result("skip", "Left off. Turn it on any time in Rules.", "Rules");
|
|
@@ -424,7 +426,7 @@ export async function applySafety(s, plan, mode) {
|
|
|
424
426
|
floor = state.floor === "ask" || state.floor === "block" ? state.floor : undefined;
|
|
425
427
|
changed = true;
|
|
426
428
|
s.summary.changed = true;
|
|
427
|
-
s.screen.result("done", `
|
|
429
|
+
s.screen.result("done", `Deletes ${plan.where} ${profile === "block" ? "are blocked" : "ask first"}`, "Rules");
|
|
428
430
|
}
|
|
429
431
|
s.record("safety", changed ? "done" : "already_set_up", { profile, ...(floor ? { floor } : {}) });
|
|
430
432
|
// The hook guard reads a local copy of these rules; bring it up to date.
|
|
@@ -433,10 +435,11 @@ export async function applySafety(s, plan, mode) {
|
|
|
433
435
|
api: (path, init) => s.api(path, init)
|
|
434
436
|
});
|
|
435
437
|
}
|
|
436
|
-
/** "
|
|
438
|
+
/** "Deletes in Stripe and GitHub ask first (set by your workspace)". Irreversible
|
|
439
|
+
* actions always ask, so the class word a person sees here is Delete. */
|
|
437
440
|
export function safetyLine(plan) {
|
|
438
441
|
const verb = plan.profile === "block" ? "are blocked" : "ask first";
|
|
439
442
|
const suffix = plan.floor && plan.floor === plan.profile ? " (set by your workspace)" : "";
|
|
440
|
-
return `
|
|
443
|
+
return `Deletes ${plan.where} ${verb}${suffix}`;
|
|
441
444
|
}
|
|
442
445
|
export { coveredByPlugin };
|
package/dist/initOutro.d.ts
CHANGED
|
@@ -4,7 +4,5 @@ import { type InitSession, type Summary } from "./initState.js";
|
|
|
4
4
|
export declare function rotateOldKeysLine(summary: Pick<Summary, "steps">): string | undefined;
|
|
5
5
|
/** A ✓ list of what's true now, what's left for the person, and one next command. */
|
|
6
6
|
export declare function outro(s: InitSession): void;
|
|
7
|
-
/**
|
|
8
|
-
* never broken. Too narrow for the `echo … >> ~/.zshrc` form, it names the
|
|
9
|
-
* file and the shorter line to add to it. */
|
|
7
|
+
/** What to do next about PATH: the step, then the command on its own line. */
|
|
10
8
|
export declare function pathNext(line: string, width: number): string[];
|