@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.
Files changed (79) 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/loading-skill.js +1 -1
  7. package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +10 -6
  8. package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +2 -2
  9. package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +1 -1
  10. package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +8 -0
  11. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +6 -2
  12. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +10 -4
  13. package/dist-lib/lib/capabilities/completion-engine/driver.js +15 -0
  14. package/dist-lib/lib/capabilities/completion-engine/loop.js +2 -1
  15. package/dist-lib/lib/capabilities/completion-engine/operations.js +1 -0
  16. package/dist-lib/lib/capabilities/completion-engine/ports.js +1 -1
  17. package/dist-lib/lib/capabilities/completion-engine/round.js +16 -7
  18. package/dist-lib/lib/capabilities/completion-engine/session.d.ts +3 -3
  19. package/dist-lib/lib/capabilities/prompt-prefix.d.ts +2 -0
  20. package/dist-lib/lib/capabilities/prompt-prefix.js +8 -0
  21. package/dist-lib/lib/capabilities/sdk-tool.d.ts +1 -1
  22. package/dist-lib/lib/capabilities/sdk-tool.js +17 -2
  23. package/dist-lib/lib/capabilities/usage-breakdown.d.ts +1 -0
  24. package/dist-lib/lib/capabilities/usage-breakdown.js +4 -1
  25. package/dist-lib/lib/contract/completion.d.ts +3 -0
  26. package/dist-lib/lib/contract/run.d.ts +2 -0
  27. package/dist-lib/lib/helpers/goal-check.d.ts +26 -0
  28. package/dist-lib/lib/helpers/goal-check.js +248 -22
  29. package/dist-lib/lib/helpers/spawn-path.d.ts +1 -0
  30. package/dist-lib/lib/helpers/spawn-path.js +2 -1
  31. package/dist-lib/lib/machine/completion/actions/completion.d.ts +3 -2
  32. package/dist-lib/lib/machine/completion/actions/completion.js +65 -15
  33. package/dist-lib/lib/machine/completion/actions/tools.js +47 -6
  34. package/dist-lib/lib/machine/completion/context.js +5 -1
  35. package/dist-lib/lib/machine/completion/implementations.d.ts +1 -0
  36. package/dist-lib/lib/machine/completion/implementations.js +7 -0
  37. package/dist-lib/lib/machine/completion/machine.d.ts +4 -1
  38. package/dist-lib/lib/machine/completion/machine.js +10 -1
  39. package/dist-lib/lib/machine/completion/rules.d.ts +3 -1
  40. package/dist-lib/lib/machine/completion/rules.js +25 -4
  41. package/dist-lib/lib/machine/completion/types.d.ts +16 -0
  42. package/dist-lib/lib/machine/index.d.ts +6 -1
  43. package/dist-lib/lib/machine/index.js +2 -0
  44. package/dist-lib/lib/models/model-pool.js +1 -2
  45. package/dist-lib/lib/office/engine/pptx/presentation.js +10 -5
  46. package/dist-lib/lib/sidecar/index.js +1 -1
  47. package/dist-lib/lib/skills-host/index.d.ts +1 -1
  48. package/dist-lib/lib/skills-host/index.js +3 -2
  49. package/dist-lib/lib/tools/exec/runner.d.ts +4 -0
  50. package/dist-lib/lib/tools/exec/runner.js +20 -3
  51. package/dist-lib/lib/tools/office.js +1 -0
  52. package/dist-lib/lib/tools/skills/overlay-watch.d.ts +2 -2
  53. package/dist-lib/lib/tools/skills/overlay-watch.js +4 -3
  54. package/dist-lib/lib/wire.js +9 -3
  55. package/dist-lib/plugins/image/index.js +5 -5
  56. package/dist-lib/plugins/knowledge/index.d.ts +3 -0
  57. package/dist-lib/plugins/knowledge/index.js +4 -0
  58. package/dist-lib/plugins/knowledge/manifest.d.ts +28 -4
  59. package/dist-lib/plugins/knowledge/manifest.js +49 -4
  60. package/dist-lib/plugins/knowledge/store.d.ts +10 -1
  61. package/dist-lib/plugins/knowledge/store.js +127 -57
  62. package/dist-lib/plugins/music/index.js +4 -4
  63. package/dist-lib/plugins/obsidian/index.js +14 -4
  64. package/dist-lib/plugins/python/index.d.ts +3 -1
  65. package/dist-lib/plugins/python/index.js +4 -1
  66. package/dist-lib/plugins/python/python-adapter.d.ts +2 -1
  67. package/dist-lib/plugins/python/python-adapter.js +8 -1
  68. package/dist-lib/plugins/sandbox-linux/index.js +2 -2
  69. package/dist-lib/plugins/sandbox-macos/index.js +2 -2
  70. package/dist-lib/plugins/sandbox-vm/index.d.ts +2 -1
  71. package/dist-lib/plugins/sandbox-vm/index.js +2 -2
  72. package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +3 -1
  73. package/dist-lib/plugins/sandbox-vm/vm-shell.js +45 -16
  74. package/dist-lib/plugins/sandbox-windows/index.js +2 -2
  75. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  76. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  77. package/package.json +27 -22
  78. package/scripts/addon-externals.cjs +4 -1
  79. package/patches/localwatch@1.4.3.patch +0 -13
