@halonicjs/testing 0.0.0 → 0.1.1

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 (438) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +41 -1
  4. package/dist/adapters/http-kit/src/address-checking.d.ts +19 -0
  5. package/dist/adapters/http-kit/src/address-checking.js +1 -0
  6. package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
  7. package/dist/adapters/http-kit/src/address-class.js +109 -0
  8. package/dist/adapters/http-kit/src/index.d.ts +3 -0
  9. package/dist/adapters/http-kit/src/index.js +2 -0
  10. package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
  11. package/dist/adapters/http-kit/src/ip-address.js +89 -0
  12. package/dist/adapters/integration-kit/src/auth-placement.d.ts +40 -0
  13. package/dist/adapters/integration-kit/src/auth-placement.js +102 -0
  14. package/dist/adapters/integration-kit/src/current-secret-forms.d.ts +28 -0
  15. package/dist/adapters/integration-kit/src/current-secret-forms.js +60 -0
  16. package/dist/adapters/integration-kit/src/declaration.d.ts +15 -0
  17. package/dist/adapters/integration-kit/src/declaration.js +78 -0
  18. package/dist/adapters/integration-kit/src/host.d.ts +34 -0
  19. package/dist/adapters/integration-kit/src/host.js +31 -0
  20. package/dist/adapters/integration-kit/src/index.d.ts +16 -0
  21. package/dist/adapters/integration-kit/src/index.js +22 -0
  22. package/dist/adapters/integration-kit/src/leak-attempt.d.ts +16 -0
  23. package/dist/adapters/integration-kit/src/leak-attempt.js +19 -0
  24. package/dist/adapters/integration-kit/src/limited-http.d.ts +55 -0
  25. package/dist/adapters/integration-kit/src/limited-http.js +225 -0
  26. package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
  27. package/dist/adapters/integration-kit/src/load-problem.js +1 -0
  28. package/dist/adapters/integration-kit/src/loader.d.ts +131 -0
  29. package/dist/adapters/integration-kit/src/loader.js +251 -0
  30. package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
  31. package/dist/adapters/integration-kit/src/local-address.js +25 -0
  32. package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
  33. package/dist/adapters/integration-kit/src/own-request.js +36 -0
  34. package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
  35. package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
  36. package/dist/adapters/integration-kit/src/policy.d.ts +83 -0
  37. package/dist/adapters/integration-kit/src/policy.js +37 -0
  38. package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
  39. package/dist/adapters/integration-kit/src/request-body.js +68 -0
  40. package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
  41. package/dist/adapters/integration-kit/src/request-log.js +17 -0
  42. package/dist/adapters/integration-kit/src/response-body.d.ts +27 -0
  43. package/dist/adapters/integration-kit/src/response-body.js +117 -0
  44. package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
  45. package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
  46. package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
  47. package/dist/adapters/integration-kit/src/secret-filter.js +220 -0
  48. package/dist/adapters/integration-kit/src/secret-in-request.d.ts +62 -0
  49. package/dist/adapters/integration-kit/src/secret-in-request.js +139 -0
  50. package/dist/adapters/integration-kit/src/secret-placement.d.ts +46 -0
  51. package/dist/adapters/integration-kit/src/secret-placement.js +160 -0
  52. package/dist/adapters/integration-kit/src/sign-in-placement.d.ts +29 -0
  53. package/dist/adapters/integration-kit/src/sign-in-placement.js +92 -0
  54. package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
  55. package/dist/adapters/integration-kit/src/wait.js +35 -0
  56. package/dist/core/events/src/add-usage.d.ts +10 -0
  57. package/dist/core/events/src/add-usage.js +27 -0
  58. package/dist/core/events/src/agent-resume.d.ts +24 -0
  59. package/dist/core/events/src/agent-resume.js +1 -0
  60. package/dist/core/events/src/blocked-sites.d.ts +57 -0
  61. package/dist/core/events/src/blocked-sites.js +89 -0
  62. package/dist/core/events/src/home-path.d.ts +13 -0
  63. package/dist/core/events/src/home-path.js +26 -0
  64. package/dist/core/events/src/index.d.ts +17 -0
  65. package/dist/core/events/src/index.js +10 -0
  66. package/dist/core/events/src/run-basics.d.ts +228 -0
  67. package/dist/core/events/src/run-basics.js +1 -0
  68. package/dist/core/events/src/run-event.d.ts +478 -0
  69. package/dist/core/events/src/run-event.js +1 -0
  70. package/dist/core/events/src/run-reads.d.ts +25 -0
  71. package/dist/core/events/src/run-reads.js +44 -0
  72. package/dist/core/events/src/run-sends.d.ts +47 -0
  73. package/dist/core/events/src/run-sends.js +68 -0
  74. package/dist/core/events/src/run-summary.d.ts +108 -0
  75. package/dist/core/events/src/run-summary.js +1 -0
  76. package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
  77. package/dist/core/events/src/sandbox-blocked.js +26 -0
  78. package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
  79. package/dist/core/events/src/sandbox-opened-read.js +63 -0
  80. package/dist/core/events/src/sandbox-opened.d.ts +94 -0
  81. package/dist/core/events/src/sandbox-opened.js +52 -0
  82. package/dist/core/events/src/summarize.d.ts +14 -0
  83. package/dist/core/events/src/summarize.js +192 -0
  84. package/dist/core/events/src/timeline-entry.d.ts +21 -0
  85. package/dist/core/events/src/timeline-entry.js +106 -0
  86. package/dist/core/events/src/upgrade.d.ts +23 -0
  87. package/dist/core/events/src/upgrade.js +49 -0
  88. package/dist/core/format/src/compact.d.ts +30 -0
  89. package/dist/core/format/src/compact.js +72 -0
  90. package/dist/core/format/src/index.d.ts +39 -0
  91. package/dist/core/format/src/index.js +25 -0
  92. package/dist/core/format/src/integration/index.d.ts +7 -0
  93. package/dist/core/format/src/integration/index.js +10 -0
  94. package/dist/core/format/src/json-schema.d.ts +26 -0
  95. package/dist/core/format/src/json-schema.js +48 -0
  96. package/dist/core/format/src/kind.d.ts +65 -0
  97. package/dist/core/format/src/kind.js +1 -0
  98. package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
  99. package/dist/core/format/src/kinds/agent/kind.js +10 -0
  100. package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +99 -0
  101. package/dist/core/format/src/kinds/agent/sandbox-fields.js +216 -0
  102. package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
  103. package/dist/core/format/src/kinds/agent/schema.js +107 -0
  104. package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
  105. package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
  106. package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
  107. package/dist/core/format/src/kinds/collection/kind.js +14 -0
  108. package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
  109. package/dist/core/format/src/kinds/collection/schema.js +90 -0
  110. package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
  111. package/dist/core/format/src/kinds/connector/is-local.js +43 -0
  112. package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
  113. package/dist/core/format/src/kinds/connector/kind.js +218 -0
  114. package/dist/core/format/src/kinds/connector/schema.d.ts +74 -0
  115. package/dist/core/format/src/kinds/connector/schema.js +143 -0
  116. package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
  117. package/dist/core/format/src/kinds/deployments/kind.js +49 -0
  118. package/dist/core/format/src/kinds/deployments/schema.d.ts +77 -0
  119. package/dist/core/format/src/kinds/deployments/schema.js +94 -0
  120. package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
  121. package/dist/core/format/src/kinds/hub/kind.js +10 -0
  122. package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
  123. package/dist/core/format/src/kinds/hub/schema.js +34 -0
  124. package/dist/core/format/src/kinds/integration/approved-sign-ins.d.ts +62 -0
  125. package/dist/core/format/src/kinds/integration/approved-sign-ins.js +125 -0
  126. package/dist/core/format/src/kinds/integration/host-key.d.ts +7 -0
  127. package/dist/core/format/src/kinds/integration/host-key.js +8 -0
  128. package/dist/core/format/src/kinds/integration/kind.d.ts +18 -0
  129. package/dist/core/format/src/kinds/integration/kind.js +175 -0
  130. package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
  131. package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
  132. package/dist/core/format/src/kinds/integration/policy.d.ts +112 -0
  133. package/dist/core/format/src/kinds/integration/policy.js +327 -0
  134. package/dist/core/format/src/kinds/integration/schema.d.ts +410 -0
  135. package/dist/core/format/src/kinds/integration/schema.js +359 -0
  136. package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +13 -0
  137. package/dist/core/format/src/kinds/integration/sign-in-checks.js +120 -0
  138. package/dist/core/format/src/kinds/integration/sign-in-urls.d.ts +19 -0
  139. package/dist/core/format/src/kinds/integration/sign-in-urls.js +47 -0
  140. package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
  141. package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
  142. package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
  143. package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
  144. package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
  145. package/dist/core/format/src/kinds/models/kind.js +10 -0
  146. package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
  147. package/dist/core/format/src/kinds/models/schema.js +38 -0
  148. package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
  149. package/dist/core/format/src/kinds/plugin/backend.js +31 -0
  150. package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
  151. package/dist/core/format/src/kinds/plugin/checks.js +137 -0
  152. package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
  153. package/dist/core/format/src/kinds/plugin/kind.js +16 -0
  154. package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
  155. package/dist/core/format/src/kinds/plugin/problems.js +65 -0
  156. package/dist/core/format/src/kinds/plugin/schema.d.ts +672 -0
  157. package/dist/core/format/src/kinds/plugin/schema.js +261 -0
  158. package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
  159. package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
  160. package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
  161. package/dist/core/format/src/kinds/plugin/ui-checks.js +85 -0
  162. package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
  163. package/dist/core/format/src/kinds/provider/kind.js +24 -0
  164. package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
  165. package/dist/core/format/src/kinds/provider/schema.js +22 -0
  166. package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
  167. package/dist/core/format/src/kinds/routine/kind.js +62 -0
  168. package/dist/core/format/src/kinds/routine/schema.d.ts +94 -0
  169. package/dist/core/format/src/kinds/routine/schema.js +115 -0
  170. package/dist/core/format/src/kinds/routine/webhook-headers.d.ts +9 -0
  171. package/dist/core/format/src/kinds/routine/webhook-headers.js +26 -0
  172. package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
  173. package/dist/core/format/src/kinds/runtime/kind.js +13 -0
  174. package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
  175. package/dist/core/format/src/kinds/runtime/schema.js +12 -0
  176. package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
  177. package/dist/core/format/src/kinds/skill/kind.js +10 -0
  178. package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
  179. package/dist/core/format/src/kinds/skill/schema.js +17 -0
  180. package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
  181. package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
  182. package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
  183. package/dist/core/format/src/kinds/workflow/kind.js +14 -0
  184. package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
  185. package/dist/core/format/src/kinds/workflow/schema.js +106 -0
  186. package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
  187. package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
  188. package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
  189. package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
  190. package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
  191. package/dist/core/format/src/kinds/workspace/kind.js +10 -0
  192. package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
  193. package/dist/core/format/src/kinds/workspace/schema.js +66 -0
  194. package/dist/core/format/src/parse-file.d.ts +69 -0
  195. package/dist/core/format/src/parse-file.js +105 -0
  196. package/dist/core/format/src/recording/format.d.ts +81 -0
  197. package/dist/core/format/src/recording/format.js +102 -0
  198. package/dist/core/format/src/recording/index.d.ts +1 -0
  199. package/dist/core/format/src/recording/index.js +3 -0
  200. package/dist/core/format/src/registry.d.ts +64 -0
  201. package/dist/core/format/src/registry.js +61 -0
  202. package/dist/core/format/src/reserved.d.ts +20 -0
  203. package/dist/core/format/src/reserved.js +30 -0
  204. package/dist/core/format/src/shared/fields.d.ts +34 -0
  205. package/dist/core/format/src/shared/fields.js +74 -0
  206. package/dist/core/format/src/shared/guard.d.ts +32 -0
  207. package/dist/core/format/src/shared/guard.js +16 -0
  208. package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
  209. package/dist/core/format/src/shared/key-in-value.js +82 -0
  210. package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
  211. package/dist/core/format/src/shared/legacy-keys.js +17 -0
  212. package/dist/core/format/src/shared/program-start.d.ts +60 -0
  213. package/dist/core/format/src/shared/program-start.js +99 -0
  214. package/dist/core/format/src/shared/relative-path.d.ts +29 -0
  215. package/dist/core/format/src/shared/relative-path.js +50 -0
  216. package/dist/core/format/src/shared/secret-name.d.ts +24 -0
  217. package/dist/core/format/src/shared/secret-name.js +107 -0
  218. package/dist/core/format/src/source.d.ts +16 -0
  219. package/dist/core/format/src/source.js +73 -0
  220. package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
  221. package/dist/core/ports/src/agent-placement-store.js +27 -0
  222. package/dist/core/ports/src/agent-runs-not-available.d.ts +21 -0
  223. package/dist/core/ports/src/agent-runs-not-available.js +25 -0
  224. package/dist/core/ports/src/blob-store.d.ts +45 -0
  225. package/dist/core/ports/src/blob-store.js +24 -0
  226. package/dist/core/ports/src/cant-try-error.d.ts +35 -0
  227. package/dist/core/ports/src/cant-try-error.js +44 -0
  228. package/dist/core/ports/src/chat.d.ts +127 -0
  229. package/dist/core/ports/src/chat.js +1 -0
  230. package/dist/core/ports/src/clock.d.ts +7 -0
  231. package/dist/core/ports/src/clock.js +2 -0
  232. package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
  233. package/dist/core/ports/src/connection-settings-store.js +2 -0
  234. package/dist/core/ports/src/connector-client.d.ts +303 -0
  235. package/dist/core/ports/src/connector-client.js +19 -0
  236. package/dist/core/ports/src/coordination.d.ts +84 -0
  237. package/dist/core/ports/src/coordination.js +2 -0
  238. package/dist/core/ports/src/definition-store.d.ts +229 -0
  239. package/dist/core/ports/src/definition-store.js +122 -0
  240. package/dist/core/ports/src/digest.d.ts +14 -0
  241. package/dist/core/ports/src/digest.js +2 -0
  242. package/dist/core/ports/src/folder-reader.d.ts +89 -0
  243. package/dist/core/ports/src/folder-reader.js +2 -0
  244. package/dist/core/ports/src/harness-bridge-server.d.ts +198 -0
  245. package/dist/core/ports/src/harness-bridge-server.js +37 -0
  246. package/dist/core/ports/src/harness-sign-in-command.d.ts +27 -0
  247. package/dist/core/ports/src/harness-sign-in-command.js +31 -0
  248. package/dist/core/ports/src/harness.d.ts +283 -0
  249. package/dist/core/ports/src/harness.js +45 -0
  250. package/dist/core/ports/src/host-settings-store.d.ts +116 -0
  251. package/dist/core/ports/src/host-settings-store.js +106 -0
  252. package/dist/core/ports/src/http-client.d.ts +27 -0
  253. package/dist/core/ports/src/http-client.js +2 -0
  254. package/dist/core/ports/src/id-generator.d.ts +14 -0
  255. package/dist/core/ports/src/id-generator.js +2 -0
  256. package/dist/core/ports/src/index.d.ts +45 -0
  257. package/dist/core/ports/src/index.js +44 -0
  258. package/dist/core/ports/src/instruction-trust-store.d.ts +81 -0
  259. package/dist/core/ports/src/instruction-trust-store.js +43 -0
  260. package/dist/core/ports/src/integration.d.ts +242 -0
  261. package/dist/core/ports/src/integration.js +31 -0
  262. package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
  263. package/dist/core/ports/src/knowledge-provider.js +2 -0
  264. package/dist/core/ports/src/llm-cache.d.ts +13 -0
  265. package/dist/core/ports/src/llm-cache.js +2 -0
  266. package/dist/core/ports/src/llm-provider.d.ts +186 -0
  267. package/dist/core/ports/src/llm-provider.js +139 -0
  268. package/dist/core/ports/src/model-price.d.ts +34 -0
  269. package/dist/core/ports/src/model-price.js +25 -0
  270. package/dist/core/ports/src/password-hasher.d.ts +63 -0
  271. package/dist/core/ports/src/password-hasher.js +2 -0
  272. package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
  273. package/dist/core/ports/src/plugin-folder-writer.js +95 -0
  274. package/dist/core/ports/src/port-versions.d.ts +47 -0
  275. package/dist/core/ports/src/port-versions.js +80 -0
  276. package/dist/core/ports/src/program-probe.d.ts +69 -0
  277. package/dist/core/ports/src/program-probe.js +2 -0
  278. package/dist/core/ports/src/provider-default-base-url.d.ts +10 -0
  279. package/dist/core/ports/src/provider-default-base-url.js +18 -0
  280. package/dist/core/ports/src/record-store.d.ts +79 -0
  281. package/dist/core/ports/src/record-store.js +108 -0
  282. package/dist/core/ports/src/resource-probe.d.ts +59 -0
  283. package/dist/core/ports/src/resource-probe.js +2 -0
  284. package/dist/core/ports/src/run-executor.d.ts +303 -0
  285. package/dist/core/ports/src/run-executor.js +2 -0
  286. package/dist/core/ports/src/run-failure-error.d.ts +49 -0
  287. package/dist/core/ports/src/run-failure-error.js +47 -0
  288. package/dist/core/ports/src/run-store.d.ts +194 -0
  289. package/dist/core/ports/src/run-store.js +131 -0
  290. package/dist/core/ports/src/run-target-not-found.d.ts +34 -0
  291. package/dist/core/ports/src/run-target-not-found.js +41 -0
  292. package/dist/core/ports/src/sandbox-setting-store.d.ts +68 -0
  293. package/dist/core/ports/src/sandbox-setting-store.js +33 -0
  294. package/dist/core/ports/src/sandbox.d.ts +364 -0
  295. package/dist/core/ports/src/sandbox.js +70 -0
  296. package/dist/core/ports/src/scheduler.d.ts +85 -0
  297. package/dist/core/ports/src/scheduler.js +2 -0
  298. package/dist/core/ports/src/secrets.d.ts +201 -0
  299. package/dist/core/ports/src/secrets.js +200 -0
  300. package/dist/core/ports/src/token-store.d.ts +19 -0
  301. package/dist/core/ports/src/token-store.js +2 -0
  302. package/dist/core/ports/src/tool-approval-store.d.ts +253 -0
  303. package/dist/core/ports/src/tool-approval-store.js +116 -0
  304. package/dist/core/ports/src/trust-store.d.ts +72 -0
  305. package/dist/core/ports/src/trust-store.js +2 -0
  306. package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
  307. package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
  308. package/dist/core/ports/src/vcs-status.d.ts +8 -0
  309. package/dist/core/ports/src/vcs-status.js +90 -0
  310. package/dist/core/ports/src/vcs.d.ts +394 -0
  311. package/dist/core/ports/src/vcs.js +48 -0
  312. package/dist/core/schema-kit/src/builders.d.ts +50 -0
  313. package/dist/core/schema-kit/src/builders.js +72 -0
  314. package/dist/core/schema-kit/src/depth.d.ts +15 -0
  315. package/dist/core/schema-kit/src/depth.js +37 -0
  316. package/dist/core/schema-kit/src/index.d.ts +6 -0
  317. package/dist/core/schema-kit/src/index.js +6 -0
  318. package/dist/core/schema-kit/src/issue.d.ts +22 -0
  319. package/dist/core/schema-kit/src/issue.js +23 -0
  320. package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
  321. package/dist/core/schema-kit/src/json-schema.js +22 -0
  322. package/dist/core/schema-kit/src/parse.d.ts +17 -0
  323. package/dist/core/schema-kit/src/parse.js +25 -0
  324. package/dist/core/schema-kit/src/schema.d.ts +12 -0
  325. package/dist/core/schema-kit/src/schema.js +1 -0
  326. package/dist/core/std/src/amount.d.ts +13 -0
  327. package/dist/core/std/src/amount.js +22 -0
  328. package/dist/core/std/src/ascii-host.d.ts +18 -0
  329. package/dist/core/std/src/ascii-host.js +110 -0
  330. package/dist/core/std/src/assert.d.ts +39 -0
  331. package/dist/core/std/src/assert.js +59 -0
  332. package/dist/core/std/src/base64url.d.ts +23 -0
  333. package/dist/core/std/src/base64url.js +65 -0
  334. package/dist/core/std/src/canonical-json.d.ts +18 -0
  335. package/dist/core/std/src/canonical-json.js +56 -0
  336. package/dist/core/std/src/clock.d.ts +27 -0
  337. package/dist/core/std/src/clock.js +33 -0
  338. package/dist/core/std/src/constant-time.d.ts +16 -0
  339. package/dist/core/std/src/constant-time.js +26 -0
  340. package/dist/core/std/src/content-digest.d.ts +24 -0
  341. package/dist/core/std/src/content-digest.js +28 -0
  342. package/dist/core/std/src/deep-clone.d.ts +15 -0
  343. package/dist/core/std/src/deep-clone.js +59 -0
  344. package/dist/core/std/src/deep-equal.d.ts +23 -0
  345. package/dist/core/std/src/deep-equal.js +64 -0
  346. package/dist/core/std/src/emitter.d.ts +42 -0
  347. package/dist/core/std/src/emitter.js +74 -0
  348. package/dist/core/std/src/error-kind.d.ts +88 -0
  349. package/dist/core/std/src/error-kind.js +98 -0
  350. package/dist/core/std/src/hex.d.ts +10 -0
  351. package/dist/core/std/src/hex.js +16 -0
  352. package/dist/core/std/src/hidden-characters.d.ts +19 -0
  353. package/dist/core/std/src/hidden-characters.js +54 -0
  354. package/dist/core/std/src/ids.d.ts +45 -0
  355. package/dist/core/std/src/ids.js +49 -0
  356. package/dist/core/std/src/index.d.ts +30 -0
  357. package/dist/core/std/src/index.js +31 -0
  358. package/dist/core/std/src/keyed-queue.d.ts +18 -0
  359. package/dist/core/std/src/keyed-queue.js +32 -0
  360. package/dist/core/std/src/line-diff.d.ts +83 -0
  361. package/dist/core/std/src/line-diff.js +179 -0
  362. package/dist/core/std/src/line-merge.d.ts +63 -0
  363. package/dist/core/std/src/line-merge.js +138 -0
  364. package/dist/core/std/src/plain-data.d.ts +32 -0
  365. package/dist/core/std/src/plain-data.js +57 -0
  366. package/dist/core/std/src/posix-path.d.ts +61 -0
  367. package/dist/core/std/src/posix-path.js +121 -0
  368. package/dist/core/std/src/public-suffixes.generated.d.ts +9 -0
  369. package/dist/core/std/src/public-suffixes.generated.js +10429 -0
  370. package/dist/core/std/src/registrable-domain.d.ts +10 -0
  371. package/dist/core/std/src/registrable-domain.js +62 -0
  372. package/dist/core/std/src/result.d.ts +55 -0
  373. package/dist/core/std/src/result.js +52 -0
  374. package/dist/core/std/src/secret-scrubber.d.ts +54 -0
  375. package/dist/core/std/src/secret-scrubber.js +124 -0
  376. package/dist/core/std/src/secret-shape.d.ts +20 -0
  377. package/dist/core/std/src/secret-shape.js +53 -0
  378. package/dist/core/std/src/secret-variable-name.d.ts +12 -0
  379. package/dist/core/std/src/secret-variable-name.js +34 -0
  380. package/dist/core/std/src/site-name.d.ts +35 -0
  381. package/dist/core/std/src/site-name.js +111 -0
  382. package/dist/core/std/src/stop-signal.d.ts +44 -0
  383. package/dist/core/std/src/stop-signal.js +77 -0
  384. package/dist/core/std/src/text.d.ts +28 -0
  385. package/dist/core/std/src/text.js +54 -0
  386. package/dist/core/std/src/url-host.d.ts +35 -0
  387. package/dist/core/std/src/url-host.js +170 -0
  388. package/dist/core/std/src/utf8.d.ts +23 -0
  389. package/dist/core/std/src/utf8.js +110 -0
  390. package/dist/core/std/src/version.d.ts +48 -0
  391. package/dist/core/std/src/version.js +103 -0
  392. package/dist/core/yaml/src/depth.d.ts +14 -0
  393. package/dist/core/yaml/src/depth.js +140 -0
  394. package/dist/core/yaml/src/edit-data.d.ts +47 -0
  395. package/dist/core/yaml/src/edit-data.js +286 -0
  396. package/dist/core/yaml/src/edit-text.d.ts +92 -0
  397. package/dist/core/yaml/src/edit-text.js +267 -0
  398. package/dist/core/yaml/src/edit.d.ts +47 -0
  399. package/dist/core/yaml/src/edit.js +198 -0
  400. package/dist/core/yaml/src/index.d.ts +5 -0
  401. package/dist/core/yaml/src/index.js +4 -0
  402. package/dist/core/yaml/src/problem.d.ts +20 -0
  403. package/dist/core/yaml/src/problem.js +1 -0
  404. package/dist/core/yaml/src/read.d.ts +47 -0
  405. package/dist/core/yaml/src/read.js +130 -0
  406. package/dist/core/yaml/src/splice-node.d.ts +47 -0
  407. package/dist/core/yaml/src/splice-node.js +333 -0
  408. package/dist/core/yaml/src/splice.d.ts +13 -0
  409. package/dist/core/yaml/src/splice.js +174 -0
  410. package/dist/core/yaml/src/unsupported.d.ts +26 -0
  411. package/dist/core/yaml/src/unsupported.js +70 -0
  412. package/dist/core/yaml/src/write.d.ts +35 -0
  413. package/dist/core/yaml/src/write.js +44 -0
  414. package/dist/testing/integration/src/canaries.d.ts +14 -0
  415. package/dist/testing/integration/src/canaries.js +17 -0
  416. package/dist/testing/integration/src/checks.d.ts +37 -0
  417. package/dist/testing/integration/src/checks.js +195 -0
  418. package/dist/testing/integration/src/describe.d.ts +35 -0
  419. package/dist/testing/integration/src/describe.js +74 -0
  420. package/dist/testing/integration/src/failure.d.ts +6 -0
  421. package/dist/testing/integration/src/failure.js +8 -0
  422. package/dist/testing/integration/src/fake-wait.d.ts +18 -0
  423. package/dist/testing/integration/src/fake-wait.js +21 -0
  424. package/dist/testing/integration/src/index.d.ts +10 -0
  425. package/dist/testing/integration/src/index.js +11 -0
  426. package/dist/testing/integration/src/load.d.ts +14 -0
  427. package/dist/testing/integration/src/load.js +47 -0
  428. package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
  429. package/dist/testing/integration/src/plugin-folder.js +59 -0
  430. package/dist/testing/integration/src/plugin.d.ts +32 -0
  431. package/dist/testing/integration/src/plugin.js +57 -0
  432. package/dist/testing/integration/src/recording.d.ts +84 -0
  433. package/dist/testing/integration/src/recording.js +164 -0
  434. package/dist/testing/integration/src/run.d.ts +60 -0
  435. package/dist/testing/integration/src/run.js +81 -0
  436. package/dist/testing/integration/src/source-scan.d.ts +16 -0
  437. package/dist/testing/integration/src/source-scan.js +40 -0
  438. package/package.json +34 -3
