passport-bridge 0.8.2 → 0.10.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.
Files changed (65) hide show
  1. package/README.md +100 -3
  2. package/dist/accessClient.d.ts +128 -0
  3. package/dist/accessClient.js +436 -0
  4. package/dist/activeProfile.d.ts +21 -0
  5. package/dist/boundedFile.d.ts +2 -0
  6. package/dist/boundedMcpFetch.d.ts +6 -0
  7. package/dist/boundedResponse.d.ts +4 -0
  8. package/dist/bridge.d.ts +98 -0
  9. package/dist/bridge.js +49 -42
  10. package/dist/bridgeConfig.d.ts +1 -0
  11. package/dist/bridgePoller.d.ts +34 -0
  12. package/dist/bridgePoller.js +123 -0
  13. package/dist/bridgeShutdown.d.ts +20 -0
  14. package/dist/bridgeShutdown.js +5 -1
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +4 -0
  17. package/dist/cliAccess.d.ts +3 -0
  18. package/dist/cliAccess.js +119 -0
  19. package/dist/cliArgs.d.ts +16 -0
  20. package/dist/cliArgs.js +14 -3
  21. package/dist/cliClient.d.ts +62 -0
  22. package/dist/cliConnect.d.ts +22 -0
  23. package/dist/cliDeadline.d.ts +9 -0
  24. package/dist/cliDescribe.d.ts +8 -0
  25. package/dist/cliLogin.d.ts +3 -0
  26. package/dist/cliOffline.d.ts +6 -0
  27. package/dist/cliOutput.d.ts +7 -0
  28. package/dist/cliOutput.js +4 -0
  29. package/dist/cliPagination.d.ts +15 -0
  30. package/dist/cliProtocol.d.ts +4 -0
  31. package/dist/cliReady.d.ts +9 -0
  32. package/dist/cliResult.d.ts +7 -0
  33. package/dist/cliSession.d.ts +20 -0
  34. package/dist/cliSetup.d.ts +10 -0
  35. package/dist/cliSetup.js +157 -0
  36. package/dist/cliSupport.d.ts +102 -0
  37. package/dist/completion.d.ts +2 -0
  38. package/dist/completion.js +20 -2
  39. package/dist/credentialStorage.d.ts +12 -0
  40. package/dist/credentials.d.ts +64 -0
  41. package/dist/discover.d.ts +52 -0
  42. package/dist/doctor.d.ts +34 -0
  43. package/dist/index.d.ts +2 -0
  44. package/dist/index.js +1 -0
  45. package/dist/legacyCliSecurity.d.ts +10 -0
  46. package/dist/managedSkills.d.ts +7 -0
  47. package/dist/managedSkills.js +268 -0
  48. package/dist/managedSkillsContract.generated.d.ts +82 -0
  49. package/dist/managedSkillsContract.generated.js +32 -0
  50. package/dist/managedSkillsFiles.d.ts +23 -0
  51. package/dist/managedSkillsFiles.js +215 -0
  52. package/dist/managedSkillsIpc.d.ts +5 -0
  53. package/dist/managedSkillsIpc.js +44 -0
  54. package/dist/managedSkillsValidation.d.ts +14 -0
  55. package/dist/managedSkillsValidation.js +118 -0
  56. package/dist/passport.d.ts +7 -0
  57. package/dist/passport.js +4 -0
  58. package/dist/privateStableFile.d.ts +13 -0
  59. package/dist/recoveryCleanup.d.ts +5 -0
  60. package/dist/recoveryIdentity.d.ts +22 -0
  61. package/dist/tokenWorkspace.d.ts +3 -0
  62. package/dist/version.d.ts +1 -0
  63. package/dist/version.js +1 -1
  64. package/npm-shrinkwrap.json +2 -2
  65. package/package.json +13 -2
