passport-bridge 0.8.0 → 0.8.1
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 +28 -6
- package/dist/cliArgs.js +2 -0
- package/dist/cliDescribe.js +18 -0
- package/dist/cliOffline.js +45 -24
- package/dist/cliOutput.js +2 -0
- package/dist/cliReady.js +56 -0
- package/dist/cliSupport.js +40 -9
- package/dist/completion.js +1 -0
- package/dist/credentials.js +21 -0
- package/dist/passport.js +9 -5
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,12 @@ passport status
|
|
|
36
36
|
|
|
37
37
|
For Passport Cloud, `passport login --workspace <id>` can omit `--cloud`.
|
|
38
38
|
Self-hosted deployments pass their origin explicitly. Add `--no-open` to print
|
|
39
|
-
the device URL without launching a browser.
|
|
39
|
+
the device URL without launching a browser. This is the required form for SSH,
|
|
40
|
+
CI, and other headless sessions:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
passport login --workspace ws_example --profile cli@ws_example --no-open
|
|
44
|
+
```
|
|
40
45
|
|
|
41
46
|
`passport help [command]` documents every option. `passport help` and `passport version` work without a profile or network connection.
|
|
42
47
|
|
|
@@ -44,7 +49,7 @@ Remote Passport servers must use HTTPS. Plain HTTP is accepted only for local
|
|
|
44
49
|
development on `localhost`, `127.0.0.0/8`, or `::1`. Self-hosted deployments
|
|
45
50
|
should terminate HTTPS before using interactive profiles or agent keys.
|
|
46
51
|
|
|
47
|
-
Passport CLI 0.8.
|
|
52
|
+
Passport CLI 0.8.1 requires gateway MCP serverInfo `passport` version 0.5.0 or
|
|
48
53
|
newer and the exact four-tool governed CLI protocol. Older servers fail clearly
|
|
49
54
|
before the CLI makes a tool call.
|
|
50
55
|
|
|
@@ -56,8 +61,9 @@ before the CLI makes a tool call.
|
|
|
56
61
|
| `logout` | Revoke the credential and remove its local profile. |
|
|
57
62
|
| `status` | Show the workspace, member, client, and visible MCP connection states. |
|
|
58
63
|
| `doctor` | Check runtime, credential-store safety, configuration, reachability, authentication, and CLI protocol compatibility. |
|
|
64
|
+
| `ready` | Report whether the local CLI is ready for the requested operation. |
|
|
59
65
|
| `search [query]` | Search permitted tool definitions. An empty query lists the complete catalog. |
|
|
60
|
-
| `describe <tool>` | Print one exact definition and its full parameter schema.
|
|
66
|
+
| `describe <tool>` | Print one exact definition and its full parameter schema. JSON also exposes `name` and `inputSchema` aliases. |
|
|
61
67
|
| `run <tool> [json]` | Run a tool through Passport governance. |
|
|
62
68
|
| `connect [app...]` | Show secure member connection links and optionally wait for completion. |
|
|
63
69
|
| `resources [uri]` | List or read MCP resources. |
|
|
@@ -68,7 +74,7 @@ before the CLI makes a tool call.
|
|
|
68
74
|
| `profiles` | List stored profiles and show the active profile without a network request. |
|
|
69
75
|
| `use <name>` | Select the active stored profile without a network request. |
|
|
70
76
|
| `help [command]` | Show general or command-specific help. |
|
|
71
|
-
| `version` | Show the package version and locally resolvable profile context.
|
|
77
|
+
| `version` | Show the package version and locally resolvable profile context. `--json` includes readiness fields. |
|
|
72
78
|
|
|
73
79
|
Every command accepts `--profile <name>`, `--json`, `--timeout <seconds>`, `--quiet`, and `--caller <id>` where applicable.
|
|
74
80
|
|
|
@@ -88,6 +94,13 @@ passport doctor --profile cli@ws_example
|
|
|
88
94
|
passport doctor --profile cli@ws_example --json
|
|
89
95
|
```
|
|
90
96
|
|
|
97
|
+
`passport version --json` works without a profile or network and returns
|
|
98
|
+
`version`, `profileCount`, `profileSelected`, `selectionSource`, `next`, and
|
|
99
|
+
optional endpoint/profile fields. `passport ready --json` runs the local,
|
|
100
|
+
authentication, server, and exact CLI-protocol preflight and returns `ready`,
|
|
101
|
+
`ok`, auth/profile context, `server`, and `checks`; use its `ready` value and
|
|
102
|
+
exit code as the automation gate rather than parsing human output.
|
|
103
|
+
|
|
91
104
|
When profile selection is unclear, start with `passport profiles` and choose
|
|
92
105
|
one with `passport use <name>`. Use `--profile <name>` for a one-off command or
|
|
93
106
|
`PASSPORT_PROFILE=<name>` for a shell scope; explicit selectors take precedence
|
|
@@ -211,8 +224,9 @@ With `--json`, stdout contains exactly one JSON value and no progress text. Hint
|
|
|
211
224
|
| `logout` | `{profile, removed, revoked}` |
|
|
212
225
|
| `status` | `{workspace, member, endpoint, auth, profile?, client, mcps, next?}` |
|
|
213
226
|
| `doctor` | `{version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}` (also emitted when checks fail). |
|
|
227
|
+
| `ready` | `{ready,version,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}` |
|
|
214
228
|
| `search` | The gateway search payload, including `results` or `catalog` and `note`. |
|
|
215
|
-
| `describe` | One tool definition.
|
|
229
|
+
| `describe` | One tool definition; JSON keeps `tool`/`parameters` and adds `name`/`inputSchema` compatibility aliases. |
|
|
216
230
|
| `run` | The complete governed MCP tool result, preserving every content block and upstream `structuredContent`. |
|
|
217
231
|
| `connect` | The gateway connection payload, including `connections` and optional `connectAllUrl`. |
|
|
218
232
|
| `resources` | The MCP list or read result. |
|
|
@@ -221,7 +235,7 @@ With `--json`, stdout contains exactly one JSON value and no progress text. Hint
|
|
|
221
235
|
| `session` | NDJSON envelopes: `{id?,ok,exitCode,result?}` or `{id?,ok:false,error,cause,exitCode,...}`. |
|
|
222
236
|
| `completion` | `{shell,script}`. Human mode emits the raw completion script. |
|
|
223
237
|
| `help` | `{command, help}` |
|
|
224
|
-
| `version` | `{version,
|
|
238
|
+
| `version` | `{version,profileCount,profileSelected,selectionSource,next,requiredInput?,endpoint?,profile?}` |
|
|
225
239
|
|
|
226
240
|
JSON errors have a stable base shape and may add safe remediation fields such
|
|
227
241
|
as `hint`, `profiles`, `next` (`argv` plus a description), `remediation`,
|
|
@@ -257,6 +271,12 @@ credential store is shared with `passport-bridge` and refresh exchanges are
|
|
|
257
271
|
coordinated across processes. The active-profile pointer contains no
|
|
258
272
|
credential and is local to this Passport credential store.
|
|
259
273
|
|
|
274
|
+
When no explicit, environment, or active selector is present, CLI 0.8.1
|
|
275
|
+
detects exactly one CLI-owned profile (`client: "cli"` or the exact legacy
|
|
276
|
+
`cli@<workspace>` shape) and makes that existing profile active. If more than
|
|
277
|
+
one CLI candidate remains, run `passport profiles`, choose with `passport use <name>`,
|
|
278
|
+
or pass an explicit `--profile`; Passport refuses to guess.
|
|
279
|
+
|
|
260
280
|
Profile names are 1-80 letters, numbers, dots, underscores, `@` signs, or hyphens, and must start with a letter or number. Credential updates are atomically replaced at mode `0600`, including when several profiles rotate concurrently.
|
|
261
281
|
|
|
262
282
|
`logout` always removes the local slot. If Passport cannot be reached to confirm server-side revocation, it prints a warning so the user knows the remote credential could not be revoked.
|
|
@@ -287,6 +307,8 @@ Supply an existing Passport agent key from the job's secret manager:
|
|
|
287
307
|
export PASSPORT_ENDPOINT=https://passport.example.com/mcp
|
|
288
308
|
export PASSPORT_AGENT_KEY="$CI_PASSPORT_AGENT_KEY"
|
|
289
309
|
passport search "deployment status" --json
|
|
310
|
+
passport version --json
|
|
311
|
+
passport ready --json
|
|
290
312
|
```
|
|
291
313
|
|
|
292
314
|
Environment authentication wins over stored profiles, persists nothing, and sends the agent key directly to the gateway. Do not combine it with `--profile`. `PASSPORT_PROFILE` is only for stored interactive credentials.
|
package/dist/cliArgs.js
CHANGED
|
@@ -5,6 +5,7 @@ export const COMMANDS = [
|
|
|
5
5
|
"use",
|
|
6
6
|
"status",
|
|
7
7
|
"doctor",
|
|
8
|
+
"ready",
|
|
8
9
|
"search",
|
|
9
10
|
"describe",
|
|
10
11
|
"run",
|
|
@@ -130,6 +131,7 @@ function validateShape(command, positionals) {
|
|
|
130
131
|
use: 1,
|
|
131
132
|
status: 0,
|
|
132
133
|
doctor: 0,
|
|
134
|
+
ready: 0,
|
|
133
135
|
describe: 1,
|
|
134
136
|
run: 2,
|
|
135
137
|
resources: 1,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize a search result for the CLI's describe contract.
|
|
3
|
+
*
|
|
4
|
+
* `tool` and `parameters` are the original Passport fields. `name` and
|
|
5
|
+
* `inputSchema` are compatibility aliases for clients that consume the
|
|
6
|
+
* conventional MCP vocabulary. Keep all server-provided fields intact.
|
|
7
|
+
*/
|
|
8
|
+
export function describedToolPayload(exact, fallbackName) {
|
|
9
|
+
const tool = typeof exact.tool === "string" && exact.tool ? exact.tool : fallbackName;
|
|
10
|
+
const parameters = exact.parameters ?? {};
|
|
11
|
+
return {
|
|
12
|
+
...exact,
|
|
13
|
+
tool,
|
|
14
|
+
parameters,
|
|
15
|
+
name: tool,
|
|
16
|
+
inputSchema: parameters
|
|
17
|
+
};
|
|
18
|
+
}
|
package/dist/cliOffline.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { value } from "./cliArgs.js";
|
|
2
2
|
import { completionScript } from "./completion.js";
|
|
3
|
-
import { readActiveProfile, readCreds, setActiveProfile } from "./credentials.js";
|
|
4
|
-
import { endpoint, failure, profileName } from "./cliSupport.js";
|
|
3
|
+
import { inferredProfileClient, readActiveProfile, readCreds, setActiveProfile } from "./credentials.js";
|
|
4
|
+
import { endpoint, failure, profileName, selectStoredProfile } from "./cliSupport.js";
|
|
5
5
|
import { VERSION } from "./version.js";
|
|
6
6
|
export function completionResult(args) {
|
|
7
7
|
const shell = args.positionals[0];
|
|
@@ -14,28 +14,29 @@ export function completionResult(args) {
|
|
|
14
14
|
export function profilesResult(_args) {
|
|
15
15
|
const creds = readCreds();
|
|
16
16
|
const names = Object.keys(creds).sort();
|
|
17
|
+
const selection = selectStoredProfile(_args, {}, creds, true);
|
|
17
18
|
const selected = readActiveProfile();
|
|
18
19
|
const active = selected && creds[selected] ? selected : undefined;
|
|
19
20
|
const profiles = names.map((name) => ({
|
|
20
21
|
name,
|
|
21
22
|
active: name === active,
|
|
22
|
-
...(creds[name]
|
|
23
|
+
...(inferredProfileClient(name, creds[name]) ? { client: inferredProfileClient(name, creds[name]) } : {})
|
|
23
24
|
}));
|
|
24
25
|
if (!profiles.length) {
|
|
25
26
|
return {
|
|
26
|
-
json: { profiles: [] },
|
|
27
|
+
json: { profiles: [], selectionSource: selection.source },
|
|
27
28
|
human: "No Passport profiles saved.\nRun: passport login --workspace <workspace-id>.",
|
|
28
29
|
essential: true
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
const lines = [
|
|
32
33
|
"Passport profiles:",
|
|
33
|
-
...profiles.map((profile) => ` ${profile.active ? "*" : " "} ${profile.name}${profile.active ? " (active)" : ""}`),
|
|
34
|
+
...profiles.map((profile) => ` ${profile.active ? "*" : " "} ${profile.name}${profile.active ? " (active)" : ""}${profile.client ? ` [${profile.client}]` : ""}`),
|
|
34
35
|
"",
|
|
35
36
|
"Use `passport use <name>` to select a profile."
|
|
36
37
|
];
|
|
37
38
|
return {
|
|
38
|
-
json: { profiles, ...(active ? { active } : {}) },
|
|
39
|
+
json: { profiles, ...(active ? { active } : {}), selectionSource: selection.source },
|
|
39
40
|
human: lines.join("\n"),
|
|
40
41
|
essential: true
|
|
41
42
|
};
|
|
@@ -79,31 +80,46 @@ export function useProfileResult(args, env) {
|
|
|
79
80
|
export function versionResult(args, env) {
|
|
80
81
|
let profile;
|
|
81
82
|
let resolvedEndpoint;
|
|
82
|
-
|
|
83
|
+
const agentMode = Boolean(env.PASSPORT_AGENT_KEY && env.PASSPORT_ENDPOINT);
|
|
84
|
+
if (agentMode && value(args, "profile") !== undefined) {
|
|
83
85
|
return failure("--profile cannot be used with PASSPORT_AGENT_KEY.", 6, "usage");
|
|
84
86
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
const creds = readCreds();
|
|
88
|
+
const profileCount = Object.keys(creds).length;
|
|
89
|
+
const selection = agentMode
|
|
90
|
+
? { profile: undefined, source: "none", names: Object.keys(creds).sort(), cliCandidates: [] }
|
|
91
|
+
: selectStoredProfile(args, env, creds, true);
|
|
92
|
+
if (agentMode) {
|
|
93
|
+
resolvedEndpoint = endpoint(env.PASSPORT_ENDPOINT ?? "");
|
|
87
94
|
}
|
|
88
95
|
else {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const candidate = explicitProfile !== undefined
|
|
93
|
-
? profileName(explicitProfile)
|
|
94
|
-
: env.PASSPORT_PROFILE
|
|
95
|
-
? profileName(env.PASSPORT_PROFILE)
|
|
96
|
-
: (() => {
|
|
97
|
-
const active = readActiveProfile();
|
|
98
|
-
return active && creds[active] ? profileName(active) : names.length === 1 ? profileName(names[0]) : "";
|
|
99
|
-
})();
|
|
100
|
-
if (candidate && creds[candidate]) {
|
|
101
|
-
profile = candidate;
|
|
102
|
-
resolvedEndpoint = endpoint(creds[candidate].endpoint);
|
|
96
|
+
if (selection.profile && creds[selection.profile]) {
|
|
97
|
+
profile = selection.profile;
|
|
98
|
+
resolvedEndpoint = endpoint(creds[profile].endpoint);
|
|
103
99
|
}
|
|
104
100
|
}
|
|
101
|
+
const selected = profile ?? null;
|
|
102
|
+
const next = agentMode
|
|
103
|
+
? [{ argv: ["passport", "status"], description: "Check the agent-key connection and visible connections." }]
|
|
104
|
+
: profile
|
|
105
|
+
? [{ argv: ["passport", "status"], description: "Check the selected profile and visible connections." }]
|
|
106
|
+
: profileCount > 1
|
|
107
|
+
? [
|
|
108
|
+
{ argv: ["passport", "profiles"], description: "List saved profiles." },
|
|
109
|
+
...Object.keys(creds)
|
|
110
|
+
.sort()
|
|
111
|
+
.map((name) => ({ argv: ["passport", "use", name], description: `Select the saved profile "${name}".` }))
|
|
112
|
+
]
|
|
113
|
+
: profileCount === 1
|
|
114
|
+
? [{ argv: ["passport", "status"], description: "Use the saved profile and check visible connections." }]
|
|
115
|
+
: [{ argv: ["passport", "help", "login"], description: "Show the required inputs for first login." }];
|
|
105
116
|
const data = {
|
|
106
117
|
version: VERSION,
|
|
118
|
+
profileCount,
|
|
119
|
+
profileSelected: selected,
|
|
120
|
+
selectionSource: agentMode ? "agent-key" : selection.source,
|
|
121
|
+
next,
|
|
122
|
+
...(profileCount === 0 && !agentMode ? { requiredInput: ["workspace-id"] } : {}),
|
|
107
123
|
...(resolvedEndpoint ? { endpoint: resolvedEndpoint } : {}),
|
|
108
124
|
...(profile ? { profile } : {})
|
|
109
125
|
};
|
|
@@ -111,8 +127,13 @@ export function versionResult(args, env) {
|
|
|
111
127
|
json: data,
|
|
112
128
|
human: [
|
|
113
129
|
`passport ${VERSION}`,
|
|
130
|
+
`Profiles: ${profileCount}`,
|
|
114
131
|
...(resolvedEndpoint ? [`Endpoint: ${resolvedEndpoint}`] : []),
|
|
115
|
-
...(
|
|
132
|
+
...(agentMode
|
|
133
|
+
? ["Authentication: agent-key", "Next: passport status"]
|
|
134
|
+
: profile
|
|
135
|
+
? [`Profile: ${profile} (${selection.source})`, "Next: passport status"]
|
|
136
|
+
: ["No profile selected.", ...next.slice(0, 1).map((action) => `Next: ${action.argv.join(" ")}`)])
|
|
116
137
|
].join("\n"),
|
|
117
138
|
essential: true
|
|
118
139
|
};
|
package/dist/cliOutput.js
CHANGED
|
@@ -10,6 +10,7 @@ function helpText(verb) {
|
|
|
10
10
|
use: "passport use <name>\nSelects a saved profile as the default for subsequent commands. Works offline.",
|
|
11
11
|
status: "passport status\nJSON: {workspace,member,endpoint,auth,profile?,client,mcps:[{app,name,status,toolCount}]}",
|
|
12
12
|
doctor: "passport doctor [--profile <name>]\nChecks Node, credential-store safety, endpoint security, server health, authentication, serverInfo, and the exact CLI protocol. JSON includes {ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}.",
|
|
13
|
+
ready: "passport ready [--profile <name>]\nRuns the local, authentication, server, and exact CLI-protocol preflight. JSON includes {ready,ok,auth,profile?,profileCount,endpointOrigin?,server?,checks}.",
|
|
13
14
|
search: "passport search [query...] [--app <key>]\nEmpty query lists the complete permitted catalog. JSON is the server search payload.",
|
|
14
15
|
describe: "passport describe <tool>\nShows the exact tool definition and complete parameter schema.",
|
|
15
16
|
run: "passport run <tool> [json-object]\n --args - read the JSON object from stdin\n --set key=value set a string argument (repeatable)\n --set-json key=<json> set a typed argument (repeatable)\n --wait <sec> retry only a definite approval_pending call\nJSON is the complete MCP tool result; human stdout is verbatim tool text.",
|
|
@@ -34,6 +35,7 @@ Usage: passport <command> [options]
|
|
|
34
35
|
use Select a saved profile for subsequent commands
|
|
35
36
|
status Show identity and visible MCP connection state
|
|
36
37
|
doctor Diagnose local setup and server compatibility
|
|
38
|
+
ready Check whether this CLI is ready to use
|
|
37
39
|
search Find permitted tools or list the catalog
|
|
38
40
|
describe Show one exact tool definition
|
|
39
41
|
run Run a governed tool
|
package/dist/cliReady.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { value } from "./cliArgs.js";
|
|
2
|
+
import { callerFrom, endpoint, resolveCliAuth, sanitize, timeoutMs } from "./cliSupport.js";
|
|
3
|
+
import { formatDoctorReport, runDoctor } from "./doctor.js";
|
|
4
|
+
import { VERSION } from "./version.js";
|
|
5
|
+
/**
|
|
6
|
+
* Run the same local, auth, server, and protocol checks as doctor, with a
|
|
7
|
+
* machine-friendly `ready` field for agents and CI preflight scripts.
|
|
8
|
+
*/
|
|
9
|
+
export async function ready(args, runtime) {
|
|
10
|
+
// resolveCliAuth owns profile selection and legacy migration. Resolve once
|
|
11
|
+
// before doctor so a deterministic CLI profile can become active for the
|
|
12
|
+
// checks below. Doctor remains the source of truth for the surfaced report;
|
|
13
|
+
// failures here are intentionally left for doctor to explain precisely.
|
|
14
|
+
try {
|
|
15
|
+
resolveCliAuth(args, runtime.env);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// Doctor reports incomplete, ambiguous, or malformed authentication with
|
|
19
|
+
// safe checks and exact remediation. Do not mask that report here.
|
|
20
|
+
}
|
|
21
|
+
const report = await runDoctor({
|
|
22
|
+
version: VERSION,
|
|
23
|
+
profile: value(args, "profile"),
|
|
24
|
+
env: runtime.env,
|
|
25
|
+
timeoutMs: timeoutMs(args),
|
|
26
|
+
signal: runtime.signal,
|
|
27
|
+
caller: callerFrom(args, runtime.env),
|
|
28
|
+
normalizeEndpoint: endpoint,
|
|
29
|
+
redactError: sanitize
|
|
30
|
+
});
|
|
31
|
+
const json = {
|
|
32
|
+
ready: report.ok,
|
|
33
|
+
version: report.version,
|
|
34
|
+
ok: report.ok,
|
|
35
|
+
auth: report.auth,
|
|
36
|
+
...(report.profile ? { profile: report.profile } : {}),
|
|
37
|
+
profileCount: report.profileCount,
|
|
38
|
+
...(report.endpointOrigin ? { endpointOrigin: report.endpointOrigin } : {}),
|
|
39
|
+
...(report.server ? { server: report.server } : {}),
|
|
40
|
+
checks: report.checks
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
json,
|
|
44
|
+
human: formatReadyReport(report),
|
|
45
|
+
essential: true,
|
|
46
|
+
exitCode: report.ok ? 0 : 1
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function formatReadyReport(report) {
|
|
50
|
+
const lines = formatDoctorReport(report).split("\n");
|
|
51
|
+
lines[0] = `Passport ready ${report.version}`;
|
|
52
|
+
lines[lines.length - 1] = report.ok
|
|
53
|
+
? "Ready: all required checks passed."
|
|
54
|
+
: "Not ready: fix the failed checks above.";
|
|
55
|
+
return lines.join("\n");
|
|
56
|
+
}
|
package/dist/cliSupport.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { value } from "./cliArgs.js";
|
|
3
|
-
import { assertProfileName, readActiveProfile, readCreds } from "./credentials.js";
|
|
3
|
+
import { assertProfileName, isCliProfile, readActiveProfile, readCreds, setActiveProfile } from "./credentials.js";
|
|
4
4
|
import { readBoundedJson } from "./boundedResponse.js";
|
|
5
5
|
export { readBoundedJson } from "./boundedResponse.js";
|
|
6
6
|
export const DEFAULT_TIMEOUT_MS = 30_000;
|
|
@@ -59,6 +59,42 @@ export function cloudOrigin(raw) {
|
|
|
59
59
|
}
|
|
60
60
|
return parsed.origin;
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Resolve a local profile without ever guessing between workspaces. Explicit
|
|
64
|
+
* CLI and environment selectors win over the active pointer. In the absence
|
|
65
|
+
* of those selectors, exactly one CLI-owned profile is deterministic enough
|
|
66
|
+
* to migrate to the active pointer; otherwise only the historical sole
|
|
67
|
+
* profile fallback is retained.
|
|
68
|
+
*/
|
|
69
|
+
export function selectStoredProfile(args, env, creds = readCreds(), persistDetected = false) {
|
|
70
|
+
const names = Object.keys(creds).sort();
|
|
71
|
+
const explicit = args ? value(args, "profile") : undefined;
|
|
72
|
+
if (explicit !== undefined) {
|
|
73
|
+
return { profile: profileName(explicit), source: "explicit", names, cliCandidates: [] };
|
|
74
|
+
}
|
|
75
|
+
if (env.PASSPORT_PROFILE) {
|
|
76
|
+
return { profile: profileName(env.PASSPORT_PROFILE), source: "environment", names, cliCandidates: [] };
|
|
77
|
+
}
|
|
78
|
+
const active = readActiveProfile();
|
|
79
|
+
if (active && creds[active]) {
|
|
80
|
+
return { profile: active, source: "active", names, cliCandidates: [] };
|
|
81
|
+
}
|
|
82
|
+
const cliCandidates = names.filter((name) => isCliProfile(name, creds[name]));
|
|
83
|
+
if (cliCandidates.length === 1) {
|
|
84
|
+
const profile = cliCandidates[0];
|
|
85
|
+
if (persistDetected)
|
|
86
|
+
setActiveProfile(profile);
|
|
87
|
+
return { profile, source: "detected-client", names, cliCandidates };
|
|
88
|
+
}
|
|
89
|
+
if (names.length === 1) {
|
|
90
|
+
return { profile: names[0], source: "sole-profile", names, cliCandidates };
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
source: names.length > 1 ? "ambiguous" : "none",
|
|
94
|
+
names,
|
|
95
|
+
cliCandidates
|
|
96
|
+
};
|
|
97
|
+
}
|
|
62
98
|
export function sameOriginWebUrl(raw, trustedOrigin, label) {
|
|
63
99
|
const normalized = endpoint(raw);
|
|
64
100
|
if (new URL(normalized).origin !== trustedOrigin) {
|
|
@@ -82,14 +118,9 @@ export function resolveCliAuth(args, env) {
|
|
|
82
118
|
return { kind: "agent-key", endpoint: endpoint(agentEndpoint), agentKey };
|
|
83
119
|
}
|
|
84
120
|
const creds = readCreds();
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
// profile is next, followed by the historical single-profile fallback. We
|
|
89
|
-
// only honor the active pointer when it still names a stored profile; a
|
|
90
|
-
// stale pointer must never make us guess a different workspace.
|
|
91
|
-
const fallbackProfile = env.PASSPORT_PROFILE || (active && creds[active] ? active : names.length === 1 ? names[0] : "");
|
|
92
|
-
const profile = explicitProfile !== undefined ? profileName(explicitProfile) : fallbackProfile ? profileName(fallbackProfile) : "";
|
|
121
|
+
const selection = selectStoredProfile(args, env, creds, true);
|
|
122
|
+
const names = selection.names;
|
|
123
|
+
const profile = selection.profile ?? "";
|
|
93
124
|
if (!profile) {
|
|
94
125
|
const suffix = names.length ? ` Available profiles: ${names.join(", ")}.` : "";
|
|
95
126
|
const hint = names.length
|
package/dist/completion.js
CHANGED
|
@@ -6,6 +6,7 @@ const DESCRIPTIONS = {
|
|
|
6
6
|
use: "Select a saved profile for subsequent commands",
|
|
7
7
|
status: "Show identity and MCP connection state",
|
|
8
8
|
doctor: "Diagnose local configuration and server compatibility",
|
|
9
|
+
ready: "Check whether this CLI is ready to use",
|
|
9
10
|
search: "Find permitted tools",
|
|
10
11
|
describe: "Show one exact tool definition",
|
|
11
12
|
run: "Run a governed tool",
|
package/dist/credentials.js
CHANGED
|
@@ -2,6 +2,27 @@ import { closeSync, constants, fchmodSync, fstatSync, lstatSync, openSync, readF
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { credentialDir, enforceOwner, ensurePrivateDirectory, isMissing, syncDirectory, withCredentialStoreWriteLock as withStoreWriteLock, withProfileLock as withProfileLockInternal, writePrivateAtomic } from "./credentialStorage.js";
|
|
4
4
|
import { activeProfilePath, clearActiveProfileAtomic, prepareActiveProfileForSelection, readActiveProfile as readActiveProfileFile, readActiveProfileDocument, writeActiveProfileAtomic } from "./activeProfile.js";
|
|
5
|
+
/**
|
|
6
|
+
* Legacy bridge versions did not persist the client on every profile. Only
|
|
7
|
+
* infer values for the small set of profile prefixes Passport itself has
|
|
8
|
+
* historically issued; arbitrary `name@workspace` values are intentionally
|
|
9
|
+
* left unknown so they cannot affect profile selection.
|
|
10
|
+
*/
|
|
11
|
+
const LEGACY_PROFILE_CLIENTS = new Set(["cli", "claude", "codex", "cursor", "gemini", "opencode"]);
|
|
12
|
+
export function inferredProfileClient(name, profile) {
|
|
13
|
+
if (profile.client)
|
|
14
|
+
return profile.client;
|
|
15
|
+
const separator = name.indexOf("@");
|
|
16
|
+
if (separator <= 0)
|
|
17
|
+
return undefined;
|
|
18
|
+
const prefix = name.slice(0, separator).toLowerCase();
|
|
19
|
+
return LEGACY_PROFILE_CLIENTS.has(prefix) ? prefix : undefined;
|
|
20
|
+
}
|
|
21
|
+
/** A deterministic CLI-owned profile is either explicitly tagged or has the
|
|
22
|
+
* exact legacy `cli@<workspace>` shape. */
|
|
23
|
+
export function isCliProfile(name, profile) {
|
|
24
|
+
return profile.client === "cli" || (!profile.client && name.startsWith("cli@"));
|
|
25
|
+
}
|
|
5
26
|
const PROFILE_NAME = /^[A-Za-z0-9][A-Za-z0-9._@-]{0,79}$/;
|
|
6
27
|
const UNSAFE_PROFILE_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
7
28
|
const MAX_CREDENTIAL_BYTES = 1024 * 1024;
|
package/dist/passport.js
CHANGED
|
@@ -7,6 +7,7 @@ import { VERSION } from "./version.js";
|
|
|
7
7
|
import { login } from "./cliLogin.js";
|
|
8
8
|
import { asFailure, emitFailure, emitResult, helpResult } from "./cliOutput.js";
|
|
9
9
|
import { completionResult, profilesResult, useProfileResult, versionResult } from "./cliOffline.js";
|
|
10
|
+
import { describedToolPayload } from "./cliDescribe.js";
|
|
10
11
|
import { connect, managePayload } from "./cliConnect.js";
|
|
11
12
|
import { firstText, hasNonText, payloadOf, refusalOf, requireSuccess } from "./cliResult.js";
|
|
12
13
|
import { callerFrom, endpoint, failure, firstSentence, readBoundedJson, resolveCliAuth, safeApiError, sanitize, sleep, timedFetch, timeoutMs } from "./cliSupport.js";
|
|
@@ -239,15 +240,16 @@ async function describe(args, runtime) {
|
|
|
239
240
|
]
|
|
240
241
|
});
|
|
241
242
|
}
|
|
242
|
-
const
|
|
243
|
+
const described = describedToolPayload(exact, name);
|
|
244
|
+
const schema = described.parameters ?? {};
|
|
243
245
|
const human = [
|
|
244
|
-
String(
|
|
245
|
-
`${
|
|
246
|
-
String(
|
|
246
|
+
String(described.tool),
|
|
247
|
+
`${described.readonly ? "Read-only" : "Write-capable"}`,
|
|
248
|
+
String(described.description ?? ""),
|
|
247
249
|
"Parameters:",
|
|
248
250
|
JSON.stringify(schema, null, 2)
|
|
249
251
|
].join("\n");
|
|
250
|
-
return { json:
|
|
252
|
+
return { json: described, human };
|
|
251
253
|
});
|
|
252
254
|
}
|
|
253
255
|
async function run(args, runtime) {
|
|
@@ -493,6 +495,8 @@ async function dispatch(args, runtime) {
|
|
|
493
495
|
return status(args, runtime);
|
|
494
496
|
case "doctor":
|
|
495
497
|
return doctor(args, runtime);
|
|
498
|
+
case "ready":
|
|
499
|
+
return (await import("./cliReady.js")).ready(args, runtime);
|
|
496
500
|
case "search":
|
|
497
501
|
return search(args, runtime);
|
|
498
502
|
case "describe":
|
package/dist/version.js
CHANGED
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passport-bridge",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "passport-bridge",
|
|
9
|
-
"version": "0.8.
|
|
9
|
+
"version": "0.8.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.30.0"
|