fullcourtdefense 2.1.2 → 2.2.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 +21 -0
- package/dist/anthropic.js +2 -0
- package/dist/client.d.ts +50 -1
- package/dist/client.js +290 -11
- package/dist/localDecision.d.ts +100 -0
- package/dist/localDecision.js +246 -0
- package/dist/localSafety.d.ts +48 -0
- package/dist/localSafety.js +220 -0
- package/dist/policy/acorn.js +6365 -0
- package/dist/policy/actionPolicyEngine.d.ts +427 -0
- package/dist/policy/actionPolicyEngine.js +6481 -0
- package/dist/policy/detectionData.d.ts +21 -0
- package/dist/policy/detectionData.js +71 -0
- package/dist/policy/detectorRuntime.d.ts +27 -0
- package/dist/policy/detectorRuntime.js +58 -0
- package/dist/policy/deterministicGuard.d.ts +406 -0
- package/dist/policy/deterministicGuard.js +6651 -0
- package/dist/protect.d.ts +6 -0
- package/dist/protect.js +18 -0
- package/dist/recordQueue.d.ts +53 -0
- package/dist/recordQueue.js +132 -0
- package/dist/types.d.ts +47 -0
- package/package.json +16 -10
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
export type ActionPolicyVerdict = 'allow' | 'block' | 'require_approval' | 'log';
|
|
2
|
+
/**
|
|
3
|
+
* Constraint operators. `not_matches` is the glob complement of `matches`: it is what lets an
|
|
4
|
+
* allow-list be expressed under "most restrictive verdict wins" — `to matches *@company.com ->
|
|
5
|
+
* allow` needs a `to not_matches *@company.com -> block` partner, because an unconstrained block
|
|
6
|
+
* rule would match every call and swallow the allow.
|
|
7
|
+
*/
|
|
8
|
+
export type ActionPolicyConstraintOperator = 'contains' | 'not_contains' | 'equals' | 'not_equals' | 'gt' | 'lt' | 'matches' | 'not_matches';
|
|
9
|
+
export interface ActionPolicyConstraint {
|
|
10
|
+
field: string;
|
|
11
|
+
operator: ActionPolicyConstraintOperator;
|
|
12
|
+
value: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Who resolves a `require_approval` verdict.
|
|
16
|
+
* - `org` — an admin in the console / Slack (default; the only scope with no human at the keyboard).
|
|
17
|
+
* - `developer` — the developer running the agent confirms in their IDE's own permission prompt
|
|
18
|
+
* (Cursor `permission: ask`, Claude `permissionDecision: ask`) or a terminal y/N.
|
|
19
|
+
* Only meaningful where a human is present — see `effectiveApprovalScope`.
|
|
20
|
+
*/
|
|
21
|
+
export type ActionPolicyApprovalScope = 'developer' | 'org';
|
|
22
|
+
/** How long a developer's confirmation is remembered for the same tool + operation. */
|
|
23
|
+
export type ActionPolicyApprovalRemember = 'none' | 'session' | '1h';
|
|
24
|
+
/** What happens when nobody answers within the approval window. */
|
|
25
|
+
export type ActionPolicyApprovalOnTimeout = 'block' | 'org';
|
|
26
|
+
export interface ActionPolicyApproval {
|
|
27
|
+
/** Explicit admin exception: replace approval from these policies for this constrained target only. Hard blocks still win. */
|
|
28
|
+
replacesPolicyIds?: string[];
|
|
29
|
+
scope?: ActionPolicyApprovalScope;
|
|
30
|
+
remember?: ActionPolicyApprovalRemember;
|
|
31
|
+
onTimeout?: ActionPolicyApprovalOnTimeout;
|
|
32
|
+
/**
|
|
33
|
+
* Caps on a developer's "Always allow" under this rule: lifetime in days
|
|
34
|
+
* (1–30) and uses before the dialog returns (1–10000). Absent = the built-in
|
|
35
|
+
* 30-day lifetime, unlimited uses. The org ceiling delivered with the bundle
|
|
36
|
+
* can only tighten these, never widen them.
|
|
37
|
+
*/
|
|
38
|
+
maxDays?: number;
|
|
39
|
+
maxUses?: number;
|
|
40
|
+
}
|
|
41
|
+
/** Fully-resolved approval options (every field present) attached to a `require_approval` result. */
|
|
42
|
+
export interface ResolvedActionPolicyApproval {
|
|
43
|
+
scope: ActionPolicyApprovalScope;
|
|
44
|
+
remember: ActionPolicyApprovalRemember;
|
|
45
|
+
onTimeout: ActionPolicyApprovalOnTimeout;
|
|
46
|
+
/** "Always allow" caps (see `ActionPolicyApproval`); undefined = built-in default. */
|
|
47
|
+
maxDays?: number;
|
|
48
|
+
maxUses?: number;
|
|
49
|
+
}
|
|
50
|
+
export declare const ACTION_POLICY_GRANT_MAX_DAYS = 30;
|
|
51
|
+
export declare const ACTION_POLICY_GRANT_MAX_USES = 10000;
|
|
52
|
+
export interface ActionPolicyRule {
|
|
53
|
+
/** Explicit, narrowly scoped permission to relax named role actions only. */
|
|
54
|
+
roleException?: {
|
|
55
|
+
roleIds: string[];
|
|
56
|
+
verbs: string[];
|
|
57
|
+
};
|
|
58
|
+
/** Set only by the role compiler; never accepted from policy authors. */
|
|
59
|
+
roleVerb?: string;
|
|
60
|
+
operations: string[];
|
|
61
|
+
verdict: ActionPolicyVerdict;
|
|
62
|
+
constraints?: ActionPolicyConstraint[];
|
|
63
|
+
/** Approval routing for `require_approval` rules. Absent = org admin approval, no memory, block on timeout. */
|
|
64
|
+
approval?: ActionPolicyApproval;
|
|
65
|
+
}
|
|
66
|
+
/** Reject ambiguous/broad approval exceptions at authoring time; runtime also fails closed on them. */
|
|
67
|
+
export declare function approvalExceptionError(rule: ActionPolicyRule): string | undefined;
|
|
68
|
+
export declare function roleExceptionError(rule: ActionPolicyRule): string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* The three kinds of machine a fleet policy can be written for:
|
|
71
|
+
* - `workstation` — laptops / desktops a person uses (default for any machine that does not say otherwise)
|
|
72
|
+
* - `ci` — ephemeral CI runner VMs enrolled with `ci-protect` (one row per pipeline)
|
|
73
|
+
* - `workload` — containers, pods, jobs, functions enrolled with `workload-protect`
|
|
74
|
+
* A call that carries no `machineKind` in its context is treated as a workstation, so a
|
|
75
|
+
* policy written only for containers can never fire on a laptop (and vice versa).
|
|
76
|
+
*/
|
|
77
|
+
export type MachineKind = 'workstation' | 'ci' | 'workload';
|
|
78
|
+
export declare const MACHINE_KINDS: readonly MachineKind[];
|
|
79
|
+
export interface ActionPolicyTargeting {
|
|
80
|
+
developerNames?: string[];
|
|
81
|
+
machineNames?: string[];
|
|
82
|
+
/** Restrict to these machine kinds. Empty/absent = every kind (a GLOBAL policy). */
|
|
83
|
+
machineKinds?: MachineKind[];
|
|
84
|
+
}
|
|
85
|
+
/** Normalize a context value into a MachineKind; anything unknown is a workstation. */
|
|
86
|
+
export declare function normalizeMachineKind(value: string | undefined): MachineKind;
|
|
87
|
+
/** Does this policy's kind targeting include the given machine kind? Empty targeting = yes. */
|
|
88
|
+
export declare function policyTargetsMachineKind(appliesTo: ActionPolicyTargeting | undefined, kind: MachineKind): boolean;
|
|
89
|
+
/** The minimal policy shape the engine needs — structurally satisfied by the backend's ActionPolicy. */
|
|
90
|
+
export interface EngineActionPolicy {
|
|
91
|
+
id: string;
|
|
92
|
+
name: string;
|
|
93
|
+
scope?: string;
|
|
94
|
+
/** Rollout stage — `monitor` policies log would-be verdicts without enforcing. Default: enforce. */
|
|
95
|
+
stage?: string;
|
|
96
|
+
/** First-class developer/machine targeting (empty = applies to everyone). */
|
|
97
|
+
appliesTo?: ActionPolicyTargeting;
|
|
98
|
+
resourceType?: string;
|
|
99
|
+
rules: ActionPolicyRule[];
|
|
100
|
+
enabled?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Enforcement ceiling on a machine where a HUMAN is present (a developer
|
|
103
|
+
* workstation). `standard` (default): a `block` rule pauses the action and asks
|
|
104
|
+
* the developer in their IDE — a wrong Ask costs one click, a wrong block costs
|
|
105
|
+
* the customer. `hard`: the policy blocks outright even with a human present.
|
|
106
|
+
* Where no human is present (CI, workloads, SDK-embedded agents) every block is
|
|
107
|
+
* hard — an Ask nobody can answer must never silently allow.
|
|
108
|
+
*/
|
|
109
|
+
enforcement?: ActionPolicyEnforcement;
|
|
110
|
+
}
|
|
111
|
+
export type ActionPolicyEnforcement = 'standard' | 'hard';
|
|
112
|
+
/**
|
|
113
|
+
* The developer Ask a softened block becomes: IDE prompt, asked EVERY time (no
|
|
114
|
+
* session memory — a Block-level rule is exactly where a second, different
|
|
115
|
+
* action must not ride on the first yes), blocks on timeout.
|
|
116
|
+
*/
|
|
117
|
+
export declare const WORKSTATION_ASK_APPROVAL: ResolvedActionPolicyApproval;
|
|
118
|
+
/**
|
|
119
|
+
* LOCAL CONTENT CEILING.
|
|
120
|
+
*
|
|
121
|
+
* Facts about what the arguments CONTAIN. A rule that needs one of these to
|
|
122
|
+
* fire is a rule about content, and content on this machine's own disk is not
|
|
123
|
+
* exfiltration: typing a key into `.env`, pasting a token into a test fixture,
|
|
124
|
+
* reading a config file that holds a password. Secret scanning on file content
|
|
125
|
+
* is inherently approximate (there is no finite list of what a fake key looks
|
|
126
|
+
* like), and the industry treats it as advisory for exactly that reason — a
|
|
127
|
+
* hard stop on EDITING is how a developer loses trust in the product after two
|
|
128
|
+
* wrong blocks. So: a `block` that fires on a content fact for a LOCAL FILE
|
|
129
|
+
* action is recorded as a warning (verdict `log`, `loggedInsteadOfBlocked`),
|
|
130
|
+
* never enforced. The same content leaving the machine — an external
|
|
131
|
+
* destination, a recipient, a shell command that sends it — is untouched by
|
|
132
|
+
* this ceiling and still blocks. A policy marked `enforcement: 'hard'` is also
|
|
133
|
+
* untouched: the admin confirmed it should stop without asking.
|
|
134
|
+
*/
|
|
135
|
+
export declare const CONTENT_FACT_FIELDS: ReadonlySet<string>;
|
|
136
|
+
/** Does this rule need a content fact to fire? (A rule with no content constraint is about the ACTION, not the content.) */
|
|
137
|
+
export declare function ruleNeedsContentFact(rule: Pick<ActionPolicyRule, 'constraints'>): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Is this call a LOCAL FILE action — content touching this machine's disk with
|
|
140
|
+
* nothing leaving the machine? Requires a file path, no external destination,
|
|
141
|
+
* no recipient, and a file-shaped tool or operation. A shell command is never
|
|
142
|
+
* a local file action here (the command line may send data in ways the URL
|
|
143
|
+
* parser cannot see), so `echo $KEY | nc host 4444` keeps its verdict.
|
|
144
|
+
*/
|
|
145
|
+
export declare function isLocalFileContentAction(toolName: string, operation: string, context: Record<string, string>): boolean;
|
|
146
|
+
/** A monitor-stage policy match: what WOULD have happened, recorded but not enforced. */
|
|
147
|
+
export interface ActionPolicyMonitorMatch {
|
|
148
|
+
policyId?: string;
|
|
149
|
+
policyName?: string;
|
|
150
|
+
verdict: ActionPolicyVerdict;
|
|
151
|
+
matchedRule?: string;
|
|
152
|
+
}
|
|
153
|
+
export interface EngineCheckResult {
|
|
154
|
+
allowed: boolean;
|
|
155
|
+
verdict: ActionPolicyVerdict;
|
|
156
|
+
policyId?: string;
|
|
157
|
+
policyName?: string;
|
|
158
|
+
resourceType?: string;
|
|
159
|
+
matchedRule?: string;
|
|
160
|
+
reason?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Resolved approval routing — present only when `verdict === 'require_approval'`. When several
|
|
163
|
+
* approval rules match, the most restrictive option wins per field (org > developer, none >
|
|
164
|
+
* session > 1h, block > org) so one permissive rule can never loosen another.
|
|
165
|
+
*/
|
|
166
|
+
approval?: ResolvedActionPolicyApproval;
|
|
167
|
+
/**
|
|
168
|
+
* The matched rule said `block`, but a human is present and the policy is not
|
|
169
|
+
* `enforcement: 'hard'`, so the action pauses and asks the developer instead
|
|
170
|
+
* (verdict is `require_approval` with WORKSTATION_ASK_APPROVAL). Surfaced so
|
|
171
|
+
* explanations can say "set to Block; asks you on a workstation; an admin can
|
|
172
|
+
* mark it Hard block".
|
|
173
|
+
*/
|
|
174
|
+
askedInsteadOfBlocked?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* The matched rule said `block` because of what the arguments CONTAIN
|
|
177
|
+
* (`toolArgs.containsSecret` / `secretKind` / `containsPii`), but the action
|
|
178
|
+
* only touches a file on this machine's own disk and nothing leaves the
|
|
179
|
+
* machine — so it is recorded as a warning (verdict `log`) instead of
|
|
180
|
+
* stopping the developer. See LOCAL CONTENT CEILING below.
|
|
181
|
+
*/
|
|
182
|
+
loggedInsteadOfBlocked?: boolean;
|
|
183
|
+
/** Monitor-stage policies that matched (would-block / would-approve) without enforcing. */
|
|
184
|
+
monitorMatches?: ActionPolicyMonitorMatch[];
|
|
185
|
+
/** Org-scoped policies skipped because the call carried no developerName (for caller-side logging). */
|
|
186
|
+
skippedOrgPolicies?: string[];
|
|
187
|
+
/** A web call that names several addresses: each was judged, the strictest decided (judgeWebBatch). */
|
|
188
|
+
webBatch?: WebBatchJudgement;
|
|
189
|
+
}
|
|
190
|
+
/** How a web call that names several addresses was judged (one evaluation per address). */
|
|
191
|
+
export interface WebBatchJudgement {
|
|
192
|
+
/** The address whose outcome decided the call: the strictest, the first of equals. */
|
|
193
|
+
url: string;
|
|
194
|
+
/** How many distinct addresses the call names. */
|
|
195
|
+
count: number;
|
|
196
|
+
/** Each judged address with its own outcome, in the call's order (at most WEB_BATCH_URL_LIMIT). */
|
|
197
|
+
addresses: Array<{
|
|
198
|
+
url: string;
|
|
199
|
+
outcome: string;
|
|
200
|
+
}>;
|
|
201
|
+
/** The call names more addresses than are judged in one call: it is stopped. */
|
|
202
|
+
overLimit?: boolean;
|
|
203
|
+
}
|
|
204
|
+
export declare const DEFAULT_ACTION_POLICY_APPROVAL: ResolvedActionPolicyApproval;
|
|
205
|
+
/**
|
|
206
|
+
* Normalize a rule's approval options: unknown / missing values fall back to the DEFAULT
|
|
207
|
+
* (org, none, block) — the strictest — so a typo in a policy document can never widen who
|
|
208
|
+
* may approve.
|
|
209
|
+
*/
|
|
210
|
+
export declare function resolveApprovalOptions(approval?: ActionPolicyApproval): ResolvedActionPolicyApproval;
|
|
211
|
+
/**
|
|
212
|
+
* Where an approval actually goes given who is present at the enforcement point.
|
|
213
|
+
*
|
|
214
|
+
* `developer` scope means "the human running the agent confirms in their IDE". That human only
|
|
215
|
+
* exists on an end machine. Ephemeral machines (CI runners, containers, cloud coding agents) and
|
|
216
|
+
* SDK-embedded online services have no keyboard, so a developer-scoped rule there degrades to the
|
|
217
|
+
* org admin queue — never to a silent self-approval, and never to allow. Pure and shared so the
|
|
218
|
+
* backend, the CLI hook and the SDK agree on this fallback without a network round-trip.
|
|
219
|
+
*/
|
|
220
|
+
export declare function effectiveApprovalScope(approval: ActionPolicyApproval | ResolvedActionPolicyApproval | undefined, presence: {
|
|
221
|
+
humanPresent: boolean;
|
|
222
|
+
}): ActionPolicyApprovalScope;
|
|
223
|
+
/**
|
|
224
|
+
* Derive the set of canonical operations a tool represents from its NAME and declared inventory
|
|
225
|
+
* actions. This is the "declared operations" model: the tool's identity/declaration defines what
|
|
226
|
+
* operation a bare call performs, NOT a substring match against the raw tool name. Used only for
|
|
227
|
+
* bare invocations (see evaluateActionPolicies).
|
|
228
|
+
*
|
|
229
|
+
* A write is also a `modify`: the console's Edit kind (MCP rule builder) names concrete verbs only,
|
|
230
|
+
* never WRITE (which the engine widens to deletes and drops), so `modify` is what lets a saved Edit
|
|
231
|
+
* rule reach `set_*`, `change_*` and `approve_*` tools. Role rules and WRITE rules match `write`.
|
|
232
|
+
*/
|
|
233
|
+
export declare function deriveToolOperations(toolName: string, declaredActions?: string[]): string[];
|
|
234
|
+
export declare function toolCapabilities(value: string): Set<string>;
|
|
235
|
+
export declare function canonicalAgentClient(value: string): string;
|
|
236
|
+
/**
|
|
237
|
+
* The data-changing verbs of every statement in a SQL text, after quoted
|
|
238
|
+
* literals / identifiers and comments are blanked (a value such as
|
|
239
|
+
* `'please update x set'` is data). The engine adds them as candidate
|
|
240
|
+
* operations so a statement that STARTS as a read cannot hide a write behind it:
|
|
241
|
+
* `WITH c AS (SELECT …) UPDATE …`, `SELECT 1; DROP TABLE …`,
|
|
242
|
+
* `EXPLAIN ANALYZE DELETE …`, and `MERGE INTO …` (a verb the operation
|
|
243
|
+
* inference does not name). Decision-side, so it holds whichever signed
|
|
244
|
+
* detector produced the facts.
|
|
245
|
+
*/
|
|
246
|
+
export declare function sqlChangeVerbs(sql: string): string[];
|
|
247
|
+
/**
|
|
248
|
+
* The words of a SQL text that can carry a statement verb, in ONE pass so a quote
|
|
249
|
+
* inside a comment or a `--` inside a literal cannot shift what is hidden: quoted
|
|
250
|
+
* literals and identifiers ('…', "…", `…`; a doubled quote stays inside, a backslash
|
|
251
|
+
* does NOT escape — standard SQL, so `'x\'; DROP …` still shows the DROP) become `""`, `--` and `/* … *\/` comments
|
|
252
|
+
* become a space (a MySQL executable comment `/*! … *\/` RUNS, so it stays), and a
|
|
253
|
+
* verb that only names a lock or a foreign-key action (`FOR UPDATE`, `FOR NO KEY
|
|
254
|
+
* UPDATE`, `ON DELETE CASCADE`, `ON UPDATE`) is blanked: none of them changes data.
|
|
255
|
+
*/
|
|
256
|
+
export declare function sqlVerbText(sql: string): string;
|
|
257
|
+
/**
|
|
258
|
+
* What an HTTP write means beyond "a change to that host" (#2284), the way an MCP
|
|
259
|
+
* tool is classed by what it is: a POST / PUT / PATCH to a messaging or email API
|
|
260
|
+
* is also a SEND, to a payment API also a PAYMENT. Any other host: only a write.
|
|
261
|
+
* Decided from the destination host the engine derived, never from payload text.
|
|
262
|
+
*/
|
|
263
|
+
export declare function httpWriteSemantics(operation: string, context: Record<string, string>): string[];
|
|
264
|
+
/**
|
|
265
|
+
* "Contains a secret" means a secret VALUE is present — never that the text
|
|
266
|
+
* talks about secrets. Source code, docs, grep patterns and commit messages in
|
|
267
|
+
* any security-minded codebase say "password", "credential", "api_key" and
|
|
268
|
+
* ".env" all day; treating those words as secrets made `toolArgs.containsSecret`
|
|
269
|
+
* true for ~77% of routine IDE agent actions (measured), and every org policy
|
|
270
|
+
* built on that fact blocked developers for editing their own code.
|
|
271
|
+
*
|
|
272
|
+
* What counts:
|
|
273
|
+
* - known token formats (GitHub, AWS, Google, OpenAI/Anthropic, Slack, JWT)
|
|
274
|
+
* - private-key PEM blocks
|
|
275
|
+
* - an ASSIGNMENT of a secret-named field to a REAL value:
|
|
276
|
+
* `password=<real value>`, `"api_key": "sk-…"`, `--token abc…` — where the
|
|
277
|
+
* value is not a placeholder (`<your-key>`, `xxxx`, `changeme`, `${VAR}`,
|
|
278
|
+
* `process.env.X`), not a code expression (`req.body.password`,
|
|
279
|
+
* `config.get('token')`) and has real-secret shape (>= 8 chars, >= 2
|
|
280
|
+
* character classes).
|
|
281
|
+
* The kind is exposed as `toolArgs.secretKind` so a Decision Card can say WHAT
|
|
282
|
+
* matched instead of just "contains secret".
|
|
283
|
+
*/
|
|
284
|
+
export type SecretKind = 'github_token' | 'aws_access_key' | 'google_api_key' | 'openai_key' | 'slack_token' | 'jwt' | 'private_key' | 'assignment' | 'high_entropy' | 'none';
|
|
285
|
+
/**
|
|
286
|
+
* A record identifier built from SEGMENTS joined by `-`, `_` or `.`: the account,
|
|
287
|
+
* customer, case and ticket ids of banking and ticketing systems
|
|
288
|
+
* (`ACC-fcdwork-mon-1792740281-r1-ccD-bal`, `CASE-2026-10-23-KYC-004512-escalated`,
|
|
289
|
+
* `KYC-<uuid>-review`). Every segment is a number, a word (lower, UPPER or
|
|
290
|
+
* Capitalized letters; PascalCase / camelCase from 6 letters: `LoanReview`) or a
|
|
291
|
+
* short code (at most 4 characters, or digits with at most 2 letters: `r1`, `ccD`,
|
|
292
|
+
* `2026Q4`). The id carries a number, at least two words of 3+ letters, and fewer
|
|
293
|
+
* codes than words. An embedded UUID counts as a number. Random credential
|
|
294
|
+
* material does not split this way: base64 / base64url segments are long and mix
|
|
295
|
+
* case with digits, a vendor key keeps one long random body after its prefix
|
|
296
|
+
* (`glpat-…`, `sk_live_…`, `xoxb-…-…`), and chunked random material
|
|
297
|
+
* (`Prod_x7Qm_K2pL_9wZr_2026`) is mostly codes.
|
|
298
|
+
* Mac Monitor run 041 (2026-10-23): read-only bank MCP lookups were held as
|
|
299
|
+
* secret-bearing because of their long account id.
|
|
300
|
+
*/
|
|
301
|
+
declare function isSegmentedIdentifier(token: string): boolean;
|
|
302
|
+
/** Test-only: lets the TS tests pin the record-identifier predicate on every edge (the Rust twin is pinned the same way). */
|
|
303
|
+
export declare const isSegmentedIdentifierForTest: typeof isSegmentedIdentifier;
|
|
304
|
+
export declare function detectSecretKind(raw: string): SecretKind;
|
|
305
|
+
/**
|
|
306
|
+
* Decision side of the file-change rule: the file changes of a whole command line (each
|
|
307
|
+
* segment, the cwd tracked through `cd`, and the command line a shell executor is handed —
|
|
308
|
+
* `bash -c "touch x"`). Added to the candidate operations of a code-execution call.
|
|
309
|
+
* `literalText` (R01 round 4): the line's literal heredoc bodies and here-strings may be read as literal
|
|
310
|
+
* (literalTextOf) — the agent's own line and the substitutions in it, not a command line a shell or an
|
|
311
|
+
* evaluator is handed.
|
|
312
|
+
*/
|
|
313
|
+
export declare function shellFileChangeOperations(command: string, depth?: number, literalText?: boolean): string[];
|
|
314
|
+
/**
|
|
315
|
+
* gcloud read verbs. Token printers (`print-access-token`, `print-identity-token`)
|
|
316
|
+
* are credential dumps and are deliberately absent; `cat` streams object bytes
|
|
317
|
+
* and keeps its own stricter proof (isGcloudStorageCatRead). `versions` is a
|
|
318
|
+
* GROUP (`app versions`, `secrets versions`), never a verb: as a verb it made
|
|
319
|
+
* `gcloud app versions delete` a read. `access` is `secrets versions access`.
|
|
320
|
+
*/
|
|
321
|
+
export declare const GCLOUD_READ_VERB_RE: RegExp;
|
|
322
|
+
/** gcloud verbs that change a cloud resource. Deletes are handled apart (DELETE). */
|
|
323
|
+
export declare const GCLOUD_WRITE_VERB_RE: RegExp;
|
|
324
|
+
/** gcloud verbs that remove a resource or its data (`kms keys versions destroy`, `secrets versions destroy`). */
|
|
325
|
+
export declare const GCLOUD_DELETE_VERB_RE: RegExp;
|
|
326
|
+
/**
|
|
327
|
+
* `gcloud [--global-flag …] [alpha|beta] <group…> <verb> …` on the masked,
|
|
328
|
+
* lowercased command words: the first token after the program that is not a
|
|
329
|
+
* flag and not a lowercase group word that names a further group. gcloud
|
|
330
|
+
* groups and verbs are both lowercase words, so the walk returns the FIRST
|
|
331
|
+
* word that is a known read/write/delete verb; a value, a redirect or an
|
|
332
|
+
* unknown word before any verb ends the walk with `null` (segment stays
|
|
333
|
+
* unknown). Nothing here reads the resource operand — `gs://…`, a service
|
|
334
|
+
* name, a secret name are what the verb acts ON, not where data goes.
|
|
335
|
+
*/
|
|
336
|
+
export declare function gcloudVerbWord(value: string): string | null;
|
|
337
|
+
export type ShellAstMode = 'off' | 'shadow' | 'primary';
|
|
338
|
+
/** Structural subset of shellAst.ts ShellFacts that the engine reads. */
|
|
339
|
+
export interface ShellAstFactsLike {
|
|
340
|
+
complete: boolean;
|
|
341
|
+
commands: Array<{
|
|
342
|
+
name: string;
|
|
343
|
+
argv: string[];
|
|
344
|
+
literal: boolean[];
|
|
345
|
+
text: string;
|
|
346
|
+
pipeline: number;
|
|
347
|
+
cwdScope: 'scoped' | 'unscoped' | 'unknown';
|
|
348
|
+
depth?: {
|
|
349
|
+
subshell: number;
|
|
350
|
+
function: number;
|
|
351
|
+
loop: number;
|
|
352
|
+
conditional: number;
|
|
353
|
+
substitution: number;
|
|
354
|
+
};
|
|
355
|
+
wrapper?: {
|
|
356
|
+
kind: string;
|
|
357
|
+
program: string;
|
|
358
|
+
inner?: ShellAstFactsLike;
|
|
359
|
+
};
|
|
360
|
+
}>;
|
|
361
|
+
}
|
|
362
|
+
export interface ShellAstOperationComparison {
|
|
363
|
+
mode: ShellAstMode;
|
|
364
|
+
complete: boolean;
|
|
365
|
+
regex: string;
|
|
366
|
+
ast?: string;
|
|
367
|
+
agree: boolean;
|
|
368
|
+
}
|
|
369
|
+
export declare function setShellAstProvider(provider: ((command: string) => ShellAstFactsLike | undefined) | undefined): void;
|
|
370
|
+
export declare function setRemoteControlProvider(provider: ((command: string) => string | undefined) | undefined): void;
|
|
371
|
+
export declare function setShellAstMode(mode: ShellAstMode): void;
|
|
372
|
+
export declare function getShellAstMode(): ShellAstMode;
|
|
373
|
+
/** Shadow telemetry: the comparison recorded by the most recent top-level shell classification (consumed once). */
|
|
374
|
+
export declare function takeShellAstOperationComparison(): ShellAstOperationComparison | undefined;
|
|
375
|
+
/**
|
|
376
|
+
* Check a tool call against action policies.
|
|
377
|
+
* Returns the most restrictive matching verdict (pure — callers do their own logging).
|
|
378
|
+
* A web call that names several addresses (`url.batch`, see applyWebReadFacts) is
|
|
379
|
+
* judged once per address as well, and the strictest outcome decides (judgeWebBatch).
|
|
380
|
+
*/
|
|
381
|
+
export declare function evaluateActionPolicies(policies: EngineActionPolicy[], toolName: string, operation: string, context?: Record<string, string>, declaredOperations?: string[]): EngineCheckResult;
|
|
382
|
+
/**
|
|
383
|
+
* Infer operation and context from a tool call.
|
|
384
|
+
* Handles common patterns: SQL operations, file paths, HTTP methods, etc.
|
|
385
|
+
*/
|
|
386
|
+
export declare function inferToolContext(toolName: string, args: Record<string, any>): {
|
|
387
|
+
operation: string;
|
|
388
|
+
context: Record<string, string>;
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* What kind of site a destination host is, for the few kinds that change how an
|
|
392
|
+
* upload should be read. A curated list, not a reputation feed: a host is in it
|
|
393
|
+
* only when its PURPOSE is the category (a paste site exists to publish text; a
|
|
394
|
+
* request catcher exists to capture whatever is sent to it). Deliberately absent:
|
|
395
|
+
* general cloud storage, code hosting and gists, which are everyday developer
|
|
396
|
+
* destinations and would turn the category into noise.
|
|
397
|
+
*/
|
|
398
|
+
export type DestinationCategory = 'paste' | 'file_drop' | 'request_capture' | 'tunnel' | 'messaging' | 'news';
|
|
399
|
+
export declare const DESTINATION_CATEGORY_HOSTS: Readonly<Record<DestinationCategory, readonly string[]>>;
|
|
400
|
+
/** Categories whose purpose is to receive data from strangers: a first upload there is high risk. */
|
|
401
|
+
export declare const HIGH_RISK_DESTINATION_CATEGORIES: ReadonlySet<DestinationCategory>;
|
|
402
|
+
/** The listed host itself or any subdomain of it (`www.pastebin.com`, `x.m.pipedream.net`); never a look-alike (`notpastebin.com`). */
|
|
403
|
+
export declare function destinationCategory(host: string | undefined | null): DestinationCategory | undefined;
|
|
404
|
+
/** A host's category and whether that category exists to receive data from anyone — the shape the anomaly scorer takes. */
|
|
405
|
+
export declare function classifyDestinationHost(host: string): {
|
|
406
|
+
category: DestinationCategory;
|
|
407
|
+
dataDrop: boolean;
|
|
408
|
+
} | undefined;
|
|
409
|
+
/**
|
|
410
|
+
* One web call can name several addresses: Copilot `fetch_webpage`'s `urls`, a
|
|
411
|
+
* Codex `web.run` batch of opens / finds, a `url` list. Every address is judged
|
|
412
|
+
* (`evaluateActionPolicies`), not only the first (which keeps the call's own
|
|
413
|
+
* facts, as before). With two or more distinct addresses the call carries
|
|
414
|
+
* `url.batch` (JSON: the host facts of each of the first WEB_BATCH_URL_LIMIT
|
|
415
|
+
* addresses, in the call's order) and `url.batch.count` (every distinct address
|
|
416
|
+
* it names). Reserved derived facts (`url.*`): a caller-supplied value never
|
|
417
|
+
* survives. A call naming more than the limit is stopped, never judged on a part.
|
|
418
|
+
*/
|
|
419
|
+
export declare const WEB_BATCH_URL_LIMIT = 20;
|
|
420
|
+
/** Exported for reproducible detector artifacts; policy decisions are not packaged. */
|
|
421
|
+
export declare function inferBundledToolContext(toolName: string, args: Record<string, any>): {
|
|
422
|
+
operation: string;
|
|
423
|
+
context: Record<string, string>;
|
|
424
|
+
};
|
|
425
|
+
/** Static inventory match — same operation rules as runtime, without constraint context. */
|
|
426
|
+
export declare function inventoryToolMatchesActionPolicy(toolName: string, toolActions: string[] | undefined, policies: EngineActionPolicy[]): boolean;
|
|
427
|
+
export {};
|