@dungle-scrubs/harness-cli-normalizer 0.6.0 → 0.6.2
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 +33 -6
- package/dist/cli/args.d.ts +9 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +36 -26
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/check.d.ts +14 -0
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +10 -3
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/config.d.ts +4 -4
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +8 -6
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/exit-codes.d.ts +0 -1
- package/dist/cli/exit-codes.d.ts.map +1 -1
- package/dist/cli/exit-codes.js +0 -1
- package/dist/cli/exit-codes.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 +10 -2
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +3 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/inspect.d.ts.map +1 -1
- package/dist/cli/inspect.js +84 -265
- package/dist/cli/inspect.js.map +1 -1
- package/dist/cli/plan-turn.d.ts +68 -0
- package/dist/cli/plan-turn.d.ts.map +1 -0
- package/dist/cli/plan-turn.js +268 -0
- package/dist/cli/plan-turn.js.map +1 -0
- package/dist/cli/refuse.d.ts.map +1 -1
- package/dist/cli/refuse.js +2 -1
- package/dist/cli/refuse.js.map +1 -1
- package/dist/cli/resolve-harness.d.ts.map +1 -1
- package/dist/cli/resolve-harness.js +2 -3
- package/dist/cli/resolve-harness.js.map +1 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +33 -367
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/session-json.d.ts +1 -1
- package/dist/cli/session-json.d.ts.map +1 -1
- package/dist/cli/session-json.js +1 -3
- package/dist/cli/session-json.js.map +1 -1
- package/dist/cli/session.d.ts.map +1 -1
- package/dist/cli/session.js +35 -43
- package/dist/cli/session.js.map +1 -1
- package/dist/cli/skills-root.d.ts +1 -1
- package/dist/cli/skills-root.d.ts.map +1 -1
- package/dist/cli/skills-root.js +1 -1
- package/dist/cli/skills-root.js.map +1 -1
- package/dist/execution/decode.d.ts.map +1 -1
- package/dist/execution/decode.js +11 -36
- package/dist/execution/decode.js.map +1 -1
- package/dist/execution/events.d.ts +4 -1
- package/dist/execution/events.d.ts.map +1 -1
- package/dist/execution/events.js.map +1 -1
- package/dist/execution/failure.d.ts +3 -1
- package/dist/execution/failure.d.ts.map +1 -1
- package/dist/execution/failure.js +14 -11
- package/dist/execution/failure.js.map +1 -1
- package/dist/execution/open-session.d.ts +1 -1
- package/dist/execution/open-session.d.ts.map +1 -1
- package/dist/execution/open-session.js +150 -223
- package/dist/execution/open-session.js.map +1 -1
- package/dist/execution/stream-turn.d.ts +9 -14
- package/dist/execution/stream-turn.d.ts.map +1 -1
- package/dist/execution/stream-turn.js +85 -188
- package/dist/execution/stream-turn.js.map +1 -1
- package/dist/execution/supervisor.d.ts +71 -0
- package/dist/execution/supervisor.d.ts.map +1 -0
- package/dist/execution/supervisor.js +127 -0
- package/dist/execution/supervisor.js.map +1 -0
- package/dist/interpretation/argv.d.ts +39 -12
- package/dist/interpretation/argv.d.ts.map +1 -1
- package/dist/interpretation/argv.js +28 -20
- package/dist/interpretation/argv.js.map +1 -1
- package/dist/interpretation/content.d.ts +10 -1
- package/dist/interpretation/content.d.ts.map +1 -1
- package/dist/interpretation/content.js +20 -11
- package/dist/interpretation/content.js.map +1 -1
- package/dist/interpretation/hints.d.ts +1 -1
- package/dist/interpretation/hints.d.ts.map +1 -1
- package/dist/interpretation/hints.js +10 -11
- package/dist/interpretation/hints.js.map +1 -1
- package/dist/interpretation/index.d.ts +0 -1
- package/dist/interpretation/index.d.ts.map +1 -1
- package/dist/interpretation/index.js +0 -1
- package/dist/interpretation/index.js.map +1 -1
- package/dist/interpretation/isolation.d.ts +10 -0
- package/dist/interpretation/isolation.d.ts.map +1 -0
- package/dist/interpretation/isolation.js +30 -0
- package/dist/interpretation/isolation.js.map +1 -0
- package/dist/interpretation/limits.d.ts +2 -5
- package/dist/interpretation/limits.d.ts.map +1 -1
- package/dist/interpretation/limits.js +8 -62
- package/dist/interpretation/limits.js.map +1 -1
- package/dist/interpretation/question.d.ts +27 -0
- package/dist/interpretation/question.d.ts.map +1 -1
- package/dist/interpretation/question.js +28 -0
- package/dist/interpretation/question.js.map +1 -1
- package/dist/interpretation/refusal.d.ts +10 -5
- package/dist/interpretation/refusal.d.ts.map +1 -1
- package/dist/interpretation/refusal.js +24 -15
- package/dist/interpretation/refusal.js.map +1 -1
- package/dist/interpretation/resolve-options.d.ts +36 -2
- package/dist/interpretation/resolve-options.d.ts.map +1 -1
- package/dist/interpretation/resolve-options.js +53 -22
- package/dist/interpretation/resolve-options.js.map +1 -1
- package/dist/interpretation/session-input.d.ts +44 -1
- package/dist/interpretation/session-input.d.ts.map +1 -1
- package/dist/interpretation/session-input.js +59 -4
- package/dist/interpretation/session-input.js.map +1 -1
- package/dist/interpretation/shape.d.ts +1 -0
- package/dist/interpretation/shape.d.ts.map +1 -1
- package/dist/interpretation/shape.js +10 -0
- package/dist/interpretation/shape.js.map +1 -1
- package/dist/interpretation/skills-selection.d.ts +25 -33
- package/dist/interpretation/skills-selection.d.ts.map +1 -1
- package/dist/interpretation/skills-selection.js +41 -48
- package/dist/interpretation/skills-selection.js.map +1 -1
- package/dist/interpretation/support.d.ts.map +1 -1
- package/dist/interpretation/support.js +25 -8
- package/dist/interpretation/support.js.map +1 -1
- package/dist/interpretation/tool-selection.d.ts +7 -6
- package/dist/interpretation/tool-selection.d.ts.map +1 -1
- package/dist/interpretation/tool-selection.js +54 -116
- package/dist/interpretation/tool-selection.js.map +1 -1
- package/dist/interpretation/tool-vocabulary.d.ts +31 -12
- package/dist/interpretation/tool-vocabulary.d.ts.map +1 -1
- package/dist/interpretation/tool-vocabulary.js +19 -41
- package/dist/interpretation/tool-vocabulary.js.map +1 -1
- package/dist/interpretation/turn-options.d.ts +4 -0
- package/dist/interpretation/turn-options.d.ts.map +1 -1
- package/dist/interpretation/turn-options.js +107 -241
- package/dist/interpretation/turn-options.js.map +1 -1
- package/dist/interpretation/vocabulary.d.ts +8 -6
- package/dist/interpretation/vocabulary.d.ts.map +1 -1
- package/dist/interpretation/vocabulary.js +22 -9
- package/dist/interpretation/vocabulary.js.map +1 -1
- package/dist/knowledge/claude-code.d.ts +3 -1
- package/dist/knowledge/claude-code.d.ts.map +1 -1
- package/dist/knowledge/claude-code.js +17 -4
- package/dist/knowledge/claude-code.js.map +1 -1
- package/dist/knowledge/codex.d.ts.map +1 -1
- package/dist/knowledge/codex.js +31 -7
- package/dist/knowledge/codex.js.map +1 -1
- package/dist/knowledge/descriptor.d.ts +67 -36
- package/dist/knowledge/descriptor.d.ts.map +1 -1
- package/dist/knowledge/descriptor.js +50 -15
- package/dist/knowledge/descriptor.js.map +1 -1
- package/dist/knowledge/matchers.d.ts +12 -0
- package/dist/knowledge/matchers.d.ts.map +1 -1
- package/dist/knowledge/matchers.js +34 -0
- package/dist/knowledge/matchers.js.map +1 -1
- package/dist/knowledge/muse.d.ts.map +1 -1
- package/dist/knowledge/muse.js +13 -6
- package/dist/knowledge/muse.js.map +1 -1
- package/dist/knowledge/overrides.d.ts.map +1 -1
- package/dist/knowledge/overrides.js +9 -20
- package/dist/knowledge/overrides.js.map +1 -1
- package/dist/knowledge/pi.d.ts.map +1 -1
- package/dist/knowledge/pi.js +8 -6
- package/dist/knowledge/pi.js.map +1 -1
- package/dist/knowledge/profile.d.ts +1 -0
- package/dist/knowledge/profile.d.ts.map +1 -1
- package/dist/knowledge/profile.js +1 -0
- package/dist/knowledge/profile.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/args.ts +39 -27
- package/src/cli/check.ts +10 -3
- package/src/cli/config.ts +14 -11
- package/src/cli/exit-codes.ts +0 -2
- package/src/cli/help.ts +10 -2
- package/src/cli/index.ts +3 -1
- package/src/cli/inspect.ts +88 -269
- package/src/cli/plan-turn.ts +350 -0
- package/src/cli/refuse.ts +2 -1
- package/src/cli/resolve-harness.ts +4 -5
- package/src/cli/run.ts +36 -399
- package/src/cli/session-json.ts +1 -6
- package/src/cli/session.ts +51 -44
- package/src/cli/skills-root.ts +1 -4
- package/src/execution/decode.ts +10 -36
- package/src/execution/events.ts +4 -1
- package/src/execution/failure.ts +18 -11
- package/src/execution/open-session.ts +154 -228
- package/src/execution/stream-turn.ts +90 -193
- package/src/execution/supervisor.ts +199 -0
- package/src/interpretation/argv.ts +65 -34
- package/src/interpretation/content.ts +30 -13
- package/src/interpretation/hints.ts +2 -12
- package/src/interpretation/index.ts +0 -1
- package/src/interpretation/isolation.ts +39 -0
- package/src/interpretation/limits.ts +14 -75
- package/src/interpretation/question.ts +46 -0
- package/src/interpretation/refusal.ts +28 -18
- package/src/interpretation/resolve-options.ts +98 -33
- package/src/interpretation/session-input.ts +88 -5
- package/src/interpretation/shape.ts +10 -0
- package/src/interpretation/skills-selection.ts +70 -74
- package/src/interpretation/support.ts +21 -6
- package/src/interpretation/tool-selection.ts +67 -122
- package/src/interpretation/tool-vocabulary.ts +48 -53
- package/src/interpretation/turn-options.ts +125 -220
- package/src/interpretation/vocabulary.ts +15 -10
- package/src/knowledge/claude-code.ts +17 -4
- package/src/knowledge/codex.ts +31 -7
- package/src/knowledge/descriptor.ts +106 -49
- package/src/knowledge/matchers.ts +35 -0
- package/src/knowledge/muse.ts +13 -6
- package/src/knowledge/overrides.ts +17 -32
- package/src/knowledge/pi.ts +8 -6
- package/src/knowledge/profile.ts +1 -0
- package/dist/interpretation/dimensions.d.ts +0 -11
- package/dist/interpretation/dimensions.d.ts.map +0 -1
- package/dist/interpretation/dimensions.js +0 -4
- package/dist/interpretation/dimensions.js.map +0 -1
- package/src/interpretation/dimensions.ts +0 -14
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ArgvRefusalError } from "./refusal.js";
|
|
2
|
+
/** Isolation owns these dimensions for the whole invocation. Config defaults
|
|
3
|
+
* yield to it; explicit competing selections refuse before registry reads. */
|
|
4
|
+
export const ISOLATION_OVERRIDES = [
|
|
5
|
+
"tools",
|
|
6
|
+
"excludeTools",
|
|
7
|
+
"skills",
|
|
8
|
+
"access",
|
|
9
|
+
"autonomy",
|
|
10
|
+
"discovery",
|
|
11
|
+
];
|
|
12
|
+
export const assertIsolationCombination = (h, opts) => {
|
|
13
|
+
if (opts.isolation === undefined)
|
|
14
|
+
return;
|
|
15
|
+
const conflict = ISOLATION_OVERRIDES.find((key) => key === "autonomy" ? opts[key] === true : opts[key] !== undefined) ??
|
|
16
|
+
(opts.skillNames !== undefined ? "skills" : undefined) ??
|
|
17
|
+
(opts.passthrough?.length ? "native passthrough" : undefined);
|
|
18
|
+
if (conflict === undefined)
|
|
19
|
+
return;
|
|
20
|
+
throw new ArgvRefusalError({
|
|
21
|
+
issue: "mutually-exclusive-options",
|
|
22
|
+
harness: h.name,
|
|
23
|
+
option: "isolation",
|
|
24
|
+
detail: conflict,
|
|
25
|
+
supported: [
|
|
26
|
+
"tool-free without explicit tools, skills, access, autonomy, discovery, or native passthrough",
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=isolation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolation.js","sourceRoot":"","sources":["../../src/interpretation/isolation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;8EAC8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,OAAO;IACP,cAAc;IACd,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,WAAW;CACH,CAAC;AACX,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,CAAoB,EACpB,IAGC,EACK,EAAE;IACR,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS;QAAE,OAAO;IACzC,MAAM,QAAQ,GACZ,mBAAmB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAC/B,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,CAClE;QACD,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAChE,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO;IACnC,MAAM,IAAI,gBAAgB,CAAC;QACzB,KAAK,EAAE,4BAA4B;QACnC,OAAO,EAAE,CAAC,CAAC,IAAI;QACf,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE;YACT,8FAA8F;SAC/F;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -19,13 +19,10 @@
|
|
|
19
19
|
import type { AuthFailureKind, AuthMatcher, HarnessDescriptor, LimitCode, LimitMatcher } from "../knowledge/descriptor.js";
|
|
20
20
|
export declare const compileLimitMatchers: (matchers: ReadonlyArray<LimitMatcher>) => ReadonlyArray<readonly [RegExp, LimitCode]>;
|
|
21
21
|
export declare const compileAuthMatchers: (matchers: ReadonlyArray<AuthMatcher>) => ReadonlyArray<readonly [RegExp, AuthFailureKind]>;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/** Per-line entry point for streaming readers: O(1) per line, no rescans.
|
|
23
|
+
* Both runners feed lines as they arrive; there is no batch form. */
|
|
24
24
|
export declare const detectLimitInLine: (h: HarnessDescriptor, line: string) => LimitCode | null;
|
|
25
|
-
/** Batch convenience over a turn's tail, bounded and bottom-up. */
|
|
26
|
-
export declare const detectLimit: (h: HarnessDescriptor, output: string) => LimitCode | null;
|
|
27
25
|
export declare const detectAuthFailureInLine: (h: HarnessDescriptor, line: string) => AuthFailureKind | null;
|
|
28
|
-
export declare const detectAuthFailure: (h: HarnessDescriptor, output: string) => AuthFailureKind | null;
|
|
29
26
|
/** A network or gateway fault between the harness and its provider. */
|
|
30
27
|
export declare const detectTransportInLine: (line: string) => boolean;
|
|
31
28
|
/** A provider that answered but cannot serve the requested model. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/interpretation/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,YAAY,EAEb,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/interpretation/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,YAAY,EAEb,MAAM,4BAA4B,CAAC;AAsBpC,eAAO,MAAM,oBAAoB,aACrB,aAAa,CAAC,YAAY,CAAC,KACpC,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,CAS5C,CAAC;AAEF,eAAO,MAAM,mBAAmB,aACpB,aAAa,CAAC,WAAW,CAAC,KACnC,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,CASlD,CAAC;AAcF;qEACqE;AACrE,eAAO,MAAM,iBAAiB,MAAO,iBAAiB,QAAQ,MAAM,KAAG,SAAS,GAAG,IACrB,CAAC;AAE/D,eAAO,MAAM,uBAAuB,MAC/B,iBAAiB,QACd,MAAM,KACX,eAAe,GAAG,IAAkE,CAAC;AAoBxF,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,SAAU,MAAM,KAAG,OACA,CAAC;AAEtD,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,SAAU,MAAM,KAAG,OACA,CAAC"}
|
|
@@ -16,39 +16,13 @@
|
|
|
16
16
|
* pattern analysis, is the backtracking bound - a malicious pattern could
|
|
17
17
|
* otherwise catastrophically backtrack on a long line.
|
|
18
18
|
*/
|
|
19
|
-
import { SHARED_TRANSPORT_MATCHERS, SHARED_UNAVAILABLE_MATCHERS } from "../knowledge/matchers.js";
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* scan over an accumulating session buffer is O(turns x output). */
|
|
23
|
-
const BATCH_SCAN_MAX_LINES = 200;
|
|
24
|
-
/** Max pattern length and max matchers per harness per kind - load-bearing
|
|
25
|
-
* bounds that prevent a crafted override file from DoS'ing the matcher
|
|
26
|
-
* compiler or the scanner. */
|
|
27
|
-
const MAX_PATTERN_LENGTH = 200;
|
|
28
|
-
const MAX_MATCHERS_PER_KIND = 64;
|
|
19
|
+
import { compileMatcher, MAX_MATCHERS_PER_KIND, SHARED_TRANSPORT_MATCHERS, SHARED_UNAVAILABLE_MATCHERS, } from "../knowledge/matchers.js";
|
|
20
|
+
/** The pattern bounds live with the matchers in the knowledge layer
|
|
21
|
+
* (compileMatcher); this is the per-line input window. */
|
|
29
22
|
const WINDOW = 4096;
|
|
30
23
|
// WeakMap cache: same matcher array instance reuses identical RegExp objects
|
|
31
24
|
const limitCache = new WeakMap();
|
|
32
25
|
const authCache = new WeakMap();
|
|
33
|
-
const validateAndCompile = (pattern, flags) => {
|
|
34
|
-
const f = flags ?? "i";
|
|
35
|
-
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
36
|
-
throw new Error(`pattern over ${MAX_PATTERN_LENGTH} characters`);
|
|
37
|
-
}
|
|
38
|
-
if (f.includes("g") || f.includes("y")) {
|
|
39
|
-
throw new Error(`flags must not contain g or y (got ${JSON.stringify(f)})`);
|
|
40
|
-
}
|
|
41
|
-
for (const ch of f) {
|
|
42
|
-
if (!"imsu".includes(ch))
|
|
43
|
-
throw new Error(`flag ${JSON.stringify(ch)} outside imsu`);
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
return new RegExp(pattern, f);
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
throw new Error(`uncompilable pattern ${JSON.stringify(pattern)}: ${e.message}`);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
26
|
export const compileLimitMatchers = (matchers) => {
|
|
53
27
|
const cached = limitCache.get(matchers);
|
|
54
28
|
if (cached !== undefined)
|
|
@@ -56,7 +30,7 @@ export const compileLimitMatchers = (matchers) => {
|
|
|
56
30
|
if (matchers.length > MAX_MATCHERS_PER_KIND) {
|
|
57
31
|
throw new Error(`more than ${MAX_MATCHERS_PER_KIND} matchers per harness per kind`);
|
|
58
32
|
}
|
|
59
|
-
const compiled = matchers.map((m) => [
|
|
33
|
+
const compiled = matchers.map((m) => [compileMatcher(m.pattern, m.flags), m.code]);
|
|
60
34
|
limitCache.set(matchers, compiled);
|
|
61
35
|
return compiled;
|
|
62
36
|
};
|
|
@@ -67,20 +41,10 @@ export const compileAuthMatchers = (matchers) => {
|
|
|
67
41
|
if (matchers.length > MAX_MATCHERS_PER_KIND) {
|
|
68
42
|
throw new Error(`more than ${MAX_MATCHERS_PER_KIND} matchers per harness per kind`);
|
|
69
43
|
}
|
|
70
|
-
const compiled = matchers.map((m) => [
|
|
44
|
+
const compiled = matchers.map((m) => [compileMatcher(m.pattern, m.flags), m.kind]);
|
|
71
45
|
authCache.set(matchers, compiled);
|
|
72
46
|
return compiled;
|
|
73
47
|
};
|
|
74
|
-
// Generic alias for tests that call compileMatchers directly
|
|
75
|
-
export const compileMatchers = (matchers) => {
|
|
76
|
-
// Dispatch based on first element's shape - limit has code, auth has kind
|
|
77
|
-
if (matchers.length === 0)
|
|
78
|
-
return [];
|
|
79
|
-
const first = matchers[0];
|
|
80
|
-
if ("code" in first)
|
|
81
|
-
return compileLimitMatchers(matchers);
|
|
82
|
-
return compileAuthMatchers(matchers);
|
|
83
|
-
};
|
|
84
48
|
const scanLine = (line, matchers) => {
|
|
85
49
|
const windowed = line.slice(0, WINDOW);
|
|
86
50
|
for (let i = 0; i < matchers.length; i++) {
|
|
@@ -90,28 +54,10 @@ const scanLine = (line, matchers) => {
|
|
|
90
54
|
}
|
|
91
55
|
return null;
|
|
92
56
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
let scanned = 0;
|
|
96
|
-
while (end > 0 && scanned < BATCH_SCAN_MAX_LINES) {
|
|
97
|
-
const start = output.lastIndexOf("\n", end - 1);
|
|
98
|
-
const line = output.slice(start + 1, end).trim();
|
|
99
|
-
end = start;
|
|
100
|
-
if (line === "")
|
|
101
|
-
continue;
|
|
102
|
-
scanned++;
|
|
103
|
-
const code = scanLine(line, matchers);
|
|
104
|
-
if (code !== null)
|
|
105
|
-
return code;
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
};
|
|
109
|
-
/** Per-line entry point for streaming readers: O(1) per line, no rescans. */
|
|
57
|
+
/** Per-line entry point for streaming readers: O(1) per line, no rescans.
|
|
58
|
+
* Both runners feed lines as they arrive; there is no batch form. */
|
|
110
59
|
export const detectLimitInLine = (h, line) => scanLine(line.trim(), compileLimitMatchers(h.limitMatchers));
|
|
111
|
-
/** Batch convenience over a turn's tail, bounded and bottom-up. */
|
|
112
|
-
export const detectLimit = (h, output) => scanTail(output, compileLimitMatchers(h.limitMatchers));
|
|
113
60
|
export const detectAuthFailureInLine = (h, line) => scanLine(line.trim(), compileAuthMatchers(h.authMatchers));
|
|
114
|
-
export const detectAuthFailure = (h, output) => scanTail(output, compileAuthMatchers(h.authMatchers));
|
|
115
61
|
const phraseCache = new WeakMap();
|
|
116
62
|
const compilePhraseMatchers = (matchers) => {
|
|
117
63
|
const cached = phraseCache.get(matchers);
|
|
@@ -120,7 +66,7 @@ const compilePhraseMatchers = (matchers) => {
|
|
|
120
66
|
if (matchers.length > MAX_MATCHERS_PER_KIND) {
|
|
121
67
|
throw new Error(`more than ${MAX_MATCHERS_PER_KIND} matchers per harness per kind`);
|
|
122
68
|
}
|
|
123
|
-
const compiled = matchers.map((m) =>
|
|
69
|
+
const compiled = matchers.map((m) => compileMatcher(m.pattern, m.flags));
|
|
124
70
|
phraseCache.set(matchers, compiled);
|
|
125
71
|
return compiled;
|
|
126
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/interpretation/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAUH,OAAO,
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/interpretation/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAUH,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAElC;0DAC0D;AAC1D,MAAM,MAAM,GAAG,IAAI,CAAC;AAEpB,6EAA6E;AAC7E,MAAM,UAAU,GAAG,IAAI,OAAO,EAG3B,CAAC;AACJ,MAAM,SAAS,GAAG,IAAI,OAAO,EAG1B,CAAC;AAEJ,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,QAAqC,EACQ,EAAE;IAC/C,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,IAAI,QAAQ,CAAC,MAAM,GAAG,qBAAqB,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,aAAa,qBAAqB,gCAAgC,CAAC,CAAC;IACtF,CAAC;IACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC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AAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzE,CAAC,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAW,EAAE,CAC7D,kBAAkB,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;AAEtD,qEAAqE;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAW,EAAE,CAC/D,kBAAkB,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC"}
|
|
@@ -25,6 +25,10 @@ export declare const NO_ESCALATION_PREAMBLE = "[hcn question protocol]\nYou are
|
|
|
25
25
|
* stays open, and the answer arrives as the next user message on the
|
|
26
26
|
* same session. No exit, no resume. */
|
|
27
27
|
export declare const SESSION_ESCALATION_PREAMBLE = "[hcn question protocol]\nYou are running in a persistent session: no one is watching live, but the caller relays answers back into this same session. This protocol never changes your permissions - asking is not how you obtain permission, and it never removes any permission this run already has. Use the tools you have exactly as granted.\nIf and only if a genuine decision you cannot make defensibly blocks correct progress, ask by stopping: emit one fenced code block tagged hcn-question, as the last content of your reply, containing a single JSON object:\n\n```hcn-question\n{\"question\": \"<the decision you need made>\", \"options\": [\"<option 1>\", \"<option 2>\"], \"recommended\": \"<one of options>\"}\n```\n\nSay nothing after the block and stop generating. The caller's user will answer, and the answer arrives as the next user message in this session - continue from it. For every choice you can make defensibly yourself, do not ask - decide, act, and state the decision you made.";
|
|
28
|
+
/** The wrapper hcn composes around the user's answer to an escalated
|
|
29
|
+
* question, so a consumer never re-derives it (RFC-01; the README quotes
|
|
30
|
+
* the exact text). One owner for both session surfaces. */
|
|
31
|
+
export declare const composeAnswer: (question: string, answer: string) => string;
|
|
28
32
|
export type QuestionMode = "ask" | "assume" | "none";
|
|
29
33
|
export declare const QUESTION_MODES: readonly QuestionMode[];
|
|
30
34
|
export declare const isQuestionMode: (value: string) => value is QuestionMode;
|
|
@@ -50,6 +54,29 @@ export type QuestionDetection = {
|
|
|
50
54
|
} | {
|
|
51
55
|
readonly malformed: string;
|
|
52
56
|
};
|
|
57
|
+
/** What a turn's close found, recorded on `done` (RFC-01). */
|
|
58
|
+
export type QuestionDetectionKind = "block" | "malformed" | "none";
|
|
59
|
+
/** The typed question event a detected block becomes: the fields ARE the
|
|
60
|
+
* question; prose renders from them downstream. */
|
|
61
|
+
export interface QuestionEvent {
|
|
62
|
+
readonly kind: "question";
|
|
63
|
+
readonly question: string;
|
|
64
|
+
readonly options: readonly string[];
|
|
65
|
+
readonly recommended?: string;
|
|
66
|
+
}
|
|
67
|
+
/** The one place a detected block becomes a question event (RFC-02
|
|
68
|
+
* change 5). Both runners call it at turn close with the last assistant
|
|
69
|
+
* message: detection is armed only in `ask` mode; a malformed block names
|
|
70
|
+
* its malformation and is never a silent no-op. */
|
|
71
|
+
export declare const questionEventOf: (lastAssistantText: string | null, mode: QuestionMode) => {
|
|
72
|
+
readonly detection: "none";
|
|
73
|
+
} | {
|
|
74
|
+
readonly detection: "malformed";
|
|
75
|
+
readonly malformed: string;
|
|
76
|
+
} | {
|
|
77
|
+
readonly detection: "block";
|
|
78
|
+
readonly event: QuestionEvent;
|
|
79
|
+
};
|
|
53
80
|
/** Detect the hcn-question block in a message text. The LAST block wins
|
|
54
81
|
* (the protocol makes the block the turn's final content; a corrected
|
|
55
82
|
* re-emit supersedes an earlier one). An empty candidate body (a bare
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../src/interpretation/question.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;iCACiC;AACjC,eAAO,MAAM,wBAAwB,4BAA4B,CAAC;AAElE,eAAO,MAAM,mBAAmB,m8BAQ+M,CAAC;AAEhP,eAAO,MAAM,sBAAsB,6VAC6R,CAAC;AAEjU;;;uCAGuC;AACvC,eAAO,MAAM,2BAA2B,w+BAQ0O,CAAC;AAEnR,MAAM,M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;;gEAGgE;AAChE,eAAO,MAAM,mBAAmB,SAAU,MAAM,KAAG,iBAAiB,GAAG,IAStE,CAAC"}
|
|
@@ -42,6 +42,10 @@ If and only if a genuine decision you cannot make defensibly blocks correct prog
|
|
|
42
42
|
\`\`\`
|
|
43
43
|
|
|
44
44
|
Say nothing after the block and stop generating. The caller's user will answer, and the answer arrives as the next user message in this session - continue from it. For every choice you can make defensibly yourself, do not ask - decide, act, and state the decision you made.`;
|
|
45
|
+
/** The wrapper hcn composes around the user's answer to an escalated
|
|
46
|
+
* question, so a consumer never re-derives it (RFC-01; the README quotes
|
|
47
|
+
* the exact text). One owner for both session surfaces. */
|
|
48
|
+
export const composeAnswer = (question, answer) => `The user answered the question: "${question}" with: ${answer}. Continue accordingly.`;
|
|
45
49
|
export const QUESTION_MODES = ["ask", "assume", "none"];
|
|
46
50
|
export const isQuestionMode = (value) => QUESTION_MODES.includes(value);
|
|
47
51
|
/** Compose the transport preamble onto a prompt. `mode` selects which
|
|
@@ -116,6 +120,30 @@ const parseBlock = (body) => {
|
|
|
116
120
|
},
|
|
117
121
|
};
|
|
118
122
|
};
|
|
123
|
+
/** The one place a detected block becomes a question event (RFC-02
|
|
124
|
+
* change 5). Both runners call it at turn close with the last assistant
|
|
125
|
+
* message: detection is armed only in `ask` mode; a malformed block names
|
|
126
|
+
* its malformation and is never a silent no-op. */
|
|
127
|
+
export const questionEventOf = (lastAssistantText, mode) => {
|
|
128
|
+
if (mode !== "ask" || lastAssistantText === null)
|
|
129
|
+
return { detection: "none" };
|
|
130
|
+
const detected = detectQuestionBlock(lastAssistantText);
|
|
131
|
+
if (detected === null)
|
|
132
|
+
return { detection: "none" };
|
|
133
|
+
if ("malformed" in detected)
|
|
134
|
+
return { detection: "malformed", malformed: detected.malformed };
|
|
135
|
+
return {
|
|
136
|
+
detection: "block",
|
|
137
|
+
event: {
|
|
138
|
+
kind: "question",
|
|
139
|
+
question: detected.block.question,
|
|
140
|
+
options: detected.block.options,
|
|
141
|
+
...(detected.block.recommended !== undefined
|
|
142
|
+
? { recommended: detected.block.recommended }
|
|
143
|
+
: {}),
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
};
|
|
119
147
|
/** Detect the hcn-question block in a message text. The LAST block wins
|
|
120
148
|
* (the protocol makes the block the turn's final content; a corrected
|
|
121
149
|
* re-emit supersedes an earlier one). An empty candidate body (a bare
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"question.js","sourceRoot":"","sources":["../../src/interpretation/question.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;iCACiC;AACjC,MAAM,CAAC,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAElE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,wBAAwB;;;;;;;;+OAQiL,CAAC;AAEhP,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,wBAAwB;gUAC+P,CAAC;AAEjU;;;uCAGuC;AACvC,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,wBAAwB;;;;;;;;kRAQ4M,CAAC;
|
|
1
|
+
{"version":3,"file":"question.js","sourceRoot":"","sources":["../../src/interpretation/question.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;iCACiC;AACjC,MAAM,CAAC,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAElE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,wBAAwB;;;;;;;;+OAQiL,CAAC;AAEhP,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,wBAAwB;gUAC+P,CAAC;AAEjU;;;uCAGuC;AACvC,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,wBAAwB;;;;;;;;kRAQ4M,CAAC;AAEnR;;2DAE2D;AAC3D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAE,MAAc,EAAU,EAAE,CACxE,oCAAoC,QAAQ,WAAW,MAAM,yBAAyB,CAAC;AAIzF,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YAC/B,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS;gBAC1C,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE;gBAC7C,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC;AACJ,CAAC,CAAC;AAEF;;;gEAGgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAA4B,EAAE;IAC5E,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAChD,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,SAAS,KAAK,SAAS;YAAE,SAAS;QACtC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,SAAS;QAC3C,OAAO,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -11,15 +11,20 @@ export type RefusalIssue = (typeof REFUSAL_ISSUES)[number];
|
|
|
11
11
|
* plus the tool-list dimensions and autonomy, which render via dedicated
|
|
12
12
|
* descriptor fields rather than a spec table. Kept closed so consumers can
|
|
13
13
|
* branch on it without a default arm. */
|
|
14
|
-
export type RefusalOption = TurnOptionKey | "tools" | "excludeTools" | "skills" | "autonomy" | "questions" | `discovery.${string}`;
|
|
14
|
+
export type RefusalOption = TurnOptionKey | "tools" | "excludeTools" | "skills" | "autonomy" | "questions" | "timeout" | `discovery.${string}`;
|
|
15
15
|
/** One helper builds the message from the structured fields so message and
|
|
16
16
|
* fields cannot drift. Every message names an alternative, not only a
|
|
17
|
-
* negation, so an agent can pivot without reading the descriptor.
|
|
18
|
-
|
|
17
|
+
* negation, so an agent can pivot without reading the descriptor. A
|
|
18
|
+
* refusal raised before a harness is chosen (argument parsing, config)
|
|
19
|
+
* passes no harness, and the message carries no harness fragment (RFC-02
|
|
20
|
+
* change 11) instead of naming one the caller never picked. */
|
|
21
|
+
export declare const buildRefusalMessage: (issue: RefusalIssue, harness: HarnessName | undefined, option?: RefusalOption, facet?: DiscoveryFacet, supported?: readonly string[], detail?: string) => string;
|
|
19
22
|
/** Raised when launch options would corrupt or subvert the spawned argv. */
|
|
20
23
|
export declare class ArgvRefusalError extends Error {
|
|
21
24
|
readonly issue: RefusalIssue;
|
|
22
|
-
|
|
25
|
+
/** The harness the refusal is about; absent when it was raised before
|
|
26
|
+
* one was chosen (argument parsing, config loading). */
|
|
27
|
+
readonly harness?: HarnessName;
|
|
23
28
|
readonly option?: RefusalOption;
|
|
24
29
|
readonly facet?: DiscoveryFacet;
|
|
25
30
|
readonly supported: readonly string[];
|
|
@@ -36,7 +41,7 @@ export declare class ArgvRefusalError extends Error {
|
|
|
36
41
|
readonly hint?: string;
|
|
37
42
|
constructor(args: {
|
|
38
43
|
readonly issue: RefusalIssue;
|
|
39
|
-
readonly harness
|
|
44
|
+
readonly harness?: HarnessName;
|
|
40
45
|
readonly option?: RefusalOption;
|
|
41
46
|
readonly facet?: DiscoveryFacet;
|
|
42
47
|
readonly supported?: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../../src/interpretation/refusal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG7F,eAAO,MAAM,cAAc,ySAchB,CAAC;AACZ,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;yCAGyC;AACzC,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,OAAO,GACP,cAAc,GACd,QAAQ,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KAAK,EAAE,YAAY,CAAC;QAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;QAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;QAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;QAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;KAC3B,EAoBA;CACF"}
|
|
@@ -22,7 +22,10 @@ export const REFUSAL_ISSUES = deepFreeze([
|
|
|
22
22
|
]);
|
|
23
23
|
/** One helper builds the message from the structured fields so message and
|
|
24
24
|
* fields cannot drift. Every message names an alternative, not only a
|
|
25
|
-
* negation, so an agent can pivot without reading the descriptor.
|
|
25
|
+
* negation, so an agent can pivot without reading the descriptor. A
|
|
26
|
+
* refusal raised before a harness is chosen (argument parsing, config)
|
|
27
|
+
* passes no harness, and the message carries no harness fragment (RFC-02
|
|
28
|
+
* change 11) instead of naming one the caller never picked. */
|
|
26
29
|
export const buildRefusalMessage = (issue, harness, option, facet, supported = [], detail) => {
|
|
27
30
|
const supportedStr = supported.length > 0 ? `supported: ${supported.join(", ")}` : "supported: (none)";
|
|
28
31
|
const facetSuffix = facet ? ` facet ${JSON.stringify(facet)}` : "";
|
|
@@ -32,48 +35,54 @@ export const buildRefusalMessage = (issue, harness, option, facet, supported = [
|
|
|
32
35
|
? ` facet ${JSON.stringify(facet)}`
|
|
33
36
|
: "";
|
|
34
37
|
const detailSuffix = detail ? ` (${detail})` : "";
|
|
38
|
+
// The harness fragments: present only when a harness was chosen.
|
|
39
|
+
const who = harness ?? "the harness";
|
|
40
|
+
const onHarness = harness === undefined ? "" : ` on ${harness}`;
|
|
41
|
+
const forHarness = harness === undefined ? "" : ` for ${harness}`;
|
|
35
42
|
switch (issue) {
|
|
36
43
|
case "unsupported-option":
|
|
37
|
-
return `${
|
|
44
|
+
return `${who} cannot express${optionPart}${detailSuffix}; ${supportedStr} - drop the option or route this work to a harness that supports it`;
|
|
38
45
|
case "unsupported-option-facet":
|
|
39
|
-
return `${
|
|
46
|
+
return `${who} cannot express discovery${facetSuffix}${detailSuffix}; ${supportedStr} - drop the facet or route this work to a harness that supports it`;
|
|
40
47
|
case "unsupported-on-resume": {
|
|
41
48
|
const name = option
|
|
42
49
|
? JSON.stringify(option) + (facet ? `:${facet}` : "")
|
|
43
50
|
: facet
|
|
44
51
|
? JSON.stringify(facet)
|
|
45
52
|
: "option";
|
|
46
|
-
return `${name} cannot be expressed on resume
|
|
53
|
+
return `${name} cannot be expressed on resume${forHarness}${detailSuffix}; ${supportedStr} - re-launch instead of resuming or drop the option`;
|
|
47
54
|
}
|
|
48
55
|
case "invalid-option-value":
|
|
49
|
-
return `invalid value for${optionPart}
|
|
56
|
+
return `invalid value for${optionPart}${onHarness}${detailSuffix}; ${supportedStr} - use a supported value instead`;
|
|
50
57
|
case "unknown-effort":
|
|
51
|
-
return `unknown effort
|
|
58
|
+
return `unknown effort${forHarness}${detail ? ` ${JSON.stringify(detail)}` : ""}; ${supportedStr} - use one of the ladder values`;
|
|
52
59
|
case "unknown-model":
|
|
53
|
-
return `unknown ${harness} model${detail ? ` ${JSON.stringify(detail)}` : ""}; ${supportedStr} - use one of the supported models`;
|
|
60
|
+
return `unknown ${harness === undefined ? "" : `${harness} `}model${detail ? ` ${JSON.stringify(detail)}` : ""}; ${supportedStr} - use one of the supported models`;
|
|
54
61
|
case "invalid-env":
|
|
55
|
-
return `invalid env key or value
|
|
62
|
+
return `invalid env key or value${forHarness}${detailSuffix}; ${supportedStr} - keys must match ^[A-Za-z_][A-Za-z0-9_]*$ and contain no NUL`;
|
|
56
63
|
case "invalid-tool-grant":
|
|
57
|
-
return `tool grant
|
|
64
|
+
return `tool grant${forHarness} contains an empty entry or a comma; a blank tool flag value grants nothing detectable, and a comma inside one name silently splits the grant; ${supportedStr} - provide comma-free, non-empty tool names as separate entries`;
|
|
58
65
|
case "unknown-tool-name":
|
|
59
|
-
return `${
|
|
66
|
+
return `${who} cannot compute a tool complement around an unknown name${detailSuffix}; ${supportedStr} - exclude only curated names, or pass the unknown name through an include list instead`;
|
|
60
67
|
case "mutually-exclusive-options":
|
|
61
|
-
return `${harness} cannot combine${optionPart}${detailSuffix}; ${supportedStr} - pass exactly one of them`;
|
|
68
|
+
return `${harness === undefined ? "cannot combine" : `${harness} cannot combine`}${optionPart}${detailSuffix}; ${supportedStr} - pass exactly one of them`;
|
|
62
69
|
case "prompt-flag-injection":
|
|
63
|
-
return `positional prompt may not start with '-'; it would be parsed as a flag by ${
|
|
70
|
+
return `positional prompt may not start with '-'; it would be parsed as a flag by ${who}${detailSuffix}; ${supportedStr} - remove leading '-' or prefix with a space`;
|
|
64
71
|
case "no-autonomy-mode":
|
|
65
|
-
return `${
|
|
72
|
+
return `${who} has no unattended-run flag; ${supportedStr} - drop autonomy or route to a supporting harness (claude --dangerously-skip-permissions, codex/muse --yolo)`;
|
|
66
73
|
case "no-session-mode":
|
|
67
|
-
return `${
|
|
74
|
+
return `${who} declares no persistent headless session mode; ${supportedStr} - use hcn run --resume <id>`;
|
|
68
75
|
default: {
|
|
69
76
|
const exhaustive = issue;
|
|
70
|
-
return `${exhaustive}
|
|
77
|
+
return `${exhaustive}${forHarness}${optionPart}${detailSuffix}; ${supportedStr}`;
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
};
|
|
74
81
|
/** Raised when launch options would corrupt or subvert the spawned argv. */
|
|
75
82
|
export class ArgvRefusalError extends Error {
|
|
76
83
|
issue;
|
|
84
|
+
/** The harness the refusal is about; absent when it was raised before
|
|
85
|
+
* one was chosen (argument parsing, config loading). */
|
|
77
86
|
harness;
|
|
78
87
|
option;
|
|
79
88
|
facet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.js","sourceRoot":"","sources":["../../src/interpretation/refusal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;IACvC,oBAAoB;IACpB,0BAA0B;IAC1B,uBAAuB;IACvB,sBAAsB;IACtB,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,oBAAoB;IACpB,mBAAmB;IACnB,4BAA4B;IAC5B,uBAAuB;IACvB,kBAAkB;IAClB,iBAAiB;CACT,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"refusal.js","sourceRoot":"","sources":["../../src/interpretation/refusal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;IACvC,oBAAoB;IACpB,0BAA0B;IAC1B,uBAAuB;IACvB,sBAAsB;IACtB,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,oBAAoB;IACpB,mBAAmB;IACnB,4BAA4B;IAC5B,uBAAuB;IACvB,kBAAkB;IAClB,iBAAiB;CACT,CAAC,CAAC;AAiBZ;;;;;+DAK+D;AAC/D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,KAAmB,EACnB,OAAgC,EAChC,MAAsB,EACtB,KAAsB,EACtB,SAAS,GAAsB,EAAE,EACjC,MAAe,EACP,EAAE;IACV,MAAM,YAAY,GAChB,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC;IACpF,MAAM,WAAW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9
|
*/
|
|
10
10
|
import type { HarnessDescriptor } from "../knowledge/descriptor.js";
|
|
11
11
|
import type { TurnOptions } from "./argv.js";
|
|
12
|
+
import type { QuestionMode } from "./question.js";
|
|
13
|
+
import type { ToolMapConfig } from "./tool-vocabulary.js";
|
|
12
14
|
export type ProvenanceTier = "arg" | "project-config" | "user-config" | "profile" | "harness";
|
|
13
15
|
export interface ProvenanceEntry {
|
|
14
16
|
readonly key: string;
|
|
@@ -30,13 +32,45 @@ export interface ResolvedOptions {
|
|
|
30
32
|
* never refuse): rendered as divergence, not failure. */
|
|
31
33
|
readonly unrenderable: readonly string[];
|
|
32
34
|
}
|
|
35
|
+
/** What one parsed config file carries: the turn options it may set, plus
|
|
36
|
+
* the keys that are not turn options - named toolsets, the raw toolMap
|
|
37
|
+
* (harness -> canonical -> native, merged into the one ToolMap shape
|
|
38
|
+
* here), and the wall-clock timeout. */
|
|
39
|
+
export type ConfigTier = Readonly<Omit<Partial<TurnOptions>, "toolMap">> & {
|
|
40
|
+
readonly toolMap?: ToolMapConfig;
|
|
41
|
+
readonly toolsets?: Readonly<Record<string, readonly string[]>>;
|
|
42
|
+
readonly timeout?: number;
|
|
43
|
+
};
|
|
33
44
|
export interface ConfigTiers {
|
|
34
45
|
/** ~/.config/hcn/config.json (XDG) - machine-wide defaults. */
|
|
35
|
-
readonly user?:
|
|
46
|
+
readonly user?: ConfigTier;
|
|
36
47
|
/** <git-root>/.hcn/config.json - auto-discovered (ratified A), the ALL-
|
|
37
48
|
* OFF tier; its `tools` key is both the default grant and the FLOOR: an
|
|
38
49
|
* arg grant exceeding it refuses, naming both sets (D5). */
|
|
39
|
-
readonly project?:
|
|
50
|
+
readonly project?: ConfigTier;
|
|
40
51
|
}
|
|
52
|
+
/** Where a resolved behaviour value came from; `default` is hcn's own. */
|
|
53
|
+
export type BehaviorTier = "arg" | "project-config" | "user-config" | "default";
|
|
54
|
+
/** The hcn-owned behaviour instructions a run resolves on every path,
|
|
55
|
+
* launch, resume, and session alike (RFC-02 change 6): question mode,
|
|
56
|
+
* which rides the prompt rather than the argv, and the wall-clock
|
|
57
|
+
* timeout hcn enforces itself. Neither is a turn option, so the
|
|
58
|
+
* launch-only turn-option resolver never sees them. */
|
|
59
|
+
export interface ResolvedBehavior {
|
|
60
|
+
readonly questions: {
|
|
61
|
+
readonly value: QuestionMode;
|
|
62
|
+
readonly tier: BehaviorTier;
|
|
63
|
+
};
|
|
64
|
+
readonly timeoutSeconds: {
|
|
65
|
+
readonly value: number | undefined;
|
|
66
|
+
readonly tier: BehaviorTier;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Precedence arg > project > user > default, with the tier the
|
|
70
|
+
* provenance line prints. Timeout 0 is an explicit disable. */
|
|
71
|
+
export declare const resolveBehavior: (args: {
|
|
72
|
+
readonly questions?: QuestionMode;
|
|
73
|
+
readonly timeoutSeconds?: number;
|
|
74
|
+
}, tiers: ConfigTiers) => ResolvedBehavior;
|
|
41
75
|
export declare const resolveEffectiveOptions: (h: HarnessDescriptor, args: TurnOptions, tiers?: ConfigTiers) => ResolvedOptions;
|
|
42
76
|
//# sourceMappingURL=resolve-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-options.d.ts","sourceRoot":"","sources":["../../src/interpretation/resolve-options.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-options.d.ts","sourceRoot":"","sources":["../../src/interpretation/resolve-options.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,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