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

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 (210) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +1 -0
  3. package/dist-lib/index.d.ts +7 -5
  4. package/dist-lib/index.js +5 -4
  5. package/dist-lib/lib/agent/resolve.js +2 -1
  6. package/dist-lib/lib/capabilities/completion-engine/actors/answering.js +2 -2
  7. package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +1 -1
  8. package/dist-lib/lib/capabilities/completion-engine/actors/execute.d.ts +1 -1
  9. package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +8 -6
  10. package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +2 -1
  11. package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +1 -1
  12. package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +2 -1
  13. package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +8 -3
  14. package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +10 -4
  15. package/dist-lib/lib/capabilities/completion-engine/actors/run-prepare.js +2 -1
  16. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +8 -8
  17. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +2 -2
  18. package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +3 -2
  19. package/dist-lib/lib/capabilities/completion-engine/loop.js +1 -0
  20. package/dist-lib/lib/capabilities/completion-engine/round.js +9 -9
  21. package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -1
  22. package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +5 -41
  23. package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +4 -133
  24. package/dist-lib/lib/capabilities/completion-engine/tool-outcome.d.ts +4 -0
  25. package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +40 -0
  26. package/dist-lib/lib/capabilities/completion-engine/tool-preflight.d.ts +43 -0
  27. package/dist-lib/lib/capabilities/completion-engine/tool-preflight.js +91 -0
  28. package/dist-lib/lib/capabilities/completion-engine/turns.js +7 -4
  29. package/dist-lib/lib/capabilities/tool-turns/answered.d.ts +15 -0
  30. package/dist-lib/lib/capabilities/tool-turns/answered.js +16 -0
  31. package/dist-lib/lib/capabilities/tool-turns/attachments.d.ts +7 -0
  32. package/dist-lib/lib/capabilities/tool-turns/attachments.js +39 -0
  33. package/dist-lib/lib/capabilities/tool-turns/copy.d.ts +13 -0
  34. package/dist-lib/lib/capabilities/tool-turns/copy.js +29 -0
  35. package/dist-lib/lib/capabilities/tool-turns/result-turn.d.ts +22 -0
  36. package/dist-lib/lib/capabilities/tool-turns/result-turn.js +120 -0
  37. package/dist-lib/lib/capabilities/tool-turns/run-limits.d.ts +6 -0
  38. package/dist-lib/lib/capabilities/tool-turns/run-limits.js +32 -0
  39. package/dist-lib/lib/capabilities/tool-turns/skill-loads.d.ts +9 -0
  40. package/dist-lib/lib/capabilities/tool-turns/skill-loads.js +71 -0
  41. package/dist-lib/lib/capabilities/tool-turns.d.ts +10 -54
  42. package/dist-lib/lib/capabilities/tool-turns.js +7 -281
  43. package/dist-lib/lib/client/index.js +3 -3
  44. package/dist-lib/lib/connect/abort.d.ts +6 -0
  45. package/dist-lib/lib/connect/abort.js +52 -0
  46. package/dist-lib/lib/connect/bridges.d.ts +21 -0
  47. package/dist-lib/lib/connect/bridges.js +185 -0
  48. package/dist-lib/lib/connect/decode.d.ts +31 -0
  49. package/dist-lib/lib/connect/decode.js +114 -0
  50. package/dist-lib/lib/connect/host-run-log.d.ts +16 -0
  51. package/dist-lib/lib/connect/host-run-log.js +74 -0
  52. package/dist-lib/lib/connect/served.d.ts +7 -0
  53. package/dist-lib/lib/connect/served.js +45 -0
  54. package/dist-lib/lib/connect.d.ts +3 -3
  55. package/dist-lib/lib/connect.js +24 -468
  56. package/dist-lib/lib/context-window.d.ts +13 -7
  57. package/dist-lib/lib/context-window.js +13 -6
  58. package/dist-lib/lib/contract/agent.d.ts +12 -1
  59. package/dist-lib/lib/contract/completion.d.ts +7 -2
  60. package/dist-lib/lib/contract/drive.d.ts +130 -4
  61. package/dist-lib/lib/contract/ocr.d.ts +5 -1
  62. package/dist-lib/lib/contract-types.d.ts +5 -3
  63. package/dist-lib/lib/errors.js +3 -3
  64. package/dist-lib/lib/helpers/goal-check/asks.d.ts +25 -0
  65. package/dist-lib/lib/helpers/goal-check/asks.js +52 -0
  66. package/dist-lib/lib/helpers/goal-check/checks.d.ts +8 -0
  67. package/dist-lib/lib/helpers/goal-check/checks.js +92 -0
  68. package/dist-lib/lib/helpers/goal-check/commands.d.ts +7 -0
  69. package/dist-lib/lib/helpers/goal-check/commands.js +130 -0
  70. package/dist-lib/lib/helpers/goal-check/paths.d.ts +5 -0
  71. package/dist-lib/lib/helpers/goal-check/paths.js +44 -0
  72. package/dist-lib/lib/helpers/goal-check/shell.d.ts +9 -0
  73. package/dist-lib/lib/helpers/goal-check/shell.js +96 -0
  74. package/dist-lib/lib/helpers/goal-check.d.ts +35 -43
  75. package/dist-lib/lib/helpers/goal-check.js +34 -406
  76. package/dist-lib/lib/helpers/recent-map.d.ts +7 -0
  77. package/dist-lib/lib/helpers/recent-map.js +23 -0
  78. package/dist-lib/lib/helpers/tool-call-markup/emit.d.ts +6 -0
  79. package/dist-lib/lib/helpers/tool-call-markup/emit.js +15 -0
  80. package/dist-lib/lib/helpers/tool-call-markup/recover.d.ts +22 -0
  81. package/dist-lib/lib/helpers/tool-call-markup/recover.js +130 -0
  82. package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.d.ts +3 -0
  83. package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.js +56 -0
  84. package/dist-lib/lib/helpers/tool-call-markup/strip.d.ts +4 -0
  85. package/dist-lib/lib/helpers/tool-call-markup/strip.js +149 -0
  86. package/dist-lib/lib/helpers/tool-call-markup.d.ts +19 -24
  87. package/dist-lib/lib/helpers/tool-call-markup.js +17 -343
  88. package/dist-lib/lib/machine/completion/actions/completion.d.ts +12 -18
  89. package/dist-lib/lib/machine/completion/actions/completion.js +19 -178
  90. package/dist-lib/lib/machine/completion/actions/goal.d.ts +10 -0
  91. package/dist-lib/lib/machine/completion/actions/goal.js +93 -0
  92. package/dist-lib/lib/machine/completion/actions/prepare.js +2 -1
  93. package/dist-lib/lib/machine/completion/actions/reject-tool.d.ts +16 -0
  94. package/dist-lib/lib/machine/completion/actions/reject-tool.js +147 -0
  95. package/dist-lib/lib/machine/completion/actions/retry-round.d.ts +6 -0
  96. package/dist-lib/lib/machine/completion/actions/retry-round.js +50 -0
  97. package/dist-lib/lib/machine/completion/actions/rounds.d.ts +5 -0
  98. package/dist-lib/lib/machine/completion/actions/rounds.js +31 -0
  99. package/dist-lib/lib/machine/completion/actions/tools.d.ts +1 -16
  100. package/dist-lib/lib/machine/completion/actions/tools.js +23 -162
  101. package/dist-lib/lib/machine/completion/context.js +3 -3
  102. package/dist-lib/lib/machine/completion/implementations.d.ts +2 -2
  103. package/dist-lib/lib/machine/completion/implementations.js +6 -2
  104. package/dist-lib/lib/machine/completion/machine.d.ts +2 -2
  105. package/dist-lib/lib/machine/completion/metrics.d.ts +25 -0
  106. package/dist-lib/lib/machine/completion/metrics.js +68 -0
  107. package/dist-lib/lib/machine/completion/nudges.d.ts +5 -0
  108. package/dist-lib/lib/machine/completion/nudges.js +33 -0
  109. package/dist-lib/lib/machine/completion/rules.d.ts +5 -34
  110. package/dist-lib/lib/machine/completion/rules.js +4 -120
  111. package/dist-lib/lib/machine/completion/splice.d.ts +9 -0
  112. package/dist-lib/lib/machine/completion/splice.js +19 -0
  113. package/dist-lib/lib/machine/completion/types.d.ts +4 -13
  114. package/dist-lib/lib/machine/index.d.ts +3 -3
  115. package/dist-lib/lib/machine/index.js +2 -2
  116. package/dist-lib/lib/media-host.js +2 -2
  117. package/dist-lib/lib/media-wire.js +2 -2
  118. package/dist-lib/lib/residency/completion-runtime.d.ts +2 -1
  119. package/dist-lib/lib/residency/completion-runtime.js +44 -1
  120. package/dist-lib/lib/residency/index.d.ts +3 -2
  121. package/dist-lib/lib/residency/index.js +2 -2
  122. package/dist-lib/lib/round-host.js +3 -3
  123. package/dist-lib/lib/round-port.js +3 -3
  124. package/dist-lib/lib/run-log/redact.js +7 -7
  125. package/dist-lib/lib/serve/completion.d.ts +7 -0
  126. package/dist-lib/lib/serve/completion.js +553 -0
  127. package/dist-lib/lib/serve/downloads.d.ts +4 -0
  128. package/dist-lib/lib/serve/downloads.js +79 -0
  129. package/dist-lib/lib/serve/models.d.ts +5 -0
  130. package/dist-lib/lib/serve/models.js +120 -0
  131. package/dist-lib/lib/serve/noop.d.ts +1 -0
  132. package/dist-lib/lib/serve/noop.js +1 -0
  133. package/dist-lib/lib/serve/requests.d.ts +147 -0
  134. package/dist-lib/lib/serve/requests.js +1 -0
  135. package/dist-lib/lib/serve/rounds.d.ts +11 -0
  136. package/dist-lib/lib/serve/rounds.js +67 -0
  137. package/dist-lib/lib/serve/run-log-start.d.ts +38 -0
  138. package/dist-lib/lib/serve/run-log-start.js +254 -0
  139. package/dist-lib/lib/serve/skills.d.ts +32 -0
  140. package/dist-lib/lib/serve/skills.js +46 -0
  141. package/dist-lib/lib/serve.d.ts +5 -1
  142. package/dist-lib/lib/serve.js +14 -1071
  143. package/dist-lib/lib/skills-host/index.d.ts +4 -2
  144. package/dist-lib/lib/skills-host/index.js +20 -8
  145. package/dist-lib/lib/tools/files/glob.js +48 -9
  146. package/dist-lib/lib/tools/files/grep.js +27 -13
  147. package/dist-lib/lib/tools/files/read-file.js +120 -76
  148. package/dist-lib/lib/tools/fs/drive.d.ts +1 -17
  149. package/dist-lib/lib/tools/fs/remote-protocol.d.ts +1 -81
  150. package/dist-lib/lib/tools/fs/scope.d.ts +2 -17
  151. package/dist-lib/lib/tools/fs/search.d.ts +2 -18
  152. package/dist-lib/lib/tools/fs/suggest.d.ts +8 -0
  153. package/dist-lib/lib/tools/fs/suggest.js +110 -0
  154. package/dist-lib/lib/tools/fs/tool-path.d.ts +3 -0
  155. package/dist-lib/lib/tools/fs/tool-path.js +13 -0
  156. package/dist-lib/lib/tools/fs/walk.d.ts +1 -5
  157. package/dist-lib/lib/tools/pdf/build.d.ts +2 -2
  158. package/dist-lib/lib/tools/pdf/recognize.js +4 -8
  159. package/dist-lib/lib/tools/pdf/request.d.ts +3 -8
  160. package/dist-lib/lib/tools/pdf/request.js +4 -4
  161. package/dist-lib/lib/tools/pdf.d.ts +0 -1
  162. package/dist-lib/lib/tools/pdf.js +0 -1
  163. package/dist-lib/lib/tools/skill.js +13 -4
  164. package/dist-lib/lib/tools/skills/bundled-dir.d.ts +3 -0
  165. package/dist-lib/lib/tools/skills/bundled-dir.js +27 -24
  166. package/dist-lib/lib/tools/skills/bundled-hash.d.ts +1 -0
  167. package/dist-lib/lib/tools/skills/bundled-hash.js +4 -1
  168. package/dist-lib/lib/tools/skills/catalog-loader.d.ts +12 -0
  169. package/dist-lib/lib/tools/skills/catalog-loader.js +173 -0
  170. package/dist-lib/lib/tools/skills/catalog.d.ts +5 -8
  171. package/dist-lib/lib/tools/skills/catalog.js +1 -162
  172. package/dist-lib/lib/tools/skills/index.d.ts +1 -0
  173. package/dist-lib/lib/tools/skills/index.js +1 -0
  174. package/dist-lib/lib/tools/skills/skill-tree.d.ts +5 -0
  175. package/dist-lib/lib/tools/skills/skill-tree.js +54 -0
  176. package/dist-lib/lib/tools/toolsets.d.ts +1 -1
  177. package/dist-lib/lib/tools/toolsets.js +1 -0
  178. package/dist-lib/lib/wire/download.d.ts +10 -0
  179. package/dist-lib/lib/wire/download.js +35 -0
  180. package/dist-lib/lib/wire/event.d.ts +41 -0
  181. package/dist-lib/lib/wire/event.js +306 -0
  182. package/dist-lib/lib/wire/fields.d.ts +3 -0
  183. package/dist-lib/lib/wire/fields.js +12 -0
  184. package/dist-lib/lib/wire/knowledge.d.ts +9 -0
  185. package/dist-lib/lib/wire/knowledge.js +68 -0
  186. package/dist-lib/lib/wire/round.d.ts +14 -0
  187. package/dist-lib/lib/wire/round.js +45 -0
  188. package/dist-lib/lib/wire/vectors.d.ts +6 -0
  189. package/dist-lib/lib/wire/vectors.js +33 -0
  190. package/dist-lib/lib/wire.d.ts +28 -77
  191. package/dist-lib/lib/wire.js +24 -489
  192. package/dist-lib/plugins/diagrams/draw.d.ts +10 -0
  193. package/dist-lib/plugins/diagrams/draw.js +90 -0
  194. package/dist-lib/plugins/diagrams/index.d.ts +13 -0
  195. package/dist-lib/plugins/diagrams/index.js +15 -0
  196. package/dist-lib/plugins/diagrams/render.d.ts +16 -0
  197. package/dist-lib/plugins/diagrams/render.js +285 -0
  198. package/dist-lib/plugins/ocr/coverage.d.ts +3 -0
  199. package/dist-lib/plugins/ocr/coverage.js +67 -0
  200. package/dist-lib/plugins/ocr/ocr-runtime.d.ts +4 -2
  201. package/dist-lib/plugins/ocr/ocr-runtime.js +25 -4
  202. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  203. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  204. package/dist-lib/schema/harness.js +4 -1
  205. package/dist-lib/spec/hrpc/messages.js +25 -1
  206. package/dist-lib/spec/hyperschema/index.js +25 -1
  207. package/dist-lib/spec/hyperschema/schema.json +6 -1
  208. package/dist-lib/spec/hyperschema/types.d.ts +1 -0
  209. package/package.json +6 -2
  210. package/worker/harness-sidecar.mjs +2 -0
