@qvac/harness 1.0.0-rc.14 → 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.
Files changed (53) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +36 -6
  3. package/dist-lib/index.d.ts +1 -0
  4. package/dist-lib/index.js +2 -1
  5. package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +20 -1
  6. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +5 -2
  7. package/dist-lib/lib/capabilities/completion-engine/driver.js +15 -0
  8. package/dist-lib/lib/capabilities/completion-engine/loop.js +2 -1
  9. package/dist-lib/lib/capabilities/completion-engine/operations.js +1 -0
  10. package/dist-lib/lib/capabilities/completion-engine/round.js +14 -6
  11. package/dist-lib/lib/contract/completion.d.ts +3 -0
  12. package/dist-lib/lib/contract/run.d.ts +2 -0
  13. package/dist-lib/lib/helpers/goal-check.d.ts +26 -0
  14. package/dist-lib/lib/helpers/goal-check.js +248 -22
  15. package/dist-lib/lib/helpers/spawn-path.d.ts +1 -0
  16. package/dist-lib/lib/helpers/spawn-path.js +2 -1
  17. package/dist-lib/lib/machine/completion/actions/completion.d.ts +3 -2
  18. package/dist-lib/lib/machine/completion/actions/completion.js +65 -15
  19. package/dist-lib/lib/machine/completion/actions/tools.js +47 -6
  20. package/dist-lib/lib/machine/completion/context.js +5 -1
  21. package/dist-lib/lib/machine/completion/implementations.d.ts +1 -0
  22. package/dist-lib/lib/machine/completion/implementations.js +7 -0
  23. package/dist-lib/lib/machine/completion/machine.d.ts +4 -1
  24. package/dist-lib/lib/machine/completion/machine.js +10 -1
  25. package/dist-lib/lib/machine/completion/rules.d.ts +3 -1
  26. package/dist-lib/lib/machine/completion/rules.js +25 -4
  27. package/dist-lib/lib/machine/completion/types.d.ts +16 -0
  28. package/dist-lib/lib/machine/index.d.ts +6 -1
  29. package/dist-lib/lib/machine/index.js +2 -0
  30. package/dist-lib/lib/models/model-pool.js +1 -2
  31. package/dist-lib/lib/office/engine/pptx/presentation.js +10 -5
  32. package/dist-lib/lib/sidecar/index.js +1 -1
  33. package/dist-lib/lib/skills-host/index.d.ts +1 -1
  34. package/dist-lib/lib/skills-host/index.js +3 -2
  35. package/dist-lib/lib/tools/exec/runner.d.ts +4 -0
  36. package/dist-lib/lib/tools/exec/runner.js +20 -3
  37. package/dist-lib/lib/tools/office.js +1 -0
  38. package/dist-lib/lib/tools/skills/overlay-watch.d.ts +2 -2
  39. package/dist-lib/lib/tools/skills/overlay-watch.js +4 -3
  40. package/dist-lib/lib/wire.js +9 -3
  41. package/dist-lib/plugins/image/index.js +5 -5
  42. package/dist-lib/plugins/music/index.js +4 -4
  43. package/dist-lib/plugins/sandbox-linux/index.js +2 -2
  44. package/dist-lib/plugins/sandbox-macos/index.js +2 -2
  45. package/dist-lib/plugins/sandbox-vm/index.d.ts +2 -1
  46. package/dist-lib/plugins/sandbox-vm/index.js +2 -2
  47. package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +3 -1
  48. package/dist-lib/plugins/sandbox-vm/vm-shell.js +45 -16
  49. package/dist-lib/plugins/sandbox-windows/index.js +2 -2
  50. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  51. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  52. package/package.json +5 -5
  53. package/patches/localwatch@1.4.3.patch +0 -13
package/CHANGELOG.md CHANGED
@@ -461,6 +461,55 @@ breaking change is listed under Changed and Removed.
461
461
 
462
462
  ### Changed
463
463
 
