@elie-laloum/outpost 4.2.0 → 5.0.0

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 (450) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +5 -3
  3. package/dist/{cli/init-authentication.constants.js → adapters/agents/authentication.constants.js} +1 -1
  4. package/dist/adapters/agents/authentication.constants.js.map +1 -0
  5. package/dist/adapters/agents/authentication.d.ts +2 -0
  6. package/dist/adapters/agents/authentication.js +52 -0
  7. package/dist/adapters/agents/authentication.js.map +1 -0
  8. package/dist/adapters/agents/claude-adapter.d.ts +2 -2
  9. package/dist/adapters/agents/claude-adapter.js +30 -2
  10. package/dist/adapters/agents/claude-adapter.js.map +1 -1
  11. package/dist/adapters/agents/claude-request.d.ts +2 -2
  12. package/dist/adapters/agents/claude-request.js +3 -3
  13. package/dist/adapters/agents/claude-request.js.map +1 -1
  14. package/dist/adapters/agents/codex-adapter.d.ts +2 -2
  15. package/dist/adapters/agents/codex-adapter.js +17 -1
  16. package/dist/adapters/agents/codex-adapter.js.map +1 -1
  17. package/dist/adapters/agents/codex-provider.d.ts +2 -2
  18. package/dist/adapters/agents/codex-provider.js +1 -1
  19. package/dist/adapters/agents/codex-provider.js.map +1 -1
  20. package/dist/adapters/agents/codex-request.d.ts +2 -2
  21. package/dist/adapters/agents/codex-request.js +3 -3
  22. package/dist/adapters/agents/codex-request.js.map +1 -1
  23. package/dist/adapters/agents/gemini-adapter.d.ts +2 -2
  24. package/dist/adapters/agents/gemini-adapter.js +20 -1
  25. package/dist/adapters/agents/gemini-adapter.js.map +1 -1
  26. package/dist/adapters/agents/gemini-request.d.ts +2 -1
  27. package/dist/adapters/agents/gemini-request.js +1 -1
  28. package/dist/adapters/agents/gemini-request.js.map +1 -1
  29. package/dist/adapters/agents/gemini.types.d.ts +2 -1
  30. package/dist/adapters/agents/gemini.types.js.map +1 -1
  31. package/dist/adapters/agents/model-support.constants.d.ts +6 -0
  32. package/dist/adapters/agents/model-support.constants.js +18 -0
  33. package/dist/adapters/agents/model-support.constants.js.map +1 -0
  34. package/dist/adapters/agents/model-support.d.ts +4 -0
  35. package/dist/adapters/agents/model-support.js +11 -0
  36. package/dist/adapters/agents/model-support.js.map +1 -0
  37. package/dist/adapters/agents/settings.types.d.ts +11 -3
  38. package/dist/adapters/agents/settings.types.js.map +1 -1
  39. package/dist/adapters/models/anthropic-model-provider.constants.d.ts +3 -0
  40. package/dist/adapters/models/anthropic-model-provider.constants.js +17 -0
  41. package/dist/adapters/models/anthropic-model-provider.constants.js.map +1 -0
  42. package/dist/adapters/models/anthropic-model-provider.d.ts +3 -0
  43. package/dist/adapters/models/anthropic-model-provider.js +31 -0
  44. package/dist/adapters/models/anthropic-model-provider.js.map +1 -0
  45. package/dist/adapters/models/anthropic-model-provider.types.d.ts +7 -0
  46. package/dist/adapters/models/anthropic-model-provider.types.js +2 -0
  47. package/dist/adapters/models/anthropic-model-provider.types.js.map +1 -0
  48. package/dist/adapters/models/anthropic-request.d.ts +4 -0
  49. package/dist/adapters/models/anthropic-request.js +81 -0
  50. package/dist/adapters/models/anthropic-request.js.map +1 -0
  51. package/dist/adapters/models/anthropic-response.d.ts +3 -0
  52. package/dist/adapters/models/anthropic-response.js +55 -0
  53. package/dist/adapters/models/anthropic-response.js.map +1 -0
  54. package/dist/adapters/models/anthropic-stream.d.ts +2 -0
  55. package/dist/adapters/models/anthropic-stream.js +96 -0
  56. package/dist/adapters/models/anthropic-stream.js.map +1 -0
  57. package/dist/adapters/models/http-provider.d.ts +3 -0
  58. package/dist/adapters/models/http-provider.js +113 -0
  59. package/dist/adapters/models/http-provider.js.map +1 -0
  60. package/dist/adapters/models/{openai-http.js → model-http.js} +1 -1
  61. package/dist/adapters/models/model-http.js.map +1 -0
  62. package/dist/adapters/models/model-protocol.types.d.ts +41 -0
  63. package/dist/adapters/models/model-protocol.types.js +2 -0
  64. package/dist/adapters/models/model-protocol.types.js.map +1 -0
  65. package/dist/adapters/models/model-request.d.ts +2 -0
  66. package/dist/adapters/models/model-request.js +18 -0
  67. package/dist/adapters/models/model-request.js.map +1 -0
  68. package/dist/adapters/models/model-response.d.ts +7 -0
  69. package/dist/adapters/models/model-response.js +41 -0
  70. package/dist/adapters/models/model-response.js.map +1 -0
  71. package/dist/adapters/models/{openai-compatible.constants.js → model.constants.js} +6 -1
  72. package/dist/adapters/models/model.constants.js.map +1 -0
  73. package/dist/adapters/models/openai-chat-stream.d.ts +2 -0
  74. package/dist/adapters/models/openai-chat-stream.js +66 -0
  75. package/dist/adapters/models/openai-chat-stream.js.map +1 -0
  76. package/dist/adapters/models/openai-chat.d.ts +4 -0
  77. package/dist/adapters/models/openai-chat.js +108 -0
  78. package/dist/adapters/models/openai-chat.js.map +1 -0
  79. package/dist/adapters/models/openai-model-provider.d.ts +3 -0
  80. package/dist/adapters/models/openai-model-provider.js +13 -0
  81. package/dist/adapters/models/openai-model-provider.js.map +1 -0
  82. package/dist/adapters/models/openai-model-provider.types.d.ts +4 -0
  83. package/dist/adapters/models/openai-model-provider.types.js +2 -0
  84. package/dist/adapters/models/openai-model-provider.types.js.map +1 -0
  85. package/dist/adapters/models/openai-protocols.d.ts +2 -0
  86. package/dist/adapters/models/openai-protocols.js +22 -0
  87. package/dist/adapters/models/openai-protocols.js.map +1 -0
  88. package/dist/adapters/models/openai-responses-stream.d.ts +2 -0
  89. package/dist/adapters/models/openai-responses-stream.js +35 -0
  90. package/dist/adapters/models/openai-responses-stream.js.map +1 -0
  91. package/dist/adapters/models/openai-responses.d.ts +4 -0
  92. package/dist/adapters/models/openai-responses.js +107 -0
  93. package/dist/adapters/models/openai-responses.js.map +1 -0
  94. package/dist/adapters/models/openai-usage.d.ts +3 -0
  95. package/dist/adapters/models/openai-usage.js +20 -0
  96. package/dist/adapters/models/openai-usage.js.map +1 -0
  97. package/dist/adapters/models/stop-reasons.constants.d.ts +4 -0
  98. package/dist/adapters/models/stop-reasons.constants.js +19 -0
  99. package/dist/adapters/models/stop-reasons.constants.js.map +1 -0
  100. package/dist/adapters/models/stream-events.d.ts +3 -0
  101. package/dist/adapters/models/stream-events.js +22 -0
  102. package/dist/adapters/models/stream-events.js.map +1 -0
  103. package/dist/adapters/tools/edit-tools.d.ts +2 -0
  104. package/dist/adapters/tools/edit-tools.js +84 -0
  105. package/dist/adapters/tools/edit-tools.js.map +1 -0
  106. package/dist/adapters/tools/file-tools.d.ts +2 -0
  107. package/dist/adapters/tools/file-tools.js +97 -0
  108. package/dist/adapters/tools/file-tools.js.map +1 -0
  109. package/dist/adapters/tools/git-tools.d.ts +2 -0
  110. package/dist/adapters/tools/git-tools.js +54 -0
  111. package/dist/adapters/tools/git-tools.js.map +1 -0
  112. package/dist/adapters/tools/sandbox-files.d.ts +10 -0
  113. package/dist/adapters/tools/sandbox-files.js +60 -0
  114. package/dist/adapters/tools/sandbox-files.js.map +1 -0
  115. package/dist/adapters/tools/search-tools.d.ts +2 -0
  116. package/dist/adapters/tools/search-tools.js +65 -0
  117. package/dist/adapters/tools/search-tools.js.map +1 -0
  118. package/dist/adapters/tools/shell-tools.d.ts +3 -0
  119. package/dist/adapters/tools/shell-tools.js +38 -0
  120. package/dist/adapters/tools/shell-tools.js.map +1 -0
  121. package/dist/adapters/tools/tools.constants.d.ts +11 -0
  122. package/dist/adapters/tools/tools.constants.js +17 -0
  123. package/dist/adapters/tools/tools.constants.js.map +1 -0
  124. package/dist/adapters/tools/tools.types.d.ts +41 -0
  125. package/dist/adapters/tools/tools.types.js +2 -0
  126. package/dist/adapters/tools/tools.types.js.map +1 -0
  127. package/dist/application/activity-watchdog.js +15 -2
  128. package/dist/application/activity-watchdog.js.map +1 -1
  129. package/dist/application/agent-bootstrap.d.ts +2 -2
  130. package/dist/application/agent-bootstrap.js +2 -0
  131. package/dist/application/agent-bootstrap.js.map +1 -1
  132. package/dist/application/agent-storage.d.ts +3 -2
  133. package/dist/application/agent-storage.js +9 -2
  134. package/dist/application/agent-storage.js.map +1 -1
  135. package/dist/application/agent-turn.d.ts +3 -3
  136. package/dist/application/agent-turn.js +7 -1
  137. package/dist/application/agent-turn.js.map +1 -1
  138. package/dist/application/attach.js +1 -0
  139. package/dist/application/attach.js.map +1 -1
  140. package/dist/application/custom-turn.d.ts +5 -0
  141. package/dist/application/custom-turn.js +190 -0
  142. package/dist/application/custom-turn.js.map +1 -0
  143. package/dist/application/dispatch-observation.d.ts +3 -0
  144. package/dist/application/dispatch-observation.js +51 -0
  145. package/dist/application/dispatch-observation.js.map +1 -0
  146. package/dist/application/dispatch-observation.types.d.ts +5 -0
  147. package/dist/application/dispatch-observation.types.js +2 -0
  148. package/dist/application/dispatch-observation.types.js.map +1 -0
  149. package/dist/application/dispatch-validation.d.ts +2 -2
  150. package/dist/application/dispatch-validation.js.map +1 -1
  151. package/dist/application/dispatch.js +8 -3
  152. package/dist/application/dispatch.js.map +1 -1
  153. package/dist/application/doctor-image.js +3 -3
  154. package/dist/application/doctor-image.js.map +1 -1
  155. package/dist/application/doctor-protocol.js +9 -4
  156. package/dist/application/doctor-protocol.js.map +1 -1
  157. package/dist/application/doctor-sandbox.js +4 -4
  158. package/dist/application/doctor-sandbox.js.map +1 -1
  159. package/dist/application/doctor-sandbox.types.d.ts +2 -2
  160. package/dist/application/doctor-sandbox.types.js.map +1 -1
  161. package/dist/application/doctor.constants.d.ts +1 -1
  162. package/dist/application/doctor.constants.js +1 -1
  163. package/dist/application/doctor.constants.js.map +1 -1
  164. package/dist/application/doctor.js +10 -9
  165. package/dist/application/doctor.js.map +1 -1
  166. package/dist/application/doctor.types.d.ts +3 -3
  167. package/dist/application/doctor.types.js.map +1 -1
  168. package/dist/application/execution.d.ts +2 -2
  169. package/dist/application/execution.js +1 -1
  170. package/dist/application/execution.js.map +1 -1
  171. package/dist/application/execution.types.d.ts +9 -2
  172. package/dist/application/execution.types.js.map +1 -1
  173. package/dist/application/harness-context.d.ts +2 -0
  174. package/dist/application/harness-context.js +54 -0
  175. package/dist/application/harness-context.js.map +1 -0
  176. package/dist/application/harness-history.d.ts +3 -0
  177. package/dist/application/harness-history.js +17 -0
  178. package/dist/application/harness-history.js.map +1 -0
  179. package/dist/application/harness-hooks.d.ts +9 -0
  180. package/dist/application/harness-hooks.js +90 -0
  181. package/dist/application/harness-hooks.js.map +1 -0
  182. package/dist/application/harness-loop.d.ts +2 -0
  183. package/dist/application/harness-loop.js +132 -0
  184. package/dist/application/harness-loop.js.map +1 -0
  185. package/dist/application/harness.types.d.ts +55 -0
  186. package/dist/application/harness.types.js +2 -0
  187. package/dist/application/harness.types.js.map +1 -0
  188. package/dist/application/lifecycle.constants.d.ts +1 -1
  189. package/dist/application/lifecycle.constants.js +1 -1
  190. package/dist/application/lifecycle.constants.js.map +1 -1
  191. package/dist/application/outpost.types.d.ts +6 -6
  192. package/dist/application/outpost.types.js.map +1 -1
  193. package/dist/application/remote-download.js +1 -1
  194. package/dist/application/remote-download.js.map +1 -1
  195. package/dist/application/sandbox-agents.js +12 -4
  196. package/dist/application/sandbox-agents.js.map +1 -1
  197. package/dist/application/sandbox-attach.js +5 -2
  198. package/dist/application/sandbox-attach.js.map +1 -1
  199. package/dist/application/sandbox-dispatch.js +3 -3
  200. package/dist/application/sandbox-dispatch.js.map +1 -1
  201. package/dist/application/sandbox-provision.js +13 -10
  202. package/dist/application/sandbox-provision.js.map +1 -1
  203. package/dist/application/sandbox-session.types.d.ts +8 -8
  204. package/dist/application/sandbox-session.types.js.map +1 -1
  205. package/dist/application/sandbox.js +6 -3
  206. package/dist/application/sandbox.js.map +1 -1
  207. package/dist/application/speculation.js +1 -1
  208. package/dist/application/speculation.js.map +1 -1
  209. package/dist/application/speculation.types.d.ts +3 -3
  210. package/dist/application/speculation.types.js.map +1 -1
  211. package/dist/application/tasks.types.d.ts +2 -2
  212. package/dist/application/tasks.types.js.map +1 -1
  213. package/dist/application/tool-execution.d.ts +3 -0
  214. package/dist/application/tool-execution.js +211 -0
  215. package/dist/application/tool-execution.js.map +1 -0
  216. package/dist/cli/commands.js +4 -2
  217. package/dist/cli/commands.js.map +1 -1
  218. package/dist/cli/doctor-command.js +6 -6
  219. package/dist/cli/doctor-command.js.map +1 -1
  220. package/dist/cli/init-authentication.js +6 -7
  221. package/dist/cli/init-authentication.js.map +1 -1
  222. package/dist/cli/init-command.js +3 -3
  223. package/dist/cli/init-command.js.map +1 -1
  224. package/dist/cli/main.constants.d.ts +4 -4
  225. package/dist/cli/main.constants.js +4 -4
  226. package/dist/cli/main.constants.js.map +1 -1
  227. package/dist/cli/recovery-command.js +1 -1
  228. package/dist/cli/recovery-command.js.map +1 -1
  229. package/dist/cli/scaffold-files.js +5 -4
  230. package/dist/cli/scaffold-files.js.map +1 -1
  231. package/dist/cli/scaffold-validation.js +13 -10
  232. package/dist/cli/scaffold-validation.js.map +1 -1
  233. package/dist/cli/scaffold.js +8 -4
  234. package/dist/cli/scaffold.js.map +1 -1
  235. package/dist/cli/scaffold.types.d.ts +1 -1
  236. package/dist/cli/scaffold.types.js.map +1 -1
  237. package/dist/cli/starters.js +8 -8
  238. package/dist/cli/starters.js.map +1 -1
  239. package/dist/domain/agent-model.d.ts +3 -0
  240. package/dist/domain/agent-model.js +22 -0
  241. package/dist/domain/agent-model.js.map +1 -0
  242. package/dist/domain/agent.d.ts +4 -0
  243. package/dist/domain/agent.js +32 -0
  244. package/dist/domain/agent.js.map +1 -0
  245. package/dist/domain/agent.types.d.ts +69 -2
  246. package/dist/domain/agent.types.js.map +1 -1
  247. package/dist/domain/context.constants.d.ts +7 -0
  248. package/dist/domain/context.constants.js +8 -0
  249. package/dist/domain/context.constants.js.map +1 -0
  250. package/dist/domain/context.d.ts +4 -0
  251. package/dist/domain/context.js +81 -0
  252. package/dist/domain/context.js.map +1 -0
  253. package/dist/domain/context.types.d.ts +26 -0
  254. package/dist/domain/context.types.js +2 -0
  255. package/dist/domain/context.types.js.map +1 -0
  256. package/dist/domain/dispatch-telemetry.types.d.ts +12 -0
  257. package/dist/domain/dispatch-telemetry.types.js +2 -0
  258. package/dist/domain/dispatch-telemetry.types.js.map +1 -0
  259. package/dist/domain/errors.types.d.ts +1 -1
  260. package/dist/domain/errors.types.js.map +1 -1
  261. package/dist/domain/glob.d.ts +2 -0
  262. package/dist/domain/glob.js +25 -0
  263. package/dist/domain/glob.js.map +1 -0
  264. package/dist/domain/glob.types.d.ts +1 -0
  265. package/dist/domain/glob.types.js +2 -0
  266. package/dist/domain/glob.types.js.map +1 -0
  267. package/dist/domain/harness.constants.d.ts +11 -0
  268. package/dist/domain/harness.constants.js +24 -0
  269. package/dist/domain/harness.constants.js.map +1 -0
  270. package/dist/domain/harness.d.ts +2 -0
  271. package/dist/domain/harness.js +89 -0
  272. package/dist/domain/harness.js.map +1 -0
  273. package/dist/domain/harness.types.d.ts +60 -0
  274. package/dist/domain/harness.types.js +2 -0
  275. package/dist/domain/harness.types.js.map +1 -0
  276. package/dist/domain/hook.constants.d.ts +3 -0
  277. package/dist/domain/hook.constants.js +10 -0
  278. package/dist/domain/hook.constants.js.map +1 -0
  279. package/dist/domain/hook.d.ts +3 -0
  280. package/dist/domain/hook.js +25 -0
  281. package/dist/domain/hook.js.map +1 -0
  282. package/dist/domain/hook.types.d.ts +66 -0
  283. package/dist/domain/hook.types.js +2 -0
  284. package/dist/domain/hook.types.js.map +1 -0
  285. package/dist/domain/instructions.d.ts +3 -0
  286. package/dist/domain/instructions.js +25 -0
  287. package/dist/domain/instructions.js.map +1 -0
  288. package/dist/domain/model-messages.d.ts +5 -0
  289. package/dist/domain/model-messages.js +81 -0
  290. package/dist/domain/model-messages.js.map +1 -0
  291. package/dist/domain/model-messages.types.d.ts +6 -0
  292. package/dist/domain/model-messages.types.js +2 -0
  293. package/dist/domain/model-messages.types.js.map +1 -0
  294. package/dist/domain/model.constants.d.ts +4 -0
  295. package/dist/domain/model.constants.js +16 -0
  296. package/dist/domain/model.constants.js.map +1 -0
  297. package/dist/domain/model.types.d.ts +59 -2
  298. package/dist/domain/model.types.js.map +1 -1
  299. package/dist/domain/permissions.d.ts +3 -0
  300. package/dist/domain/permissions.js +92 -0
  301. package/dist/domain/permissions.js.map +1 -0
  302. package/dist/domain/permissions.types.d.ts +34 -0
  303. package/dist/domain/permissions.types.js +2 -0
  304. package/dist/domain/permissions.types.js.map +1 -0
  305. package/dist/domain/response.js +3 -2
  306. package/dist/domain/response.js.map +1 -1
  307. package/dist/domain/response.types.d.ts +12 -0
  308. package/dist/domain/response.types.js.map +1 -1
  309. package/dist/domain/skill.constants.d.ts +2 -0
  310. package/dist/domain/skill.constants.js +8 -0
  311. package/dist/domain/skill.constants.js.map +1 -0
  312. package/dist/domain/skill.d.ts +8 -0
  313. package/dist/domain/skill.js +79 -0
  314. package/dist/domain/skill.js.map +1 -0
  315. package/dist/domain/skill.types.d.ts +18 -0
  316. package/dist/domain/skill.types.js +2 -0
  317. package/dist/domain/skill.types.js.map +1 -0
  318. package/dist/domain/standard-schema.d.ts +6 -0
  319. package/dist/domain/standard-schema.js +45 -0
  320. package/dist/domain/standard-schema.js.map +1 -0
  321. package/dist/domain/tool-schema.d.ts +3 -0
  322. package/dist/domain/tool-schema.js +109 -0
  323. package/dist/domain/tool-schema.js.map +1 -0
  324. package/dist/domain/tool.constants.d.ts +4 -0
  325. package/dist/domain/tool.constants.js +36 -0
  326. package/dist/domain/tool.constants.js.map +1 -0
  327. package/dist/domain/tool.d.ts +4 -0
  328. package/dist/domain/tool.js +66 -0
  329. package/dist/domain/tool.js.map +1 -0
  330. package/dist/domain/tool.types.d.ts +62 -0
  331. package/dist/domain/tool.types.js +2 -0
  332. package/dist/domain/tool.types.js.map +1 -0
  333. package/dist/domain/transcript.d.ts +4 -0
  334. package/dist/domain/transcript.js +48 -0
  335. package/dist/domain/transcript.js.map +1 -0
  336. package/dist/domain/transcript.types.d.ts +15 -0
  337. package/dist/domain/transcript.types.js +2 -0
  338. package/dist/domain/transcript.types.js.map +1 -0
  339. package/dist/domain/workflow/workflow-state.js +13 -6
  340. package/dist/domain/workflow/workflow-state.js.map +1 -1
  341. package/dist/domain/workflow.d.ts +1 -1
  342. package/dist/domain/workflow.js.map +1 -1
  343. package/dist/domain/workflow.types.d.ts +4 -0
  344. package/dist/domain/workflow.types.js.map +1 -1
  345. package/dist/index.d.ts +34 -8
  346. package/dist/index.js +19 -4
  347. package/dist/index.js.map +1 -1
  348. package/dist/infrastructure/conversations/harness-store.d.ts +3 -0
  349. package/dist/infrastructure/conversations/harness-store.js +27 -0
  350. package/dist/infrastructure/conversations/harness-store.js.map +1 -0
  351. package/dist/infrastructure/conversations/harness-transcript.d.ts +2 -0
  352. package/dist/infrastructure/conversations/harness-transcript.js +50 -0
  353. package/dist/infrastructure/conversations/harness-transcript.js.map +1 -0
  354. package/dist/infrastructure/conversations/harness-transcript.types.d.ts +18 -0
  355. package/dist/infrastructure/conversations/harness-transcript.types.js +2 -0
  356. package/dist/infrastructure/conversations/harness-transcript.types.js.map +1 -0
  357. package/dist/infrastructure/conversations.d.ts +4 -1
  358. package/dist/infrastructure/conversations.js +3 -0
  359. package/dist/infrastructure/conversations.js.map +1 -1
  360. package/dist/infrastructure/conversations.types.d.ts +1 -0
  361. package/dist/infrastructure/conversations.types.js.map +1 -1
  362. package/dist/infrastructure/custom-reporter.d.ts +2 -0
  363. package/dist/infrastructure/custom-reporter.js +33 -0
  364. package/dist/infrastructure/custom-reporter.js.map +1 -0
  365. package/dist/infrastructure/custom-reporter.types.d.ts +13 -0
  366. package/dist/infrastructure/custom-reporter.types.js +2 -0
  367. package/dist/infrastructure/custom-reporter.types.js.map +1 -0
  368. package/dist/infrastructure/git/git.constants.d.ts +1 -1
  369. package/dist/infrastructure/git/git.constants.js +1 -0
  370. package/dist/infrastructure/git/git.constants.js.map +1 -1
  371. package/dist/infrastructure/journal.constants.d.ts +1 -0
  372. package/dist/infrastructure/journal.constants.js +2 -0
  373. package/dist/infrastructure/journal.constants.js.map +1 -0
  374. package/dist/infrastructure/journal.js +4 -1
  375. package/dist/infrastructure/journal.js.map +1 -1
  376. package/dist/infrastructure/opentelemetry-dispatch.d.ts +6 -0
  377. package/dist/infrastructure/opentelemetry-dispatch.js +70 -0
  378. package/dist/infrastructure/opentelemetry-dispatch.js.map +1 -0
  379. package/dist/infrastructure/opentelemetry.constants.d.ts +3 -0
  380. package/dist/infrastructure/opentelemetry.constants.js +3 -0
  381. package/dist/infrastructure/opentelemetry.constants.js.map +1 -1
  382. package/dist/infrastructure/opentelemetry.js +4 -0
  383. package/dist/infrastructure/opentelemetry.js.map +1 -1
  384. package/dist/infrastructure/opentelemetry.types.d.ts +3 -3
  385. package/dist/infrastructure/opentelemetry.types.js.map +1 -1
  386. package/dist/infrastructure/reporter.js +27 -2
  387. package/dist/infrastructure/reporter.js.map +1 -1
  388. package/dist/infrastructure/resource-activity-inspection.js +3 -2
  389. package/dist/infrastructure/resource-activity-inspection.js.map +1 -1
  390. package/dist/infrastructure/resource-activity.js +2 -2
  391. package/dist/infrastructure/resource-activity.js.map +1 -1
  392. package/dist/infrastructure/resource-activity.types.d.ts +2 -2
  393. package/dist/infrastructure/resource-activity.types.js.map +1 -1
  394. package/dist/infrastructure/settings.d.ts +1 -1
  395. package/dist/infrastructure/settings.js +3 -3
  396. package/dist/infrastructure/settings.js.map +1 -1
  397. package/dist/infrastructure/sse.d.ts +2 -0
  398. package/dist/infrastructure/sse.js +64 -0
  399. package/dist/infrastructure/sse.js.map +1 -0
  400. package/dist/infrastructure/sse.types.d.ts +4 -0
  401. package/dist/infrastructure/sse.types.js +2 -0
  402. package/dist/infrastructure/sse.types.js.map +1 -0
  403. package/dist/infrastructure/transport-conversations.d.ts +2 -2
  404. package/dist/infrastructure/transport-conversations.js +8 -1
  405. package/dist/infrastructure/transport-conversations.js.map +1 -1
  406. package/dist/infrastructure/transport-journal.js +2 -1
  407. package/dist/infrastructure/transport-journal.js.map +1 -1
  408. package/dist/providers/agents.d.ts +3 -3
  409. package/dist/providers/agents.js +3 -3
  410. package/dist/providers/agents.js.map +1 -1
  411. package/dist/providers/daytona.d.ts +1 -1
  412. package/dist/providers/daytona.js +1 -1
  413. package/dist/providers/daytona.js.map +1 -1
  414. package/dist/providers/docker.d.ts +1 -1
  415. package/dist/providers/docker.js +1 -1
  416. package/dist/providers/docker.js.map +1 -1
  417. package/dist/providers/factories.d.ts +2 -2
  418. package/dist/providers/factories.js +3 -3
  419. package/dist/providers/factories.js.map +1 -1
  420. package/dist/providers/firecracker.d.ts +1 -1
  421. package/dist/providers/firecracker.js +1 -1
  422. package/dist/providers/firecracker.js.map +1 -1
  423. package/dist/providers/local.d.ts +1 -1
  424. package/dist/providers/local.js +1 -1
  425. package/dist/providers/local.js.map +1 -1
  426. package/dist/providers/podman.d.ts +1 -1
  427. package/dist/providers/podman.js +1 -1
  428. package/dist/providers/podman.js.map +1 -1
  429. package/dist/providers/vercel.d.ts +1 -1
  430. package/dist/providers/vercel.js +1 -1
  431. package/dist/providers/vercel.js.map +1 -1
  432. package/package.json +1 -1
  433. package/dist/adapters/models/openai-compatible.constants.js.map +0 -1
  434. package/dist/adapters/models/openai-compatible.d.ts +0 -3
  435. package/dist/adapters/models/openai-compatible.js +0 -78
  436. package/dist/adapters/models/openai-compatible.js.map +0 -1
  437. package/dist/adapters/models/openai-compatible.types.d.ts +0 -14
  438. package/dist/adapters/models/openai-compatible.types.js +0 -2
  439. package/dist/adapters/models/openai-compatible.types.js.map +0 -1
  440. package/dist/adapters/models/openai-http.js.map +0 -1
  441. package/dist/adapters/models/openai-request.d.ts +0 -4
  442. package/dist/adapters/models/openai-request.js +0 -46
  443. package/dist/adapters/models/openai-request.js.map +0 -1
  444. package/dist/adapters/models/openai-response.d.ts +0 -3
  445. package/dist/adapters/models/openai-response.js +0 -65
  446. package/dist/adapters/models/openai-response.js.map +0 -1
  447. package/dist/cli/init-authentication.constants.js.map +0 -1
  448. /package/dist/{cli/init-authentication.constants.d.ts → adapters/agents/authentication.constants.d.ts} +0 -0
  449. /package/dist/adapters/models/{openai-http.d.ts → model-http.d.ts} +0 -0
  450. /package/dist/adapters/models/{openai-compatible.constants.d.ts → model.constants.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"agent.types.js","sourceRoot":"","sources":["../../src/domain/agent.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Command, Variables } from \"./command.types.ts\";\nimport type { ConversationStore } from \"./conversation.types.ts\";\n\nexport interface Usage {\n readonly input: number;\n readonly cached: number;\n readonly cacheCreated?: number;\n readonly output: number;\n}\n\nexport type AgentEvent =\n | {\n readonly kind: \"phase\";\n readonly name: string;\n readonly agent?: string;\n readonly branch?: string;\n readonly directory?: string;\n }\n | {\n readonly kind: \"summary\";\n readonly durationMs: number;\n readonly status: number;\n readonly tokens: Usage;\n }\n | { readonly kind: \"warning\"; readonly message: string }\n | { readonly kind: \"text\"; readonly text: string }\n | { readonly kind: \"result\"; readonly text: string }\n | { readonly kind: \"prompt\"; readonly text: string }\n | { readonly kind: \"tool\"; readonly name: string; readonly input: unknown }\n | { readonly kind: \"conversation\"; readonly id: string }\n | { readonly kind: \"usage\"; readonly tokens: Usage }\n | { readonly kind: \"failure\"; readonly message: string }\n | { readonly kind: \"finished\" }\n | { readonly kind: \"raw\"; readonly value: unknown };\n\nexport type AgentObservation = AgentEvent & {\n readonly pass: number;\n readonly at: string;\n};\n\nexport type AgentEventHandlers = {\n readonly [Kind in AgentEvent[\"kind\"]]?: (\n event: Extract<AgentEvent, { kind: Kind }>,\n ) => void;\n};\n\nexport interface AgentInput {\n readonly text?: string;\n readonly interactive?: boolean;\n readonly continuation?: { readonly id: string; readonly fork?: boolean };\n}\n\nexport interface AgentAdapter {\n readonly name: string;\n readonly bootstrap?: string;\n readonly requiresFinishedEvent?: boolean;\n readonly variables?: Variables;\n readonly conversations?: \"claude\" | \"codex\";\n readonly storage?: ConversationStore;\n readonly capture?: boolean;\n readonly resumable?: boolean;\n transcriptUsage?(text: string): Usage | undefined;\n request(input: AgentInput): Command;\n events(line: string): readonly AgentEvent[];\n}\n\nexport interface RequiredAgent {\n readonly agent: AgentAdapter;\n}\n"]}
