passport-bridge 0.13.2 → 0.14.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 +92 -17
- package/dist/cli.js +4 -3
- package/dist/cliArgs.d.ts +1 -1
- package/dist/cliArgs.js +21 -5
- package/dist/cliAutopilot.d.ts +60 -0
- package/dist/cliAutopilot.js +389 -0
- package/dist/cliAutopilotPolicy.d.ts +94 -0
- package/dist/cliAutopilotPolicy.js +193 -0
- package/dist/cliClient.d.ts +7 -0
- package/dist/cliClient.js +36 -19
- package/dist/cliHook.d.ts +20 -9
- package/dist/cliHook.js +125 -32
- package/dist/cliHookClassify.d.ts +3 -0
- package/dist/cliHookClassify.js +2 -1
- package/dist/cliHookDecide.d.ts +89 -0
- package/dist/cliHookDecide.js +167 -0
- package/dist/cliHookEnvironment.d.ts +55 -0
- package/dist/cliHookEnvironment.js +219 -0
- package/dist/cliHookGuard.d.ts +61 -12
- package/dist/cliHookGuard.js +211 -24
- package/dist/cliHookInstall.js +19 -4
- package/dist/cliHookMode.d.ts +31 -0
- package/dist/cliHookMode.js +50 -0
- package/dist/cliHookRedact.d.ts +16 -0
- package/dist/cliHookRedact.js +136 -0
- package/dist/cliInit.d.ts +4 -1
- package/dist/cliInit.js +10 -3
- package/dist/cliLogin.js +18 -2
- package/dist/cliOffline.js +9 -9
- package/dist/cliOutput.js +11 -5
- package/dist/cliPolicy.d.ts +11 -3
- package/dist/cliPolicy.js +5 -2
- package/dist/cliPolicyV2.d.ts +18 -0
- package/dist/cliPolicyV2.js +234 -0
- package/dist/cliSetupOrg.d.ts +15 -0
- package/dist/cliSetupOrg.js +241 -0
- package/dist/cliSupport.d.ts +4 -0
- package/dist/cliSupport.js +12 -9
- package/dist/completion.js +12 -3
- package/dist/doctor.js +3 -3
- package/dist/enrollment.d.ts +18 -0
- package/dist/enrollment.js +79 -0
- package/dist/hookPlugin.d.ts +7 -0
- package/dist/hookPlugin.js +54 -0
- package/dist/initAgents.d.ts +3 -1
- package/dist/initAgents.js +7 -3
- package/dist/initAutopilotStep.d.ts +24 -0
- package/dist/initAutopilotStep.js +257 -0
- package/dist/initLocalSteps.d.ts +3 -0
- package/dist/initLocalSteps.js +30 -5
- package/dist/initState.d.ts +24 -0
- package/dist/initUi.js +5 -0
- package/dist/passport.js +27 -3
- package/dist/pluginPin.d.ts +7 -0
- package/dist/pluginPin.js +7 -0
- package/dist/universalUrl.d.ts +28 -0
- package/dist/universalUrl.js +59 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which environment a CLI command acts on, read from its own flags.
|
|
3
|
+
*
|
|
4
|
+
* Only flags each vendor documents are read. The name is matched against
|
|
5
|
+
* Passport's naming rules (production, staging, development) and anything
|
|
6
|
+
* Passport can't place counts as Production. A command with no flag acts on
|
|
7
|
+
* whatever the folder is linked to, which the hook can't see, so it counts as
|
|
8
|
+
* Production too and says so in its cause.
|
|
9
|
+
*
|
|
10
|
+
* Local only: the name never leaves this machine. Reports carry the kind.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ENV_KINDS: readonly ["production", "staging", "development"];
|
|
13
|
+
export type EnvKind = (typeof ENV_KINDS)[number];
|
|
14
|
+
/** How the kind was found: from a flag's name, the vendor's own default, or
|
|
15
|
+
* nothing at all (assumed Production). */
|
|
16
|
+
export type EnvSource = "flag" | "vendor-default" | "assumed";
|
|
17
|
+
export type EnvHint = {
|
|
18
|
+
kind: EnvKind;
|
|
19
|
+
source: EnvSource;
|
|
20
|
+
/** The name that placed it, such as `qa` or `preview`: an environment name
|
|
21
|
+
* the server can map, never a path, host, or other argument. */
|
|
22
|
+
name?: string;
|
|
23
|
+
};
|
|
24
|
+
/** The map's naming rule: production first, then staging, then development. */
|
|
25
|
+
export declare function kindOfName(name: string): EnvKind | undefined;
|
|
26
|
+
export declare function isEnvKind(value: unknown): value is EnvKind;
|
|
27
|
+
/**
|
|
28
|
+
* The environment one vendor command acts on. `args` are the words after the
|
|
29
|
+
* program name, as the classifier saw them.
|
|
30
|
+
*/
|
|
31
|
+
export declare function environmentHint(vendor: string, args: string[]): EnvHint;
|
|
32
|
+
export type EnvironmentContext = {
|
|
33
|
+
/** cli-policy v2 `environmentFlags`: a flag either names a kind itself
|
|
34
|
+
* (`--prod`) or takes the environment's name as its value. */
|
|
35
|
+
flags?: Record<string, Array<{
|
|
36
|
+
flag: string;
|
|
37
|
+
value?: EnvKind;
|
|
38
|
+
}>>;
|
|
39
|
+
/** Environments the workspace placed, so `qa` can be Staging if an admin
|
|
40
|
+
* said so, whatever its name suggests. */
|
|
41
|
+
known?: Array<{
|
|
42
|
+
vendor: string;
|
|
43
|
+
name: string;
|
|
44
|
+
kind: EnvKind;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The built-in hint, with the server's extra flags filling a gap and the
|
|
49
|
+
* workspace's own placement of a named environment winning over its name.
|
|
50
|
+
*/
|
|
51
|
+
export declare function environmentHintWith(vendor: string, args: string[], context?: EnvironmentContext): EnvHint;
|
|
52
|
+
/** What the server is told: a short environment name it can map, the kind
|
|
53
|
+
* when only that is known, or nothing when Production was assumed. */
|
|
54
|
+
export declare function reportedEnvironment(hint: EnvHint): string | undefined;
|
|
55
|
+
export declare const ENV_LABEL: Record<EnvKind, string>;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which environment a CLI command acts on, read from its own flags.
|
|
3
|
+
*
|
|
4
|
+
* Only flags each vendor documents are read. The name is matched against
|
|
5
|
+
* Passport's naming rules (production, staging, development) and anything
|
|
6
|
+
* Passport can't place counts as Production. A command with no flag acts on
|
|
7
|
+
* whatever the folder is linked to, which the hook can't see, so it counts as
|
|
8
|
+
* Production too and says so in its cause.
|
|
9
|
+
*
|
|
10
|
+
* Local only: the name never leaves this machine. Reports carry the kind.
|
|
11
|
+
*/
|
|
12
|
+
export const ENV_KINDS = ["production", "staging", "development"];
|
|
13
|
+
// The same rules as `environmentKindFromName` in shared/autopilotContract.ts.
|
|
14
|
+
const PRODUCTION = /prod|production|live|main/i;
|
|
15
|
+
const STAGING = /stag|qa|uat|preview/i;
|
|
16
|
+
const DEVELOPMENT = /dev|local|test|sandbox|feature|branch/i;
|
|
17
|
+
const LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]", "0.0.0.0", "host.docker.internal"]);
|
|
18
|
+
/** The map's naming rule: production first, then staging, then development. */
|
|
19
|
+
export function kindOfName(name) {
|
|
20
|
+
const value = name.trim();
|
|
21
|
+
if (!value)
|
|
22
|
+
return undefined;
|
|
23
|
+
if (PRODUCTION.test(value))
|
|
24
|
+
return "production";
|
|
25
|
+
if (STAGING.test(value))
|
|
26
|
+
return "staging";
|
|
27
|
+
if (DEVELOPMENT.test(value))
|
|
28
|
+
return "development";
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
export function isEnvKind(value) {
|
|
32
|
+
return typeof value === "string" && ENV_KINDS.includes(value);
|
|
33
|
+
}
|
|
34
|
+
const VENDOR_FLAGS = {
|
|
35
|
+
// railway up|redeploy|logs|variables … -e, --environment <name>
|
|
36
|
+
railway: { names: ["--environment"], short: ["-e"] },
|
|
37
|
+
// wrangler deploy|secret … -e, --env <name>
|
|
38
|
+
wrangler: { names: ["--env"], short: ["-e"] },
|
|
39
|
+
// sentry-cli releases deploys <v> new -e <env>
|
|
40
|
+
"sentry-cli": { names: ["--env"], short: ["-e"] },
|
|
41
|
+
// vercel deploy --target <env>; vercel env pull --environment <env>
|
|
42
|
+
vercel: { names: ["--target", "--environment"] },
|
|
43
|
+
// fly and heroku name apps, which often carry the environment
|
|
44
|
+
flyctl: { names: ["--app"], short: ["-a"] },
|
|
45
|
+
fly: { names: ["--app"], short: ["-a"] },
|
|
46
|
+
heroku: { names: ["--app"], short: ["-a"] },
|
|
47
|
+
// supabase --project-ref <ref>; branches by name
|
|
48
|
+
supabase: { names: ["--project-ref", "--branch"] },
|
|
49
|
+
kubectl: { names: ["--context", "--namespace"], short: ["-n"] },
|
|
50
|
+
k: { names: ["--context", "--namespace"], short: ["-n"] },
|
|
51
|
+
helm: { names: ["--kube-context", "--namespace"], short: ["-n"] },
|
|
52
|
+
aws: { names: ["--profile"] },
|
|
53
|
+
gcloud: { names: ["--project"] },
|
|
54
|
+
terraform: { names: ["-var-file"] },
|
|
55
|
+
tf: { names: ["-var-file"] }
|
|
56
|
+
};
|
|
57
|
+
/** Any vendor: these long flags always name an environment or branch. */
|
|
58
|
+
const GENERIC_FLAGS = ["--environment", "--branch"];
|
|
59
|
+
function flagValue(args, names, short = []) {
|
|
60
|
+
for (let index = 0; index < args.length; index++) {
|
|
61
|
+
const arg = args[index];
|
|
62
|
+
for (const name of names) {
|
|
63
|
+
if (arg === name && args[index + 1] !== undefined && !args[index + 1].startsWith("-"))
|
|
64
|
+
return args[index + 1];
|
|
65
|
+
if (arg.startsWith(`${name}=`))
|
|
66
|
+
return arg.slice(name.length + 1);
|
|
67
|
+
}
|
|
68
|
+
for (const flag of short) {
|
|
69
|
+
if (arg === flag && args[index + 1] !== undefined && !args[index + 1].startsWith("-"))
|
|
70
|
+
return args[index + 1];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
function named(name, source = "flag") {
|
|
76
|
+
return { kind: kindOfName(name) ?? "production", source: kindOfName(name) ? source : "assumed", name };
|
|
77
|
+
}
|
|
78
|
+
function hostOf(raw) {
|
|
79
|
+
try {
|
|
80
|
+
return new URL(raw).hostname.toLowerCase();
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** psql: a local host is Development; otherwise the host name decides. */
|
|
87
|
+
function psqlHint(args) {
|
|
88
|
+
const host = flagValue(args, ["--host"], ["-h"]) ??
|
|
89
|
+
args.map((arg) => (/^postgres(?:ql)?:\/\//i.test(arg) ? hostOf(arg) : undefined)).find(Boolean) ??
|
|
90
|
+
args.map((arg) => /(?:^|\s)host=([^\s]+)/.exec(arg)?.[1]).find(Boolean);
|
|
91
|
+
if (!host)
|
|
92
|
+
return undefined;
|
|
93
|
+
if (LOCAL_HOSTS.has(host.toLowerCase()) || host.startsWith("/"))
|
|
94
|
+
return { kind: "development", source: "flag" };
|
|
95
|
+
return kindOfName(host) ? { kind: kindOfName(host), source: "flag" } : undefined;
|
|
96
|
+
}
|
|
97
|
+
function vercelHint(args, positional) {
|
|
98
|
+
if (args.includes("--prod") || args.includes("--production"))
|
|
99
|
+
return { kind: "production", source: "flag" };
|
|
100
|
+
const target = flagValue(args, VENDOR_FLAGS.vercel.names);
|
|
101
|
+
if (target)
|
|
102
|
+
return named(target);
|
|
103
|
+
// `vercel env add|rm|pull NAME <environment>`
|
|
104
|
+
if (positional[0] === "env" && positional[3])
|
|
105
|
+
return named(positional[3]);
|
|
106
|
+
if (positional[0] === "env" && positional[1] === "pull" && positional[2])
|
|
107
|
+
return named(positional[2]);
|
|
108
|
+
// Promote, rollback, and aliases act on production by definition.
|
|
109
|
+
if (["promote", "rollback", "alias"].includes(positional[0] ?? ""))
|
|
110
|
+
return { kind: "production", source: "flag" };
|
|
111
|
+
// A deploy without --prod or --target is a preview deployment.
|
|
112
|
+
if (!positional.length || positional[0] === "deploy" || positional[0] === "redeploy") {
|
|
113
|
+
return { kind: "staging", source: "vendor-default", name: "preview" };
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
function supabaseHint(args, positional) {
|
|
118
|
+
if (args.includes("--local"))
|
|
119
|
+
return { kind: "development", source: "flag" };
|
|
120
|
+
const dbUrl = flagValue(args, ["--db-url"]);
|
|
121
|
+
if (dbUrl) {
|
|
122
|
+
const host = hostOf(dbUrl);
|
|
123
|
+
if (host && LOCAL_HOSTS.has(host))
|
|
124
|
+
return { kind: "development", source: "flag" };
|
|
125
|
+
}
|
|
126
|
+
// `supabase db reset` resets the local database unless --linked says otherwise.
|
|
127
|
+
if (positional[0] === "db" && positional[1] === "reset" && !args.includes("--linked")) {
|
|
128
|
+
return { kind: "development", source: "vendor-default", name: "local" };
|
|
129
|
+
}
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
/** Stripe's CLI works in test mode unless told `--live` or given a live key. */
|
|
133
|
+
function stripeHint(args) {
|
|
134
|
+
if (args.includes("--live"))
|
|
135
|
+
return { kind: "production", source: "flag" };
|
|
136
|
+
const key = flagValue(args, ["--api-key"]);
|
|
137
|
+
if (key && /^[sr]k_live_/.test(key))
|
|
138
|
+
return { kind: "production", source: "flag" };
|
|
139
|
+
return { kind: "development", source: "vendor-default", name: "test mode" };
|
|
140
|
+
}
|
|
141
|
+
/** `git push <remote> <branch>`: the branch name decides. */
|
|
142
|
+
function gitHint(positional) {
|
|
143
|
+
if (positional[0] !== "push")
|
|
144
|
+
return undefined;
|
|
145
|
+
const refspec = positional[2];
|
|
146
|
+
if (!refspec)
|
|
147
|
+
return undefined;
|
|
148
|
+
const branch = refspec
|
|
149
|
+
.replace(/^\+/, "")
|
|
150
|
+
.split(":")
|
|
151
|
+
.at(-1)
|
|
152
|
+
?.replace(/^refs\/heads\//, "");
|
|
153
|
+
return branch ? named(branch) : undefined;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The environment one vendor command acts on. `args` are the words after the
|
|
157
|
+
* program name, as the classifier saw them.
|
|
158
|
+
*/
|
|
159
|
+
export function environmentHint(vendor, args) {
|
|
160
|
+
const positional = args.filter((arg) => !arg.startsWith("-"));
|
|
161
|
+
const special = vendor === "psql"
|
|
162
|
+
? psqlHint(args)
|
|
163
|
+
: vendor === "vercel"
|
|
164
|
+
? vercelHint(args, positional)
|
|
165
|
+
: vendor === "supabase"
|
|
166
|
+
? supabaseHint(args, positional)
|
|
167
|
+
: vendor === "stripe"
|
|
168
|
+
? stripeHint(args)
|
|
169
|
+
: vendor === "git"
|
|
170
|
+
? gitHint(positional)
|
|
171
|
+
: undefined;
|
|
172
|
+
if (special)
|
|
173
|
+
return special;
|
|
174
|
+
if (args.includes("--prod") || args.includes("--production"))
|
|
175
|
+
return { kind: "production", source: "flag" };
|
|
176
|
+
const spec = Object.hasOwn(VENDOR_FLAGS, vendor) ? VENDOR_FLAGS[vendor] : undefined;
|
|
177
|
+
const value = (spec && flagValue(args, spec.names, spec.short)) ?? flagValue(args, GENERIC_FLAGS);
|
|
178
|
+
if (value)
|
|
179
|
+
return named(value);
|
|
180
|
+
return { kind: "production", source: "assumed" };
|
|
181
|
+
}
|
|
182
|
+
function serverFlagHint(vendor, args, flags) {
|
|
183
|
+
const listed = flags && Object.hasOwn(flags, vendor) ? flags[vendor] : [];
|
|
184
|
+
for (const { flag, value } of listed) {
|
|
185
|
+
if (value && args.some((arg) => arg === flag || arg.startsWith(`${flag}=`)))
|
|
186
|
+
return { kind: value, source: "flag" };
|
|
187
|
+
}
|
|
188
|
+
const named_ = listed.filter((entry) => !entry.value).map((entry) => entry.flag);
|
|
189
|
+
const found = flagValue(args, named_.filter((flag) => flag.startsWith("--") || flag.length > 2), named_.filter((flag) => !flag.startsWith("--") && flag.length === 2));
|
|
190
|
+
return found ? named(found) : undefined;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The built-in hint, with the server's extra flags filling a gap and the
|
|
194
|
+
* workspace's own placement of a named environment winning over its name.
|
|
195
|
+
*/
|
|
196
|
+
export function environmentHintWith(vendor, args, context = {}) {
|
|
197
|
+
let hint = environmentHint(vendor, args);
|
|
198
|
+
if (hint.source === "assumed")
|
|
199
|
+
hint = serverFlagHint(vendor, args, context.flags) ?? hint;
|
|
200
|
+
if (hint.name && context.known?.length) {
|
|
201
|
+
const name = hint.name.toLowerCase();
|
|
202
|
+
const placed = context.known.find((entry) => entry.vendor === vendor && entry.name.toLowerCase() === name);
|
|
203
|
+
if (placed)
|
|
204
|
+
return { ...hint, kind: placed.kind, source: "flag" };
|
|
205
|
+
}
|
|
206
|
+
return hint;
|
|
207
|
+
}
|
|
208
|
+
/** What the server is told: a short environment name it can map, the kind
|
|
209
|
+
* when only that is known, or nothing when Production was assumed. */
|
|
210
|
+
export function reportedEnvironment(hint) {
|
|
211
|
+
if (hint.source === "assumed" && !hint.name)
|
|
212
|
+
return undefined;
|
|
213
|
+
return hint.name && /^[A-Za-z0-9._-]{1,40}$/.test(hint.name) ? hint.name : hint.kind;
|
|
214
|
+
}
|
|
215
|
+
export const ENV_LABEL = {
|
|
216
|
+
production: "Production",
|
|
217
|
+
staging: "Staging",
|
|
218
|
+
development: "Development"
|
|
219
|
+
};
|
package/dist/cliHookGuard.d.ts
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The guard's decision and the one line each agent shows for it.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* With a v2 (Autopilot) policy the guard answers allow, ask, or deny:
|
|
5
|
+
*
|
|
6
|
+
* - **allow** only when every command in the line is a vendor command Passport
|
|
7
|
+
* recognizes and every one is allowed. Anything it can't read (a script, a
|
|
8
|
+
* pipe into another program, a substitution, a redirect) means no decision,
|
|
9
|
+
* so the agent's own permission rules apply. Codex can't receive allow.
|
|
10
|
+
* - **ask** or **deny** when any recognized command needs it; the strictest
|
|
11
|
+
* wins and names itself.
|
|
12
|
+
*
|
|
13
|
+
* With a v1 policy (an older server) or none at all, the guard keeps its old
|
|
14
|
+
* shape: ask or deny, never allow.
|
|
9
15
|
*/
|
|
16
|
+
import { type ActionClass, type Cause, type Decision } from "./cliAutopilotPolicy.js";
|
|
10
17
|
import type { CliFinding } from "./cliHookClassify.js";
|
|
11
|
-
import type
|
|
12
|
-
|
|
18
|
+
import { type EnvKind, type EnvSource } from "./cliHookEnvironment.js";
|
|
19
|
+
import type { CachedCliPolicy, CachedCliPolicyV2 } from "./cliPolicy.js";
|
|
20
|
+
export type GuardVerdict = "allow" | "ask" | "deny";
|
|
13
21
|
export type GuardClient = "claude-code" | "codex" | "cursor";
|
|
22
|
+
/** One recognized command and what Autopilot decided for it. */
|
|
23
|
+
export type DecidedFinding = {
|
|
24
|
+
finding: CliFinding;
|
|
25
|
+
decision: Decision;
|
|
26
|
+
cause: Cause;
|
|
27
|
+
environment: EnvKind;
|
|
28
|
+
environmentSource: EnvSource;
|
|
29
|
+
/** What the server is told about the environment (a name or a kind). */
|
|
30
|
+
reported?: string;
|
|
31
|
+
actionClass: ActionClass;
|
|
32
|
+
};
|
|
14
33
|
export type GuardDecision = {
|
|
15
34
|
verdict: GuardVerdict;
|
|
16
35
|
/** The finding that set the verdict, e.g. `railway volume delete`. */
|
|
@@ -19,21 +38,51 @@ export type GuardDecision = {
|
|
|
19
38
|
findings: CliFinding[];
|
|
20
39
|
/** Whether the deciding finding is destructive by Passport's own map. */
|
|
21
40
|
destructive: boolean;
|
|
41
|
+
/** v2 only: the deciding command's cause, environment, and class. */
|
|
42
|
+
cause?: Cause;
|
|
43
|
+
environment?: EnvKind;
|
|
44
|
+
environmentSource?: EnvSource;
|
|
45
|
+
actionClass?: ActionClass;
|
|
46
|
+
/** v2 only: every recognized command, in line order. */
|
|
47
|
+
decided?: DecidedFinding[];
|
|
22
48
|
};
|
|
23
49
|
/** The words a person needs to recognise the command, never its arguments. */
|
|
24
50
|
export declare function guardLabel(finding: CliFinding): string;
|
|
51
|
+
/** One recognized command's decision, or null when Autopilot has no opinion. */
|
|
52
|
+
export declare function decideFinding(finding: CliFinding, policy: CachedCliPolicyV2): DecidedFinding | null;
|
|
53
|
+
/**
|
|
54
|
+
* Every simple command in the line is a vendor command the classifier read
|
|
55
|
+
* with confidence, with nothing hidden from it: no substitutions, redirects,
|
|
56
|
+
* variables, wrappers, heredocs, or environment prefixes.
|
|
57
|
+
*/
|
|
58
|
+
export declare function fullyRecognized(command: string, findings: CliFinding[]): boolean;
|
|
25
59
|
/** The strictest verdict across every command in the line wins. */
|
|
26
|
-
export declare function decideGuard(findings: CliFinding[], policy: CachedCliPolicy | null): GuardDecision | null;
|
|
60
|
+
export declare function decideGuard(findings: CliFinding[], policy: CachedCliPolicy | null, command?: string): GuardDecision | null;
|
|
27
61
|
export declare function askMessage(decision: GuardDecision): string;
|
|
28
|
-
export declare function denyMessage(decision: GuardDecision): string;
|
|
62
|
+
export declare function denyMessage(decision: GuardDecision, owner?: string): string;
|
|
63
|
+
export declare function allowReason(decision: GuardDecision): string;
|
|
29
64
|
export declare const DENY_AGENT_MESSAGE = "Blocked by Passport safety settings. Ask the user to run this command themselves.";
|
|
65
|
+
/** What the agent reads when an unattended ask became an approval request. */
|
|
66
|
+
export declare function waitingMessage(approvalId: string, approver?: string): string;
|
|
67
|
+
/** Appended when the server couldn't be reached and this machine decided. */
|
|
68
|
+
export declare const OFFLINE_NOTE = "Passport couldn't be reached, so this computer decided.";
|
|
69
|
+
export type GuardOutputOptions = {
|
|
70
|
+
/** Replaces the reason entirely: an approval request is waiting. */
|
|
71
|
+
waiting?: string;
|
|
72
|
+
/** One line added to the reason, e.g. OFFLINE_NOTE. */
|
|
73
|
+
note?: string;
|
|
74
|
+
/** Who to ask, for a block. */
|
|
75
|
+
owner?: string;
|
|
76
|
+
};
|
|
30
77
|
/**
|
|
31
78
|
* The exact stdout each agent reads, or null for nothing at all.
|
|
32
79
|
*
|
|
33
80
|
* - Claude Code shows an ask reason in its permission prompt; a deny reason
|
|
34
81
|
* goes to the model, so the person gets the deny line as a system message.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
82
|
+
* An allow skips the prompt.
|
|
83
|
+
* - Codex supports deny only. It parses "ask" and fails the hook, and its allow
|
|
84
|
+
* is for rewriting a command, so the guard stays silent otherwise and
|
|
85
|
+
* Codex's own approval policy applies.
|
|
37
86
|
* - Cursor's beforeShellExecution takes a flat, snake_case response.
|
|
38
87
|
*/
|
|
39
|
-
export declare function guardOutput(client: GuardClient, decision: GuardDecision): Record<string, unknown> | null;
|
|
88
|
+
export declare function guardOutput(client: GuardClient, decision: GuardDecision, options?: GuardOutputOptions): Record<string, unknown> | null;
|