@sema-agent/core 7.45.0 → 7.46.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/CHANGELOG.md +246 -1
- package/dist/agents/extra-tool-names.d.ts +65 -0
- package/dist/agents/extra-tool-names.js +124 -0
- package/dist/agents/subagent.d.ts +17 -5
- package/dist/agents/subagent.js +33 -25
- package/dist/agents/tool-filter.d.ts +17 -1
- package/dist/agents/tool-filter.js +7 -0
- package/dist/core/agent-config-dir.d.ts +20 -0
- package/dist/core/agent-config-dir.js +49 -0
- package/dist/core/allow-entry.d.ts +5 -3
- package/dist/core/allow-entry.js +3 -1
- package/dist/core/ask-origin.js +1 -1
- package/dist/core/checkpoint-store.d.ts +39 -2
- package/dist/core/effective-path-target.d.ts +136 -4
- package/dist/core/effective-path-target.js +110 -2
- package/dist/core/engine-notice.d.ts +5 -0
- package/dist/core/gate-fold.js +3 -0
- package/dist/core/gate-lanes.js +9 -3
- package/dist/core/governance-codes.d.ts +3 -1
- package/dist/core/governance-codes.js +3 -0
- package/dist/core/hooks.d.ts +3 -0
- package/dist/core/path-rule-binding.d.ts +65 -0
- package/dist/core/path-rule-binding.js +99 -0
- package/dist/core/permission-rule-model.d.ts +47 -18
- package/dist/core/permission-rule-model.js +38 -42
- package/dist/core/permission-rule-provider.d.ts +7 -0
- package/dist/core/permission-rule-provider.js +10 -3
- package/dist/core/permission-rule-store.d.ts +8 -0
- package/dist/core/permission-rule-store.js +6 -2
- package/dist/core/permission-rule-sync.js +2 -2
- package/dist/core/permission-rules.d.ts +22 -40
- package/dist/core/permission-rules.js +50 -43
- package/dist/core/runner/child-tree.d.ts +97 -0
- package/dist/core/runner/child-tree.js +104 -0
- package/dist/core/runner/construction-doors.d.ts +5 -0
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +46 -0
- package/dist/core/runner/permission-rule-lanes.d.ts +34 -25
- package/dist/core/runner/permission-rule-lanes.js +18 -12
- package/dist/core/runner/persisted-path-rows.d.ts +31 -7
- package/dist/core/runner/persisted-path-rows.js +31 -12
- package/dist/core/runner/prepare-ask-lane.d.ts +4 -0
- package/dist/core/runner/prepare-ask-lane.js +4 -2
- package/dist/core/runner/prepare-execution-env.d.ts +5 -2
- package/dist/core/runner/prepare-execution-env.js +10 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +3 -0
- package/dist/core/runner/prepare-gate-stations.js +2 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +8 -4
- package/dist/core/runner/prepare-hands-readface.js +6 -6
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -1
- package/dist/core/runner/prepare-inherited-gate.js +8 -2
- package/dist/core/runner/prepare-park-ask.d.ts +3 -0
- package/dist/core/runner/prepare-park-ask.js +5 -3
- package/dist/core/runner/prepare-policy-chain.d.ts +14 -2
- package/dist/core/runner/prepare-policy-chain.js +11 -4
- package/dist/core/runner/prepare-suspend-saga.d.ts +10 -0
- package/dist/core/runner/prepare-suspend-saga.js +7 -1
- package/dist/core/runner/prepare-task.js +37 -18
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +1 -0
- package/dist/core/runner/resume-apply.js +17 -3
- package/dist/core/runner/resume-checkpoint-screen.js +13 -0
- package/dist/core/runner/run-leg.js +5 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.d.ts +1 -1
- package/dist/core/runner/write-protection-station.d.ts +3 -2
- package/dist/core/runner/write-protection-station.js +1 -0
- package/dist/core/runner-deps.d.ts +14 -0
- package/dist/core/sensitive-path-policy.d.ts +8 -0
- package/dist/core/sensitive-path-policy.js +18 -2
- package/dist/core/shell-wrapper-projection.d.ts +11 -0
- package/dist/core/shell-wrapper-projection.js +56 -0
- package/dist/core/shell-wrapper-table.d.ts +144 -34
- package/dist/core/shell-wrapper-table.js +40 -20
- package/dist/core/synthetic-read-verdict.d.ts +3 -0
- package/dist/core/synthetic-read-verdict.js +3 -1
- package/dist/core/tool-catalog-entries.d.ts +21 -0
- package/dist/core/tool-catalog-entries.js +9 -0
- package/dist/core/tool-policy.d.ts +30 -8
- package/dist/core/tool-policy.js +9 -7
- package/dist/core/tool-spec.d.ts +3 -2
- package/dist/core/write-protect.d.ts +4 -0
- package/dist/core/write-protect.js +30 -9
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/orchestration/run-spec.js +8 -7
- package/dist/orchestration/workflow.js +1 -1
- package/dist/shell/lex.d.ts +7 -0
- package/dist/shell/lex.js +17 -0
- package/dist/tools/fs/bash-program-position.d.ts +8 -87
- package/dist/tools/fs/bash-program-position.js +33 -69
- package/dist/tools/fs/bash-readonly-classifier.d.ts +17 -444
- package/dist/tools/fs/bash-readonly-classifier.js +169 -1225
- package/dist/tools/fs/index.d.ts +3 -2
- package/dist/tools/fs/program-read-model.d.ts +694 -0
- package/dist/tools/fs/program-read-model.js +1252 -0
- package/dist/tools/fs/program-read-model.rows.d.ts +18 -0
- package/dist/tools/fs/program-read-model.rows.js +613 -0
- package/dist/tools/fs/read-deny-home.d.ts +19 -1
- package/dist/tools/fs/read-deny-home.js +62 -24
- package/dist/tools/fs/read-deny.d.ts +54 -14
- package/dist/tools/fs/read-deny.js +104 -50
- package/dist/tools/fs/removal-targets.d.ts +7 -6
- package/dist/tools/fs/removal-targets.js +22 -22
- package/dist/tools/fs/safety.d.ts +3 -0
- package/dist/tools/fs/safety.js +10 -3
- package/dist/tools/fs/shell-read-argv.d.ts +85 -0
- package/dist/tools/fs/shell-read-argv.js +386 -0
- package/dist/tools/fs/shell-read-bindings.d.ts +273 -0
- package/dist/tools/fs/shell-read-bindings.js +746 -0
- package/dist/tools/fs/shell-read-check.js +23 -15
- package/dist/tools/fs/shell-read-establish.js +79 -5
- package/dist/tools/fs/shell-read-judge.d.ts +11 -1
- package/dist/tools/fs/shell-read-judge.js +9 -1
- package/dist/tools/fs/shell-read-plan.d.ts +31 -7
- package/dist/tools/fs/shell-read-plan.js +299 -393
- package/dist/tools/fs/shell-read-word.d.ts +29 -26
- package/dist/tools/fs/shell-read-word.js +30 -38
- package/dist/tools/fs/shell-read-write-targets.d.ts +15 -64
- package/dist/tools/fs/shell-read-write-targets.js +83 -136
- package/dist/tools/fs/shell-reentry-text.d.ts +38 -6
- package/dist/tools/fs/shell-reentry-text.js +90 -53
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +17 -3
- package/wire-changes/core@7.46.0.json +1522 -0
|
@@ -2,6 +2,7 @@ import { homedir } from "node:os";
|
|
|
2
2
|
import { isAbsolute, join, resolve } from "node:path";
|
|
3
3
|
import { canonicalizeTarget, expandHomeTilde, isAbsoluteForFamily, isWinFormPath, pathFamilyOf, writeTargetPath } from "../tools/fs/safety.js";
|
|
4
4
|
import { compileSegmentPattern, matchSegmentPatterns, READ_FACE_BUILTIN_DENY_TABLE, readDenyPatternRun } from "../tools/fs/read-deny.js";
|
|
5
|
+
import { agentConfigDirSegments, agentConfigDirTail, checkedAgentConfigDir } from "./agent-config-dir.js";
|
|
5
6
|
import { isProtectedWrite, protectivePathTargetOf } from "./tool-registry.js";
|
|
6
7
|
import { pathTargetBaseOf } from "./effective-path-target.js";
|
|
7
8
|
import { symlinkChainHops } from "./path-identity.js";
|
|
@@ -32,6 +33,7 @@ export const RECOMMENDED_SENSITIVE_PATTERNS = [
|
|
|
32
33
|
".mcp.json",
|
|
33
34
|
".ai-agent/.env",
|
|
34
35
|
".sema/engine-data/.env",
|
|
36
|
+
".sema/config-lkg-*.json",
|
|
35
37
|
".codex/config.toml",
|
|
36
38
|
".cursor/mcp.json",
|
|
37
39
|
".continue/config.json",
|
|
@@ -115,6 +117,19 @@ function matchSensitive(canonicalKey, compiled, aliasResolved) {
|
|
|
115
117
|
}
|
|
116
118
|
export function createSensitivePathPolicy(opts) {
|
|
117
119
|
const compiled = compilePatterns(opts.patterns);
|
|
120
|
+
const configRoot = checkedAgentConfigDir(opts.agentConfigDir, "createSensitivePathPolicy agentConfigDir");
|
|
121
|
+
const configRows = configRoot === undefined ? [] : opts.patterns.flatMap((raw) => {
|
|
122
|
+
const tail = agentConfigDirTail(raw, !CASE_INSENSITIVE_FS);
|
|
123
|
+
return tail === undefined ? [] : [{ raw, tail }];
|
|
124
|
+
});
|
|
125
|
+
const configTwins = async (signal) => {
|
|
126
|
+
if (configRoot === undefined || configRows.length === 0)
|
|
127
|
+
return [];
|
|
128
|
+
const fold = CASE_INSENSITIVE_FS ? "ascii" : "none";
|
|
129
|
+
const lower = (segs) => (CASE_INSENSITIVE_FS ? segs.map((seg) => seg.replace(/[A-Z]/g, (c) => c.toLowerCase())) : segs);
|
|
130
|
+
const anchors = [configRoot, ...(await canonicalDataRootKeys(opts.env, [configRoot], signal))].map((root) => lower(agentConfigDirSegments(root)));
|
|
131
|
+
return configRows.map(({ raw, tail }) => ({ ...(compileSegmentPattern(tail, fold) ?? { raw, segments: [], foldAscii: CASE_INSENSITIVE_FS }), raw, anchors, rootedOnly: true }));
|
|
132
|
+
};
|
|
118
133
|
const dataRootPaths = dataRootSpellings(opts.dataRoot);
|
|
119
134
|
const guardedByName = opts.tools !== undefined ? new Set(opts.tools) : undefined;
|
|
120
135
|
const family = (cwd) => pathFamilyOf({ root: opts.rootPath, cwd: cwd ?? opts.env.cwd });
|
|
@@ -130,12 +145,13 @@ export function createSensitivePathPolicy(opts) {
|
|
|
130
145
|
}
|
|
131
146
|
if (relative === "")
|
|
132
147
|
return { kind: "clear" };
|
|
133
|
-
const
|
|
148
|
+
const twins = await configTwins(signal);
|
|
149
|
+
const hit = matchSensitive(relative ?? canon.key, [...compiled, ...twins], canon.aliasResolved === true);
|
|
134
150
|
if (hit)
|
|
135
151
|
return { kind: "hit", pattern: hit, via: "target" };
|
|
136
152
|
if (relative === null) {
|
|
137
153
|
for (const hop of await symlinkChainHops(opts.env, path, signal, fam, base)) {
|
|
138
|
-
const viaHop = matchSensitive(hop, compiled, false);
|
|
154
|
+
const viaHop = matchSensitive(hop, [...compiled, ...twins], false);
|
|
139
155
|
if (viaHop)
|
|
140
156
|
return { kind: "hit", pattern: viaHop, via: "chain" };
|
|
141
157
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ShellWrapperRow } from "./shell-wrapper-table.js";
|
|
2
|
+
/**
|
|
3
|
+
* The PROJECTION {@link import("./shell-wrapper-table.js").SHELL_WRAPPER_TABLE} is: the second lexer's view of the program read model's rows (`program-read-model.ts`
|
|
4
|
+
* — one table of program facts, read through the binary gate). A launcher row's options by arity (a value word, a
|
|
5
|
+
* switch or an attached-only value, a command string), its required operand (a duration, or the spelling it must have),
|
|
6
|
+
* its bare-dash switch and its `NAME=value` operands; a row that runs its operands, or a code body, as shell input
|
|
7
|
+
* (`viaShell`); an option that runs a command (`executes`). The table is this projection written out (its
|
|
8
|
+
* literal type is the export's), and `test/shell-wrapper-table-projection.test.ts` pins it equal — a launcher fact is
|
|
9
|
+
* edited in its row, never here.
|
|
10
|
+
*/
|
|
11
|
+
export declare function shellWrapperProjection(): Record<string, ShellWrapperRow>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { programRows } from "../tools/fs/program-read-model.js";
|
|
2
|
+
import { DURATION_SPELLING } from "../tools/fs/program-read-model.rows.js";
|
|
3
|
+
export function shellWrapperProjection() {
|
|
4
|
+
const out = {};
|
|
5
|
+
for (const row of programRows()) {
|
|
6
|
+
const projected = projectRow(row);
|
|
7
|
+
if (projected !== undefined)
|
|
8
|
+
out[row.key] = projected;
|
|
9
|
+
}
|
|
10
|
+
return out;
|
|
11
|
+
}
|
|
12
|
+
function spellings(row) {
|
|
13
|
+
const out = new Map();
|
|
14
|
+
for (const g of row.grammars) {
|
|
15
|
+
const add = (spelling, spec) => {
|
|
16
|
+
const e = out.get(spelling) ?? { spec, arities: new Set() };
|
|
17
|
+
e.arities.add(spec.arity);
|
|
18
|
+
out.set(spelling, e);
|
|
19
|
+
};
|
|
20
|
+
for (const [l, spec] of Object.entries(g.short))
|
|
21
|
+
add(`-${l}`, spec);
|
|
22
|
+
for (const [n, spec] of Object.entries(g.long))
|
|
23
|
+
add(`--${n}`, spec);
|
|
24
|
+
for (const [n, spec] of Object.entries(g.dashWords ?? {}))
|
|
25
|
+
add(`-${n}`, spec);
|
|
26
|
+
}
|
|
27
|
+
return [...out].map(([spelling, e]) => ({ spelling, spec: e.spec, arity: e.arities.size === 1 ? [...e.arities][0] : "disputed" }));
|
|
28
|
+
}
|
|
29
|
+
const runsCommand = (spec) => spec.effect === "executes" || spec.value?.kind === "shell-text" || spec.value?.kind === "command";
|
|
30
|
+
function projectRow(row) {
|
|
31
|
+
const sorted = (xs) => [...new Set(xs)].sort();
|
|
32
|
+
const all = spellings(row);
|
|
33
|
+
const viaShell = row.reentry?.kind === "shell" || row.launcher?.shellText === true || row.body === "first-operand" || row.body === "assignment-values" || (row.operands?.rest?.kind === "program-text" && row.operands.rest.language === "arithmetic");
|
|
34
|
+
if (row.launcher === undefined) {
|
|
35
|
+
if (viaShell)
|
|
36
|
+
return { valueFlags: [], flags: [], commandString: [], viaShell: true };
|
|
37
|
+
const executes = sorted(all.filter((o) => runsCommand(o.spec)).map((o) => o.spelling));
|
|
38
|
+
return executes.length > 0 ? { valueFlags: [], flags: [], commandString: [], executes } : undefined;
|
|
39
|
+
}
|
|
40
|
+
const commandString = sorted(all.filter((o) => o.spec.value?.kind === "shell-text").map((o) => o.spelling));
|
|
41
|
+
const values = all.filter((o) => o.spec.value?.kind !== "shell-text");
|
|
42
|
+
const attached = sorted(values.filter((o) => o.arity === "attached" && !o.spelling.startsWith("--")).map((o) => o.spelling));
|
|
43
|
+
const required = row.launcher.requiredOperands ?? 0;
|
|
44
|
+
const duration = required > 0 && row.launcher.requiredOperandSpelling === DURATION_SPELLING;
|
|
45
|
+
return {
|
|
46
|
+
valueFlags: sorted(values.filter((o) => o.arity === 1).map((o) => o.spelling)),
|
|
47
|
+
flags: sorted(values.filter((o) => o.arity === 0 || (o.arity === "attached" && o.spelling.startsWith("--"))).map((o) => o.spelling)),
|
|
48
|
+
...(attached.length > 0 ? { attached } : {}),
|
|
49
|
+
commandString,
|
|
50
|
+
...(required > 0 && !duration ? { positional: row.launcher.requiredOperandSpelling ?? /^/ } : {}),
|
|
51
|
+
...(duration ? { duration: true } : {}),
|
|
52
|
+
...(row.launcher.bareDash === true ? { bareDash: true } : {}),
|
|
53
|
+
...(row.launcher.assignmentOperands === true ? { assignments: true } : {}),
|
|
54
|
+
...(viaShell ? { viaShell: true } : {}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
* caller asks a person) instead of guessing its arity, because a wrong guess names the option's VALUE
|
|
12
12
|
* or an operand as the program — a phantom run no deny matches. Three adversarial rounds found exactly
|
|
13
13
|
* that shape behind every "unknown is value-less" reading; the closed sets end the family rather than
|
|
14
|
-
* the instance.
|
|
14
|
+
* the instance. The table is the PROJECTION of the program read model's rows
|
|
15
|
+
* ({@link import("./shell-wrapper-projection.js").shellWrapperProjection}) written
|
|
16
|
+
* out with its literal type: a launcher fact is edited in its row (one table of program facts, read by the binary gate
|
|
17
|
+
* and by the read station alike), and `test/shell-wrapper-table-projection.test.ts` keeps the two equal.
|
|
15
18
|
*
|
|
16
19
|
* Per row: `valueFlags` — options whose value is the NEXT word (`-u root`; the attached `-uroot` and
|
|
17
20
|
* `--user=root` spellings are one word and need no row); `flags` — value-less options, including those
|
|
@@ -56,26 +59,26 @@ export declare const SHELL_WRAPPER_TABLE: {
|
|
|
56
59
|
readonly commandString: readonly [];
|
|
57
60
|
};
|
|
58
61
|
readonly env: {
|
|
59
|
-
readonly valueFlags: readonly ["
|
|
60
|
-
readonly flags: readonly ["
|
|
61
|
-
readonly commandString: readonly ["-
|
|
62
|
+
readonly valueFlags: readonly ["--argv0", "--chdir", "--unset", "-C", "-P", "-a", "-u"];
|
|
63
|
+
readonly flags: readonly ["--debug", "--default-signal", "--help", "--ignore-environment", "--ignore-signal", "--list-signal-handling", "--version", "-i", "-v"];
|
|
64
|
+
readonly commandString: readonly ["--split-string", "-S"];
|
|
62
65
|
readonly bareDash: true;
|
|
63
66
|
readonly assignments: true;
|
|
64
67
|
};
|
|
65
68
|
readonly sudo: {
|
|
66
|
-
readonly valueFlags: readonly ["-
|
|
67
|
-
readonly flags: readonly ["
|
|
69
|
+
readonly valueFlags: readonly ["--auth-type", "--chdir", "--chroot", "--close-from", "--command-timeout", "--group", "--host", "--other-user", "--prompt", "--role", "--type", "--user", "-C", "-D", "-R", "-T", "-U", "-a", "-g", "-h", "-p", "-r", "-t", "-u"];
|
|
70
|
+
readonly flags: readonly ["--askpass", "--background", "--bell", "--help", "--list", "--login", "--non-interactive", "--preserve-env", "--preserve-groups", "--remove-timestamp", "--reset-timestamp", "--set-home", "--shell", "--stdin", "--validate", "--version", "-A", "-E", "-H", "-K", "-P", "-S", "-V", "-b", "-i", "-k", "-l", "-n", "-s", "-v"];
|
|
68
71
|
readonly commandString: readonly [];
|
|
69
72
|
readonly assignments: true;
|
|
70
73
|
};
|
|
71
74
|
readonly doas: {
|
|
72
|
-
readonly valueFlags: readonly ["-
|
|
75
|
+
readonly valueFlags: readonly ["-C", "-a", "-u"];
|
|
73
76
|
readonly flags: readonly ["-L", "-n", "-s"];
|
|
74
77
|
readonly commandString: readonly [];
|
|
75
78
|
};
|
|
76
79
|
readonly pkexec: {
|
|
77
80
|
readonly valueFlags: readonly ["--user"];
|
|
78
|
-
readonly flags: readonly ["--disable-internal-agent", "--
|
|
81
|
+
readonly flags: readonly ["--disable-internal-agent", "--help", "--keep-cwd", "--version"];
|
|
79
82
|
readonly commandString: readonly [];
|
|
80
83
|
};
|
|
81
84
|
readonly nohup: {
|
|
@@ -84,29 +87,29 @@ export declare const SHELL_WRAPPER_TABLE: {
|
|
|
84
87
|
readonly commandString: readonly [];
|
|
85
88
|
};
|
|
86
89
|
readonly time: {
|
|
87
|
-
readonly valueFlags: readonly ["
|
|
88
|
-
readonly flags: readonly ["
|
|
90
|
+
readonly valueFlags: readonly ["--format", "--output", "-f", "-o"];
|
|
91
|
+
readonly flags: readonly ["--append", "--help", "--portability", "--quiet", "--verbose", "--version", "-a", "-p", "-q", "-v"];
|
|
89
92
|
readonly commandString: readonly [];
|
|
90
93
|
};
|
|
91
94
|
readonly nice: {
|
|
92
|
-
readonly valueFlags: readonly ["
|
|
95
|
+
readonly valueFlags: readonly ["--adjustment", "-n"];
|
|
93
96
|
readonly flags: readonly ["--help", "--version"];
|
|
94
97
|
readonly commandString: readonly [];
|
|
95
98
|
};
|
|
96
99
|
readonly timeout: {
|
|
97
|
-
readonly valueFlags: readonly ["-
|
|
98
|
-
readonly flags: readonly ["
|
|
100
|
+
readonly valueFlags: readonly ["--kill-after", "--signal", "-k", "-s"];
|
|
101
|
+
readonly flags: readonly ["--foreground", "--help", "--preserve-status", "--verbose", "--version", "-v"];
|
|
99
102
|
readonly commandString: readonly [];
|
|
100
103
|
readonly duration: true;
|
|
101
104
|
};
|
|
102
105
|
readonly stdbuf: {
|
|
103
|
-
readonly valueFlags: readonly ["
|
|
106
|
+
readonly valueFlags: readonly ["--error", "--input", "--output", "-e", "-i", "-o"];
|
|
104
107
|
readonly flags: readonly ["--help", "--version"];
|
|
105
108
|
readonly commandString: readonly [];
|
|
106
109
|
};
|
|
107
110
|
readonly xargs: {
|
|
108
|
-
readonly valueFlags: readonly ["-
|
|
109
|
-
readonly flags: readonly ["
|
|
111
|
+
readonly valueFlags: readonly ["--arg-file", "--delimiter", "--max-args", "--max-chars", "--max-procs", "--process-slot-var", "-E", "-I", "-L", "-P", "-a", "-d", "-n", "-s"];
|
|
112
|
+
readonly flags: readonly ["--eof", "--exit", "--help", "--interactive", "--max-lines", "--no-run-if-empty", "--null", "--open-tty", "--replace", "--show-limits", "--verbose", "--version", "-0", "-o", "-p", "-r", "-t", "-x"];
|
|
110
113
|
readonly attached: readonly ["-i", "-l"];
|
|
111
114
|
readonly commandString: readonly [];
|
|
112
115
|
};
|
|
@@ -117,57 +120,58 @@ export declare const SHELL_WRAPPER_TABLE: {
|
|
|
117
120
|
readonly viaShell: true;
|
|
118
121
|
};
|
|
119
122
|
readonly ionice: {
|
|
120
|
-
readonly valueFlags: readonly ["
|
|
121
|
-
readonly flags: readonly ["
|
|
123
|
+
readonly valueFlags: readonly ["--class", "--classdata", "--pgid", "--pid", "--uid", "-P", "-c", "-n", "-p", "-u"];
|
|
124
|
+
readonly flags: readonly ["--help", "--ignore", "--version", "-V", "-h", "-t"];
|
|
122
125
|
readonly commandString: readonly [];
|
|
123
126
|
};
|
|
124
127
|
readonly setsid: {
|
|
125
128
|
readonly valueFlags: readonly [];
|
|
126
|
-
readonly flags: readonly ["
|
|
129
|
+
readonly flags: readonly ["--ctty", "--fork", "--help", "--version", "--wait", "-c", "-f", "-w"];
|
|
127
130
|
readonly commandString: readonly [];
|
|
128
131
|
};
|
|
129
132
|
readonly taskset: {
|
|
130
133
|
readonly valueFlags: readonly [];
|
|
131
|
-
readonly flags: readonly ["-
|
|
134
|
+
readonly flags: readonly ["--all-tasks", "--cpu-list", "--help", "--pid", "--version", "-a", "-c", "-p"];
|
|
132
135
|
readonly commandString: readonly [];
|
|
133
136
|
readonly positional: RegExp;
|
|
134
137
|
};
|
|
135
138
|
readonly chrt: {
|
|
136
|
-
readonly valueFlags: readonly ["
|
|
137
|
-
readonly flags: readonly ["-
|
|
139
|
+
readonly valueFlags: readonly ["--pid", "--sched-deadline", "--sched-period", "--sched-runtime", "-D", "-P", "-T", "-p"];
|
|
140
|
+
readonly flags: readonly ["--all-tasks", "--batch", "--deadline", "--fifo", "--help", "--idle", "--max", "--other", "--reset-on-fork", "--rr", "--verbose", "--version", "-R", "-a", "-b", "-d", "-f", "-i", "-m", "-o", "-r", "-v"];
|
|
138
141
|
readonly commandString: readonly [];
|
|
139
142
|
readonly positional: RegExp;
|
|
140
143
|
};
|
|
141
144
|
readonly strace: {
|
|
142
|
-
readonly valueFlags: readonly ["
|
|
143
|
-
readonly flags: readonly ["
|
|
145
|
+
readonly valueFlags: readonly ["--attach", "--columns", "--const-print-style", "--detach-on", "--env", "--expr", "--interruptible", "--output", "--string-limit", "--summary-columns", "--summary-sort-by", "--summary-syscall-overhead", "--trace", "--trace-path", "--user", "-E", "-I", "-O", "-P", "-S", "-U", "-X", "-a", "-b", "-e", "-o", "-p", "-s", "-u"];
|
|
146
|
+
readonly flags: readonly ["--debug", "--follow-forks", "--help", "--summary", "--summary-only", "--version", "-C", "-D", "-F", "-T", "-V", "-Z", "-c", "-d", "-f", "-h", "-i", "-k", "-q", "-r", "-t", "-v", "-w", "-x", "-y", "-z"];
|
|
144
147
|
readonly commandString: readonly [];
|
|
145
148
|
};
|
|
146
149
|
readonly ltrace: {
|
|
147
|
-
readonly valueFlags: readonly ["
|
|
148
|
-
readonly flags: readonly ["
|
|
150
|
+
readonly valueFlags: readonly ["--align", "--config", "--debug", "--indent", "--library", "--output", "--string-max", "--where", "-A", "-D", "-F", "-a", "-e", "-l", "-n", "-o", "-p", "-s", "-u", "-w", "-x"];
|
|
151
|
+
readonly flags: readonly ["--demangle", "--help", "--version", "-C", "-L", "-S", "-T", "-V", "-c", "-f", "-i", "-r", "-t"];
|
|
149
152
|
readonly commandString: readonly [];
|
|
150
153
|
};
|
|
151
154
|
readonly flock: {
|
|
152
|
-
readonly valueFlags: readonly ["-
|
|
153
|
-
readonly flags: readonly ["
|
|
154
|
-
readonly commandString: readonly ["
|
|
155
|
+
readonly valueFlags: readonly ["--conflict-exit-code", "--timeout", "--wait", "-E", "-w"];
|
|
156
|
+
readonly flags: readonly ["--close", "--exclusive", "--help", "--nb", "--no-fork", "--nonblock", "--shared", "--unlock", "--verbose", "--version", "-F", "-n", "-o", "-s", "-u", "-x"];
|
|
157
|
+
readonly commandString: readonly ["--command", "-c"];
|
|
155
158
|
readonly positional: RegExp;
|
|
156
159
|
};
|
|
157
160
|
readonly script: {
|
|
158
161
|
readonly valueFlags: readonly [];
|
|
159
162
|
readonly flags: readonly [];
|
|
160
|
-
readonly commandString: readonly ["
|
|
163
|
+
readonly commandString: readonly ["--command", "-c"];
|
|
161
164
|
readonly viaShell: true;
|
|
162
165
|
};
|
|
163
166
|
readonly unshare: {
|
|
164
|
-
readonly valueFlags: readonly ["
|
|
165
|
-
readonly flags: readonly ["
|
|
167
|
+
readonly valueFlags: readonly ["--boottime", "--map-group", "--map-user", "--monotonic", "--propagation", "--root", "--setgid", "--setgroups", "--setuid", "--wd", "-G", "-R", "-S", "-w"];
|
|
168
|
+
readonly flags: readonly ["--cgroup", "--fork", "--help", "--ipc", "--keep-caps", "--kill-child", "--map-current-user", "--map-root-user", "--mount", "--mount-proc", "--net", "--pid", "--time", "--user", "--uts", "--version", "-C", "-T", "-U", "-c", "-f", "-i", "-m", "-n", "-p", "-r", "-u"];
|
|
166
169
|
readonly commandString: readonly [];
|
|
167
170
|
};
|
|
168
171
|
readonly nsenter: {
|
|
169
|
-
readonly valueFlags: readonly ["
|
|
170
|
-
readonly flags: readonly ["
|
|
172
|
+
readonly valueFlags: readonly ["--setgid", "--setuid", "--target", "-G", "-S", "-t"];
|
|
173
|
+
readonly flags: readonly ["--all", "--cgroup", "--help", "--ipc", "--mount", "--net", "--no-fork", "--pid", "--preserve-credentials", "--root", "--time", "--user", "--uts", "--version", "--wd", "-C", "-F", "-T", "-U", "-Z", "-a", "-i", "-m", "-n", "-p", "-u"];
|
|
174
|
+
readonly attached: readonly ["-r", "-w"];
|
|
171
175
|
readonly commandString: readonly [];
|
|
172
176
|
};
|
|
173
177
|
readonly eval: {
|
|
@@ -266,6 +270,112 @@ export declare const SHELL_WRAPPER_TABLE: {
|
|
|
266
270
|
readonly commandString: readonly [];
|
|
267
271
|
readonly executes: readonly ["-C", "-F"];
|
|
268
272
|
};
|
|
273
|
+
readonly busybox: {
|
|
274
|
+
readonly valueFlags: readonly [];
|
|
275
|
+
readonly flags: readonly [];
|
|
276
|
+
readonly commandString: readonly [];
|
|
277
|
+
};
|
|
278
|
+
readonly su: {
|
|
279
|
+
readonly valueFlags: readonly [];
|
|
280
|
+
readonly flags: readonly [];
|
|
281
|
+
readonly commandString: readonly [];
|
|
282
|
+
readonly viaShell: true;
|
|
283
|
+
};
|
|
284
|
+
readonly runuser: {
|
|
285
|
+
readonly valueFlags: readonly [];
|
|
286
|
+
readonly flags: readonly [];
|
|
287
|
+
readonly commandString: readonly [];
|
|
288
|
+
readonly viaShell: true;
|
|
289
|
+
};
|
|
290
|
+
readonly chroot: {
|
|
291
|
+
readonly valueFlags: readonly [];
|
|
292
|
+
readonly flags: readonly [];
|
|
293
|
+
readonly commandString: readonly [];
|
|
294
|
+
readonly positional: RegExp;
|
|
295
|
+
};
|
|
296
|
+
readonly setpriv: {
|
|
297
|
+
readonly valueFlags: readonly [];
|
|
298
|
+
readonly flags: readonly [];
|
|
299
|
+
readonly commandString: readonly [];
|
|
300
|
+
};
|
|
301
|
+
readonly numactl: {
|
|
302
|
+
readonly valueFlags: readonly [];
|
|
303
|
+
readonly flags: readonly [];
|
|
304
|
+
readonly commandString: readonly [];
|
|
305
|
+
};
|
|
306
|
+
readonly prlimit: {
|
|
307
|
+
readonly valueFlags: readonly [];
|
|
308
|
+
readonly flags: readonly [];
|
|
309
|
+
readonly commandString: readonly [];
|
|
310
|
+
};
|
|
311
|
+
readonly "systemd-run": {
|
|
312
|
+
readonly valueFlags: readonly [];
|
|
313
|
+
readonly flags: readonly [];
|
|
314
|
+
readonly commandString: readonly [];
|
|
315
|
+
};
|
|
316
|
+
readonly valgrind: {
|
|
317
|
+
readonly valueFlags: readonly [];
|
|
318
|
+
readonly flags: readonly [];
|
|
319
|
+
readonly commandString: readonly [];
|
|
320
|
+
};
|
|
321
|
+
readonly firejail: {
|
|
322
|
+
readonly valueFlags: readonly [];
|
|
323
|
+
readonly flags: readonly [];
|
|
324
|
+
readonly commandString: readonly [];
|
|
325
|
+
};
|
|
326
|
+
readonly bwrap: {
|
|
327
|
+
readonly valueFlags: readonly [];
|
|
328
|
+
readonly flags: readonly [];
|
|
329
|
+
readonly commandString: readonly [];
|
|
330
|
+
};
|
|
331
|
+
readonly ash: {
|
|
332
|
+
readonly valueFlags: readonly [];
|
|
333
|
+
readonly flags: readonly [];
|
|
334
|
+
readonly commandString: readonly [];
|
|
335
|
+
readonly viaShell: true;
|
|
336
|
+
};
|
|
337
|
+
readonly mksh: {
|
|
338
|
+
readonly valueFlags: readonly [];
|
|
339
|
+
readonly flags: readonly [];
|
|
340
|
+
readonly commandString: readonly [];
|
|
341
|
+
readonly viaShell: true;
|
|
342
|
+
};
|
|
343
|
+
readonly yash: {
|
|
344
|
+
readonly valueFlags: readonly [];
|
|
345
|
+
readonly flags: readonly [];
|
|
346
|
+
readonly commandString: readonly [];
|
|
347
|
+
readonly viaShell: true;
|
|
348
|
+
};
|
|
349
|
+
readonly pdksh: {
|
|
350
|
+
readonly valueFlags: readonly [];
|
|
351
|
+
readonly flags: readonly [];
|
|
352
|
+
readonly commandString: readonly [];
|
|
353
|
+
readonly viaShell: true;
|
|
354
|
+
};
|
|
355
|
+
readonly parallel: {
|
|
356
|
+
readonly valueFlags: readonly [];
|
|
357
|
+
readonly flags: readonly [];
|
|
358
|
+
readonly commandString: readonly [];
|
|
359
|
+
readonly viaShell: true;
|
|
360
|
+
};
|
|
361
|
+
readonly alias: {
|
|
362
|
+
readonly valueFlags: readonly [];
|
|
363
|
+
readonly flags: readonly [];
|
|
364
|
+
readonly commandString: readonly [];
|
|
365
|
+
readonly viaShell: true;
|
|
366
|
+
};
|
|
367
|
+
readonly mapfile: {
|
|
368
|
+
readonly valueFlags: readonly [];
|
|
369
|
+
readonly flags: readonly [];
|
|
370
|
+
readonly commandString: readonly [];
|
|
371
|
+
readonly executes: readonly ["-C"];
|
|
372
|
+
};
|
|
373
|
+
readonly readarray: {
|
|
374
|
+
readonly valueFlags: readonly [];
|
|
375
|
+
readonly flags: readonly [];
|
|
376
|
+
readonly commandString: readonly [];
|
|
377
|
+
readonly executes: readonly ["-C"];
|
|
378
|
+
};
|
|
269
379
|
};
|
|
270
380
|
export type ShellWrapperName = keyof typeof SHELL_WRAPPER_TABLE;
|
|
271
381
|
/** The shape of one row (see the table's contract). */
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
+
import { declaresOption, programRows } from "../tools/fs/program-read-model.js";
|
|
1
2
|
export const SHELL_WRAPPER_TABLE = {
|
|
2
3
|
command: { valueFlags: [], flags: ["-p"], commandString: [] },
|
|
3
4
|
builtin: { valueFlags: [], flags: [], commandString: [] },
|
|
4
5
|
noglob: { valueFlags: [], flags: [], commandString: [] },
|
|
5
6
|
nocorrect: { valueFlags: [], flags: [], commandString: [] },
|
|
6
7
|
exec: { valueFlags: ["-a"], flags: ["-c", "-l"], commandString: [] },
|
|
7
|
-
env: { valueFlags: ["
|
|
8
|
-
sudo: { valueFlags: ["-
|
|
9
|
-
doas: { valueFlags: ["-
|
|
10
|
-
pkexec: { valueFlags: ["--user"], flags: ["--disable-internal-agent", "--
|
|
8
|
+
env: { valueFlags: ["--argv0", "--chdir", "--unset", "-C", "-P", "-a", "-u"], flags: ["--debug", "--default-signal", "--help", "--ignore-environment", "--ignore-signal", "--list-signal-handling", "--version", "-i", "-v"], commandString: ["--split-string", "-S"], bareDash: true, assignments: true },
|
|
9
|
+
sudo: { valueFlags: ["--auth-type", "--chdir", "--chroot", "--close-from", "--command-timeout", "--group", "--host", "--other-user", "--prompt", "--role", "--type", "--user", "-C", "-D", "-R", "-T", "-U", "-a", "-g", "-h", "-p", "-r", "-t", "-u"], flags: ["--askpass", "--background", "--bell", "--help", "--list", "--login", "--non-interactive", "--preserve-env", "--preserve-groups", "--remove-timestamp", "--reset-timestamp", "--set-home", "--shell", "--stdin", "--validate", "--version", "-A", "-E", "-H", "-K", "-P", "-S", "-V", "-b", "-i", "-k", "-l", "-n", "-s", "-v"], commandString: [], assignments: true },
|
|
10
|
+
doas: { valueFlags: ["-C", "-a", "-u"], flags: ["-L", "-n", "-s"], commandString: [] },
|
|
11
|
+
pkexec: { valueFlags: ["--user"], flags: ["--disable-internal-agent", "--help", "--keep-cwd", "--version"], commandString: [] },
|
|
11
12
|
nohup: { valueFlags: [], flags: ["--help", "--version"], commandString: [] },
|
|
12
|
-
time: { valueFlags: ["
|
|
13
|
-
nice: { valueFlags: ["
|
|
14
|
-
timeout: { valueFlags: ["-
|
|
15
|
-
stdbuf: { valueFlags: ["
|
|
16
|
-
xargs: { valueFlags: ["-
|
|
13
|
+
time: { valueFlags: ["--format", "--output", "-f", "-o"], flags: ["--append", "--help", "--portability", "--quiet", "--verbose", "--version", "-a", "-p", "-q", "-v"], commandString: [] },
|
|
14
|
+
nice: { valueFlags: ["--adjustment", "-n"], flags: ["--help", "--version"], commandString: [] },
|
|
15
|
+
timeout: { valueFlags: ["--kill-after", "--signal", "-k", "-s"], flags: ["--foreground", "--help", "--preserve-status", "--verbose", "--version", "-v"], commandString: [], duration: true },
|
|
16
|
+
stdbuf: { valueFlags: ["--error", "--input", "--output", "-e", "-i", "-o"], flags: ["--help", "--version"], commandString: [] },
|
|
17
|
+
xargs: { valueFlags: ["--arg-file", "--delimiter", "--max-args", "--max-chars", "--max-procs", "--process-slot-var", "-E", "-I", "-L", "-P", "-a", "-d", "-n", "-s"], flags: ["--eof", "--exit", "--help", "--interactive", "--max-lines", "--no-run-if-empty", "--null", "--open-tty", "--replace", "--show-limits", "--verbose", "--version", "-0", "-o", "-p", "-r", "-t", "-x"], attached: ["-i", "-l"], commandString: [] },
|
|
17
18
|
watch: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
18
|
-
ionice: { valueFlags: ["
|
|
19
|
-
setsid: { valueFlags: [], flags: ["
|
|
20
|
-
taskset: { valueFlags: [], flags: ["-
|
|
21
|
-
chrt: { valueFlags: ["
|
|
22
|
-
strace: { valueFlags: ["
|
|
23
|
-
ltrace: { valueFlags: ["
|
|
24
|
-
flock: { valueFlags: ["-
|
|
25
|
-
script: { valueFlags: [], flags: [], commandString: ["
|
|
26
|
-
unshare: { valueFlags: ["
|
|
27
|
-
nsenter: { valueFlags: ["
|
|
19
|
+
ionice: { valueFlags: ["--class", "--classdata", "--pgid", "--pid", "--uid", "-P", "-c", "-n", "-p", "-u"], flags: ["--help", "--ignore", "--version", "-V", "-h", "-t"], commandString: [] },
|
|
20
|
+
setsid: { valueFlags: [], flags: ["--ctty", "--fork", "--help", "--version", "--wait", "-c", "-f", "-w"], commandString: [] },
|
|
21
|
+
taskset: { valueFlags: [], flags: ["--all-tasks", "--cpu-list", "--help", "--pid", "--version", "-a", "-c", "-p"], commandString: [], positional: /^(?:0x)?[\da-f]+$|^[\d,:-]+$/i },
|
|
22
|
+
chrt: { valueFlags: ["--pid", "--sched-deadline", "--sched-period", "--sched-runtime", "-D", "-P", "-T", "-p"], flags: ["--all-tasks", "--batch", "--deadline", "--fifo", "--help", "--idle", "--max", "--other", "--reset-on-fork", "--rr", "--verbose", "--version", "-R", "-a", "-b", "-d", "-f", "-i", "-m", "-o", "-r", "-v"], commandString: [], positional: /^\d+$/ },
|
|
23
|
+
strace: { valueFlags: ["--attach", "--columns", "--const-print-style", "--detach-on", "--env", "--expr", "--interruptible", "--output", "--string-limit", "--summary-columns", "--summary-sort-by", "--summary-syscall-overhead", "--trace", "--trace-path", "--user", "-E", "-I", "-O", "-P", "-S", "-U", "-X", "-a", "-b", "-e", "-o", "-p", "-s", "-u"], flags: ["--debug", "--follow-forks", "--help", "--summary", "--summary-only", "--version", "-C", "-D", "-F", "-T", "-V", "-Z", "-c", "-d", "-f", "-h", "-i", "-k", "-q", "-r", "-t", "-v", "-w", "-x", "-y", "-z"], commandString: [] },
|
|
24
|
+
ltrace: { valueFlags: ["--align", "--config", "--debug", "--indent", "--library", "--output", "--string-max", "--where", "-A", "-D", "-F", "-a", "-e", "-l", "-n", "-o", "-p", "-s", "-u", "-w", "-x"], flags: ["--demangle", "--help", "--version", "-C", "-L", "-S", "-T", "-V", "-c", "-f", "-i", "-r", "-t"], commandString: [] },
|
|
25
|
+
flock: { valueFlags: ["--conflict-exit-code", "--timeout", "--wait", "-E", "-w"], flags: ["--close", "--exclusive", "--help", "--nb", "--no-fork", "--nonblock", "--shared", "--unlock", "--verbose", "--version", "-F", "-n", "-o", "-s", "-u", "-x"], commandString: ["--command", "-c"], positional: /^/ },
|
|
26
|
+
script: { valueFlags: [], flags: [], commandString: ["--command", "-c"], viaShell: true },
|
|
27
|
+
unshare: { valueFlags: ["--boottime", "--map-group", "--map-user", "--monotonic", "--propagation", "--root", "--setgid", "--setgroups", "--setuid", "--wd", "-G", "-R", "-S", "-w"], flags: ["--cgroup", "--fork", "--help", "--ipc", "--keep-caps", "--kill-child", "--map-current-user", "--map-root-user", "--mount", "--mount-proc", "--net", "--pid", "--time", "--user", "--uts", "--version", "-C", "-T", "-U", "-c", "-f", "-i", "-m", "-n", "-p", "-r", "-u"], commandString: [] },
|
|
28
|
+
nsenter: { valueFlags: ["--setgid", "--setuid", "--target", "-G", "-S", "-t"], flags: ["--all", "--cgroup", "--help", "--ipc", "--mount", "--net", "--no-fork", "--pid", "--preserve-credentials", "--root", "--time", "--user", "--uts", "--version", "--wd", "-C", "-F", "-T", "-U", "-Z", "-a", "-i", "-m", "-n", "-p", "-u"], attached: ["-r", "-w"], commandString: [] },
|
|
28
29
|
eval: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
29
30
|
source: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
30
31
|
".": { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
@@ -41,8 +42,27 @@ export const SHELL_WRAPPER_TABLE = {
|
|
|
41
42
|
find: { valueFlags: [], flags: [], commandString: [], executes: ["-exec", "-execdir", "-ok", "-okdir"] },
|
|
42
43
|
compgen: { valueFlags: [], flags: [], commandString: [], executes: ["-C", "-F"] },
|
|
43
44
|
complete: { valueFlags: [], flags: [], commandString: [], executes: ["-C", "-F"] },
|
|
45
|
+
busybox: { valueFlags: [], flags: [], commandString: [] },
|
|
46
|
+
su: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
47
|
+
runuser: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
48
|
+
chroot: { valueFlags: [], flags: [], commandString: [], positional: /^/ },
|
|
49
|
+
setpriv: { valueFlags: [], flags: [], commandString: [] },
|
|
50
|
+
numactl: { valueFlags: [], flags: [], commandString: [] },
|
|
51
|
+
prlimit: { valueFlags: [], flags: [], commandString: [] },
|
|
52
|
+
"systemd-run": { valueFlags: [], flags: [], commandString: [] },
|
|
53
|
+
valgrind: { valueFlags: [], flags: [], commandString: [] },
|
|
54
|
+
firejail: { valueFlags: [], flags: [], commandString: [] },
|
|
55
|
+
bwrap: { valueFlags: [], flags: [], commandString: [] },
|
|
56
|
+
ash: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
57
|
+
mksh: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
58
|
+
yash: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
59
|
+
pdksh: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
60
|
+
parallel: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
61
|
+
alias: { valueFlags: [], flags: [], commandString: [], viaShell: true },
|
|
62
|
+
mapfile: { valueFlags: [], flags: [], commandString: [], executes: ["-C"] },
|
|
63
|
+
readarray: { valueFlags: [], flags: [], commandString: [], executes: ["-C"] },
|
|
44
64
|
};
|
|
45
|
-
export const VARIABLE_OPERAND_BUILTINS = new Set(
|
|
65
|
+
export const VARIABLE_OPERAND_BUILTINS = new Set(programRows().filter((row) => row.operands?.rest?.kind === "binds-name" || declaresOption(row, (spec) => spec.value?.kind === "binds-name")).map((row) => row.key));
|
|
46
66
|
export function evaluatesOperand(run) {
|
|
47
67
|
if (!VARIABLE_OPERAND_BUILTINS.has(run[0]?.text ?? ""))
|
|
48
68
|
return false;
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
* visibility probe from a model's call.
|
|
51
51
|
*/
|
|
52
52
|
import type { ToolCallRequest, ToolCallFace, ToolPolicy } from "./tool-policy.js";
|
|
53
|
+
import type { CallTargetStamp } from "./effective-path-target.js";
|
|
53
54
|
import { type SkillGrantLane } from "./skill-grant.js";
|
|
54
55
|
import type { OrgGateVerdict, PersistedRuleAnswer } from "./hooks.js";
|
|
55
56
|
/** The layers the judge consults, as named in its verdicts. */
|
|
@@ -81,6 +82,8 @@ export interface SyntheticReadLayers {
|
|
|
81
82
|
orgRuleLane?: {
|
|
82
83
|
adjudicate: (req: ToolCallRequest) => Promise<OrgGateVerdict>;
|
|
83
84
|
};
|
|
85
|
+
/** The leg's target-reading stamp: the probe's request carries a reading of its target, as the live gate's does. */
|
|
86
|
+
stampCallTarget?: CallTargetStamp;
|
|
84
87
|
/** The run's signal, for the engine's own layers. */
|
|
85
88
|
signal?: AbortSignal;
|
|
86
89
|
}
|
|
@@ -15,13 +15,15 @@ export function createSyntheticReadJudge(layers) {
|
|
|
15
15
|
return async (call, face, budget) => {
|
|
16
16
|
const deadlineAt = budget?.deadlineAt ?? Date.now() + ORG_ADJUDICATION_TIMEOUT_MS;
|
|
17
17
|
const left = () => Math.max(0, Math.min(ORG_ADJUDICATION_TIMEOUT_MS, deadlineAt - Date.now()));
|
|
18
|
-
const
|
|
18
|
+
const probe = {
|
|
19
19
|
toolName: "Read",
|
|
20
20
|
args: { file_path: call.file_path, ...(call.offset !== undefined ? { offset: call.offset } : {}), ...(call.limit !== undefined ? { limit: call.limit } : {}) },
|
|
21
21
|
toolCallId: syntheticReadProbeId(face),
|
|
22
22
|
...(call.cwd !== undefined ? { cwd: call.cwd } : {}),
|
|
23
23
|
...(call.face !== undefined ? { face: call.face } : {}),
|
|
24
24
|
};
|
|
25
|
+
const stamped = layers.stampCallTarget?.(probe, layers.signal);
|
|
26
|
+
const req = stamped !== undefined ? await stamped : probe;
|
|
25
27
|
let unanswered;
|
|
26
28
|
const cannot = (layer, cause, reason) => {
|
|
27
29
|
unanswered ??= { verdict: "unanswerable", layer, cause, reason };
|