@dungle-scrubs/harness-cli-normalizer 0.4.5 → 0.5.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 +53 -7
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +13 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +65 -0
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/help.d.ts +2 -2
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +28 -7
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/inspect.d.ts.map +1 -1
- package/dist/cli/inspect.js +81 -25
- package/dist/cli/inspect.js.map +1 -1
- package/dist/cli/provenance.d.ts +3 -0
- package/dist/cli/provenance.d.ts.map +1 -0
- package/dist/cli/provenance.js +11 -0
- package/dist/cli/provenance.js.map +1 -0
- package/dist/cli/refuse.d.ts +14 -0
- package/dist/cli/refuse.d.ts.map +1 -0
- package/dist/cli/refuse.js +38 -0
- package/dist/cli/refuse.js.map +1 -0
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +27 -68
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/session.d.ts.map +1 -1
- package/dist/cli/session.js +3 -3
- package/dist/cli/session.js.map +1 -1
- package/dist/cli/skills-root.d.ts +2 -1
- package/dist/cli/skills-root.d.ts.map +1 -1
- package/dist/cli/skills-root.js +6 -4
- package/dist/cli/skills-root.js.map +1 -1
- package/dist/execution/decode.d.ts.map +1 -1
- package/dist/execution/decode.js +2 -1
- package/dist/execution/decode.js.map +1 -1
- package/dist/execution/deps.d.ts +1 -1
- package/dist/execution/deps.js +1 -1
- package/dist/execution/failure.d.ts +5 -1
- package/dist/execution/failure.d.ts.map +1 -1
- package/dist/execution/failure.js +12 -0
- package/dist/execution/failure.js.map +1 -1
- package/dist/execution/index.d.ts +2 -2
- package/dist/execution/index.js +2 -2
- package/dist/execution/open-session.d.ts.map +1 -1
- package/dist/execution/open-session.js +23 -8
- package/dist/execution/open-session.js.map +1 -1
- package/dist/execution/stream-turn.d.ts.map +1 -1
- package/dist/execution/stream-turn.js +18 -10
- package/dist/execution/stream-turn.js.map +1 -1
- package/dist/interpretation/argv.d.ts +3 -0
- package/dist/interpretation/argv.d.ts.map +1 -1
- package/dist/interpretation/argv.js +6 -1
- package/dist/interpretation/argv.js.map +1 -1
- package/dist/interpretation/content.d.ts.map +1 -1
- package/dist/interpretation/content.js +4 -1
- package/dist/interpretation/content.js.map +1 -1
- package/dist/interpretation/hints.d.ts.map +1 -1
- package/dist/interpretation/hints.js +4 -0
- package/dist/interpretation/hints.js.map +1 -1
- package/dist/interpretation/limits.d.ts +1 -0
- package/dist/interpretation/limits.d.ts.map +1 -1
- package/dist/interpretation/limits.js +22 -0
- package/dist/interpretation/limits.js.map +1 -1
- package/dist/interpretation/resolve-options.d.ts.map +1 -1
- package/dist/interpretation/resolve-options.js +124 -3
- package/dist/interpretation/resolve-options.js.map +1 -1
- package/dist/interpretation/support.d.ts +1 -0
- package/dist/interpretation/support.d.ts.map +1 -1
- package/dist/interpretation/support.js +29 -0
- package/dist/interpretation/support.js.map +1 -1
- package/dist/interpretation/tool-selection.d.ts +6 -16
- package/dist/interpretation/tool-selection.d.ts.map +1 -1
- package/dist/interpretation/tool-selection.js +216 -80
- package/dist/interpretation/tool-selection.js.map +1 -1
- package/dist/interpretation/tool-vocabulary.d.ts +38 -0
- package/dist/interpretation/tool-vocabulary.d.ts.map +1 -0
- package/dist/interpretation/tool-vocabulary.js +142 -0
- package/dist/interpretation/tool-vocabulary.js.map +1 -0
- package/dist/interpretation/turn-options.d.ts.map +1 -1
- package/dist/interpretation/turn-options.js +107 -2
- package/dist/interpretation/turn-options.js.map +1 -1
- package/dist/interpretation/versions.d.ts +1 -1
- package/dist/interpretation/versions.d.ts.map +1 -1
- package/dist/interpretation/vocabulary.d.ts +1 -0
- package/dist/interpretation/vocabulary.d.ts.map +1 -1
- package/dist/interpretation/vocabulary.js +5 -0
- package/dist/interpretation/vocabulary.js.map +1 -1
- package/dist/knowledge/claude-code.d.ts.map +1 -1
- package/dist/knowledge/claude-code.js +14 -13
- package/dist/knowledge/claude-code.js.map +1 -1
- package/dist/knowledge/codex.d.ts.map +1 -1
- package/dist/knowledge/codex.js +10 -4
- package/dist/knowledge/codex.js.map +1 -1
- package/dist/knowledge/descriptor.d.ts +20 -1
- package/dist/knowledge/descriptor.d.ts.map +1 -1
- package/dist/knowledge/descriptor.js +18 -1
- package/dist/knowledge/descriptor.js.map +1 -1
- package/dist/knowledge/index.d.ts +1 -1
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/matchers.d.ts +2 -1
- package/dist/knowledge/matchers.d.ts.map +1 -1
- package/dist/knowledge/matchers.js +15 -0
- package/dist/knowledge/matchers.js.map +1 -1
- package/dist/knowledge/muse.d.ts.map +1 -1
- package/dist/knowledge/muse.js +18 -3
- package/dist/knowledge/muse.js.map +1 -1
- package/dist/knowledge/overrides.d.ts.map +1 -1
- package/dist/knowledge/overrides.js +3 -2
- package/dist/knowledge/overrides.js.map +1 -1
- package/dist/knowledge/pi.d.ts.map +1 -1
- package/dist/knowledge/pi.js +12 -8
- package/dist/knowledge/pi.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/args.ts +13 -0
- package/src/cli/config.ts +88 -0
- package/src/cli/help.ts +28 -7
- package/src/cli/inspect.ts +78 -21
- package/src/cli/provenance.ts +19 -0
- package/src/cli/refuse.ts +50 -0
- package/src/cli/run.ts +27 -94
- package/src/cli/session.ts +4 -3
- package/src/cli/skills-root.ts +11 -4
- package/src/execution/decode.ts +2 -1
- package/src/execution/deps.ts +1 -1
- package/src/execution/failure.ts +17 -1
- package/src/execution/index.ts +2 -2
- package/src/execution/open-session.ts +33 -7
- package/src/execution/stream-turn.ts +21 -9
- package/src/interpretation/argv.ts +9 -1
- package/src/interpretation/content.ts +5 -1
- package/src/interpretation/hints.ts +8 -0
- package/src/interpretation/limits.ts +29 -0
- package/src/interpretation/resolve-options.ts +129 -3
- package/src/interpretation/support.ts +30 -0
- package/src/interpretation/tool-selection.ts +236 -96
- package/src/interpretation/tool-vocabulary.ts +183 -0
- package/src/interpretation/turn-options.ts +99 -2
- package/src/interpretation/versions.ts +1 -1
- package/src/interpretation/vocabulary.ts +5 -0
- package/src/knowledge/claude-code.ts +14 -13
- package/src/knowledge/codex.ts +10 -4
- package/src/knowledge/descriptor.ts +42 -2
- package/src/knowledge/index.ts +5 -1
- package/src/knowledge/matchers.ts +17 -1
- package/src/knowledge/muse.ts +18 -3
- package/src/knowledge/overrides.ts +4 -2
- package/src/knowledge/pi.ts +12 -8
|
@@ -1,46 +1,61 @@
|
|
|
1
1
|
import { defaultDescriptors } from "../knowledge/overrides.js";
|
|
2
|
+
import { hintFor } from "./hints.js";
|
|
2
3
|
import { ArgvRefusalError } from "./refusal.js";
|
|
3
|
-
import { supportedBy } from "./support.js";
|
|
4
|
+
import { supportedBy, supportedByCanonical } from "./support.js";
|
|
5
|
+
import { allCanonicalNames, canonicalTable, parseToolSelector, READ_PRESET, } from "./tool-vocabulary.js";
|
|
4
6
|
export const TOOL_SELECTOR = /^[A-Za-z0-9][A-Za-z0-9._:/@-]{0,127}$/;
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
}
|
|
7
|
+
const validateInnerName = (h, name, raw) => {
|
|
8
|
+
if (name.trim() === "" || name.includes(",")) {
|
|
9
|
+
throw new ArgvRefusalError({
|
|
10
|
+
issue: "invalid-tool-grant",
|
|
11
|
+
harness: h.name,
|
|
12
|
+
supported: ["non-empty, comma-free tool names"],
|
|
13
|
+
detail: `tools=${JSON.stringify(raw)}`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (!TOOL_SELECTOR.test(name)) {
|
|
17
|
+
throw new ArgvRefusalError({
|
|
18
|
+
issue: "invalid-tool-grant",
|
|
19
|
+
harness: h.name,
|
|
20
|
+
supported: [`must match ${TOOL_SELECTOR.source}`],
|
|
21
|
+
detail: name,
|
|
22
|
+
});
|
|
23
23
|
}
|
|
24
|
-
return [...names];
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
for (const name of names) {
|
|
33
|
-
if (known.has(name))
|
|
34
|
-
mapped.push(name);
|
|
35
|
-
else
|
|
36
|
-
unmapped.push(name);
|
|
25
|
+
const categoriesFor = (h, canonicals, table) => {
|
|
26
|
+
const cats = new Set();
|
|
27
|
+
for (const c of canonicals) {
|
|
28
|
+
const val = table[c]?.[h.name];
|
|
29
|
+
if (val?.kind === "category")
|
|
30
|
+
cats.add(val.key);
|
|
37
31
|
}
|
|
38
|
-
return
|
|
32
|
+
return cats;
|
|
33
|
+
};
|
|
34
|
+
export const renderAccessPreset = (h, access, opts = {}) => {
|
|
35
|
+
if (access === "write")
|
|
36
|
+
return [];
|
|
37
|
+
// read preset
|
|
38
|
+
const filtered = READ_PRESET.filter((c) => {
|
|
39
|
+
if (opts.toolMap?.[c] !== undefined)
|
|
40
|
+
return true;
|
|
41
|
+
const table = canonicalTable(defaultDescriptors());
|
|
42
|
+
return table[c]?.[h.name] !== undefined;
|
|
43
|
+
});
|
|
44
|
+
if (filtered.length === 0)
|
|
45
|
+
return [];
|
|
46
|
+
// For tool-preset harnesses, render via tool-selection include
|
|
47
|
+
const spec = h.turnOptions.access;
|
|
48
|
+
if (spec && spec.kind === "tool-preset") {
|
|
49
|
+
const rendered = renderToolSelection(h, { include: filtered, toolMap: opts.toolMap });
|
|
50
|
+
return [...rendered.tokens];
|
|
51
|
+
}
|
|
52
|
+
// For flag-value / flag-list-by-value harnesses, caller should handle via spec mapping;
|
|
53
|
+
// we return empty here so turn-options can map via spec values.
|
|
54
|
+
return [];
|
|
39
55
|
};
|
|
40
56
|
export const renderToolSelection = (h, selection) => {
|
|
41
57
|
const hasInclude = selection.include !== undefined;
|
|
42
58
|
const hasExclude = selection.exclude !== undefined;
|
|
43
|
-
// D1: mutual exclusivity, structured refusal.
|
|
44
59
|
if (hasInclude && hasExclude) {
|
|
45
60
|
throw new ArgvRefusalError({
|
|
46
61
|
issue: "mutually-exclusive-options",
|
|
@@ -51,81 +66,202 @@ export const renderToolSelection = (h, selection) => {
|
|
|
51
66
|
});
|
|
52
67
|
}
|
|
53
68
|
if (!hasInclude && !hasExclude)
|
|
54
|
-
return { tokens: [],
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
69
|
+
return { tokens: [], passthrough: [] };
|
|
70
|
+
const set = defaultDescriptors();
|
|
71
|
+
const table = canonicalTable(set);
|
|
72
|
+
const toolMap = selection.toolMap ?? {};
|
|
73
|
+
const allCanonical = allCanonicalNames(set, {
|
|
74
|
+
[h.name]: toolMap,
|
|
75
|
+
});
|
|
76
|
+
const splitSelection = (names) => {
|
|
77
|
+
const canonical = [];
|
|
78
|
+
const passthrough = [];
|
|
79
|
+
const setForValidate = new Set(allCanonical);
|
|
80
|
+
for (const raw of names) {
|
|
81
|
+
const parsed = parseToolSelector(raw);
|
|
82
|
+
if (parsed.kind === "native") {
|
|
83
|
+
validateInnerName(h, parsed.name, names);
|
|
84
|
+
passthrough.push(parsed.name);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
validateInnerName(h, parsed.name, names);
|
|
88
|
+
if (!setForValidate.has(parsed.name)) {
|
|
89
|
+
throw new ArgvRefusalError({
|
|
90
|
+
issue: "unknown-tool-name",
|
|
91
|
+
harness: h.name,
|
|
92
|
+
option: "tools",
|
|
93
|
+
supported: [...allCanonical],
|
|
94
|
+
hint: "use native:<name> for an extension or MCP tool",
|
|
95
|
+
detail: `unknown tool name(s) ${parsed.name}`,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
canonical.push(parsed.name);
|
|
99
|
+
}
|
|
100
|
+
return { canonical, passthrough };
|
|
101
|
+
};
|
|
102
|
+
const isCodexShape = h.tools.includeFlag === null && h.tools.categories.length === 0;
|
|
103
|
+
const isCategoryShape = h.tools.includeFlag === null && h.tools.categories.length > 0;
|
|
104
|
+
if (isCodexShape) {
|
|
58
105
|
throw new ArgvRefusalError({
|
|
59
106
|
issue: "unsupported-option",
|
|
60
107
|
harness: h.name,
|
|
61
|
-
option,
|
|
108
|
+
option: hasInclude ? "tools" : "excludeTools",
|
|
62
109
|
supported: ["per-tool name lists"],
|
|
63
|
-
supportedBy:
|
|
64
|
-
hint: h.name
|
|
65
|
-
|
|
66
|
-
: "nearest control on muse: category switches (--disable-write, --disable-shell, --disable-web-tools) gate tool execution per session",
|
|
110
|
+
supportedBy: supportedBy(set, hasInclude ? "tools" : "excludeTools"),
|
|
111
|
+
hint: hintFor(h.name, hasInclude ? "tools" : "excludeTools") ??
|
|
112
|
+
"nearest control on codex: category switches via config keys (features.shell_tool, web_search) or sandbox modes - see `hcn inspect codex`",
|
|
67
113
|
});
|
|
68
114
|
}
|
|
115
|
+
if (isCategoryShape) {
|
|
116
|
+
const names = hasInclude ? selection.include : selection.exclude;
|
|
117
|
+
const { canonical, passthrough } = splitSelection(names);
|
|
118
|
+
if (hasExclude) {
|
|
119
|
+
// one helper replaces the three no-counterpart loops
|
|
120
|
+
for (const c of canonical) {
|
|
121
|
+
const has = toolMap[c] !== undefined || table[c]?.[h.name] !== undefined;
|
|
122
|
+
if (!has) {
|
|
123
|
+
throw new ArgvRefusalError({
|
|
124
|
+
issue: "unsupported-option",
|
|
125
|
+
harness: h.name,
|
|
126
|
+
option: "excludeTools",
|
|
127
|
+
supported: ["per-tool name lists"],
|
|
128
|
+
supportedBy: supportedByCanonical(set, c),
|
|
129
|
+
hint: hintFor(h.name, "excludeTools"),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const cats = categoriesFor(h, canonical, table);
|
|
134
|
+
const tokens = [];
|
|
135
|
+
for (const cat of h.tools.categories) {
|
|
136
|
+
if (cats.has(cat.key) && cat.disableFlag)
|
|
137
|
+
tokens.push(cat.disableFlag);
|
|
138
|
+
}
|
|
139
|
+
return { tokens, passthrough };
|
|
140
|
+
}
|
|
141
|
+
for (const c of canonical) {
|
|
142
|
+
const has = toolMap[c] !== undefined || table[c]?.[h.name] !== undefined;
|
|
143
|
+
if (!has) {
|
|
144
|
+
throw new ArgvRefusalError({
|
|
145
|
+
issue: "unsupported-option",
|
|
146
|
+
harness: h.name,
|
|
147
|
+
option: "tools",
|
|
148
|
+
supported: ["per-tool name lists"],
|
|
149
|
+
supportedBy: supportedByCanonical(set, c),
|
|
150
|
+
hint: hintFor(h.name, "tools"),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (canonical.length === 0) {
|
|
155
|
+
const tokens = h.tools.categories.map((c) => c.disableFlag).filter((f) => !!f);
|
|
156
|
+
return { tokens, passthrough };
|
|
157
|
+
}
|
|
158
|
+
const grantedCats = categoriesFor(h, canonical, table);
|
|
159
|
+
const tokens = [];
|
|
160
|
+
for (const cat of h.tools.categories) {
|
|
161
|
+
if (!grantedCats.has(cat.key) && cat.disableFlag)
|
|
162
|
+
tokens.push(cat.disableFlag);
|
|
163
|
+
}
|
|
164
|
+
return { tokens, passthrough };
|
|
165
|
+
}
|
|
166
|
+
// From here: h has list flags (claude, pi)
|
|
69
167
|
if (hasInclude) {
|
|
70
|
-
const names =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (mapped.length === 0 && unmapped.length > 0) {
|
|
168
|
+
const names = selection.include;
|
|
169
|
+
if (names.length === 0) {
|
|
170
|
+
if (h.tools.includeIsStrictAllowlist) {
|
|
74
171
|
throw new ArgvRefusalError({
|
|
75
|
-
issue: "
|
|
172
|
+
issue: "invalid-tool-grant",
|
|
173
|
+
harness: h.name,
|
|
174
|
+
option: "tools",
|
|
175
|
+
supported: ["non-empty tool list (empty include would deny everything)"],
|
|
176
|
+
detail: "empty include list",
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const known = h.tools.builtins.map((t) => t.name);
|
|
180
|
+
return { tokens: [h.tools.excludeFlag, known.join(",")], passthrough: [] };
|
|
181
|
+
}
|
|
182
|
+
const { canonical, passthrough } = splitSelection(names);
|
|
183
|
+
for (const c of canonical) {
|
|
184
|
+
const has = toolMap[c] !== undefined || table[c]?.[h.name] !== undefined;
|
|
185
|
+
if (!has) {
|
|
186
|
+
throw new ArgvRefusalError({
|
|
187
|
+
issue: "unsupported-option",
|
|
76
188
|
harness: h.name,
|
|
77
189
|
option: "tools",
|
|
78
|
-
supported: [
|
|
79
|
-
|
|
190
|
+
supported: ["per-tool name lists"],
|
|
191
|
+
supportedBy: supportedByCanonical(set, c),
|
|
192
|
+
hint: `add toolMap.${h.name}.${c} to ~/.config/hcn/config.json or pass native:${c}`,
|
|
80
193
|
});
|
|
81
194
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
195
|
+
}
|
|
196
|
+
const mapped = [];
|
|
197
|
+
for (const c of canonical) {
|
|
198
|
+
let n = toolMap[c] ?? null;
|
|
199
|
+
if (n === null) {
|
|
200
|
+
const entry = table[c]?.[h.name];
|
|
201
|
+
if (entry?.kind === "builtin")
|
|
202
|
+
n = entry.native;
|
|
203
|
+
}
|
|
204
|
+
if (n)
|
|
205
|
+
mapped.push(n);
|
|
206
|
+
}
|
|
207
|
+
if (!h.tools.includeIsStrictAllowlist) {
|
|
208
|
+
// claude's include flag pre-approves without restricting, so an exact allowlist renders as the deny complement
|
|
88
209
|
const known = h.tools.builtins.map((t) => t.name);
|
|
89
210
|
const excluded = known.filter((n) => !mapped.includes(n));
|
|
90
|
-
const tokens = [h.tools.includeFlag, [...mapped, ...
|
|
91
|
-
|
|
92
|
-
|
|
211
|
+
const tokens = [h.tools.includeFlag, [...mapped, ...passthrough].join(",")];
|
|
212
|
+
// only add exclude if needed? original pushed exclude even when? Keep original behavior: push excludeFlag excluded
|
|
213
|
+
if (excluded.length > 0 || passthrough.length > 0) {
|
|
214
|
+
tokens.push(h.tools.excludeFlag, excluded.join(","));
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// when all tools included, exclude nothing? but keep token? original pushed exclude always
|
|
218
|
+
tokens.push(h.tools.excludeFlag, excluded.join(","));
|
|
219
|
+
}
|
|
220
|
+
return { tokens, passthrough };
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
tokens: [h.tools.includeFlag, [...mapped, ...passthrough].join(",")],
|
|
224
|
+
passthrough,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
// exclude
|
|
228
|
+
const names = selection.exclude;
|
|
229
|
+
const { canonical, passthrough: excludedPassthrough } = splitSelection(names);
|
|
230
|
+
for (const c of canonical) {
|
|
231
|
+
const has = toolMap[c] !== undefined || table[c]?.[h.name] !== undefined;
|
|
232
|
+
if (!has) {
|
|
233
|
+
throw new ArgvRefusalError({
|
|
234
|
+
issue: "unsupported-option",
|
|
235
|
+
harness: h.name,
|
|
236
|
+
option: "excludeTools",
|
|
237
|
+
supported: ["per-tool name lists"],
|
|
238
|
+
supportedBy: supportedByCanonical(set, c),
|
|
239
|
+
hint: `add toolMap.${h.name}.${c} to ~/.config/hcn/config.json or pass native:${c}`,
|
|
240
|
+
});
|
|
93
241
|
}
|
|
94
|
-
// pi: strict over built-ins, direct include; unmapped (extension/MCP)
|
|
95
|
-
// names ride along in the same list - pi governs them too.
|
|
96
|
-
return { tokens: [h.tools.includeFlag, [...mapped, ...unmapped].join(",")], unmapped };
|
|
97
242
|
}
|
|
98
|
-
|
|
99
|
-
const names = validateNames(h, selection.exclude);
|
|
100
|
-
const { mapped, unmapped: excludedUnmapped } = resolveNames(h, names);
|
|
101
|
-
if (excludedUnmapped.length > 0) {
|
|
102
|
-
// Excluding a name the descriptor does not know: permitted (it may be a
|
|
103
|
-
// runtime-registered tool), rendered natively where the harness's deny
|
|
104
|
-
// list can carry it; on claude only, since its include path consumes
|
|
105
|
-
// unknown names without effect (silent-acceptance hazard).
|
|
243
|
+
if (excludedPassthrough.length > 0) {
|
|
106
244
|
if (!h.tools.includeIsStrictAllowlist) {
|
|
107
|
-
const
|
|
108
|
-
|
|
245
|
+
const mapped = canonical.map((c) => toolMap[c] ?? table[c]?.[h.name]?.native ?? c);
|
|
246
|
+
const tokens = [h.tools.excludeFlag, [...mapped, ...excludedPassthrough].join(",")];
|
|
247
|
+
return { tokens, passthrough: excludedPassthrough };
|
|
109
248
|
}
|
|
110
|
-
// pi: a D2 exclude renders as a computed include (its native exclude
|
|
111
|
-
// subtracts from the default set, which cannot express "all minus X"
|
|
112
|
-
// when off-by-default tools are involved). An unknown excluded name
|
|
113
|
-
// cannot be complemented - refuse rather than silently grant it.
|
|
114
249
|
throw new ArgvRefusalError({
|
|
115
250
|
issue: "unknown-tool-name",
|
|
116
251
|
harness: h.name,
|
|
117
252
|
option: "excludeTools",
|
|
118
253
|
supported: [`known tool names: ${h.tools.builtins.map((t) => t.name).join(", ")}`],
|
|
119
|
-
detail: `cannot exclude unknown name(s) ${
|
|
254
|
+
detail: `cannot exclude unknown name(s) ${excludedPassthrough.join(", ")}: the complement cannot be computed`,
|
|
120
255
|
});
|
|
121
256
|
}
|
|
257
|
+
const mapped = canonical
|
|
258
|
+
.map((c) => toolMap[c] ?? table[c]?.[h.name]?.native ?? "")
|
|
259
|
+
.filter(Boolean);
|
|
122
260
|
const known = h.tools.builtins.filter((t) => !mapped.includes(t.name));
|
|
123
261
|
const kept = known.map((t) => t.name);
|
|
124
262
|
if (!h.tools.includeIsStrictAllowlist) {
|
|
125
|
-
|
|
126
|
-
return { tokens: [h.tools.excludeFlag, mapped.join(",")], unmapped: [] };
|
|
263
|
+
return { tokens: [h.tools.excludeFlag, mapped.join(",")], passthrough: [] };
|
|
127
264
|
}
|
|
128
|
-
|
|
129
|
-
return { tokens: [h.tools.includeFlag, kept.join(",")], unmapped: [] };
|
|
265
|
+
return { tokens: [h.tools.includeFlag, kept.join(",")], passthrough: [] };
|
|
130
266
|
};
|
|
131
267
|
//# sourceMappingURL=tool-selection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-selection.js","sourceRoot":"","sources":["../../src/interpretation/tool-selection.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,uCAAuC,CAAC;AAYrE,MAAM,aAAa,GAAG,CAAC,CAAoB,EAAE,KAAwB,EAAY,EAAE;IACjF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,gBAAgB,CAAC;gBACzB,KAAK,EAAE,oBAAoB;gBAC3B,OAAO,EAAE,CAAC,CAAC,IAAI;gBACf,SAAS,EAAE,CAAC,kCAAkC,CAAC;gBAC/C,MAAM,EAAE,SAAS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;aACzC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,gBAAgB,CAAC;gBACzB,KAAK,EAAE,oBAAoB;gBAC3B,OAAO,EAAE,CAAC,CAAC,IAAI;gBACf,SAAS,EAAE,CAAC,cAAc,aAAa,CAA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AAC,KAAK,CAAC,WAAY,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AAC7E,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DescriptorSet } from "../knowledge/overrides.js";
|
|
2
|
+
export declare const NATIVE_PREFIX: "native:";
|
|
3
|
+
export type VocabularyEntry = {
|
|
4
|
+
kind: "builtin";
|
|
5
|
+
native: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "category";
|
|
8
|
+
key: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const READ_PRESET: readonly ["read", "grep", "glob", "list", "web-fetch", "web-search"];
|
|
11
|
+
export type ParsedSelector = {
|
|
12
|
+
kind: "canonical";
|
|
13
|
+
name: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "native";
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const parseToolSelector: (raw: string) => ParsedSelector;
|
|
19
|
+
export type ToolMap = Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
20
|
+
export type ToolMapTier = "user-config" | "project-config";
|
|
21
|
+
export type MergedToolMap = Readonly<Record<string, Readonly<Record<string, {
|
|
22
|
+
native: string;
|
|
23
|
+
tier: ToolMapTier;
|
|
24
|
+
}>>>>;
|
|
25
|
+
/** Pure merge per harness per canonical: project > user. */
|
|
26
|
+
export declare const mergeToolMaps: (tiers: {
|
|
27
|
+
readonly user?: ToolMap;
|
|
28
|
+
readonly project?: ToolMap;
|
|
29
|
+
}) => MergedToolMap;
|
|
30
|
+
export type CanonicalTable = Readonly<Record<string, Readonly<Partial<Record<string, VocabularyEntry>>>>>;
|
|
31
|
+
export declare const canonicalTable: (set: DescriptorSet) => CanonicalTable;
|
|
32
|
+
export declare const canonicalToolTable: typeof canonicalTable;
|
|
33
|
+
export declare const canonicalNames: (set: DescriptorSet) => readonly string[];
|
|
34
|
+
export declare const allCanonicalNames: (set: DescriptorSet, toolMap?: ToolMap | MergedToolMap) => readonly string[];
|
|
35
|
+
export declare const hasCounterpart: (table: CanonicalTable, canonical: string, harnessName: string, toolMap?: MergedToolMap | ToolMap) => boolean;
|
|
36
|
+
export declare const nativeFor: (table: CanonicalTable, canonical: string, harnessName: string, toolMap?: MergedToolMap | ToolMap) => string | null;
|
|
37
|
+
export declare const validateCanonicalList: (names: readonly string[] | undefined, allCanonical: readonly string[], harness: string) => void;
|
|
38
|
+
//# sourceMappingURL=tool-vocabulary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-vocabulary.d.ts","sourceRoot":"","sources":["../../src/interpretation/tool-vocabulary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D,eAAO,MAAM,aAAa,EAAG,SAAkB,CAAC;AAEhD,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,eAAO,MAAM,WAAW,YAAI,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,CAAU,CAAC;AAEhG,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpG,eAAO,MAAM,iBAAiB,QAAS,MAAM,KAAG,cAGV,CAAC;AAEvC,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjF,MAAM,MAAM,WAAW,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const NATIVE_PREFIX = "native:";
|
|
3
|
+
export const READ_PRESET = ["read", "grep", "glob", "list", "web-fetch", "web-search"];
|
|
4
|
+
export const parseToolSelector = (raw) => raw.startsWith(NATIVE_PREFIX)
|
|
5
|
+
? { kind: "native", name: raw.slice(NATIVE_PREFIX.length) }
|
|
6
|
+
: { kind: "canonical", name: raw };
|
|
7
|
+
/** Pure merge per harness per canonical: project > user. */
|
|
8
|
+
export const mergeToolMaps = (tiers) => {
|
|
9
|
+
const merged = {};
|
|
10
|
+
const harnesses = new Set([
|
|
11
|
+
...Object.keys(tiers.user ?? {}),
|
|
12
|
+
...Object.keys(tiers.project ?? {}),
|
|
13
|
+
]);
|
|
14
|
+
for (const h of harnesses) {
|
|
15
|
+
const userEntries = tiers.user?.[h] ?? {};
|
|
16
|
+
const projectEntries = tiers.project?.[h] ?? {};
|
|
17
|
+
const canonicals = new Set([
|
|
18
|
+
...Object.keys(userEntries),
|
|
19
|
+
...Object.keys(projectEntries),
|
|
20
|
+
]);
|
|
21
|
+
const perHarness = {};
|
|
22
|
+
for (const c of canonicals) {
|
|
23
|
+
if (projectEntries[c] !== undefined) {
|
|
24
|
+
perHarness[c] = { native: projectEntries[c], tier: "project-config" };
|
|
25
|
+
}
|
|
26
|
+
else if (userEntries[c] !== undefined) {
|
|
27
|
+
perHarness[c] = { native: userEntries[c], tier: "user-config" };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (Object.keys(perHarness).length > 0) {
|
|
31
|
+
merged[h] = perHarness;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return merged;
|
|
35
|
+
};
|
|
36
|
+
const tableCache = new WeakMap();
|
|
37
|
+
export const canonicalTable = (set) => {
|
|
38
|
+
const cached = tableCache.get(set);
|
|
39
|
+
if (cached)
|
|
40
|
+
return cached;
|
|
41
|
+
const allCanonical = new Set();
|
|
42
|
+
for (const h of Object.values(set)) {
|
|
43
|
+
if (!h)
|
|
44
|
+
continue;
|
|
45
|
+
for (const b of h.tools.builtins) {
|
|
46
|
+
if (b.canonical !== null)
|
|
47
|
+
allCanonical.add(b.canonical);
|
|
48
|
+
}
|
|
49
|
+
for (const c of h.tools.categories) {
|
|
50
|
+
for (const n of c.canonical)
|
|
51
|
+
allCanonical.add(n);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const table = {};
|
|
55
|
+
for (const canonical of allCanonical) {
|
|
56
|
+
const perHarness = {};
|
|
57
|
+
for (const h of Object.values(set)) {
|
|
58
|
+
if (!h)
|
|
59
|
+
continue;
|
|
60
|
+
const builtin = h.tools.builtins.find((b) => b.canonical === canonical);
|
|
61
|
+
if (builtin) {
|
|
62
|
+
perHarness[h.name] = { kind: "builtin", native: builtin.name };
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const cat = h.tools.categories.find((c) => c.canonical.includes(canonical));
|
|
66
|
+
if (cat) {
|
|
67
|
+
perHarness[h.name] = { kind: "category", key: cat.key };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
table[canonical] = perHarness;
|
|
71
|
+
}
|
|
72
|
+
const frozen = table;
|
|
73
|
+
tableCache.set(set, frozen);
|
|
74
|
+
return frozen;
|
|
75
|
+
};
|
|
76
|
+
// Backwards compat alias
|
|
77
|
+
export const canonicalToolTable = canonicalTable;
|
|
78
|
+
export const canonicalNames = (set) => {
|
|
79
|
+
const table = canonicalTable(set);
|
|
80
|
+
return Object.keys(table).sort();
|
|
81
|
+
};
|
|
82
|
+
export const allCanonicalNames = (set, toolMap) => {
|
|
83
|
+
const base = canonicalNames(set);
|
|
84
|
+
const extra = toolMap
|
|
85
|
+
? Object.values(toolMap).flatMap((m) => Object.keys(m))
|
|
86
|
+
: [];
|
|
87
|
+
return [...new Set([...base, ...extra])].sort();
|
|
88
|
+
};
|
|
89
|
+
export const hasCounterpart = (table, canonical, harnessName, toolMap) => {
|
|
90
|
+
if (toolMap) {
|
|
91
|
+
const hm = toolMap[harnessName];
|
|
92
|
+
if (hm && hm[canonical] !== undefined) {
|
|
93
|
+
const v = hm[canonical];
|
|
94
|
+
if (typeof v === "object" && v !== null && "native" in v)
|
|
95
|
+
return true;
|
|
96
|
+
if (typeof v === "string")
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const entry = table[canonical];
|
|
101
|
+
if (!entry)
|
|
102
|
+
return false;
|
|
103
|
+
return entry[harnessName] !== undefined;
|
|
104
|
+
};
|
|
105
|
+
export const nativeFor = (table, canonical, harnessName, toolMap) => {
|
|
106
|
+
if (toolMap) {
|
|
107
|
+
const hm = toolMap[harnessName];
|
|
108
|
+
const val = hm?.[canonical];
|
|
109
|
+
if (val !== undefined) {
|
|
110
|
+
if (typeof val === "object" && val !== null && "native" in val) {
|
|
111
|
+
return val.native;
|
|
112
|
+
}
|
|
113
|
+
if (typeof val === "string")
|
|
114
|
+
return val;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const entry = table[canonical];
|
|
118
|
+
const v = entry?.[harnessName];
|
|
119
|
+
if (v?.kind === "builtin")
|
|
120
|
+
return v.native;
|
|
121
|
+
return null;
|
|
122
|
+
};
|
|
123
|
+
export const validateCanonicalList = (names, allCanonical, harness) => {
|
|
124
|
+
if (!names)
|
|
125
|
+
return;
|
|
126
|
+
const set = new Set(allCanonical);
|
|
127
|
+
for (const name of names) {
|
|
128
|
+
if (name.startsWith(NATIVE_PREFIX))
|
|
129
|
+
continue;
|
|
130
|
+
if (!set.has(name)) {
|
|
131
|
+
throw new ArgvRefusalError({
|
|
132
|
+
issue: "unknown-tool-name",
|
|
133
|
+
harness: harness,
|
|
134
|
+
option: "tools",
|
|
135
|
+
supported: allCanonical,
|
|
136
|
+
hint: "use native:<name> for an extension or MCP tool",
|
|
137
|
+
detail: `unknown tool name ${JSON.stringify(name)}`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=tool-vocabulary.js.map
|
|
@@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IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;YAAE,SAAS;QAC7C,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,gBAAgB,CAAC;gBACzB,KAAK,EAAE,mBAAmB;gBAC1B,OAAO,EAAE,OAA2D;gBACpE,MAAM,EAAE,OAAO;gBACf,SAAS,EAAE,YAAmC;gBAC9C,IAAI,EAAE,gDAAgD;gBACtD,MAAM,EAAE,qBAAqB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;aACpD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-options.d.ts","sourceRoot":"","sources":["../../src/interpretation/turn-options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAA0B,MAAM,4BAA4B,CAAC;AAE5F,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"turn-options.d.ts","sourceRoot":"","sources":["../../src/interpretation/turn-options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAA0B,MAAM,4BAA4B,CAAC;AAE5F,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,WAAW,CAAC;AAe/D;;8EAE8E;AAC9E,eAAO,MAAM,iBAAiB,MACzB,iBAAiB,QACd,WAAW,SACV,QAAQ,GAAG,QAAQ,KACzB,MAAM,EAqgBR,CAAC"}
|