@agent-corpus/policy-manager 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -3
- package/dist/adapters.d.ts +9 -0
- package/dist/adapters.js +49 -15
- package/dist/cli.js +63 -18
- package/dist/flow.js +61 -9
- package/dist/grants.js +42 -8
- package/dist/helpers.d.ts +59 -0
- package/dist/helpers.js +304 -0
- package/dist/permissive.d.ts +6 -0
- package/dist/permissive.js +216 -1
- package/dist/policy.js +10 -0
- package/dist/profile.d.ts +13 -0
- package/dist/profile.js +36 -0
- package/dist/review.d.ts +9 -0
- package/dist/review.js +16 -0
- package/dist/service.d.ts +14 -1
- package/dist/service.js +55 -4
- package/dist/session.d.ts +7 -0
- package/dist/session.js +34 -6
- package/dist/setup.d.ts +7 -0
- package/dist/setup.js +33 -5
- package/dist/shell.d.ts +2 -0
- package/dist/shell.js +1 -1
- package/dist/shim.d.ts +24 -0
- package/dist/shim.js +114 -0
- package/dist/tools.d.ts +23 -0
- package/dist/tools.js +66 -0
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Request } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Tools the engine judges itself: shell, file, patch and command-running tools. They are never
|
|
4
|
+
* approved by default and always get the engine's checks. MCP tools (`mcp__*`) follow
|
|
5
|
+
* `mcpReadOnly` instead.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ENGINE_TOOLS: Set<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Harness tools that are never approved by default and keep the classification path. Empty for
|
|
10
|
+
* now; a profile adds names through `toolsDeny`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const BUILTIN_TOOLS_DENY: Record<Request["harness"], ReadonlySet<string>>;
|
|
13
|
+
/**
|
|
14
|
+
* A name that suggests running code, feeding a running command, or touching files. Such a tool is
|
|
15
|
+
* never approved by default, even when ENGINE_TOOLS misses it, so a new or renamed one fails
|
|
16
|
+
* closed. A false positive (`BashOutput`, `SendUserFile`) only costs a classification.
|
|
17
|
+
*/
|
|
18
|
+
export declare const COMMAND_TOOL: RegExp;
|
|
19
|
+
/** A harness tool name a profile may list. */
|
|
20
|
+
export declare const TOOL_NAME: RegExp;
|
|
21
|
+
/** Whether a tool is approved by default: not an engine or MCP tool, and not denied. */
|
|
22
|
+
export declare function defaultAllowed(harness: Request["harness"], tool: string, deny: readonly string[]): boolean;
|
|
23
|
+
//# sourceMappingURL=tools.d.ts.map
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools the engine judges itself: shell, file, patch and command-running tools. They are never
|
|
3
|
+
* approved by default and always get the engine's checks. MCP tools (`mcp__*`) follow
|
|
4
|
+
* `mcpReadOnly` instead.
|
|
5
|
+
*/
|
|
6
|
+
export const ENGINE_TOOLS = new Set([
|
|
7
|
+
"Bash",
|
|
8
|
+
"bash",
|
|
9
|
+
"powershell",
|
|
10
|
+
"exec_command",
|
|
11
|
+
"shell",
|
|
12
|
+
"apply_patch",
|
|
13
|
+
"Read",
|
|
14
|
+
"view",
|
|
15
|
+
"read_file",
|
|
16
|
+
"Edit",
|
|
17
|
+
"Write",
|
|
18
|
+
"MultiEdit",
|
|
19
|
+
"NotebookEdit",
|
|
20
|
+
"edit",
|
|
21
|
+
"create",
|
|
22
|
+
"write_file",
|
|
23
|
+
"str_replace_editor",
|
|
24
|
+
// Read file contents or names, so they can reach credential paths.
|
|
25
|
+
"Grep",
|
|
26
|
+
"Glob",
|
|
27
|
+
"LS",
|
|
28
|
+
"NotebookRead",
|
|
29
|
+
"view_image",
|
|
30
|
+
// Runs a shell command in the background.
|
|
31
|
+
"Monitor",
|
|
32
|
+
// Run a command or feed a running one.
|
|
33
|
+
"shell_command",
|
|
34
|
+
"local_shell",
|
|
35
|
+
"unified_exec",
|
|
36
|
+
"write_stdin",
|
|
37
|
+
"write_bash",
|
|
38
|
+
"write_powershell",
|
|
39
|
+
].map((name) => name.toLowerCase()));
|
|
40
|
+
/**
|
|
41
|
+
* Harness tools that are never approved by default and keep the classification path. Empty for
|
|
42
|
+
* now; a profile adds names through `toolsDeny`.
|
|
43
|
+
*/
|
|
44
|
+
export const BUILTIN_TOOLS_DENY = {
|
|
45
|
+
claude: new Set(),
|
|
46
|
+
codex: new Set(),
|
|
47
|
+
copilot: new Set(),
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* A name that suggests running code, feeding a running command, or touching files. Such a tool is
|
|
51
|
+
* never approved by default, even when ENGINE_TOOLS misses it, so a new or renamed one fails
|
|
52
|
+
* closed. A false positive (`BashOutput`, `SendUserFile`) only costs a classification.
|
|
53
|
+
*/
|
|
54
|
+
export const COMMAND_TOOL = /bash|shell|powershell|pwsh|exec|stdin|terminal|command|cmd|spawn|repl|eval|python|node|interpreter|script|computer|run|file|delete|remove|move|rename|patch|edit/i;
|
|
55
|
+
/** A harness tool name a profile may list. */
|
|
56
|
+
export const TOOL_NAME = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;
|
|
57
|
+
/** Whether a tool is approved by default: not an engine or MCP tool, and not denied. */
|
|
58
|
+
export function defaultAllowed(harness, tool, deny) {
|
|
59
|
+
return (TOOL_NAME.test(tool) &&
|
|
60
|
+
!ENGINE_TOOLS.has(tool.toLowerCase()) &&
|
|
61
|
+
!COMMAND_TOOL.test(tool) &&
|
|
62
|
+
!tool.toLowerCase().startsWith("mcp__") &&
|
|
63
|
+
!BUILTIN_TOOLS_DENY[harness]?.has(tool) &&
|
|
64
|
+
!deny.includes(tool));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=tools.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -40,6 +40,12 @@ export interface Decision {
|
|
|
40
40
|
ai?: Classification;
|
|
41
41
|
/** A human decision the user may approve for the rest of the session (`approve --session`). */
|
|
42
42
|
sessionGrantable?: boolean;
|
|
43
|
+
/** What `approve --session` would cover, in words the user can check. */
|
|
44
|
+
sessionScopeLabel?: string;
|
|
45
|
+
/** A harness tool approved by default (not a shell, file, patch or MCP tool), by name. */
|
|
46
|
+
defaultTool?: string;
|
|
47
|
+
/** Listed credential helpers this request runs, as `<path>#<shape index>`. */
|
|
48
|
+
credentialHelpers?: string[];
|
|
43
49
|
/** The agent tried to approve a request itself: no approval instruction is offered for it. */
|
|
44
50
|
userOnly?: boolean;
|
|
45
51
|
}
|
package/package.json
CHANGED