@@ -0,0 +1,37 @@
1
+ import { priceOf } from "./model-price.js";
2
+ /** Version of the {@link HarnessBridgeServer} port. A breaking change bumps it and comes with an ADR. */
3
+ export const harnessBridgeServerVersion = 1;
4
+ /**
5
+ * The `cost` the bridge records on a model call's `llm.response`, in the
6
+ * workspace's budget currency (requirement `ports.harness-bridge-server`).
7
+ * A sign-in call costs 0, because the person's subscription pays. A keyed call
8
+ * costs its tokens at the model's price ({@link priceOf}), or is `undefined` (unpriced) when the
9
+ * model has no price.
10
+ *
11
+ * @deprecated Use {@link bridgeCallCharge}, which also marks a sign-in call
12
+ * `paidBy: "subscription"`. Recording this cost alone writes a sign-in call
13
+ * as a free call, so the run never counts it in `subscriptionCalls`.
14
+ */
15
+ export function bridgeCallCost(access, price, usage) {
16
+ if (access.kind === "sign-in")
17
+ return 0;
18
+ if (price === null)
19
+ return undefined;
20
+ return priceOf(price, usage);
21
+ }
22
+ /**
23
+ * The `cost` and `paidBy` the bridge records on a model call's
24
+ * `llm.response` (requirement `ports.harness-bridge-server`). A sign-in call
25
+ * gets `cost: 0` and `paidBy: "subscription"`, so the run counts it in
26
+ * `subscriptionCalls`. A keyed call gets the cost from {@link bridgeCallCost},
27
+ * or nothing when its model has no price.
28
+ *
29
+ * @example
30
+ * recorder.record({ type: "llm.response", ...call, ...bridgeCallCharge(access, price, usage) });
31
+ */
32
+ export function bridgeCallCharge(access, price, usage) {
33
+ if (access.kind === "sign-in")
34
+ return { cost: 0, paidBy: "subscription" };
35
+ const cost = bridgeCallCost(access, price, usage);
36
+ return cost === undefined ? {} : { cost };
37
+ }
@@ -0,0 +1,27 @@
1
+ import type { HarnessSignIn } from "./harness.js";
2
+ /**
3
+ * The terminal a person types a sign-in into: PowerShell, the default
4
+ * terminal on Windows, or `sh` and the shells that read it like `sh` elsewhere.
5
+ */
6
+ export type SignInShell = "powershell" | "sh";
7
+ /**
8
+ * A harness's sign-in for one agent, as a person types it into their own
9
+ * terminal (requirement `ports.harness-sign-in-command`). Studio shows it
10
+ * when it can't open a window, and `halonic doctor` shows it for each
11
+ * agent that isn't signed in, so both print the same command.
12
+ *
13
+ * It names the program as the person's `PATH` finds it and sets the
14
+ * agent's folder for this command only. The folder is single-quoted, so the
15
+ * shell takes it as it is: no variable, `~` or wildcard in it is expanded.
16
+ *
17
+ * @param signIn - the harness's own sign-in
18
+ * @param settingsFolder - the agent's settings folder, absolute
19
+ * @param shell - the terminal it is typed into
20
+ *
21
+ * @example
22
+ * signInCommandText(claudeCodeSignIn, "/data/agents/writer", "sh");
23
+ * // CLAUDE_CONFIG_DIR='/data/agents/writer' claude auth login
24
+ * signInCommandText(claudeCodeSignIn, agentFolder, "powershell");
25
+ * // $env:CLAUDE_CONFIG_DIR = '<agentFolder>'; claude auth login
26
+ */
27
+ export declare function signInCommandText(signIn: HarnessSignIn, settingsFolder: string, shell: SignInShell): string;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A harness's sign-in for one agent, as a person types it into their own
3
+ * terminal (requirement `ports.harness-sign-in-command`). Studio shows it
4
+ * when it can't open a window, and `halonic doctor` shows it for each
5
+ * agent that isn't signed in, so both print the same command.
6
+ *
7
+ * It names the program as the person's `PATH` finds it and sets the
8
+ * agent's folder for this command only. The folder is single-quoted, so the
9
+ * shell takes it as it is: no variable, `~` or wildcard in it is expanded.
10
+ *
11
+ * @param signIn - the harness's own sign-in
12
+ * @param settingsFolder - the agent's settings folder, absolute
13
+ * @param shell - the terminal it is typed into
14
+ *
15
+ * @example
16
+ * signInCommandText(claudeCodeSignIn, "/data/agents/writer", "sh");
17
+ * // CLAUDE_CONFIG_DIR='/data/agents/writer' claude auth login
18
+ * signInCommandText(claudeCodeSignIn, agentFolder, "powershell");
19
+ * // $env:CLAUDE_CONFIG_DIR = '<agentFolder>'; claude auth login
20
+ */
21
+ export function signInCommandText(signIn, settingsFolder, shell) {
22
+ const words = [signIn.program, ...signIn.args].join(" ");
23
+ if (shell === "powershell") {
24
+ // PowerShell keeps a single-quoted string as it is, apart from `''` for one `'`.
25
+ const folder = `'${settingsFolder.replaceAll("'", "''")}'`;
26
+ return `$env:${signIn.folderVariable} = ${folder}; ${words}`;
27
+ }
28
+ // `sh` keeps a single-quoted string as it is; a `'` closes it, so it is written `'\''`.
29
+ const folder = `'${settingsFolder.replaceAll("'", "'\\''")}'`;
30
+ return `${signIn.folderVariable}=${folder} ${words}`;
31
+ }
@@ -0,0 +1,283 @@
1
+ import type { AgentResume, RunEventBody, RunEventType } from "../../events/src/index.js";
2
+ import type { SandboxProfile, SandboxSession } from "./sandbox.js";
3
+ /** Version of the {@link Harness} port. A breaking change bumps it and comes with an ADR. */
4
+ export declare const harnessVersion = 3;
5
+ /**
6
+ * Whether a harness can run on this machine, as `detect()` finds it. Studio
7
+ * turns it into the sentence next to the harness choice, so each case
8
+ * carries what that sentence needs.
9
+ *
10
+ * @example
11
+ * const found = await codex.detect();
12
+ * if (found.status === "missing") show(`${codex.name} isn't installed`);
13
+ * if (found.status === "unsupported") {
14
+ * const oldest = found.supported.replace(/^>=/, "");
15
+ * show(`${codex.name} ${found.version} isn't supported. Halonic needs ${oldest} or newer.`);
16
+ * }
17
+ * if (found.status === "signed-out") show(`Found ${codex.name} ${found.version} · not signed in`);
18
+ */
19
+ export type HarnessDetection =
20
+ /**
21
+ * Installed in a version Halonic supports, and signed in, or its sign-in
22
+ * can't be checked. Asked about an agent's settings folder, "signed in"
23
+ * means that agent is; otherwise it means the person is, in their own
24
+ * settings, which a run never uses.
25
+ */
26
+ {
27
+ status: "ready";
28
+ version: string;
29
+ }
30
+ /**
31
+ * Installed in a version Halonic supports, but the program says no one is
32
+ * signed in: for the agent whose settings folder `detect()` was given, or
33
+ * else on this computer. It can still run when Halonic holds a key
34
+ * for the agent's model provider, so this isn't an error on its own.
35
+ */
36
+ | {
37
+ status: "signed-out";
38
+ version: string;
39
+ }
40
+ /** The program isn't installed, or isn't where Halonic looks for it. */
41
+ | {
42
+ status: "missing";
43
+ }
44
+ /**
45
+ * Installed, but in a version Halonic doesn't support. `supported` names the
46
+ * oldest version it does, always written as ">=X.Y.Z" (such as ">=1.0.0"),
47
+ * so screens can drop the ">=" and say "needs 1.0.0 or newer".
48
+ */
49
+ | {
50
+ status: "unsupported";
51
+ version: string;
52
+ supported: string;
53
+ }
54
+ /** Found, but asking it for its version failed; `error` says how, in words a person can act on. */
55
+ | {
56
+ status: "failed";
57
+ error: string;
58
+ };
59
+ /** What `detect()` may be asked about. */
60
+ export interface HarnessDetectOptions {
61
+ /**
62
+ * The agent's own settings folder, the one its runs get as
63
+ * `settingsFolder`. With it, the sign-in answer is about that agent, which
64
+ * is what a run needs. Without it, `detect()` checks the program and the
65
+ * person's own sign-in, as `halonic doctor` does outside an agent.
66
+ */
67
+ settingsFolder?: string;
68
+ }
69
+ /** What a harness run is asked to do: one agent of one run, with the agent's own settings. */
70
+ export interface HarnessTask {
71
+ /** The run this agent belongs to. Every event the harness reports is written to its log. */
72
+ runId: string;
73
+ hubId: string;
74
+ /** The agent's id; the harness sets it as `agent` on the events it reports for this agent. */
75
+ agentId: string;
76
+ /** The agent's instructions from its file; empty when it has none. */
77
+ instructions: string;
78
+ /** What the agent is asked to do in this run: the task step's prompt, or the chat message. */
79
+ prompt: string;
80
+ /** The model the agent's file names; the harness's own default when absent. */
81
+ model?: string;
82
+ }
83
+ /**
84
+ * The request header that carries the run's bridge token. The token has a
85
+ * header of its own because `Authorization` isn't free: with a subscription,
86
+ * it carries the person's own sign-in, which the bridge passes on unread.
87
+ * Never put the token in the URL, because paths end up in logs.
88
+ */
89
+ export declare const harnessBridgeTokenHeader = "x-halonic-run-token";
90
+ /**
91
+ * The Halonic bridge of one run: an address in Halonic that serves the model
92
+ * gateway and Halonic's tools over MCP. The harness points its program at
93
+ * `url` and has it send `token` in the {@link harnessBridgeTokenHeader}
94
+ * header on every request.
95
+ *
96
+ * The token is a credential for this run only. A harness never writes it into
97
+ * an event, a log line or an error message.
98
+ */
99
+ export interface HarnessBridge {
100
+ /**
101
+ * The address the program calls: on loopback, such as
102
+ * "http://127.0.0.1:41817", or, when the bridge serves a Unix socket, the
103
+ * name the sandbox's proxy sends to it, such as
104
+ * "http://bridge.halonic.invalid".
105
+ */
106
+ url: string;
107
+ /** The run's random token. */
108
+ token: string;
109
+ /**
110
+ * The absolute path of the Unix socket the bridge serves, when it serves
111
+ * one instead of a loopback port. Absent for a loopback bridge.
112
+ */
113
+ socketPath?: string;
114
+ }
115
+ /** The body of the run log event with this `type`. */
116
+ type RunEventOf<Type extends RunEventType> = Extract<RunEventBody, {
117
+ type: Type;
118
+ }>;
119
+ /**
120
+ * What a harness reports, as run log events without the fields the engine
121
+ * adds. A harness run is still a Halonic run: Runs, the receipt, budgets and
122
+ * the inbox read these events as they read the built-in agent loop's, so a
123
+ * harness has no event types of its own.
124
+ *
125
+ * The engine adds the run fields (`runId`, `seq`, `at`) and the workflow
126
+ * `state` the agent runs in, then writes the event to the run's log.
127
+ *
128
+ * - `agent.started` and `agent.finished` with a `parent` report a subagent.
129
+ * The engine writes the task's own `agent.started` before it calls
130
+ * `start`; the stream ends with the task's own `agent.finished`, without a
131
+ * `parent`, whose `output` is the agent's result.
132
+ * - `llm.request`, `llm.response` and `llm.fallback` report model calls, with
133
+ * their token use and cost.
134
+ * - `knowledge.searched`, `tool.called` and `tool.result` report tool use.
135
+ * - `approval.requested` asks a person for an OK; the harness waits until
136
+ * `send` brings the answer. The built-in loop sets `resume`, so the run can
137
+ * continue after a restart; a program can't be resumed, so a program
138
+ * harness leaves it out.
139
+ *
140
+ * `approval.resolved` isn't here: the engine writes it when a person answers,
141
+ * and passes the answer on with `send`.
142
+ *
143
+ * Each model call and tool call is recorded once. A call that goes through
144
+ * the Halonic bridge is recorded by the bridge, so a harness reports only the
145
+ * calls its program makes elsewhere. The built-in loop calls the model port
146
+ * and Halonic's tools directly, so it reports all of its own.
147
+ */
148
+ export type HarnessEvent = Omit<RunEventOf<"agent.started">, "state"> | RunEventOf<"llm.request"> | RunEventOf<"llm.response"> | RunEventOf<"llm.fallback"> | RunEventOf<"knowledge.searched"> | RunEventOf<"tool.called"> | RunEventOf<"tool.result"> | (Omit<RunEventOf<"approval.requested">, "state" | "resume"> & {
149
+ resume?: AgentResume;
150
+ }) | Omit<RunEventOf<"agent.finished">, "state">;
151
+ /** What `send` passes to a running harness. */
152
+ export type HarnessInput =
153
+ /** A person's answer to a question the agent asked, or the next message of a chat. */
154
+ {
155
+ type: "answer";
156
+ text: string;
157
+ }
158
+ /** A person's decision on the `approval.requested` event with this `callId`. */
159
+ | {
160
+ type: "approval";
161
+ callId: string;
162
+ approved: boolean;
163
+ comment?: string;
164
+ };
165
+ /**
166
+ * One harness run: its events, read with `for await`, and the way to answer
167
+ * it or stop it.
168
+ *
169
+ * The stream ends with the task agent's `agent.finished` and yields nothing
170
+ * after it. A run that fails or is cancelled ends the stream with an error
171
+ * instead. An error never contains the bridge token.
172
+ */
173
+ export interface HarnessRun extends AsyncIterable<HarnessEvent> {
174
+ /**
175
+ * Passes a person's answer or approval decision to the run.
176
+ *
177
+ * @throws when the run has ended, or no `approval.requested` with that `callId` is waiting
178
+ */
179
+ send(input: HarnessInput): Promise<void>;
180
+ /**
181
+ * Stops the run. Resolves once every program it started has stopped; does nothing on a run that has ended.
182
+ *
183
+ * @throws when a program it started can't be stopped, so it may still be running; the error never contains the bridge token
184
+ */
185
+ cancel(): Promise<void>;
186
+ }
187
+ /**
188
+ * What drives an agent: Halonic's own agent loop, Claude Code or Codex. An
189
+ * agent's file picks one by `id`.
190
+ *
191
+ * Every harness runs behind Halonic's `Sandbox` port and reaches Halonic
192
+ * only through the bridge, so integrations, secrets and approvals stay in
193
+ * Halonic. The built-in loop starts no program for the agent: it calls the
194
+ * model port and Halonic's tools directly, ignores `bridge`, and uses
195
+ * `session` only to start the stdio connectors a workspace names. On a
196
+ * target that can't start programs, such as a cloud worker, the session's
197
+ * `start` throws, so the same loop runs there without stdio connectors.
198
+ *
199
+ * @example
200
+ * const found = await harness.detect({ settingsFolder: agentSettingsFolder });
201
+ * if (found.status !== "ready") return;
202
+ * const extra = harness.environment?.(bridge, profile) ?? {};
203
+ * const session = await sandbox.open({ ...profile, env: addHarnessEnvironment(profile.env, extra) });
204
+ * const run = harness.start(task, session, bridge);
205
+ * for await (const event of run) {
206
+ * if (event.type === "approval.requested") await run.send(await askPerson(event));
207
+ * else record(event);
208
+ * }
209
+ */
210
+ export interface Harness {
211
+ /** The value of `harness` in an agent's file, such as "claude-code". */
212
+ readonly id: string;
213
+ /** The name a person reads, such as "Claude Code". */
214
+ readonly name: string;
215
+ /**
216
+ * Finds the harness's program on this machine, checks its version and,
217
+ * where the program can tell, whether someone is signed in to it. Given
218
+ * an agent's settings folder, it asks the program about that folder's
219
+ * sign-in (requirement `ports.harness-detect-folder`). Never throws: a
220
+ * problem is a {@link HarnessDetection}.
221
+ */
222
+ detect(options?: HarnessDetectOptions): Promise<HarnessDetection>;
223
+ /**
224
+ * The environment variables the harness's program needs, such as the
225
+ * bridge's address, the token header and the program's own settings and
226
+ * temp folders (requirement `ports.harness-environment`). The engine calls
227
+ * it before it opens the sandbox and adds the result to the profile's `env`
228
+ * with {@link addHarnessEnvironment}, so `session.profile` stays exactly
229
+ * what the program gets.
230
+ *
231
+ * Optional: the built-in loop starts no program, so it has none.
232
+ */
233
+ environment?(bridge: HarnessBridge, folders: Pick<SandboxProfile, "workingFolder" | "tempFolder" | "settingsFolder">): Record<string, string>;
234
+ /**
235
+ * Starts the agent on `task` inside the sandbox `session`, pointed at the
236
+ * run's `bridge`. Returns at once; a program that can't start ends the
237
+ * stream with an error.
238
+ */
239
+ start(task: HarnessTask, session: SandboxSession, bridge: HarnessBridge): HarnessRun;
240
+ /**
241
+ * How a person signs in to the harness's program for one agent, with the
242
+ * program's own sign-in (requirement `ports.harness-sign-in`). Studio runs
243
+ * it in a terminal the person can see, and `halonic doctor` shows it.
244
+ *
245
+ * Optional: the built-in loop has no sign-in of its own.
246
+ */
247
+ readonly signIn?: HarnessSignIn;
248
+ }
249
+ /**
250
+ * The program's own sign-in, pointed at one agent's settings folder. Each
251
+ * agent signs in on its own, so a run reaches only its own sign-in; the
252
+ * person's own is never copied there.
253
+ *
254
+ * @example
255
+ * // Claude Code: CLAUDE_CONFIG_DIR=<agent's folder> claude auth login
256
+ * const { program, args, folderVariable } = harness.signIn;
257
+ * start(program, args, { [folderVariable]: profile.settingsFolder });
258
+ */
259
+ export interface HarnessSignIn {
260
+ /** The program, by the name Halonic finds it under, such as "claude". */
261
+ readonly program: string;
262
+ /** What it is asked to sign in, such as `["auth", "login"]`. */
263
+ readonly args: readonly string[];
264
+ /**
265
+ * The environment variable that points the program at the agent's
266
+ * settings folder, such as "CLAUDE_CONFIG_DIR": the same one
267
+ * `environment()` sets for a run.
268
+ */
269
+ readonly folderVariable: string;
270
+ }
271
+ /**
272
+ * The profile's environment with a harness's variables added (requirement
273
+ * `ports.harness-environment`). A harness may only add: a name the engine
274
+ * already set is an error, so a harness can't quietly replace `PATH` or
275
+ * `HOME`. Names are compared without regard to case, because Windows treats
276
+ * `Path` and `PATH` as one variable. For the same reason a harness may not set
277
+ * two names that differ only in case: which one wins would depend on the
278
+ * platform.
279
+ *
280
+ * @throws Error naming the variables in question, never their values, which may hold the run token
281
+ */
282
+ export declare function addHarnessEnvironment(engine: Readonly<Record<string, string>>, harness: Readonly<Record<string, string>>): Record<string, string>;
283
+ export {};
@@ -0,0 +1,45 @@
1
+ /** Version of the {@link Harness} port. A breaking change bumps it and comes with an ADR. */
2
+ export const harnessVersion = 3;
3
+ /**
4
+ * The request header that carries the run's bridge token. The token has a
5
+ * header of its own because `Authorization` isn't free: with a subscription,
6
+ * it carries the person's own sign-in, which the bridge passes on unread.
7
+ * Never put the token in the URL, because paths end up in logs.
8
+ */
9
+ export const harnessBridgeTokenHeader = "x-halonic-run-token";
10
+ /**
11
+ * The profile's environment with a harness's variables added (requirement
12
+ * `ports.harness-environment`). A harness may only add: a name the engine
13
+ * already set is an error, so a harness can't quietly replace `PATH` or
14
+ * `HOME`. Names are compared without regard to case, because Windows treats
15
+ * `Path` and `PATH` as one variable. For the same reason a harness may not set
16
+ * two names that differ only in case: which one wins would depend on the
17
+ * platform.
18
+ *
19
+ * @throws Error naming the variables in question, never their values, which may hold the run token
20
+ */
21
+ export function addHarnessEnvironment(engine, harness) {
22
+ const twice = namesSetTwice(Object.keys(harness));
23
+ if (twice.length > 0) {
24
+ throw new Error(`The harness sets environment variables that differ only in case: ${twice.join(", ")}`);
25
+ }
26
+ const engineNames = new Set(Object.keys(engine).map((name) => name.toUpperCase()));
27
+ const clashes = Object.keys(harness).filter((name) => engineNames.has(name.toUpperCase()));
28
+ if (clashes.length > 0) {
29
+ throw new Error(`The harness sets environment variables Halonic already sets: ${clashes.join(", ")}`);
30
+ }
31
+ return { ...engine, ...harness };
32
+ }
33
+ /** The names that share their spelling, apart from case, with an earlier name. */
34
+ function namesSetTwice(names) {
35
+ const seen = new Set();
36
+ const twice = [];
37
+ for (const name of names) {
38
+ const key = name.toUpperCase();
39
+ if (seen.has(key))
40
+ twice.push(name);
41
+ else
42
+ seen.add(key);
43
+ }
44
+ return twice;
45
+ }
@@ -0,0 +1,116 @@
1
+ /** Version of the {@link HostSettingsStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export declare const hostSettingsStoreVersion = 1;
3
+ /** A saved setting's value: anything `JSON.parse` can give back. */
4
+ export type HostSettingValue = null | boolean | number | string | readonly HostSettingValue[] | {
5
+ readonly [name: string]: HostSettingValue;
6
+ };
7
+ /**
8
+ * Every saved setting, by key.
9
+ *
10
+ * @example
11
+ * const values: HostSettingValues = { "assistant.turn-limit": 16, "assistant.connector-tools": true };
12
+ */
13
+ export type HostSettingValues = Readonly<Record<string, HostSettingValue>>;
14
+ /**
15
+ * The most bytes every saved value may take together, as compact JSON of
16
+ * the values by key (`JSON.stringify(values)` in UTF-8), so long
17
+ * instructions fit and a runaway value doesn't.
18
+ */
19
+ export declare const hostSettingsMaxBytes: number;
20
+ /**
21
+ * Whether `key` can name a host setting: at most 64 characters, the section
22
+ * first, such as `assistant.turn-limit` or `sandbox.new-agents`. Adapters
23
+ * refuse any other key, so no key can be `__proto__` or hold a path.
24
+ *
25
+ * @example
26
+ * isHostSettingKey("assistant.turn-limit"); // true
27
+ * isHostSettingKey("turn-limit"); // false: no section
28
+ */
29
+ export declare function isHostSettingKey(key: string): boolean;
30
+ /**
31
+ * The settings kept where Halonic runs, for every workspace on that
32
+ * computer: the assistant and the sandbox default (`host`-scoped settings
33
+ * in Studio). They live in the user's profile, `settings/host.json` for the
34
+ * CLI, `serve` and the desktop app, memory for tests and the browser demo,
35
+ * and **never in a workspace file**. A provider key is never one of them,
36
+ * only its secret name.
37
+ *
38
+ * The port only stores JSON values by key. `HostSettings` in `core/app`
39
+ * gives each setting its schema and default, so a value that doesn't fit
40
+ * reads as the default. The saved settings are `{ "version": 1, "values":
41
+ * {…} }`; the contract suite's golden cases
42
+ * (`packages/testing/contracts/src/golden/host-settings-limits.json`) list
43
+ * the keys, sizes and saved shapes every adapter, the desktop shell's Rust
44
+ * side too, agrees on.
45
+ *
46
+ * - Saved settings that can't be parsed read as none saved, so every
47
+ * setting starts from its default. The first save over them keeps them
48
+ * first as a broken copy (`host.json.broken`, replacing an older one),
49
+ * so they can still be recovered.
50
+ * - A save keeps everything it doesn't change exactly as it is: other
51
+ * keys, keys `read` leaves out, and the fields and `version` of settings
52
+ * saved by a newer Halonic.
53
+ * - Saves through one store run one at a time, so two saves of different
54
+ * keys keep both, and so do two windows of the desktop app, which save
55
+ * through one process. Between processes (the CLI and the desktop app
56
+ * saving at the same moment) the last save wins.
57
+ * - Settings that can't be read at all (no permission, a link) make `read`
58
+ * throw, so Studio can say it couldn't load them.
59
+ */
60
+ export interface HostSettingsStore {
61
+ /** Every saved value by key; an empty object when none is saved or they can't be parsed. */
62
+ read(): Promise<HostSettingValues>;
63
+ /**
64
+ * Saves one key's value and leaves every other key as it is. A reader
65
+ * sees the settings from before the save or after it, never half of them.
66
+ *
67
+ * @throws RangeError when the key isn't one {@link isHostSettingKey} allows, a
68
+ * number isn't finite, or the settings would be over {@link hostSettingsMaxBytes};
69
+ * nothing is saved then
70
+ */
71
+ set(key: string, value: HostSettingValue): Promise<void>;
72
+ /**
73
+ * Removes one key and leaves every other key as it is. Removing a key
74
+ * that isn't saved is not an error, and a removal is never refused for
75
+ * size, even when the saved settings are already over
76
+ * {@link hostSettingsMaxBytes}.
77
+ *
78
+ * @throws RangeError when the key isn't one {@link isHostSettingKey} allows; nothing is saved then
79
+ */
80
+ remove(key: string): Promise<void>;
81
+ /**
82
+ * Calls `listener` after the saved settings may have changed, by this
83
+ * store or by anything else (another window, the CLI). It may call more
84
+ * than once for one change, and once for several, so the caller reads
85
+ * again and compares. It never calls after the returned stop function.
86
+ */
87
+ watch(listener: () => void): () => void;
88
+ }
89
+ /**
90
+ * The values in saved settings' text, leaving out any key
91
+ * {@link isHostSettingKey} refuses; `undefined` when the text can't be
92
+ * parsed as `{ "values": {…} }`. For adapters, which only read and write.
93
+ *
94
+ * @example
95
+ * readSavedHostSettings('{"version":1,"values":{"assistant.turn-limit":20}}'); // { "assistant.turn-limit": 20 }
96
+ * readSavedHostSettings('{"version":1,"values":{'); // undefined
97
+ */
98
+ export declare function readSavedHostSettings(text: string): HostSettingValues | undefined;
99
+ /** What an adapter writes for one save, from {@link changeSavedHostSettings}. */
100
+ export interface SavedHostSettingsChange {
101
+ /** The settings' new text. */
102
+ readonly text: string;
103
+ /** Whether the old text couldn't be parsed, so the adapter keeps it as a broken copy first. */
104
+ readonly broken: boolean;
105
+ }
106
+ /**
107
+ * The saved settings' text with one key saved, or removed when `value` is
108
+ * `undefined`, and everything else kept as it is. For adapters, which only
109
+ * read and write.
110
+ *
111
+ * @param text - the saved settings' text, `undefined` when none is saved
112
+ * @throws RangeError when the key isn't one {@link isHostSettingKey} allows, a
113
+ * number isn't finite, or a saved value would bring the values over
114
+ * {@link hostSettingsMaxBytes}; a removal is never refused for size
115
+ */
116
+ export declare function changeSavedHostSettings(text: string | undefined, key: string, value: HostSettingValue | undefined): SavedHostSettingsChange;
@@ -0,0 +1,106 @@
1
+ /** Version of the {@link HostSettingsStore} port. A breaking change bumps it and comes with an ADR. */
2
+ export const hostSettingsStoreVersion = 1;
3
+ /**
4
+ * The most bytes every saved value may take together, as compact JSON of
5
+ * the values by key (`JSON.stringify(values)` in UTF-8), so long
6
+ * instructions fit and a runaway value doesn't.
7
+ */
8
+ export const hostSettingsMaxBytes = 256 * 1024;
9
+ /** A key is two or more lowercase words joined by dots, each word letters and digits with single `-`. */
10
+ const keyPattern = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\.[a-z][a-z0-9]*(?:-[a-z0-9]+)*)+$/;
11
+ /**
12
+ * Whether `key` can name a host setting: at most 64 characters, the section
13
+ * first, such as `assistant.turn-limit` or `sandbox.new-agents`. Adapters
14
+ * refuse any other key, so no key can be `__proto__` or hold a path.
15
+ *
16
+ * @example
17
+ * isHostSettingKey("assistant.turn-limit"); // true
18
+ * isHostSettingKey("turn-limit"); // false: no section
19
+ */
20
+ export function isHostSettingKey(key) {
21
+ return key.length <= 64 && keyPattern.test(key);
22
+ }
23
+ /**
24
+ * The values in saved settings' text, leaving out any key
25
+ * {@link isHostSettingKey} refuses; `undefined` when the text can't be
26
+ * parsed as `{ "values": {…} }`. For adapters, which only read and write.
27
+ *
28
+ * @example
29
+ * readSavedHostSettings('{"version":1,"values":{"assistant.turn-limit":20}}'); // { "assistant.turn-limit": 20 }
30
+ * readSavedHostSettings('{"version":1,"values":{'); // undefined
31
+ */
32
+ export function readSavedHostSettings(text) {
33
+ const saved = parseSaved(text);
34
+ if (saved === undefined)
35
+ return undefined;
36
+ return Object.fromEntries(Object.entries(saved.values).filter(([key]) => isHostSettingKey(key)));
37
+ }
38
+ /**
39
+ * The saved settings' text with one key saved, or removed when `value` is
40
+ * `undefined`, and everything else kept as it is. For adapters, which only
41
+ * read and write.
42
+ *
43
+ * @param text - the saved settings' text, `undefined` when none is saved
44
+ * @throws RangeError when the key isn't one {@link isHostSettingKey} allows, a
45
+ * number isn't finite, or a saved value would bring the values over
46
+ * {@link hostSettingsMaxBytes}; a removal is never refused for size
47
+ */
48
+ export function changeSavedHostSettings(text, key, value) {
49
+ if (!isHostSettingKey(key)) {
50
+ throw new RangeError(`${JSON.stringify(key)} can't name a setting.`);
51
+ }
52
+ if (value !== undefined && !holdsOnlyFiniteNumbers(value)) {
53
+ throw new RangeError(`The value for ${key} has a number that isn't finite.`);
54
+ }
55
+ const saved = text === undefined ? undefined : parseSaved(text);
56
+ const values = { ...saved?.values };
57
+ if (value === undefined)
58
+ delete values[key];
59
+ else
60
+ values[key] = value;
61
+ // A removal is never refused for size, so settings already over it (saved
62
+ // by a newer Halonic, or edited by hand) can still be brought back under it.
63
+ if (value !== undefined && utf8Length(JSON.stringify(values)) > hostSettingsMaxBytes) {
64
+ throw new RangeError(`The settings would be over ${hostSettingsMaxBytes} bytes with ${key}.`);
65
+ }
66
+ return {
67
+ text: `${JSON.stringify({ version: 1, ...saved, values }, null, 2)}\n`,
68
+ broken: text !== undefined && saved === undefined,
69
+ };
70
+ }
71
+ function parseSaved(text) {
72
+ let parsed;
73
+ try {
74
+ parsed = JSON.parse(text);
75
+ }
76
+ catch {
77
+ return undefined;
78
+ }
79
+ return isObject(parsed) && isObject(parsed["values"]) ? parsed : undefined;
80
+ }
81
+ function isObject(value) {
82
+ return typeof value === "object" && value !== null && !Array.isArray(value);
83
+ }
84
+ /** `text`'s length in UTF-8 bytes. The core has no `TextEncoder`; JSON text has no lone surrogates. */
85
+ function utf8Length(text) {
86
+ let bytes = 0;
87
+ for (const character of text) {
88
+ const code = character.codePointAt(0) ?? 0;
89
+ if (code < 0x80)
90
+ bytes += 1;
91
+ else if (code < 0x800)
92
+ bytes += 2;
93
+ else if (code < 0x10000)
94
+ bytes += 3;
95
+ else
96
+ bytes += 4;
97
+ }
98
+ return bytes;
99
+ }
100
+ function holdsOnlyFiniteNumbers(value) {
101
+ if (typeof value === "number")
102
+ return Number.isFinite(value);
103
+ if (typeof value !== "object" || value === null)
104
+ return true;
105
+ return Object.values(value).every(holdsOnlyFiniteNumbers);
106
+ }