1
+ {"version":3,"file":"agent.types.js","sourceRoot":"","sources":["../../src/domain/agent.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CustomHarness } from \"./harness.types.ts\";\nimport type { AgentModel, ModelSpec } from \"./model.types.ts\";\nimport type { Command, Variables } from \"./command.types.ts\";\nimport type { ConversationStore } from \"./conversation.types.ts\";\n\nexport interface Usage {\n readonly input: number;\n readonly cached: number;\n readonly cacheCreated?: number;\n readonly output: number;\n}\n\nexport type AgentEvent =\n | {\n readonly kind: \"phase\";\n readonly name: string;\n readonly agent?: string;\n readonly branch?: string;\n readonly directory?: string;\n }\n | {\n readonly kind: \"summary\";\n readonly durationMs: number;\n readonly status: number;\n readonly tokens: Usage;\n }\n | { readonly kind: \"warning\"; readonly message: string }\n | { readonly kind: \"text\"; readonly text: string }\n | { readonly kind: \"text-delta\"; readonly text: string }\n | { readonly kind: \"result\"; readonly text: string }\n | { readonly kind: \"prompt\"; readonly text: string }\n | {\n readonly kind: \"tool\";\n readonly name: string;\n readonly input: unknown;\n readonly callId?: string;\n }\n | {\n readonly kind: \"tool-result\";\n readonly callId: string;\n readonly name: string;\n readonly isError: boolean;\n readonly preview: string;\n readonly characters: number;\n }\n | { readonly kind: \"step\"; readonly index: number }\n | {\n readonly kind: \"tool-denied\";\n readonly callId: string;\n readonly name: string;\n readonly reason: string;\n }\n | { readonly kind: \"stop-prevented\"; readonly message: string }\n | {\n readonly kind: \"compaction\";\n readonly strategy: string;\n readonly messages: number;\n }\n | { readonly kind: \"conversation\"; readonly id: string }\n | { readonly kind: \"usage\"; readonly tokens: Usage }\n | { readonly kind: \"failure\"; readonly message: string }\n | { readonly kind: \"finished\" }\n | { readonly kind: \"raw\"; readonly value: unknown };\n\nexport type AgentObservation = AgentEvent & {\n readonly pass: number;\n readonly at: string;\n};\n\nexport type AgentEventHandlers = {\n readonly [Kind in AgentEvent[\"kind\"]]?: (\n event: Extract<AgentEvent, { kind: Kind }>,\n ) => void;\n};\n\nexport interface AgentInput {\n readonly text?: string;\n readonly interactive?: boolean;\n readonly continuation?: { readonly id: string; readonly fork?: boolean };\n}\n\nexport interface AgentFeatures {\n readonly name: string;\n readonly bootstrap?: string;\n readonly requiresFinishedEvent?: boolean;\n readonly variables?: Variables;\n readonly conversations?: \"claude\" | \"codex\";\n readonly storage?: ConversationStore;\n readonly capture?: boolean;\n readonly resumable?: boolean;\n transcriptUsage?(text: string): Usage | undefined;\n}\n\nexport interface AgentAdapter extends AgentFeatures {\n authenticate?(\n variables: Readonly<Record<string, string>>,\n ): Command | undefined;\n request(input: AgentInput): Command;\n events(line: string): readonly AgentEvent[];\n}\n\nexport interface RequiredAgent {\n readonly agent: Agent;\n}\n\nexport interface CliHarness {\n readonly kind: \"cli\";\n bind(model?: AgentModel): AgentAdapter;\n}\n\nexport type Harness = CliHarness | CustomHarness;\n\nexport interface CliAgent extends AgentAdapter {\n readonly kind: \"cli\";\n readonly harness: CliHarness;\n readonly model?: AgentModel;\n}\n\nexport interface CustomAgent extends AgentFeatures {\n readonly resumable: boolean;\n readonly capture: boolean;\n readonly kind: \"custom\";\n readonly harness: CustomHarness;\n readonly model: AgentModel;\n}\n\nexport type Agent = CliAgent | CustomAgent;\n\nexport interface CliAgentOptions {\n readonly harness: CliHarness;\n readonly model?: ModelSpec;\n}\nexport interface CustomAgentOptions {\n readonly harness: CustomHarness;\n readonly model: ModelSpec;\n}\nexport type AgentOptions = CliAgentOptions | CustomAgentOptions;\n\nexport type AgentAuthentication =\n | { readonly mode: \"api-key\"; readonly environment?: string }\n | { readonly mode: \"oauth-token\" }\n | { readonly mode: \"login\"; readonly credentials?: string };\n"]}
@@ -0,0 +1,7 @@
1
+ export declare const CONTEXT_DEFAULTS: {
2
+ readonly keepRecentResults: 4;
3
+ readonly truncatedCharacters: 2000;
4
+ readonly triggerCharacters: 400000;
5
+ readonly keepRecentMessages: 6;
6
+ };
7
+ export declare const SUMMARY_INSTRUCTIONS = "Summarize this earlier part of an agent conversation for the agent that will continue it. Keep the task, decisions, files and commands involved, results, errors and open questions. Be factual and concise.";
@@ -0,0 +1,8 @@
1
+ export const CONTEXT_DEFAULTS = {
2
+ keepRecentResults: 4,
3
+ truncatedCharacters: 2_000,
4
+ triggerCharacters: 400_000,
5
+ keepRecentMessages: 6,
6
+ };
7
+ export const SUMMARY_INSTRUCTIONS = "Summarize this earlier part of an agent conversation for the agent that will continue it. Keep the task, decisions, files and commands involved, results, errors and open questions. Be factual and concise.";
8
+ //# sourceMappingURL=context.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.constants.js","sourceRoot":"","sources":["../../src/domain/context.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,iBAAiB,EAAE,CAAC;IACpB,mBAAmB,EAAE,KAAK;IAC1B,iBAAiB,EAAE,OAAO;IAC1B,kBAAkB,EAAE,CAAC;CACb,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB,GAC/B,8MAA8M,CAAC","sourcesContent":["export const CONTEXT_DEFAULTS = {\n keepRecentResults: 4,\n truncatedCharacters: 2_000,\n triggerCharacters: 400_000,\n keepRecentMessages: 6,\n} as const;\n\nexport const SUMMARY_INSTRUCTIONS =\n \"Summarize this earlier part of an agent conversation for the agent that will continue it. Keep the task, decisions, files and commands involved, results, errors and open questions. Be factual and concise.\";\n"]}
@@ -0,0 +1,4 @@
1
+ import type { HarnessContextStrategy, HarnessContextStrategyOptions, SummarizeHistoryOptions, TruncateToolResultsOptions } from "./context.types.ts";
2
+ export declare function defineHarnessContextStrategy(options: HarnessContextStrategyOptions): HarnessContextStrategy;
3
+ export declare function truncateToolResults(options?: TruncateToolResultsOptions): HarnessContextStrategy;
4
+ export declare function summarizeHistory(options?: SummarizeHistoryOptions): HarnessContextStrategy;
@@ -0,0 +1,81 @@
1
+ import { CONTEXT_DEFAULTS } from "./context.constants.js";
2
+ import { invariant, positive } from "./errors.js";
3
+ export function defineHarnessContextStrategy(options) {
4
+ invariant(options !== null &&
5
+ typeof options === "object" &&
6
+ typeof options.name === "string" &&
7
+ options.name.trim() &&
8
+ typeof options.compact === "function", "Context strategies need a name and a compact function");
9
+ return Object.freeze({
10
+ kind: "context",
11
+ name: options.name,
12
+ compact: async (input) => options.compact(input),
13
+ });
14
+ }
15
+ export function truncateToolResults(options = {}) {
16
+ const keepRecent = positive(options.keepRecent ?? CONTEXT_DEFAULTS.keepRecentResults, "keepRecent");
17
+ const maxCharacters = positive(options.maxCharacters ?? CONTEXT_DEFAULTS.truncatedCharacters, "maxCharacters");
18
+ return defineHarnessContextStrategy({
19
+ name: "truncate-tool-results",
20
+ compact({ messages }) {
21
+ const carriers = messages.flatMap((message, index) => message.content.some((block) => block.type === "tool-result")
22
+ ? [index]
23
+ : []);
24
+ const older = new Set(carriers.slice(0, -keepRecent));
25
+ let changed = false;
26
+ const compacted = messages.map((message, index) => {
27
+ if (!older.has(index))
28
+ return message;
29
+ return {
30
+ ...message,
31
+ content: message.content.map((block) => {
32
+ if (block.type !== "tool-result" ||
33
+ block.content.length <= maxCharacters)
34
+ return block;
35
+ changed = true;
36
+ return {
37
+ ...block,
38
+ content: `${block.content.slice(0, maxCharacters)}\n[earlier output truncated from ${block.content.length} characters]`,
39
+ };
40
+ }),
41
+ };
42
+ });
43
+ return changed ? compacted : undefined;
44
+ },
45
+ });
46
+ }
47
+ export function summarizeHistory(options = {}) {
48
+ const trigger = positive(options.triggerCharacters ?? CONTEXT_DEFAULTS.triggerCharacters, "triggerCharacters");
49
+ const keep = positive(options.keepRecentMessages ?? CONTEXT_DEFAULTS.keepRecentMessages, "keepRecentMessages");
50
+ return defineHarnessContextStrategy({
51
+ name: "summarize-history",
52
+ async compact({ messages, summarize }) {
53
+ if (JSON.stringify(messages).length <= trigger)
54
+ return undefined;
55
+ const cut = boundary(messages, Math.max(2, messages.length - keep));
56
+ if (cut === undefined)
57
+ return undefined;
58
+ const summary = await summarize(messages.slice(1, cut));
59
+ return [
60
+ messages[0],
61
+ {
62
+ role: "user",
63
+ content: [
64
+ {
65
+ type: "text",
66
+ text: `Summary of the earlier conversation:\n${summary}`,
67
+ },
68
+ ],
69
+ },
70
+ ...messages.slice(cut),
71
+ ];
72
+ },
73
+ });
74
+ }
75
+ function boundary(messages, from) {
76
+ for (let index = Math.min(from, messages.length - 1); index > 1; index--)
77
+ if (messages[index].role === "assistant")
78
+ return index;
79
+ return undefined;
80
+ }
81
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/domain/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAQ1D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,UAAU,4BAA4B,CAC1C,OAAsC;IAEtC,SAAS,CACP,OAAO,KAAK,IAAI;QACd,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ;QAChC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE;QACnB,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EACvC,uDAAuD,CACxD,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,KAAK,EAAE,KAA0B,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;KACtE,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,UAAsC,EAAE;IAExC,MAAM,UAAU,GAAG,QAAQ,CACzB,OAAO,CAAC,UAAU,IAAI,gBAAgB,CAAC,iBAAiB,EACxD,YAAY,CACb,CAAC;IACF,MAAM,aAAa,GAAG,QAAQ,CAC5B,OAAO,CAAC,aAAa,IAAI,gBAAgB,CAAC,mBAAmB,EAC7D,eAAe,CAChB,CAAC;IACF,OAAO,4BAA4B,CAAC;QAClC,IAA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,EAAE,KAAK,EAAE;QACtE,IAAI,QAAQ,CAAC,KAAK,CAAE,CAAC,IAAI,KAAK,WAAW;YAAE,OAAO,KAAK,CAAC;IAC1D,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { CONTEXT_DEFAULTS } from \"./context.constants.ts\";\nimport type {\n HarnessContextInput,\n HarnessContextStrategy,\n HarnessContextStrategyOptions,\n SummarizeHistoryOptions,\n TruncateToolResultsOptions,\n} from \"./context.types.ts\";\nimport { invariant, positive } from \"./errors.ts\";\nimport type { ModelMessage } from \"./model.types.ts\";\n\nexport function defineHarnessContextStrategy(\n options: HarnessContextStrategyOptions,\n): HarnessContextStrategy {\n invariant(\n options !== null &&\n typeof options === \"object\" &&\n typeof options.name === \"string\" &&\n options.name.trim() &&\n typeof options.compact === \"function\",\n \"Context strategies need a name and a compact function\",\n );\n return Object.freeze({\n kind: \"context\",\n name: options.name,\n compact: async (input: HarnessContextInput) => options.compact(input),\n });\n}\n\nexport function truncateToolResults(\n options: TruncateToolResultsOptions = {},\n): HarnessContextStrategy {\n const keepRecent = positive(\n options.keepRecent ?? CONTEXT_DEFAULTS.keepRecentResults,\n \"keepRecent\",\n );\n const maxCharacters = positive(\n options.maxCharacters ?? CONTEXT_DEFAULTS.truncatedCharacters,\n \"maxCharacters\",\n );\n return defineHarnessContextStrategy({\n name: \"truncate-tool-results\",\n compact({ messages }) {\n const carriers = messages.flatMap((message, index) =>\n message.content.some((block) => block.type === \"tool-result\")\n ? [index]\n : [],\n );\n const older = new Set(carriers.slice(0, -keepRecent));\n let changed = false;\n const compacted = messages.map((message, index): ModelMessage => {\n if (!older.has(index)) return message;\n return {\n ...message,\n content: message.content.map((block) => {\n if (\n block.type !== \"tool-result\" ||\n block.content.length <= maxCharacters\n )\n return block;\n changed = true;\n return {\n ...block,\n content: `${block.content.slice(0, maxCharacters)}\\n[earlier output truncated from ${block.content.length} characters]`,\n };\n }),\n };\n });\n return changed ? compacted : undefined;\n },\n });\n}\n\nexport function summarizeHistory(\n options: SummarizeHistoryOptions = {},\n): HarnessContextStrategy {\n const trigger = positive(\n options.triggerCharacters ?? CONTEXT_DEFAULTS.triggerCharacters,\n \"triggerCharacters\",\n );\n const keep = positive(\n options.keepRecentMessages ?? CONTEXT_DEFAULTS.keepRecentMessages,\n \"keepRecentMessages\",\n );\n return defineHarnessContextStrategy({\n name: \"summarize-history\",\n async compact({ messages, summarize }) {\n if (JSON.stringify(messages).length <= trigger) return undefined;\n const cut = boundary(messages, Math.max(2, messages.length - keep));\n if (cut === undefined) return undefined;\n const summary = await summarize(messages.slice(1, cut));\n return [\n messages[0]!,\n {\n role: \"user\",\n content: [\n {\n type: \"text\",\n text: `Summary of the earlier conversation:\\n${summary}`,\n },\n ],\n },\n ...messages.slice(cut),\n ];\n },\n });\n}\n\nfunction boundary(\n messages: readonly ModelMessage[],\n from: number,\n): number | undefined {\n for (let index = Math.min(from, messages.length - 1); index > 1; index--)\n if (messages[index]!.role === \"assistant\") return index;\n return undefined;\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import type { AgentModel, ModelMessage } from "./model.types.ts";
2
+ export interface HarnessContextInput {
3
+ readonly messages: readonly ModelMessage[];
4
+ readonly step: number;
5
+ readonly model: AgentModel;
6
+ readonly signal: AbortSignal;
7
+ summarize(messages: readonly ModelMessage[]): Promise<string>;
8
+ }
9
+ export type HarnessContextResult = readonly ModelMessage[] | undefined;
10
+ export interface HarnessContextStrategyOptions {
11
+ readonly name: string;
12
+ compact(input: HarnessContextInput): HarnessContextResult | Promise<HarnessContextResult>;
13
+ }
14
+ export interface HarnessContextStrategy {
15
+ readonly kind: "context";
16
+ readonly name: string;
17
+ compact(input: HarnessContextInput): Promise<HarnessContextResult>;
18
+ }
19
+ export interface TruncateToolResultsOptions {
20
+ readonly keepRecent?: number;
21
+ readonly maxCharacters?: number;
22
+ }
23
+ export interface SummarizeHistoryOptions {
24
+ readonly triggerCharacters?: number;
25
+ readonly keepRecentMessages?: number;
26
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.types.js","sourceRoot":"","sources":["../../src/domain/context.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AgentModel, ModelMessage } from \"./model.types.ts\";\n\nexport interface HarnessContextInput {\n readonly messages: readonly ModelMessage[];\n readonly step: number;\n readonly model: AgentModel;\n readonly signal: AbortSignal;\n summarize(messages: readonly ModelMessage[]): Promise<string>;\n}\n\nexport type HarnessContextResult = readonly ModelMessage[] | undefined;\n\nexport interface HarnessContextStrategyOptions {\n readonly name: string;\n compact(\n input: HarnessContextInput,\n ): HarnessContextResult | Promise<HarnessContextResult>;\n}\n\nexport interface HarnessContextStrategy {\n readonly kind: \"context\";\n readonly name: string;\n compact(input: HarnessContextInput): Promise<HarnessContextResult>;\n}\n\nexport interface TruncateToolResultsOptions {\n readonly keepRecent?: number;\n readonly maxCharacters?: number;\n}\n\nexport interface SummarizeHistoryOptions {\n readonly triggerCharacters?: number;\n readonly keepRecentMessages?: number;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import type { Usage } from "./agent.types.ts";
2
+ export interface DispatchTelemetryOutcome {
3
+ readonly status: "done" | "failed" | "cancelled";
4
+ readonly usage: Usage;
5
+ readonly completed?: boolean;
6
+ }
7
+ export interface DispatchTelemetrySession {
8
+ finish(outcome: DispatchTelemetryOutcome): void;
9
+ }
10
+ export interface DispatchTelemetry {
11
+ startDispatch(): DispatchTelemetrySession;
12
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dispatch-telemetry.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-telemetry.types.js","sourceRoot":"","sources":["../../src/domain/dispatch-telemetry.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Usage } from \"./agent.types.ts\";\n\nexport interface DispatchTelemetryOutcome {\n readonly status: \"done\" | \"failed\" | \"cancelled\";\n readonly usage: Usage;\n readonly completed?: boolean;\n}\n\nexport interface DispatchTelemetrySession {\n finish(outcome: DispatchTelemetryOutcome): void;\n}\n\nexport interface DispatchTelemetry {\n startDispatch(): DispatchTelemetrySession;\n}\n"]}
@@ -1 +1 @@
1
- export type FaultCode = "configuration" | "process" | "timeout" | "aborted" | "workspace" | "conflict" | "prompt" | "response" | "session" | "provider";
1
+ export type FaultCode = "configuration" | "process" | "timeout" | "aborted" | "workspace" | "conflict" | "prompt" | "response" | "session" | "provider" | "limit";
@@ -1 +1 @@
1
- {"version":3,"file":"errors.types.js","sourceRoot":"","sources":["../../src/domain/errors.types.ts"],"names":[],"mappings":"","sourcesContent":["export type FaultCode =\n | \"configuration\"\n | \"process\"\n | \"timeout\"\n | \"aborted\"\n | \"workspace\"\n | \"conflict\"\n | \"prompt\"\n | \"response\"\n | \"session\"\n | \"provider\";\n"]}
1
+ {"version":3,"file":"errors.types.js","sourceRoot":"","sources":["../../src/domain/errors.types.ts"],"names":[],"mappings":"","sourcesContent":["export type FaultCode =\n | \"configuration\"\n | \"process\"\n | \"timeout\"\n | \"aborted\"\n | \"workspace\"\n | \"conflict\"\n | \"prompt\"\n | \"response\"\n | \"session\"\n | \"provider\"\n | \"limit\";\n"]}
@@ -0,0 +1,2 @@
1
+ import type { GlobMode } from "./glob.types.ts";
2
+ export declare function glob(pattern: string, mode: GlobMode): RegExp;
@@ -0,0 +1,25 @@
1
+ const stars = {
2
+ path: "[^/]*",
3
+ text: "[^]*",
4
+ };
5
+ const tokens = {
6
+ "*": (mode) => stars[mode],
7
+ "?": () => "[^/]",
8
+ };
9
+ export function glob(pattern, mode) {
10
+ let source = "";
11
+ for (let index = 0; index < pattern.length; index++) {
12
+ const character = pattern[index];
13
+ if (character === "*" && pattern[index + 1] === "*") {
14
+ const directory = pattern[index + 2] === "/";
15
+ source += directory ? "(?:[^]*/)?" : "[^]*";
16
+ index += directory ? 2 : 1;
17
+ continue;
18
+ }
19
+ source +=
20
+ tokens[character]?.(mode) ??
21
+ character.replace(/[.+^${}()|[\]\\]/g, "\\$&");
22
+ }
23
+ return new RegExp(`^${source}$`);
24
+ }
25
+ //# sourceMappingURL=glob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/domain/glob.ts"],"names":[],"mappings":"AAEA,MAAM,KAAK,GAAuC;IAChD,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,MAAM,MAAM,GAAyD;IACnE,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;IAC1B,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM;CAClB,CAAC;AAEF,MAAM,UAAU,IAAI,CAAC,OAAe,EAAE,IAAc;IAClD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACpD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAE,CAAC;QAClC,IAAI,SAAS,KAAK,GAAG,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACpD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;YAC7C,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC;YAC5C,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3B,SAAS;QACX,CAAC;QACD,MAAM;YACJ,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC;gBACzB,SAAS,CAAC,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type { GlobMode } from \"./glob.types.ts\";\n\nconst stars: Readonly<Record<GlobMode, string>> = {\n path: \"[^/]*\",\n text: \"[^]*\",\n};\n\nconst tokens: Readonly<Record<string, (mode: GlobMode) => string>> = {\n \"*\": (mode) => stars[mode],\n \"?\": () => \"[^/]\",\n};\n\nexport function glob(pattern: string, mode: GlobMode): RegExp {\n let source = \"\";\n for (let index = 0; index < pattern.length; index++) {\n const character = pattern[index]!;\n if (character === \"*\" && pattern[index + 1] === \"*\") {\n const directory = pattern[index + 2] === \"/\";\n source += directory ? \"(?:[^]*/)?\" : \"[^]*\";\n index += directory ? 2 : 1;\n continue;\n }\n source +=\n tokens[character]?.(mode) ??\n character.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\");\n }\n return new RegExp(`^${source}$`);\n}\n"]}
@@ -0,0 +1 @@
1
+ export type GlobMode = "path" | "text";
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=glob.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.types.js","sourceRoot":"","sources":["../../src/domain/glob.types.ts"],"names":[],"mappings":"","sourcesContent":["export type GlobMode = \"path\" | \"text\";\n"]}
@@ -0,0 +1,11 @@
1
+ export declare const HARNESS_DEFAULTS: {
2
+ readonly maxSteps: 100;
3
+ readonly concurrency: 4;
4
+ readonly toolDeadlineMs: 300000;
5
+ readonly onError: "return-to-model";
6
+ readonly cache: true;
7
+ };
8
+ export declare const HARNESS_FIELDS: ReadonlySet<string>;
9
+ export declare const TOOL_RESULT_CHARACTERS = 100000;
10
+ export declare const TOOL_PREVIEW_CHARACTERS = 2000;
11
+ export declare const USAGE_FIELDS: string[];
@@ -0,0 +1,24 @@
1
+ export const HARNESS_DEFAULTS = {
2
+ maxSteps: 100,
3
+ concurrency: 4,
4
+ toolDeadlineMs: 300_000,
5
+ onError: "return-to-model",
6
+ cache: true,
7
+ };
8
+ export const HARNESS_FIELDS = new Set([
9
+ "modelProvider",
10
+ "instructions",
11
+ "tools",
12
+ "limits",
13
+ "toolExecution",
14
+ "hooks",
15
+ "permissions",
16
+ "context",
17
+ "conversations",
18
+ "skills",
19
+ "cache",
20
+ ]);
21
+ export const TOOL_RESULT_CHARACTERS = 100_000;
22
+ export const TOOL_PREVIEW_CHARACTERS = 2_000;
23
+ export const USAGE_FIELDS = ["input", "cached", "cacheCreated", "output"];
24
+ //# sourceMappingURL=harness.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness.constants.js","sourceRoot":"","sources":["../../src/domain/harness.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,GAAG;IACb,WAAW,EAAE,CAAC;IACd,cAAc,EAAE,OAAO;IACvB,OAAO,EAAE,iBAAiB;IAC1B,KAAK,EAAE,IAAI;CACH,CAAC;AAEX,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IACzD,eAAe;IACf,cAAc;IACd,OAAO;IACP,QAAQ;IACR,eAAe;IACf,OAAO;IACP,aAAa;IACb,SAAS;IACT,eAAe;IACf,QAAQ;IACR,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAE9C,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["export const HARNESS_DEFAULTS = {\n maxSteps: 100,\n concurrency: 4,\n toolDeadlineMs: 300_000,\n onError: \"return-to-model\",\n cache: true,\n} as const;\n\nexport const HARNESS_FIELDS: ReadonlySet<string> = new Set([\n \"modelProvider\",\n \"instructions\",\n \"tools\",\n \"limits\",\n \"toolExecution\",\n \"hooks\",\n \"permissions\",\n \"context\",\n \"conversations\",\n \"skills\",\n \"cache\",\n]);\n\nexport const TOOL_RESULT_CHARACTERS = 100_000;\n\nexport const TOOL_PREVIEW_CHARACTERS = 2_000;\n\nexport const USAGE_FIELDS = [\"input\", \"cached\", \"cacheCreated\", \"output\"];\n"]}
@@ -0,0 +1,2 @@
1
+ import type { CustomHarness, CustomHarnessOptions } from "./harness.types.ts";
2
+ export declare function harness(options: CustomHarnessOptions): CustomHarness;
@@ -0,0 +1,89 @@
1
+ import { invariant, positive } from "./errors.js";
2
+ import { HARNESS_DEFAULTS, HARNESS_FIELDS, USAGE_FIELDS, } from "./harness.constants.js";
3
+ import { harnessHooks } from "./hook.js";
4
+ import { defineHarnessInstructions, harnessInstructions, } from "./instructions.js";
5
+ import { harnessSkills, skillCatalog, skillLoader } from "./skill.js";
6
+ import { harnessTools } from "./tool.js";
7
+ export function harness(options) {
8
+ invariant(options !== null && typeof options === "object", "Harness options must be an object");
9
+ invariant(!("run" in options), "harness() no longer accepts run; declare tools, instructions and limits");
10
+ const unsupported = Object.keys(options).filter((key) => !HARNESS_FIELDS.has(key));
11
+ invariant(unsupported.length === 0, `Unsupported harness option: ${unsupported.join(", ")}`);
12
+ invariant(typeof options.modelProvider?.request === "function", "Custom harness requires a model provider");
13
+ invariant(options.modelProvider.validate === undefined ||
14
+ typeof options.modelProvider.validate === "function", "Model provider validate must be a function");
15
+ invariant(options.cache === undefined || typeof options.cache === "boolean", "Harness cache must be boolean");
16
+ invariant(options.permissions === undefined ||
17
+ options.permissions?.kind === "permissions", "Declare permissions with defineHarnessPermissions");
18
+ invariant(options.context === undefined || options.context?.kind === "context", "Declare context strategies with defineHarnessContextStrategy");
19
+ invariant(options.conversations === undefined ||
20
+ options.conversations === false ||
21
+ conversationStore(options.conversations), "Harness conversations must be a conversation store or false");
22
+ const skills = harnessSkills(options.skills);
23
+ return Object.freeze({
24
+ kind: "custom",
25
+ modelProvider: options.modelProvider,
26
+ instructions: Object.freeze([
27
+ ...harnessInstructions(options.instructions),
28
+ ...(skills.length
29
+ ? [defineHarnessInstructions(skillCatalog(skills))]
30
+ : []),
31
+ ]),
32
+ tools: harnessTools([
33
+ ...(options.tools ?? []),
34
+ ...skills.flatMap((skill) => skill.tools),
35
+ ...(skills.length ? [skillLoader(skills)] : []),
36
+ ]),
37
+ skills,
38
+ limits: limits(options.limits ?? {}),
39
+ toolExecution: toolExecution(options.toolExecution ?? {}),
40
+ hooks: harnessHooks(options.hooks),
41
+ ...(options.permissions ? { permissions: options.permissions } : {}),
42
+ ...(options.context ? { context: options.context } : {}),
43
+ ...(options.conversations === undefined
44
+ ? {}
45
+ : { conversations: options.conversations }),
46
+ cache: options.cache ?? HARNESS_DEFAULTS.cache,
47
+ });
48
+ }
49
+ function limits(value) {
50
+ invariant(value !== null && typeof value === "object", "Harness limits must be an object");
51
+ const maxSteps = positive(value.maxSteps ?? HARNESS_DEFAULTS.maxSteps, "Harness maxSteps");
52
+ if (value.maxToolCalls !== undefined)
53
+ positive(value.maxToolCalls, "Harness maxToolCalls");
54
+ if (value.usage !== undefined) {
55
+ invariant(value.usage !== null &&
56
+ typeof value.usage === "object" &&
57
+ Object.keys(value.usage).every((key) => USAGE_FIELDS.includes(key)), "Harness usage limits accept input, cached, cacheCreated and output");
58
+ for (const limit of Object.values(value.usage))
59
+ invariant(Number.isSafeInteger(limit) && limit >= 0, "Harness usage limits must be nonnegative integers");
60
+ }
61
+ return Object.freeze({
62
+ maxSteps,
63
+ ...(value.maxToolCalls === undefined
64
+ ? {}
65
+ : { maxToolCalls: value.maxToolCalls }),
66
+ ...(value.usage === undefined
67
+ ? {}
68
+ : { usage: Object.freeze({ ...value.usage }) }),
69
+ });
70
+ }
71
+ function toolExecution(value) {
72
+ invariant(value !== null && typeof value === "object", "Harness toolExecution must be an object");
73
+ invariant(value.onError === undefined ||
74
+ value.onError === "return-to-model" ||
75
+ value.onError === "fail", 'Tool onError must be "return-to-model" or "fail"');
76
+ return Object.freeze({
77
+ concurrency: positive(value.concurrency ?? HARNESS_DEFAULTS.concurrency, "Tool concurrency"),
78
+ deadlineMs: positive(value.deadlineMs ?? HARNESS_DEFAULTS.toolDeadlineMs, "Tool deadlineMs"),
79
+ onError: value.onError ?? HARNESS_DEFAULTS.onError,
80
+ });
81
+ }
82
+ function conversationStore(value) {
83
+ return (value !== null &&
84
+ typeof value === "object" &&
85
+ typeof value.locate === "function" &&
86
+ typeof value.capture === "function" &&
87
+ typeof value.restore === "function");
88
+ }
89
+ //# sourceMappingURL=harness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness.js","sourceRoot":"","sources":["../../src/domain/harness.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,YAAY,GACb,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,UAAU,OAAO,CAAC,OAA6B;IACnD,SAAS,CACP,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAC/C,mCAAmC,CACpC,CAAC;IACF,SAAS,CACP,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC,EACnB,yEAAyE,CAC1E,CAAC;IACF,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAClC,CAAC;IACF,SAAS,CACP,WAAW,CAAC,MAAM,KAAK,CAAC,EACxB,+BAA+B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxD,CAAC;IACF,SAAS,CACP,OAAO,OAAO,CAAC,aAAa,EAAE,OAAO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CAAC,WAAW,IAAI,gBAAgB,CAAC,WAAW,EACjD,kBAAkB,CACnB;QACD,UAAU,EAAE,QAAQ,CAClB,KAAK,CAAC,UAAU,IAAI,gBAAgB,CAAC,cAAc,EACnD,iBAAiB,CAClB;QACD,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,gBAAgB,CAAC,OAAO;KACnD,CAAC,CAAC;AACL,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAwB;IACjD,OAAO,CACL,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,CAAC,MAAM,KAAK,UAAU;QAClC,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU;QACnC,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU,CACpC,CAAC;AACJ,CAAC","sourcesContent":["import type { ConversationStore } from \"./conversation.types.ts\";\nimport { invariant, positive } from \"./errors.ts\";\nimport {\n HARNESS_DEFAULTS,\n HARNESS_FIELDS,\n USAGE_FIELDS,\n} from \"./harness.constants.ts\";\nimport type {\n CustomHarness,\n CustomHarnessOptions,\n HarnessLimits,\n HarnessToolExecution,\n ResolvedHarnessLimits,\n} from \"./harness.types.ts\";\nimport { harnessHooks } from \"./hook.ts\";\nimport {\n defineHarnessInstructions,\n harnessInstructions,\n} from \"./instructions.ts\";\nimport { harnessSkills, skillCatalog, skillLoader } from \"./skill.ts\";\nimport { harnessTools } from \"./tool.ts\";\n\nexport function harness(options: CustomHarnessOptions): CustomHarness {\n invariant(\n options !== null && typeof options === \"object\",\n \"Harness options must be an object\",\n );\n invariant(\n !(\"run\" in options),\n \"harness() no longer accepts run; declare tools, instructions and limits\",\n );\n const unsupported = Object.keys(options).filter(\n (key) => !HARNESS_FIELDS.has(key),\n );\n invariant(\n unsupported.length === 0,\n `Unsupported harness option: ${unsupported.join(\", \")}`,\n );\n invariant(\n typeof options.modelProvider?.request === \"function\",\n \"Custom harness requires a model provider\",\n );\n invariant(\n options.modelProvider.validate === undefined ||\n typeof options.modelProvider.validate === \"function\",\n \"Model provider validate must be a function\",\n );\n invariant(\n options.cache === undefined || typeof options.cache === \"boolean\",\n \"Harness cache must be boolean\",\n );\n invariant(\n options.permissions === undefined ||\n options.permissions?.kind === \"permissions\",\n \"Declare permissions with defineHarnessPermissions\",\n );\n invariant(\n options.context === undefined || options.context?.kind === \"context\",\n \"Declare context strategies with defineHarnessContextStrategy\",\n );\n invariant(\n options.conversations === undefined ||\n options.conversations === false ||\n conversationStore(options.conversations),\n \"Harness conversations must be a conversation store or false\",\n );\n const skills = harnessSkills(options.skills);\n return Object.freeze({\n kind: \"custom\",\n modelProvider: options.modelProvider,\n instructions: Object.freeze([\n ...harnessInstructions(options.instructions),\n ...(skills.length\n ? [defineHarnessInstructions(skillCatalog(skills))]\n : []),\n ]),\n tools: harnessTools([\n ...(options.tools ?? []),\n ...skills.flatMap((skill) => skill.tools),\n ...(skills.length ? [skillLoader(skills)] : []),\n ]),\n skills,\n limits: limits(options.limits ?? {}),\n toolExecution: toolExecution(options.toolExecution ?? {}),\n hooks: harnessHooks(options.hooks),\n ...(options.permissions ? { permissions: options.permissions } : {}),\n ...(options.context ? { context: options.context } : {}),\n ...(options.conversations === undefined\n ? {}\n : { conversations: options.conversations }),\n cache: options.cache ?? HARNESS_DEFAULTS.cache,\n });\n}\n\nfunction limits(value: HarnessLimits): ResolvedHarnessLimits {\n invariant(\n value !== null && typeof value === \"object\",\n \"Harness limits must be an object\",\n );\n const maxSteps = positive(\n value.maxSteps ?? HARNESS_DEFAULTS.maxSteps,\n \"Harness maxSteps\",\n );\n if (value.maxToolCalls !== undefined)\n positive(value.maxToolCalls, \"Harness maxToolCalls\");\n if (value.usage !== undefined) {\n invariant(\n value.usage !== null &&\n typeof value.usage === \"object\" &&\n Object.keys(value.usage).every((key) => USAGE_FIELDS.includes(key)),\n \"Harness usage limits accept input, cached, cacheCreated and output\",\n );\n for (const limit of Object.values(value.usage))\n invariant(\n Number.isSafeInteger(limit) && limit >= 0,\n \"Harness usage limits must be nonnegative integers\",\n );\n }\n return Object.freeze({\n maxSteps,\n ...(value.maxToolCalls === undefined\n ? {}\n : { maxToolCalls: value.maxToolCalls }),\n ...(value.usage === undefined\n ? {}\n : { usage: Object.freeze({ ...value.usage }) }),\n });\n}\n\nfunction toolExecution(\n value: HarnessToolExecution,\n): Required<HarnessToolExecution> {\n invariant(\n value !== null && typeof value === \"object\",\n \"Harness toolExecution must be an object\",\n );\n invariant(\n value.onError === undefined ||\n value.onError === \"return-to-model\" ||\n value.onError === \"fail\",\n 'Tool onError must be \"return-to-model\" or \"fail\"',\n );\n return Object.freeze({\n concurrency: positive(\n value.concurrency ?? HARNESS_DEFAULTS.concurrency,\n \"Tool concurrency\",\n ),\n deadlineMs: positive(\n value.deadlineMs ?? HARNESS_DEFAULTS.toolDeadlineMs,\n \"Tool deadlineMs\",\n ),\n onError: value.onError ?? HARNESS_DEFAULTS.onError,\n });\n}\n\nfunction conversationStore(value: ConversationStore): boolean {\n return (\n value !== null &&\n typeof value === \"object\" &&\n typeof value.locate === \"function\" &&\n typeof value.capture === \"function\" &&\n typeof value.restore === \"function\"\n );\n}\n"]}
@@ -0,0 +1,60 @@
1
+ import type { Usage } from "./agent.types.ts";
2
+ import type { HarnessContextStrategy } from "./context.types.ts";
3
+ import type { ConversationStore } from "./conversation.types.ts";
4
+ import type { HarnessHook } from "./hook.types.ts";
5
+ import type { AgentModel, ModelProvider } from "./model.types.ts";
6
+ import type { HarnessPermissions } from "./permissions.types.ts";
7
+ import type { HarnessSkill } from "./skill.types.ts";
8
+ import type { SandboxLease } from "./sandbox.types.ts";
9
+ import type { HarnessTool, HarnessToolset } from "./tool.types.ts";
10
+ export interface HarnessInstructionContext {
11
+ readonly sandbox: SandboxLease;
12
+ readonly signal: AbortSignal;
13
+ readonly model: AgentModel;
14
+ }
15
+ export type HarnessInstructionSource = string | ((context: HarnessInstructionContext) => string | Promise<string>);
16
+ export interface HarnessInstructions {
17
+ readonly kind: "instructions";
18
+ resolve(context: HarnessInstructionContext): Promise<string>;
19
+ }
20
+ export type HarnessInstructionsOption = string | HarnessInstructions | readonly (string | HarnessInstructions)[];
21
+ export interface HarnessLimits {
22
+ readonly maxSteps?: number;
23
+ readonly maxToolCalls?: number;
24
+ readonly usage?: Partial<Usage>;
25
+ }
26
+ export interface ResolvedHarnessLimits extends HarnessLimits {
27
+ readonly maxSteps: number;
28
+ }
29
+ export interface HarnessToolExecution {
30
+ readonly concurrency?: number;
31
+ readonly deadlineMs?: number;
32
+ readonly onError?: "return-to-model" | "fail";
33
+ }
34
+ export interface CustomHarnessOptions {
35
+ readonly modelProvider: ModelProvider;
36
+ readonly instructions?: HarnessInstructionsOption;
37
+ readonly tools?: readonly (HarnessTool | HarnessToolset)[];
38
+ readonly limits?: HarnessLimits;
39
+ readonly toolExecution?: HarnessToolExecution;
40
+ readonly hooks?: readonly HarnessHook[];
41
+ readonly permissions?: HarnessPermissions;
42
+ readonly context?: HarnessContextStrategy;
43
+ readonly conversations?: ConversationStore | false;
44
+ readonly skills?: readonly HarnessSkill[];
45
+ readonly cache?: boolean;
46
+ }
47
+ export interface CustomHarness {
48
+ readonly kind: "custom";
49
+ readonly modelProvider: ModelProvider;
50
+ readonly instructions: readonly HarnessInstructions[];
51
+ readonly tools: readonly HarnessTool[];
52
+ readonly limits: ResolvedHarnessLimits;
53
+ readonly toolExecution: Required<HarnessToolExecution>;
54
+ readonly hooks: readonly HarnessHook[];
55
+ readonly permissions?: HarnessPermissions;
56
+ readonly context?: HarnessContextStrategy;
57
+ readonly conversations?: ConversationStore | false;
58
+ readonly skills: readonly HarnessSkill[];
59
+ readonly cache: boolean;
60
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=harness.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness.types.js","sourceRoot":"","sources":["../../src/domain/harness.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Usage } from \"./agent.types.ts\";\nimport type { HarnessContextStrategy } from \"./context.types.ts\";\nimport type { ConversationStore } from \"./conversation.types.ts\";\nimport type { HarnessHook } from \"./hook.types.ts\";\nimport type { AgentModel, ModelProvider } from \"./model.types.ts\";\nimport type { HarnessPermissions } from \"./permissions.types.ts\";\nimport type { HarnessSkill } from \"./skill.types.ts\";\nimport type { SandboxLease } from \"./sandbox.types.ts\";\nimport type { HarnessTool, HarnessToolset } from \"./tool.types.ts\";\n\nexport interface HarnessInstructionContext {\n readonly sandbox: SandboxLease;\n readonly signal: AbortSignal;\n readonly model: AgentModel;\n}\n\nexport type HarnessInstructionSource =\n string | ((context: HarnessInstructionContext) => string | Promise<string>);\n\nexport interface HarnessInstructions {\n readonly kind: \"instructions\";\n resolve(context: HarnessInstructionContext): Promise<string>;\n}\n\nexport type HarnessInstructionsOption =\n string | HarnessInstructions | readonly (string | HarnessInstructions)[];\n\nexport interface HarnessLimits {\n readonly maxSteps?: number;\n readonly maxToolCalls?: number;\n readonly usage?: Partial<Usage>;\n}\n\nexport interface ResolvedHarnessLimits extends HarnessLimits {\n readonly maxSteps: number;\n}\n\nexport interface HarnessToolExecution {\n readonly concurrency?: number;\n readonly deadlineMs?: number;\n readonly onError?: \"return-to-model\" | \"fail\";\n}\n\nexport interface CustomHarnessOptions {\n readonly modelProvider: ModelProvider;\n readonly instructions?: HarnessInstructionsOption;\n readonly tools?: readonly (HarnessTool | HarnessToolset)[];\n readonly limits?: HarnessLimits;\n readonly toolExecution?: HarnessToolExecution;\n readonly hooks?: readonly HarnessHook[];\n readonly permissions?: HarnessPermissions;\n readonly context?: HarnessContextStrategy;\n readonly conversations?: ConversationStore | false;\n readonly skills?: readonly HarnessSkill[];\n readonly cache?: boolean;\n}\n\nexport interface CustomHarness {\n readonly kind: \"custom\";\n readonly modelProvider: ModelProvider;\n readonly instructions: readonly HarnessInstructions[];\n readonly tools: readonly HarnessTool[];\n readonly limits: ResolvedHarnessLimits;\n readonly toolExecution: Required<HarnessToolExecution>;\n readonly hooks: readonly HarnessHook[];\n readonly permissions?: HarnessPermissions;\n readonly context?: HarnessContextStrategy;\n readonly conversations?: ConversationStore | false;\n readonly skills: readonly HarnessSkill[];\n readonly cache: boolean;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { HarnessHookPhase } from "./hook.types.ts";
2
+ export declare const HOOK_PHASES: ReadonlySet<HarnessHookPhase>;
3
+ export declare const HOOK_FIELDS: ReadonlySet<string>;
@@ -0,0 +1,10 @@
1
+ export const HOOK_PHASES = new Set([
2
+ "session-start",
3
+ "before-model",
4
+ "after-model",
5
+ "before-tool",
6
+ "after-tool",
7
+ "stop",
8
+ ]);
9
+ export const HOOK_FIELDS = new Set(["on", "name", "run"]);
10
+ //# sourceMappingURL=hook.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.constants.js","sourceRoot":"","sources":["../../src/domain/hook.constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAkC,IAAI,GAAG,CAAC;IAChE,eAAe;IACf,cAAc;IACd,aAAa;IACb,aAAa;IACb,YAAY;IACZ,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC","sourcesContent":["import type { HarnessHookPhase } from \"./hook.types.ts\";\n\nexport const HOOK_PHASES: ReadonlySet<HarnessHookPhase> = new Set([\n \"session-start\",\n \"before-model\",\n \"after-model\",\n \"before-tool\",\n \"after-tool\",\n \"stop\",\n]);\n\nexport const HOOK_FIELDS: ReadonlySet<string> = new Set([\"on\", \"name\", \"run\"]);\n"]}
@@ -0,0 +1,3 @@
1
+ import type { HarnessHook, HarnessHookOptions, HarnessHookPhase } from "./hook.types.ts";
2
+ export declare function defineHarnessHook<Phase extends HarnessHookPhase>(options: HarnessHookOptions<Phase>): HarnessHook<Phase>;
3
+ export declare function harnessHooks(hooks: readonly HarnessHook[] | undefined): readonly HarnessHook[];
@@ -0,0 +1,25 @@
1
+ import { invariant } from "./errors.js";
2
+ import { HOOK_FIELDS, HOOK_PHASES } from "./hook.constants.js";
3
+ export function defineHarnessHook(options) {
4
+ invariant(options !== null && typeof options === "object", "Hook options must be an object");
5
+ invariant(Object.keys(options).every((key) => HOOK_FIELDS.has(key)), "Unsupported hook option");
6
+ invariant(HOOK_PHASES.has(options.on), `Hook phase must be one of ${[...HOOK_PHASES].join(", ")}`);
7
+ invariant(typeof options.run === "function", "Hook run must be a function");
8
+ invariant(options.name === undefined ||
9
+ (typeof options.name === "string" && options.name.trim()), "Hook name must be nonempty text");
10
+ return Object.freeze({
11
+ kind: "hook",
12
+ on: options.on,
13
+ name: options.name ?? options.on,
14
+ run: (input) => options.run(input),
15
+ });
16
+ }
17
+ export function harnessHooks(hooks) {
18
+ if (hooks === undefined)
19
+ return [];
20
+ invariant(Array.isArray(hooks), "Hooks must be an array");
21
+ for (const hook of hooks)
22
+ invariant(hook?.kind === "hook", "Declare hooks with defineHarnessHook");
23
+ return Object.freeze([...hooks]);
24
+ }
25
+ //# sourceMappingURL=hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.js","sourceRoot":"","sources":["../../src/domain/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQ/D,MAAM,UAAU,iBAAiB,CAC/B,OAAkC;IAElC,SAAS,CACP,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAC/C,gCAAgC,CACjC,CAAC;IACF,SAAS,CACP,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EACzD,yBAAyB,CAC1B,CAAC;IACF,SAAS,CACP,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAC3B,6BAA6B,CAAC,GAAG,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3D,CAAC;IACF,SAAS,CAAC,OAAO,OAAO,CAAC,GAAG,KAAK,UAAU,EAAE,6BAA6B,CAAC,CAAC;IAC5E,SAAS,CACP,OAAO,CAAC,IAAI,KAAK,SAAS;QACxB,CAAC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAC3D,iCAAiC,CAClC,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM;QACZ,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE;QAChC,GAAG,EAAE,CAAC,KAA8B,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;KAC5D,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,KAAyC;IAEzC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,wBAAwB,CAAC,CAAC;IAC1D,KAAK,MAAM,IAAI,IAAI,KAAK;QACtB,SAAS,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,EAAE,sCAAsC,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import { invariant } from \"./errors.ts\";\nimport { HOOK_FIELDS, HOOK_PHASES } from \"./hook.constants.ts\";\nimport type {\n HarnessHook,\n HarnessHookInput,\n HarnessHookOptions,\n HarnessHookPhase,\n} from \"./hook.types.ts\";\n\nexport function defineHarnessHook<Phase extends HarnessHookPhase>(\n options: HarnessHookOptions<Phase>,\n): HarnessHook<Phase> {\n invariant(\n options !== null && typeof options === \"object\",\n \"Hook options must be an object\",\n );\n invariant(\n Object.keys(options).every((key) => HOOK_FIELDS.has(key)),\n \"Unsupported hook option\",\n );\n invariant(\n HOOK_PHASES.has(options.on),\n `Hook phase must be one of ${[...HOOK_PHASES].join(\", \")}`,\n );\n invariant(typeof options.run === \"function\", \"Hook run must be a function\");\n invariant(\n options.name === undefined ||\n (typeof options.name === \"string\" && options.name.trim()),\n \"Hook name must be nonempty text\",\n );\n return Object.freeze({\n kind: \"hook\",\n on: options.on,\n name: options.name ?? options.on,\n run: (input: HarnessHookInput<Phase>) => options.run(input),\n });\n}\n\nexport function harnessHooks(\n hooks: readonly HarnessHook[] | undefined,\n): readonly HarnessHook[] {\n if (hooks === undefined) return [];\n invariant(Array.isArray(hooks), \"Hooks must be an array\");\n for (const hook of hooks)\n invariant(hook?.kind === \"hook\", \"Declare hooks with defineHarnessHook\");\n return Object.freeze([...hooks]);\n}\n"]}