@halonicjs/testing 0.0.0-stage → 0.1.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 (384) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +1 -0
  3. package/README.md +40 -2
  4. package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
  5. package/dist/adapters/http-kit/src/address-class.js +109 -0
  6. package/dist/adapters/http-kit/src/index.d.ts +2 -0
  7. package/dist/adapters/http-kit/src/index.js +2 -0
  8. package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
  9. package/dist/adapters/http-kit/src/ip-address.js +89 -0
  10. package/dist/adapters/integration-kit/src/declaration.d.ts +14 -0
  11. package/dist/adapters/integration-kit/src/declaration.js +77 -0
  12. package/dist/adapters/integration-kit/src/host.d.ts +28 -0
  13. package/dist/adapters/integration-kit/src/host.js +30 -0
  14. package/dist/adapters/integration-kit/src/index.d.ts +14 -0
  15. package/dist/adapters/integration-kit/src/index.js +21 -0
  16. package/dist/adapters/integration-kit/src/leak-attempt.d.ts +14 -0
  17. package/dist/adapters/integration-kit/src/leak-attempt.js +16 -0
  18. package/dist/adapters/integration-kit/src/limited-http.d.ts +49 -0
  19. package/dist/adapters/integration-kit/src/limited-http.js +182 -0
  20. package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
  21. package/dist/adapters/integration-kit/src/load-problem.js +1 -0
  22. package/dist/adapters/integration-kit/src/loader.d.ts +104 -0
  23. package/dist/adapters/integration-kit/src/loader.js +219 -0
  24. package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
  25. package/dist/adapters/integration-kit/src/local-address.js +25 -0
  26. package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
  27. package/dist/adapters/integration-kit/src/own-request.js +36 -0
  28. package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
  29. package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
  30. package/dist/adapters/integration-kit/src/policy.d.ts +55 -0
  31. package/dist/adapters/integration-kit/src/policy.js +37 -0
  32. package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
  33. package/dist/adapters/integration-kit/src/request-body.js +68 -0
  34. package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
  35. package/dist/adapters/integration-kit/src/request-log.js +17 -0
  36. package/dist/adapters/integration-kit/src/response-body.d.ts +23 -0
  37. package/dist/adapters/integration-kit/src/response-body.js +117 -0
  38. package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
  39. package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
  40. package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
  41. package/dist/adapters/integration-kit/src/secret-filter.js +205 -0
  42. package/dist/adapters/integration-kit/src/secret-in-request.d.ts +59 -0
  43. package/dist/adapters/integration-kit/src/secret-in-request.js +133 -0
  44. package/dist/adapters/integration-kit/src/secret-placement.d.ts +36 -0
  45. package/dist/adapters/integration-kit/src/secret-placement.js +190 -0
  46. package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
  47. package/dist/adapters/integration-kit/src/wait.js +35 -0
  48. package/dist/core/events/src/add-usage.d.ts +10 -0
  49. package/dist/core/events/src/add-usage.js +27 -0
  50. package/dist/core/events/src/agent-resume.d.ts +24 -0
  51. package/dist/core/events/src/agent-resume.js +1 -0
  52. package/dist/core/events/src/home-path.d.ts +13 -0
  53. package/dist/core/events/src/home-path.js +26 -0
  54. package/dist/core/events/src/index.d.ts +13 -0
  55. package/dist/core/events/src/index.js +7 -0
  56. package/dist/core/events/src/run-basics.d.ts +205 -0
  57. package/dist/core/events/src/run-basics.js +1 -0
  58. package/dist/core/events/src/run-event.d.ts +434 -0
  59. package/dist/core/events/src/run-event.js +1 -0
  60. package/dist/core/events/src/run-summary.d.ts +108 -0
  61. package/dist/core/events/src/run-summary.js +1 -0
  62. package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
  63. package/dist/core/events/src/sandbox-blocked.js +26 -0
  64. package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
  65. package/dist/core/events/src/sandbox-opened-read.js +63 -0
  66. package/dist/core/events/src/sandbox-opened.d.ts +94 -0
  67. package/dist/core/events/src/sandbox-opened.js +52 -0
  68. package/dist/core/events/src/summarize.d.ts +14 -0
  69. package/dist/core/events/src/summarize.js +188 -0
  70. package/dist/core/events/src/timeline-entry.d.ts +21 -0
  71. package/dist/core/events/src/timeline-entry.js +105 -0
  72. package/dist/core/events/src/upgrade.d.ts +23 -0
  73. package/dist/core/events/src/upgrade.js +49 -0
  74. package/dist/core/format/src/compact.d.ts +30 -0
  75. package/dist/core/format/src/compact.js +72 -0
  76. package/dist/core/format/src/index.d.ts +37 -0
  77. package/dist/core/format/src/index.js +23 -0
  78. package/dist/core/format/src/integration/index.d.ts +6 -0
  79. package/dist/core/format/src/integration/index.js +9 -0
  80. package/dist/core/format/src/json-schema.d.ts +26 -0
  81. package/dist/core/format/src/json-schema.js +48 -0
  82. package/dist/core/format/src/kind.d.ts +65 -0
  83. package/dist/core/format/src/kind.js +1 -0
  84. package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
  85. package/dist/core/format/src/kinds/agent/kind.js +10 -0
  86. package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +89 -0
  87. package/dist/core/format/src/kinds/agent/sandbox-fields.js +197 -0
  88. package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
  89. package/dist/core/format/src/kinds/agent/schema.js +107 -0
  90. package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
  91. package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
  92. package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
  93. package/dist/core/format/src/kinds/collection/kind.js +14 -0
  94. package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
  95. package/dist/core/format/src/kinds/collection/schema.js +90 -0
  96. package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
  97. package/dist/core/format/src/kinds/connector/is-local.js +43 -0
  98. package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
  99. package/dist/core/format/src/kinds/connector/kind.js +119 -0
  100. package/dist/core/format/src/kinds/connector/schema.d.ts +50 -0
  101. package/dist/core/format/src/kinds/connector/schema.js +92 -0
  102. package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
  103. package/dist/core/format/src/kinds/deployments/kind.js +25 -0
  104. package/dist/core/format/src/kinds/deployments/schema.d.ts +37 -0
  105. package/dist/core/format/src/kinds/deployments/schema.js +42 -0
  106. package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
  107. package/dist/core/format/src/kinds/hub/kind.js +10 -0
  108. package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
  109. package/dist/core/format/src/kinds/hub/schema.js +34 -0
  110. package/dist/core/format/src/kinds/integration/kind.d.ts +16 -0
  111. package/dist/core/format/src/kinds/integration/kind.js +138 -0
  112. package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
  113. package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
  114. package/dist/core/format/src/kinds/integration/policy.d.ts +67 -0
  115. package/dist/core/format/src/kinds/integration/policy.js +268 -0
  116. package/dist/core/format/src/kinds/integration/schema.d.ts +233 -0
  117. package/dist/core/format/src/kinds/integration/schema.js +233 -0
  118. package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
  119. package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
  120. package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
  121. package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
  122. package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
  123. package/dist/core/format/src/kinds/models/kind.js +10 -0
  124. package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
  125. package/dist/core/format/src/kinds/models/schema.js +38 -0
  126. package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
  127. package/dist/core/format/src/kinds/plugin/backend.js +31 -0
  128. package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
  129. package/dist/core/format/src/kinds/plugin/checks.js +131 -0
  130. package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
  131. package/dist/core/format/src/kinds/plugin/kind.js +16 -0
  132. package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
  133. package/dist/core/format/src/kinds/plugin/problems.js +65 -0
  134. package/dist/core/format/src/kinds/plugin/schema.d.ts +542 -0
  135. package/dist/core/format/src/kinds/plugin/schema.js +261 -0
  136. package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
  137. package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
  138. package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
  139. package/dist/core/format/src/kinds/plugin/ui-checks.js +94 -0
  140. package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
  141. package/dist/core/format/src/kinds/provider/kind.js +24 -0
  142. package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
  143. package/dist/core/format/src/kinds/provider/schema.js +22 -0
  144. package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
  145. package/dist/core/format/src/kinds/routine/kind.js +25 -0
  146. package/dist/core/format/src/kinds/routine/schema.d.ts +84 -0
  147. package/dist/core/format/src/kinds/routine/schema.js +93 -0
  148. package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
  149. package/dist/core/format/src/kinds/runtime/kind.js +13 -0
  150. package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
  151. package/dist/core/format/src/kinds/runtime/schema.js +12 -0
  152. package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
  153. package/dist/core/format/src/kinds/skill/kind.js +10 -0
  154. package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
  155. package/dist/core/format/src/kinds/skill/schema.js +17 -0
  156. package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
  157. package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
  158. package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
  159. package/dist/core/format/src/kinds/workflow/kind.js +14 -0
  160. package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
  161. package/dist/core/format/src/kinds/workflow/schema.js +106 -0
  162. package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
  163. package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
  164. package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
  165. package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
  166. package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
  167. package/dist/core/format/src/kinds/workspace/kind.js +10 -0
  168. package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
  169. package/dist/core/format/src/kinds/workspace/schema.js +66 -0
  170. package/dist/core/format/src/parse-file.d.ts +69 -0
  171. package/dist/core/format/src/parse-file.js +105 -0
  172. package/dist/core/format/src/recording/format.d.ts +81 -0
  173. package/dist/core/format/src/recording/format.js +102 -0
  174. package/dist/core/format/src/recording/index.d.ts +1 -0
  175. package/dist/core/format/src/recording/index.js +3 -0
  176. package/dist/core/format/src/registry.d.ts +64 -0
  177. package/dist/core/format/src/registry.js +61 -0
  178. package/dist/core/format/src/reserved.d.ts +20 -0
  179. package/dist/core/format/src/reserved.js +30 -0
  180. package/dist/core/format/src/shared/fields.d.ts +37 -0
  181. package/dist/core/format/src/shared/fields.js +54 -0
  182. package/dist/core/format/src/shared/guard.d.ts +32 -0
  183. package/dist/core/format/src/shared/guard.js +16 -0
  184. package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
  185. package/dist/core/format/src/shared/key-in-value.js +82 -0
  186. package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
  187. package/dist/core/format/src/shared/legacy-keys.js +17 -0
  188. package/dist/core/format/src/shared/program-start.d.ts +60 -0
  189. package/dist/core/format/src/shared/program-start.js +99 -0
  190. package/dist/core/format/src/shared/relative-path.d.ts +29 -0
  191. package/dist/core/format/src/shared/relative-path.js +50 -0
  192. package/dist/core/format/src/shared/secret-name.d.ts +24 -0
  193. package/dist/core/format/src/shared/secret-name.js +107 -0
  194. package/dist/core/format/src/source.d.ts +16 -0
  195. package/dist/core/format/src/source.js +73 -0
  196. package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
  197. package/dist/core/ports/src/agent-placement-store.js +27 -0
  198. package/dist/core/ports/src/blob-store.d.ts +33 -0
  199. package/dist/core/ports/src/blob-store.js +2 -0
  200. package/dist/core/ports/src/cant-try-error.d.ts +35 -0
  201. package/dist/core/ports/src/cant-try-error.js +44 -0
  202. package/dist/core/ports/src/chat.d.ts +127 -0
  203. package/dist/core/ports/src/chat.js +1 -0
  204. package/dist/core/ports/src/clock.d.ts +7 -0
  205. package/dist/core/ports/src/clock.js +2 -0
  206. package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
  207. package/dist/core/ports/src/connection-settings-store.js +2 -0
  208. package/dist/core/ports/src/connector-client.d.ts +259 -0
  209. package/dist/core/ports/src/connector-client.js +2 -0
  210. package/dist/core/ports/src/coordination.d.ts +84 -0
  211. package/dist/core/ports/src/coordination.js +2 -0
  212. package/dist/core/ports/src/definition-store.d.ts +208 -0
  213. package/dist/core/ports/src/definition-store.js +122 -0
  214. package/dist/core/ports/src/digest.d.ts +14 -0
  215. package/dist/core/ports/src/digest.js +2 -0
  216. package/dist/core/ports/src/folder-reader.d.ts +89 -0
  217. package/dist/core/ports/src/folder-reader.js +2 -0
  218. package/dist/core/ports/src/harness-bridge-server.d.ts +189 -0
  219. package/dist/core/ports/src/harness-bridge-server.js +37 -0
  220. package/dist/core/ports/src/harness.d.ts +250 -0
  221. package/dist/core/ports/src/harness.js +45 -0
  222. package/dist/core/ports/src/http-client.d.ts +27 -0
  223. package/dist/core/ports/src/http-client.js +2 -0
  224. package/dist/core/ports/src/id-generator.d.ts +14 -0
  225. package/dist/core/ports/src/id-generator.js +2 -0
  226. package/dist/core/ports/src/index.d.ts +37 -0
  227. package/dist/core/ports/src/index.js +36 -0
  228. package/dist/core/ports/src/integration.d.ts +178 -0
  229. package/dist/core/ports/src/integration.js +13 -0
  230. package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
  231. package/dist/core/ports/src/knowledge-provider.js +2 -0
  232. package/dist/core/ports/src/llm-cache.d.ts +13 -0
  233. package/dist/core/ports/src/llm-cache.js +2 -0
  234. package/dist/core/ports/src/llm-provider.d.ts +184 -0
  235. package/dist/core/ports/src/llm-provider.js +136 -0
  236. package/dist/core/ports/src/model-price.d.ts +34 -0
  237. package/dist/core/ports/src/model-price.js +25 -0
  238. package/dist/core/ports/src/password-hasher.d.ts +47 -0
  239. package/dist/core/ports/src/password-hasher.js +2 -0
  240. package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
  241. package/dist/core/ports/src/plugin-folder-writer.js +95 -0
  242. package/dist/core/ports/src/port-versions.d.ts +44 -0
  243. package/dist/core/ports/src/port-versions.js +74 -0
  244. package/dist/core/ports/src/program-probe.d.ts +46 -0
  245. package/dist/core/ports/src/program-probe.js +2 -0
  246. package/dist/core/ports/src/record-store.d.ts +62 -0
  247. package/dist/core/ports/src/record-store.js +38 -0
  248. package/dist/core/ports/src/resource-probe.d.ts +59 -0
  249. package/dist/core/ports/src/resource-probe.js +2 -0
  250. package/dist/core/ports/src/run-executor.d.ts +302 -0
  251. package/dist/core/ports/src/run-executor.js +2 -0
  252. package/dist/core/ports/src/run-failure-error.d.ts +49 -0
  253. package/dist/core/ports/src/run-failure-error.js +47 -0
  254. package/dist/core/ports/src/run-store.d.ts +194 -0
  255. package/dist/core/ports/src/run-store.js +131 -0
  256. package/dist/core/ports/src/sandbox.d.ts +247 -0
  257. package/dist/core/ports/src/sandbox.js +34 -0
  258. package/dist/core/ports/src/scheduler.d.ts +85 -0
  259. package/dist/core/ports/src/scheduler.js +2 -0
  260. package/dist/core/ports/src/secrets.d.ts +128 -0
  261. package/dist/core/ports/src/secrets.js +144 -0
  262. package/dist/core/ports/src/token-store.d.ts +19 -0
  263. package/dist/core/ports/src/token-store.js +2 -0
  264. package/dist/core/ports/src/tool-approval-store.d.ts +211 -0
  265. package/dist/core/ports/src/tool-approval-store.js +57 -0
  266. package/dist/core/ports/src/trust-store.d.ts +72 -0
  267. package/dist/core/ports/src/trust-store.js +2 -0
  268. package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
  269. package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
  270. package/dist/core/ports/src/vcs.d.ts +394 -0
  271. package/dist/core/ports/src/vcs.js +48 -0
  272. package/dist/core/schema-kit/src/builders.d.ts +50 -0
  273. package/dist/core/schema-kit/src/builders.js +72 -0
  274. package/dist/core/schema-kit/src/depth.d.ts +15 -0
  275. package/dist/core/schema-kit/src/depth.js +37 -0
  276. package/dist/core/schema-kit/src/index.d.ts +6 -0
  277. package/dist/core/schema-kit/src/index.js +6 -0
  278. package/dist/core/schema-kit/src/issue.d.ts +22 -0
  279. package/dist/core/schema-kit/src/issue.js +23 -0
  280. package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
  281. package/dist/core/schema-kit/src/json-schema.js +22 -0
  282. package/dist/core/schema-kit/src/parse.d.ts +17 -0
  283. package/dist/core/schema-kit/src/parse.js +25 -0
  284. package/dist/core/schema-kit/src/schema.d.ts +12 -0
  285. package/dist/core/schema-kit/src/schema.js +1 -0
  286. package/dist/core/std/src/ascii-host.d.ts +18 -0
  287. package/dist/core/std/src/ascii-host.js +110 -0
  288. package/dist/core/std/src/assert.d.ts +39 -0
  289. package/dist/core/std/src/assert.js +59 -0
  290. package/dist/core/std/src/base64url.d.ts +23 -0
  291. package/dist/core/std/src/base64url.js +65 -0
  292. package/dist/core/std/src/canonical-json.d.ts +18 -0
  293. package/dist/core/std/src/canonical-json.js +56 -0
  294. package/dist/core/std/src/clock.d.ts +27 -0
  295. package/dist/core/std/src/clock.js +33 -0
  296. package/dist/core/std/src/constant-time.d.ts +16 -0
  297. package/dist/core/std/src/constant-time.js +26 -0
  298. package/dist/core/std/src/content-digest.d.ts +24 -0
  299. package/dist/core/std/src/content-digest.js +28 -0
  300. package/dist/core/std/src/deep-clone.d.ts +15 -0
  301. package/dist/core/std/src/deep-clone.js +59 -0
  302. package/dist/core/std/src/deep-equal.d.ts +23 -0
  303. package/dist/core/std/src/deep-equal.js +64 -0
  304. package/dist/core/std/src/emitter.d.ts +42 -0
  305. package/dist/core/std/src/emitter.js +74 -0
  306. package/dist/core/std/src/error-kind.d.ts +88 -0
  307. package/dist/core/std/src/error-kind.js +98 -0
  308. package/dist/core/std/src/hex.d.ts +10 -0
  309. package/dist/core/std/src/hex.js +16 -0
  310. package/dist/core/std/src/ids.d.ts +45 -0
  311. package/dist/core/std/src/ids.js +49 -0
  312. package/dist/core/std/src/index.d.ts +25 -0
  313. package/dist/core/std/src/index.js +26 -0
  314. package/dist/core/std/src/keyed-queue.d.ts +18 -0
  315. package/dist/core/std/src/keyed-queue.js +32 -0
  316. package/dist/core/std/src/line-diff.d.ts +83 -0
  317. package/dist/core/std/src/line-diff.js +179 -0
  318. package/dist/core/std/src/line-merge.d.ts +63 -0
  319. package/dist/core/std/src/line-merge.js +138 -0
  320. package/dist/core/std/src/plain-data.d.ts +32 -0
  321. package/dist/core/std/src/plain-data.js +57 -0
  322. package/dist/core/std/src/posix-path.d.ts +61 -0
  323. package/dist/core/std/src/posix-path.js +121 -0
  324. package/dist/core/std/src/result.d.ts +55 -0
  325. package/dist/core/std/src/result.js +52 -0
  326. package/dist/core/std/src/secret-scrubber.d.ts +54 -0
  327. package/dist/core/std/src/secret-scrubber.js +124 -0
  328. package/dist/core/std/src/secret-shape.d.ts +20 -0
  329. package/dist/core/std/src/secret-shape.js +53 -0
  330. package/dist/core/std/src/stop-signal.d.ts +44 -0
  331. package/dist/core/std/src/stop-signal.js +77 -0
  332. package/dist/core/std/src/text.d.ts +28 -0
  333. package/dist/core/std/src/text.js +54 -0
  334. package/dist/core/std/src/utf8.d.ts +23 -0
  335. package/dist/core/std/src/utf8.js +110 -0
  336. package/dist/core/std/src/version.d.ts +48 -0
  337. package/dist/core/std/src/version.js +103 -0
  338. package/dist/core/yaml/src/depth.d.ts +14 -0
  339. package/dist/core/yaml/src/depth.js +140 -0
  340. package/dist/core/yaml/src/edit-data.d.ts +47 -0
  341. package/dist/core/yaml/src/edit-data.js +286 -0
  342. package/dist/core/yaml/src/edit-text.d.ts +92 -0
  343. package/dist/core/yaml/src/edit-text.js +267 -0
  344. package/dist/core/yaml/src/edit.d.ts +47 -0
  345. package/dist/core/yaml/src/edit.js +198 -0
  346. package/dist/core/yaml/src/index.d.ts +5 -0
  347. package/dist/core/yaml/src/index.js +4 -0
  348. package/dist/core/yaml/src/problem.d.ts +20 -0
  349. package/dist/core/yaml/src/problem.js +1 -0
  350. package/dist/core/yaml/src/read.d.ts +47 -0
  351. package/dist/core/yaml/src/read.js +130 -0
  352. package/dist/core/yaml/src/splice-node.d.ts +47 -0
  353. package/dist/core/yaml/src/splice-node.js +333 -0
  354. package/dist/core/yaml/src/splice.d.ts +13 -0
  355. package/dist/core/yaml/src/splice.js +174 -0
  356. package/dist/core/yaml/src/unsupported.d.ts +26 -0
  357. package/dist/core/yaml/src/unsupported.js +70 -0
  358. package/dist/core/yaml/src/write.d.ts +35 -0
  359. package/dist/core/yaml/src/write.js +44 -0
  360. package/dist/testing/integration/src/canaries.d.ts +14 -0
  361. package/dist/testing/integration/src/canaries.js +17 -0
  362. package/dist/testing/integration/src/checks.d.ts +37 -0
  363. package/dist/testing/integration/src/checks.js +195 -0
  364. package/dist/testing/integration/src/describe.d.ts +35 -0
  365. package/dist/testing/integration/src/describe.js +74 -0
  366. package/dist/testing/integration/src/failure.d.ts +6 -0
  367. package/dist/testing/integration/src/failure.js +8 -0
  368. package/dist/testing/integration/src/fake-wait.d.ts +18 -0
  369. package/dist/testing/integration/src/fake-wait.js +21 -0
  370. package/dist/testing/integration/src/index.d.ts +10 -0
  371. package/dist/testing/integration/src/index.js +11 -0
  372. package/dist/testing/integration/src/load.d.ts +14 -0
  373. package/dist/testing/integration/src/load.js +45 -0
  374. package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
  375. package/dist/testing/integration/src/plugin-folder.js +59 -0
  376. package/dist/testing/integration/src/plugin.d.ts +32 -0
  377. package/dist/testing/integration/src/plugin.js +57 -0
  378. package/dist/testing/integration/src/recording.d.ts +84 -0
  379. package/dist/testing/integration/src/recording.js +164 -0
  380. package/dist/testing/integration/src/run.d.ts +60 -0
  381. package/dist/testing/integration/src/run.js +81 -0
  382. package/dist/testing/integration/src/source-scan.d.ts +16 -0
  383. package/dist/testing/integration/src/source-scan.js +40 -0
  384. package/package.json +35 -4
