strands-darwin 0.0.32 → 0.0.34
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 +3 -1
- package/README.zh-CN.md +3 -1
- package/dist/src/agent/background-delegation.d.ts +69 -11
- package/dist/src/agent/background-delegation.js +156 -28
- package/dist/src/agent/background-delegation.js.map +1 -1
- package/dist/src/agent/cache-miss.d.ts +143 -0
- package/dist/src/agent/cache-miss.js +182 -0
- package/dist/src/agent/cache-miss.js.map +1 -0
- package/dist/src/agent/compact.d.ts +28 -0
- package/dist/src/agent/compact.js +34 -0
- package/dist/src/agent/compact.js.map +1 -1
- package/dist/src/agent/context-breakdown.d.ts +109 -0
- package/dist/src/agent/context-breakdown.js +116 -0
- package/dist/src/agent/context-breakdown.js.map +1 -0
- package/dist/src/agent/instructions.d.ts +1 -1
- package/dist/src/agent/instructions.js.map +1 -1
- package/dist/src/agent/permission-rules.d.ts +81 -2
- package/dist/src/agent/permission-rules.js +226 -6
- package/dist/src/agent/permission-rules.js.map +1 -1
- package/dist/src/agent/permission.d.ts +116 -2
- package/dist/src/agent/permission.js +201 -26
- package/dist/src/agent/permission.js.map +1 -1
- package/dist/src/agent/prompt-cache.d.ts +12 -3
- package/dist/src/agent/prompt-cache.js +12 -3
- package/dist/src/agent/prompt-cache.js.map +1 -1
- package/dist/src/agent/runtime.d.ts +141 -1
- package/dist/src/agent/runtime.js +259 -13
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/agent/task-terminal-delivery.d.ts +43 -0
- package/dist/src/agent/task-terminal-delivery.js +115 -0
- package/dist/src/agent/task-terminal-delivery.js.map +1 -0
- package/dist/src/agents/child-recipe.d.ts +9 -1
- package/dist/src/agents/child-recipe.js +2 -0
- package/dist/src/agents/child-recipe.js.map +1 -1
- package/dist/src/agents/dispatch-registry.d.ts +18 -0
- package/dist/src/agents/dispatch-registry.js +2 -0
- package/dist/src/agents/dispatch-registry.js.map +1 -1
- package/dist/src/agents/retained-children.d.ts +101 -0
- package/dist/src/agents/retained-children.js +101 -0
- package/dist/src/agents/retained-children.js.map +1 -0
- package/dist/src/agents/subagent-tool.d.ts +56 -1
- package/dist/src/agents/subagent-tool.js +148 -10
- package/dist/src/agents/subagent-tool.js.map +1 -1
- package/dist/src/agents/workflow-tool.d.ts +2 -0
- package/dist/src/agents/workflow-tool.js +1 -1
- package/dist/src/agents/workflow-tool.js.map +1 -1
- package/dist/src/cli-doctor.js +3 -1
- package/dist/src/cli-doctor.js.map +1 -1
- package/dist/src/cli-main.js +14 -3
- package/dist/src/cli-main.js.map +1 -1
- package/dist/src/commands/custom-commands.js +5 -4
- package/dist/src/commands/custom-commands.js.map +1 -1
- package/dist/src/config.d.ts +57 -6
- package/dist/src/config.js +43 -16
- package/dist/src/config.js.map +1 -1
- package/dist/src/headless-protocol.d.ts +1 -1
- package/dist/src/headless-runner.js +7 -2
- package/dist/src/headless-runner.js.map +1 -1
- package/dist/src/hooks/tool-hooks.js +10 -6
- package/dist/src/hooks/tool-hooks.js.map +1 -1
- package/dist/src/skills/builtin/self-evolution-research/SKILL.md +14 -1
- package/dist/src/skills/prompt.d.ts +17 -0
- package/dist/src/skills/prompt.js +20 -0
- package/dist/src/skills/prompt.js.map +1 -1
- package/dist/src/tools/background-bash.d.ts +11 -2
- package/dist/src/tools/background-bash.js +11 -5
- package/dist/src/tools/background-bash.js.map +1 -1
- package/dist/src/tools/background-tail.d.ts +1 -0
- package/dist/src/tools/background-tail.js +2 -1
- package/dist/src/tools/background-tail.js.map +1 -1
- package/dist/src/tools/background-wait-contract.d.ts +7 -0
- package/dist/src/tools/background-wait-contract.js +17 -0
- package/dist/src/tools/background-wait-contract.js.map +1 -1
- package/dist/src/trajectory/record.d.ts +212 -2
- package/dist/src/trajectory/record.js +138 -0
- package/dist/src/trajectory/record.js.map +1 -1
- package/dist/src/trajectory/replay.d.ts +34 -1
- package/dist/src/trajectory/replay.js +148 -4
- package/dist/src/trajectory/replay.js.map +1 -1
- package/dist/src/trajectory/resume-recap.js +10 -3
- package/dist/src/trajectory/resume-recap.js.map +1 -1
- package/dist/src/trajectory/spend.d.ts +14 -1
- package/dist/src/trajectory/spend.js +40 -6
- package/dist/src/trajectory/spend.js.map +1 -1
- package/dist/src/trajectory/writer.d.ts +57 -6
- package/dist/src/trajectory/writer.js +141 -9
- package/dist/src/trajectory/writer.js.map +1 -1
- package/dist/src/tui/App.d.ts +8 -4
- package/dist/src/tui/App.js +302 -55
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/background-tool-presentation.js +2 -2
- package/dist/src/tui/background-tool-presentation.js.map +1 -1
- package/dist/src/tui/context-format.d.ts +16 -0
- package/dist/src/tui/context-format.js +41 -0
- package/dist/src/tui/context-format.js.map +1 -1
- package/dist/src/tui/prompt-queue.d.ts +52 -8
- package/dist/src/tui/prompt-queue.js +68 -8
- package/dist/src/tui/prompt-queue.js.map +1 -1
- package/dist/src/tui/status-format.d.ts +35 -16
- package/dist/src/tui/status-format.js +67 -8
- package/dist/src/tui/status-format.js.map +1 -1
- package/dist/src/tui/subagent-format.d.ts +8 -0
- package/dist/src/tui/subagent-format.js +24 -1
- package/dist/src/tui/subagent-format.js.map +1 -1
- package/dist/src/tui/task-wake.d.ts +75 -0
- package/dist/src/tui/task-wake.js +201 -0
- package/dist/src/tui/task-wake.js.map +1 -0
- package/dist/src/tui/terminal-notify.d.ts +40 -0
- package/dist/src/tui/terminal-notify.js +136 -0
- package/dist/src/tui/terminal-notify.js.map +1 -0
- package/dist/src/tui/terminal-title.d.ts +94 -0
- package/dist/src/tui/terminal-title.js +121 -0
- package/dist/src/tui/terminal-title.js.map +1 -0
- package/dist/src/tui/turn-state.d.ts +10 -1
- package/dist/src/tui/turn-state.js +17 -1
- package/dist/src/tui/turn-state.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,6 +10,55 @@ export interface RuleSuggestion {
|
|
|
10
10
|
/** Short label for the option line, e.g. `pnpm *` or `all bash`. */
|
|
11
11
|
label: string;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Home-relative directories whose every entry is a credential. The directory
|
|
15
|
+
* itself counts too: listing `~/.ssh` names the keys that exist.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SENSITIVE_READ_DIRECTORIES: readonly string[];
|
|
18
|
+
/** Home-relative files that hold credentials. */
|
|
19
|
+
export declare const SENSITIVE_READ_HOME_FILES: readonly string[];
|
|
20
|
+
/** Absolute files that hold credentials. */
|
|
21
|
+
export declare const SENSITIVE_READ_ABSOLUTE_FILES: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* The fixed sensitive-read set (SER-071): a resolved absolute path that is under
|
|
24
|
+
* one of {@link SENSITIVE_READ_DIRECTORIES}, is one of the home or absolute
|
|
25
|
+
* credential files, has a `.env` / `.env.*` basename anywhere, or is one of
|
|
26
|
+
* darwin's own policy files ({@link isSensitiveDarwinPath}).
|
|
27
|
+
*
|
|
28
|
+
* A fixed set rather than "outside the project": darwin legitimately reads
|
|
29
|
+
* `/tmp`, `/etc/os-release` and the global skill roots, and a one-line list is
|
|
30
|
+
* something a prompt can explain.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isSensitiveReadPath(projectRoot: string, resolved: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The credential location a recursive content search started at `resolved`
|
|
35
|
+
* would descend into — `~/.ssh` for `~`, `/home/<user>` or `/`; `/etc/shadow`
|
|
36
|
+
* for `/etc` — or undefined. Only the fixed home/absolute locations qualify:
|
|
37
|
+
* `.env*` basenames are excluded on purpose, or `grep -r foo .` would prompt in
|
|
38
|
+
* every project that has a `.env`. Returned `~`-abbreviated for the prompt.
|
|
39
|
+
*/
|
|
40
|
+
export declare function sensitiveLocationBelow(resolved: string): string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* One path argument as the shell (or the model) would resolve it: `~`, `~/…`,
|
|
43
|
+
* `$HOME…` and `${HOME}…` against the home directory, relative forms against
|
|
44
|
+
* the project root, `..` segments normalised. Surrounding quotes are dropped
|
|
45
|
+
* first — bash would not expand a quoted `~`, so this over-approximates, which
|
|
46
|
+
* for a read costs a prompt and never a silent approval.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveReadTarget(argument: string, projectRoot: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* The first read target of this call that falls in the sensitive set, as the
|
|
51
|
+
* model wrote it, or undefined when the call reads nothing sensitive (SER-071).
|
|
52
|
+
*
|
|
53
|
+
* Targets are the `path` of `fileEditor view` and every non-option argument of
|
|
54
|
+
* every {@link BASH_PATH_READERS} segment of a bash command — a pattern
|
|
55
|
+
* argument (`rg password ~/.gnupg`) is resolved like a path and simply misses.
|
|
56
|
+
* For the {@link RECURSIVE_CONTENT_READERS} an argument that is an ancestor of a
|
|
57
|
+
* credential location also counts, returned as
|
|
58
|
+
* `<arg> (searches above <location>)`. Any other tool or command reads nothing
|
|
59
|
+
* this function can see.
|
|
60
|
+
*/
|
|
61
|
+
export declare function sensitiveReadPath(toolName: string, input: unknown, projectRoot: string): string | undefined;
|
|
13
62
|
/** True when the command contains redirection or substitution. */
|
|
14
63
|
export declare function hasShellMetacharacters(command: string): boolean;
|
|
15
64
|
/**
|
|
@@ -33,10 +82,40 @@ export declare function isValidRule(rule: string): boolean;
|
|
|
33
82
|
* permissions.
|
|
34
83
|
*/
|
|
35
84
|
export declare function matchesAnyRule(rules: readonly string[], target: RuleTarget, projectRoot: string): string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* The first deny-rule that forbids this call, or undefined when none does
|
|
87
|
+
* (SER-076). Same grammar as {@link matchesAnyRule}, inverted conservatism:
|
|
88
|
+
*
|
|
89
|
+
* - no exemptions — {@link isRuleExempt} exists so a rule cannot *widen*, and a
|
|
90
|
+
* deny only ever narrows, so `memory_save`, `.env*` and darwin's own policy
|
|
91
|
+
* files can be denied like anything else;
|
|
92
|
+
* - a bash pattern forbids the call when **any** segment matches, not every one
|
|
93
|
+
* (`git status && git push --force` is a forced push), and the segments are
|
|
94
|
+
* cut more finely than for allow — also at `$(`, backticks, parentheses, `&`
|
|
95
|
+
* and redirection — so `echo $(git push --force)` and `(git push --force)`
|
|
96
|
+
* expose the forbidden words as a segment of their own;
|
|
97
|
+
* - shell metacharacters never exempt the call — for allow they mean "the words
|
|
98
|
+
* no longer say what will run", which for a prohibition is a reason to deny,
|
|
99
|
+
* not to look away;
|
|
100
|
+
* - a file pattern applies to every `fileEditor` call on the path, `view`
|
|
101
|
+
* included, exactly as an allow pattern would cover it.
|
|
102
|
+
*
|
|
103
|
+
* The allow matcher above is untouched: the two directions share the parser and
|
|
104
|
+
* the pattern primitives, not the decision.
|
|
105
|
+
*/
|
|
106
|
+
export declare function matchesAnyDenyRule(rules: readonly string[], target: RuleTarget, projectRoot: string): string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* The deny-side cut of a command: {@link splitBashSegments}' operators plus
|
|
109
|
+
* substitution openers, grouping parentheses, `&` and redirection. Over-splitting
|
|
110
|
+
* is the safe direction here — a spurious segment can only match a deny pattern
|
|
111
|
+
* the user wrote, never clear one.
|
|
112
|
+
*/
|
|
113
|
+
export declare function splitDenySegments(command: string): string[];
|
|
36
114
|
/**
|
|
37
115
|
* Calls no rule may ever cover: darwin's own config (a rule there lets the agent
|
|
38
|
-
* grant itself more rules)
|
|
39
|
-
*
|
|
116
|
+
* grant itself more rules), environment files, and — the read side of the same
|
|
117
|
+
* exemption (SER-071) — any read into the sensitive set. All are also
|
|
118
|
+
* `dangerous` statically, so the effect is that they always ask.
|
|
40
119
|
*/
|
|
41
120
|
export declare function isRuleExempt(target: RuleTarget, projectRoot: string): boolean;
|
|
42
121
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Wildcard allow-rules: "stop asking about calls like this one"
|
|
2
|
+
* Wildcard allow-rules: "stop asking about calls like this one" — and, in the
|
|
3
|
+
* same grammar, deny-rules: "never run calls like this one" (SER-076).
|
|
3
4
|
*
|
|
4
5
|
* A rule is a string, so it survives a round trip through `.darwin/config.json`
|
|
5
6
|
* unchanged and stays readable in it:
|
|
@@ -9,10 +10,12 @@
|
|
|
9
10
|
* - `bash` — no colon: every call of that tool. The only shape available for
|
|
10
11
|
* unknown and MCP tools, whose input has no structure we can reason about.
|
|
11
12
|
*
|
|
12
|
-
* The matcher is deliberately conservative in the same way the static risk
|
|
13
|
-
* are: anything it cannot reason about does not match, and a non-match only
|
|
14
|
-
* a prompt.
|
|
13
|
+
* The allow matcher is deliberately conservative in the same way the static risk
|
|
14
|
+
* rules are: anything it cannot reason about does not match, and a non-match only
|
|
15
|
+
* costs a prompt. The deny matcher ({@link matchesAnyDenyRule}) is conservative in
|
|
16
|
+
* the opposite direction: anything that *might* be the forbidden call is denied.
|
|
15
17
|
*/
|
|
18
|
+
import os from 'node:os';
|
|
16
19
|
import path from 'node:path';
|
|
17
20
|
import { isSensitiveDarwinPath } from '../paths.js';
|
|
18
21
|
/**
|
|
@@ -23,6 +26,148 @@ import { isSensitiveDarwinPath } from '../paths.js';
|
|
|
23
26
|
const SHELL_METACHARACTERS = /[><`]|\$\(/;
|
|
24
27
|
/** Sensitive file basenames no rule may cover. */
|
|
25
28
|
const ENV_FILE = /^\.env(\..+)?$/;
|
|
29
|
+
/**
|
|
30
|
+
* Whitelisted bash readers whose non-option arguments name files (SER-071).
|
|
31
|
+
* `echo` is on the static safe list but deliberately absent here: with `<` and
|
|
32
|
+
* `$(` refused as metacharacters it can only print its arguments, never open a
|
|
33
|
+
* file, so `echo ~/.ssh/id_rsa` reveals a path string and nothing else. `pwd`
|
|
34
|
+
* and `which` take no file paths.
|
|
35
|
+
*/
|
|
36
|
+
const BASH_PATH_READERS = new Set(['cat', 'head', 'tail', 'grep', 'rg', 'find', 'ls', 'wc']);
|
|
37
|
+
/**
|
|
38
|
+
* The two readers that recurse into file *contents*: `grep -r AKIA ~` or
|
|
39
|
+
* `rg -uu password /` reads `~/.aws/credentials` without ever naming it, so for
|
|
40
|
+
* these a start directory that is an ancestor of a credential location counts
|
|
41
|
+
* too. Deliberately not `cat`/`head`/`tail`/`wc` (one file each, named) and not
|
|
42
|
+
* `find`/`ls -R`, which reveal names only, never contents.
|
|
43
|
+
*/
|
|
44
|
+
const RECURSIVE_CONTENT_READERS = new Set(['grep', 'rg']);
|
|
45
|
+
/**
|
|
46
|
+
* Home-relative directories whose every entry is a credential. The directory
|
|
47
|
+
* itself counts too: listing `~/.ssh` names the keys that exist.
|
|
48
|
+
*/
|
|
49
|
+
export const SENSITIVE_READ_DIRECTORIES = ['.ssh', '.aws', '.gnupg'];
|
|
50
|
+
/** Home-relative files that hold credentials. */
|
|
51
|
+
export const SENSITIVE_READ_HOME_FILES = [
|
|
52
|
+
'.netrc',
|
|
53
|
+
path.join('.kube', 'config'),
|
|
54
|
+
path.join('.docker', 'config.json'),
|
|
55
|
+
];
|
|
56
|
+
/** Absolute files that hold credentials. */
|
|
57
|
+
export const SENSITIVE_READ_ABSOLUTE_FILES = ['/etc/shadow'];
|
|
58
|
+
/**
|
|
59
|
+
* The fixed sensitive-read set (SER-071): a resolved absolute path that is under
|
|
60
|
+
* one of {@link SENSITIVE_READ_DIRECTORIES}, is one of the home or absolute
|
|
61
|
+
* credential files, has a `.env` / `.env.*` basename anywhere, or is one of
|
|
62
|
+
* darwin's own policy files ({@link isSensitiveDarwinPath}).
|
|
63
|
+
*
|
|
64
|
+
* A fixed set rather than "outside the project": darwin legitimately reads
|
|
65
|
+
* `/tmp`, `/etc/os-release` and the global skill roots, and a one-line list is
|
|
66
|
+
* something a prompt can explain.
|
|
67
|
+
*/
|
|
68
|
+
export function isSensitiveReadPath(projectRoot, resolved) {
|
|
69
|
+
const home = os.homedir();
|
|
70
|
+
if (SENSITIVE_READ_DIRECTORIES.some((directory) => isInside(path.join(home, directory), resolved)))
|
|
71
|
+
return true;
|
|
72
|
+
if (SENSITIVE_READ_HOME_FILES.some((file) => samePath(path.join(home, file), resolved)))
|
|
73
|
+
return true;
|
|
74
|
+
if (SENSITIVE_READ_ABSOLUTE_FILES.some((file) => samePath(file, resolved)))
|
|
75
|
+
return true;
|
|
76
|
+
if (ENV_FILE.test(path.basename(resolved)))
|
|
77
|
+
return true;
|
|
78
|
+
return isSensitiveDarwinPath(projectRoot, resolved);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The credential location a recursive content search started at `resolved`
|
|
82
|
+
* would descend into — `~/.ssh` for `~`, `/home/<user>` or `/`; `/etc/shadow`
|
|
83
|
+
* for `/etc` — or undefined. Only the fixed home/absolute locations qualify:
|
|
84
|
+
* `.env*` basenames are excluded on purpose, or `grep -r foo .` would prompt in
|
|
85
|
+
* every project that has a `.env`. Returned `~`-abbreviated for the prompt.
|
|
86
|
+
*/
|
|
87
|
+
export function sensitiveLocationBelow(resolved) {
|
|
88
|
+
const home = os.homedir();
|
|
89
|
+
for (const directory of SENSITIVE_READ_DIRECTORIES) {
|
|
90
|
+
if (isInside(resolved, path.join(home, directory)))
|
|
91
|
+
return `~/${directory}`;
|
|
92
|
+
}
|
|
93
|
+
for (const file of SENSITIVE_READ_HOME_FILES) {
|
|
94
|
+
if (isInside(resolved, path.join(home, file)))
|
|
95
|
+
return `~/${file.split(path.sep).join('/')}`;
|
|
96
|
+
}
|
|
97
|
+
return SENSITIVE_READ_ABSOLUTE_FILES.find((file) => isInside(resolved, file));
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* One path argument as the shell (or the model) would resolve it: `~`, `~/…`,
|
|
101
|
+
* `$HOME…` and `${HOME}…` against the home directory, relative forms against
|
|
102
|
+
* the project root, `..` segments normalised. Surrounding quotes are dropped
|
|
103
|
+
* first — bash would not expand a quoted `~`, so this over-approximates, which
|
|
104
|
+
* for a read costs a prompt and never a silent approval.
|
|
105
|
+
*/
|
|
106
|
+
export function resolveReadTarget(argument, projectRoot) {
|
|
107
|
+
const unquoted = argument.replace(/^(["'])([\s\S]*)\1$/, '$2');
|
|
108
|
+
const home = os.homedir();
|
|
109
|
+
let expanded = unquoted;
|
|
110
|
+
if (unquoted === '~')
|
|
111
|
+
expanded = home;
|
|
112
|
+
else if (unquoted.startsWith('~/'))
|
|
113
|
+
expanded = path.join(home, unquoted.slice(2));
|
|
114
|
+
else if (/^\$(HOME|\{HOME\})(\/|$)/.test(unquoted))
|
|
115
|
+
expanded = path.join(home, unquoted.replace(/^\$(HOME|\{HOME\})/, ''));
|
|
116
|
+
return path.resolve(projectRoot, expanded);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The first read target of this call that falls in the sensitive set, as the
|
|
120
|
+
* model wrote it, or undefined when the call reads nothing sensitive (SER-071).
|
|
121
|
+
*
|
|
122
|
+
* Targets are the `path` of `fileEditor view` and every non-option argument of
|
|
123
|
+
* every {@link BASH_PATH_READERS} segment of a bash command — a pattern
|
|
124
|
+
* argument (`rg password ~/.gnupg`) is resolved like a path and simply misses.
|
|
125
|
+
* For the {@link RECURSIVE_CONTENT_READERS} an argument that is an ancestor of a
|
|
126
|
+
* credential location also counts, returned as
|
|
127
|
+
* `<arg> (searches above <location>)`. Any other tool or command reads nothing
|
|
128
|
+
* this function can see.
|
|
129
|
+
*/
|
|
130
|
+
export function sensitiveReadPath(toolName, input, projectRoot) {
|
|
131
|
+
if (toolName === 'fileEditor') {
|
|
132
|
+
if (readString(input, 'command') !== 'view')
|
|
133
|
+
return undefined;
|
|
134
|
+
const filePath = readString(input, 'path');
|
|
135
|
+
if (filePath === undefined || filePath === '')
|
|
136
|
+
return undefined;
|
|
137
|
+
return isSensitiveReadPath(projectRoot, resolveReadTarget(filePath, projectRoot)) ? filePath : undefined;
|
|
138
|
+
}
|
|
139
|
+
if (toolName === 'bash') {
|
|
140
|
+
const command = readString(input, 'command');
|
|
141
|
+
if (command === undefined)
|
|
142
|
+
return undefined;
|
|
143
|
+
for (const segment of splitBashSegments(command)) {
|
|
144
|
+
const [word = '', ...args] = segment.split(/\s+/);
|
|
145
|
+
if (!BASH_PATH_READERS.has(word))
|
|
146
|
+
continue;
|
|
147
|
+
const recursive = RECURSIVE_CONTENT_READERS.has(word);
|
|
148
|
+
for (const arg of args) {
|
|
149
|
+
if (arg.startsWith('-'))
|
|
150
|
+
continue;
|
|
151
|
+
const resolved = resolveReadTarget(arg, projectRoot);
|
|
152
|
+
if (isSensitiveReadPath(projectRoot, resolved))
|
|
153
|
+
return arg;
|
|
154
|
+
if (recursive) {
|
|
155
|
+
const below = sensitiveLocationBelow(resolved);
|
|
156
|
+
if (below !== undefined)
|
|
157
|
+
return `${arg} (searches above ${below})`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
function samePath(left, right) {
|
|
165
|
+
return path.relative(left, right) === '';
|
|
166
|
+
}
|
|
167
|
+
function isInside(root, candidate) {
|
|
168
|
+
const relative = path.relative(root, candidate);
|
|
169
|
+
return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));
|
|
170
|
+
}
|
|
26
171
|
/**
|
|
27
172
|
* Commands whose first word is only a dispatcher: `git push` and `git status`
|
|
28
173
|
* have nothing in common, so a rule derived from `git …` alone would be far
|
|
@@ -110,14 +255,77 @@ export function matchesAnyRule(rules, target, projectRoot) {
|
|
|
110
255
|
}
|
|
111
256
|
return undefined;
|
|
112
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* The first deny-rule that forbids this call, or undefined when none does
|
|
260
|
+
* (SER-076). Same grammar as {@link matchesAnyRule}, inverted conservatism:
|
|
261
|
+
*
|
|
262
|
+
* - no exemptions — {@link isRuleExempt} exists so a rule cannot *widen*, and a
|
|
263
|
+
* deny only ever narrows, so `memory_save`, `.env*` and darwin's own policy
|
|
264
|
+
* files can be denied like anything else;
|
|
265
|
+
* - a bash pattern forbids the call when **any** segment matches, not every one
|
|
266
|
+
* (`git status && git push --force` is a forced push), and the segments are
|
|
267
|
+
* cut more finely than for allow — also at `$(`, backticks, parentheses, `&`
|
|
268
|
+
* and redirection — so `echo $(git push --force)` and `(git push --force)`
|
|
269
|
+
* expose the forbidden words as a segment of their own;
|
|
270
|
+
* - shell metacharacters never exempt the call — for allow they mean "the words
|
|
271
|
+
* no longer say what will run", which for a prohibition is a reason to deny,
|
|
272
|
+
* not to look away;
|
|
273
|
+
* - a file pattern applies to every `fileEditor` call on the path, `view`
|
|
274
|
+
* included, exactly as an allow pattern would cover it.
|
|
275
|
+
*
|
|
276
|
+
* The allow matcher above is untouched: the two directions share the parser and
|
|
277
|
+
* the pattern primitives, not the decision.
|
|
278
|
+
*/
|
|
279
|
+
export function matchesAnyDenyRule(rules, target, projectRoot) {
|
|
280
|
+
for (const rule of rules) {
|
|
281
|
+
const parsed = parseRule(rule);
|
|
282
|
+
if (parsed === undefined)
|
|
283
|
+
continue;
|
|
284
|
+
if (parsed.toolName !== target.toolName)
|
|
285
|
+
continue;
|
|
286
|
+
if (parsed.pattern === undefined)
|
|
287
|
+
return rule;
|
|
288
|
+
if (patternForbids(parsed.pattern, target, projectRoot))
|
|
289
|
+
return rule;
|
|
290
|
+
}
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* The deny-side cut of a command: {@link splitBashSegments}' operators plus
|
|
295
|
+
* substitution openers, grouping parentheses, `&` and redirection. Over-splitting
|
|
296
|
+
* is the safe direction here — a spurious segment can only match a deny pattern
|
|
297
|
+
* the user wrote, never clear one.
|
|
298
|
+
*/
|
|
299
|
+
export function splitDenySegments(command) {
|
|
300
|
+
return command
|
|
301
|
+
.split(/&&|\|\||\$\(|[;|\n&`()<>]/)
|
|
302
|
+
.map((segment) => segment.trim())
|
|
303
|
+
.filter((segment) => segment !== '');
|
|
304
|
+
}
|
|
305
|
+
function patternForbids(pattern, target, projectRoot) {
|
|
306
|
+
if (target.toolName === 'bash') {
|
|
307
|
+
const command = readString(target.input, 'command') ?? '';
|
|
308
|
+
return splitDenySegments(command).some((segment) => commandMatches(pattern, segment));
|
|
309
|
+
}
|
|
310
|
+
if (target.toolName === 'fileEditor') {
|
|
311
|
+
const filePath = readString(target.input, 'path');
|
|
312
|
+
if (filePath === undefined)
|
|
313
|
+
return false;
|
|
314
|
+
return pathMatches(pattern, toPosix(projectRelativeOrAbsolute(filePath, projectRoot)));
|
|
315
|
+
}
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
113
318
|
/**
|
|
114
319
|
* Calls no rule may ever cover: darwin's own config (a rule there lets the agent
|
|
115
|
-
* grant itself more rules)
|
|
116
|
-
*
|
|
320
|
+
* grant itself more rules), environment files, and — the read side of the same
|
|
321
|
+
* exemption (SER-071) — any read into the sensitive set. All are also
|
|
322
|
+
* `dangerous` statically, so the effect is that they always ask.
|
|
117
323
|
*/
|
|
118
324
|
export function isRuleExempt(target, projectRoot) {
|
|
119
325
|
if (target.toolName === 'memory_save')
|
|
120
326
|
return true;
|
|
327
|
+
if (sensitiveReadPath(target.toolName, target.input, projectRoot) !== undefined)
|
|
328
|
+
return true;
|
|
121
329
|
if (target.toolName !== 'fileEditor')
|
|
122
330
|
return false;
|
|
123
331
|
const filePath = readString(target.input, 'path');
|
|
@@ -245,6 +453,18 @@ function normalizeSpaces(value) {
|
|
|
245
453
|
function toPosix(value) {
|
|
246
454
|
return value.split(path.sep).join('/');
|
|
247
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* The path a file pattern is matched against: project-relative when the target
|
|
458
|
+
* lies inside the project, the resolved absolute path otherwise — the same view
|
|
459
|
+
* `patternCovers` takes for allow, so `fileEditor:dist/**` names the same files
|
|
460
|
+
* in both directions.
|
|
461
|
+
*/
|
|
462
|
+
function projectRelativeOrAbsolute(filePath, projectRoot) {
|
|
463
|
+
const resolved = path.resolve(projectRoot, filePath);
|
|
464
|
+
const relative = path.relative(projectRoot, resolved);
|
|
465
|
+
const inside = relative !== '' && !relative.startsWith('..') && !path.isAbsolute(relative);
|
|
466
|
+
return inside ? relative : resolved;
|
|
467
|
+
}
|
|
248
468
|
function escapeRegExp(value) {
|
|
249
469
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
250
470
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-rules.js","sourceRoot":"","sources":["../../../src/agent/permission-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAgBpD;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C,kDAAkD;AAClD,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAElC;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,QAAQ;IACR,SAAS;IACT,MAAM;IACN,MAAM;IACN,IAAI;IACJ,SAAS;IACT,KAAK;IACL,QAAQ;CACT,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,kEAAkE;AAClE,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,OAAO,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,OAAO;SACX,KAAK,CAAC,gBAAgB,CAAC;SACvB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;SAChC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAA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I,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,QAAQ,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC3F,OAAO,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;AACtC,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,GAAG,CAAC;AAC7F,CAAC;AAED,SAAS,UAAU,CAAC,KAAc,EAAE,GAAW;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1F,MAAM,KAAK,GAAI,KAAiC,CAAC,GAAG,CAAC,CAAC;IACtD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { type RuleSuggestion } from './permission-rules.js';
|
|
|
6
6
|
* `./interventions` has no subpath export, so derive it from the base class.
|
|
7
7
|
*/
|
|
8
8
|
type InterventionAction = Awaited<ReturnType<InterventionHandler['beforeToolCall']>>;
|
|
9
|
-
/** How a tool call is classified. `read` calls run without asking. */
|
|
9
|
+
/** How a tool call is classified. `read` calls run without asking unless they target a sensitive path. */
|
|
10
10
|
export type PermissionKind = 'read' | 'write' | 'execute';
|
|
11
11
|
/**
|
|
12
12
|
* How much confirmation the gate demands.
|
|
@@ -36,6 +36,12 @@ export interface RiskAssessment {
|
|
|
36
36
|
risk: PermissionRisk;
|
|
37
37
|
/** Human-readable, shown in the confirmation prompt. */
|
|
38
38
|
riskReason: string;
|
|
39
|
+
/**
|
|
40
|
+
* Set only by the sensitive-read branch (SER-071): the one `dangerous` class
|
|
41
|
+
* `auto` must hand to the user without consulting the classifier, because a
|
|
42
|
+
* credential read is a question of consent, not of harmlessness.
|
|
43
|
+
*/
|
|
44
|
+
sensitiveRead?: true;
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
41
47
|
* What the UI needs to render a confirmation. `summary` is a one-line headline;
|
|
@@ -171,6 +177,42 @@ export interface SafetyVerdict {
|
|
|
171
177
|
* bounds it with a timeout and treats any failure as "not safe".
|
|
172
178
|
*/
|
|
173
179
|
export type SafetyClassifier = (request: AssessedPermissionRequest) => Promise<SafetyVerdict>;
|
|
180
|
+
/**
|
|
181
|
+
* Which stage of the gate settled a call (SER-079). One name per `proceed`/`deny`
|
|
182
|
+
* return in the decision path, in the order the stages run:
|
|
183
|
+
*
|
|
184
|
+
* - `write-scope-denied`: a `workflow` node's declared `writeScopes` (SER-065);
|
|
185
|
+
* - `deny-rule`: a configured deny-rule (SER-076);
|
|
186
|
+
* - `plan-denied`: plan mode refusing a write/execute;
|
|
187
|
+
* - `yolo`, `safe`, `allow-rule`, `classifier`: the four silent approvals;
|
|
188
|
+
* - `user-approved`, `user-denied`: what the bridge answered;
|
|
189
|
+
* - `restart-limit-denied`: {@link MAX_MODE_CHANGE_RESTARTS} reached.
|
|
190
|
+
*/
|
|
191
|
+
export type PermissionOutcome = 'write-scope-denied' | 'deny-rule' | 'plan-denied' | 'yolo' | 'safe' | 'allow-rule' | 'classifier' | 'user-approved' | 'user-denied' | 'restart-limit-denied';
|
|
192
|
+
/**
|
|
193
|
+
* One settled decision, as the gate publishes it to {@link PermissionGateOptions.onDecision}.
|
|
194
|
+
*
|
|
195
|
+
* Deliberately **never** the tool input or any argument text: the recorded
|
|
196
|
+
* `beforeToolCallEvent` under the same `toolUseId` already carries it, and an audit
|
|
197
|
+
* line that repeated a command or a file body would be a second copy of the one thing
|
|
198
|
+
* the record already bounds. Plain strings and booleans only, frozen, so an observer
|
|
199
|
+
* cannot relabel a decision another observer will read.
|
|
200
|
+
*/
|
|
201
|
+
export interface PermissionDecisionRecord {
|
|
202
|
+
toolUseId: string;
|
|
203
|
+
toolName: string;
|
|
204
|
+
kind: PermissionKind;
|
|
205
|
+
risk: PermissionRisk;
|
|
206
|
+
/** The mode in force when the decision settled. */
|
|
207
|
+
mode: ApprovalMode;
|
|
208
|
+
/** `PermissionSource.label`: `parent`, or `<agent>#<dispatchId>` for a child. */
|
|
209
|
+
source: string;
|
|
210
|
+
outcome: PermissionOutcome;
|
|
211
|
+
/** The deny-rule or allow-rule that matched, or the rule granted at the prompt. */
|
|
212
|
+
rule?: string;
|
|
213
|
+
/** True only when the bridge was actually asked for this call (a withdrawn prompt counts). */
|
|
214
|
+
promptedUser: boolean;
|
|
215
|
+
}
|
|
174
216
|
export interface PermissionGateOptions {
|
|
175
217
|
/** Where enforcement starts. `PermissionGate.setMode` moves it, user-only. */
|
|
176
218
|
mode: ApprovalMode;
|
|
@@ -179,6 +221,13 @@ export interface PermissionGateOptions {
|
|
|
179
221
|
ask: PermissionBridge;
|
|
180
222
|
/** Wildcard allow-rules from the config; see `./permission-rules.ts`. */
|
|
181
223
|
allowRules?: readonly string[];
|
|
224
|
+
/**
|
|
225
|
+
* Wildcard deny-rules from the config (SER-076), same grammar. Judged before
|
|
226
|
+
* the mode, the static `safe` check, allow-rules and the classifier, so a deny
|
|
227
|
+
* holds in every mode — `yolo` included — and for every child sharing the gate.
|
|
228
|
+
* Configured only: nothing in the session can add or remove one.
|
|
229
|
+
*/
|
|
230
|
+
denyRules?: readonly string[];
|
|
182
231
|
/** Consulted for dangerous calls in `auto` mode; ignored otherwise. */
|
|
183
232
|
classifier?: SafetyClassifier;
|
|
184
233
|
/** How long `auto` waits for the classifier before falling back to asking. */
|
|
@@ -188,6 +237,14 @@ export interface PermissionGateOptions {
|
|
|
188
237
|
* reads as the parent's, which is only true for a runtime with no delegation.
|
|
189
238
|
*/
|
|
190
239
|
dispatchSource?: DispatchSourceResolver;
|
|
240
|
+
/**
|
|
241
|
+
* Observes every settled decision (SER-079): called exactly once per tool call
|
|
242
|
+
* the gate judged, after the outcome is final — a `WITHDRAWN` restart is not an
|
|
243
|
+
* outcome. Publication only: the object is frozen and carries no input, and a
|
|
244
|
+
* throwing observer is swallowed, so nothing here can change or delay what the
|
|
245
|
+
* model gets. The runtime points it at the trajectory recorder.
|
|
246
|
+
*/
|
|
247
|
+
onDecision?: (decision: PermissionDecisionRecord) => void;
|
|
191
248
|
}
|
|
192
249
|
/**
|
|
193
250
|
* Where a live allow-rule came from. `configured` means it was loaded from the
|
|
@@ -225,6 +282,12 @@ export declare class PermissionGate extends InterventionHandler {
|
|
|
225
282
|
* (`matchesAnyRule`) reads the plain strings and must stay unchanged.
|
|
226
283
|
*/
|
|
227
284
|
private readonly ruleOrigins;
|
|
285
|
+
/**
|
|
286
|
+
* Configured deny-rules (SER-076). Frozen: there is no grant, revoke or
|
|
287
|
+
* suggestion path for a deny — the rules file is the only way one changes,
|
|
288
|
+
* and it is read at startup only.
|
|
289
|
+
*/
|
|
290
|
+
private readonly denyRuleList;
|
|
228
291
|
/**
|
|
229
292
|
* Live enforcement policy, not `options.mode`: `/mode` moves it mid-session and
|
|
230
293
|
* every decision — parent and child, since they share this instance — reads it
|
|
@@ -279,6 +342,13 @@ export declare class PermissionGate extends InterventionHandler {
|
|
|
279
342
|
* the enforcement surface.
|
|
280
343
|
*/
|
|
281
344
|
listAllowRules(): AllowRuleEntry[];
|
|
345
|
+
/**
|
|
346
|
+
* The configured deny-rules, in the order they are consulted (SER-076). Every
|
|
347
|
+
* one is `configured` by construction — there is no session origin to state —
|
|
348
|
+
* and the array is frozen, so `/permissions` can show it but nothing can edit
|
|
349
|
+
* the enforcement surface through it.
|
|
350
|
+
*/
|
|
351
|
+
get denyRules(): readonly string[];
|
|
282
352
|
/**
|
|
283
353
|
* Denies plan-mode mutation before hooks, rules, classifiers, or prompts can
|
|
284
354
|
* have side effects. Undefined means the ordinary permission flow still owns
|
|
@@ -288,12 +358,27 @@ export declare class PermissionGate extends InterventionHandler {
|
|
|
288
358
|
* and leaving it stops guarding immediately.
|
|
289
359
|
*/
|
|
290
360
|
planGuard(toolName: string, input: unknown): InterventionAction | undefined;
|
|
361
|
+
/**
|
|
362
|
+
* The two guards the hook wrapper runs ahead of any `PreToolUse` shell — deny-rule,
|
|
363
|
+
* then plan — as one call that also **publishes** the denial (SER-079). Undefined
|
|
364
|
+
* means the ordinary flow owns the call and nothing was published.
|
|
365
|
+
*
|
|
366
|
+
* This is what keeps the audit at one record per tool call: the wrapper returns a
|
|
367
|
+
* denial from here without ever reaching {@link beforeToolCall}, so that path never
|
|
368
|
+
* sees the call; a call that passes here and is later denied by the same guards
|
|
369
|
+
* inside {@link beforeToolCall} (the mode moved to `plan` while Pre hooks ran) is
|
|
370
|
+
* published there instead. {@link denyRuleGuard} and {@link planGuard} themselves
|
|
371
|
+
* stay pure and unpublished, so calling them directly (tests, other callers)
|
|
372
|
+
* records nothing.
|
|
373
|
+
*/
|
|
374
|
+
guardBeforeHooks(event: BeforeToolCallEvent): InterventionAction | undefined;
|
|
291
375
|
/**
|
|
292
376
|
* Decides one call, restarting whenever the user changes the mode underneath it.
|
|
293
377
|
*
|
|
294
378
|
* The loop is the whole in-flight contract: a withdrawn decision is discarded,
|
|
295
379
|
* never applied, and the call is judged again from the top — plan guard first —
|
|
296
|
-
* by whatever mode is in force now.
|
|
380
|
+
* by whatever mode is in force now. Whatever settles it — a pass, or the restart
|
|
381
|
+
* limit — is published exactly once, after it is final.
|
|
297
382
|
*/
|
|
298
383
|
beforeToolCall(event: BeforeToolCallEvent): Promise<InterventionAction>;
|
|
299
384
|
/**
|
|
@@ -305,12 +390,41 @@ export declare class PermissionGate extends InterventionHandler {
|
|
|
305
390
|
* re-checks `aborted` after the promise settles.
|
|
306
391
|
*/
|
|
307
392
|
private decideOnce;
|
|
393
|
+
/**
|
|
394
|
+
* The deny-rule and plan guards as one settled denial, or undefined when neither
|
|
395
|
+
* applies. Shared by {@link guardBeforeHooks} and {@link decideOnce} so the two
|
|
396
|
+
* cannot disagree about which stage a call fell at.
|
|
397
|
+
*/
|
|
398
|
+
private earlyDenial;
|
|
399
|
+
/**
|
|
400
|
+
* Hands one settled decision to the observer (SER-079). Publication only: the
|
|
401
|
+
* object is composed from what the gate already knows — never the input — and
|
|
402
|
+
* frozen, and an observer that throws costs nothing but its own record. `kind`
|
|
403
|
+
* and `risk` are re-derived here because the early guards settle a call before
|
|
404
|
+
* the request exists; `classify`/`assessRisk` are pure, so the reading is the one
|
|
405
|
+
* the decision path would have made.
|
|
406
|
+
*/
|
|
407
|
+
private publish;
|
|
308
408
|
/**
|
|
309
409
|
* Who is asking. A tracked dispatch resolves to its child label; anything else
|
|
310
410
|
* is the parent, because the runtime assembles exactly one `Agent` and every
|
|
311
411
|
* other agent in the process is a dispatch this resolver knows about.
|
|
312
412
|
*/
|
|
313
413
|
private sourceOf;
|
|
414
|
+
/**
|
|
415
|
+
* Denies a call a configured deny-rule forbids (SER-076). Undefined means the
|
|
416
|
+
* ordinary flow owns the call. The reason names the rule so the model can
|
|
417
|
+
* report it precisely, and says in so many words not to retry or route around
|
|
418
|
+
* it: a deny is the user's standing instruction, not a transient failure. The
|
|
419
|
+
* rule text is bounded because it reaches the model verbatim.
|
|
420
|
+
*
|
|
421
|
+
* Public like {@link planGuard} and for the same reason: the hook wrapper runs
|
|
422
|
+
* it before any `PreToolUse` shell, so a forbidden call cannot trigger a policy
|
|
423
|
+
* hook either. Idempotent and side-effect free, so running it twice is safe.
|
|
424
|
+
*/
|
|
425
|
+
denyRuleGuard(toolName: string, input: unknown): InterventionAction | undefined;
|
|
426
|
+
/** The first configured deny-rule the call matches, or undefined. Pure. */
|
|
427
|
+
private matchedDenyRule;
|
|
314
428
|
/**
|
|
315
429
|
* Denies a scoped `workflow` node's `fileEditor` write that lands outside every
|
|
316
430
|
* declared scope. Undefined means the ordinary flow owns the call — including
|