@qvac/harness 1.0.0-rc.13 → 1.0.0-rc.15
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 +90 -0
- package/README.md +36 -6
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.js +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +20 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +10 -6
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +8 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +6 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +10 -4
- package/dist-lib/lib/capabilities/completion-engine/driver.js +15 -0
- package/dist-lib/lib/capabilities/completion-engine/loop.js +2 -1
- package/dist-lib/lib/capabilities/completion-engine/operations.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/ports.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/round.js +16 -7
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +3 -3
- package/dist-lib/lib/capabilities/prompt-prefix.d.ts +2 -0
- package/dist-lib/lib/capabilities/prompt-prefix.js +8 -0
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +1 -1
- package/dist-lib/lib/capabilities/sdk-tool.js +17 -2
- package/dist-lib/lib/capabilities/usage-breakdown.d.ts +1 -0
- package/dist-lib/lib/capabilities/usage-breakdown.js +4 -1
- package/dist-lib/lib/contract/completion.d.ts +3 -0
- package/dist-lib/lib/contract/run.d.ts +2 -0
- package/dist-lib/lib/helpers/goal-check.d.ts +26 -0
- package/dist-lib/lib/helpers/goal-check.js +248 -22
- package/dist-lib/lib/helpers/spawn-path.d.ts +1 -0
- package/dist-lib/lib/helpers/spawn-path.js +2 -1
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +3 -2
- package/dist-lib/lib/machine/completion/actions/completion.js +65 -15
- package/dist-lib/lib/machine/completion/actions/tools.js +47 -6
- package/dist-lib/lib/machine/completion/context.js +5 -1
- package/dist-lib/lib/machine/completion/implementations.d.ts +1 -0
- package/dist-lib/lib/machine/completion/implementations.js +7 -0
- package/dist-lib/lib/machine/completion/machine.d.ts +4 -1
- package/dist-lib/lib/machine/completion/machine.js +10 -1
- package/dist-lib/lib/machine/completion/rules.d.ts +3 -1
- package/dist-lib/lib/machine/completion/rules.js +25 -4
- package/dist-lib/lib/machine/completion/types.d.ts +16 -0
- package/dist-lib/lib/machine/index.d.ts +6 -1
- package/dist-lib/lib/machine/index.js +2 -0
- package/dist-lib/lib/models/model-pool.js +1 -2
- package/dist-lib/lib/office/engine/pptx/presentation.js +10 -5
- package/dist-lib/lib/sidecar/index.js +1 -1
- package/dist-lib/lib/skills-host/index.d.ts +1 -1
- package/dist-lib/lib/skills-host/index.js +3 -2
- package/dist-lib/lib/tools/exec/runner.d.ts +4 -0
- package/dist-lib/lib/tools/exec/runner.js +20 -3
- package/dist-lib/lib/tools/office.js +1 -0
- package/dist-lib/lib/tools/skills/overlay-watch.d.ts +2 -2
- package/dist-lib/lib/tools/skills/overlay-watch.js +4 -3
- package/dist-lib/lib/wire.js +9 -3
- package/dist-lib/plugins/image/index.js +5 -5
- package/dist-lib/plugins/knowledge/index.d.ts +3 -0
- package/dist-lib/plugins/knowledge/index.js +4 -0
- package/dist-lib/plugins/knowledge/manifest.d.ts +28 -4
- package/dist-lib/plugins/knowledge/manifest.js +49 -4
- package/dist-lib/plugins/knowledge/store.d.ts +10 -1
- package/dist-lib/plugins/knowledge/store.js +127 -57
- package/dist-lib/plugins/music/index.js +4 -4
- package/dist-lib/plugins/obsidian/index.js +14 -4
- package/dist-lib/plugins/python/index.d.ts +3 -1
- package/dist-lib/plugins/python/index.js +4 -1
- package/dist-lib/plugins/python/python-adapter.d.ts +2 -1
- package/dist-lib/plugins/python/python-adapter.js +8 -1
- package/dist-lib/plugins/sandbox-linux/index.js +2 -2
- package/dist-lib/plugins/sandbox-macos/index.js +2 -2
- package/dist-lib/plugins/sandbox-vm/index.d.ts +2 -1
- package/dist-lib/plugins/sandbox-vm/index.js +2 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +3 -1
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +45 -16
- package/dist-lib/plugins/sandbox-windows/index.js +2 -2
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/package.json +27 -22
- package/scripts/addon-externals.cjs +4 -1
- package/patches/localwatch@1.4.3.patch +0 -13
|
@@ -13,9 +13,12 @@ export function promptUsageParts({ system, toolSchemas }) {
|
|
|
13
13
|
systemPrompt: system.text.length - system.bioChars - system.skillsChars,
|
|
14
14
|
agentInstructions: system.bioChars,
|
|
15
15
|
activeSkills: system.skillsChars,
|
|
16
|
-
toolSchemas: (toolSchemas
|
|
16
|
+
toolSchemas: toolSchemaChars(toolSchemas)
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
export function toolSchemaChars(toolSchemas) {
|
|
20
|
+
return (toolSchemas ?? []).reduce((total, schema) => total + JSON.stringify(schema).length, 0);
|
|
21
|
+
}
|
|
19
22
|
export function usageBreakdown(chars, totalTokens, modelName) {
|
|
20
23
|
if (!totalTokens || totalTokens <= 0)
|
|
21
24
|
return null;
|
|
@@ -183,6 +183,7 @@ export interface ToolParameterSchema {
|
|
|
183
183
|
enum?: string[];
|
|
184
184
|
items?: ToolParameterSchema;
|
|
185
185
|
properties?: Record<string, ToolParameterSchema>;
|
|
186
|
+
additionalProperties?: boolean;
|
|
186
187
|
required?: string[];
|
|
187
188
|
default?: unknown;
|
|
188
189
|
}
|
|
@@ -330,6 +331,8 @@ export type GoalEvent = {
|
|
|
330
331
|
round: number;
|
|
331
332
|
text?: string;
|
|
332
333
|
checks?: string[];
|
|
334
|
+
proof?: string;
|
|
335
|
+
cases?: true;
|
|
333
336
|
};
|
|
334
337
|
export type FoldEvent = {
|
|
335
338
|
type: 'fold';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export interface RunBudget {
|
|
2
2
|
readonly deadlineMs: number;
|
|
3
|
+
readonly totalMs?: number | undefined;
|
|
3
4
|
outputBytesUsed: number;
|
|
4
5
|
responseRoomChars?: number | undefined;
|
|
5
6
|
}
|
|
@@ -143,6 +144,7 @@ export interface RoundSpeed {
|
|
|
143
144
|
promptTokensPerSecond?: number;
|
|
144
145
|
tokensPerSecond?: number;
|
|
145
146
|
timeToFirstToken?: number;
|
|
147
|
+
avgConcurrentSeq?: number;
|
|
146
148
|
stopReason?: string;
|
|
147
149
|
overflows?: number;
|
|
148
150
|
contextBoundary?: true;
|
|
@@ -1,18 +1,44 @@
|
|
|
1
1
|
export declare const MAX_GOAL_CHECKS = 8;
|
|
2
|
+
export declare const MAX_PROVING: number;
|
|
2
3
|
export declare const GOAL_CHECKS_ASK: string;
|
|
3
4
|
export declare const GOAL_PROOF_ASK: string;
|
|
5
|
+
export declare const GOAL_REVIEW_ASK: string;
|
|
6
|
+
export declare const GOAL_CASES_ASK: string;
|
|
7
|
+
export declare const GOAL_DELIVERABLE_ASK: string;
|
|
8
|
+
export declare const GOAL_RUN_ASK: string;
|
|
4
9
|
export declare const MAX_PROOF_ASKS = 2;
|
|
5
10
|
export interface AskedGoal {
|
|
6
11
|
checkable?: boolean;
|
|
7
12
|
named?: boolean;
|
|
8
13
|
checks: readonly {
|
|
9
14
|
name: string;
|
|
15
|
+
passed?: boolean;
|
|
10
16
|
}[];
|
|
11
17
|
turns: number;
|
|
18
|
+
deliverable?: readonly string[];
|
|
19
|
+
proving?: readonly string[];
|
|
20
|
+
edited?: readonly string[];
|
|
21
|
+
proof?: string;
|
|
12
22
|
}
|
|
23
|
+
export declare function deliverableAsk(paths: readonly string[]): string;
|
|
24
|
+
export declare function deliverableChecked(goal: AskedGoal): boolean;
|
|
25
|
+
export declare function asksDeliverable(goal: AskedGoal): boolean;
|
|
26
|
+
export declare function runAsk(path: string): string;
|
|
27
|
+
export declare function codeUnrun(goal: AskedGoal): boolean;
|
|
28
|
+
export declare function asksRun(goal: AskedGoal): boolean;
|
|
13
29
|
export declare function asksChecks(goal: AskedGoal): boolean;
|
|
14
30
|
export declare function existenceOnly(checks: readonly string[]): boolean;
|
|
31
|
+
export declare function pathsOf(checks: readonly string[]): string[];
|
|
32
|
+
export declare function runsDeliverable(check: string, deliverable: readonly string[], proving: readonly string[]): boolean;
|
|
33
|
+
export declare function sourceFile(path: string): boolean;
|
|
34
|
+
export declare function runsCode(command: string, edited: readonly string[]): string | undefined;
|
|
35
|
+
export declare function runsCodeCheck(command: string, checks: readonly string[]): string | undefined;
|
|
36
|
+
export declare function runsScript(check: string, paths: readonly string[]): boolean;
|
|
37
|
+
export declare function namesPath(text: string, paths: readonly string[]): boolean;
|
|
38
|
+
export declare function writtenTexts(args: Readonly<Record<string, unknown>>): [string, string][];
|
|
15
39
|
export declare function provesResult(command: string): string | undefined;
|
|
40
|
+
export declare function citesPassed(text: string, passed: readonly string[]): boolean;
|
|
16
41
|
export declare function namedChecks(text: string): string[];
|
|
17
42
|
export declare function mergeChecks(host: readonly string[], named: readonly string[]): string[];
|
|
18
43
|
export declare function runsCheck(command: string, check: string): boolean;
|
|
44
|
+
export declare function samePath(a: string, b: string): boolean;
|
|
@@ -2,6 +2,7 @@ const SHELL_OPERATOR = /(&&|\|\||;|\||\n)/;
|
|
|
2
2
|
const RUNNER = /^(python[\d.]*|bash|sh|node|bun|pytest)$/;
|
|
3
3
|
const CHECKS_HEADING = /^[\s*#_]*checks:?[\s*_]*$/i;
|
|
4
4
|
const CHECK_LINE = /^\s*(?:[-*]|\d+[.)])?\s*`([^`]+)`\s*$/;
|
|
5
|
+
const SPAN = /`([^`\n]+)`/g;
|
|
5
6
|
const FILE_TEST = /^-[sfed]$/;
|
|
6
7
|
const NOT_A_PATH = /^(-\w+|!|!?=+|<|>|\]\]?)$/;
|
|
7
8
|
const COMPARISON = /^(!?=+|-(eq|ne|lt|le|gt|ge))$/;
|
|
@@ -9,13 +10,33 @@ const TEST_SCRIPT = /^(tests?|checks?|verify|validate)(?=[_.-]|$)/;
|
|
|
9
10
|
const PACKAGE_TEST = /^tests?(?=[:_.-]|$)/;
|
|
10
11
|
const PACKAGE_MANAGER = /^(npm|yarn|pnpm|bun)$/;
|
|
11
12
|
const PYTHON = /^python[\d.]*$/;
|
|
12
|
-
const
|
|
13
|
+
const COMPARE = /^(diff|cmp)$/;
|
|
13
14
|
const QUIET = /^(-[a-zA-Z]*q[a-zA-Z]*|--quiet)$/;
|
|
15
|
+
const NEVER_RUNS = /^(cat|ls|head|tail|stat|file|wc|echo|printf|touch|chmod|chown|cp|mv|mkdir|rm|ln|unlink|rmdir|true|\w*sum)$/;
|
|
16
|
+
const INTERPRETER = /^(python[\d.]*|bash|sh|zsh|node|bun|deno|go|ruby|perl|php|lua|Rscript|julia|tsx|ts-node|java)$/;
|
|
17
|
+
const SYNTAX_ONLY = /^((ba|z)?sh -n|node (-c|--check)|(perl|ruby) -c|php -l)$/;
|
|
18
|
+
const SOURCE = /\.(py|js|mjs|cjs|ts|mts|cts|jsx|tsx|sh|bash|zsh|rb|pl|php|lua|r|jl|go|rs|c|h|cc|cpp|cxx|hpp|java)$/i;
|
|
19
|
+
const COMPILER = /^(gcc|g\+\+|cc|c\+\+|clang|clang\+\+|rustc)$/;
|
|
20
|
+
const SYSTEM_BIN = /^\/(usr\/)?s?bin\//;
|
|
21
|
+
const MAKE_DRY_RUN = /^(-n|-q|--dry-run|--just-print|--question)$/;
|
|
22
|
+
const CLEAN = /^(clean|distclean)$/;
|
|
23
|
+
const PATH_BREAK = /[\s'"`(),;:=<>|&[\]{}]+/;
|
|
24
|
+
const WRITE = /(?<![>&\d])>\|?\s*(['"]?)([^\s'";|&<>()]+)\1/g;
|
|
25
|
+
const HEREDOC = /(<<-?\s*(['"]?)(\w+)\2[^\n]*)\n([\s\S]*?\n)?\t*\3(?=\n|$)/g;
|
|
26
|
+
const WRAPPERS = new Map([
|
|
27
|
+
['timeout', /^(-s|-k|--signal|--kill-after)$/],
|
|
28
|
+
['env', /^(-u|-C|--unset|--chdir)$/],
|
|
29
|
+
['nice', /^(-n|--adjustment)$/],
|
|
30
|
+
['stdbuf', /^(-i|-o|-e|--input|--output|--error)$/],
|
|
31
|
+
['npx', /^(-p|--package)$/],
|
|
32
|
+
['bunx', /^(-p|--package)$/]
|
|
33
|
+
]);
|
|
14
34
|
const BRACKETS = new Map([
|
|
15
35
|
['[', ']'],
|
|
16
36
|
['[[', ']]']
|
|
17
37
|
]);
|
|
18
38
|
export const MAX_GOAL_CHECKS = 8;
|
|
39
|
+
export const MAX_PROVING = MAX_GOAL_CHECKS * 2;
|
|
19
40
|
export const GOAL_CHECKS_ASK = '[This goal has no checks yet. Name the commands that will prove the task is done: write a ' +
|
|
20
41
|
'line `Checks:`, then one command per line in backticks, such as `test -s /app/result.json` ' +
|
|
21
42
|
'or `python3 check.py`. Each must exit 0 only once the task is done, with no pipe, ; or && ' +
|
|
@@ -25,20 +46,54 @@ export const GOAL_PROOF_ASK = '[The checks this goal has so far may only show th
|
|
|
25
46
|
"and comparing with what the task asks, or the task's own tests: write a line `Checks:`, " +
|
|
26
47
|
'then one command per line in backticks, with no pipe, ; or && in it. A command that repeats ' +
|
|
27
48
|
'one of those checks does not count. The goal is met only once each check ran on its own and exited 0.]';
|
|
49
|
+
export const GOAL_REVIEW_ASK = '[Before the goal is met, read the task again and list each requirement it states, one line ' +
|
|
50
|
+
'each, with the command that proves it in backticks and the output it gave. Then write a ' +
|
|
51
|
+
'line `Checks:` and, one per line in backticks, a command for each requirement nothing proved ' +
|
|
52
|
+
'yet, that exits 0 only when it holds, with no pipe, ; or && in it. If every requirement is ' +
|
|
53
|
+
'proved, name no command.]';
|
|
54
|
+
export const GOAL_CASES_ASK = '[The checks pass with most of the budget left. Read the task again and quote each case it ' +
|
|
55
|
+
'names, such as an input, an edge case or an output format, one line each. For each one, ' +
|
|
56
|
+
'run a command that feeds it to your result and show the output it gave. Fix what does not ' +
|
|
57
|
+
'hold, then answer.]';
|
|
58
|
+
export const GOAL_DELIVERABLE_ASK = '[The checks pass, but none of them runs or reads {paths}, what the task asks for. A check ' +
|
|
59
|
+
'counts only when its command, or a script it runs that you wrote, names one of those paths. ' +
|
|
60
|
+
'Write a line `Checks:`, then one command per line in backticks that runs or reads it on an ' +
|
|
61
|
+
'input and exits 0 only when the result is right, with no pipe, ; or && in it. The checks so ' +
|
|
62
|
+
'far stay.]';
|
|
63
|
+
export const GOAL_RUN_ASK = '[No command ran `{path}` after your last edit. Run a test that exercises it. It counts only ' +
|
|
64
|
+
'when it exits 0 on its own, with no pipe, `|| true` or ; after it.]';
|
|
28
65
|
export const MAX_PROOF_ASKS = 2;
|
|
66
|
+
export function deliverableAsk(paths) {
|
|
67
|
+
return GOAL_DELIVERABLE_ASK.replaceAll('{paths}', paths.join(', '));
|
|
68
|
+
}
|
|
69
|
+
export function deliverableChecked(goal) {
|
|
70
|
+
const { deliverable, proving = [] } = goal;
|
|
71
|
+
return (!deliverable || goal.checks.some((check) => runsDeliverable(check.name, deliverable, proving)));
|
|
72
|
+
}
|
|
73
|
+
export function asksDeliverable(goal) {
|
|
74
|
+
return (!asksChecks(goal) && goal.checks.every((check) => check.passed) && !deliverableChecked(goal));
|
|
75
|
+
}
|
|
76
|
+
export function runAsk(path) {
|
|
77
|
+
return GOAL_RUN_ASK.replaceAll('{path}', path);
|
|
78
|
+
}
|
|
79
|
+
export function codeUnrun(goal) {
|
|
80
|
+
return !!goal.checkable && !!goal.edited?.length && !goal.proof;
|
|
81
|
+
}
|
|
82
|
+
export function asksRun(goal) {
|
|
83
|
+
return (codeUnrun(goal) &&
|
|
84
|
+
!asksChecks(goal) &&
|
|
85
|
+
goal.checks.every((check) => check.passed) &&
|
|
86
|
+
deliverableChecked(goal));
|
|
87
|
+
}
|
|
29
88
|
export function asksChecks(goal) {
|
|
30
|
-
return
|
|
31
|
-
!goal.named &&
|
|
32
|
-
(!goal.checks.length ||
|
|
33
|
-
existenceOnly(goal.checks.map((check) => check.name)) ||
|
|
34
|
-
goal.turns < MAX_PROOF_ASKS));
|
|
89
|
+
return !!goal.checkable && !goal.named && goal.turns < MAX_PROOF_ASKS;
|
|
35
90
|
}
|
|
36
91
|
export function existenceOnly(checks) {
|
|
37
92
|
return (checks.length > 0 &&
|
|
38
93
|
checks.every((check) => check
|
|
39
94
|
.split(SHELL_OPERATOR)
|
|
40
95
|
.filter((part, at) => at % 2 === 0 && part.trim())
|
|
41
|
-
.every((part) => testsExistence(
|
|
96
|
+
.every((part) => testsExistence(commandOf(part)))));
|
|
42
97
|
}
|
|
43
98
|
function testsExistence(tokens) {
|
|
44
99
|
const close = BRACKETS.get(tokens[0]);
|
|
@@ -50,6 +105,155 @@ function testsExistence(tokens) {
|
|
|
50
105
|
path.length > 0 &&
|
|
51
106
|
!path.some((token) => NOT_A_PATH.test(token)));
|
|
52
107
|
}
|
|
108
|
+
export function pathsOf(checks) {
|
|
109
|
+
const paths = checks.flatMap((check) => check
|
|
110
|
+
.split(SHELL_OPERATOR)
|
|
111
|
+
.filter((part, at) => at % 2 === 0)
|
|
112
|
+
.map(commandOf)
|
|
113
|
+
.filter(testsExistence)
|
|
114
|
+
.flatMap((tokens) => tokens.slice(2, BRACKETS.has(tokens[0]) ? -1 : undefined)));
|
|
115
|
+
return [...new Set(paths)];
|
|
116
|
+
}
|
|
117
|
+
export function runsDeliverable(check, deliverable, proving) {
|
|
118
|
+
return (!existenceOnly([check]) &&
|
|
119
|
+
exitSegments(check).some((segment) => {
|
|
120
|
+
const tokens = commandOf(segment);
|
|
121
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
122
|
+
const tests = program === 'test' || BRACKETS.has(program);
|
|
123
|
+
if ((tests && !tokens.some((token) => COMPARISON.test(token))) || NEVER_RUNS.test(program)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const script = scriptOf(tokens);
|
|
127
|
+
return (namesPath(tokens.join(' '), deliverable) ||
|
|
128
|
+
(script !== undefined && proving.some((path) => samePath(script, path))) ||
|
|
129
|
+
runsTests(tokens));
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
export function sourceFile(path) {
|
|
133
|
+
return SOURCE.test(path);
|
|
134
|
+
}
|
|
135
|
+
export function runsCode(command, edited) {
|
|
136
|
+
const segments = exitSegments(command.replace(HEREDOC, '$1'));
|
|
137
|
+
return segments.find((segment, at) => {
|
|
138
|
+
const tokens = commandOf(segment);
|
|
139
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
140
|
+
if (program === 'test' || BRACKETS.has(program)) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
const script = INTERPRETER.test(program) ? interpreted(tokens) : tokens[0];
|
|
144
|
+
return (runsSuite(tokens) ||
|
|
145
|
+
runsProject(tokens) ||
|
|
146
|
+
(!!tokens[0]?.includes('/') &&
|
|
147
|
+
!SYSTEM_BIN.test(tokens[0]) &&
|
|
148
|
+
segments.slice(0, at).some((part) => builds(commandOf(part)))) ||
|
|
149
|
+
(script !== undefined &&
|
|
150
|
+
(edited.some((path) => samePath(script, path)) ||
|
|
151
|
+
TEST_SCRIPT.test(script.split('/').at(-1) ?? ''))));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
export function runsCodeCheck(command, checks) {
|
|
155
|
+
return checks.find((check) => runsCheck(command, check) &&
|
|
156
|
+
exitSegments(check).some((segment) => {
|
|
157
|
+
const tokens = commandOf(segment);
|
|
158
|
+
return runsSuite(tokens) || sourceFile(scriptOf(tokens) ?? '');
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
function interpreted(tokens) {
|
|
162
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
163
|
+
let at = 1;
|
|
164
|
+
for (; tokens[at]?.startsWith('-'); at++) {
|
|
165
|
+
if (tokens[at] === '-m' || SYNTAX_ONLY.test(`${program} ${tokens[at]}`)) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return (program === 'bun' || program === 'deno' || program === 'go') && tokens[at] === 'run'
|
|
170
|
+
? tokens[at + 1]
|
|
171
|
+
: tokens[at];
|
|
172
|
+
}
|
|
173
|
+
function runsProject(tokens) {
|
|
174
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
175
|
+
const [, next, target = ''] = tokens;
|
|
176
|
+
return ((program === 'cargo' && next === 'run') ||
|
|
177
|
+
(program === 'go' && next === 'run' && !target.endsWith('.go')));
|
|
178
|
+
}
|
|
179
|
+
function builds(tokens) {
|
|
180
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
181
|
+
const next = tokens[1];
|
|
182
|
+
return ((COMPILER.test(program) && !tokens.includes('-c')) ||
|
|
183
|
+
((program === 'go' || program === 'cargo') && next === 'build') ||
|
|
184
|
+
(program === 'make' &&
|
|
185
|
+
!tokens.some((token) => MAKE_DRY_RUN.test(token)) &&
|
|
186
|
+
!cleansOnly(tokens.slice(1).filter((token) => !token.startsWith('-')))) ||
|
|
187
|
+
(program === 'cmake' &&
|
|
188
|
+
tokens.includes('--build') &&
|
|
189
|
+
!cleansOnly(tokens.slice(tokens.indexOf('--target') + 1))));
|
|
190
|
+
}
|
|
191
|
+
function cleansOnly(tokens) {
|
|
192
|
+
const end = tokens.findIndex((token) => token.startsWith('-'));
|
|
193
|
+
const targets = end === -1 ? tokens : tokens.slice(0, end);
|
|
194
|
+
return targets.length > 0 && targets.every((target) => CLEAN.test(target));
|
|
195
|
+
}
|
|
196
|
+
export function runsScript(check, paths) {
|
|
197
|
+
return exitSegments(check).some((segment) => {
|
|
198
|
+
const script = scriptOf(commandOf(segment));
|
|
199
|
+
return script !== undefined && paths.some((path) => samePath(script, path));
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function runsTests(tokens) {
|
|
203
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
204
|
+
if (program === 'pytest' || PYTHON.test(program)) {
|
|
205
|
+
return (program === 'pytest' || testRunner(tokens)) && scriptOf(tokens) === undefined;
|
|
206
|
+
}
|
|
207
|
+
return testRunner(tokens);
|
|
208
|
+
}
|
|
209
|
+
function runsSuite(tokens) {
|
|
210
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
211
|
+
return (program === 'pytest' ||
|
|
212
|
+
program === 'ctest' ||
|
|
213
|
+
(program === 'node' && tokens.includes('--test')) ||
|
|
214
|
+
testRunner(tokens));
|
|
215
|
+
}
|
|
216
|
+
function testRunner(tokens) {
|
|
217
|
+
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
218
|
+
const [, next = '', third = ''] = tokens;
|
|
219
|
+
const module = tokens.indexOf('-m');
|
|
220
|
+
return ((PACKAGE_MANAGER.test(program) && PACKAGE_TEST.test(next === 'run' ? third : next)) ||
|
|
221
|
+
((program === 'cargo' || program === 'go') && next === 'test') ||
|
|
222
|
+
(program === 'make' && (next === 'test' || next === 'check')) ||
|
|
223
|
+
(PYTHON.test(program) && module > 0 && /^(pytest|unittest)$/.test(tokens[module + 1] ?? '')));
|
|
224
|
+
}
|
|
225
|
+
export function namesPath(text, paths) {
|
|
226
|
+
return text
|
|
227
|
+
.split(PATH_BREAK)
|
|
228
|
+
.some((token) => token && paths.some((path) => samePath(token, path)));
|
|
229
|
+
}
|
|
230
|
+
export function writtenTexts(args) {
|
|
231
|
+
const text = args.content ?? args.new;
|
|
232
|
+
if (typeof args.path === 'string' && typeof text === 'string') {
|
|
233
|
+
return [[args.path, text]];
|
|
234
|
+
}
|
|
235
|
+
const { command } = args;
|
|
236
|
+
if (typeof command !== 'string') {
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
const heredocs = [...command.matchAll(HEREDOC)].map((match) => ({
|
|
240
|
+
opened: match.index + match[1].length,
|
|
241
|
+
end: match.index + match[0].length,
|
|
242
|
+
body: match[4] ?? ''
|
|
243
|
+
}));
|
|
244
|
+
const written = [];
|
|
245
|
+
for (const match of command.matchAll(WRITE)) {
|
|
246
|
+
const [, , target] = match;
|
|
247
|
+
const inBody = heredocs.some(({ opened, end }) => match.index > opened && match.index < end);
|
|
248
|
+
if (inBody || target.startsWith('/dev/')) {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
const close = command.indexOf('\n', match.index);
|
|
252
|
+
const line = command.slice(command.lastIndexOf('\n', match.index) + 1, close < 0 ? undefined : close);
|
|
253
|
+
written.push([target, heredocs.find(({ opened }) => opened === close)?.body ?? line]);
|
|
254
|
+
}
|
|
255
|
+
return written;
|
|
256
|
+
}
|
|
53
257
|
export function provesResult(command) {
|
|
54
258
|
return exitSegments(command).find(proves);
|
|
55
259
|
}
|
|
@@ -57,10 +261,8 @@ function proves(segment) {
|
|
|
57
261
|
if (segment.split('"').length % 2 === 0 || segment.split("'").length % 2 === 0) {
|
|
58
262
|
return false;
|
|
59
263
|
}
|
|
60
|
-
const
|
|
61
|
-
const tokens = all.slice(Math.max(commandStart(all), 0));
|
|
264
|
+
const tokens = commandOf(segment);
|
|
62
265
|
const program = tokens[0]?.split('/').at(-1) ?? '';
|
|
63
|
-
const [, next = '', third = ''] = tokens;
|
|
64
266
|
const python = PYTHON.test(program);
|
|
65
267
|
if (program === 'test' || program === '[' || program === '[[') {
|
|
66
268
|
return tokens.some((token) => COMPARISON.test(token));
|
|
@@ -68,25 +270,26 @@ function proves(segment) {
|
|
|
68
270
|
if ((python && tokens.includes('-c')) || (program === 'node' && tokens.includes('-e'))) {
|
|
69
271
|
return /\bassert\b/.test(segment);
|
|
70
272
|
}
|
|
71
|
-
|
|
72
|
-
return (TEST_PROGRAM.test(program) ||
|
|
273
|
+
return (COMPARE.test(program) ||
|
|
73
274
|
(program === 'grep' && tokens.some((token) => QUIET.test(token))) ||
|
|
74
|
-
(
|
|
75
|
-
((
|
|
76
|
-
(program === 'make' && (next === 'test' || next === 'check')) ||
|
|
77
|
-
(program === 'node' && tokens.includes('--test')) ||
|
|
78
|
-
(python && module > 0 && /^(pytest|unittest)$/.test(tokens[module + 1] ?? '')) ||
|
|
79
|
-
TEST_SCRIPT.test(scriptOf(tokens) ?? ''));
|
|
275
|
+
runsSuite(tokens) ||
|
|
276
|
+
TEST_SCRIPT.test(scriptOf(tokens)?.split('/').at(-1) ?? ''));
|
|
80
277
|
}
|
|
81
278
|
function scriptOf(tokens) {
|
|
82
279
|
let at = 0;
|
|
83
280
|
if (RUNNER.test(tokens[0]?.split('/').at(-1) ?? '')) {
|
|
84
281
|
at++;
|
|
85
282
|
while (tokens[at]?.startsWith('-')) {
|
|
86
|
-
at
|
|
283
|
+
at += tokens[at] === '-m' ? 2 : 1;
|
|
87
284
|
}
|
|
88
285
|
}
|
|
89
|
-
return tokens[at]
|
|
286
|
+
return tokens[at];
|
|
287
|
+
}
|
|
288
|
+
export function citesPassed(text, passed) {
|
|
289
|
+
const lines = text.split('\n');
|
|
290
|
+
const heading = lines.findIndex((line) => CHECKS_HEADING.test(line));
|
|
291
|
+
const cited = lines.slice(0, heading < 0 ? undefined : heading).join('\n');
|
|
292
|
+
return [...cited.matchAll(SPAN)].some(([, span]) => passed.some((command) => runsCheck(span, command)));
|
|
90
293
|
}
|
|
91
294
|
export function namedChecks(text) {
|
|
92
295
|
const lines = text.split('\n');
|
|
@@ -143,6 +346,10 @@ function exitSegments(command) {
|
|
|
143
346
|
}
|
|
144
347
|
return segments;
|
|
145
348
|
}
|
|
349
|
+
function commandOf(segment) {
|
|
350
|
+
const all = words(segment);
|
|
351
|
+
return all.slice(Math.max(commandStart(all), 0));
|
|
352
|
+
}
|
|
146
353
|
function words(text) {
|
|
147
354
|
return text
|
|
148
355
|
.trim()
|
|
@@ -168,13 +375,32 @@ function invokes(tokens, wanted) {
|
|
|
168
375
|
return leads(tokens.slice(start), wanted);
|
|
169
376
|
}
|
|
170
377
|
function commandStart(tokens) {
|
|
171
|
-
|
|
378
|
+
let at = 0;
|
|
379
|
+
while (at < tokens.length) {
|
|
380
|
+
if (/^\w+=/.test(tokens[at])) {
|
|
381
|
+
at++;
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
const wrapper = tokens[at].split('/').at(-1) ?? '';
|
|
385
|
+
const takesValue = WRAPPERS.get(wrapper);
|
|
386
|
+
if (!takesValue) {
|
|
387
|
+
return at;
|
|
388
|
+
}
|
|
389
|
+
at++;
|
|
390
|
+
while (tokens[at]?.startsWith('-')) {
|
|
391
|
+
at += takesValue.test(tokens[at]) ? 2 : 1;
|
|
392
|
+
}
|
|
393
|
+
if (wrapper === 'timeout') {
|
|
394
|
+
at++;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return -1;
|
|
172
398
|
}
|
|
173
399
|
function leads(tokens, wanted) {
|
|
174
400
|
return (wanted.length > 0 &&
|
|
175
401
|
wanted.every((word, at) => tokens[at] !== undefined && samePath(tokens[at], word)));
|
|
176
402
|
}
|
|
177
|
-
function samePath(a, b) {
|
|
403
|
+
export function samePath(a, b) {
|
|
178
404
|
const left = a.replace(/^\.\//, '');
|
|
179
405
|
const right = b.replace(/^\.\//, '');
|
|
180
406
|
return left === right || left.endsWith(`/${right}`) || right.endsWith(`/${left}`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const HOMEBREW_BIN_DIRS: readonly string[];
|
|
2
2
|
export declare function withHomebrewPath(path: string | undefined, platformName: string): string | undefined;
|
|
3
3
|
export declare const EXEC_ENV_ALLOWLIST: readonly ['PATH', 'HOME', 'TMPDIR', 'TMP', 'TEMP', 'LANG', 'LC_ALL', 'LC_CTYPE', 'TZ', 'USER', 'LOGNAME', 'HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'https_proxy', 'ALL_PROXY', 'all_proxy', 'NO_PROXY', 'no_proxy', 'SSL_CERT_FILE', 'SSL_CERT_DIR', 'CURL_CA_BUNDLE', 'REQUESTS_CA_BUNDLE', 'NODE_EXTRA_CA_CERTS'];
|
|
4
|
+
export declare const EXEC_ENV_DEFAULTS: Readonly<Record<string, string>>;
|
|
4
5
|
export declare function execEnv(env: Readonly<Record<string, string | undefined>>, platformName: string): Record<string, string>;
|
|
5
6
|
export declare function spawnEnv(env: Readonly<Record<string, string | undefined>>, platformName: string, overrides?: Readonly<Record<string, string>>): Record<string, string>;
|
|
@@ -40,8 +40,9 @@ const PLATFORM_EXEC_ENV_ALLOWLIST = {
|
|
|
40
40
|
win32: ['SystemRoot', 'COMSPEC', 'PATHEXT', 'USERPROFILE'],
|
|
41
41
|
linux: ['DISPLAY', 'WAYLAND_DISPLAY', 'XDG_RUNTIME_DIR']
|
|
42
42
|
};
|
|
43
|
+
export const EXEC_ENV_DEFAULTS = { PYTHONUNBUFFERED: '1' };
|
|
43
44
|
export function execEnv(env, platformName) {
|
|
44
|
-
const out = {};
|
|
45
|
+
const out = { ...EXEC_ENV_DEFAULTS };
|
|
45
46
|
const keys = [...EXEC_ENV_ALLOWLIST, ...(PLATFORM_EXEC_ENV_ALLOWLIST[platformName] ?? [])];
|
|
46
47
|
for (const key of keys) {
|
|
47
48
|
const value = env[key];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnsweredPayload, CompletionActionArgs, CompletionContext, PreparingPayload, RetrievingOutput, RoundDonePayload } from '../types.ts';
|
|
2
|
-
import type { RunOutcome } from '../../../contract/run.ts';
|
|
2
|
+
import type { GoalStatus, RunOutcome } from '../../../contract/run.ts';
|
|
3
3
|
import type { EngineError } from '../../../helpers/engine-error.ts';
|
|
4
4
|
export declare function startInitialRound({ context, params }: CompletionActionArgs<PreparingPayload>): Partial<CompletionContext>;
|
|
5
5
|
export declare function startNextRound({ context }: CompletionActionArgs): Partial<CompletionContext>;
|
|
@@ -11,12 +11,13 @@ export declare function retryCutRound({ context }: CompletionActionArgs): Partia
|
|
|
11
11
|
export declare function wrapCutCompletion({ context }: CompletionActionArgs): Partial<CompletionContext>;
|
|
12
12
|
export declare function continueWithInput({ context }: CompletionActionArgs): Partial<CompletionContext>;
|
|
13
13
|
export declare function addKnowledge({ context, params }: CompletionActionArgs<RetrievingOutput>): Partial<CompletionContext>;
|
|
14
|
-
export declare function goalTurn(
|
|
14
|
+
export declare function goalTurn(context: Readonly<CompletionContext>, stall?: string): string;
|
|
15
15
|
export declare function continueStalledGoal({ context }: CompletionActionArgs): Partial<CompletionContext>;
|
|
16
16
|
export declare function markGoalStalled({ context }: CompletionActionArgs): Partial<CompletionContext>;
|
|
17
17
|
export declare function continueGoal({ context }: CompletionActionArgs): Partial<CompletionContext>;
|
|
18
18
|
export declare function continueStop({ context, params }: CompletionActionArgs<AnsweredPayload>): Partial<CompletionContext>;
|
|
19
19
|
export declare function settleGoal({ context }: CompletionActionArgs): Partial<CompletionContext>;
|
|
20
|
+
export declare function goalStatus(context: Readonly<CompletionContext>): GoalStatus;
|
|
20
21
|
export declare function finishRound({ context, params }: CompletionActionArgs<RoundDonePayload>): Partial<CompletionContext>;
|
|
21
22
|
export declare function finishWrapRound({ context, params }: CompletionActionArgs<RoundDonePayload>): Partial<CompletionContext>;
|
|
22
23
|
export declare function wrapCompletion({ context, params }: CompletionActionArgs<RunOutcome>): Partial<CompletionContext>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hasRoundsLeft, stuckResult } from '../guards/retry.js';
|
|
2
|
-
import { asksChecks, mergeChecks, namedChecks } from '../../../helpers/goal-check.js';
|
|
3
|
-
import { activate, applyHistorySplice, applySplice, foldMetrics, goalMet, goalTokensLeft, nudgeWithChecks, nudgeWithPlan, retainFailureResults, settledSince } from '../rules.js';
|
|
2
|
+
import { asksChecks, asksDeliverable, asksRun, citesPassed, deliverableAsk, deliverableChecked, existenceOnly, GOAL_CASES_ASK, GOAL_REVIEW_ASK, MAX_GOAL_CHECKS, MAX_PROOF_ASKS, mergeChecks, namedChecks, runAsk } from '../../../helpers/goal-check.js';
|
|
3
|
+
import { activate, applyHistorySplice, applySplice, casesDue, checksMet, foldMetrics, goalMet, goalTokensLeft, nudgeWithChecks, nudgeWithPlan, retainFailureResults, settledSince } from '../rules.js';
|
|
4
4
|
export function startInitialRound({ context, params }) {
|
|
5
5
|
return applyPreparation(context, params);
|
|
6
6
|
}
|
|
@@ -19,17 +19,15 @@ export function startNextRound({ context }) {
|
|
|
19
19
|
}
|
|
20
20
|
export function retryMuteRound(args) {
|
|
21
21
|
const { context } = args;
|
|
22
|
+
const { goal } = context;
|
|
23
|
+
const goalReAsk = goal && !context.steering.length && !goalMet(context);
|
|
22
24
|
return {
|
|
23
|
-
...silentTurn(args,
|
|
25
|
+
...silentTurn(args, goalReAsk ? [{ role: 'user', content: goalTurn(context) }] : continuation(context)),
|
|
26
|
+
goal: goalReAsk && !args.params.cutOff ? askedGoal(context, goal) : goal,
|
|
24
27
|
mute: context.mute + 1,
|
|
25
28
|
round: context.round + 1
|
|
26
29
|
};
|
|
27
30
|
}
|
|
28
|
-
function muteReAsk(context) {
|
|
29
|
-
return context.goal && !context.steering.length && !goalMet(context)
|
|
30
|
-
? [{ role: 'user', content: goalTurn(context) }]
|
|
31
|
-
: continuation(context);
|
|
32
|
-
}
|
|
33
31
|
function silentTurn({ context, params }, reAsk = continuation(context)) {
|
|
34
32
|
if (params.cutOff) {
|
|
35
33
|
return {};
|
|
@@ -157,9 +155,28 @@ export function addKnowledge({ context, params }) {
|
|
|
157
155
|
sources: params.sources ? [...context.sources, ...params.sources] : context.sources
|
|
158
156
|
};
|
|
159
157
|
}
|
|
160
|
-
export function goalTurn(
|
|
158
|
+
export function goalTurn(context, stall) {
|
|
159
|
+
const { policy, goal, plan } = context;
|
|
161
160
|
const nudge = stall ? `${policy.goalNudge}\n${stall}` : policy.goalNudge;
|
|
162
|
-
|
|
161
|
+
const turn = nudgeWithChecks(nudgeWithPlan(`${nudge}\nGoal: ${goal?.objective ?? ''}`, plan), goal?.checks ?? [], !!goal && asksChecks(goal));
|
|
162
|
+
const deliverable = goal?.deliverable && asksDeliverable(goal)
|
|
163
|
+
? `${turn}\n${deliverableAsk(goal.deliverable)}`
|
|
164
|
+
: turn;
|
|
165
|
+
const edited = goal?.edited?.at(-1);
|
|
166
|
+
const asked = goal && edited && asksRun(goal) ? `${deliverable}\n${runAsk(edited)}` : deliverable;
|
|
167
|
+
if (reviewDue(context)) {
|
|
168
|
+
return `${asked}\n${GOAL_REVIEW_ASK}`;
|
|
169
|
+
}
|
|
170
|
+
return casesDue(context) ? `${asked}\n${GOAL_CASES_ASK}` : asked;
|
|
171
|
+
}
|
|
172
|
+
function reviewDue(context) {
|
|
173
|
+
return !!context.goal?.checkable && context.goal.review === 'due' && checksMet(context);
|
|
174
|
+
}
|
|
175
|
+
function askedGoal(context, goal) {
|
|
176
|
+
if (reviewDue(context)) {
|
|
177
|
+
return { ...goal, review: 'asked' };
|
|
178
|
+
}
|
|
179
|
+
return casesDue(context) ? { ...goal, cases: true } : goal;
|
|
163
180
|
}
|
|
164
181
|
export function continueStalledGoal({ context }) {
|
|
165
182
|
const { goal, policy } = context;
|
|
@@ -185,7 +202,7 @@ export function continueStalledGoal({ context }) {
|
|
|
185
202
|
narrated: false,
|
|
186
203
|
malformed: false,
|
|
187
204
|
cappedRounds: 0,
|
|
188
|
-
goal: goal && { ...goal, turns: goal.turns + 1 }
|
|
205
|
+
goal: goal && askedGoal(context, { ...goal, turns: goal.turns + 1 })
|
|
189
206
|
};
|
|
190
207
|
}
|
|
191
208
|
export function markGoalStalled({ context }) {
|
|
@@ -196,7 +213,7 @@ export function continueGoal({ context }) {
|
|
|
196
213
|
const { goal } = context;
|
|
197
214
|
return {
|
|
198
215
|
...continueAfterAnswer(context, [{ role: 'user', content: goalTurn(context) }]),
|
|
199
|
-
goal: goal && { ...goal, turns: goal.turns + 1 }
|
|
216
|
+
goal: goal && askedGoal(context, { ...goal, turns: goal.turns + 1 })
|
|
200
217
|
};
|
|
201
218
|
}
|
|
202
219
|
export function continueStop({ context, params }) {
|
|
@@ -206,7 +223,7 @@ export function settleGoal({ context }) {
|
|
|
206
223
|
const { goal } = context;
|
|
207
224
|
return goal ? { goal: { ...goal, status: goalStatus(context) } } : {};
|
|
208
225
|
}
|
|
209
|
-
function goalStatus(context) {
|
|
226
|
+
export function goalStatus(context) {
|
|
210
227
|
if (goalMet(context)) {
|
|
211
228
|
return 'met';
|
|
212
229
|
}
|
|
@@ -230,7 +247,7 @@ export function finishRound({ context, params }) {
|
|
|
230
247
|
const historyState = applyHistorySplice(context, params.history);
|
|
231
248
|
return {
|
|
232
249
|
lastRound: { ...params, history: undefined },
|
|
233
|
-
goal: adoptChecks(context.goal, params.contentText),
|
|
250
|
+
goal: adoptChecks(context.goal, params.contentText, params.toolCalls.length > 0),
|
|
234
251
|
roundsSent: context.round + 1,
|
|
235
252
|
cacheKey: params.cacheable === false ? null : context.cacheKey,
|
|
236
253
|
...historyState,
|
|
@@ -251,7 +268,13 @@ export function finishWrapRound({ context, params }) {
|
|
|
251
268
|
metrics
|
|
252
269
|
};
|
|
253
270
|
}
|
|
254
|
-
function adoptChecks(goal, text) {
|
|
271
|
+
function adoptChecks(goal, text, calling) {
|
|
272
|
+
if (goal?.review === 'asked') {
|
|
273
|
+
return adoptReview(goal, text, calling);
|
|
274
|
+
}
|
|
275
|
+
if (goal?.named && !deliverableChecked(goal)) {
|
|
276
|
+
return addChecks(goal, text);
|
|
277
|
+
}
|
|
255
278
|
if (!goal?.checkable || goal.named) {
|
|
256
279
|
return goal;
|
|
257
280
|
}
|
|
@@ -263,6 +286,33 @@ function adoptChecks(goal, text) {
|
|
|
263
286
|
const checks = names.map((name) => goal.checks.find((check) => check.name === name) ?? { name, passed: false, output: null });
|
|
264
287
|
return { ...goal, checks, named: true };
|
|
265
288
|
}
|
|
289
|
+
function adoptReview(goal, text, calling) {
|
|
290
|
+
const passed = goal.checks.filter((check) => check.passed).map((check) => check.name);
|
|
291
|
+
if (citesPassed(text, goal.proof ? [...passed, goal.proof] : passed)) {
|
|
292
|
+
return { ...addChecks(goal, text), review: 'done' };
|
|
293
|
+
}
|
|
294
|
+
if (calling) {
|
|
295
|
+
return goal;
|
|
296
|
+
}
|
|
297
|
+
const reviewAsks = (goal.reviewAsks ?? 0) + 1;
|
|
298
|
+
return {
|
|
299
|
+
...addChecks(goal, text),
|
|
300
|
+
reviewAsks,
|
|
301
|
+
review: reviewAsks < MAX_PROOF_ASKS ? 'due' : 'done'
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function addChecks(goal, text) {
|
|
305
|
+
const known = goal.checks.map((check) => check.name);
|
|
306
|
+
const fresh = namedChecks(text)
|
|
307
|
+
.filter((name) => !known.includes(name) && !existenceOnly([name]))
|
|
308
|
+
.slice(0, MAX_GOAL_CHECKS - known.length);
|
|
309
|
+
return fresh.length
|
|
310
|
+
? {
|
|
311
|
+
...goal,
|
|
312
|
+
checks: [...goal.checks, ...fresh.map((name) => ({ name, passed: false, output: null }))]
|
|
313
|
+
}
|
|
314
|
+
: goal;
|
|
315
|
+
}
|
|
266
316
|
function settledAfterSend(context, params) {
|
|
267
317
|
return params.history && params.history.at < context.history.length
|
|
268
318
|
? {
|