@qvac/harness 1.0.0-rc.20 → 1.0.0-rc.21

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 (191) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist-lib/index.d.ts +7 -5
  3. package/dist-lib/index.js +5 -4
  4. package/dist-lib/lib/agent/resolve.js +2 -1
  5. package/dist-lib/lib/capabilities/completion-engine/actors/answering.js +2 -2
  6. package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +1 -1
  7. package/dist-lib/lib/capabilities/completion-engine/actors/execute.d.ts +1 -1
  8. package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +8 -6
  9. package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +1 -1
  10. package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +1 -1
  11. package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +2 -1
  12. package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +8 -3
  13. package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +10 -4
  14. package/dist-lib/lib/capabilities/completion-engine/actors/run-prepare.js +2 -1
  15. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +8 -8
  16. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +2 -2
  17. package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +3 -2
  18. package/dist-lib/lib/capabilities/completion-engine/loop.js +1 -0
  19. package/dist-lib/lib/capabilities/completion-engine/round.js +9 -9
  20. package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -1
  21. package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +5 -41
  22. package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +4 -133
  23. package/dist-lib/lib/capabilities/completion-engine/tool-outcome.d.ts +4 -0
  24. package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +42 -0
  25. package/dist-lib/lib/capabilities/completion-engine/tool-preflight.d.ts +43 -0
  26. package/dist-lib/lib/capabilities/completion-engine/tool-preflight.js +91 -0
  27. package/dist-lib/lib/capabilities/completion-engine/turns.js +7 -4
  28. package/dist-lib/lib/capabilities/tool-turns/attachments.d.ts +7 -0
  29. package/dist-lib/lib/capabilities/tool-turns/attachments.js +39 -0
  30. package/dist-lib/lib/capabilities/tool-turns/copy.d.ts +13 -0
  31. package/dist-lib/lib/capabilities/tool-turns/copy.js +29 -0
  32. package/dist-lib/lib/capabilities/tool-turns/result-turn.d.ts +22 -0
  33. package/dist-lib/lib/capabilities/tool-turns/result-turn.js +120 -0
  34. package/dist-lib/lib/capabilities/tool-turns/run-limits.d.ts +6 -0
  35. package/dist-lib/lib/capabilities/tool-turns/run-limits.js +32 -0
  36. package/dist-lib/lib/capabilities/tool-turns/skill-loads.d.ts +9 -0
  37. package/dist-lib/lib/capabilities/tool-turns/skill-loads.js +71 -0
  38. package/dist-lib/lib/capabilities/tool-turns.d.ts +8 -54
  39. package/dist-lib/lib/capabilities/tool-turns.js +6 -281
  40. package/dist-lib/lib/client/index.js +3 -3
  41. package/dist-lib/lib/connect/abort.d.ts +6 -0
  42. package/dist-lib/lib/connect/abort.js +52 -0
  43. package/dist-lib/lib/connect/bridges.d.ts +21 -0
  44. package/dist-lib/lib/connect/bridges.js +185 -0
  45. package/dist-lib/lib/connect/decode.d.ts +31 -0
  46. package/dist-lib/lib/connect/decode.js +114 -0
  47. package/dist-lib/lib/connect/host-run-log.d.ts +16 -0
  48. package/dist-lib/lib/connect/host-run-log.js +74 -0
  49. package/dist-lib/lib/connect/served.d.ts +7 -0
  50. package/dist-lib/lib/connect/served.js +45 -0
  51. package/dist-lib/lib/connect.d.ts +3 -3
  52. package/dist-lib/lib/connect.js +24 -468
  53. package/dist-lib/lib/context-window.d.ts +13 -7
  54. package/dist-lib/lib/context-window.js +13 -6
  55. package/dist-lib/lib/contract/agent.d.ts +12 -1
  56. package/dist-lib/lib/contract/completion.d.ts +5 -1
  57. package/dist-lib/lib/contract/drive.d.ts +130 -4
  58. package/dist-lib/lib/contract/ocr.d.ts +5 -1
  59. package/dist-lib/lib/contract-types.d.ts +5 -3
  60. package/dist-lib/lib/errors.js +3 -3
  61. package/dist-lib/lib/helpers/goal-check/asks.d.ts +25 -0
  62. package/dist-lib/lib/helpers/goal-check/asks.js +52 -0
  63. package/dist-lib/lib/helpers/goal-check/checks.d.ts +8 -0
  64. package/dist-lib/lib/helpers/goal-check/checks.js +92 -0
  65. package/dist-lib/lib/helpers/goal-check/commands.d.ts +7 -0
  66. package/dist-lib/lib/helpers/goal-check/commands.js +130 -0
  67. package/dist-lib/lib/helpers/goal-check/paths.d.ts +5 -0
  68. package/dist-lib/lib/helpers/goal-check/paths.js +44 -0
  69. package/dist-lib/lib/helpers/goal-check/shell.d.ts +9 -0
  70. package/dist-lib/lib/helpers/goal-check/shell.js +96 -0
  71. package/dist-lib/lib/helpers/goal-check.d.ts +35 -43
  72. package/dist-lib/lib/helpers/goal-check.js +34 -406
  73. package/dist-lib/lib/helpers/recent-map.d.ts +7 -0
  74. package/dist-lib/lib/helpers/recent-map.js +23 -0
  75. package/dist-lib/lib/helpers/tool-call-markup/emit.d.ts +6 -0
  76. package/dist-lib/lib/helpers/tool-call-markup/emit.js +15 -0
  77. package/dist-lib/lib/helpers/tool-call-markup/recover.d.ts +22 -0
  78. package/dist-lib/lib/helpers/tool-call-markup/recover.js +130 -0
  79. package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.d.ts +3 -0
  80. package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.js +56 -0
  81. package/dist-lib/lib/helpers/tool-call-markup/strip.d.ts +4 -0
  82. package/dist-lib/lib/helpers/tool-call-markup/strip.js +149 -0
  83. package/dist-lib/lib/helpers/tool-call-markup.d.ts +19 -24
  84. package/dist-lib/lib/helpers/tool-call-markup.js +17 -343
  85. package/dist-lib/lib/machine/completion/actions/completion.d.ts +12 -18
  86. package/dist-lib/lib/machine/completion/actions/completion.js +19 -178
  87. package/dist-lib/lib/machine/completion/actions/goal.d.ts +10 -0
  88. package/dist-lib/lib/machine/completion/actions/goal.js +93 -0
  89. package/dist-lib/lib/machine/completion/actions/prepare.js +2 -1
  90. package/dist-lib/lib/machine/completion/actions/reject-tool.d.ts +16 -0
  91. package/dist-lib/lib/machine/completion/actions/reject-tool.js +147 -0
  92. package/dist-lib/lib/machine/completion/actions/retry-round.d.ts +6 -0
  93. package/dist-lib/lib/machine/completion/actions/retry-round.js +50 -0
  94. package/dist-lib/lib/machine/completion/actions/rounds.d.ts +5 -0
  95. package/dist-lib/lib/machine/completion/actions/rounds.js +31 -0
  96. package/dist-lib/lib/machine/completion/actions/tools.d.ts +1 -16
  97. package/dist-lib/lib/machine/completion/actions/tools.js +16 -161
  98. package/dist-lib/lib/machine/completion/context.js +3 -3
  99. package/dist-lib/lib/machine/completion/implementations.d.ts +2 -2
  100. package/dist-lib/lib/machine/completion/implementations.js +6 -2
  101. package/dist-lib/lib/machine/completion/machine.d.ts +2 -2
  102. package/dist-lib/lib/machine/completion/metrics.d.ts +25 -0
  103. package/dist-lib/lib/machine/completion/metrics.js +68 -0
  104. package/dist-lib/lib/machine/completion/nudges.d.ts +5 -0
  105. package/dist-lib/lib/machine/completion/nudges.js +33 -0
  106. package/dist-lib/lib/machine/completion/rules.d.ts +5 -34
  107. package/dist-lib/lib/machine/completion/rules.js +4 -120
  108. package/dist-lib/lib/machine/completion/splice.d.ts +9 -0
  109. package/dist-lib/lib/machine/completion/splice.js +19 -0
  110. package/dist-lib/lib/machine/completion/types.d.ts +4 -13
  111. package/dist-lib/lib/machine/index.d.ts +3 -3
  112. package/dist-lib/lib/machine/index.js +2 -2
  113. package/dist-lib/lib/media-host.js +2 -2
  114. package/dist-lib/lib/media-wire.js +2 -2
  115. package/dist-lib/lib/residency/completion-runtime.d.ts +2 -1
  116. package/dist-lib/lib/residency/completion-runtime.js +44 -1
  117. package/dist-lib/lib/residency/index.d.ts +3 -2
  118. package/dist-lib/lib/residency/index.js +2 -2
  119. package/dist-lib/lib/round-host.js +3 -3
  120. package/dist-lib/lib/round-port.js +3 -3
  121. package/dist-lib/lib/run-log/redact.js +7 -7
  122. package/dist-lib/lib/serve/completion.d.ts +7 -0
  123. package/dist-lib/lib/serve/completion.js +553 -0
  124. package/dist-lib/lib/serve/downloads.d.ts +4 -0
  125. package/dist-lib/lib/serve/downloads.js +79 -0
  126. package/dist-lib/lib/serve/models.d.ts +5 -0
  127. package/dist-lib/lib/serve/models.js +120 -0
  128. package/dist-lib/lib/serve/noop.d.ts +1 -0
  129. package/dist-lib/lib/serve/noop.js +1 -0
  130. package/dist-lib/lib/serve/requests.d.ts +147 -0
  131. package/dist-lib/lib/serve/requests.js +1 -0
  132. package/dist-lib/lib/serve/rounds.d.ts +11 -0
  133. package/dist-lib/lib/serve/rounds.js +67 -0
  134. package/dist-lib/lib/serve/run-log-start.d.ts +38 -0
  135. package/dist-lib/lib/serve/run-log-start.js +254 -0
  136. package/dist-lib/lib/serve/skills.d.ts +32 -0
  137. package/dist-lib/lib/serve/skills.js +46 -0
  138. package/dist-lib/lib/serve.d.ts +5 -1
  139. package/dist-lib/lib/serve.js +14 -1071
  140. package/dist-lib/lib/skills-host/index.d.ts +4 -2
  141. package/dist-lib/lib/skills-host/index.js +20 -8
  142. package/dist-lib/lib/tools/fs/drive.d.ts +1 -17
  143. package/dist-lib/lib/tools/fs/remote-protocol.d.ts +1 -81
  144. package/dist-lib/lib/tools/fs/scope.d.ts +2 -17
  145. package/dist-lib/lib/tools/fs/search.d.ts +2 -18
  146. package/dist-lib/lib/tools/fs/walk.d.ts +1 -5
  147. package/dist-lib/lib/tools/pdf/build.d.ts +2 -2
  148. package/dist-lib/lib/tools/pdf/recognize.js +4 -8
  149. package/dist-lib/lib/tools/pdf/request.d.ts +3 -8
  150. package/dist-lib/lib/tools/pdf/request.js +4 -4
  151. package/dist-lib/lib/tools/pdf.d.ts +0 -1
  152. package/dist-lib/lib/tools/pdf.js +0 -1
  153. package/dist-lib/lib/tools/skill.js +13 -4
  154. package/dist-lib/lib/tools/skills/bundled-dir.d.ts +3 -0
  155. package/dist-lib/lib/tools/skills/bundled-dir.js +27 -24
  156. package/dist-lib/lib/tools/skills/bundled-hash.d.ts +1 -0
  157. package/dist-lib/lib/tools/skills/bundled-hash.js +4 -1
  158. package/dist-lib/lib/tools/skills/catalog-loader.d.ts +12 -0
  159. package/dist-lib/lib/tools/skills/catalog-loader.js +173 -0
  160. package/dist-lib/lib/tools/skills/catalog.d.ts +5 -8
  161. package/dist-lib/lib/tools/skills/catalog.js +1 -162
  162. package/dist-lib/lib/tools/skills/index.d.ts +1 -0
  163. package/dist-lib/lib/tools/skills/index.js +1 -0
  164. package/dist-lib/lib/tools/skills/skill-tree.d.ts +5 -0
  165. package/dist-lib/lib/tools/skills/skill-tree.js +54 -0
  166. package/dist-lib/lib/wire/download.d.ts +10 -0
  167. package/dist-lib/lib/wire/download.js +35 -0
  168. package/dist-lib/lib/wire/event.d.ts +41 -0
  169. package/dist-lib/lib/wire/event.js +306 -0
  170. package/dist-lib/lib/wire/fields.d.ts +3 -0
  171. package/dist-lib/lib/wire/fields.js +12 -0
  172. package/dist-lib/lib/wire/knowledge.d.ts +9 -0
  173. package/dist-lib/lib/wire/knowledge.js +68 -0
  174. package/dist-lib/lib/wire/round.d.ts +14 -0
  175. package/dist-lib/lib/wire/round.js +45 -0
  176. package/dist-lib/lib/wire/vectors.d.ts +6 -0
  177. package/dist-lib/lib/wire/vectors.js +33 -0
  178. package/dist-lib/lib/wire.d.ts +28 -77
  179. package/dist-lib/lib/wire.js +24 -489
  180. package/dist-lib/plugins/ocr/coverage.d.ts +3 -0
  181. package/dist-lib/plugins/ocr/coverage.js +67 -0
  182. package/dist-lib/plugins/ocr/ocr-runtime.d.ts +4 -2
  183. package/dist-lib/plugins/ocr/ocr-runtime.js +25 -4
  184. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  185. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  186. package/dist-lib/schema/harness.js +4 -1
  187. package/dist-lib/spec/hrpc/messages.js +25 -1
  188. package/dist-lib/spec/hyperschema/index.js +25 -1
  189. package/dist-lib/spec/hyperschema/schema.json +6 -1
  190. package/dist-lib/spec/hyperschema/types.d.ts +1 -0
  191. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -21,6 +21,17 @@ breaking change is listed under Changed and Removed.