464
+ - Importing `@qvac/harness/plugins/image` or `@qvac/harness/plugins/music` no
465
+ longer needs their peers; constructing `Image` or `Music` without them throws
466
+ the error naming the plugin and the missing packages. A sidecar host passing no
467
+ image or music model installs neither's peers.
468
+
469
+ - **Breaking:** a command that times out resolves instead of throwing.
470
+ `runCommand` (`lib/tools/exec/runner.ts`) and the `exec` tool result come
471
+ back as `{ stdout, stderr, exitCode: 124 }`: `stdout` and `stderr` hold what
472
+ the command printed before the kill, and a note goes at the end of `stderr`,
473
+ added after the head/tail cut so the cut never drops it. There is no `error`
474
+ field and no `COMMAND_TIMED_OUT`. This holds on the host shell and the Linux,
475
+ macOS and Windows sandboxes. An abort still rejects with `AbortedError`. The
476
+ Pyodide `python` language still throws `COMMAND_TIMED_OUT` and `quickjs` still
477
+ throws a plain error. (#742)
478
+
479
+ ```js
480
+ import { HarnessError } from '@qvac/harness/errors'
481
+ import { runCommand } from '@qvac/harness/lib/tools/exec/runner.ts'
482
+
483
+ // before
484
+ try {
485
+ await runCommand('npm test', { spawn, timeoutMs: 60_000 })
486
+ } catch (err) {
487
+ if (HarnessError.is(err, 'COMMAND_TIMED_OUT')) retry()
488
+ }
489
+ // after
490
+ const result = await runCommand('npm test', { spawn, timeoutMs: 60_000 })
491
+ if (result.exitCode === 124) retry(result.stdout)
492
+ ```
493
+
494
+ - Exec sets `PYTHONUNBUFFERED=1` (`EXEC_ENV_DEFAULTS` in
495
+ `lib/helpers/spawn-path.ts`), so a python child's output reaches the pipe
496
+ before a timeout's kill instead of dying in its block buffer. `execEnv`
497
+ always sets it, as it is not on the env allowlist. The Linux, macOS and
498
+ Windows sandboxes spread it first, so a policy `env` allowlist that leaves
499
+ it out still passes it, and an explicit value wins. (#742)
500
+
501
+ - The ask for checks of the model's own stops after two goal turns it ignored
502
+ on every goal, not only one whose host checks test behaviour. A goal with no
503
+ host checks is then met on its plan. A goal whose host checks only test that
504
+ a file exists stays open until a passing check runs or reads what they test,
505
+ and each goal turn asks for one; a passing test runner, test script or
506
+ assertion that runs it is held as a check even after the model named others.
507
+ A run no longer repeats the same ask until its time budget. (#721)
508
+
509
+ - A spawned harness that cannot open now fails its sidecar's start with the
510
+ harness's own error, instead of serving a harness whose every call fails. A
511
+ supervising host sees the boot fail and why. (core v1 follow-up H1)
512
+
464
513
  - A goal with host checks that test behaviour stops asking the model for checks
465
514
  of its own after two goal turns it ignored. From then on the plan and the host
466
515
  checks meet it, and a check the model names later still gates it. A goal with
@@ -468,6 +517,47 @@ breaking change is listed under Changed and Removed.
468
517
  file exists (`test -s`, `[ -f ... ]`), the ask stays until the model names a
469
518
  check or a passing test runner, test script or inline assertion proves the
470
519
  result; that run is held as a check of its own. (#686)
520
+ - Breaking for hosts that send only `test -s` checks: a goal whose host checks
521
+ all test only that a path exists is met only once its checks pass and one of
522
+ them names a path the host checks test (not with `cat`, `ls` or another
523
+ command that only shows or moves a file, nor a `test` with no comparison),
524
+ runs a script whose written text names one (a heredoc, a `>` line,
525
+ `write_file` or `edit_file`), or runs a test runner on no given script
526
+ (`npm test`, `pytest`). While every check passes and none does this, each
527
+ goal turn asks for such a check, and until one does, the checks the model
528
+ names are added, so a run that used to end `met` now goes on until one passes
529
+ or a budget runs out. Set `goal.checksProve: true` when the
530
+ checks prove the task. (#698) Once that holds, one goal turn asks the model
531
+ to list the task's requirements and to name a check for each one the checks
532
+ miss, and adds those checks. (#694) A check wrapped in `timeout`, `env`,
533
+ `nice` or `stdbuf` is read as the command it runs; `nohup` is not, as
534
+ `nohup X &` exits at once. (#700, #703) On every goal, a write to a script resets
535
+ the pass of each check that runs it, so a pass from before the rewrite never
536
+ counts. (#701)
537
+ - Breaking for hosts that pass a `goal`: on a run with a tool that takes a
538
+ `command`, plan and checks no longer meet a goal on their own. Once the model
539
+ writes a source file, known by its extension for the languages a run can be
540
+ read for (Python, JavaScript and TypeScript, shell, Ruby, Perl, PHP, Lua, R,
541
+ Julia, Go, Rust, C and C++, Java; not `.txt`, `.json`, `.csv` or `.md`), the
542
+ goal stays open until a later command that runs that code exits 0, and once
543
+ the checks pass each goal turn asks for that run. A run is the file run as a
544
+ program or by its interpreter (`go run`, `Rscript`, `julia`, `tsx`,
545
+ `ts-node`, `java X.java`, and through `npx` or `bunx`), a test suite or test
546
+ script, `go run .`, `cargo run` or a build then a run in one command, or a
547
+ passing check that runs a script or a test suite. A reader such as `cat` or
548
+ `grep`, also by its `/bin` or `/usr/bin` path after a build, a run after
549
+ `make clean`, `make -n` or a cmake clean target, a compile, lint or syntax
550
+ check, and a run piped or followed by `|| true` or `;` do not count. Every
551
+ goal, whatever its host checks and with `checksProve` set, then takes a
552
+ review turn that asks for each requirement with the command that proves it.
553
+ The `goal` event carries `proof`, the command that ran the edited code,
554
+ recorded as `goalProof` in the bench trial row. (#732, #735, #745) The review
555
+ reply answers it only when a line above its `Checks:` names, in backticks, a
556
+ passed check or the run that proved the code; a reply with no calls that
557
+ names none is asked again, at most twice in all. A goal met with more than
558
+ half of each budget left takes one turn on the cases the task names; the met
559
+ `goal` event then carries `cases: true`, recorded as `goalCases`, and
560
+ `RunBudget.totalMs` keeps the whole time budget. (#740)
471
561
  - A host reaches the drive protocol it serves, the skill catalog and the
472
562
  user-plugin import map through named entries: `@qvac/harness/drive`
473
563
  (`DriveRequest`, `DriveResponse`, `DriveEntry`, `GrantedDrive`, `DriveOpFn`,
package/README.md CHANGED
@@ -194,13 +194,43 @@ const delegate = Agent.delegateTool(harness, base, { targets })
194
194
  `plan: true` gives an agent `update_plan`, a checklist it sees after every round. A `goal` keeps the
195
195
  run going until every step is done or a budget runs out. A goal's `checks` are commands the result
196
196
  is judged by, and until they pass each goal turn names the check and the output of its failed run.
197
- On a run with a tool that takes a `command`, the model must also name its own checks under a
197
+ On a run with a tool that takes a `command`, the model is also asked to name its own checks under a
198
198
  `Checks:` line, and the goal is met only once every check, the host's and the model's, ran in a
199
- call's `command` and exited 0. With host checks, the ask stops after two goal turns the model
200
- ignores, and from then on the plan and the host checks meet the goal. `checksProve: true` says the host
201
- checks prove the task: the goal is met on them alone and the model is not asked for its own. It has
202
- no effect without checks. With no tool that takes a `command` and no host checks, the goal ends when the plan is done; host
203
- checks need a tool that takes a `command`, or the goal runs to its budget.
199
+ call's `command` and exited 0. With no tool that takes a `command` and no host checks, the goal ends
200
+ when the plan is done; host checks need a tool that takes a `command`, or the goal runs to its
201
+ budget.
202
+
203
+ The ask stops after two goal turns the model ignores. From then on the plan and any host checks,
204
+ such as `npm test`, meet the goal once the gates below hold. When every host check only tests that a
205
+ path exists (`test -s out.txt`, `[ -f out.txt ]`), a passing test runner, test script or assertion
206
+ also counts as a check the model named. Such a goal is met only once its checks pass and one of them
207
+ names a path the host checks test, runs a script the model wrote that names one, or runs a test
208
+ runner on no given script, such as `npm test` or `pytest`. `cat`, `ls` and other commands that only
209
+ show or move a file do not count, nor does a `test` with no comparison. While every check passes and
210
+ none does this, each goal turn asks for such a check, and until one does, the checks the model names
211
+ are added. A check wrapped in `timeout`, `env`, `nice` or `stdbuf` counts as the command it runs.
212
+
213
+ On a run with a tool that takes a `command`, three more gates hold on every goal. Once the model
214
+ writes a source file, known by its extension (`.py`, `.js`, `.ts`, `.sh`, `.go`, `.rs`, `.c`,
215
+ `.java` and the like, not `.txt`, `.json`, `.csv` or `.md`), the goal is met only after a later
216
+ command runs that code and exits 0; once the checks pass, each goal turn asks for that run. A run
217
+ counts when it runs the file as a program or through its interpreter, runs a test suite (`pytest`,
218
+ `npm test`, `cargo test`, `go test`) or a test script, builds and runs the project (`go run .`,
219
+ `cargo run`, or a build then a run in one command), or is a passing check that runs a script or a
220
+ test suite. `cat`, `grep`, `diff` and other commands that only read a file do not count, nor does a
221
+ compile, lint or syntax check, nor a run piped or followed by `|| true` or `;`. Another write to a
222
+ source file needs a new run. Once the checks pass and the code ran, one goal turn asks the model to
223
+ list each requirement of the task with the command that proves it and the output it gave, then,
224
+ under a `Checks:` line, a command for each requirement nothing proved. The reply answers it only
225
+ when a line above its `Checks:` names, in backticks, a passed check or the run that proved the code;
226
+ otherwise the turn is asked again, at most twice in all. The commands it names under `Checks:` are
227
+ added. A goal met with more than half of each budget left (time, rounds, and the goal's tokens when
228
+ it caps them) then takes one turn on the cases the task names. `checksProve: true` says the host
229
+ checks prove the task: the goal skips the ask and the gate on the paths, and still takes the run
230
+ gate, the review turn and the cases turn. It has no effect without checks. On every goal,
231
+ `checksProve` included, a write to a script resets the pass of each check that runs it, so the check
232
+ must pass again.
233
+
204
234
  `planMode` refuses writes until the user approves the plan.
205
235
 
206
236
  ```ts
@@ -31,6 +31,7 @@ import type { ResolvedSkillCatalogEntry } from './lib/tools/skills/catalog.ts';
31
31
  import type { SkillSettingEntry } from './lib/tools/skills/skill-settings.ts';
32
32
  export type * from './lib/contract/index.ts';
33
33
  export { CompletionEngine, type CompletionArgs, type CompletionEngineOptions, type CompletionRun, type ModelRoundEvent, type ModelRoundIo, type ModelRoundPort, type ModelRoundRequest, type ModelRoundResult, ToolSets } from './lib/capabilities/completion-engine/index.ts';
34
+ export { renderedTools } from './lib/capabilities/sdk-tool.ts';
34
35
  export declare const CONTEXT_OVERFLOW_MESSAGE: string;
35
36
  export { imageSettingsFrom } from './lib/helpers/image-settings.ts';
36
37
  export { skillInContext, unreadySkillState, type CompletionSkillEntry } from './lib/capabilities/skill-entry.ts';
package/dist-lib/index.js CHANGED
@@ -40,6 +40,7 @@ import { runCommand } from './lib/tools/exec/runner.js';
40
40
  import { createLocalRoots } from './lib/tools/fs/local.js';
41
41
  import { createRemoteRoots } from './lib/tools/fs/remote.js';
42
42
  export { CompletionEngine, ToolSets } from './lib/capabilities/completion-engine/index.js';
43
+ export { renderedTools } from './lib/capabilities/sdk-tool.js';
43
44
  export const CONTEXT_OVERFLOW_MESSAGE = HarnessError.CONTEXT_OVERFLOW_MESSAGE;
44
45
  export { imageSettingsFrom } from './lib/helpers/image-settings.js';
45
46
  export { skillInContext, unreadySkillState } from './lib/capabilities/skill-entry.js';
@@ -156,7 +157,7 @@ export class Harness extends ReadyResource {
156
157
  },
157
158
  statusChanged: () => this._residency.invalidateStatus(),
158
159
  teardown: async () => {
159
- this._skills.close();
160
+ await this._skills.close();
160
161
  await this._teardownPlugins();
161
162
  }
162
163
  });
@@ -11,7 +11,7 @@ import { runToolCall } from './execute.js';
11
11
  import { toolCaller } from '../tool-caller.js';
12
12
  import { loadSkill } from './loading-skill.js';
13
13
  import { failureResultRef, storeFailureResult } from '../../../helpers/failure-result.js';
14
- import { provesResult, runsCheck } from '../../../helpers/goal-check.js';
14
+ import { namesPath, provesResult, runsCheck, writtenTexts } from '../../../helpers/goal-check.js';
15
15
  const CHECK_OUTPUT_CHARS = 2000;
16
16
  export const executing = async function executing(input) {
17
17
  const { emit, input: deps, context } = input;
@@ -56,6 +56,8 @@ export const executing = async function executing(input) {
56
56
  durationMs: settled.durationMs,
57
57
  checked: settled.checked,
58
58
  proved: settled.proved,
59
+ wrote: settled.wrote,
60
+ ran: settled.ran,
59
61
  plan: planned ? Agent.planSteps(callArgs) : undefined,
60
62
  leftPlanMode: planned && context.planMode && call.leavesPlan ? true : undefined
61
63
  };
@@ -209,6 +211,12 @@ export function settleCall({ input: { session }, context }, { ran, direct, emit
209
211
  proved: executed.executed && succeeded && context.goal
210
212
  ? proofRun(callArgs.command, executed.output)
211
213
  : undefined,
214
+ wrote: executed.executed && outcome.kind === 'success'
215
+ ? writtenScripts(context, callArgs)
216
+ : undefined,
217
+ ran: executed.executed && succeeded && context.goal && typeof callArgs.command === 'string'
218
+ ? callArgs.command
219
+ : undefined,
212
220
  entry: toolResultHistoryEntry({
213
221
  name: call.name,
214
222
  id: resultTurnId,
@@ -226,6 +234,17 @@ function checksRun({ goal }, { command, passed, output }) {
226
234
  }
227
235
  return ran.map(({ name }) => ({ name, passed, output: outputTail(output) }));
228
236
  }
237
+ function writtenScripts({ goal }, args) {
238
+ if (!goal) {
239
+ return undefined;
240
+ }
241
+ const { deliverable } = goal;
242
+ const fragment = typeof args.content !== 'string' && typeof args.new === 'string';
243
+ const wrote = writtenTexts(args).map(([path, text]) => deliverable
244
+ ? { path, proving: namesPath(text, deliverable) || (fragment ? undefined : false) }
245
+ : { path });
246
+ return wrote.length ? wrote : undefined;
247
+ }
229
248
  function proofRun(command, output) {
230
249
  const name = typeof command === 'string' ? provesResult(command) : undefined;
231
250
  return name ? { name, passed: true, output: outputTail(output) } : undefined;
@@ -33,7 +33,7 @@ export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session,
33
33
  goalNudge: context.policy.goalNudge,
34
34
  wrapUpNudge: context.policy.wrapUpNudge,
35
35
  tools: session.sdkTools,
36
- generationParams: wrapUpParams(session.generationParams),
36
+ generationParams: wrapUpParams(session.generationParams, context.outcome === 'time-capped'),
37
37
  toolDialect: args.model ? toolDialectFor(args.model) : undefined,
38
38
  cacheKey,
39
39
  signal,
@@ -78,7 +78,10 @@ export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session,
78
78
  response: replay || contentText || fallbackResponse
79
79
  };
80
80
  };
81
- function wrapUpParams(params) {
81
+ function wrapUpParams(params, timeUp) {
82
+ if (timeUp) {
83
+ return { ...params, reasoning_budget: 0, predict: WRAP_UP_PREDICT, tool_choice: 'none' };
84
+ }
82
85
  if (!params) {
83
86
  return { tool_choice: 'none' };
84
87
  }
@@ -79,6 +79,20 @@ async function* submittedInput(input, pipeline, { runId, agentId }) {
79
79
  yield submitted.context === undefined ? item : { ...item, notes: submitted.context };
80
80
  }
81
81
  }
82
+ function* cutGoal(context, runId) {
83
+ const { goal } = context;
84
+ if (goal?.status !== 'open') {
85
+ return;
86
+ }
87
+ yield {
88
+ type: 'goal',
89
+ runId,
90
+ status: CompletionMachine.goalStatus(context),
91
+ turn: goal.turns,
92
+ round: context.round,
93
+ proof: goal.proof
94
+ };
95
+ }
82
96
  function hookManifest(hooks) {
83
97
  const ordinals = new Map();
84
98
  return hooks.map((hook) => {
@@ -616,6 +630,7 @@ export async function* driveCompletion(args, runtime, options) {
616
630
  'tag' in result.error &&
617
631
  result.error.tag === 'aborted') {
618
632
  reachedPause = true;
633
+ yield* cutGoal(snapshot.context, runId);
619
634
  yield* runMetrics(cancelledRound(completionState.session?.liveRound));
620
635
  throw new AbortedError();
621
636
  }
@@ -25,7 +25,8 @@ const RUN_WALL_CLOCK_BUDGET_MS = 30 * 60_000;
25
25
  export function createRunBudget(startedAt, ms) {
26
26
  const override = Number(process.env.QVAC_RUN_BUDGET_MS);
27
27
  const fallback = Number.isFinite(override) && override > 0 ? override : RUN_WALL_CLOCK_BUDGET_MS;
28
- return { deadlineMs: startedAt + (ms ?? fallback), outputBytesUsed: 0 };
28
+ const totalMs = ms ?? fallback;
29
+ return { deadlineMs: startedAt + totalMs, totalMs, outputBytesUsed: 0 };
29
30
  }
30
31
  export function runToolContext(args, runBudget) {
31
32
  const { agent, attach, fetchAttachment, progress, askUser, signal } = args;
@@ -145,6 +145,7 @@ export function bindOperations(deps, context, stage) {
145
145
  : current.backends,
146
146
  runBudget: {
147
147
  deadlineMs: current.runBudget.deadlineMs,
148
+ totalMs: current.runBudget.totalMs,
148
149
  outputBytesUsed: Math.max(current.runBudget.outputBytesUsed, recorded.runBudget.outputBytesUsed)
149
150
  },
150
151
  outcome: {
@@ -18,8 +18,9 @@ import { detachJson } from '../../helpers/detach-json.js';
18
18
  import { isSkillMentionNudge, materializeCompletionHistory } from '../tool-turns.js';
19
19
  import { completionParams } from '../../helpers/completion-params.js';
20
20
  import { requestPromptPrefix } from '../prompt-prefix.js';
21
+ import { renderedTools } from '../sdk-tool.js';
21
22
  import { isFailureResultReference } from '../../helpers/failure-result.js';
22
- import { GOAL_CHECKS_ASK, GOAL_PROOF_ASK } from '../../helpers/goal-check.js';
23
+ import { GOAL_CHECKS_ASK, GOAL_PROOF_ASK, GOAL_REVIEW_ASK } from '../../helpers/goal-check.js';
23
24
  import { Fold } from '../../fold/index.js';
24
25
  import { CompletionMachine } from '../../machine/index.js';
25
26
  import { modelTurns } from './turns.js';
@@ -225,11 +226,18 @@ export function foldTokens(stats, cacheable) {
225
226
  function slotStats(stats, previous) {
226
227
  if (!stats)
227
228
  return undefined;
228
- const { cacheTokens: _summed, ...rest } = stats;
229
- if (previous === undefined || stats.promptTokens === undefined) {
229
+ const { cacheTokens: _summed, promptTokensPerSecond: _scheduler, ...own } = stats;
230
+ const { promptTokens, timeToFirstToken } = stats;
231
+ const rest = promptTokens !== undefined &&
232
+ promptTokens > 0 &&
233
+ timeToFirstToken !== undefined &&
234
+ timeToFirstToken > 0
235
+ ? { ...own, promptTokensPerSecond: (promptTokens / timeToFirstToken) * 1000 }
236
+ : own;
237
+ if (previous === undefined || promptTokens === undefined) {
230
238
  return rest;
231
239
  }
232
- return { ...rest, cacheTokens: previous + stats.promptTokens + (stats.generatedTokens ?? 0) };
240
+ return { ...rest, cacheTokens: previous + promptTokens + (stats.generatedTokens ?? 0) };
233
241
  }
234
242
  function boundaryStats(final, predict) {
235
243
  const stats = copy(final.stats);
@@ -391,7 +399,7 @@ function harnessTurns(args, history) {
391
399
  }
392
400
  function goalTurns(args) {
393
401
  const goal = args.goalNudge === undefined ? [] : [args.goalNudge];
394
- return [...goal, GOAL_CHECKS_ASK, GOAL_PROOF_ASK];
402
+ return [...goal, GOAL_CHECKS_ASK, GOAL_PROOF_ASK, GOAL_REVIEW_ASK];
395
403
  }
396
404
  async function foldRounds(send, history) {
397
405
  const { sdk, args, ctxSize } = send;
@@ -752,7 +760,7 @@ export function inferenceCall({ args, droppedTurns, modelId, params, cacheKey })
752
760
  droppedTurns,
753
761
  modelId,
754
762
  messages: params.history,
755
- tools: params.tools,
763
+ tools: renderedTools(params.tools, params.history),
756
764
  generationParams: params.generationParams,
757
765
  responseFormat: params.responseFormat,
758
766
  toolDialect: params.toolDialect,
@@ -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;