passport-bridge 0.9.0 → 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.
- package/README.md +19 -0
- package/dist/bridge.d.ts +9 -0
- package/dist/bridge.js +49 -42
- package/dist/bridgePoller.d.ts +34 -0
- package/dist/bridgePoller.js +123 -0
- package/dist/bridgeShutdown.d.ts +3 -0
- package/dist/bridgeShutdown.js +5 -1
- package/dist/cli.js +4 -0
- package/dist/cliArgs.d.ts +1 -1
- package/dist/cliArgs.js +4 -1
- package/dist/cliOutput.js +2 -0
- package/dist/cliSetup.d.ts +10 -0
- package/dist/cliSetup.js +157 -0
- package/dist/completion.js +2 -0
- package/dist/managedSkills.d.ts +7 -0
- package/dist/managedSkills.js +268 -0
- package/dist/managedSkillsContract.generated.d.ts +82 -0
- package/dist/managedSkillsContract.generated.js +32 -0
- package/dist/managedSkillsFiles.d.ts +23 -0
- package/dist/managedSkillsFiles.js +215 -0
- package/dist/managedSkillsIpc.d.ts +5 -0
- package/dist/managedSkillsIpc.js +44 -0
- package/dist/managedSkillsValidation.d.ts +14 -0
- package/dist/managedSkillsValidation.js +118 -0
- package/dist/passport.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -86,6 +86,25 @@ or traffic. Managed-policy violations return exit `5`, so endpoint management
|
|
|
86
86
|
can use it as a compliance gate without Passport silently editing client
|
|
87
87
|
configuration.
|
|
88
88
|
|
|
89
|
+
### Team workflows
|
|
90
|
+
|
|
91
|
+
Passport CLI 0.10.0 adds assigned workflow discovery and managed skills for
|
|
92
|
+
Codex and Claude Code on macOS and Linux. Sign in with a member profile first.
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
passport setup list
|
|
96
|
+
passport setup install <setup-id> <workflow-key> --client codex
|
|
97
|
+
passport setup install <setup-id> <workflow-key> --client codex --apply
|
|
98
|
+
passport setup installed
|
|
99
|
+
passport setup rollback <skill-name> --apply
|
|
100
|
+
passport setup remove <skill-name> --apply
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Installation defaults to a preview. Updates require the published manifest for
|
|
104
|
+
the selected workspace, setup, and client. Personal edits are preserved; local
|
|
105
|
+
removal and rollback remain available offline after access changes. Installing
|
|
106
|
+
guidance never grants app permissions or provisions a vendor account.
|
|
107
|
+
|
|
89
108
|
### Diagnostics
|
|
90
109
|
|
|
91
110
|
Run diagnostics before opening a support ticket or promoting a CLI release:
|
package/dist/bridge.d.ts
CHANGED
|
@@ -87,3 +87,12 @@ export type BridgeRunOptions = {
|
|
|
87
87
|
* a periodic re-list notifies the client when the toolset changes.
|
|
88
88
|
*/
|
|
89
89
|
export declare function runBridge(endpoint: string, tokens: TokenManager, options?: BridgeRunOptions): Promise<void>;
|
|
90
|
+
export type ToolSignatureDefinition = {
|
|
91
|
+
name: string;
|
|
92
|
+
description?: string;
|
|
93
|
+
inputSchema?: unknown;
|
|
94
|
+
};
|
|
95
|
+
/** Canonical hash of the complete visible tool definitions. Kept pure so the
|
|
96
|
+
* bridge can prove hashing cost independently from MCP transport latency. */
|
|
97
|
+
export declare function canonicalToolSignature(tools: readonly ToolSignatureDefinition[]): string;
|
|
98
|
+
export declare function toolSignature(client: Client, signal?: AbortSignal): Promise<string>;
|
package/dist/bridge.js
CHANGED
|
@@ -9,6 +9,7 @@ import { VERSION } from "./version.js";
|
|
|
9
9
|
import { bridgePollIntervalMs } from "./bridgeConfig.js";
|
|
10
10
|
import { readBoundedJson } from "./boundedResponse.js";
|
|
11
11
|
import { createBoundedBridgeShutdown } from "./bridgeShutdown.js";
|
|
12
|
+
import { BridgePoller } from "./bridgePoller.js";
|
|
12
13
|
import { workspaceOfToken } from "./tokenWorkspace.js";
|
|
13
14
|
export { workspaceOfToken } from "./tokenWorkspace.js";
|
|
14
15
|
/** Everything but the MCP protocol goes to stderr — stdout is the transport. */
|
|
@@ -285,7 +286,6 @@ export async function runBridge(endpoint, tokens, options = {}) {
|
|
|
285
286
|
let state = "connecting";
|
|
286
287
|
let recoveryInFlight;
|
|
287
288
|
let recoveryAbort;
|
|
288
|
-
let pollTimer;
|
|
289
289
|
let lastSignature = "";
|
|
290
290
|
const connectCandidate = async (candidate) => {
|
|
291
291
|
if (options.connectUpstream) {
|
|
@@ -338,42 +338,45 @@ export async function runBridge(endpoint, tokens, options = {}) {
|
|
|
338
338
|
server.notification({ method: "notifications/prompts/list_changed" })
|
|
339
339
|
]);
|
|
340
340
|
};
|
|
341
|
-
const enterDegraded = async (error) => {
|
|
341
|
+
const enterDegraded = async (error, generationAlreadyInvalidated = false) => {
|
|
342
342
|
const hadUpstream = Boolean(upstream);
|
|
343
343
|
const previous = upstream;
|
|
344
344
|
state = "degraded";
|
|
345
345
|
upstream = undefined;
|
|
346
346
|
upstreamHasUrlElicitation = false;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
347
|
+
// Invalidate the generation before closing the old client. A poll that
|
|
348
|
+
// finishes during reconnect cannot notify the downstream for a superseded
|
|
349
|
+
// upstream surface.
|
|
350
|
+
if (!generationAlreadyInvalidated)
|
|
351
|
+
await poller?.rotate();
|
|
350
352
|
void previous?.close().catch(() => undefined);
|
|
351
353
|
const status = isBridgeCredentialError(error) ? "credential rejected" : "unavailable";
|
|
352
354
|
log(`Passport ${status}; serving fail-closed recovery mode.`);
|
|
353
355
|
if (hadUpstream)
|
|
354
356
|
await notifySurfacesChanged().catch(() => undefined);
|
|
355
357
|
};
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
},
|
|
375
|
-
|
|
376
|
-
|
|
358
|
+
const poller = new BridgePoller({
|
|
359
|
+
intervalMs: pollMs,
|
|
360
|
+
poll: (signal) => {
|
|
361
|
+
const client = upstream;
|
|
362
|
+
if (!client || state !== "ready")
|
|
363
|
+
return Promise.resolve(undefined);
|
|
364
|
+
return toolSignature(client, signal);
|
|
365
|
+
},
|
|
366
|
+
onSignature: async (signature, generation) => {
|
|
367
|
+
if (!poller?.isCurrent(generation) || !upstream || state !== "ready")
|
|
368
|
+
return;
|
|
369
|
+
if (signature === lastSignature)
|
|
370
|
+
return;
|
|
371
|
+
await notifySurfacesChanged();
|
|
372
|
+
if (poller?.isCurrent(generation) && upstream && state === "ready") {
|
|
373
|
+
lastSignature = signature;
|
|
374
|
+
log("tools changed; notified client");
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
isCredentialError: isBridgeCredentialError,
|
|
378
|
+
onCredentialError: (error) => enterDegraded(error, true)
|
|
379
|
+
});
|
|
377
380
|
const connectUpstream = async () => {
|
|
378
381
|
const urlElicitation = server.getClientCapabilities()?.elicitation?.url;
|
|
379
382
|
if (state === "ready" && upstreamHasUrlElicitation === Boolean(urlElicitation))
|
|
@@ -392,6 +395,9 @@ export async function runBridge(endpoint, tokens, options = {}) {
|
|
|
392
395
|
upstream = undefined;
|
|
393
396
|
state = "connecting";
|
|
394
397
|
connecting = (async () => {
|
|
398
|
+
// Publish `connecting` before yielding so simultaneous recovery or
|
|
399
|
+
// capability-negotiation callers share this one reconnect attempt.
|
|
400
|
+
await poller?.rotate();
|
|
395
401
|
// URL mode is never claimed on behalf of a client that did not advertise
|
|
396
402
|
// it. The bridge has historically offered no form-elicitation surface,
|
|
397
403
|
// so leaving form mode unadvertised preserves its gateway fallback.
|
|
@@ -414,15 +420,13 @@ export async function runBridge(endpoint, tokens, options = {}) {
|
|
|
414
420
|
state = "ready";
|
|
415
421
|
lastSignature = await toolSignature(candidate);
|
|
416
422
|
log(`connected to ${activeEndpoint}`);
|
|
417
|
-
|
|
418
|
-
startPolling();
|
|
423
|
+
poller?.start();
|
|
419
424
|
})()
|
|
420
425
|
.catch(async (error) => {
|
|
421
426
|
if (previous && !isBridgeCredentialError(error)) {
|
|
422
427
|
upstream = previous;
|
|
423
428
|
state = "ready";
|
|
424
|
-
|
|
425
|
-
startPolling();
|
|
429
|
+
poller?.start();
|
|
426
430
|
log("URL elicitation negotiation was unavailable; continuing with the existing Passport session.");
|
|
427
431
|
return;
|
|
428
432
|
}
|
|
@@ -551,17 +555,15 @@ export async function runBridge(endpoint, tokens, options = {}) {
|
|
|
551
555
|
server.onclose = () => {
|
|
552
556
|
removeProcessSignalHandlers();
|
|
553
557
|
recoveryAbort?.abort();
|
|
554
|
-
|
|
555
|
-
clearInterval(pollTimer);
|
|
556
|
-
pollTimer = undefined;
|
|
558
|
+
void poller?.stop();
|
|
557
559
|
void upstream?.close().catch(() => undefined);
|
|
558
560
|
};
|
|
559
561
|
await server.connect(options.downstreamTransport ?? new StdioServerTransport());
|
|
560
562
|
log("ready on stdio");
|
|
561
563
|
if (upstream)
|
|
562
|
-
|
|
564
|
+
poller.start();
|
|
563
565
|
const shutdown = createBoundedBridgeShutdown({
|
|
564
|
-
|
|
566
|
+
poller,
|
|
565
567
|
upstream: { close: () => upstream?.close() ?? Promise.resolve() },
|
|
566
568
|
server,
|
|
567
569
|
onFailure: () => log("shutdown did not drain cleanly")
|
|
@@ -574,13 +576,9 @@ export async function runBridge(endpoint, tokens, options = {}) {
|
|
|
574
576
|
process.off("SIGTERM", onSignal);
|
|
575
577
|
};
|
|
576
578
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
// one meta-tool per app carries the catalog in its DESCRIPTION, so policy
|
|
581
|
-
// changes inside an app (a pass change, tools toggled) alter descriptions
|
|
582
|
-
// while the name set stays identical — a names-only signature missed them and
|
|
583
|
-
// the client's view went stale until an app restart.
|
|
579
|
+
/** Canonical hash of the complete visible tool definitions. Kept pure so the
|
|
580
|
+
* bridge can prove hashing cost independently from MCP transport latency. */
|
|
581
|
+
export function canonicalToolSignature(tools) {
|
|
584
582
|
const digest = createHash("sha256");
|
|
585
583
|
for (const t of [...tools].sort((a, b) => a.name.localeCompare(b.name))) {
|
|
586
584
|
digest.update(t.name).update("\0");
|
|
@@ -589,3 +587,12 @@ async function toolSignature(client) {
|
|
|
589
587
|
}
|
|
590
588
|
return digest.digest("hex");
|
|
591
589
|
}
|
|
590
|
+
export async function toolSignature(client, signal) {
|
|
591
|
+
const { tools } = await client.listTools({}, signal ? { signal } : undefined);
|
|
592
|
+
// Hash the full visible definitions, not just names: in `apps` discovery mode
|
|
593
|
+
// one meta-tool per app carries the catalog in its DESCRIPTION, so policy
|
|
594
|
+
// changes inside an app (a pass change, tools toggled) alter descriptions
|
|
595
|
+
// while the name set stays identical — a names-only signature missed them and
|
|
596
|
+
// the client's view went stale until an app restart.
|
|
597
|
+
return canonicalToolSignature(tools);
|
|
598
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type BridgePollerOptions = {
|
|
2
|
+
intervalMs: number;
|
|
3
|
+
poll: (signal: AbortSignal) => Promise<string | undefined>;
|
|
4
|
+
onSignature: (signature: string, generation: number) => Promise<void> | void;
|
|
5
|
+
isCredentialError?: (error: unknown) => boolean;
|
|
6
|
+
onCredentialError?: (error: unknown) => Promise<void> | void;
|
|
7
|
+
onError?: (error: unknown) => Promise<void> | void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Runs at most one tool-surface poll at a time. A generation invalidates any
|
|
11
|
+
* result that belongs to a superseded upstream connection; rotate() aborts and
|
|
12
|
+
* drains the in-flight request before the caller installs its replacement.
|
|
13
|
+
*/
|
|
14
|
+
export declare class BridgePoller {
|
|
15
|
+
private readonly options;
|
|
16
|
+
private timer;
|
|
17
|
+
private active;
|
|
18
|
+
private readonly callbacks;
|
|
19
|
+
private generation;
|
|
20
|
+
private stopped;
|
|
21
|
+
constructor(options: BridgePollerOptions);
|
|
22
|
+
start(): void;
|
|
23
|
+
/** Invalidate and drain the current poll while keeping the timer reusable. */
|
|
24
|
+
rotate(): Promise<void>;
|
|
25
|
+
/** Permanently stop polling and drain the active request. */
|
|
26
|
+
stop(): Promise<void>;
|
|
27
|
+
/** Testable/manual trigger; timer ticks use the same single-flight path. */
|
|
28
|
+
pollNow(): Promise<void>;
|
|
29
|
+
isCurrent(generation: number): boolean;
|
|
30
|
+
private execute;
|
|
31
|
+
private clearActive;
|
|
32
|
+
private drainActive;
|
|
33
|
+
private trackCallback;
|
|
34
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs at most one tool-surface poll at a time. A generation invalidates any
|
|
3
|
+
* result that belongs to a superseded upstream connection; rotate() aborts and
|
|
4
|
+
* drains the in-flight request before the caller installs its replacement.
|
|
5
|
+
*/
|
|
6
|
+
export class BridgePoller {
|
|
7
|
+
options;
|
|
8
|
+
timer;
|
|
9
|
+
active;
|
|
10
|
+
callbacks = new Set();
|
|
11
|
+
generation = 0;
|
|
12
|
+
stopped = false;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
if (!Number.isSafeInteger(options.intervalMs) || options.intervalMs < 1) {
|
|
16
|
+
throw new Error("Bridge poll interval must be a positive integer.");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
start() {
|
|
20
|
+
if (this.stopped || this.timer)
|
|
21
|
+
return;
|
|
22
|
+
this.generation++;
|
|
23
|
+
this.timer = setInterval(() => {
|
|
24
|
+
void this.pollNow();
|
|
25
|
+
}, this.options.intervalMs);
|
|
26
|
+
this.timer.unref?.();
|
|
27
|
+
}
|
|
28
|
+
/** Invalidate and drain the current poll while keeping the timer reusable. */
|
|
29
|
+
async rotate() {
|
|
30
|
+
this.generation++;
|
|
31
|
+
await this.drainActive();
|
|
32
|
+
}
|
|
33
|
+
/** Permanently stop polling and drain the active request. */
|
|
34
|
+
async stop() {
|
|
35
|
+
if (!this.stopped) {
|
|
36
|
+
this.stopped = true;
|
|
37
|
+
this.generation++;
|
|
38
|
+
if (this.timer)
|
|
39
|
+
clearInterval(this.timer);
|
|
40
|
+
this.timer = undefined;
|
|
41
|
+
}
|
|
42
|
+
await this.drainActive();
|
|
43
|
+
}
|
|
44
|
+
/** Testable/manual trigger; timer ticks use the same single-flight path. */
|
|
45
|
+
pollNow() {
|
|
46
|
+
if (this.stopped)
|
|
47
|
+
return Promise.resolve();
|
|
48
|
+
if (this.active)
|
|
49
|
+
return this.active.promise;
|
|
50
|
+
if (this.callbacks.size)
|
|
51
|
+
return Promise.allSettled(this.callbacks).then(() => undefined);
|
|
52
|
+
const active = {
|
|
53
|
+
generation: this.generation,
|
|
54
|
+
controller: new AbortController(),
|
|
55
|
+
promise: Promise.resolve()
|
|
56
|
+
};
|
|
57
|
+
this.active = active;
|
|
58
|
+
active.promise = this.execute(active);
|
|
59
|
+
return active.promise;
|
|
60
|
+
}
|
|
61
|
+
isCurrent(generation) {
|
|
62
|
+
return !this.stopped && generation === this.generation;
|
|
63
|
+
}
|
|
64
|
+
async execute(active) {
|
|
65
|
+
let signature;
|
|
66
|
+
try {
|
|
67
|
+
signature = await this.options.poll(active.controller.signal);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
this.clearActive(active);
|
|
71
|
+
if (!this.isCurrent(active.generation))
|
|
72
|
+
return;
|
|
73
|
+
if (this.options.isCredentialError?.(error)) {
|
|
74
|
+
// Invalidate before invoking the asynchronous transition callback, so
|
|
75
|
+
// a reconnect cannot accept a result from this failed generation.
|
|
76
|
+
this.generation++;
|
|
77
|
+
await this.trackCallback(() => this.options.onCredentialError?.(error));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
await this.trackCallback(() => this.options.onError?.(error));
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.clearActive(active);
|
|
85
|
+
if (!this.isCurrent(active.generation) || signature === undefined)
|
|
86
|
+
return;
|
|
87
|
+
await this.trackCallback(async () => {
|
|
88
|
+
try {
|
|
89
|
+
await this.options.onSignature(signature, active.generation);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
await this.options.onError?.(error);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
clearActive(active) {
|
|
97
|
+
if (this.active === active)
|
|
98
|
+
this.active = undefined;
|
|
99
|
+
}
|
|
100
|
+
async drainActive() {
|
|
101
|
+
while (this.active || this.callbacks.size) {
|
|
102
|
+
const active = this.active;
|
|
103
|
+
if (active)
|
|
104
|
+
active.controller.abort();
|
|
105
|
+
const waits = [...(active ? [active.promise] : []), ...this.callbacks];
|
|
106
|
+
await Promise.allSettled(waits);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
trackCallback(callback) {
|
|
110
|
+
const promise = (async () => {
|
|
111
|
+
try {
|
|
112
|
+
await callback();
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// Poll callbacks are lifecycle housekeeping. A notification failure
|
|
116
|
+
// must not become a detached rejection or wedge future polling.
|
|
117
|
+
}
|
|
118
|
+
})();
|
|
119
|
+
this.callbacks.add(promise);
|
|
120
|
+
void promise.finally(() => this.callbacks.delete(promise));
|
|
121
|
+
return promise;
|
|
122
|
+
}
|
|
123
|
+
}
|
package/dist/bridgeShutdown.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ type Closeable = {
|
|
|
4
4
|
};
|
|
5
5
|
type BridgeShutdownOptions = {
|
|
6
6
|
pollTimer?: ReturnType<typeof setInterval> | (() => ReturnType<typeof setInterval> | undefined);
|
|
7
|
+
poller?: {
|
|
8
|
+
stop(): Promise<void>;
|
|
9
|
+
};
|
|
7
10
|
upstream: Closeable;
|
|
8
11
|
server: Closeable;
|
|
9
12
|
timeoutMs?: number;
|
package/dist/bridgeShutdown.js
CHANGED
|
@@ -17,7 +17,11 @@ export function createBoundedBridgeShutdown(options) {
|
|
|
17
17
|
const timedOut = new Promise((resolve) => {
|
|
18
18
|
deadline = setTimeout(() => resolve("timeout"), timeoutMs);
|
|
19
19
|
});
|
|
20
|
-
const closed = Promise.allSettled([
|
|
20
|
+
const closed = Promise.allSettled([
|
|
21
|
+
options.poller?.stop() ?? Promise.resolve(),
|
|
22
|
+
options.server.close(),
|
|
23
|
+
options.upstream.close()
|
|
24
|
+
]).then((results) => results.every((result) => result.status === "fulfilled") ? "closed" : "failed");
|
|
21
25
|
const outcome = await Promise.race([closed, timedOut]);
|
|
22
26
|
if (deadline)
|
|
23
27
|
clearTimeout(deadline);
|
package/dist/cli.js
CHANGED
|
@@ -26,6 +26,10 @@ function arg(flag, fallback = "") {
|
|
|
26
26
|
}
|
|
27
27
|
async function main() {
|
|
28
28
|
const command = process.argv[2] ?? "serve";
|
|
29
|
+
if (command === "managed-skills") {
|
|
30
|
+
const { managedSkillsIpcMain } = await import("./managedSkillsIpc.js");
|
|
31
|
+
return managedSkillsIpcMain();
|
|
32
|
+
}
|
|
29
33
|
if (process.argv.includes("--help") || process.argv.includes("-h") || command === "help")
|
|
30
34
|
return help();
|
|
31
35
|
if (command === "--version" || command === "-V" || command === "version")
|
package/dist/cliArgs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const COMMANDS: readonly ["login", "logout", "profiles", "use", "status", "doctor", "ready", "search", "describe", "run", "connect", "resources", "prompts", "discover", "session", "access", "completion", "help", "version"];
|
|
1
|
+
export declare const COMMANDS: readonly ["login", "logout", "profiles", "use", "status", "doctor", "ready", "search", "describe", "run", "connect", "resources", "prompts", "discover", "setup", "session", "access", "completion", "help", "version"];
|
|
2
2
|
export type Command = (typeof COMMANDS)[number];
|
|
3
3
|
export declare class ArgError extends Error {
|
|
4
4
|
}
|
package/dist/cliArgs.js
CHANGED
|
@@ -13,6 +13,7 @@ export const COMMANDS = [
|
|
|
13
13
|
"resources",
|
|
14
14
|
"prompts",
|
|
15
15
|
"discover",
|
|
16
|
+
"setup",
|
|
16
17
|
"session",
|
|
17
18
|
"access",
|
|
18
19
|
"completion",
|
|
@@ -28,7 +29,8 @@ const FLAGS = {
|
|
|
28
29
|
help: { kind: "boolean" },
|
|
29
30
|
cloud: { kind: "value", commands: ["login"] },
|
|
30
31
|
workspace: { kind: "value", commands: ["login", "access"] },
|
|
31
|
-
client: { kind: "value", commands: ["login"] },
|
|
32
|
+
client: { kind: "value", commands: ["login", "setup"] },
|
|
33
|
+
apply: { kind: "boolean", commands: ["setup"] },
|
|
32
34
|
"no-open": { kind: "boolean", commands: ["login"] },
|
|
33
35
|
app: { kind: "value", commands: ["search"] },
|
|
34
36
|
args: { kind: "value", commands: ["run"] },
|
|
@@ -144,6 +146,7 @@ function validateShape(command, positionals) {
|
|
|
144
146
|
resources: 1,
|
|
145
147
|
prompts: 1,
|
|
146
148
|
discover: 0,
|
|
149
|
+
setup: 3,
|
|
147
150
|
session: 0,
|
|
148
151
|
access: 2,
|
|
149
152
|
completion: 1,
|
package/dist/cliOutput.js
CHANGED
|
@@ -18,6 +18,7 @@ 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.',
|
|
22
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>",
|
|
23
24
|
completion: "passport completion <bash|zsh|fish>\nPrints an offline shell-completion script to stdout.",
|
|
@@ -44,6 +45,7 @@ Usage: passport <command> [options]
|
|
|
44
45
|
resources List or read MCP resources
|
|
45
46
|
prompts List or get MCP prompts
|
|
46
47
|
discover Scan this computer for direct MCP configuration
|
|
48
|
+
setup Install and maintain assigned team workflows
|
|
47
49
|
session Reuse one authenticated MCP session for NDJSON commands
|
|
48
50
|
access Use the signed managed access gateway
|
|
49
51
|
completion Generate bash, zsh, or fish completion
|
|
@@ -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 {};
|
package/dist/cliSetup.js
ADDED
|
@@ -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
|
+
}
|
package/dist/completion.js
CHANGED
|
@@ -16,6 +16,7 @@ const DESCRIPTIONS = {
|
|
|
16
16
|
discover: "Scan local MCP configuration for fleet governance",
|
|
17
17
|
session: "Reuse one authenticated session for NDJSON commands",
|
|
18
18
|
access: "Use the signed managed access gateway",
|
|
19
|
+
setup: "Install and maintain your assigned AI workflows",
|
|
19
20
|
completion: "Generate shell completion",
|
|
20
21
|
help: "Show command help",
|
|
21
22
|
version: "Show CLI version and local context"
|
|
@@ -28,6 +29,7 @@ const COMMAND_FLAGS = {
|
|
|
28
29
|
connect: ["--alias", "--open", "--wait"],
|
|
29
30
|
resources: ["--out"],
|
|
30
31
|
prompts: ["--set", "--out"],
|
|
32
|
+
setup: ["--client", "--apply"],
|
|
31
33
|
access: [
|
|
32
34
|
"--workspace",
|
|
33
35
|
"--client-id",
|
|
@@ -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;
|