21
21
 
22
22
  ### Added
23
23
 
24
+ - Workspace skills run in every chat of the workspace. Send them as `workspaceSkills`, shaped like
25
+ `projectSkills`. On a name clash the project's skill wins over the workspace's, and the workspace's
26
+ over your own. A workspace skill with a script asks each member by its hash, as a project skill
27
+ does. (#727)
28
+
29
+ - A project's skills run in its chats over your own. Send each as `{ name, hash, files }`, with `hash`
30
+ from `hashSkillFiles`. The harness writes the tree under its hash and layers it over the sender's
31
+ skills, the project's copy wins on a name clash, and a skill that joins is on. A skill whose tree has not replicated is left out until a run brings its files.
32
+ Each project skill joins a run only after `approve` says yes to `<name>@<hash>`, in every
33
+ approval mode, so a changed skill asks again. (#726)
34
+
24
35
  - Image and music generation can run on a device that holds the model. A run
25
36
  that passes `mediaRound` has `generate_image`, `edit_image` and
26
37
  `generate_music` ask it for the model call, and the device with the model
@@ -83,6 +94,18 @@ breaking change is listed under Changed and Removed.
83
94
  [the decision record](docs/decisions/2026-11-03-a-scanned-pdf-page-is-read-by-ocr.md).
84
95
  (#768)
85
96
 
97
+ - A host that reads PDFs in its own process OCRs their scanned pages through
98
+ the harness. `pdfPages(bytes, { ocr, signal })` (`@qvac/harness/pdf-pages`)
99
+ returns each page's text, renders a scanned page in the host and marks it
100
+ `unread` when OCR fails, and `harness.ocrRead({ image, signal })` reads one
101
+ rendered page across the wire. `ocrRead` resolves an `OcrPage`,
102
+ `{ text, coverage }`: `coverage`, 0 to 1, is the share of the page's ink
103
+ inside the words read, near 1 on a typed page and under 0.5 on a chart or a
104
+ photo, so a host can give a model a high-coverage page as its text. Before
105
+ rc.21 it resolved the text alone. The harness keeps the last 1,024 pages it
106
+ read, so a scan indexed and then shown is read once. See
107
+ [docs/hosting.md](docs/hosting.md). (#789, #841)
108
+
86
109
  - Kwaipilot's KAT-Coder-V2.5-Dev (`Kwaipilot_KAT-Coder-V2.5-Dev-Q4_K_M`, 21.4 GB) is in the LLM catalog:
87
110
  a coding tune of the Qwen3.6-35B-A3B architecture, text only, `xhigh`, with the `qwen35` tool
88
111
  dialect. It and gpt-oss sample as their makers recommend: KAT-Coder at temp 1.0, top_p 0.95 and
@@ -3,7 +3,7 @@ import ReadyResource from 'ready-resource';
3
3
  import { Policy } from './lib/policy/index.ts';
4
4
  import type { EngineBoot, EngineStep, RecoveryResolution } from './lib/run-log/index.ts';
5
5
  import { type CompletionArgs, type ModelRoundIo, type ModelRoundPort, type ModelRoundRequest, type ModelRoundResult } from './lib/capabilities/completion-engine/index.ts';
6
- import type { AccessPolicy, AgentConfig, ApproveFn, AskUserFn, AttachFn, CompletionEvent, FetchAttachmentFn, MediaRoundIo, MediaRoundPort, MediaRoundRequest, MediaRoundResult, Message, ProgressFn, ResponseFormat, RunGoal, RunInput, ShowImageFn, ToolDefinition, ToolExecuteContext } from './lib/contract/index.ts';
6
+ import type { AccessPolicy, AgentConfig, ApproveFn, AskUserFn, AttachFn, CompletionEvent, FetchAttachmentFn, MediaRoundIo, MediaRoundPort, MediaRoundRequest, MediaRoundResult, Message, ProgressFn, WorkspaceSkill, ResponseFormat, RunGoal, RunInput, ShowImageFn, ToolDefinition, ToolExecuteContext, ProjectSkill } from './lib/contract/index.ts';
7
7
  import { type DetectLanguageContext, type DetectedLanguage } from './lib/capabilities/detect-language.ts';
8
8
  import { type Capability } from './lib/capabilities/invoke.ts';
9
9
  import { type ModelSourcePreview, type PreviewModelSourceContext } from './lib/capabilities/preview-model-source.ts';
@@ -12,7 +12,7 @@ import { type DownloadArgs, type DownloadEventStream } from './lib/capabilities/
12
12
  import type { EmbedContext } from './lib/capabilities/embed.ts';
13
13
  import { type KvCacheDeletionResult } from './lib/capabilities/kv-cache.ts';
14
14
  import type { LlmGenerationParams } from './lib/models/llm-presets.ts';
15
- import type { OcrReadContext } from './lib/contract/ocr.ts';
15
+ import type { OcrPage, OcrReadContext } from './lib/contract/ocr.ts';
16
16
  import type { SpeakContext, SpeakResult, SpeakStreamContext, TranscribeContext } from './lib/contract/speech.ts';
17
17
  import type { CapabilityInfo, CredentialEntry, HarnessDiagnostics, InfraModel, LoadModelResult, MemoryUsage, SkillWriteResult, UnloadModelContext, UnloadModelResult } from './lib/contract-types.ts';
18
18
  import { type CustomModelEntry } from './lib/models/model-catalog.ts';
@@ -45,7 +45,7 @@ export type { ModelSourceFile, ModelSourcePreview, ModelSourceRefusal, PreviewMo
45
45
  export type { ModelFitBasis, ModelFitEvidence, ModelFitVerdict } from './lib/models/model-fit.ts';
46
46
  export * from './lib/capabilities/download.ts';
47
47
  export type { EmbedContext } from './lib/capabilities/embed.ts';
48
- export type { OcrImage, OcrReadContext, OcrService } from './lib/contract/ocr.ts';
48
+ export type { OcrImage, OcrPage, OcrReadContext, OcrService } from './lib/contract/ocr.ts';
49
49
  export type { SpeakContext, SpeakResult, SpeakStreamContext, SpeechService, TranscribeContext } from './lib/contract/speech.ts';
50
50
  export type { EmbedDevice } from './lib/models/embed-config.ts';
51
51
  export type { MemoryBudget } from './lib/hardware/memory-budget.ts';
@@ -69,7 +69,7 @@ export type { ConnectOptions, HostRunLog, HostRunLogLease } from './lib/connect.
69
69
  export type { KvCacheDeletionResult } from './lib/capabilities/kv-cache.ts';
70
70
  export type { AgentKnobs, ApprovalCall, ChatMessage, CredentialEntry, DownloadContext, HarnessContract, HarnessDiagnostics, HarnessEvent, HarnessInfo, HarnessStatus, InfraModel, LoadedModel, LoadFit, ModelState, SkillsOptions, SkillWriteResult } from './lib/contract-types.ts';
71
71
  import type { DownloadsAllowedOptions, HarnessInfo } from './lib/contract-types.ts';
72
- export { serveHarness } from './lib/serve.ts';
72
+ export declare const serveHarness: (stream: import("./lib/rpc-session.ts").Stream, harness: import("./index.ts").HarnessContract) => void;
73
73
  export { HarnessLog };
74
74
  export type { LogLevel } from './lib/log.ts';
75
75
  export declare const harnessLog: typeof HarnessLog;
@@ -137,6 +137,8 @@ export interface CompletionContext {
137
137
  recovery?: RecoveryResolution[];
138
138
  model: string;
139
139
  agent?: AgentConfig;
140
+ projectSkills?: readonly ProjectSkill[];
141
+ workspaceSkills?: readonly WorkspaceSkill[];
140
142
  agents?: Record<string, AgentConfig>;
141
143
  messages: Message[];
142
144
  typedText?: string;
@@ -288,7 +290,7 @@ export declare class Harness extends ReadyResource {
288
290
  knowledgeStatus(): Promise<KnowledgeStatus>;
289
291
  transcribe(context: TranscribeContext): Promise<string>;
290
292
  private _transcribe;
291
- ocrRead({ image, signal }: OcrReadContext): Promise<string>;
293
+ ocrRead({ image, signal }: OcrReadContext): Promise<OcrPage>;
292
294
  private _ocrService;
293
295
  detectLanguage(context: DetectLanguageContext): Promise<DetectedLanguage[]>;
294
296
  speak(context: SpeakContext): Promise<SpeakResult>;
package/dist-lib/index.js CHANGED
@@ -32,8 +32,9 @@ import { Residency } from './lib/residency/index.js';
32
32
  import { toolCatalog } from './lib/tools/catalog.js';
33
33
  import { SkillsHost } from './lib/skills-host/index.js';
34
34
  import { errorMessage, isRecord } from './lib/guards.js';
35
- import { redactedRecoveryFields } from './lib/wire.js';
35
+ import { Wire } from './lib/wire.js';
36
36
  import { HarnessLog } from './lib/log.js';
37
+ import { HarnessServer } from './lib/serve.js';
37
38
  import { installResolutionDetector, resolutionDetail } from './lib/resolution-detector.js';
38
39
  import { bareRuntime } from './lib/tools/exec/bare-runtime.js';
39
40
  import { runCommand } from './lib/tools/exec/runner.js';
@@ -58,7 +59,7 @@ export { markCredentialRejected, markCredentialValid, recordCredentialHealth, re
58
59
  export { readSetup as normalizeSkillSetup } from './lib/tools/skills/manifest-parse.js';
59
60
  export { isAvailableState, SKILL_STATE } from './lib/tools/skills/skill-state.js';
60
61
  export { connectHarness, HARNESS_DIED, RemoteHarness } from './lib/connect.js';
61
- export { serveHarness } from './lib/serve.js';
62
+ export const serveHarness = HarnessServer.serve;
62
63
  export { HarnessLog };
63
64
  export const harnessLog = HarnessLog;
64
65
  export const hlog = HarnessLog.info;
@@ -228,7 +229,7 @@ export class Harness extends ReadyResource {
228
229
  ],
229
230
  unloadIdlePlugins: () => this._plugins.unloadIdle(),
230
231
  tools: () => this._tools,
231
- skills: (agentId, model) => this._skills.completionSkills(agentId, model),
232
+ skills: (agentId, model, trees) => this._skills.completionSkills(agentId, model, trees),
232
233
  platform: () => this._skills.platform
233
234
  });
234
235
  this._embeddings = new Embeddings({
@@ -1071,7 +1072,7 @@ function completionErrorDetails(error) {
1071
1072
  if (!isRecord(error))
1072
1073
  return {};
1073
1074
  if (error.code === 'PENDING_ARGS_REDACTED') {
1074
- return { code: 'PENDING_ARGS_REDACTED', ...redactedRecoveryFields(error) };
1075
+ return { code: 'PENDING_ARGS_REDACTED', ...Wire.redactedRecoveryFields(error) };
1075
1076
  }
1076
1077
  if (error.name !== 'RunIncompatible') {
1077
1078
  return {};
@@ -14,9 +14,10 @@ export function resolveAgent(request, ports) {
14
14
  ...fsWriteRoots,
15
15
  ...fsRoots.filter((root) => root.kind === 'hyper' && root.writable && !fsWriteRoots.includes(root))
16
16
  ];
17
+ const layered = request.skills.filter((skill) => skill.layered).map((skill) => skill.name);
17
18
  const toggles = {
18
19
  skillsSelected: skillsAreSelected(agent?.skillsScope, Boolean(agent)),
19
- enabledSkills: agent?.enabledSkills ?? []
20
+ enabledSkills: [...(agent?.enabledSkills ?? []), ...layered]
20
21
  };
21
22
  const activeSkills = request.skills.filter((skill) => skillIsActive(skill.name, toggles));
22
23
  const unreadySkills = toggles.skillsSelected
@@ -1,5 +1,5 @@
1
1
  import { assembleAnswer } from './stream.js';
2
- import { stripToolCallMarkup } from '../../../helpers/tool-call-markup.js';
2
+ import { ToolCallMarkup } from '../../../helpers/tool-call-markup.js';
3
3
  export const answering = async function answering({ emit, input: { session }, context }) {
4
4
  const round = context.lastRound;
5
5
  let response;
@@ -12,7 +12,7 @@ export const answering = async function answering({ emit, input: { session }, co
12
12
  response = round.response;
13
13
  }
14
14
  else {
15
- const replay = round.replay ? stripToolCallMarkup(round.replay) : '';
15
+ const replay = round.replay ? ToolCallMarkup.stripToolCallMarkup(round.replay) : '';
16
16
  response = await assembleAnswer({
17
17
  contentText: round.contentText,
18
18
  replay,
@@ -3,7 +3,7 @@ import { Agent } from '../../../agent/index.js';
3
3
  import { DIRECT_CALL_ID } from '../../tool-turns.js';
4
4
  import { approvalGate, trustedSources } from './execution-plan.js';
5
5
  import { detachJson } from '../../../helpers/detach-json.js';
6
- import { ruleInputs } from '../tool-execution.js';
6
+ import { ruleInputs } from '../tool-preflight.js';
7
7
  import { deniedWithoutApprover, gateRejection, policyActivity } from './rejection.js';
8
8
  export const directSearch = async function directSearch({ input: deps, context }) {
9
9
  return {
@@ -1,4 +1,4 @@
1
- import { type ToolPreflight } from '../tool-execution.ts';
1
+ import type { ToolPreflight } from '../tool-preflight.ts';
2
2
  import type { OutboundGuard, ToolActivityEvent, ToolCallDisplay, ToolDefinition, ToolExecuteContext, ToolExecutionOutcome } from '../../../contract/index.ts';
3
3
  import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
4
4
  import type { ToolPolicySources } from './execution-plan.ts';
@@ -1,7 +1,9 @@
1
1
  import { Agent } from '../../../agent/index.js';
2
2
  import { AbortedError } from '../../../helpers/race-abort.js';
3
3
  import { spliceFrom } from '../splice.js';
4
- import { answerOf, callSucceeded, readyPreflightFromFacts, reportFailure, settledFailure } from '../tool-execution.js';
4
+ import { reportFailure } from '../tool-execution.js';
5
+ import { answerOf, callSucceeded, settledFailure } from '../tool-outcome.js';
6
+ import { readyPreflightFromFacts } from '../tool-preflight.js';
5
7
  import { directToolHistory } from '../turns.js';
6
8
  import { labelOf } from '../loop.js';
7
9
  import { attachedFiles, DIRECT_CALL_ID, FAILURE_STREAK, TOOL_FAILING_MESSAGE, deliversFile, historyPayload, materializeCompletionHistory, withHookContext, toolResultHistoryEntry, toolResultTurn } from '../../tool-turns.js';
@@ -12,7 +14,7 @@ import { toolCaller } from '../tool-caller.js';
12
14
  import { loadSkill } from './loading-skill.js';
13
15
  import { CompletionMachine } from '../../../machine/index.js';
14
16
  import { failureResultRef, storeFailureResult } from '../../../helpers/failure-result.js';
15
- import { namesPath, provesResult, runsCheck, writtenTexts } from '../../../helpers/goal-check.js';
17
+ import { GoalCheck } from '../../../helpers/goal-check.js';
16
18
  const CHECK_OUTPUT_CHARS = 2000;
17
19
  export const executing = async function executing(input) {
18
20
  const { emit, input: deps, context } = input;
@@ -252,7 +254,7 @@ export function settleCall({ input: { session }, context }, { ran, direct, emit
252
254
  }
253
255
  function checksRun({ goal }, { command, passed, output }) {
254
256
  const ran = typeof command === 'string' && goal
255
- ? goal.checks.filter((check) => runsCheck(command, check.name))
257
+ ? goal.checks.filter((check) => GoalCheck.runsCheck(command, check.name))
256
258
  : [];
257
259
  if (!ran.length) {
258
260
  return undefined;
@@ -265,13 +267,13 @@ function writtenScripts({ goal }, args) {
265
267
  }
266
268
  const { deliverable } = goal;
267
269
  const fragment = typeof args.content !== 'string' && typeof args.new === 'string';
268
- const wrote = writtenTexts(args).map(([path, text]) => deliverable
269
- ? { path, proving: namesPath(text, deliverable) || (fragment ? undefined : false) }
270
+ const wrote = GoalCheck.writtenTexts(args).map(([path, text]) => deliverable
271
+ ? { path, proving: GoalCheck.namesPath(text, deliverable) || (fragment ? undefined : false) }
270
272
  : { path });
271
273
  return wrote.length ? wrote : undefined;
272
274
  }
273
275
  function proofRun(command, output) {
274
- const name = typeof command === 'string' ? provesResult(command) : undefined;
276
+ const name = typeof command === 'string' ? GoalCheck.provesResult(command) : undefined;
275
277
  return name ? { name, passed: true, output: outputTail(output) } : undefined;
276
278
  }
277
279
  function outputTail(output) {
@@ -1,7 +1,7 @@
1
1
  import { Agent } from '../../../agent/index.js';
2
2
  import { labelOf } from '../loop.js';
3
3
  import { detachJson } from '../../../helpers/detach-json.js';
4
- import { inspectToolPolicy } from '../tool-execution.js';
4
+ import { inspectToolPolicy } from '../tool-preflight.js';
5
5
  import { modelTurns, trustedSourcesFrom } from '../turns.js';
6
6
  import { skillNameOf } from '../../tool-plan.js';
7
7
  import { unreadySkillState } from '../../skill-entry.js';
@@ -1,6 +1,6 @@
1
1
  import { AbortedError } from '../../../helpers/race-abort.js';
2
2
  import { copy } from '../../../helpers/copy.js';
3
- import { inspectToolPolicy, ruleInputs } from '../tool-execution.js';
3
+ import { inspectToolPolicy, ruleInputs } from '../tool-preflight.js';
4
4
  import { toolContext, trustedSources } from './execution-plan.js';
5
5
  export function inspectPrepare(source) {
6
6
  return async function inspectPrepare({ input: deps, context }) {
@@ -1,7 +1,8 @@
1
1
  import { AbortedError } from '../../../helpers/race-abort.js';
2
2
  import { spliceFrom } from '../splice.js';
3
3
  import { labelOf, skillEmojiFrom } from '../loop.js';
4
- import { readyPreflightFromFacts, reportFailure } from '../tool-execution.js';
4
+ import { reportFailure } from '../tool-execution.js';
5
+ import { readyPreflightFromFacts } from '../tool-preflight.js';
5
6
  import { skillFileKey } from '../../tool-plan.js';
6
7
  import { toolResultTurn } from '../../tool-turns.js';
7
8
  import { skillLoadTurns } from '../../sdk-tool.js';
@@ -15,7 +15,7 @@ import { logToolPrompt } from '../../tool-prompt-log.js';
15
15
  import { toolContext } from './execution-plan.js';
16
16
  import { knowledgeSearch } from './retrieving.js';
17
17
  import { detachJson } from '../../../helpers/detach-json.js';
18
- import { asksChecks, GOAL_CHECKS_ASK, GOAL_PROOF_ASK } from '../../../helpers/goal-check.js';
18
+ import { GoalCheck } from '../../../helpers/goal-check.js';
19
19
  function offeredTools(tools, model) {
20
20
  const profile = model ? modelNameToCapabilityProfile(model) : undefined;
21
21
  return tools.filter(({ minCapabilityProfile: min }) => !min || (profile !== undefined && meetsMinCapabilityProfile(profile, min)));
@@ -38,10 +38,15 @@ function takesCommand(tools) {
38
38
  return tools.some((tool) => 'command' in tool.parameters.properties);
39
39
  }
40
40
  function checksAsk({ goal }, checkable) {
41
- if (!goal || !asksChecks({ ...goal, checkable })) {
41
+ if (!goal || !GoalCheck.asksChecks({ ...goal, checkable })) {
42
42
  return [];
43
43
  }
44
- return [{ role: 'user', content: goal.checks.length ? GOAL_PROOF_ASK : GOAL_CHECKS_ASK }];
44
+ return [
45
+ {
46
+ role: 'user',
47
+ content: goal.checks.length ? GoalCheck.GOAL_PROOF_ASK : GoalCheck.GOAL_CHECKS_ASK
48
+ }
49
+ ];
45
50
  }
46
51
  export function preparing(source) {
47
52
  return ({ input, context, reconstruct, emit }) => prepare({ input, context, reconstruct, source, emit });
@@ -2,7 +2,7 @@ import { Agent } from '../../../agent/index.js';
2
2
  import { spliceFrom } from '../splice.js';
3
3
  import { AbortedError } from '../../../helpers/race-abort.js';
4
4
  import { HarnessLog } from '../../../log.js';
5
- import { MALFORMED_CALL_ID, stripToolCallMarkup } from '../../../helpers/tool-call-markup.js';
5
+ import { ToolCallMarkup } from '../../../helpers/tool-call-markup.js';
6
6
  import { toolResultTurn } from '../../tool-turns.js';
7
7
  import { loadTurns, unloadedTools } from '../../sdk-tool.js';
8
8
  import { assistantToolTurn } from '../turns.js';
@@ -65,7 +65,7 @@ function firstOfEach(calls, session) {
65
65
  });
66
66
  }
67
67
  function answerFacts({ round, context, session }) {
68
- const replay = round.replay ? stripToolCallMarkup(round.replay) : '';
68
+ const replay = round.replay ? ToolCallMarkup.stripToolCallMarkup(round.replay) : '';
69
69
  const spoken = round.contentText.trim();
70
70
  const cutOff = session.enabled.length > 0 && !replay && CompletionMachine.atContextBoundary(round);
71
71
  const narrated = session.enabled.length && !replay && !cutOff && narratedIntent(spoken) ? spoken : undefined;
@@ -102,7 +102,10 @@ function malformedCallTurns({ round, context, session }) {
102
102
  return spliceFrom(context.history, [
103
103
  ...context.history,
104
104
  { role: 'assistant', content: said.filter(Boolean).join('\n') },
105
- { role: 'tool', content: toolResultTurn('tool_call', MALFORMED_CALL_ID, { error }) },
105
+ {
106
+ role: 'tool',
107
+ content: toolResultTurn('tool_call', ToolCallMarkup.MALFORMED_CALL_ID, { error })
108
+ },
106
109
  { role: 'user', content: context.policy.continuationNudge }
107
110
  ]);
108
111
  }
@@ -118,7 +121,10 @@ function repeatedCallTurn(context) {
118
121
  }
119
122
  function cutTailTurn(context, round) {
120
123
  const error = { error: CompletionMachine.cutOffMessage(context.policy, round) };
121
- return { role: 'tool', content: toolResultTurn('tool_call', MALFORMED_CALL_ID, error) };
124
+ return {
125
+ role: 'tool',
126
+ content: toolResultTurn('tool_call', ToolCallMarkup.MALFORMED_CALL_ID, error)
127
+ };
122
128
  }
123
129
  function cutCallId(round) {
124
130
  return CompletionMachine.cutShort(round) && !round.toolErrors?.length
@@ -1,5 +1,6 @@
1
1
  import { AbortedError } from '../../../helpers/race-abort.js';
2
- import { executeCall, readyPreflightFromFacts } from '../tool-execution.js';
2
+ import { executeCall } from '../tool-execution.js';
3
+ import { readyPreflightFromFacts } from '../tool-preflight.js';
3
4
  import { errorMessage } from '../../../guards.js';
4
5
  import { toolContext } from './execution-plan.js';
5
6
  import { detachJson } from '../../../helpers/detach-json.js';
@@ -3,7 +3,7 @@ import { carriesRunOnlyText } from '../turns.js';
3
3
  import { runRound } from './stream.js';
4
4
  import { foldTokens } from '../round.js';
5
5
  import { truncateAtControlToken } from '../../../helpers/control-tokens.js';
6
- import { clipRawCall, recoverMarkupToolCalls, recoverPrintedSkillLoad, recoverSkillNamedCall, stripToolResponseBlocks } from '../../../helpers/tool-call-markup.js';
6
+ import { ToolCallMarkup } from '../../../helpers/tool-call-markup.js';
7
7
  import { unquoteArg } from '../../../helpers/model-args.js';
8
8
  import { Agent } from '../../../agent/index.js';
9
9
  import { loadedTools } from '../../sdk-tool.js';
@@ -13,7 +13,7 @@ import { HarnessLog } from '../../../log.js';
13
13
  import { toolDialectFor } from '../../../models/model-catalog.js';
14
14
  import { loadedSkills } from '../session.js';
15
15
  import { CompletionMachine } from '../../../machine/index.js';
16
- import { responseRoomChars } from '../../../context-window.js';
16
+ import { ContextWindow } from '../../../context-window.js';
17
17
  export const streaming = async function streaming({ emit, input: { sdk, args, session, operations }, context }) {
18
18
  const { recovered, promptPrefix, thinkingText, durationMs } = await generateStreamingRound({
19
19
  sdk,
@@ -69,7 +69,7 @@ function roundToolErrors(errors) {
69
69
  return errors.map(({ code, message, raw }) => ({
70
70
  code,
71
71
  message,
72
- raw: raw === undefined ? undefined : clipRawCall(raw)
72
+ raw: raw === undefined ? undefined : ToolCallMarkup.clipRawCall(raw)
73
73
  }));
74
74
  }
75
75
  async function generateStreamingRound({ sdk, args, session, operations, context, emit }) {
@@ -92,7 +92,7 @@ async function generateStreamingRound({ sdk, args, session, operations, context,
92
92
  emit(event);
93
93
  }
94
94
  });
95
- session.runBudget.responseRoomChars = responseRoomChars(recovered.ctxSize ?? args.ctxSize, recovered.final.stats?.cacheTokens);
95
+ session.runBudget.responseRoomChars = ContextWindow.responseRoomChars(recovered.ctxSize ?? args.ctxSize, recovered.final.stats?.cacheTokens);
96
96
  const durationMs = Date.now() - prepared.startedAt;
97
97
  logRoundStats({ round: context.round, durationMs, recovered });
98
98
  const promptPrefix = recovered.history
@@ -208,10 +208,10 @@ function plans(history) {
208
208
  return true;
209
209
  }
210
210
  function recoverToolCalls({ recovered, session, round }) {
211
- const markup = stripToolResponseBlocks(truncateAtControlToken(recovered.final.raw.fullText) || recovered.unproven || '');
211
+ const markup = ToolCallMarkup.stripToolResponseBlocks(truncateAtControlToken(recovered.final.raw.fullText) || recovered.unproven || '');
212
212
  let calls = recovered.final.toolCalls?.length
213
213
  ? recovered.final.toolCalls
214
- : recoverMarkupToolCalls(markup, session.enabled);
214
+ : ToolCallMarkup.recoverMarkupToolCalls(markup, session.enabled);
215
215
  if (!calls.length) {
216
216
  calls = recoverPrintedSkill(markup, session, round);
217
217
  }
@@ -224,7 +224,7 @@ function recoverPrintedSkill(markup, session, round) {
224
224
  if (!session.enabled.some((tool) => tool.name === Agent.SKILL_TOOL_NAME)) {
225
225
  return [];
226
226
  }
227
- const rescued = recoverPrintedSkillLoad(markup, Agent.SKILL_TOOL_NAME);
227
+ const rescued = ToolCallMarkup.recoverPrintedSkillLoad(markup, Agent.SKILL_TOOL_NAME);
228
228
  const rescuedArgs = rescued[0]?.arguments;
229
229
  const alreadyLoaded = rescuedArgs !== undefined &&
230
230
  (session.loadedSkillFiles
@@ -243,7 +243,7 @@ function recoverNamedSkill(markup, session, round) {
243
243
  if (!session.enabled.some((tool) => tool.name === Agent.SKILL_TOOL_NAME)) {
244
244
  return [];
245
245
  }
246
- const calls = recoverSkillNamedCall(markup, session.inContextSkills
246
+ const calls = ToolCallMarkup.recoverSkillNamedCall(markup, session.inContextSkills
247
247
  .filter((skill) => !session.nudgedSkills.has(skill.name))
248
248
  .map((skill) => skill.name), Agent.SKILL_TOOL_NAME);
249
249
  for (const call of calls) {
@@ -3,7 +3,7 @@ import { carriesRunOnlyText } from '../turns.js';
3
3
  import { runRound } from './stream.js';
4
4
  import { roundFold } from './streaming.js';
5
5
  import { degenerateAnswer } from '../../../helpers/run-outcome.js';
6
- import { stripToolCallMarkup } from '../../../helpers/tool-call-markup.js';
6
+ import { ToolCallMarkup } from '../../../helpers/tool-call-markup.js';
7
7
  import { materializeCompletionHistory } from '../../tool-turns.js';
8
8
  import { requestPromptPrefix } from '../../prompt-prefix.js';
9
9
  import { toolDialectFor } from '../../../models/model-catalog.js';
@@ -47,7 +47,7 @@ export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session,
47
47
  });
48
48
  const durationMs = Date.now() - startedAt;
49
49
  const cutOff = CompletionMachine.atContextBoundary(recovered.final);
50
- const replay = !cutOff && recovered.replay?.trim() ? stripToolCallMarkup(recovered.replay) : '';
50
+ const replay = !cutOff && recovered.replay?.trim() ? ToolCallMarkup.stripToolCallMarkup(recovered.replay) : '';
51
51
  const contentText = !cutOff && recovered.contentText.trim() ? recovered.contentText : '';
52
52
  if (cutOff) {
53
53
  emit({
@@ -2,7 +2,7 @@ import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
2
2
  import type { RecoveryResolution } from '../../run-log/index.ts';
3
3
  import type { KnowledgeGrant } from '../../contract/knowledge.ts';
4
4
  import type { GuidelineWording, MediaRoundPort, ToolCallDisplay } from '../../contract/index.ts';
5
- import type { AgentConfig, AccessPolicy, CompiledPolicy, CompletionEvent, ApproveFn, AskUserFn, AttachFn, DriveRoot, FetchAttachmentFn, LlmGenerationParams, Message, ProgressFn, ResponseFormat, RunBudget, RunGoal, RunInput, RoundModelLease, ShowImageFn, ToolDefinition, ToolExecuteContext } from '../../contract/index.ts';
5
+ import type { AgentConfig, AccessPolicy, CompiledPolicy, CompletionEvent, ApproveFn, AskUserFn, AttachFn, DriveRoot, FetchAttachmentFn, LlmGenerationParams, Message, ProgressFn, ResponseFormat, RunBudget, RunGoal, RunInput, RoundModelLease, ShowImageFn, ToolDefinition, SkillTree, ToolExecuteContext } from '../../contract/index.ts';
6
6
  import type { CompletionSkillEntry } from '../skill-entry.ts';
7
7
  import type { ModelRoundPort } from './model-round.ts';
8
8
  export interface CompletionArgs {
@@ -30,6 +30,7 @@ export interface CompletionArgs {
30
30
  tools?: ToolDefinition[];
31
31
  skillCatalog?: readonly CompletionSkillEntry[];
32
32
  platform?: string | undefined;
33
+ skillTrees?: ReadonlyMap<string, SkillTree>;
33
34
  approve?: ApproveFn;
34
35
  attach?: AttachFn;
35
36
  fetchAttachment?: FetchAttachmentFn;
@@ -77,4 +78,4 @@ export declare function createRunBudget(startedAt: number, ms?: number): RunBudg
77
78
  export type ToolContextFactory = (turnImages?: {
78
79
  path: string;
79
80
  }[], ctxSize?: number, signal?: BareAbortSignal) => ToolExecuteContext;
80
- export declare function runToolContext(args: Pick<CompletionArgs, 'agent' | 'attach' | 'fetchAttachment' | 'progress' | 'askUser' | 'mediaRound' | 'signal' | 'fsRoots' | 'fsWriteRoots' | 'session' | 'cacheKey'>, runBudget: RunBudget): ToolContextFactory;
81
+ export declare function runToolContext(args: Pick<CompletionArgs, 'agent' | 'attach' | 'fetchAttachment' | 'progress' | 'askUser' | 'mediaRound' | 'signal' | 'fsRoots' | 'fsWriteRoots' | 'session' | 'cacheKey' | 'skillTrees'>, runBudget: RunBudget): ToolContextFactory;
@@ -35,6 +35,7 @@ export function runToolContext(args, runBudget) {
35
35
  return (turnImages = [], ctxSize, invocationSignal) => {
36
36
  const context = {
37
37
  agentId: agent?.id ?? null,
38
+ skillTrees: args.skillTrees,
38
39
  ctxSize,
39
40
  fsRoots: args.fsRoots ?? [],
40
41
  fsWriteRoots: args.fsWriteRoots ?? [],
@@ -1,4 +1,4 @@
1
- import { compactedFrom, contextCandidates, TOOL_SEARCH_RESULT } from '../../context-window.js';
1
+ import { ContextWindow } from '../../context-window.js';
2
2
  import { Agent } from '../../agent/index.js';
3
3
  import { HarnessError } from '../../errors.js';
4
4
  import { bufferBurst } from '../../helpers/buffer-burst.js';
@@ -7,7 +7,7 @@ import { createMarkupStreamFilter } from '../../helpers/markup-stream-filter.js'
7
7
  import { AbortedError, raceAbort } from '../../helpers/race-abort.js';
8
8
  import { raceTimeout } from '../../helpers/race-timeout.js';
9
9
  import { withoutRepeatedReply } from '../../helpers/repeated-reply.js';
10
- import { recoverMarkupToolCalls } from '../../helpers/tool-call-markup.js';
10
+ import { ToolCallMarkup } from '../../helpers/tool-call-markup.js';
11
11
  import { splitThinking, tapThinking } from '../../helpers/thinking.js';
12
12
  import { errorMessage } from '../../guards.js';
13
13
  import { HarnessLog } from '../../log.js';
@@ -20,7 +20,7 @@ import { completionParams } from '../../helpers/completion-params.js';
20
20
  import { requestPromptPrefix } from '../prompt-prefix.js';
21
21
  import { renderedTools } from '../sdk-tool.js';
22
22
  import { isFailureResultReference } from '../../helpers/failure-result.js';
23
- import { GOAL_CHECKS_ASK, GOAL_PROOF_ASK, GOAL_REVIEW_ASK } from '../../helpers/goal-check.js';
23
+ import { GoalCheck } from '../../helpers/goal-check.js';
24
24
  import { Fold } from '../../fold/index.js';
25
25
  import { CompletionMachine } from '../../machine/index.js';
26
26
  import { modelTurns } from './turns.js';
@@ -141,7 +141,7 @@ function watchMarkupCalls(state, knownTools, cancelThisRound) {
141
141
  if (state.runaway)
142
142
  return;
143
143
  blocks++;
144
- const parsed = recoverMarkupToolCalls(body, knownTools).map((call) => [
144
+ const parsed = ToolCallMarkup.recoverMarkupToolCalls(body, knownTools).map((call) => [
145
145
  call.name,
146
146
  call.arguments
147
147
  ]);
@@ -354,7 +354,7 @@ async function* runRecoveredRoundWith(send) {
354
354
  }
355
355
  async function* runLadder({ send, history, origins, fold }) {
356
356
  let lastOverflow = null;
357
- const candidates = contextCandidates(history, ...harnessTurns(send.args, history));
357
+ const candidates = ContextWindow.contextCandidates(history, ...harnessTurns(send.args, history));
358
358
  for (const candidate of candidates) {
359
359
  const outcome = yield* runCandidateAttempts({ ...send, candidate, history, origins });
360
360
  if ('round' in outcome) {
@@ -399,7 +399,7 @@ function harnessTurns(args, history) {
399
399
  }
400
400
  function goalTurns(args) {
401
401
  const goal = args.goalNudge === undefined ? [] : [args.goalNudge];
402
- return [...goal, GOAL_CHECKS_ASK, GOAL_PROOF_ASK, GOAL_REVIEW_ASK];
402
+ return [...goal, GoalCheck.GOAL_CHECKS_ASK, GoalCheck.GOAL_PROOF_ASK, GoalCheck.GOAL_REVIEW_ASK];
403
403
  }
404
404
  async function foldRounds(send, history) {
405
405
  const { sdk, args, ctxSize } = send;
@@ -432,7 +432,7 @@ async function foldRounds(send, history) {
432
432
  }
433
433
  function keepsLoad(message) {
434
434
  return (message.role === 'tool' &&
435
- (message.content.startsWith(TOOL_SEARCH_RESULT) ||
435
+ (message.content.startsWith(ContextWindow.TOOL_SEARCH_RESULT) ||
436
436
  message.content.startsWith(`[Tool: ${Agent.SKILL_TOOL_NAME} (`)));
437
437
  }
438
438
  async function* foldChat(send, history) {
@@ -823,7 +823,7 @@ function logCandidateFinal({ state, final, contentText }, replay) {
823
823
  }
824
824
  function failureTurns(args, origins, sent) {
825
825
  return sent.flatMap((message, at) => {
826
- const source = compactedFrom(message);
826
+ const source = ContextWindow.compactedFrom(message);
827
827
  const entry = origins.get(source ?? message)?.entry;
828
828
  if (!entry || !isFailureResultReference(entry)) {
829
829
  return [];
@@ -835,7 +835,7 @@ function failureTurns(args, origins, sent) {
835
835
  }
836
836
  function restoreHistory(messages, origins) {
837
837
  return messages.map((message) => {
838
- const source = compactedFrom(message);
838
+ const source = ContextWindow.compactedFrom(message);
839
839
  const origin = origins.get(source ?? message);
840
840
  if (!origin || stableStringify(source ?? message) !== origin.fingerprint) {
841
841
  return message;
@@ -7,7 +7,9 @@ import { historyPayload } from '../tool-turns.js';
7
7
  import { defers, TOOL_SEARCH_TOOL_NAME, unloadedTools } from '../sdk-tool.js';
8
8
  import { labelOf } from './loop.js';
9
9
  import { ToolPolicyChanged } from './operations.js';
10
- import { callSucceeded, executeCall, preflightToolCall, reportFailure, ruleInputs } from './tool-execution.js';
10
+ import { executeCall, reportFailure } from './tool-execution.js';
11
+ import { callSucceeded } from './tool-outcome.js';
12
+ import { preflightToolCall, ruleInputs } from './tool-preflight.js';
11
13
  import { toolContext, trustedSources } from './actors/execution-plan.js';
12
14
  export const MAX_SCRIPT_CALLS = 16;
13
15
  function callable(tool) {
@@ -1,13 +1,10 @@
1
1
  import type { ToolCallWithCall } from '@qvac/inference';
2
2
  import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
3
3
  import type { HookPipeline } from '../../hooks/index.ts';
4
- import type { NetworkMode, PreToolCallPayload, ToolFailurePayload } from '../../contract/index.ts';
5
- import type { ApproveFn, OutboundGuard, ResolvedCall, ResourceDescriptor, ToolActivityFn, ToolCallDisplay, ToolDefinition, ToolEffect, ToolExecuteContext, ToolExecutionOutcome, TrustedSource, TrustedSourceFacts } from '../../contract/index.ts';
6
- import type { ToolPreflightFacts } from './stages.ts';
7
- export declare function callSucceeded(result: unknown, outcome: ToolExecutionOutcome): boolean;
8
- export declare function answerOf(result: unknown): string | undefined;
9
- export declare function settledFailure(result: unknown, outcome: ToolExecutionOutcome): boolean;
10
- export interface ExecuteCallOptions {
4
+ import type { NetworkMode, ToolFailurePayload } from '../../contract/index.ts';
5
+ import type { ApproveFn, OutboundGuard, ResolvedCall, ToolActivityFn, ToolCallDisplay, ToolDefinition, ToolEffect, ToolExecuteContext, ToolExecutionOutcome, TrustedSource, TrustedSourceFacts } from '../../contract/index.ts';
6
+ import { type ToolPreflight } from './tool-preflight.ts';
7
+ interface ExecuteCallOptions {
11
8
  runId: string;
12
9
  deniedMessage: string;
13
10
  approve?: ApproveFn | undefined;
@@ -30,42 +27,9 @@ export interface ExecutedCall {
30
27
  readonly outcome: ToolExecutionOutcome;
31
28
  readonly executed: boolean;
32
29
  }
33
- export type ToolPreflight = {
34
- status: 'blocked';
35
- reason: 'validation' | 'refusal';
36
- result: unknown;
37
- effect: ToolEffect;
38
- } | {
39
- status: 'denied';
40
- result: {
41
- error: string;
42
- denied: true;
43
- };
44
- key: string;
45
- } | {
46
- status: 'ready';
47
- key: string;
48
- effect: ToolEffect;
49
- resource: ResourceDescriptor | null;
50
- autoRun: boolean;
51
- permission?: 'allow' | 'ask' | undefined;
52
- };
53
- interface ToolPolicyOptions extends Pick<ExecuteCallOptions, 'sources' | 'sourceFacts' | 'outbound' | 'denied' | 'effect' | 'skipApprovals'> {
54
- key?: string;
55
- permission?: 'allow' | 'ask' | undefined;
56
- }
57
- interface PreflightOptions extends ToolPolicyOptions, Pick<ExecuteCallOptions, 'deniedMessage'> {
58
- }
59
- export declare function preflightToolCall(tool: ToolDefinition, args: Record<string, unknown>, ctx: ToolExecuteContext, options: PreflightOptions): ToolPreflight;
60
- export declare function inspectToolPolicy(tool: ToolDefinition, args: Record<string, unknown>, ctx: ToolExecuteContext, options: ToolPolicyOptions): ToolPreflightFacts;
61
- type ReadyToolPreflight = Extract<ToolPreflight, {
62
- status: 'ready';
63
- }>;
64
- export declare function readyPreflightFromFacts(facts: ToolPreflightFacts): ReadyToolPreflight;
65
30
  export declare function executeCall(tool: ToolDefinition, args: Record<string, unknown>, ctx: ToolExecuteContext, { runId, deniedMessage, approve, signal, denied, sources, sourceFacts, outbound, pipeline, callId, effect: classified, skipApprovals, preflight: prepared, onToolActivity, intent, display }: ExecuteCallOptions): Promise<ExecutedCall>;
66
31
  export declare function reportFailure(pipeline: HookPipeline, failure: Omit<ToolFailurePayload, 'phase'>): Promise<unknown>;
67
- export declare function ruleInputs(tool: ToolDefinition, ctx: ToolExecuteContext | undefined): Pick<PreToolCallPayload, 'command' | 'paths'>;
68
- export interface ResolveToolCallsOptions {
32
+ interface ResolveToolCallsOptions {
69
33
  runId: string;
70
34
  agentId: string | null;
71
35
  pipeline: HookPipeline;