@@ -0,0 +1,8 @@
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 declare function describedToolPayload(exact: Record<string, unknown>, fallbackName: string): Record<string, unknown>;
@@ -0,0 +1,3 @@
1
+ import { type ParsedArgs } from "./cliArgs.js";
2
+ import { type CommandResult, type Runtime } from "./cliSupport.js";
3
+ export declare function login(args: ParsedArgs, runtime: Runtime): Promise<CommandResult>;
@@ -0,0 +1,6 @@
1
+ import { type ParsedArgs } from "./cliArgs.js";
2
+ import { type CommandResult, type Env } from "./cliSupport.js";
3
+ export declare function completionResult(args: ParsedArgs): CommandResult;
4
+ export declare function profilesResult(_args: ParsedArgs): CommandResult;
5
+ export declare function useProfileResult(args: ParsedArgs, env: Env): CommandResult;
6
+ export declare function versionResult(args: ParsedArgs, env: Env): CommandResult;
@@ -0,0 +1,7 @@
1
+ import { type ParsedArgs } from "./cliArgs.js";
2
+ import { CliFailure, type CommandResult, type Runtime } from "./cliSupport.js";
3
+ export declare function helpResult(args: ParsedArgs): CommandResult;
4
+ export declare function emitResult(result: CommandResult, args: ParsedArgs, runtime: Runtime): void;
5
+ export declare function asFailure(error: unknown): CliFailure;
6
+ export declare function emitFailure(error: CliFailure, json: boolean, quiet: boolean, runtime: Runtime): void;
7
+ export declare function failurePayload(error: CliFailure): Record<string, unknown>;
package/dist/cliOutput.js CHANGED
@@ -18,7 +18,9 @@ function helpText(verb) {
18
18
  resources: "passport resources [uri] [--out <file>]\nLists or reads workspace MCP resources. Binary content requires --out or --json.",
19
19
  prompts: "passport prompts [name] [--set key=value] [--out <file>]\nLists or gets workspace MCP prompts. Binary content requires --out or --json.",
20
20
  discover: "passport discover\nScans supported local MCP configuration, submits privacy-minimized inventory, and exits 5 when a managed policy reports a violation.",
21
+ setup: "passport setup list\npassport setup installed\npassport setup install <setup-id> <workflow-key> --client <codex|claude-code> [--apply]\npassport setup remove <skill-name> [--apply]\npassport setup rollback <skill-name> [--apply]\nLists assigned workflows and safely manages their local skill files. Changes are previewed unless --apply is supplied. Personal edits are preserved. Installed inventory, removal, and rollback work offline.",
21
22
  session: 'passport session\nReads newline-delimited {"id"?:string|number,"argv":string[]} requests from stdin and emits one JSON response per line. Reuses one authenticated MCP session. Supported request commands: status, search, describe, run, connect, resources, prompts, discover.',
23
+ access: "passport access <keygen|actions|run|invoke|status|cancel>\nkeygen writes a new owner-only private key and separate public JWK. Other commands use PASSPORT_ENDPOINT, PASSPORT_CLIENT_ID, and PASSPORT_PRIVATE_KEY_FILE.\n access actions [--delegation-id <id>]\n access run --input <json-file>\n access invoke --input <json-file> --caller <stable-id>\n access status <invocation-id>\n access cancel <run-id>",
22
24
  completion: "passport completion <bash|zsh|fish>\nPrints an offline shell-completion script to stdout.",
23
25
  help: "passport help [verb]",
24
26
  version: "passport version\nWorks without a profile or network."
@@ -43,7 +45,9 @@ Usage: passport <command> [options]
43
45
  resources List or read MCP resources
44
46
  prompts List or get MCP prompts
45
47
  discover Scan this computer for direct MCP configuration
48
+ setup Install and maintain assigned team workflows
46
49
  session Reuse one authenticated MCP session for NDJSON commands
50
+ access Use the signed managed access gateway
47
51
  completion Generate bash, zsh, or fish completion
48
52
  help Show command help
49
53
  version Show CLI version and local context
@@ -0,0 +1,15 @@
1
+ export type CliPaginationLimits = {
2
+ maxPages: number;
3
+ maxItems: number;
4
+ maxSerializedBytes: number;
5
+ maxCursorBytes: number;
6
+ };
7
+ export declare const DEFAULT_CLI_PAGINATION_LIMITS: Readonly<CliPaginationLimits>;
8
+ /** Aggregate the MCP pages a one-shot CLI command prints while bounding every
9
+ * attacker/provider-controlled dimension. Cursor cycles fail closed. */
10
+ export declare function collectCliPages<TItem, TPage extends {
11
+ nextCursor?: string;
12
+ }>(kind: "resource" | "prompt", load: (cursor: string | undefined) => Promise<TPage>, itemsFrom: (page: TPage) => readonly TItem[], limits?: CliPaginationLimits): Promise<{
13
+ last: TPage;
14
+ items: TItem[];
15
+ }>;
@@ -0,0 +1,4 @@
1
+ /** Dependency-free protocol messages shared by the CLI entrypoint and MCP
2
+ * client. Keeping this separate lets `passport version` run directly from an
3
+ * extracted tarball without loading the MCP SDK or touching the network. */
4
+ export declare const SERVER_TOO_OLD = "This Passport server is too old for the CLI. Ask your admin to deploy the CLI-compatible server release first.";
@@ -0,0 +1,9 @@
1
+ import { type ParsedArgs } from "./cliArgs.js";
2
+ import { type CommandResult, type Runtime } from "./cliSupport.js";
3
+ import { type DoctorReport } from "./doctor.js";
4
+ /**
5
+ * Run the same local, auth, server, and protocol checks as doctor, with a
6
+ * machine-friendly `ready` field for agents and CI preflight scripts.
7
+ */
8
+ export declare function ready(args: ParsedArgs, runtime: Runtime): Promise<CommandResult>;
9
+ export declare function formatReadyReport(report: DoctorReport): string;
@@ -0,0 +1,7 @@
1
+ import type { ToolCall } from "./cliClient.js";
2
+ import { CliFailure } from "./cliSupport.js";
3
+ export declare function firstText(result: ToolCall): string;
4
+ export declare function hasNonText(result: ToolCall): boolean;
5
+ export declare function payloadOf(result: ToolCall, label: string): Record<string, unknown>;
6
+ export declare function refusalOf(result: ToolCall): CliFailure | undefined;
7
+ export declare function requireSuccess(result: ToolCall): ToolCall;
@@ -0,0 +1,20 @@
1
+ import { type ParsedArgs } from "./cliArgs.js";
2
+ import { CliFailure, type CommandResult, type Runtime } from "./cliSupport.js";
3
+ export declare const CLI_SESSION_LINE_MAX_BYTES: number;
4
+ export declare const CLI_SESSION_ARGV_MAX_ITEMS = 128;
5
+ export type SessionRequest = {
6
+ id?: string | number;
7
+ argv: string[];
8
+ };
9
+ /**
10
+ * Split an async byte stream into bounded UTF-8 lines. The limit applies before
11
+ * decoding, so a caller cannot grow an unbounded string while omitting `\n`.
12
+ */
13
+ export declare function readBoundedSessionLines(input: AsyncIterable<string | Uint8Array>, signal: AbortSignal, maxBytes?: number): AsyncGenerator<string>;
14
+ export declare function parseSessionRequest(line: string): SessionRequest | undefined;
15
+ export declare function writeCliSessionFailure(runtime: Runtime, error: CliFailure): Promise<void>;
16
+ /** Keep one token manager and MCP client alive while processing sequential
17
+ * NDJSON requests. Authorization and policy still run at the gateway for every
18
+ * operation; only local process, token-exchange, initialization, and protocol
19
+ * assertion overhead is shared. */
20
+ export declare function runCliSession(args: ParsedArgs, runtime: Runtime, dispatch: (args: ParsedArgs, runtime: Runtime) => Promise<CommandResult>): Promise<CommandResult>;
@@ -0,0 +1,10 @@
1
+ import { type ParsedArgs } from "./cliArgs.js";
2
+ import type { GatewayRunner } from "./cliConnect.js";
3
+ import { type ManagedWorkflowManifest, type ManagedSkillsRequest, type ManagedSkillsResult } from "./managedSkillsContract.generated.js";
4
+ import { type CommandResult, type Runtime } from "./cliSupport.js";
5
+ type Installer = (input: ManagedSkillsRequest) => ManagedSkillsResult;
6
+ export declare function validateSetupManifest(value: unknown): ManagedWorkflowManifest;
7
+ /** Profile-bound discovery and installation; local removal/rollback remain
8
+ * available after a person loses access to the original workspace. */
9
+ export declare function setup(args: ParsedArgs, runtime: Runtime, withGateway: GatewayRunner, install?: Installer): Promise<CommandResult>;
10
+ export {};
@@ -0,0 +1,157 @@
1
+ import { bool, value } from "./cliArgs.js";
2
+ import { runManagedSkills } from "./managedSkills.js";
3
+ import { managedSkillFromManifest } from "./managedSkillsContract.generated.js";
4
+ import { identifier, object, validatePackage, validateSource } from "./managedSkillsValidation.js";
5
+ import { workspaceOfToken } from "./tokenWorkspace.js";
6
+ import { failure, readBoundedJson, sanitize } from "./cliSupport.js";
7
+ const envelope = { protocol: "passport.managed-skills", version: 1 };
8
+ function installerResult(result) {
9
+ return { json: result, human: result.message, exitCode: result.ok ? 0 : result.state === "conflict" ? 5 : 1 };
10
+ }
11
+ export function validateSetupManifest(value) {
12
+ const manifest = object(value);
13
+ const workflow = object(manifest.workflow);
14
+ if (manifest.schemaVersion !== 1 ||
15
+ !Array.isArray(manifest.skills) ||
16
+ manifest.skills.length > 32 ||
17
+ !Array.isArray(manifest.dependencies) ||
18
+ manifest.dependencies.length > 64 ||
19
+ ![workflow.key, workflow.name, workflow.description, workflow.instructions].every((part) => typeof part === "string")) {
20
+ return failure("Passport returned an invalid workflow manifest.", 1, "invalid_manifest");
21
+ }
22
+ for (const raw of manifest.skills) {
23
+ const skill = object(raw);
24
+ if (![skill.key, skill.name, skill.description, skill.instructions].every((part) => typeof part === "string")) {
25
+ return failure("Passport returned invalid workflow guidance.", 1, "invalid_manifest");
26
+ }
27
+ }
28
+ for (const raw of manifest.dependencies) {
29
+ const dependency = object(raw);
30
+ if (![dependency.label, dependency.kind, dependency.ref].every((part) => typeof part === "string")) {
31
+ return failure("Passport returned invalid workflow dependencies.", 1, "invalid_manifest");
32
+ }
33
+ }
34
+ return manifest;
35
+ }
36
+ function previewOrApply(request, apply, install) {
37
+ const checked = install({ ...request, operation: "status", expectedState: undefined });
38
+ if (!checked.ok || !checked.status)
39
+ return installerResult(checked);
40
+ if (checked.status.state === "modified") {
41
+ return failure("This workflow changed locally. Passport preserved it; restore or move your edit before updating.", 5, "local_conflict");
42
+ }
43
+ if (!apply) {
44
+ return {
45
+ json: { preview: true, operation: request.operation, status: checked.status, name: request.package?.name },
46
+ human: [
47
+ `${request.package?.name ?? checked.status.skillName} · ${checked.status.source.client}`,
48
+ `Current state: ${checked.status.state}`,
49
+ ...(request.package ? [`Published version: ${request.package.revisionVersion}`] : []),
50
+ `Planned action: ${request.operation}. Re-run with --apply to make this local change.`
51
+ ].join("\n")
52
+ };
53
+ }
54
+ return installerResult(install({ ...request, expectedState: checked.status.reviewToken }));
55
+ }
56
+ /** Profile-bound discovery and installation; local removal/rollback remain
57
+ * available after a person loses access to the original workspace. */
58
+ export async function setup(args, runtime, withGateway, install = runManagedSkills) {
59
+ const [action = "list", first, second] = args.positionals;
60
+ const apply = bool(args, "apply");
61
+ if (!["list", "installed", "install", "remove", "rollback"].includes(action)) {
62
+ return failure("Use setup list, installed, install, remove, or rollback.", 6, "usage");
63
+ }
64
+ if ((["list", "installed"].includes(action) && (first || apply || value(args, "client"))) ||
65
+ (action === "install" && (!first || !second)) ||
66
+ (["remove", "rollback"].includes(action) && (!first || second || value(args, "client")))) {
67
+ return failure("Invalid setup arguments. Run: passport help setup", 6, "usage");
68
+ }
69
+ if (["installed", "remove", "rollback"].includes(action)) {
70
+ const inventory = install({ ...envelope, operation: "list" });
71
+ if (!inventory.ok)
72
+ return installerResult(inventory);
73
+ if (action === "installed")
74
+ return {
75
+ json: { items: inventory.items ?? [] },
76
+ human: inventory.items?.length
77
+ ? inventory.items
78
+ .map((item) => `${item.skillName} · ${item.source.client} · ${item.state} · version ${item.installedVersion ?? "none"}`)
79
+ .join("\n")
80
+ : "No managed workflows installed. Run: passport setup list"
81
+ };
82
+ const chosen = inventory.items?.find((item) => item.skillName === first);
83
+ if (!chosen)
84
+ return failure("That managed workflow is not in the local inventory. Run: passport setup installed", 6, "usage");
85
+ return previewOrApply({ ...envelope, operation: action === "remove" ? "uninstall" : "rollback", source: chosen.source }, apply, install);
86
+ }
87
+ if (action === "install") {
88
+ identifier(first);
89
+ identifier(second);
90
+ if (!["codex", "claude-code"].includes(value(args, "client") ?? "")) {
91
+ return failure("Choose --client codex or --client claude-code.", 6, "usage");
92
+ }
93
+ }
94
+ return withGateway(args, runtime, async (gateway, auth) => {
95
+ if (auth.kind !== "profile")
96
+ return failure("Employee setups require a signed-in member profile.", 2, "member_profile_required");
97
+ const path = action === "list"
98
+ ? "/api/my/ai-setups"
99
+ : `/api/my/ai-setups/${encodeURIComponent(first)}/workflows/${encodeURIComponent(second)}/manifest?client=${encodeURIComponent(value(args, "client"))}`;
100
+ const response = await gateway.fetchApi(path, { signal: runtime.signal, redirect: "error" });
101
+ if (!response.ok) {
102
+ await response.body?.cancel().catch(() => undefined);
103
+ if (response.status === 404)
104
+ return failure("This setup is unavailable, or the gateway needs an update. Refresh your assigned setups in Passport.", 1, "setup_unavailable");
105
+ return failure("Passport could not authorize this employee setup. Reconnect or check your assignment.", response.status === 401 || response.status === 403 ? 2 : 1, "setup_unavailable");
106
+ }
107
+ const data = object(await readBoundedJson(response, 1024 * 1024));
108
+ if (action === "list") {
109
+ if (!Array.isArray(data.setups) || data.setups.length > 100)
110
+ return failure("Passport returned invalid assigned setups.", 1, "invalid_manifest");
111
+ const setups = data.setups.map((raw) => {
112
+ const row = object(raw);
113
+ const profile = object(row.profile);
114
+ if (!Array.isArray(row.workflows) || row.workflows.length > 100)
115
+ return failure("Passport returned invalid setup workflows.", 1, "invalid_manifest");
116
+ return {
117
+ id: identifier(profile.id),
118
+ name: sanitize(String(profile.name ?? "Team setup")),
119
+ version: profile.version,
120
+ workflows: row.workflows.map((rawWorkflow) => {
121
+ const workflow = object(rawWorkflow);
122
+ return {
123
+ key: identifier(workflow.key),
124
+ name: sanitize(String(workflow.name ?? "Workflow")),
125
+ status: sanitize(String(workflow.status ?? "unavailable"))
126
+ };
127
+ })
128
+ };
129
+ });
130
+ return {
131
+ json: { setups },
132
+ human: setups.length
133
+ ? setups
134
+ .flatMap((entry) => [
135
+ `${entry.name} (${entry.id})`,
136
+ ...entry.workflows.map((workflow) => ` ${workflow.key} · ${workflow.name} · ${workflow.status}`),
137
+ `Install: passport setup install ${entry.id} <workflow-key> --client <codex|claude-code> --apply`
138
+ ])
139
+ .join("\n")
140
+ : "No team setups are assigned yet. Ask your workspace admin to publish a setup for your team."
141
+ };
142
+ }
143
+ const manifest = validateSetupManifest(data.manifest);
144
+ const boundWorkspace = workspaceOfToken(auth.refreshToken);
145
+ if (!boundWorkspace ||
146
+ manifest.workspaceId !== boundWorkspace ||
147
+ manifest.profileId !== first ||
148
+ manifest.workflow.key !== second ||
149
+ manifest.clientKey !== value(args, "client")) {
150
+ return failure("The returned workflow does not match this workspace, client, and setup.", 1, "invalid_manifest");
151
+ }
152
+ const packageInfo = managedSkillFromManifest(manifest, gateway.origin);
153
+ const source = validateSource(packageInfo.source);
154
+ const artifact = validatePackage(packageInfo.package);
155
+ return previewOrApply({ ...envelope, operation: "install", source, package: artifact }, apply, install);
156
+ });
157
+ }
@@ -0,0 +1,102 @@
1
+ import { type ChildProcess } from "node:child_process";
2
+ import { type ParsedArgs } from "./cliArgs.js";
3
+ import type { CliAuth, CliGateway } from "./cliClient.js";
4
+ import { type Profile } from "./credentials.js";
5
+ export { readBoundedJson } from "./boundedResponse.js";
6
+ export declare const DEFAULT_TIMEOUT_MS = 30000;
7
+ export type Env = NodeJS.ProcessEnv;
8
+ export type Runtime = {
9
+ env: Env;
10
+ stdin?: AsyncIterable<string | Uint8Array>;
11
+ stdout: Pick<NodeJS.WriteStream, "write">;
12
+ stderr: Pick<NodeJS.WriteStream, "write">;
13
+ signal: AbortSignal;
14
+ sharedGateway?: {
15
+ gateway: CliGateway;
16
+ auth: CliAuth;
17
+ };
18
+ };
19
+ export type CliNextAction = {
20
+ argv: string[];
21
+ description: string;
22
+ };
23
+ export type CliRemediation = {
24
+ action: string;
25
+ description: string;
26
+ };
27
+ export type CliRetry = {
28
+ command: "run";
29
+ tool: string;
30
+ waitSeconds: number;
31
+ arguments: "none" | "reuse_original";
32
+ };
33
+ export type ProfileSelectionSource = "explicit" | "environment" | "active" | "detected-client" | "sole-profile" | "ambiguous" | "none";
34
+ export type StoredProfileSelection = {
35
+ profile?: string;
36
+ source: ProfileSelectionSource;
37
+ names: string[];
38
+ /** Profiles that are safe candidates for the current CLI surface. */
39
+ cliCandidates: string[];
40
+ };
41
+ export type CommandResult = {
42
+ json: unknown;
43
+ human?: string | Buffer;
44
+ essential?: boolean;
45
+ raw?: boolean;
46
+ exitCode?: number;
47
+ };
48
+ export declare class CliFailure extends Error {
49
+ readonly exitCode: number;
50
+ readonly cause: string;
51
+ readonly details: {
52
+ approvalId?: string;
53
+ app?: string;
54
+ connectUrl?: string;
55
+ hint?: string;
56
+ profiles?: string[];
57
+ next?: CliNextAction[];
58
+ remediation?: CliRemediation;
59
+ retry?: CliRetry;
60
+ requiredInput?: string[];
61
+ };
62
+ constructor(message: string, exitCode: number, cause: string, details?: {
63
+ approvalId?: string;
64
+ app?: string;
65
+ connectUrl?: string;
66
+ hint?: string;
67
+ profiles?: string[];
68
+ next?: CliNextAction[];
69
+ remediation?: CliRemediation;
70
+ retry?: CliRetry;
71
+ requiredInput?: string[];
72
+ });
73
+ }
74
+ export declare function failure(message: string, exitCode: number, cause: string, details?: CliFailure["details"]): never;
75
+ export declare function timeoutMs(args: ParsedArgs): number;
76
+ export declare function profileName(raw: string): string;
77
+ export declare function endpoint(raw: string): string;
78
+ export declare function cloudOrigin(raw: string): string;
79
+ /**
80
+ * Resolve a local profile without ever guessing between workspaces. Explicit
81
+ * CLI and environment selectors win over the active pointer. In the absence
82
+ * of those selectors, exactly one CLI-owned profile is deterministic enough
83
+ * to migrate to the active pointer; otherwise only the historical sole
84
+ * profile fallback is retained.
85
+ */
86
+ export declare function selectStoredProfile(args: ParsedArgs | undefined, env: Env, creds?: Record<string, Profile>, persistDetected?: boolean): StoredProfileSelection;
87
+ export declare function sameOriginWebUrl(raw: string, trustedOrigin: string, label: string): string;
88
+ export declare function resolveCliAuth(args: ParsedArgs, env: Env): CliAuth;
89
+ export declare function callerFrom(args: ParsedArgs, env: Env): string | undefined;
90
+ export declare function sanitize(message: string): string;
91
+ export declare function timedFetch(input: string | URL, init: RequestInit, ms: number, parent: AbortSignal): Promise<Response>;
92
+ export declare function safeApiError(response: Response, fallback: string): Promise<string>;
93
+ export declare function sleep(ms: number, signal: AbortSignal): Promise<void>;
94
+ type UrlLauncher = (command: string, args: string[], options: {
95
+ stdio: "ignore";
96
+ detached: true;
97
+ shell: false;
98
+ }) => Pick<ChildProcess, "on" | "unref">;
99
+ /** Open only a validated web URL. A provider-controlled query string must stay
100
+ * one opaque process argument and never cross a command-shell boundary. */
101
+ export declare function openUrl(url: string, platform?: NodeJS.Platform, launch?: UrlLauncher): boolean;
102
+ export declare function firstSentence(value: string): string;
@@ -0,0 +1,2 @@
1
+ export type CompletionShell = "bash" | "zsh" | "fish";
2
+ export declare function completionScript(shell: CompletionShell): string;
@@ -15,6 +15,8 @@ const DESCRIPTIONS = {
15
15
  prompts: "List or get MCP prompts",
16
16
  discover: "Scan local MCP configuration for fleet governance",
17
17
  session: "Reuse one authenticated session for NDJSON commands",
18
+ access: "Use the signed managed access gateway",
19
+ setup: "Install and maintain your assigned AI workflows",
18
20
  completion: "Generate shell completion",
19
21
  help: "Show command help",
20
22
  version: "Show CLI version and local context"
@@ -26,7 +28,17 @@ const COMMAND_FLAGS = {
26
28
  run: ["--args", "--set", "--set-json", "--wait"],
27
29
  connect: ["--alias", "--open", "--wait"],
28
30
  resources: ["--out"],
29
- prompts: ["--set", "--out"]
31
+ prompts: ["--set", "--out"],
32
+ setup: ["--client", "--apply"],
33
+ access: [
34
+ "--workspace",
35
+ "--client-id",
36
+ "--private-key-file",
37
+ "--public-jwk-file",
38
+ "--algorithm",
39
+ "--input",
40
+ "--delegation-id"
41
+ ]
30
42
  };
31
43
  const VALUE_FLAGS = new Set([
32
44
  "--profile",
@@ -41,7 +53,13 @@ const VALUE_FLAGS = new Set([
41
53
  "--set-json",
42
54
  "--wait",
43
55
  "--alias",
44
- "--out"
56
+ "--out",
57
+ "--input",
58
+ "--algorithm",
59
+ "--private-key-file",
60
+ "--public-jwk-file",
61
+ "--delegation-id",
62
+ "--client-id"
45
63
  ]);
46
64
  function flagsFor(command) {
47
65
  return [...GLOBAL, ...(command ? (COMMAND_FLAGS[command] ?? []) : [])];
@@ -0,0 +1,12 @@
1
+ import { type Stats } from "node:fs";
2
+ export declare function credentialDir(): string;
3
+ export declare function isMissing(error: unknown): boolean;
4
+ export declare function enforceOwner(stat: Stats, label: string): void;
5
+ /** Create or repair the owner-only credential directory without following a
6
+ * symlink at the security boundary. */
7
+ export declare function ensurePrivateDirectory(create: boolean): boolean;
8
+ /** The JSON document and the active-profile pointer share this lock. */
9
+ export declare function withCredentialStoreWriteLock<T>(fn: () => T): T;
10
+ export declare function syncDirectory(): void;
11
+ export declare function writePrivateAtomic(target: string, temporaryPrefix: string, contents: string, label: string): void;
12
+ export declare function withProfileLock<T>(name: string, fn: () => Promise<T>): Promise<T>;
@@ -0,0 +1,64 @@
1
+ import { activeProfilePath } from "./activeProfile.js";
2
+ /**
3
+ * Local credential store for the bridge: ~/.passport/credentials.json.
4
+ * PASSPORT_HOME overrides the directory for tests and sandboxes.
5
+ */
6
+ export type Profile = {
7
+ refreshToken: string;
8
+ endpoint: string;
9
+ instanceId?: string;
10
+ /** Stable AI-client and route identity used when an expired bridge profile is recovered in place. */
11
+ client?: string;
12
+ target?: string;
13
+ };
14
+ type Creds = Record<string, Profile>;
15
+ export declare function inferredProfileClient(name: string, profile: Profile): string | undefined;
16
+ /** A deterministic CLI-owned profile is either explicitly tagged or has the
17
+ * exact legacy `cli@<workspace>` shape. */
18
+ export declare function isCliProfile(name: string, profile: Profile): boolean;
19
+ /** Profile names become both JSON keys and lock-file names. */
20
+ export declare function assertProfileName(name: string): void;
21
+ export declare function profileRotationJournalPath(name: string): string;
22
+ /** Best-effort reads preserve the historical offline UX. Mutations use the
23
+ * strict reader below and never turn corruption into an empty store. */
24
+ export declare function readCreds(): Creds;
25
+ export declare function getProfile(name: string): Profile | undefined;
26
+ /** Security-sensitive flows use the strict view before minting or rotating a
27
+ * credential. Corruption and unreadable paths must fail before a remote token
28
+ * is changed, not after it becomes impossible to persist. */
29
+ export declare function getProfileStrict(name: string): Profile | undefined;
30
+ export declare function assertCredentialStoreMutationReady(): void;
31
+ /** Persist a minted refresh-token child before acknowledging its access token.
32
+ * The journal is fsynced first, so a failed credential replace or killed process
33
+ * can recover the child without replaying its now-stale parent. */
34
+ export declare function persistProfileRotation(name: string, previousRefreshToken: string, next: Profile): void;
35
+ /** Persist a rotating child against the endpoint currently stored for this
36
+ * profile. Interactive recovery may have replaced that endpoint after the
37
+ * TokenManager was constructed, so a captured startup endpoint is only a
38
+ * fallback and must never overwrite newer durable state. */
39
+ export declare function persistCurrentProfileRotation(name: string, previousRefreshToken: string, nextRefreshToken: string, fallbackEndpoint: string): void;
40
+ /** Complete an interrupted profile rotation while the caller owns its profile
41
+ * lock. Conflicting state fails closed rather than choosing a stale parent. */
42
+ export declare function recoverProfileRotation(name: string): Profile | undefined;
43
+ export declare function writeProfile(name: string, profile: Profile): void;
44
+ /** Replace a profile only if the credential that started an interactive
45
+ * recovery is still the live slot value. A bridge may be waiting for browser
46
+ * approval while another process rotates or reconnects the same profile; in
47
+ * that race the newer durable slot wins and the recovery must not overwrite
48
+ * it. */
49
+ export declare function replaceProfileAfterRecovery(name: string, previousRefreshToken: string, profile: Profile): void;
50
+ export declare function removeProfile(name: string): Profile | undefined;
51
+ export { activeProfilePath };
52
+ /** Serialize refresh-token exchange across processes. A heartbeat keeps a live
53
+ * owner fresh; the random token makes release ownership-safe after recovery. */
54
+ export declare function withProfileLock<T>(name: string, fn: () => Promise<T>): Promise<T>;
55
+ /** Best-effort read for command resolution. A stale or damaged pointer must
56
+ * never make the CLI guess a credential; callers can fall back to the normal
57
+ * sole-profile rule or report ambiguity. */
58
+ export declare function readActiveProfile(): string | undefined;
59
+ /** Make a stored profile the local default for interactive CLI commands. The
60
+ * selected name is not a credential and is stored separately from secrets. */
61
+ export declare function setActiveProfile(name: string): void;
62
+ /** Clear the local selection, optionally only when it points at `name`. */
63
+ export declare function clearActiveProfile(name?: string): void;
64
+ export declare function credsPath(): string;
@@ -0,0 +1,52 @@
1
+ export type DiscoveryClient = "claude" | "claude-code" | "cursor" | "vscode" | "codex";
2
+ export type DiscoverySourceStatus = "ready" | "missing" | "permission_denied" | "invalid" | "unreadable";
3
+ export type DiscoveryEntry = {
4
+ client: DiscoveryClient;
5
+ name: string;
6
+ governance: "governed" | "unmanaged";
7
+ transport: "stdio" | "http" | "sse" | "unknown";
8
+ detail: string;
9
+ canImport: boolean;
10
+ protectedSettings: boolean;
11
+ };
12
+ export type DiscoverySource = {
13
+ client: DiscoveryClient;
14
+ status: DiscoverySourceStatus;
15
+ servers: DiscoveryEntry[];
16
+ };
17
+ export type DiscoverySnapshot = {
18
+ scanId: string;
19
+ scannedAt: number;
20
+ installationId: string;
21
+ installationLabel: string;
22
+ sources: DiscoverySource[];
23
+ };
24
+ export type DiscoveryComplianceReport = {
25
+ assets?: Array<{
26
+ connectionCount?: number;
27
+ decision?: {
28
+ state?: string;
29
+ } | null;
30
+ }>;
31
+ policy?: {
32
+ fleetMode?: string;
33
+ enforcement?: string;
34
+ };
35
+ };
36
+ /**
37
+ * A managed scanner is the enforcement boundary Passport can verify today.
38
+ * `require_passport` fails every active direct connection unless an admin has
39
+ * explicitly approved it or granted an exception. `block` is narrower: it
40
+ * fails entries an admin explicitly denied. Endpoint management can use the
41
+ * exit code as a compliance gate without Passport editing client config.
42
+ */
43
+ export declare function evaluateDiscoveryCompliance(report: DiscoveryComplianceReport): {
44
+ compliant: boolean;
45
+ routeRequired: number;
46
+ denied: number;
47
+ };
48
+ export declare function inspectDiscoveryEntry(client: DiscoveryClient, rawName: string, raw: unknown, passportOrigin: string): DiscoveryEntry;
49
+ export declare function fleetInstallationId(env?: NodeJS.ProcessEnv): string;
50
+ export declare function scanLocalMcpConfigs(passportOrigin: string, env?: NodeJS.ProcessEnv): DiscoverySnapshot;
51
+ /** Contract helper: no prohibited local detail may enter the wire snapshot. */
52
+ export declare function discoverySnapshotFingerprint(snapshot: DiscoverySnapshot): string;
@@ -0,0 +1,34 @@
1
+ export type DoctorStatus = "pass" | "warn" | "fail" | "skip";
2
+ export type DoctorCheck = {
3
+ id: string;
4
+ status: DoctorStatus;
5
+ summary: string;
6
+ action?: string;
7
+ };
8
+ export type DoctorReport = {
9
+ version: string;
10
+ ok: boolean;
11
+ auth: "profile" | "agent-key" | "none";
12
+ profile?: string;
13
+ profileCount: number;
14
+ endpointOrigin?: string;
15
+ server?: {
16
+ name: string;
17
+ version: string;
18
+ };
19
+ checks: DoctorCheck[];
20
+ };
21
+ type DoctorOptions = {
22
+ version: string;
23
+ profile?: string;
24
+ env: NodeJS.ProcessEnv;
25
+ timeoutMs: number;
26
+ signal: AbortSignal;
27
+ caller?: string;
28
+ normalizeEndpoint: (raw: string) => string;
29
+ redactError: (message: string) => string;
30
+ };
31
+ export declare function nodeRuntimeSupported(version: string): boolean;
32
+ export declare function runDoctor(options: DoctorOptions): Promise<DoctorReport>;
33
+ export declare function formatDoctorReport(report: DoctorReport): string;
34
+ export {};
@@ -0,0 +1,2 @@
1
+ export { AccessGatewayClient, AccessGatewayError, accessClientFromEnv, assertCallerId, defaultAccessPrivateKeyFile, defaultAccessPublicJwkFile, generateAccessKey, parseAccessInputFile, writeGeneratedAccessKey } from "./accessClient.js";
2
+ export type { AccessAction, AccessAlgorithm, AccessCapability, AccessGatewayClientOptions, AccessInvocationInput, AccessInvocationResult, AccessReceipt, AccessRun, AccessRunInput, GeneratedAccessKey } from "./accessClient.js";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { AccessGatewayClient, AccessGatewayError, accessClientFromEnv, assertCallerId, defaultAccessPrivateKeyFile, defaultAccessPublicJwkFile, generateAccessKey, parseAccessInputFile, writeGeneratedAccessKey } from "./accessClient.js";
@@ -0,0 +1,10 @@
1
+ /** Kept well below the profile lock's 30-second stale lease. */
2
+ export declare const LEGACY_REQUEST_TIMEOUT_MS = 10000;
3
+ export declare function legacyCloudOrigin(raw: string): string;
4
+ export declare function legacyProfileEndpoint(raw: string): string;
5
+ export declare function legacyCredentialEndpoint(raw: string, cloud: string): string;
6
+ export declare function legacyVerifyUrl(raw: string, cloud: string): string;
7
+ /** Every legacy network operation is finite and refuses redirects. In
8
+ * particular, a 307/308 can never replay a refresh token, session bearer, or
9
+ * device code to an origin selected by a response. */
10
+ export declare function legacyFetch(input: string | URL, init?: RequestInit, fetcher?: typeof fetch, timeout?: number): Promise<Response>;
@@ -0,0 +1,7 @@
1
+ import type { ManagedSkillsResult } from "./managedSkillsContract.generated.js";
2
+ export type ManagedSkillsOptions = {
3
+ /** Dependency injection for isolated filesystem verification, never accepted over IPC. */
4
+ home?: string;
5
+ checkpoint?: (phase: "journal" | "artifact" | "record") => void;
6
+ };
7
+ export declare function runManagedSkills(input: unknown, options?: ManagedSkillsOptions): ManagedSkillsResult;