passport-bridge 0.38.0 → 0.39.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/dist/cliExec.d.ts +3 -1
- package/dist/cliExec.js +15 -3
- package/dist/connectorKit/manifests/github.generated.js +1 -1
- package/dist/connectorKit/manifests/githubHooks.generated.js +13 -4
- package/dist/connectorKit/manifests/railway.generated.js +1 -1
- package/dist/controlPlane.generated.d.ts +18 -6
- package/dist/controlPlaneBasic.generated.d.ts +3 -0
- package/dist/controlPlaneBasic.generated.js +9 -1
- package/dist/controlPlaneCli.d.ts +1 -0
- package/dist/controlPlaneCli.js +1 -0
- package/dist/controlPlaneExec.js +17 -6
- package/dist/controlPlaneGithub.generated.d.ts +2 -2
- package/dist/controlPlaneGithub.generated.js +3 -2
- package/dist/controlPlaneGithubCatalog.generated.d.ts +3 -0
- package/dist/controlPlaneGithubCatalog.generated.js +13 -0
- package/dist/controlPlaneGithubCli.generated.d.ts +9 -0
- package/dist/controlPlaneGithubCli.generated.js +35 -7
- package/dist/controlPlaneModel.generated.d.ts +30 -1
- package/dist/controlPlaneModel.generated.js +51 -1
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/cliExec.d.ts
CHANGED
|
@@ -41,11 +41,13 @@ export type ExecDependencies = {
|
|
|
41
41
|
};
|
|
42
42
|
export { execTarget };
|
|
43
43
|
export { githubRepo } from "./execGithubRepo.js";
|
|
44
|
-
/** The classified finding the server decides on: vendor, verb, risk. Never an
|
|
44
|
+
/** The classified finding the server decides on: vendor, verb, risk, and for `gh api` the method gh sends. Never an
|
|
45
|
+
* argument. */
|
|
45
46
|
export declare function execFinding(vendor: ExecVendor, binary: string, args: readonly string[]): {
|
|
46
47
|
vendor: string;
|
|
47
48
|
verb: string;
|
|
48
49
|
risk: string;
|
|
50
|
+
method?: string;
|
|
49
51
|
};
|
|
50
52
|
/** Only the vendor's own variables, as plain single-line strings. None for a Railway read Passport sends with the
|
|
51
53
|
* person's own sign-in (`ownSignIn`: Passport mints only for actions). */
|
package/dist/cliExec.js
CHANGED
|
@@ -25,6 +25,7 @@ import { memberApi } from "./cliClient.js";
|
|
|
25
25
|
import { passportUnreachable } from "./cliOutput.js";
|
|
26
26
|
import { execControlPlaneRefusal, execIdsWanted, execRailwayScope, execRelease } from "./controlPlaneExec.js";
|
|
27
27
|
import { classifyCommand, UNRECOGNIZED_VERB } from "./cliHookClassify.js";
|
|
28
|
+
import { GH_VALUES, ghApiMethod, parseArgs as parseGhArgs } from "./controlPlaneGithubCli.generated.js";
|
|
28
29
|
import { redactCommand } from "./cliHookRedact.js";
|
|
29
30
|
import { noteExecVendor } from "./execMarker.js";
|
|
30
31
|
import { CliFailure, callerFrom, failure, readBoundedJson, resolveCliAuth, safeApiError, timeoutMs } from "./cliSupport.js";
|
|
@@ -50,7 +51,8 @@ function quote(part) {
|
|
|
50
51
|
function carrierOf(binary) {
|
|
51
52
|
return !execVendorOf(binary) && Object.hasOwn(EXEC_CARRIERS, binary) ? binary : undefined;
|
|
52
53
|
}
|
|
53
|
-
/** The classified finding the server decides on: vendor, verb, risk. Never an
|
|
54
|
+
/** The classified finding the server decides on: vendor, verb, risk, and for `gh api` the method gh sends. Never an
|
|
55
|
+
* argument. */
|
|
54
56
|
export function execFinding(vendor, binary, args) {
|
|
55
57
|
const command = [binary, ...args].map(quote).join(" ");
|
|
56
58
|
const carrier = carrierOf(binary);
|
|
@@ -66,7 +68,15 @@ export function execFinding(vendor, binary, args) {
|
|
|
66
68
|
.filter((token) => /^-{0,2}[A-Za-z0-9][A-Za-z0-9._:+-]{0,39}$/.test(token))
|
|
67
69
|
.slice(0, 4)
|
|
68
70
|
.join(" ");
|
|
69
|
-
|
|
71
|
+
const finding = { vendor: carrier ?? vendor, verb: verb || UNRECOGNIZED_VERB, risk: found?.risk ?? "unknown" };
|
|
72
|
+
// `gh api`: Passport reads the method (a read isn't decided; anything else is decided), never the endpoint.
|
|
73
|
+
if (vendor !== "gh" || carrier || finding.verb.split(" ")[0] !== "api")
|
|
74
|
+
return finding;
|
|
75
|
+
const parsed = parseGhArgs(args, GH_VALUES.api);
|
|
76
|
+
if (parsed.pos[0] !== "api")
|
|
77
|
+
return finding;
|
|
78
|
+
const { method, read } = ghApiMethod(parsed);
|
|
79
|
+
return { ...finding, method: read ? method : method === "GET" || method === "HEAD" ? "POST" : method };
|
|
70
80
|
}
|
|
71
81
|
/** Only the vendor's own variables, as plain single-line strings. None for a Railway read Passport sends with the
|
|
72
82
|
* person's own sign-in (`ownSignIn`: Passport mints only for actions). */
|
|
@@ -407,7 +417,9 @@ async function basicDecision(api, profile, prepared, runtime, args) {
|
|
|
407
417
|
return;
|
|
408
418
|
const { askCliVerb } = await import("./controlPlaneCli.js");
|
|
409
419
|
const session = value(args, "session");
|
|
410
|
-
|
|
420
|
+
// Authorize decides it again and spends an Allow once with the credential: this ask only finds it.
|
|
421
|
+
const extra = { exec: true, ...(session ? { sessionId: session } : {}) };
|
|
422
|
+
const answer = await askCliVerb(api, vendor, verb, extra, runtime.signal);
|
|
411
423
|
if (answer.kind === "block")
|
|
412
424
|
failure(answer.message, 5, "blocked");
|
|
413
425
|
}
|
|
@@ -56,7 +56,7 @@ export const GITHUB_ACTIONS = [
|
|
|
56
56
|
},
|
|
57
57
|
{ key: "github.org.invite", kind: "grant", appliesTo: "org", label: "Invite a member", icon: "UserPlus" },
|
|
58
58
|
{ key: "github.secret.change", kind: "grant", appliesTo: "secrets", label: "Create or change a secret", icon: "Key" },
|
|
59
|
-
//
|
|
59
|
+
// Anything the manifest can't name fails closed; in the server catalog since E3 (2026-11-16).
|
|
60
60
|
{ key: "github.unclassified", kind: "delete", appliesTo: "repo", label: "Unclassified action", icon: "CircleHelp" }
|
|
61
61
|
];
|
|
62
62
|
export const GITHUB = {
|
|
@@ -357,13 +357,16 @@ export function githubHooks(m, branches) {
|
|
|
357
357
|
ghRepo,
|
|
358
358
|
ghApi: (n, _p, context) => {
|
|
359
359
|
const raw = text(n.params.$1);
|
|
360
|
+
const fields = n.params["raw-field"] !== undefined || n.params.field !== undefined;
|
|
361
|
+
const asked = text(n.params.method)?.toUpperCase();
|
|
362
|
+
const reads = n.params.input === undefined && (asked ? asked === "GET" || asked === "HEAD" : !fields);
|
|
363
|
+
// Anything it can't parse fails closed (E3): no endpoint, or a placeholder it can't fill, unless it reads.
|
|
360
364
|
if (raw === null)
|
|
361
|
-
return "
|
|
365
|
+
return "unclassified";
|
|
362
366
|
const linked = context.linked ?? {};
|
|
363
367
|
const path = raw.replace(/\{(owner|repo|branch)\}/g, (all, key) => linked[key] ?? all);
|
|
364
|
-
// gh fills these from the folder's repository; outside one it refuses to run.
|
|
365
368
|
if (/\{(owner|repo|branch)\}/.test(path))
|
|
366
|
-
return "read";
|
|
369
|
+
return reads ? "read" : "unclassified";
|
|
367
370
|
const body = {};
|
|
368
371
|
for (const entry of words(n.params["raw-field"])) {
|
|
369
372
|
const eq = entry.indexOf("=");
|
|
@@ -381,9 +384,15 @@ export function githubHooks(m, branches) {
|
|
|
381
384
|
const method = (explicit ?? (Object.keys(body).length > 0 || opaque ? "POST" : "GET")).toUpperCase();
|
|
382
385
|
if (!WRITE.has(method))
|
|
383
386
|
return "read";
|
|
387
|
+
// GraphQL is a POST either way: a query (anything but a mutation, from fields it can read) is a read; a mutation
|
|
388
|
+
// goes to the GraphQL hook.
|
|
389
|
+
const graphql = path.replace(/^\/+/, "") === "graphql" && !opaque && typeof body.query === "string";
|
|
390
|
+
if (graphql && !/^\s*mutation\b/i.test(String(body.query)))
|
|
391
|
+
return "read";
|
|
384
392
|
const found = classify(m, { interface: "api", method, url: path, body: opaque ? { force: true } : body }, context, hooks);
|
|
393
|
+
// A write it can't name fails closed (E3); a GraphQL call is decided by its own hook.
|
|
385
394
|
if (found === null)
|
|
386
|
-
return "
|
|
395
|
+
return "unclassified";
|
|
387
396
|
const list = Array.isArray(found) ? found : [found];
|
|
388
397
|
// A body that can't be read names no exact target: no "Allow once" is offered for it.
|
|
389
398
|
return opaque ? list.map(({ target: _t, ...rest }) => rest) : list;
|
|
@@ -70,7 +70,7 @@ const ACTIONS = [
|
|
|
70
70
|
["railway.volume.backups", "change", "volume", "Change backups", "Archive"],
|
|
71
71
|
["railway.bucket.delete", "change", "bucket", "Delete bucket", "Trash2"],
|
|
72
72
|
["railway.bucket.credentials", "change", "bucket", "Reset credentials", "Key"],
|
|
73
|
-
//
|
|
73
|
+
// Anything the manifest can't name fails closed; in the server catalog since E3 (2026-11-16).
|
|
74
74
|
["railway.unclassified", "delete", "project", "Unclassified action", "CircleHelp"]
|
|
75
75
|
];
|
|
76
76
|
export const RAILWAY_ACTIONS = ACTIONS.map(([key, kind, appliesTo, label, icon]) => ({
|
|
@@ -72,8 +72,7 @@ export type ActionDef = {
|
|
|
72
72
|
appliesTo: string;
|
|
73
73
|
/** Sentence case, verb first: "Delete the branch". */
|
|
74
74
|
label: string;
|
|
75
|
-
/** What "Allow once" is tied to beyond the node
|
|
76
|
-
* Absent when the node is the whole target. */
|
|
75
|
+
/** What "Allow once" is tied to beyond the node when the request names it ("collaborator"); absent: the node. */
|
|
77
76
|
exactTarget?: string;
|
|
78
77
|
/** A lucide-react icon name matching the platform's own iconography ("Trash2"). */
|
|
79
78
|
icon?: string;
|
|
@@ -84,6 +83,13 @@ export type ActionDef = {
|
|
|
84
83
|
source: Exclude<ObservationSourceKey, "passport">;
|
|
85
84
|
actor: boolean;
|
|
86
85
|
}>;
|
|
86
|
+
steer?: {
|
|
87
|
+
line: string;
|
|
88
|
+
check?: {
|
|
89
|
+
action: string;
|
|
90
|
+
at: "self" | "sibling";
|
|
91
|
+
};
|
|
92
|
+
};
|
|
87
93
|
};
|
|
88
94
|
/** How a platform's records show an action Passport made (section 1). */
|
|
89
95
|
export type IdentityRule = {
|
|
@@ -319,13 +325,20 @@ export declare const OUTSIDE_CREDENTIAL_KINDS: readonly ["personal_token", "depl
|
|
|
319
325
|
export type OutsideCredentialKind = (typeof OUTSIDE_CREDENTIAL_KINDS)[number];
|
|
320
326
|
export declare const SETUP_GAP_KINDS: readonly ["guard_off", "key_on_computer", "token_in_secrets", "stale_deploy_key"];
|
|
321
327
|
export type SetupGapKind = (typeof SETUP_GAP_KINDS)[number];
|
|
322
|
-
/** Where and whose, when known: a computer or a repository's secrets ("payments-api secrets"), the person
|
|
323
|
-
*
|
|
328
|
+
/** Where and whose, when known: a computer or a repository's secrets ("payments-api secrets"), the person, the install,
|
|
329
|
+
* the resource it sits on; `expected`: an admin marked it expected (core loop 4): off Needs you, still Unmanaged. */
|
|
324
330
|
export type CredentialPlace = {
|
|
325
331
|
where?: string;
|
|
326
332
|
personId?: string;
|
|
327
333
|
agentId?: string;
|
|
328
334
|
nodeId?: string;
|
|
335
|
+
} & Marked;
|
|
336
|
+
export type Marked = {
|
|
337
|
+
expected?: {
|
|
338
|
+
byId: string;
|
|
339
|
+
by: string;
|
|
340
|
+
at: number;
|
|
341
|
+
};
|
|
329
342
|
};
|
|
330
343
|
/** An Unmanaged event's credential, for "Open where it's set"; kind "passport": a Passport credential no rule decided. */
|
|
331
344
|
export type CpCredentialRef = CredentialPlace & {
|
|
@@ -345,8 +358,7 @@ export type CpOutsideCredential = CredentialPlace & {
|
|
|
345
358
|
lastSeenTs: number;
|
|
346
359
|
unmanaged7d: number;
|
|
347
360
|
};
|
|
348
|
-
/** A "Needs you" setup row
|
|
349
|
-
* ("passport keys move gh"); `count` is the Unmanaged events it led to in the last 7 days. */
|
|
361
|
+
/** A "Needs you" setup row: `id` `gap_` + 16 hex; `command` closes it; `count`: its Unmanaged events in 7 days. */
|
|
350
362
|
export type CpSetupGap = CredentialPlace & {
|
|
351
363
|
id: string;
|
|
352
364
|
platform: PlatformKey;
|
|
@@ -43,6 +43,9 @@ export declare const LOCAL_IRREVERSIBLE_VERBS: {
|
|
|
43
43
|
readonly "change-system": "Change system files";
|
|
44
44
|
};
|
|
45
45
|
export type LocalIrreversibleVerb = keyof typeof LOCAL_IRREVERSIBLE_VERBS;
|
|
46
|
+
/** The allowed way to finish that a refusal names (core loop 1, `ActionDef.steer`): the same work, one file at a time.
|
|
47
|
+
* No check: naming files is no governed action. */
|
|
48
|
+
export declare function localSteer(verb: LocalIrreversibleVerb): NonNullable<ActionDef["steer"]>;
|
|
46
49
|
export declare function isLocalIrreversibleVerb(verb: string): verb is LocalIrreversibleVerb;
|
|
47
50
|
/** Why one of these doesn't run, in the words the agent reads after "Blocked by Passport:" and an admin reads when
|
|
48
51
|
* Allow once is refused for one. */
|
|
@@ -43,6 +43,13 @@ export const LOCAL_IRREVERSIBLE_VERBS = {
|
|
|
43
43
|
"change-disk": "Change every file on the disk",
|
|
44
44
|
"change-system": "Change system files"
|
|
45
45
|
};
|
|
46
|
+
/** The allowed way to finish that a refusal names (core loop 1, `ActionDef.steer`): the same work, one file at a time.
|
|
47
|
+
* No check: naming files is no governed action. */
|
|
48
|
+
export function localSteer(verb) {
|
|
49
|
+
return verb.startsWith("delete-")
|
|
50
|
+
? { line: "Delete only the files you need, by name, instead." }
|
|
51
|
+
: { line: "Change only the files you need, by name, instead." };
|
|
52
|
+
}
|
|
46
53
|
export function isLocalIrreversibleVerb(verb) {
|
|
47
54
|
return Object.prototype.hasOwnProperty.call(LOCAL_IRREVERSIBLE_VERBS, verb);
|
|
48
55
|
}
|
|
@@ -140,7 +147,8 @@ export function basicActionDef(actionKey, kind = "change") {
|
|
|
140
147
|
kind: "delete",
|
|
141
148
|
appliesTo: "platform",
|
|
142
149
|
label: LOCAL_IRREVERSIBLE_VERBS[parsed.name],
|
|
143
|
-
irreversible: true
|
|
150
|
+
irreversible: true,
|
|
151
|
+
steer: localSteer(parsed.name)
|
|
144
152
|
};
|
|
145
153
|
}
|
|
146
154
|
return {
|
|
@@ -10,5 +10,6 @@ export declare const CP_DECIDE_CLI_PATH = "/api/cp/decide/cli";
|
|
|
10
10
|
/** Ask Passport about one verb. Never throws. */
|
|
11
11
|
export declare function askCliVerb(api: ApiCall, vendor: string, verb: string, extra: {
|
|
12
12
|
sessionId?: string | undefined;
|
|
13
|
+
exec?: true;
|
|
13
14
|
}, signal: AbortSignal): Promise<CpAnswer>;
|
|
14
15
|
export {};
|
package/dist/controlPlaneCli.js
CHANGED
|
@@ -24,6 +24,7 @@ export async function askCliVerb(api, vendor, verb, extra, signal) {
|
|
|
24
24
|
verb,
|
|
25
25
|
interface: "cli",
|
|
26
26
|
requestId,
|
|
27
|
+
...(extra.exec ? { exec: true } : {}),
|
|
27
28
|
...(extra.sessionId && SESSION.test(extra.sessionId) ? { sessionId: extra.sessionId } : {})
|
|
28
29
|
}),
|
|
29
30
|
signal: AbortSignal.any([signal, AbortSignal.timeout(CLI_DECIDE_TIMEOUT_MS)])
|
package/dist/controlPlaneExec.js
CHANGED
|
@@ -33,7 +33,12 @@ export function execIdsWanted(vendor, decided, links = false) {
|
|
|
33
33
|
return true;
|
|
34
34
|
if (vendor === "railway")
|
|
35
35
|
return typeof decided.controlPlane?.eventId === "string";
|
|
36
|
-
return vendor === "supabase" && decided.controlPlane?.supabase === true;
|
|
36
|
+
return vendor === "supabase" && (decided.controlPlane?.supabase === true || serverDecided(decided));
|
|
37
|
+
}
|
|
38
|
+
/** Supabase decided by Passport at authorize: its decision's id came back, and the CLI doesn't decide it again. */
|
|
39
|
+
function serverDecided(decided) {
|
|
40
|
+
const eventId = decided.controlPlane?.eventId;
|
|
41
|
+
return decided.controlPlane?.supabase === false && typeof eventId === "string" && EVENT_ID.test(eventId);
|
|
37
42
|
}
|
|
38
43
|
const keptOutput = (capture) => (capture ? `${capture.stdout.kept()}\n${capture.stderr.kept()}` : "");
|
|
39
44
|
/** Railway: the deployment the command started, attached to the decision Passport made at authorize. */
|
|
@@ -154,6 +159,11 @@ async function execSupabase(fetchApi, prepared, decided, bounded, env) {
|
|
|
154
159
|
const bundle = supabase.classifySupabaseArgv(["supabase", ...prepared.rest], { cwd: prepared.cwd, env });
|
|
155
160
|
if (!bundle)
|
|
156
161
|
return NO_IDS;
|
|
162
|
+
const nodeIds = bundle.found.flatMap((found) => [found.nodeId, ...(found.nodes ?? []).map((node) => node.id)]);
|
|
163
|
+
// Passport decided it at authorize: the ids go to that decision, and nothing is asked again.
|
|
164
|
+
const serverEvent = decided.controlPlane?.supabase === false ? decided.controlPlane.eventId : undefined;
|
|
165
|
+
if (typeof serverEvent === "string" && EVENT_ID.test(serverEvent))
|
|
166
|
+
return supabaseIds(fetchApi, prepared, { eventId: serverEvent }, nodeIds);
|
|
157
167
|
const { supabaseHandoffKey, takeSupabaseDecision } = await import("./supabaseDecisions.js");
|
|
158
168
|
let requestId = takeSupabaseDecision(supabaseHandoffKey(bundle.found));
|
|
159
169
|
if (!requestId) {
|
|
@@ -165,9 +175,10 @@ async function execSupabase(fetchApi, prepared, decided, bounded, env) {
|
|
|
165
175
|
await (await import("./controlPlaneLate.js")).tellLate((path, init) => fetchApi(path, init), asked.answer.late);
|
|
166
176
|
requestId = asked.answer.kind === "allow" && asked.answer.eventId ? asked.requestId : null;
|
|
167
177
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
178
|
+
return requestId ? supabaseIds(fetchApi, prepared, { requestId }, nodeIds) : NO_IDS;
|
|
179
|
+
}
|
|
180
|
+
/** Once a decided supabase command ran, the ids it printed go to its decision. */
|
|
181
|
+
function supabaseIds(fetchApi, prepared, decision, nodeIds) {
|
|
171
182
|
return {
|
|
172
183
|
report: async (capture, exitCode) => {
|
|
173
184
|
if (exitCode !== 0)
|
|
@@ -175,7 +186,7 @@ async function execSupabase(fetchApi, prepared, decided, bounded, env) {
|
|
|
175
186
|
const { migrationDigests, reportPlatformIds, supabaseOutputIds } = await import("./controlPlaneIds.js");
|
|
176
187
|
const ids = supabaseOutputIds(prepared.rest, keptOutput(capture), nodeIds);
|
|
177
188
|
// The statements of the migrations it applied, fingerprinted as the Postgres-log feed fingerprints them.
|
|
178
|
-
await reportPlatformIds(fetchApi,
|
|
189
|
+
await reportPlatformIds(fetchApi, decision, ids, undefined, migrationDigests(prepared.cwd, ids));
|
|
179
190
|
}
|
|
180
191
|
};
|
|
181
192
|
}
|
|
@@ -188,7 +199,7 @@ export async function execControlPlaneRefusal(fetchApi, prepared, decided, timeo
|
|
|
188
199
|
return NO_IDS;
|
|
189
200
|
if (prepared.vendor === "railway")
|
|
190
201
|
return railwayIds(fetchApi, prepared, decided);
|
|
191
|
-
if (prepared.vendor === "supabase" && decided.controlPlane?.supabase === true) {
|
|
202
|
+
if (prepared.vendor === "supabase" && (decided.controlPlane?.supabase === true || serverDecided(decided))) {
|
|
192
203
|
const bounded = signal ? AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
|
|
193
204
|
return execSupabase(fetchApi, prepared, decided, bounded, options.env ?? process.env);
|
|
194
205
|
}
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* here; the bridge copies all five (scripts/generate-control-plane-classifier.mjs).
|
|
21
21
|
*/
|
|
22
22
|
import type { GithubClassification, GithubContext, GithubRequest } from "./controlPlaneGithubCatalog.generated.js";
|
|
23
|
-
export { githubNodeIds, githubTarget, globMatch, MAX_BRANCH_MATCH_LENGTH, overlongBranchNode, matchBranch, normalizeHead, type GithubClassification, type GithubContext, type GithubRepo, type GithubRequest } from "./controlPlaneGithubCatalog.generated.js";
|
|
24
|
-
export { classifyGitPushRefs, githubPushRefs, worstCasePush, type CliArgs, type GithubCliArgs, type GithubPush, type PushRef } from "./controlPlaneGithubCli.generated.js";
|
|
23
|
+
export { githubNodeIds, githubTarget, globMatch, MAX_BRANCH_MATCH_LENGTH, overlongBranchNode, matchBranch, normalizeHead, type GithubClassification, type GithubContext, type GithubRepo, type GithubRequest, unclassifiedGh } from "./controlPlaneGithubCatalog.generated.js";
|
|
24
|
+
export { classifyGitPushRefs, ghApiMethod, githubPushRefs, worstCasePush, type CliArgs, type GithubCliArgs, type GithubPush, type PushRef } from "./controlPlaneGithubCli.generated.js";
|
|
25
25
|
export { classifyGithubEvent, outsideVia, type GithubEvent, type GithubEventClassification } from "./controlPlaneGithubWebhook.generated.js";
|
|
26
26
|
/**
|
|
27
27
|
* Every consequential thing one request does, in order: one entry, except a
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { classifyApi, classifyMcp } from "./controlPlaneGithubApi.generated.js";
|
|
24
24
|
import { classifyCli, pushRank } from "./controlPlaneGithubCli.generated.js";
|
|
25
|
-
export { githubNodeIds, githubTarget, globMatch, MAX_BRANCH_MATCH_LENGTH, overlongBranchNode, matchBranch, normalizeHead } from "./controlPlaneGithubCatalog.generated.js";
|
|
26
|
-
export { classifyGitPushRefs, githubPushRefs, worstCasePush } from "./controlPlaneGithubCli.generated.js";
|
|
25
|
+
export { githubNodeIds, githubTarget, globMatch, MAX_BRANCH_MATCH_LENGTH, overlongBranchNode, matchBranch, normalizeHead, unclassifiedGh } from "./controlPlaneGithubCatalog.generated.js";
|
|
26
|
+
export { classifyGitPushRefs, ghApiMethod, githubPushRefs, worstCasePush } from "./controlPlaneGithubCli.generated.js";
|
|
27
27
|
export { classifyGithubEvent, outsideVia } from "./controlPlaneGithubWebhook.generated.js";
|
|
28
28
|
/* ------------------------------------------------------------------ */
|
|
29
29
|
/* Entry point: a request */
|
|
@@ -77,6 +77,7 @@ export const GITHUB_ACTION_ICON = {
|
|
|
77
77
|
"github.repo.delete": "trash",
|
|
78
78
|
"github.repo.workflow": "server",
|
|
79
79
|
"github.repo.change": "repo",
|
|
80
|
+
"github.unclassified": "trash",
|
|
80
81
|
"github.branch.push": "repo-push",
|
|
81
82
|
"github.branch.force": "trash",
|
|
82
83
|
"github.branch.delete": "trash",
|
|
@@ -76,6 +76,9 @@ export declare function githubTarget(fields: TargetFields, primary: string): str
|
|
|
76
76
|
export declare const withTarget: (found: GithubClassification, target: string | undefined) => GithubClassification;
|
|
77
77
|
export declare function withoutTarget(found: GithubClassification): GithubClassification;
|
|
78
78
|
export declare const onRepo: (r: Repo, actionKey: string, summary: string, target?: string) => GithubClassification;
|
|
79
|
+
/** Fails closed: a `gh` command Passport can't name, a Delete on its repository (on Repositories when none is
|
|
80
|
+
* known). No target, so no Allow once is tied to anything narrower than the node. */
|
|
81
|
+
export declare const unclassifiedGh: (r: Repo | null) => GithubClassification;
|
|
79
82
|
/** The branch's own node, its most specific pattern node, or the repository when no node matches. */
|
|
80
83
|
export declare function branchTarget(r: Repo, branch: string, context: BranchContext): string;
|
|
81
84
|
export type BranchVerb = "push" | "force" | "delete";
|
|
@@ -129,6 +129,19 @@ export function withoutTarget(found) {
|
|
|
129
129
|
return rest;
|
|
130
130
|
}
|
|
131
131
|
export const onRepo = (r, actionKey, summary, target) => withTarget({ nodeId: repoNode(r.owner, r.repo), actionKey, summary }, target);
|
|
132
|
+
/** Fails closed: a `gh` command Passport can't name, a Delete on its repository (on Repositories when none is
|
|
133
|
+
* known). No target, so no Allow once is tied to anything narrower than the node. */
|
|
134
|
+
export const unclassifiedGh = (r) => r
|
|
135
|
+
? {
|
|
136
|
+
nodeId: repoNode(r.owner, r.repo),
|
|
137
|
+
actionKey: "github.unclassified",
|
|
138
|
+
summary: `Run a gh command Passport can't name in ${slug(r)}`
|
|
139
|
+
}
|
|
140
|
+
: {
|
|
141
|
+
nodeId: githubNodeIds.repos,
|
|
142
|
+
actionKey: "github.unclassified",
|
|
143
|
+
summary: "Run a gh command Passport can't name"
|
|
144
|
+
};
|
|
132
145
|
/** The branch's own node, its most specific pattern node, or the repository when no node matches. */
|
|
133
146
|
export function branchTarget(r, branch, context) {
|
|
134
147
|
const known = [...context.knownBranches(r.owner, r.repo)];
|
|
@@ -15,6 +15,15 @@ export declare const GH_GLOBAL: Set<string>;
|
|
|
15
15
|
export declare const GH_VALUES: Record<string, ReadonlySet<string>>;
|
|
16
16
|
/** `-F` fields are typed (true, false, null, integers); `-f` fields are strings. */
|
|
17
17
|
export declare function typedField(raw: string): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* How `gh api` is read when Passport can't name what it does: a read is GET or HEAD (no method, or one of those,
|
|
20
|
+
* and with no method no fields, as gh then sends a POST), never decided; any other method, or a body from `--input`,
|
|
21
|
+
* is a write. Exec reads only this (`passport exec` sends the method, never the arguments).
|
|
22
|
+
*/
|
|
23
|
+
export declare function ghApiMethod(parsed: Parsed): {
|
|
24
|
+
method: string;
|
|
25
|
+
read: boolean;
|
|
26
|
+
};
|
|
18
27
|
export declare function ghApi(parsed: Parsed, args: CliArgs, context: GithubContext): GithubClassification | null;
|
|
19
28
|
/** A command line as the classifier reads it: the words, and where it runs. */
|
|
20
29
|
export type GithubCliArgs = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by scripts/generate-control-plane-classifier.mjs. Do not edit.
|
|
2
2
|
/** GitHub classifier: `gh` and `git push` command lines. Part of controlPlaneGithub.ts. */
|
|
3
|
-
import { changeSecret, deleteRepo, eventBranch, githubTarget, makePublic, merge, numberOf, onBranch, onRepo, parseRepoRef, release, tag, withoutTarget } from "./controlPlaneGithubCatalog.generated.js";
|
|
4
|
-
import { classifyApi, OPAQUE_BODY } from "./controlPlaneGithubApi.generated.js";
|
|
3
|
+
import { changeSecret, deleteRepo, eventBranch, githubTarget, makePublic, merge, numberOf, onBranch, onRepo, parseRepoRef, release, tag, unclassifiedGh, withoutTarget } from "./controlPlaneGithubCatalog.generated.js";
|
|
4
|
+
import { apiSegments, classifyApi, OPAQUE_BODY } from "./controlPlaneGithubApi.generated.js";
|
|
5
5
|
/** Words and options of one command. `valueFlags` are the options that take the next word as their value. */
|
|
6
6
|
export function parseArgs(args, valueFlags) {
|
|
7
7
|
const parsed = { pos: [], opts: [] };
|
|
@@ -65,13 +65,36 @@ export function typedField(raw) {
|
|
|
65
65
|
return false;
|
|
66
66
|
return /^\d+$/.test(raw) ? Number(raw) : raw;
|
|
67
67
|
}
|
|
68
|
+
const FIELD_FLAGS = ["-f", "--raw-field", "-F", "--field"];
|
|
69
|
+
/**
|
|
70
|
+
* How `gh api` is read when Passport can't name what it does: a read is GET or HEAD (no method, or one of those,
|
|
71
|
+
* and with no method no fields, as gh then sends a POST), never decided; any other method, or a body from `--input`,
|
|
72
|
+
* is a write. Exec reads only this (`passport exec` sends the method, never the arguments).
|
|
73
|
+
*/
|
|
74
|
+
export function ghApiMethod(parsed) {
|
|
75
|
+
const explicit = lastValue(parsed, "-X", "--method")?.toUpperCase();
|
|
76
|
+
const fields = hasFlag(parsed, ...FIELD_FLAGS);
|
|
77
|
+
const input = hasFlag(parsed, "--input");
|
|
78
|
+
const method = explicit ?? (fields || input ? "POST" : "GET");
|
|
79
|
+
return { method, read: (method === "GET" || method === "HEAD") && !input };
|
|
80
|
+
}
|
|
81
|
+
/** The repository a `gh api` call is about: its path's, else `-R`, else the folder's. */
|
|
82
|
+
function apiRepo(path, parsed, args, context) {
|
|
83
|
+
const [root, owner, repo] = path ? apiSegments(path) : [];
|
|
84
|
+
if (root === "repos" && owner && repo && !/[{}]/.test(owner + repo))
|
|
85
|
+
return { owner, repo };
|
|
86
|
+
const flag = lastValue(parsed, "-R", "--repo");
|
|
87
|
+
return flag !== undefined ? parseRepoRef(flag, context.org) : (args.cwdRepo ?? null);
|
|
88
|
+
}
|
|
68
89
|
export function ghApi(parsed, args, context) {
|
|
69
90
|
const raw = parsed.pos[1];
|
|
91
|
+
const { method, read } = ghApiMethod(parsed);
|
|
92
|
+
// Unparseable (no endpoint, or a placeholder gh fills in that Passport can't): fails closed.
|
|
70
93
|
if (raw === undefined)
|
|
71
|
-
return
|
|
94
|
+
return unclassifiedGh(apiRepo(undefined, parsed, args, context));
|
|
72
95
|
const path = raw.replace(/\{(owner|repo|branch)\}/g, (placeholder, key) => (key === "branch" ? args.currentBranch : args.cwdRepo?.[key]) ?? placeholder);
|
|
73
96
|
if (/\{(owner|repo|branch)\}/.test(path))
|
|
74
|
-
return null;
|
|
97
|
+
return read ? null : unclassifiedGh(apiRepo(undefined, parsed, args, context));
|
|
75
98
|
const body = {};
|
|
76
99
|
const fields = [
|
|
77
100
|
["-f", false],
|
|
@@ -86,13 +109,18 @@ export function ghApi(parsed, args, context) {
|
|
|
86
109
|
body[entry.slice(0, eq)] = typed ? typedField(entry.slice(eq + 1)) : entry.slice(eq + 1);
|
|
87
110
|
}
|
|
88
111
|
}
|
|
89
|
-
const explicit = lastValue(parsed, "-X", "--method");
|
|
90
112
|
// With --input the body comes from a file (any -f fields go to the query string): unknown here.
|
|
91
113
|
const opaque = hasFlag(parsed, "--input");
|
|
92
|
-
const method = explicit ?? (Object.keys(body).length > 0 || opaque ? "POST" : "GET");
|
|
93
114
|
const found = classifyApi(method, path, opaque ? OPAQUE_BODY : body, context);
|
|
94
115
|
// Fail closed: no target to tie an "Allow once" to, so none is offered for this block.
|
|
95
|
-
|
|
116
|
+
if (found)
|
|
117
|
+
return opaque ? withoutTarget(found) : found;
|
|
118
|
+
// Named nothing: a read isn't decided; any write is Passport's Unclassified action on its repository. A GraphQL
|
|
119
|
+
// call is a POST either way: a query (anything but a mutation, from fields Passport can read) is a read.
|
|
120
|
+
const query = path.replace(/^\/+/, "") === "graphql" && !opaque && typeof body.query === "string" ? body.query : null;
|
|
121
|
+
if (query !== null && !/^\s*mutation\b/i.test(query))
|
|
122
|
+
return null;
|
|
123
|
+
return read ? null : unclassifiedGh(apiRepo(path, parsed, args, context));
|
|
96
124
|
}
|
|
97
125
|
export function classifyGh(args, context) {
|
|
98
126
|
const words = parseArgs(args.argv.slice(1), GH_GLOBAL).pos;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* and Managed coverage with Followed. Platform-free; part of the contract with `controlPlane.ts`,
|
|
5
5
|
* changed only through the orchestrating session.
|
|
6
6
|
*/
|
|
7
|
-
import { type ActionEvent, type Coverage, type Kind, type PlatformId, type PlatformKey, type PlatformMode, type ResourceNode, type Surface } from "./controlPlane.generated.js";
|
|
7
|
+
import { type ActionDef, type ActionEvent, type ControlRule, type Coverage, type Kind, type PlatformId, type PlatformKey, type PlatformMode, type ResourceNode, type Surface } from "./controlPlane.generated.js";
|
|
8
8
|
/** The kind removed 2026-11-14 (v19): stored rules and events that name it read as `change` (`currentKind`). */
|
|
9
9
|
export declare const RETIRED_KINDS: Readonly<Record<string, Kind>>;
|
|
10
10
|
/** A stored kind as today's list names it: a retired kind maps to its replacement; undefined when unknown. */
|
|
@@ -74,3 +74,32 @@ export type ManagedCoverage = Coverage & {
|
|
|
74
74
|
* everything else. App traffic and events on an account Passport isn't connected to are left out.
|
|
75
75
|
*/
|
|
76
76
|
export declare function managedCoverageOf(events: readonly (Pick<ActionEvent, "through" | "platform"> & Partial<Pick<ActionEvent, "outcome" | "surface" | "cause" | "notConnected">>)[], observed: boolean): ManagedCoverage;
|
|
77
|
+
export type ActionSteer = NonNullable<ActionDef["steer"]>;
|
|
78
|
+
/** A steer line is one sentence naming the allowed way to finish: capitalized, saying "instead", ending in a full
|
|
79
|
+
* stop, short, straight quotes only (agent and terminal text). */
|
|
80
|
+
export declare const STEER_MAX_LENGTH = 80;
|
|
81
|
+
export declare function steerLineValid(line: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The line a block message adds, or undefined: the action's `steer`, dropped when its `check` action would be
|
|
84
|
+
* blocked where the agent would take that path, so a steer never points at another block. `self` resolves on the
|
|
85
|
+
* blocked node's path; `sibling` where a new resource of the action's type would be decided (the node's parent when
|
|
86
|
+
* the node is of that type, a pushed branch's repository otherwise). An unknown check action drops the line.
|
|
87
|
+
*/
|
|
88
|
+
export declare function steerFor(action: Pick<ActionDef, "steer" | "appliesTo">, path: readonly Pick<ResourceNode, "id" | "type">[], rules: readonly ControlRule[], actionOf: (key: string) => Pick<ActionDef, "key" | "kind"> | undefined): string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Whether a rule could have stopped this event: Passport decided it, or its own credential ran it with no decision
|
|
91
|
+
* ("undecided"). Every rehearsal ("would have blocked N": the rule sheet, Rules, a node's Rules tab, the Turn on
|
|
92
|
+
* blocking review) counts only these, so a rule never looks stronger than it is.
|
|
93
|
+
*/
|
|
94
|
+
export declare function ruleCouldBlock(event: Pick<ActionEvent, "through">): boolean;
|
|
95
|
+
/** Went around Passport, so no rule can block it: Unmanaged, not Followed, not app traffic, not on an account
|
|
96
|
+
* Passport isn't connected to. A rehearsal names these on their own line ("Rules would also block N that went around Passport."). */
|
|
97
|
+
export declare function wentAround(event: Pick<ActionEvent, "through" | "surface" | "cause" | "platform"> & {
|
|
98
|
+
notConnected?: boolean;
|
|
99
|
+
}): boolean;
|
|
100
|
+
/** Core loop 3: branch-name prefixes agents create their own branches under. Suggested rules (S2, "Agents' own
|
|
101
|
+
* branches") only ever name these: `feature/` and the like can be people's branches, and letting agents force-push
|
|
102
|
+
* them could destroy someone's work. */
|
|
103
|
+
export declare const AGENT_BRANCH_PREFIXES: readonly ["claude/", "codex/", "cursor/", "copilot/"];
|
|
104
|
+
/** The agent prefix a branch sits under, or null. */
|
|
105
|
+
export declare function agentBranchPrefix(branch: string): (typeof AGENT_BRANCH_PREFIXES)[number] | null;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* and Managed coverage with Followed. Platform-free; part of the contract with `controlPlane.ts`,
|
|
6
6
|
* changed only through the orchestrating session.
|
|
7
7
|
*/
|
|
8
|
-
import { KINDS } from "./controlPlane.generated.js";
|
|
8
|
+
import { KINDS, resolveRule } from "./controlPlane.generated.js";
|
|
9
9
|
/* ------------------------------------------------------------------ */
|
|
10
10
|
/* Kinds and modes (v19) */
|
|
11
11
|
/* ------------------------------------------------------------------ */
|
|
@@ -163,3 +163,53 @@ export function managedCoverageOf(events, observed) {
|
|
|
163
163
|
notConnectedExcluded
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
+
/** A steer line is one sentence naming the allowed way to finish: capitalized, saying "instead", ending in a full
|
|
167
|
+
* stop, short, straight quotes only (agent and terminal text). */
|
|
168
|
+
export const STEER_MAX_LENGTH = 80;
|
|
169
|
+
export function steerLineValid(line) {
|
|
170
|
+
return (line.length <= STEER_MAX_LENGTH && /^[A-Z][^\n\u2018\u2019\u201c\u201d]*\.$/.test(line) && / instead\b/.test(line));
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The line a block message adds, or undefined: the action's `steer`, dropped when its `check` action would be
|
|
174
|
+
* blocked where the agent would take that path, so a steer never points at another block. `self` resolves on the
|
|
175
|
+
* blocked node's path; `sibling` where a new resource of the action's type would be decided (the node's parent when
|
|
176
|
+
* the node is of that type, a pushed branch's repository otherwise). An unknown check action drops the line.
|
|
177
|
+
*/
|
|
178
|
+
export function steerFor(action, path, rules, actionOf) {
|
|
179
|
+
const steer = action.steer;
|
|
180
|
+
if (!steer?.check)
|
|
181
|
+
return steer?.line;
|
|
182
|
+
const checked = actionOf(steer.check.action);
|
|
183
|
+
const at = steer.check.at === "sibling" && path[0]?.type === action.appliesTo ? path.slice(1) : path;
|
|
184
|
+
if (!checked || !at.length)
|
|
185
|
+
return undefined;
|
|
186
|
+
return resolveRule(at.map((node) => node.id), checked, rules).decision === "block"
|
|
187
|
+
? undefined
|
|
188
|
+
: steer.line;
|
|
189
|
+
}
|
|
190
|
+
/* ------------------------------------------------------------------ */
|
|
191
|
+
/* Core loop 2: what a rule could have blocked */
|
|
192
|
+
/* ------------------------------------------------------------------ */
|
|
193
|
+
/**
|
|
194
|
+
* Whether a rule could have stopped this event: Passport decided it, or its own credential ran it with no decision
|
|
195
|
+
* ("undecided"). Every rehearsal ("would have blocked N": the rule sheet, Rules, a node's Rules tab, the Turn on
|
|
196
|
+
* blocking review) counts only these, so a rule never looks stronger than it is.
|
|
197
|
+
*/
|
|
198
|
+
export function ruleCouldBlock(event) {
|
|
199
|
+
return event.through === "passport";
|
|
200
|
+
}
|
|
201
|
+
/** Went around Passport, so no rule can block it: Unmanaged, not Followed, not app traffic, not on an account
|
|
202
|
+
* Passport isn't connected to. A rehearsal names these on their own line ("Rules would also block N that went around Passport."). */
|
|
203
|
+
export function wentAround(event) {
|
|
204
|
+
if (event.through !== "outside" || event.notConnected === true || event.surface === "app")
|
|
205
|
+
return false;
|
|
206
|
+
return !(event.cause?.through === "passport" && event.cause.platform === event.platform);
|
|
207
|
+
}
|
|
208
|
+
/** Core loop 3: branch-name prefixes agents create their own branches under. Suggested rules (S2, "Agents' own
|
|
209
|
+
* branches") only ever name these: `feature/` and the like can be people's branches, and letting agents force-push
|
|
210
|
+
* them could destroy someone's work. */
|
|
211
|
+
export const AGENT_BRANCH_PREFIXES = ["claude/", "codex/", "cursor/", "copilot/"];
|
|
212
|
+
/** The agent prefix a branch sits under, or null. */
|
|
213
|
+
export function agentBranchPrefix(branch) {
|
|
214
|
+
return AGENT_BRANCH_PREFIXES.find((prefix) => branch.startsWith(prefix) && branch.length > prefix.length) ?? null;
|
|
215
|
+
}
|
package/dist/pluginPin.d.ts
CHANGED
package/dist/pluginPin.js
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.39.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Keep in lockstep with bridge/package.json.
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.39.0";
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passport-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "passport-bridge",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.39.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.32.1"
|