@agent-corpus/policy-manager 0.10.0 → 0.11.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 +94 -29
- package/dist/adapters.d.ts +3 -1
- package/dist/adapters.js +37 -18
- package/dist/classifier.d.ts +98 -0
- package/dist/classifier.js +343 -0
- package/dist/cli.js +66 -7
- package/dist/config.d.ts +2 -0
- package/dist/config.js +6 -2
- package/dist/evidence.d.ts +1 -0
- package/dist/evidence.js +60 -0
- package/dist/flow.d.ts +4 -0
- package/dist/flow.js +68 -13
- package/dist/gitalias.d.ts +13 -0
- package/dist/gitalias.js +33 -0
- package/dist/grants.d.ts +9 -9
- package/dist/grants.js +46 -35
- package/dist/hard.d.ts +63 -0
- package/dist/hard.js +1637 -0
- package/dist/merged.d.ts +6 -0
- package/dist/merged.js +23 -0
- package/dist/nativerules.d.ts +44 -0
- package/dist/nativerules.js +653 -0
- package/dist/permissive.js +32 -6
- package/dist/policy.d.ts +12 -0
- package/dist/policy.js +228 -45
- package/dist/profile.d.ts +4 -0
- package/dist/profile.js +19 -1
- package/dist/prompt.d.ts +32 -0
- package/dist/prompt.js +334 -0
- package/dist/reads.d.ts +46 -0
- package/dist/reads.js +812 -0
- package/dist/replay.d.ts +42 -0
- package/dist/replay.js +174 -1
- package/dist/service.d.ts +12 -1
- package/dist/service.js +23 -6
- package/dist/session.d.ts +76 -13
- package/dist/session.js +373 -116
- package/dist/shellscan.d.ts +58 -0
- package/dist/shellscan.js +395 -0
- package/dist/statepaths.d.ts +41 -0
- package/dist/statepaths.js +706 -0
- package/dist/types.d.ts +9 -1
- package/package.json +1 -1
package/dist/merged.d.ts
CHANGED
|
@@ -11,4 +11,10 @@ export interface MergedEvidence {
|
|
|
11
11
|
export declare function mergedEvidence(cwd: string, ref: string): MergedEvidence;
|
|
12
12
|
/** The remote tip must match the fetched tracking ref, or a delete could discard unseen commits. */
|
|
13
13
|
export declare function remoteTipMatches(cwd: string, branch: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether deleting local branch `branch` loses no commit: its tip is reachable from a
|
|
16
|
+
* remote-tracking ref (which covers a tip equal to its upstream). The commits stay recoverable
|
|
17
|
+
* from that ref. A tip that exists only locally is not.
|
|
18
|
+
*/
|
|
19
|
+
export declare function onRemote(cwd: string, branch: string): boolean;
|
|
14
20
|
//# sourceMappingURL=merged.d.ts.map
|
package/dist/merged.js
CHANGED
|
@@ -93,4 +93,27 @@ export function remoteTipMatches(cwd, branch) {
|
|
|
93
93
|
return false;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Whether deleting local branch `branch` loses no commit: its tip is reachable from a
|
|
98
|
+
* remote-tracking ref (which covers a tip equal to its upstream). The commits stay recoverable
|
|
99
|
+
* from that ref. A tip that exists only locally is not.
|
|
100
|
+
*/
|
|
101
|
+
export function onRemote(cwd, branch) {
|
|
102
|
+
if (!BRANCH_NAME.test(branch) || /^(?:main|master|HEAD)$/.test(branch))
|
|
103
|
+
return false;
|
|
104
|
+
try {
|
|
105
|
+
const tip = git(cwd, ["rev-parse", "--verify", `refs/heads/${branch}^{commit}`]);
|
|
106
|
+
return (git(cwd, [
|
|
107
|
+
"for-each-ref",
|
|
108
|
+
"--count=1",
|
|
109
|
+
"--contains",
|
|
110
|
+
tip,
|
|
111
|
+
"--format=%(refname)",
|
|
112
|
+
"refs/remotes/",
|
|
113
|
+
]) !== "");
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
96
119
|
//# sourceMappingURL=merged.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Request } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The user's own permission rules in each harness, read (never written) so the policy manager
|
|
4
|
+
* agrees with them: a user deny or ask rule beats any approval here (no hook decision, so the
|
|
5
|
+
* harness's own flow applies), and a user allow rule counts as the person's answer.
|
|
6
|
+
*/
|
|
7
|
+
export type NativeVerdict = "allow" | "ask" | "deny";
|
|
8
|
+
export interface NativeMatch {
|
|
9
|
+
verdict: NativeVerdict;
|
|
10
|
+
/** The rule that decided it, as the user wrote it. */
|
|
11
|
+
rule: string;
|
|
12
|
+
/** The file it came from. */
|
|
13
|
+
source: string;
|
|
14
|
+
}
|
|
15
|
+
/** `*` matches any run of characters, including none and spaces. O(text × pattern) worst case. */
|
|
16
|
+
export declare function wildcard(pattern: string, text: string): boolean;
|
|
17
|
+
/** Gitignore-style path glob over `/` segments: `**` any segments, `*` and `?` within one. */
|
|
18
|
+
export declare function pathGlob(pattern: string, path: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* One Bash rule against one subcommand's text. Without `*` the rule is the exact command.
|
|
21
|
+
* `cmd:*` is the same as `cmd *`; a rule whose only `*` is a trailing ` *` also matches the bare
|
|
22
|
+
* command (`Bash(ls *)` matches `ls`, not `lsof`). Otherwise `*` matches any text, spaces too.
|
|
23
|
+
*/
|
|
24
|
+
export declare function bashRuleMatches(content: string, text: string): boolean;
|
|
25
|
+
type CodexDecision = "allow" | "prompt" | "forbidden";
|
|
26
|
+
interface PrefixRule {
|
|
27
|
+
pattern: string[][];
|
|
28
|
+
decision: CodexDecision;
|
|
29
|
+
text: string;
|
|
30
|
+
}
|
|
31
|
+
/** Parses the `prefix_rule(...)` calls of a rules file. Other statements are skipped. */
|
|
32
|
+
export declare function parseCodexRules(text: string): PrefixRule[];
|
|
33
|
+
/**
|
|
34
|
+
* The invocations Codex evaluates for a shell script: each command of a linear chain of plain
|
|
35
|
+
* words joined by `&&`, `||`, `;` or `|`; anything else (redirects, substitutions, assignments,
|
|
36
|
+
* globs, control flow) is one `bash -lc <script>` invocation.
|
|
37
|
+
*/
|
|
38
|
+
export declare function codexInvocations(script: string): string[][];
|
|
39
|
+
/** The user's own rule verdict for a request in its harness, or undefined when none applies. */
|
|
40
|
+
export declare function nativeRules(request: Request): NativeMatch | undefined;
|
|
41
|
+
/** For tests: forget cached rule files. */
|
|
42
|
+
export declare function clearNativeRuleCache(): void;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=nativerules.d.ts.map
|