package/CHANGELOG.md CHANGED
@@ -21,6 +21,40 @@ breaking change is listed under Changed and Removed.
21
21
 
22
22
  ### Added
23
23
 
24
+ - `grep` takes `caseSensitive` to match exact case, and `grep` and `glob` take `includeIgnored` to also
25
+ search what `.gitignore`, `.ignore` and cache folders leave out; `.git`, `node_modules` and `.trash`
26
+ stay skipped. `glob` takes `limit` (default 100, at most 500) and `offset`. A `glob` that finds more
27
+ than 100 paths, with neither set, now samples across the top-level folders instead of taking the
28
+ newest 100, and says so in a `note`; with `limit` or `offset` it pages newest first as before.
29
+ - A `Diagrams` plugin gives the model `draw_diagram`: a diagram type and its links in, and the
30
+ Mermaid block the app renders out, as the run's reply. It draws flowcharts, sequence, state,
31
+ ER and class diagrams, mind maps, timelines, Gantt charts and pies, escapes every label itself,
32
+ and draws a horizontal sequence as a numbered `flowchart LR`, but only when a user turn asks for
33
+ horizontal, left to right or sideways in words. It sits in a new `diagrams`
34
+ toolset, and the shipped sidecar registers it with its read grant. On the diagrams pack, with the
35
+ `diagrams` skill that declares it, the 2B succeeds in 180 of 198 runs against 161 and draws no
36
+ broken diagram against 12; the 4B 180 against 170, with none broken against 18.
37
+ ```js
38
+ new Harness({ plugins: [new Diagrams({ read: ['draw_diagram'] })] })
39
+ ```
40
+ (#892)
41
+ - `answeredToolTurns` and `isAnswer` in `@qvac/harness/lib/capabilities/tool-turns`: a call whose
42
+ result answered the run (`{ content, answer: true }`) has no round after it, so a host that
43
+ rebuilds a chat from its own record replays it with these, before the run's reply. (#892)
44
+ - `ToolExecuteContext.userTurns`: the user's turns as the host sent them, so a tool can check an
45
+ argument the model sent against what was asked. (#892)
46
+
47
+ - Workspace skills run in every chat of the workspace. Send them as `workspaceSkills`, shaped like
48
+ `projectSkills`. On a name clash the project's skill wins over the workspace's, and the workspace's
49
+ over your own. A workspace skill with a script asks each member by its hash, as a project skill
50
+ does. (#727)
51
+
52
+ - A project's skills run in its chats over your own. Send each as `{ name, hash, files }`, with `hash`
53
+ from `hashSkillFiles`. The harness writes the tree under its hash and layers it over the sender's
54
+ 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.
55
+ Each project skill joins a run only after `approve` says yes to `<name>@<hash>`, in every
56
+ approval mode, so a changed skill asks again. (#726)
57
+
24
58
  - Image and music generation can run on a device that holds the model. A run
25
59
  that passes `mediaRound` has `generate_image`, `edit_image` and
26
60
  `generate_music` ask it for the model call, and the device with the model
@@ -83,6 +117,18 @@ breaking change is listed under Changed and Removed.
83
117
  [the decision record](docs/decisions/2026-11-03-a-scanned-pdf-page-is-read-by-ocr.md).
84
118
  (#768)
85
119
 
120
+ - A host that reads PDFs in its own process OCRs their scanned pages through
121
+ the harness. `pdfPages(bytes, { ocr, signal })` (`@qvac/harness/pdf-pages`)
122
+ returns each page's text, renders a scanned page in the host and marks it
123
+ `unread` when OCR fails, and `harness.ocrRead({ image, signal })` reads one
124
+ rendered page across the wire. `ocrRead` resolves an `OcrPage`,
125
+ `{ text, coverage }`: `coverage`, 0 to 1, is the share of the page's ink
126
+ inside the words read, near 1 on a typed page and under 0.5 on a chart or a
127
+ photo, so a host can give a model a high-coverage page as its text. Before
128
+ rc.21 it resolved the text alone. The harness keeps the last 1,024 pages it
129
+ read, so a scan indexed and then shown is read once. See
130
+ [docs/hosting.md](docs/hosting.md). (#789, #841)
131
+
86
132
  - 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
133
  a coding tune of the Qwen3.6-35B-A3B architecture, text only, `xhigh`, with the `qwen35` tool
88
134
  dialect. It and gpt-oss sample as their makers recommend: KAT-Coder at temp 1.0, top_p 0.95 and
@@ -563,6 +609,9 @@ breaking change is listed under Changed and Removed.
563
609
 
564
610
  ### Changed
565
611
 
612
+ - Two calls in one round whose results each answer the run (`{ content, answer: true }`) both
613
+ reach the reply, joined in order; only the first did before. (#892)
614
+
566
615
  - **Breaking:** speech defaults to Audio8. A `speak` or `speakStream` that
567
616
  names no model loads `Audio8-Q8_0` on every device profile, where it loaded
568
617
  Supertonic 3. Audio8 is 1.05 GB with its codec decoder (Supertonic was 85 MB
@@ -1343,6 +1392,24 @@ breaking change is listed under Changed and Removed.
1343
1392
 
1344
1393
  ### Fixed
1345
1394
 
1395
+ - `read_file` returns what a model can use. A CRLF line loses its `\r`, and a
1396
+ line over 2000 characters is cut there, so one long line no longer uses up
1397
+ the read; the cut names the full length,
1398
+ `… (line cut at 2000 chars; 5800 bytes in all)` for a text file and
1399
+ `5800 chars` for a document. A `startLine` past the end returns the last 50
1400
+ lines under `startLine N is past the end; the file has T lines`, and a
1401
+ negative `startLine` reads from the end (`-50` is the last 50 lines). A range
1402
+ names the exact total (`lines 2-2 of 50001`) where it said `of unknown`.
1403
+ Every read is one pass over one stream: the file is counted to its end
1404
+ without decoding it, and the tail is kept in a ring as it goes. The count
1405
+ stops at 8 MiB: past it a range's total stays unknown, and a tail returns
1406
+ `has more than N lines; its end is past the 8 MiB read_file counts` instead
1407
+ of reading on. A missing
1408
+ path suggests up to three near matches: the same name in another case, the
1409
+ same name with another extension, a name that contains it, or a one- or
1410
+ two-letter typo. For a missing folder it names the nearest folder that
1411
+ exists, and for a path written from the wrong root it suggests the same path
1412
+ under the shared folder. Denied paths are never suggested. (#887)
1346
1413
  - OCR loads in the harness sidecar. Since rc.16 the first OCR model load
1347
1414
  failed with `CANNOT_LOAD`, so a scanned PDF got no text on desktop. (#844)
1348
1415
  - `edit_file`, `insert_text` and `edit_many` write only what they change. A
package/README.md CHANGED
@@ -327,6 +327,7 @@ itself.
327
327
  | [`TranslationPlugin`](plugins/translation/README.md) | Translation on device |
328
328
  | [`LanguageHint`](plugins/language-hint/README.md) | A prompt in another language, in English too, for the model |
329
329
  | [`Weather`](plugins/weather/README.md) | Weather lookup |
330
+ | [`Diagrams`](plugins/diagrams/README.md) | Diagrams drawn from a type and its links, as the Mermaid the app renders |
330
331
  | [`ObsidianRoute`](plugins/obsidian/README.md) | `obsidian …` commands against a vault |
331
332
 
332
333
  Each plugin is imported from `@qvac/harness/plugins/<folder>`. Its own dependencies are optional
@@ -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';
@@ -22,6 +22,7 @@ export function toolContext({ deps, context, name }) {
22
22
  const { args, session, commitFacts } = deps;
23
23
  return {
24
24
  currentTime: args.messages.findLast((turn) => turn.role === 'user')?.sentAt || session.startedAt,
25
+ userTurns: args.messages.filter((turn) => turn.role === 'user').map((turn) => turn.content),
25
26
  ...session.toolContext(session.turnImages, context.metrics.ctxSize ?? args.ctxSize, args.signal),
26
27
  skills: context.activated.filter((skill) => Agent.skillIsActive(skill, session.activation) &&
27
28
  !unreadySkillState(skill, args.skillCatalog ?? [])),
@@ -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) {