@@ -1,7 +1,7 @@
1
1
  import { activate, applyHistorySplice, applySplice, cutOffMessage, recordTool, retainFailureResults, settledSince } from '../rules.js';
2
2
  import { failureResultRef, storeFailureResult, toolDeniedResult } from '../../../helpers/failure-result.js';
3
3
  import { applyPreparation } from './completion.js';
4
- import { asksChecks, existenceOnly, mergeChecks } from '../../../helpers/goal-check.js';
4
+ import { deliverableChecked, existenceOnly, MAX_GOAL_CHECKS, MAX_PROVING, mergeChecks, runsCode, runsCodeCheck, runsDeliverable, runsScript, samePath, sourceFile } from '../../../helpers/goal-check.js';
5
5
  export function resolveTools({ context, params }) {
6
6
  return {
7
7
  toolQueue: [...params.calls],
@@ -215,7 +215,7 @@ function applyToolResult(context, payload, call) {
215
215
  metrics: recordTool(context, call, payload.durationMs),
216
216
  activated: activate(context.activated, payload.activate ? [payload.activate] : []),
217
217
  plan: payload.plan ?? context.plan,
218
- goal: applyChecks(adoptProof(context.goal, payload.proved), payload.checked),
218
+ goal: applyChecks(adoptProof(adoptRun(addProving(context.goal, payload.wrote), payload.ran), payload.proved), payload.checked),
219
219
  planMode: context.planMode && payload.leftPlanMode !== true,
220
220
  pendingCall: null,
221
221
  approval: { status: 'idle', key: null },
@@ -289,6 +289,37 @@ export function rejectPlanModeWrite({ params }) {
289
289
  }
290
290
  };
291
291
  }
292
+ function addProving(goal, wrote) {
293
+ if (!goal || !wrote) {
294
+ return goal;
295
+ }
296
+ const written = wrote.map(({ path }) => path);
297
+ const checks = goal.checks.map((check) => runsScript(check.name, written) ? { ...check, passed: false, output: null } : check);
298
+ const edited = editCode(goal, written);
299
+ const changed = wrote.filter((write) => write.proving !== undefined);
300
+ if (!changed.length) {
301
+ return { ...goal, ...edited, checks };
302
+ }
303
+ const kept = (goal.proving ?? []).filter((path) => !changed.some((write) => samePath(write.path, path)));
304
+ const added = changed.filter((write) => write.proving).map(({ path }) => path);
305
+ return { ...goal, ...edited, checks, proving: [...kept, ...added].slice(-MAX_PROVING) };
306
+ }
307
+ function editCode(goal, written) {
308
+ const code = written.filter(sourceFile);
309
+ if (!code.length) {
310
+ return {};
311
+ }
312
+ const edited = code.reduce((list, path) => [...list.filter((known) => !samePath(known, path)), path], goal.edited ?? []);
313
+ return { edited: edited.slice(-MAX_PROVING), proof: undefined };
314
+ }
315
+ function adoptRun(goal, ran) {
316
+ if (!goal?.edited?.length || !ran) {
317
+ return goal;
318
+ }
319
+ const proof = runsCode(ran, goal.edited) ??
320
+ runsCodeCheck(ran, goal.checks.map((check) => check.name));
321
+ return proof ? { ...goal, proof } : goal;
322
+ }
292
323
  function applyChecks(goal, checked) {
293
324
  if (!goal || !checked) {
294
325
  return goal;
@@ -299,10 +330,15 @@ function applyChecks(goal, checked) {
299
330
  };
300
331
  }
301
332
  function adoptProof(goal, proved) {
302
- if (!goal ||
303
- !proved ||
304
- !asksChecks(goal) ||
305
- !existenceOnly(goal.checks.map((check) => check.name))) {
333
+ if (!goal || !proved) {
334
+ return goal;
335
+ }
336
+ if (goal.named) {
337
+ return goal.checks.length < MAX_GOAL_CHECKS && runsOutput(goal, proved.name)
338
+ ? { ...goal, checks: [...goal.checks, proved] }
339
+ : goal;
340
+ }
341
+ if (!goal.checkable || !existenceOnly(goal.checks.map((check) => check.name))) {
306
342
  return goal;
307
343
  }
308
344
  const names = mergeChecks(goal.checks.map((check) => check.name), [proved.name]);
@@ -315,3 +351,8 @@ function adoptProof(goal, proved) {
315
351
  named: true
316
352
  };
317
353
  }
354
+ function runsOutput(goal, name) {
355
+ return (!!goal.deliverable &&
356
+ !deliverableChecked(goal) &&
357
+ runsDeliverable(name, goal.deliverable, goal.proving ?? []));
358
+ }
@@ -1,4 +1,6 @@
1
+ import { existenceOnly, pathsOf } from '../../helpers/goal-check.js';
1
2
  export function emptyCompletionContext(opts) {
3
+ const existence = !opts.goal?.checksProve && existenceOnly(opts.goal?.checks ?? []);
2
4
  return {
3
5
  runId: opts.runId ?? '',
4
6
  policy: opts.policy,
@@ -67,7 +69,9 @@ export function emptyCompletionContext(opts) {
67
69
  turns: 0,
68
70
  status: 'open',
69
71
  checks: (opts.goal.checks ?? []).map((name) => ({ name, passed: false, output: null })),
70
- named: (opts.goal.checksProve && Boolean(opts.goal.checks?.length)) || undefined
72
+ named: (opts.goal.checksProve && Boolean(opts.goal.checks?.length)) || undefined,
73
+ review: 'due',
74
+ deliverable: existence ? pathsOf(opts.goal.checks ?? []) : undefined
71
75
  }
72
76
  : null
73
77
  };
@@ -100,6 +100,7 @@ export declare const completionActions: {
100
100
  cause?: import("../../helpers/engine-error.ts").ErrorCause;
101
101
  }, never, never, never, never, never>;
102
102
  markTimeUp: import("xstate").ActionFunction<CompletionContext, CompletionMachineEvent, CompletionMachineEvent, undefined, never, never, never, never, never>;
103
+ markHalfTime: import("xstate").ActionFunction<CompletionContext, CompletionMachineEvent, CompletionMachineEvent, undefined, never, never, never, never, never>;
103
104
  recordPause: import("xstate").ActionFunction<CompletionContext, CompletionMachineEvent, CompletionMachineEvent, undefined, never, never, never, never, never>;
104
105
  recordRecovery: import("xstate").ActionFunction<CompletionContext, CompletionMachineEvent, CompletionMachineEvent, undefined, never, never, never, never, never>;
105
106
  resumeRun: import("xstate").ActionFunction<CompletionContext, CompletionMachineEvent, CompletionMachineEvent, undefined, never, never, never, never, never>;
@@ -133,6 +133,7 @@ export const completionActions = {
133
133
  requestApproval: assignAction(requestApproval),
134
134
  failCompletion: assignAction(failCompletion),
135
135
  markTimeUp: assignAction(() => ({ timeUp: true })),
136
+ markHalfTime: assignAction(() => ({ halfTime: true })),
136
137
  recordPause: assignAction(({ context }) => ({
137
138
  pauseCount: context.pauseCount + 1
138
139
  })),
@@ -222,6 +223,12 @@ function goalAction(action) {
222
223
  if (goal.checks.length) {
223
224
  event.checks = goal.checks.map(({ name }) => name);
224
225
  }
226
+ if (goal.proof) {
227
+ event.proof = goal.proof;
228
+ }
229
+ if (goal.status === 'met' && goal.cases) {
230
+ event.cases = true;
231
+ }
225
232
  enqueue.emit(event);
226
233
  });
227
234
  }
@@ -175,6 +175,9 @@ declare const createCompletionMachineImplementation: (context?: CompletionContex
175
175
  } | {
176
176
  type: "markGoalStalled";
177
177
  params: undefined;
178
+ } | {
179
+ type: "markHalfTime";
180
+ params: undefined;
178
181
  } | {
179
182
  type: "markTimeUp";
180
183
  params: undefined;
@@ -426,7 +429,7 @@ declare const createCompletionMachineImplementation: (context?: CompletionContex
426
429
  } | {
427
430
  type: "toolRejected";
428
431
  params: unknown;
429
- }, "deadline", "done" | "failed" | "paused" | "pausing" | "resuming" | {
432
+ }, "deadline" | "halfTime", "done" | "failed" | "paused" | "pausing" | "resuming" | {
430
433
  active: "answering" | "finishing" | "generating" | "idle" | "prepareChecking" | "prepareRunning" | "preparing" | "resolving" | "retrieving" | "round" | "searching" | "wrapping" | {
431
434
  tools: "approving" | "batching" | "executing" | "inspecting" | "rejecting" | "selecting";
432
435
  };
@@ -98,6 +98,12 @@ const createCompletionMachineImplementation = (context, now = noClock) => setup(
98
98
  deadline: ({ context }) => {
99
99
  const deadline = context.durable?.runBudget.deadlineMs;
100
100
  return deadline === undefined ? MAX_DELAY : clamp(deadline - now());
101
+ },
102
+ halfTime: ({ context }) => {
103
+ const budget = context.durable?.runBudget;
104
+ return budget?.totalMs === undefined
105
+ ? MAX_DELAY
106
+ : clamp(budget.deadlineMs - budget.totalMs / 2 - now());
101
107
  }
102
108
  }
103
109
  }).createMachine({
@@ -139,7 +145,10 @@ const createCompletionMachineImplementation = (context, now = noClock) => setup(
139
145
  states: {
140
146
  active: {
141
147
  initial: 'idle',
142
- after: { deadline: { actions: 'markTimeUp' } },
148
+ after: {
149
+ deadline: { actions: 'markTimeUp' },
150
+ halfTime: { actions: 'markHalfTime' }
151
+ },
143
152
  on: {
144
153
  PAUSE: { target: '#completion.pausing', actions: 'recordPause' },
145
154
  FAIL: [
@@ -10,7 +10,9 @@ export declare const MAX_UNCHANGED_RESULTS = 3;
10
10
  export declare const MAX_ROUND_REPEATS = 3;
11
11
  export declare const MAX_ROUND_CALLS = 32;
12
12
  export declare function nudgeWithPlan(nudge: string, plan: readonly PlanStep[]): string;
13
- export declare function goalMet({ plan, goal }: Readonly<CompletionContext>): boolean;
13
+ export declare function goalMet(context: Readonly<CompletionContext>): boolean;
14
+ export declare function casesDue(context: Readonly<CompletionContext>): boolean;
15
+ export declare function checksMet({ plan, goal }: Readonly<CompletionContext>): boolean;
14
16
  export declare function nudgeWithChecks(nudge: string, checks: readonly GoalCheck[], unnamed?: boolean): string;
15
17
  export declare function goalTokensLeft({ goal, metrics }: Readonly<CompletionContext>): boolean;
16
18
  export declare function goalStalled({ outcome }: Readonly<CompletionContext>): boolean;
@@ -1,5 +1,5 @@
1
1
  import { isFailureResultReference } from '../../helpers/failure-result.js';
2
- import { asksChecks, GOAL_CHECKS_ASK, GOAL_PROOF_ASK } from '../../helpers/goal-check.js';
2
+ import { asksChecks, codeUnrun, deliverableChecked, GOAL_CHECKS_ASK, GOAL_PROOF_ASK } from '../../helpers/goal-check.js';
3
3
  export function runsUnasked(facts) {
4
4
  if (facts.permission === 'ask')
5
5
  return false;
@@ -33,9 +33,29 @@ function isDone(step) {
33
33
  function planDone(plan) {
34
34
  return plan.length > 0 && plan.every(isDone);
35
35
  }
36
- export function goalMet({ plan, goal }) {
36
+ export function goalMet(context) {
37
+ return checksMet(context) && !reviewPending(context.goal) && !casesOpen(context);
38
+ }
39
+ export function casesDue(context) {
40
+ return checksMet(context) && !reviewPending(context.goal) && casesOpen(context);
41
+ }
42
+ function casesOpen(context) {
43
+ return !!context.goal?.checkable && !context.goal.cases && halfLeft(context);
44
+ }
45
+ function halfLeft({ halfTime, round, policy, goal, metrics }) {
46
+ return (!halfTime &&
47
+ (round + 1) * 2 < policy.maxToolRounds &&
48
+ (!goal || goal.tokens === null || metrics.tokens * 2 < goal.tokens));
49
+ }
50
+ export function checksMet({ plan, goal }) {
37
51
  const checks = goal?.checks ?? [];
38
- return planDone(plan) && !(goal && asksChecks(goal)) && checks.every((check) => check.passed);
52
+ return (planDone(plan) &&
53
+ !(goal && asksChecks(goal)) &&
54
+ checks.every((check) => check.passed) &&
55
+ (!goal || (deliverableChecked(goal) && !codeUnrun(goal))));
56
+ }
57
+ function reviewPending(goal) {
58
+ return !!goal?.checkable && (goal.review === 'due' || goal.review === 'asked');
39
59
  }
40
60
  export function nudgeWithChecks(nudge, checks, unnamed) {
41
61
  if (!checks.length) {
@@ -127,7 +147,8 @@ const ROUND_STATS = [
127
147
  'generatedTokens',
128
148
  'promptTokensPerSecond',
129
149
  'tokensPerSecond',
130
- 'timeToFirstToken'
150
+ 'timeToFirstToken',
151
+ 'avgConcurrentSeq'
131
152
  ];
132
153
  function roundSpeed(round, { stats, stopReason, durationMs, overflows, reasoningDeltas, keyed }) {
133
154
  const speed = { round, durationMs: durationMs ?? 0 };
@@ -8,6 +8,7 @@ export interface CompletionStats {
8
8
  tokensPerSecond?: number | undefined;
9
9
  promptTokens?: number | undefined;
10
10
  cacheTokens?: number | undefined;
11
+ avgConcurrentSeq?: number | undefined;
11
12
  contextBoundary?: boolean | undefined;
12
13
  }
13
14
  export interface EngineEvent {
@@ -22,6 +23,8 @@ export interface EngineEvent {
22
23
  status?: GoalStatus;
23
24
  turn?: number;
24
25
  checks?: string[];
26
+ proof?: string;
27
+ cases?: true;
25
28
  context?: TurnContext;
26
29
  }
27
30
  export interface EngineFacts extends Record<string, unknown> {
@@ -158,6 +161,11 @@ export interface ToolDonePayload {
158
161
  leftPlanMode?: boolean;
159
162
  checked?: GoalCheck[];
160
163
  proved?: GoalCheck;
164
+ wrote?: {
165
+ path: string;
166
+ proving?: boolean;
167
+ }[];
168
+ ran?: string;
161
169
  }
162
170
  export interface BatchDonePayload {
163
171
  history?: HistorySplice;
@@ -283,6 +291,13 @@ export interface GoalState {
283
291
  checkable?: boolean;
284
292
  named?: boolean;
285
293
  stalled?: true;
294
+ review?: 'due' | 'asked' | 'done';
295
+ deliverable?: string[];
296
+ proving?: string[];
297
+ edited?: string[];
298
+ proof?: string;
299
+ reviewAsks?: number;
300
+ cases?: true;
286
301
  }
287
302
  export interface QueuedInput {
288
303
  id?: string;
@@ -294,6 +309,7 @@ export interface CompletionContext {
294
309
  runId: string;
295
310
  policy: RunPolicy;
296
311
  timeUp: boolean;
312
+ halfTime?: true;
297
313
  pauseCount: number;
298
314
  durable: EngineFacts | null;
299
315
  recovery: Operation | undefined;
@@ -1,3 +1,4 @@
1
+ import { goalStatus } from './completion/actions/completion.ts';
1
2
  import { emptyCompletionContext } from './completion/context.ts';
2
3
  import { atContextBoundary, cutOffMessage, cutShort, runsUnasked } from './completion/rules.ts';
3
4
  import { completionMachineDefinition, transitionName } from './definition.ts';
@@ -179,6 +180,9 @@ export declare class CompletionMachine {
179
180
  } | {
180
181
  type: "markGoalStalled";
181
182
  params: undefined;
183
+ } | {
184
+ type: "markHalfTime";
185
+ params: undefined;
182
186
  } | {
183
187
  type: "markTimeUp";
184
188
  params: undefined;
@@ -430,7 +434,7 @@ export declare class CompletionMachine {
430
434
  } | {
431
435
  type: "toolRejected";
432
436
  params: unknown;
433
- }, "deadline", "done" | "failed" | "paused" | "pausing" | "resuming" | {
437
+ }, "deadline" | "halfTime", "done" | "failed" | "paused" | "pausing" | "resuming" | {
434
438
  active: "answering" | "finishing" | "generating" | "idle" | "prepareChecking" | "prepareRunning" | "preparing" | "resolving" | "retrieving" | "round" | "searching" | "wrapping" | {
435
439
  tools: "approving" | "batching" | "executing" | "inspecting" | "rejecting" | "selecting";
436
440
  };
@@ -480,6 +484,7 @@ export declare class CompletionMachine {
480
484
  }, import("xstate").MetaObject>;
481
485
  static definition: typeof completionMachineDefinition;
482
486
  static emptyContext: typeof emptyCompletionContext;
487
+ static goalStatus: typeof goalStatus;
483
488
  static transitionName: typeof transitionName;
484
489
  static runsUnasked: typeof runsUnasked;
485
490
  static cutOffMessage: typeof cutOffMessage;
@@ -1,3 +1,4 @@
1
+ import { goalStatus } from './completion/actions/completion.js';
1
2
  import { PLAN_MODE_REFUSAL } from './completion/actions/tools.js';
2
3
  import { emptyCompletionContext } from './completion/context.js';
3
4
  import { createCompletionMachine } from './completion/machine.js';
@@ -10,6 +11,7 @@ export class CompletionMachine {
10
11
  static create = createCompletionMachine;
11
12
  static definition = completionMachineDefinition;
12
13
  static emptyContext = emptyCompletionContext;
14
+ static goalStatus = goalStatus;
13
15
  static transitionName = transitionName;
14
16
  static runsUnasked = runsUnasked;
15
17
  static cutOffMessage = cutOffMessage;
@@ -438,8 +438,7 @@ export function createModelPool(loadSdk, notify, { deviceConfig = {}, loads = cr
438
438
  gpu_layers: deviceConfig.gpuLayers,
439
439
  'main-gpu': mainGpu,
440
440
  openclCacheDir: openclCache || undefined,
441
- threads: resolved.llama?.threads ?? placement?.threads,
442
- 'cpu-mask': placement?.mask
441
+ threads: resolved.llama?.threads ?? placement?.threads
443
442
  });
444
443
  const pending = { key, model, modelSrc, modelType: 'llamacpp-completion' };
445
444
  const chosen = contextSize(model, modelSrc, { opts: resolved, deviceConfig });
@@ -765,11 +765,10 @@ export class Presentation {
765
765
  checkPlacement(opts);
766
766
  const ratio = info.height / info.width;
767
767
  let { width, height } = opts;
768
- if (width === undefined && height === undefined) {
769
- const natural = { width: info.width * EMU_PER_PIXEL, height: info.height * EMU_PER_PIXEL };
770
- const scale = Math.min(1, area.width / natural.width, area.height / natural.height);
771
- width = Math.round(natural.width * scale);
772
- height = Math.round(natural.height * scale);
768
+ const sized = width !== undefined || height !== undefined;
769
+ if (!sized) {
770
+ width = info.width * EMU_PER_PIXEL;
771
+ height = info.height * EMU_PER_PIXEL;
773
772
  }
774
773
  else if (height === undefined) {
775
774
  height = Math.round((width ?? 0) * ratio);
@@ -777,6 +776,12 @@ export class Presentation {
777
776
  else if (width === undefined) {
778
777
  width = Math.round(height / ratio);
779
778
  }
779
+ const placed = opts.x !== undefined || opts.y !== undefined;
780
+ if (width && height && !(sized && placed)) {
781
+ const scale = Math.min(1, area.width / width, area.height / height);
782
+ width = Math.round(width * scale);
783
+ height = Math.round(height * scale);
784
+ }
780
785
  if (!width || !height) {
781
786
  throw new DocsError('INVALID_BOX', 'the picture would have no visible size');
782
787
  }
@@ -87,7 +87,7 @@ export class HarnessSidecar {
87
87
  pluginMode: 'dynamic',
88
88
  plugins: admit(plugins, log)
89
89
  });
90
- await harness.ready().catch((err) => log.error(SCOPE, 'harness failed to open', err));
90
+ await harness.ready();
91
91
  await addUserPlugins(harness, log);
92
92
  await addHostModule(harness, log);
93
93
  sealAddons();
@@ -34,7 +34,7 @@ export declare class SkillsHost {
34
34
  constructor(opts: SkillsHostOptions);
35
35
  get names(): string[];
36
36
  open(): Promise<void>;
37
- close(): void;
37
+ close(): Promise<void>;
38
38
  publish(skills: readonly SkillReadiness[]): void;
39
39
  setCredentials(entries: ReadonlyArray<CredentialEntry>): void;
40
40
  setSkillSettings(entries: ReadonlyArray<SkillSettingEntry>): void;
@@ -44,9 +44,10 @@ export class SkillsHost {
44
44
  await this._reload();
45
45
  await this._watch();
46
46
  }
47
- close() {
48
- this._watcher?.stop();
47
+ async close() {
48
+ const watcher = this._watcher;
49
49
  this._watcher = null;
50
+ await watcher?.stop();
50
51
  }
51
52
  publish(skills) {
52
53
  this._readiness = new Map(skills.map((readiness) => [readiness.skill, readiness]));
@@ -14,6 +14,8 @@ export interface RunCommandOptions {
14
14
  readonly platform?: string;
15
15
  }
16
16
  export declare const DEFAULT_TIMEOUT_MS = 120000;
17
+ export declare const STOP_GRACE_MS = 2000;
18
+ export declare const TIMED_OUT_EXIT_CODE = 124;
17
19
  export declare const MAX_OUTPUT_CHARS = 8192;
18
20
  export declare const MAX_OUTPUT_CHARS_LIMIT = 65536;
19
21
  interface CapturedOutput {
@@ -27,6 +29,8 @@ export declare function capOutput(text: string, limit: number): string;
27
29
  export declare function appendOutput(output: CapturedOutput, chunk: Buffer | string): void;
28
30
  export declare function formatOutput(output: CapturedOutput, locator?: string | null): string;
29
31
  export declare function createCapturedOutput(limit: number, sink?: SpillSink): CapturedOutput;
32
+ export declare function timeoutNote(timeoutMs: number, printed: boolean): string;
33
+ export declare function withNote(stderr: string, note: string): string;
30
34
  export interface StartCommandOptions {
31
35
  readonly cwd?: string;
32
36
  readonly spawn: SpawnFn;
@@ -1,10 +1,10 @@
1
1
  import b4a from 'b4a';
2
2
  import process from 'process';
3
- import { HarnessError } from '../../errors.js';
4
3
  import { headTail, joinHeadTail } from '../../helpers/head-tail.js';
5
4
  import { AbortedError } from '../../helpers/race-abort.js';
6
5
  export const DEFAULT_TIMEOUT_MS = 120_000;
7
- const STOP_GRACE_MS = 2_000;
6
+ export const STOP_GRACE_MS = 2_000;
7
+ export const TIMED_OUT_EXIT_CODE = 124;
8
8
  export const MAX_OUTPUT_CHARS = 8_192;
9
9
  export const MAX_OUTPUT_CHARS_LIMIT = 65_536;
10
10
  export function capOutput(text, limit) {
@@ -27,6 +27,23 @@ export function formatOutput(output, locator) {
27
27
  export function createCapturedOutput(limit, sink) {
28
28
  return { limit, sink, head: '', tail: '', total: 0 };
29
29
  }
30
+ export function timeoutNote(timeoutMs, printed) {
31
+ const stopped = `command timed out after ${timeoutMs}ms and was stopped`;
32
+ return printed
33
+ ? `${stopped}; the output shown is what it printed before then`
34
+ : `${stopped}; no output reached exec in that time. A filter it pipes into (head, grep, sort) loses what it held when the command is stopped: send the output to a file, then head or tail the file. Otherwise it may loop over too much work or wait for input: try it on a small input that prints its progress`;
35
+ }
36
+ export function withNote(stderr, note) {
37
+ return stderr === '' || stderr.endsWith('\n') ? `${stderr}${note}` : `${stderr}\n${note}`;
38
+ }
39
+ function timedOut(timeoutMs, { stdout, stderr, files: [out, err] }) {
40
+ const note = timeoutNote(timeoutMs, stdout.total + stderr.total > 0);
41
+ return {
42
+ stdout: formatOutput(stdout, out),
43
+ stderr: withNote(formatOutput(stderr, err), note),
44
+ exitCode: TIMED_OUT_EXIT_CODE
45
+ };
46
+ }
30
47
  function terminateProcessTree(child, killProcess, signal = 'SIGTERM') {
31
48
  if (child.pid !== undefined && killProcess) {
32
49
  try {
@@ -109,7 +126,7 @@ export function runCommand(command, options) {
109
126
  };
110
127
  options.signal?.addEventListener('abort', onAbort, { once: true });
111
128
  const timer = setTimeout(() => {
112
- finish(() => reject(new HarnessError('COMMAND_TIMED_OUT', [timeoutMs])));
129
+ finish((files) => resolve(timedOut(timeoutMs, { stdout, stderr, files })));
113
130
  terminateProcessTree(child, options.killProcess);
114
131
  }, timeoutMs);
115
132
  child.stdout?.on('data', (chunk) => appendOutput(stdout, chunk));
@@ -587,6 +587,7 @@ function parameters(format) {
587
587
  items: {
588
588
  type: 'object',
589
589
  properties: { op: { type: 'string', enum: Object.keys(format.ops) } },
590
+ additionalProperties: true,
590
591
  required: ['op']
591
592
  }
592
593
  },
@@ -1,10 +1,10 @@
1
1
  export interface OverlayWatcher {
2
- stop(): void;
2
+ stop(): Promise<void>;
3
3
  }
4
4
  export type OverlayChangeStream = AsyncIterable<{
5
5
  diff?: readonly unknown[];
6
6
  }> & {
7
- destroy?: () => void;
7
+ destroy: () => void;
8
8
  };
9
9
  export type WatchStreamFactory = (overlayDir: string) => OverlayChangeStream;
10
10
  export interface WatchSkillsOverlayOptions {
@@ -19,7 +19,7 @@ export function watchSkillsOverlay(overlayDir, onChange, opts = {}) {
19
19
  }
20
20
  }, debounceMs);
21
21
  };
22
- void (async () => {
22
+ const drained = (async () => {
23
23
  try {
24
24
  for await (const batch of stream) {
25
25
  if (batch?.diff && batch.diff.length > 0) {
@@ -33,13 +33,14 @@ export function watchSkillsOverlay(overlayDir, onChange, opts = {}) {
33
33
  return {
34
34
  stop() {
35
35
  if (stopped)
36
- return;
36
+ return drained;
37
37
  stopped = true;
38
38
  if (timer) {
39
39
  clearTimeout(timer);
40
40
  }
41
41
  timer = null;
42
- stream.destroy?.();
42
+ stream.destroy();
43
+ return drained;
43
44
  }
44
45
  };
45
46
  }
@@ -150,7 +150,13 @@ function toWirePayload(event) {
150
150
  return {
151
151
  type: 'goal',
152
152
  text: stringField(event.text),
153
- payload: { status: event.status, turn: event.turn, checks: event.checks }
153
+ payload: {
154
+ status: event.status,
155
+ turn: event.turn,
156
+ checks: event.checks,
157
+ proof: event.proof,
158
+ cases: event.cases
159
+ }
154
160
  };
155
161
  case 'fold':
156
162
  return event.phase === 'done'
@@ -295,8 +301,8 @@ function fromWirePayload(event) {
295
301
  };
296
302
  }
297
303
  case 'goal': {
298
- const { status, turn, checks } = objectField(event.payload);
299
- return { type: 'goal', status, turn, text: event.text || undefined, checks };
304
+ const { status, turn, checks, proof, cases } = objectField(event.payload);
305
+ return { type: 'goal', status, turn, text: event.text || undefined, checks, proof, cases };
300
306
  }
301
307
  case 'fold': {
302
308
  const { phase, summary, throughId, foldedTurns } = objectField(event.payload);
@@ -3,11 +3,6 @@ import { retryMemo } from '../../lib/helpers/retry-memo.js';
3
3
  import { PluginRegistry } from '../../lib/plugins/index.js';
4
4
  import { createEditImageTool, loadMediaCodecs } from './edit-image.js';
5
5
  import { createDiffusionRuntime, createGenerateImageTool } from './generate-image.js';
6
- PluginRegistry.requirePeers('image', {
7
- '@qvac/diffusion-cpp': () => import.meta.resolve('@qvac/diffusion-cpp/addonLogging'),
8
- 'bare-image-resample': () => import.meta.resolve('bare-image-resample'),
9
- 'bare-media': () => import.meta.resolve('bare-media')
10
- });
11
6
  export { createEditImageTool } from './edit-image.js';
12
7
  export { createDiffusionRuntime, createGenerateImageTool, generationPercentTick, settingsDimension, settingsSteps } from './generate-image.js';
13
8
  function diffusionRuntime(models, model) {
@@ -67,6 +62,11 @@ export class Image {
67
62
  read;
68
63
  _options;
69
64
  constructor(options) {
65
+ PluginRegistry.requirePeers('image', {
66
+ '@qvac/diffusion-cpp': () => import.meta.resolve('@qvac/diffusion-cpp/addonLogging'),
67
+ 'bare-image-resample': () => import.meta.resolve('bare-image-resample'),
68
+ 'bare-media': () => import.meta.resolve('bare-media')
69
+ });
70
70
  this._options = options;
71
71
  this.read = options.read;
72
72
  }
@@ -13,6 +13,9 @@ export declare class Knowledge implements HarnessPlugin {
13
13
  readonly api = 1;
14
14
  readonly provides: string[];
15
15
  readonly needs: string[];
16
+ readonly addons: {
17
+ 'turbovec-ggml': () => Promise<any>;
18
+ };
16
19
  readonly read: readonly string[] | undefined;
17
20
  private readonly _options;
18
21
  constructor(options: KnowledgeOptions);
@@ -1,6 +1,9 @@
1
1
  import { PluginRegistry } from '../../lib/plugins/index.js';
2
2
  import { knowledgeSearchTool } from './search-tool.js';
3
3
  import { KnowledgeStore } from './store.js';
4
+ PluginRegistry.requirePeers('knowledge', {
5
+ '@qvac/turbovec-ggml': () => import.meta.resolve('@qvac/turbovec-ggml')
6
+ });
4
7
  export { KNOWLEDGE_SEARCH_TOOL } from './search-tool.js';
5
8
  function invalid(config) {
6
9
  if (!config?.dir || !config.model) {
@@ -20,6 +23,7 @@ export class Knowledge {
20
23
  api = PluginRegistry.API_VERSION;
21
24
  provides = ['knowledge'];
22
25
  needs = ['embed'];
26
+ addons = { 'turbovec-ggml': () => import('@qvac/turbovec-ggml/binding.js') };
23
27
  read;
24
28
  _options;
25
29
  constructor(options) {