@@ -0,0 +1,24 @@
1
+ import type { Path } from "../../../schema-kit/src/index.js";
2
+ import type { KindCheckProblem } from "../kind.js";
3
+ /**
4
+ * Whether a value written as a secret's name looks like a key instead.
5
+ * Only the answer leaves the check; when it is `true`, never repeat the value.
6
+ *
7
+ * @example
8
+ * looksLikeKey("openai-key"); // false
9
+ * looksLikeKey(`sk-ant-api03-${"Q7x2Lm9K".repeat(4)}`); // true
10
+ */
11
+ export declare function looksLikeKey(value: string): boolean;
12
+ /**
13
+ * Checks a value a file gives as a secret's name, before anything asks a
14
+ * store for it. A key is refused first (`secret-looks-like-key`), then a
15
+ * name that breaks the rule of the `Secrets` port (`secret-name`). Both are
16
+ * errors, because the file may be committed. The message repeats the value
17
+ * only when it doesn't look like a key and would pass the rule with its
18
+ * spaces and dots written as `-`.
19
+ *
20
+ * @param name - the value from the file
21
+ * @param path - where it sits in the file
22
+ * @returns the problem, or `undefined` for a good name
23
+ */
24
+ export declare function checkSecretName(name: string, path: Path): KindCheckProblem | undefined;
@@ -0,0 +1,107 @@
1
+ import { isSecretName, maxSecretNameLength } from "../../../ports/src/index.js";
2
+ import { findSecretShape } from "../../../std/src/index.js";
3
+ /*
4
+ * A key pasted where a secret's name belongs fits the name rule more often
5
+ * than not (`sk-ant-api03-…` is a letter, then letters, digits and `-`), so
6
+ * the rule alone lets it through and every later message repeats it. Three
7
+ * tests catch it:
8
+ *
9
+ * - The known key formats `findSecretShape` spots (`sk-`, `GOCSPX-`, `AIza`,
10
+ * `ghp_`, `github_pat_`, `xoxb-`), the same check Studio asks before a
11
+ * chat message is sent.
12
+ * - A UUID anywhere in the value. Many services issue keys as a bare UUID,
13
+ * whose parts are too short for the next test.
14
+ * - A long random part: between the `-` and `_` that split a name, a run of
15
+ * at least 20 characters that mixes letters and digits. Names people
16
+ * write are words (`openai-key`, `SERVE_PASSWORD`), and a word of 20
17
+ * characters with digits in it is rare. Keys without a known prefix
18
+ * (hex tokens, other Slack tokens, cloud access keys) are such runs. An
19
+ * AWS access key ID is exactly 20 characters, so keep the length at 20.
20
+ */
21
+ const uuid = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
22
+ const randomPartLength = 20;
23
+ const nameParts = /[-_]/;
24
+ const letter = /[A-Za-z]/;
25
+ const digit = /[0-9]/;
26
+ /**
27
+ * Whether a value written as a secret's name looks like a key instead.
28
+ * Only the answer leaves the check; when it is `true`, never repeat the value.
29
+ *
30
+ * @example
31
+ * looksLikeKey("openai-key"); // false
32
+ * looksLikeKey(`sk-ant-api03-${"Q7x2Lm9K".repeat(4)}`); // true
33
+ */
34
+ export function looksLikeKey(value) {
35
+ if (findSecretShape(value) !== undefined || uuid.test(value)) {
36
+ return true;
37
+ }
38
+ return value
39
+ .split(nameParts)
40
+ .some((part) => part.length >= randomPartLength && letter.test(part) && digit.test(part));
41
+ }
42
+ /*
43
+ * The words wait on the board (HAL-2264, P8). They sit here, one per
44
+ * problem, so the approved text replaces them in one place.
45
+ */
46
+ const words = {
47
+ "secret-looks-like-key": "This looks like an API key, not a secret's name. Remove it from the file, store the key as a secret, and write the secret's name here, such as openai-key.",
48
+ "secret-name": (name) => `The secret name "${name}" can't be used. Start with a letter, then use only letters, digits, - or _, such as openai-key.`,
49
+ "secret-name-too-long": (length) => `This secret name is ${length} characters long. Use at most ${maxSecretNameLength}, starting with a letter, then only letters, digits, - or _.`,
50
+ "secret-name-characters": "This secret name has characters that can't be used. Start with a letter, then use only letters, digits, - or _.",
51
+ };
52
+ const typoSeparators = /[ .]/g;
53
+ /**
54
+ * Whether a name that breaks the rule does so the way a typo does: it
55
+ * would pass with each space and dot written as `-` (`openai key`,
56
+ * `openai.key`). Only such a name may be repeated in a message. Anything
57
+ * else (`Hunter2!x`, `pass@word`) may be a password pasted by mistake, and
58
+ * `halonic validate` output can end up in a CI log.
59
+ *
60
+ * @example
61
+ * isTypoedSecretName("openai key"); // true
62
+ * isTypoedSecretName("Hunter2!x"); // false
63
+ */
64
+ function isTypoedSecretName(name) {
65
+ return isSecretName(name.replace(typoSeparators, "-"));
66
+ }
67
+ /** The `secret-name` message: the name quoted only when it is a typo. */
68
+ function badNameMessage(name) {
69
+ if (isTypoedSecretName(name)) {
70
+ return words["secret-name"](name);
71
+ }
72
+ if (name.length > maxSecretNameLength) {
73
+ return words["secret-name-too-long"](name.length);
74
+ }
75
+ return words["secret-name-characters"];
76
+ }
77
+ /**
78
+ * Checks a value a file gives as a secret's name, before anything asks a
79
+ * store for it. A key is refused first (`secret-looks-like-key`), then a
80
+ * name that breaks the rule of the `Secrets` port (`secret-name`). Both are
81
+ * errors, because the file may be committed. The message repeats the value
82
+ * only when it doesn't look like a key and would pass the rule with its
83
+ * spaces and dots written as `-`.
84
+ *
85
+ * @param name - the value from the file
86
+ * @param path - where it sits in the file
87
+ * @returns the problem, or `undefined` for a good name
88
+ */
89
+ export function checkSecretName(name, path) {
90
+ if (looksLikeKey(name)) {
91
+ return {
92
+ severity: "error",
93
+ code: "secret-looks-like-key",
94
+ path,
95
+ message: words["secret-looks-like-key"],
96
+ };
97
+ }
98
+ if (isSecretName(name)) {
99
+ return undefined;
100
+ }
101
+ return {
102
+ severity: "error",
103
+ code: "secret-name",
104
+ path,
105
+ message: badNameMessage(name),
106
+ };
107
+ }
@@ -0,0 +1,16 @@
1
+ import { type Result } from "../../std/src/index.js";
2
+ import { type SourcePosition, type YamlPath, type YamlProblem } from "../../yaml/src/index.js";
3
+ import type { KindSyntax } from "./kind.js";
4
+ /** A file's text, read into data, with where each value sits. */
5
+ export interface Source {
6
+ /** The data: a map for a well-formed file; `{}` for an empty one, as the old loader read it. */
7
+ readonly data: unknown;
8
+ /** Where the value at `path` starts, or the nearest parent; line 1, column 1 when nothing does. */
9
+ positionOf(path: YamlPath): SourcePosition;
10
+ }
11
+ /**
12
+ * Reads a file's text in its kind's syntax.
13
+ *
14
+ * @returns the data and positions, or the YAML problem with its line in the file
15
+ */
16
+ export declare function readSource(syntax: KindSyntax, text: string): Result<Source, YamlProblem>;
@@ -0,0 +1,73 @@
1
+ import { err, ok } from "../../std/src/index.js";
2
+ import { readYaml } from "../../yaml/src/index.js";
3
+ import { isMap } from "./shared/legacy-keys.js";
4
+ const fileStart = { line: 1, col: 1 };
5
+ /**
6
+ * Reads a file's text in its kind's syntax.
7
+ *
8
+ * @returns the data and positions, or the YAML problem with its line in the file
9
+ */
10
+ export function readSource(syntax, text) {
11
+ if (syntax === "front-matter") {
12
+ return readFrontMatterFile(text);
13
+ }
14
+ const read = readYaml(text);
15
+ if (!read.ok) {
16
+ return read;
17
+ }
18
+ const file = read.value;
19
+ return ok({
20
+ data: file.data ?? {},
21
+ positionOf: (path) => file.positionOf(path) ?? fileStart,
22
+ });
23
+ }
24
+ // The old loader's pattern (784f78d: parseSkillMarkdown): `---`, the YAML,
25
+ // `---`, then the body.
26
+ const frontMatterPattern = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
27
+ /**
28
+ * Reads a Markdown file with YAML front matter, such as `SKILL.md`. The data
29
+ * is the front matter plus `body`, the Markdown after it, trimmed. Without
30
+ * front matter the data is only `body`, the whole text untrimmed, as before.
31
+ */
32
+ function readFrontMatterFile(text) {
33
+ const match = frontMatterPattern.exec(text);
34
+ if (match === null) {
35
+ return ok({ data: { body: text }, positionOf: () => fileStart });
36
+ }
37
+ const frontMatterText = match[1] ?? "";
38
+ const body = match[2] ?? "";
39
+ // The front matter starts on line 2, below the opening `---`.
40
+ const lineOffset = 1;
41
+ const read = readYaml(frontMatterText);
42
+ if (!read.ok) {
43
+ return err({ ...read.error, line: read.error.line + lineOffset });
44
+ }
45
+ const frontMatter = read.value;
46
+ const bodyPosition = {
47
+ line: lineCount(text.slice(0, text.length - body.length)),
48
+ col: 1,
49
+ };
50
+ const data = frontMatter.data ?? {};
51
+ return ok({
52
+ data: isMap(data) ? { ...data, body: body.trim() } : data,
53
+ positionOf: (path) => {
54
+ if (path[0] === "body") {
55
+ return bodyPosition;
56
+ }
57
+ const position = frontMatter.positionOf(path);
58
+ return position === undefined
59
+ ? fileStart
60
+ : { line: position.line + lineOffset, col: position.col };
61
+ },
62
+ });
63
+ }
64
+ /** The 1-based number of the line a text ends on. */
65
+ function lineCount(text) {
66
+ let lines = 1;
67
+ for (const character of text) {
68
+ if (character === "\n") {
69
+ lines += 1;
70
+ }
71
+ }
72
+ return lines;
73
+ }
@@ -0,0 +1,74 @@
1
+ /** Version of the {@link AgentPlacementStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const agentPlacementStoreVersion = 1;
3
+ /** Which agent a placement is for. */
4
+ export interface AgentPlacementKey {
5
+ /** The workspace's resolved real path, as in a `TrustRecord`. */
6
+ location: string;
7
+ /** The agent's id in the workspace. */
8
+ agent: string;
9
+ }
10
+ /**
11
+ * A person's choice to run one agent's harness on this computer, outside a
12
+ * sandbox (requirement `ports.agent-placement-store`). Without a record, the
13
+ * agent runs in a sandbox on this computer, so the default is the safe one.
14
+ *
15
+ * @example
16
+ * const placement: AgentPlacementRecord = {
17
+ * location: "/workspaces/acme",
18
+ * agent: "coder",
19
+ * runsOn: "this-computer",
20
+ * agentFingerprint: "sha256:9f86d0…",
21
+ * chosenAt: "2026-11-09T10:00:00.000Z",
22
+ * };
23
+ */
24
+ export interface AgentPlacementRecord extends AgentPlacementKey {
25
+ /** Where the person chose to run the agent. The only choice a record can hold. */
26
+ runsOn: "this-computer";
27
+ /**
28
+ * The fingerprint of the agent's file when the person chose. When the file
29
+ * changes, `AgentPlacement` in `core/app` treats the choice as not made
30
+ * until the person confirms again.
31
+ */
32
+ agentFingerprint: string;
33
+ /** When the person chose, as ISO text. */
34
+ chosenAt: string;
35
+ }
36
+ /**
37
+ * Each agent's "this computer" choice, in the user's profile next to the
38
+ * trust records: the profile folder for the CLI and `serve`, the app data
39
+ * folder for the desktop app, memory for tests and the browser demo. **Never
40
+ * inside a workspace**, so an agent that edits the workspace can't take
41
+ * itself out of its sandbox.
42
+ *
43
+ * The port only stores choices. `AgentPlacement` in `core/app` reads them,
44
+ * checks the fingerprint and is what the engine asks. Only a person makes a
45
+ * choice: no tool the model can call reaches this store.
46
+ *
47
+ * A record that exists but can't be read makes `get` throw, never return
48
+ * `null`: the caller then runs the agent in a sandbox and tells the user why.
49
+ * The error names the record's key, and `remove` still deletes it.
50
+ */
51
+ export interface AgentPlacementStore {
52
+ /** The choice for one agent, or `null` when there is none. */
53
+ get(key: AgentPlacementKey): Promise<AgentPlacementRecord | null>;
54
+ /** Saves a choice, replacing any with the same key. */
55
+ save(placement: AgentPlacementRecord): Promise<void>;
56
+ /**
57
+ * Deletes the choice for one agent, even one that can't be read. Removing
58
+ * a choice that isn't there is not an error.
59
+ */
60
+ remove(key: AgentPlacementKey): Promise<void>;
61
+ }
62
+ /**
63
+ * Whether `value`, as read back from a store, is a valid choice for `key`:
64
+ * exactly the fields of an {@link AgentPlacementRecord}, each text, with
65
+ * `runsOn: "this-computer"` and the key asked for. Anything else is a
66
+ * damaged or borrowed choice, such as a hand edit or a file copied from
67
+ * another agent, and must never take an agent out of its sandbox. Every
68
+ * adapter checks what it reads with this, and `AgentPlacement` in
69
+ * `core/app` checks what an adapter gives back with it again.
70
+ *
71
+ * @example
72
+ * isAgentPlacementFor(key, JSON.parse(text)); // false for `{ ...record, sandbox: false }`
73
+ */
74
+ export declare function isAgentPlacementFor(key: AgentPlacementKey, value: unknown): value is AgentPlacementRecord;
@@ -0,0 +1,27 @@
1
+ /** Version of the {@link AgentPlacementStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export const agentPlacementStoreVersion = 1;
3
+ /** Every field of an {@link AgentPlacementRecord}, and no other. */
4
+ const placementFields = ["location", "agent", "runsOn", "agentFingerprint", "chosenAt"];
5
+ /**
6
+ * Whether `value`, as read back from a store, is a valid choice for `key`:
7
+ * exactly the fields of an {@link AgentPlacementRecord}, each text, with
8
+ * `runsOn: "this-computer"` and the key asked for. Anything else is a
9
+ * damaged or borrowed choice, such as a hand edit or a file copied from
10
+ * another agent, and must never take an agent out of its sandbox. Every
11
+ * adapter checks what it reads with this, and `AgentPlacement` in
12
+ * `core/app` checks what an adapter gives back with it again.
13
+ *
14
+ * @example
15
+ * isAgentPlacementFor(key, JSON.parse(text)); // false for `{ ...record, sandbox: false }`
16
+ */
17
+ export function isAgentPlacementFor(key, value) {
18
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
19
+ return false;
20
+ }
21
+ const record = value;
22
+ return (Object.keys(record).length === placementFields.length &&
23
+ placementFields.every((field) => Object.hasOwn(record, field) && typeof record[field] === "string") &&
24
+ record.runsOn === "this-computer" &&
25
+ record.location === key.location &&
26
+ record.agent === key.agent);
27
+ }
@@ -0,0 +1,33 @@
1
+ /** Version of the {@link BlobStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const blobStoreVersion = 1;
3
+ /** A stored blob: its hash (lowercase hex SHA-256 of the bytes), size in bytes and media type. */
4
+ export interface BlobRef {
5
+ hash: string;
6
+ size: number;
7
+ mediaType: string;
8
+ }
9
+ /**
10
+ * Content-addressed storage for attachments, knowledge files, large event
11
+ * payloads and exports. The same bytes always get the same hash, so storing
12
+ * them twice keeps one copy.
13
+ */
14
+ export interface BlobStore {
15
+ /**
16
+ * Stores the bytes and returns their reference, which echoes this call's
17
+ * `mediaType`. Storing the same bytes again with another type keeps one
18
+ * copy, and `get` doesn't promise which type, if any, was kept: callers
19
+ * keep the `BlobRef` they got.
20
+ *
21
+ * @throws RangeError when `mediaType` isn't `type/subtype` made of HTTP
22
+ * token characters (no parameters, spaces or line breaks), because it
23
+ * ends up in storage metadata and in a served `Content-Type` header
24
+ */
25
+ put(data: Uint8Array, mediaType: string): Promise<BlobRef>;
26
+ /**
27
+ * The bytes stored under a hash, or `null` when there are none. A hash that
28
+ * isn't 64 lowercase hex characters returns `null` without touching
29
+ * storage, so it can never reach a file path or key (the old Node adapter
30
+ * read `get("../…")` outside its folder).
31
+ */
32
+ get(hash: string): Promise<Uint8Array | null>;
33
+ }
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link BlobStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export const blobStoreVersion = 1;
@@ -0,0 +1,35 @@
1
+ import type { CantTryReason } from "../../events/src/index.js";
2
+ /**
3
+ * An error a Try it or Test adapter throws when a step it serves can't be
4
+ * tried, because it needs a change left out of the run, such as a model
5
+ * alias that is new in `models.yaml` (requirement `ports.cant-try-error`).
6
+ * The engine then ends the step's branch as it does for a failed step, and
7
+ * the run ends with `run.cant-try` instead of `run.failed`. The engine adds
8
+ * the step's id; the adapter knows the item being tried and why.
9
+ *
10
+ * The message must be safe to show and to log. Check for it with
11
+ * {@link isCantTryError}, not `instanceof`: an adapter may be built against
12
+ * its own copy of this package.
13
+ *
14
+ * @example
15
+ * const reason = { kind: "needs-left-out-change", path: "models.yaml", leftOut: "models" } as const;
16
+ * throw new CantTryError("workflows/triage.yaml", reason, "Alias smart is new.");
17
+ */
18
+ export declare class CantTryError extends Error {
19
+ readonly name = "CantTryError";
20
+ /** The path of the item being tried. */
21
+ readonly item: string;
22
+ readonly reason: CantTryReason;
23
+ /**
24
+ * @param item - the path of the item being tried
25
+ * @param reason - which left-out change the step needs
26
+ * @param message - safe to show and to log
27
+ */
28
+ constructor(item: string, reason: CantTryReason, message: string);
29
+ }
30
+ /**
31
+ * Whether `value` is a {@link CantTryError}: an `Error` named "CantTryError"
32
+ * with an `item` and a `reason` of a known kind. It works across copies of
33
+ * this package, where `instanceof` doesn't.
34
+ */
35
+ export declare function isCantTryError(value: unknown): value is CantTryError;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * An error a Try it or Test adapter throws when a step it serves can't be
3
+ * tried, because it needs a change left out of the run, such as a model
4
+ * alias that is new in `models.yaml` (requirement `ports.cant-try-error`).
5
+ * The engine then ends the step's branch as it does for a failed step, and
6
+ * the run ends with `run.cant-try` instead of `run.failed`. The engine adds
7
+ * the step's id; the adapter knows the item being tried and why.
8
+ *
9
+ * The message must be safe to show and to log. Check for it with
10
+ * {@link isCantTryError}, not `instanceof`: an adapter may be built against
11
+ * its own copy of this package.
12
+ *
13
+ * @example
14
+ * const reason = { kind: "needs-left-out-change", path: "models.yaml", leftOut: "models" } as const;
15
+ * throw new CantTryError("workflows/triage.yaml", reason, "Alias smart is new.");
16
+ */
17
+ export class CantTryError extends Error {
18
+ name = "CantTryError";
19
+ /** The path of the item being tried. */
20
+ item;
21
+ reason;
22
+ /**
23
+ * @param item - the path of the item being tried
24
+ * @param reason - which left-out change the step needs
25
+ * @param message - safe to show and to log
26
+ */
27
+ constructor(item, reason, message) {
28
+ super(message);
29
+ this.item = item;
30
+ this.reason = reason;
31
+ }
32
+ }
33
+ /**
34
+ * Whether `value` is a {@link CantTryError}: an `Error` named "CantTryError"
35
+ * with an `item` and a `reason` of a known kind. It works across copies of
36
+ * this package, where `instanceof` doesn't.
37
+ */
38
+ export function isCantTryError(value) {
39
+ if (!(value instanceof Error) || value.name !== "CantTryError")
40
+ return false;
41
+ const { item, reason } = value;
42
+ const knownKind = reason?.kind === "needs-left-out-change" || reason?.kind === "invalid-without-change";
43
+ return typeof item === "string" && knownKind;
44
+ }
@@ -0,0 +1,127 @@
1
+ import type { Usage } from "../../events/src/index.js";
2
+ /** A tool call the model asked for. */
3
+ export interface ToolCall {
4
+ id: string;
5
+ name: string;
6
+ arguments: Record<string, unknown>;
7
+ /** Opaque data a provider needs back with this call in later turns (Gemini's thought signature). */
8
+ signature?: string;
9
+ }
10
+ /**
11
+ * A provider's own record of an assistant turn, which it needs back unchanged
12
+ * in later turns (Anthropic's content blocks with their thinking signatures,
13
+ * OpenAI's reasoning items).
14
+ *
15
+ * Only the provider that wrote it reads `data`. The engine copies `replay`
16
+ * from a {@link ChatResponse} onto the assistant {@link ChatMessage} it
17
+ * stores for that turn, never changes it, and keeps it as JSON. A provider
18
+ * sends `data` back only when `type` is its own; otherwise, as after a model
19
+ * switch, it builds the turn from `content` and `toolCalls`.
20
+ *
21
+ * @example
22
+ * const replay: ProviderReplay = { type: "anthropic", data: body.content };
23
+ */
24
+ export interface ProviderReplay {
25
+ /** The provider that wrote it, such as "anthropic". */
26
+ type: string;
27
+ /** JSON-safe data only that provider understands. */
28
+ data: unknown;
29
+ }
30
+ /** One message of a conversation with a model. */
31
+ export type ChatMessage = {
32
+ role: "system";
33
+ content: string;
34
+ } | {
35
+ role: "user";
36
+ content: string;
37
+ } | {
38
+ role: "assistant";
39
+ content: string;
40
+ toolCalls?: ToolCall[];
41
+ replay?: ProviderReplay;
42
+ } | {
43
+ role: "tool";
44
+ content: string;
45
+ toolCallId: string;
46
+ name: string;
47
+ };
48
+ /** A tool the model may call. */
49
+ export interface ToolDefinition {
50
+ name: string;
51
+ description: string;
52
+ /** JSON Schema of the arguments object. */
53
+ parameters: Record<string, unknown>;
54
+ }
55
+ /** Sampling settings for one model call. Providers ignore what they don't support. */
56
+ export interface ChatParams {
57
+ temperature?: number;
58
+ topP?: number;
59
+ maxTokens?: number;
60
+ stop?: string[];
61
+ reasoningEffort?: "low" | "medium" | "high";
62
+ extra?: Record<string, unknown>;
63
+ }
64
+ /** One model call. */
65
+ export interface ChatRequest {
66
+ model: string;
67
+ messages: ChatMessage[];
68
+ tools?: ToolDefinition[];
69
+ params?: ChatParams;
70
+ responseFormat?: "text" | "json";
71
+ /** Who is asking; used by mocks, logging and routing. Never sent to vendors. */
72
+ meta?: {
73
+ agentId?: string;
74
+ runId?: string;
75
+ };
76
+ signal?: AbortSignal;
77
+ }
78
+ /** The model's answer to one {@link ChatRequest}. */
79
+ export interface ChatResponse {
80
+ content: string;
81
+ /** The model's own summary of its reasoning, where the provider gives one (Gemini thought summaries). */
82
+ reasoning?: string;
83
+ toolCalls: ToolCall[];
84
+ usage: Usage;
85
+ finishReason: "stop" | "tool_calls" | "length" | "error" | "other";
86
+ /** The provider's record of this turn; the engine copies it onto the assistant message unchanged. */
87
+ replay?: ProviderReplay;
88
+ }
89
+ /**
90
+ * One piece of a streamed answer. Deltas arrive in the order the model
91
+ * writes them; the stream ends with exactly one `done`, whose `response` is
92
+ * what `chat()` would have returned for the same request.
93
+ *
94
+ * A tool call arrives in pieces too: the first piece for an `index` carries
95
+ * its `id` and `name`, and the `arguments` pieces join into the JSON text of
96
+ * its arguments. Only `done` holds the parsed {@link ToolCall}.
97
+ *
98
+ * The pieces must add up to `done`: the `text` deltas joined equal
99
+ * `done.response.content`, and the `arguments` pieces for each `index`
100
+ * joined parse to `done.response.toolCalls[index].arguments`. A stream that
101
+ * ends without `done`, or yields anything after it, is an error for the
102
+ * caller. The engine runs tool calls only from `done`, never from deltas.
103
+ *
104
+ * @example
105
+ * if (provider.capabilities.streaming && provider.stream) {
106
+ * for await (const event of provider.stream(request)) {
107
+ * if (event.type === "text") showText(event.delta);
108
+ * if (event.type === "done") return event.response;
109
+ * }
110
+ * }
111
+ */
112
+ export type ChatStreamEvent = {
113
+ type: "text";
114
+ delta: string;
115
+ } | {
116
+ type: "reasoning";
117
+ delta: string;
118
+ } | {
119
+ type: "tool-call";
120
+ index: number;
121
+ id?: string;
122
+ name?: string;
123
+ arguments: string;
124
+ } | {
125
+ type: "done";
126
+ response: ChatResponse;
127
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /** Version of the {@link Clock} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const clockVersion = 1;
3
+ /** The current time. Passed in, so tests and replays can fix it. */
4
+ export interface Clock {
5
+ /** The current time. Each call returns a new `Date`, so callers may change it. */
6
+ now(): Date;
7
+ }
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link Clock} port. A breaking change bumps it and comes with an ADR. */
2
+ export const clockVersion = 1;
@@ -0,0 +1,57 @@
1
+ /** Version of the {@link ConnectionSettingsStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const connectionSettingsStoreVersion = 1;
3
+ /** Which connector a setting is for. */
4
+ export interface ConnectionKey {
5
+ /** The workspace's resolved real path, as in a `TrustRecord`. */
6
+ location: string;
7
+ /** The connector's id in the workspace. */
8
+ connector: string;
9
+ }
10
+ /**
11
+ * The settings a person chose for one connector (requirement
12
+ * `ports.connection-settings-store`).
13
+ *
14
+ * @example
15
+ * const settings: ConnectionSettingsRecord = {
16
+ * location: "/workspaces/acme",
17
+ * connector: "mail",
18
+ * allowSending: true,
19
+ * changedAt: "2026-11-09T10:00:00.000Z",
20
+ * };
21
+ */
22
+ export interface ConnectionSettingsRecord extends ConnectionKey {
23
+ /**
24
+ * Whether the connector's tools labelled `send` may run, such as sending
25
+ * a mail. Without a record, sending is off.
26
+ */
27
+ allowSending: boolean;
28
+ /** When the person last changed the settings, as ISO text. */
29
+ changedAt: string;
30
+ }
31
+ /**
32
+ * The settings of each connector, in the user's profile next to the trust
33
+ * records: the profile folder for the CLI and `serve`, the app data folder
34
+ * for the desktop app, memory for tests and the browser demo. **Never
35
+ * inside a workspace**, so an agent that edits the workspace can't switch
36
+ * sending on.
37
+ *
38
+ * The port only stores settings. `ConnectionSettings` in `core/app` reads
39
+ * them, treats a missing record as sending off, and is what the engine and
40
+ * the outside-a-run gate ask. Only a person changes them: no tool the model
41
+ * can call reaches this store.
42
+ *
43
+ * A record that exists but can't be read makes `get` throw, never return
44
+ * `null`: the caller then treats sending as off and tells the user why. The
45
+ * error names the record's key, and `remove` still deletes it.
46
+ */
47
+ export interface ConnectionSettingsStore {
48
+ /** The settings for one connector, or `null` when there are none. */
49
+ get(key: ConnectionKey): Promise<ConnectionSettingsRecord | null>;
50
+ /** Saves settings, replacing any with the same key. */
51
+ save(settings: ConnectionSettingsRecord): Promise<void>;
52
+ /**
53
+ * Deletes the settings for one connector, even ones that can't be read.
54
+ * Removing settings that aren't there is not an error.
55
+ */
56
+ remove(key: ConnectionKey): Promise<void>;
57
+ }
@@ -0,0 +1,2 @@
1
+ /** Version of the {@link ConnectionSettingsStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export const connectionSettingsStoreVersion = 1;