@zhivex-ai/harness 1.6.3 → 1.8.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 (391) hide show
  1. package/CHANGELOG.md +16 -3
  2. package/README.md +17 -5
  3. package/SECURITY.md +1 -1
  4. package/SUPPORT.md +2 -2
  5. package/benchmarks/README.md +98 -0
  6. package/contracts/engine-api.json +1587 -0
  7. package/contracts/public-api.json +114 -0
  8. package/contracts/stable-api-signatures.json +17 -17
  9. package/dist/acp-cli.js +37 -1090
  10. package/dist/application/agenda.d.ts +10 -0
  11. package/dist/application/approval-review.d.ts +61 -0
  12. package/dist/application/assistant/automation/scheduler.d.ts +21 -0
  13. package/dist/application/assistant/automation/summary.d.ts +29 -0
  14. package/dist/application/assistant/automation/time.d.ts +10 -0
  15. package/dist/application/assistant/calendar/calendar.d.ts +238 -0
  16. package/dist/application/assistant/calendar/connection.d.ts +50 -0
  17. package/dist/application/assistant/calendar/create-event.d.ts +75 -0
  18. package/dist/application/assistant/calendar/environment.d.ts +2 -0
  19. package/dist/application/assistant/calendar/http.d.ts +6 -0
  20. package/dist/application/assistant/calendar/oauth.d.ts +68 -0
  21. package/dist/application/assistant/calendar/store.d.ts +11 -0
  22. package/dist/application/assistant/calendar/tools.d.ts +78 -0
  23. package/dist/application/assistant/client.d.ts +10 -0
  24. package/dist/application/assistant/config.d.ts +9 -0
  25. package/dist/application/assistant/contracts.d.ts +77 -0
  26. package/dist/application/assistant/daily/service.d.ts +181 -0
  27. package/dist/application/assistant/doctor.d.ts +22 -0
  28. package/dist/application/assistant/evaluation.d.ts +81 -0
  29. package/dist/application/assistant/host.d.ts +399 -0
  30. package/dist/application/assistant/integrations/google.d.ts +117 -0
  31. package/dist/application/assistant/integrations/public-web.d.ts +16 -0
  32. package/dist/application/assistant/managed/secrets.d.ts +10 -0
  33. package/dist/application/assistant/managed/setup-state.d.ts +346 -0
  34. package/dist/application/assistant/managed/setup.d.ts +492 -0
  35. package/dist/application/assistant/microsoft/connection.d.ts +73 -0
  36. package/dist/application/assistant/microsoft/tools.d.ts +78 -0
  37. package/dist/application/assistant/modules/calendar.d.ts +3 -0
  38. package/dist/application/assistant/modules/catalog.d.ts +38 -0
  39. package/dist/application/assistant/modules/daily.d.ts +5 -0
  40. package/dist/application/assistant/modules/github.d.ts +5 -0
  41. package/dist/application/assistant/modules/google.d.ts +3 -0
  42. package/dist/application/assistant/modules/mcp.d.ts +11 -0
  43. package/dist/application/assistant/modules/microsoft.d.ts +3 -0
  44. package/dist/application/assistant/modules/module.d.ts +224 -0
  45. package/dist/application/assistant/modules/tools.d.ts +11 -0
  46. package/dist/application/assistant/modules/web.d.ts +7 -0
  47. package/dist/application/assistant/private-directory.d.ts +3 -0
  48. package/dist/application/assistant/proactive/service.d.ts +142 -0
  49. package/dist/application/assistant/providers/openai-compatible.d.ts +66 -0
  50. package/dist/application/assistant/providers/provider.d.ts +141 -0
  51. package/dist/application/assistant/providers/web-citations.d.ts +2 -0
  52. package/dist/application/assistant/runtime.d.ts +16 -0
  53. package/dist/application/assistant/task-metrics.d.ts +304 -0
  54. package/dist/application/assistant/telegram/api.d.ts +47 -0
  55. package/dist/application/assistant/telegram/bridge.d.ts +69 -0
  56. package/dist/application/assistant/telegram/store.d.ts +10 -0
  57. package/dist/application/automation.d.ts +5 -0
  58. package/dist/application/calendar-review.d.ts +5 -0
  59. package/dist/application/checkpoint-review.d.ts +30 -0
  60. package/dist/application/client.d.ts +18 -0
  61. package/dist/application/code/context.d.ts +5 -0
  62. package/dist/application/code/delivery.d.ts +6 -0
  63. package/dist/application/code/git-delivery.d.ts +54 -0
  64. package/dist/application/code/github-git-transport.d.ts +15 -0
  65. package/dist/application/code/github-pr-transport.d.ts +6 -0
  66. package/dist/application/code/host.d.ts +25 -0
  67. package/dist/application/code/pr-delivery.d.ts +79 -0
  68. package/dist/application/code/projects.d.ts +90 -0
  69. package/dist/application/code/remote-delivery.d.ts +80 -0
  70. package/dist/application/code/repository.d.ts +9 -0
  71. package/dist/application/code/worktrees.d.ts +123 -0
  72. package/dist/application/contracts.d.ts +288 -0
  73. package/dist/application/coordinator-client.d.ts +33 -0
  74. package/dist/application/coordinator-discovery.d.ts +17 -0
  75. package/dist/application/coordinator-launcher.d.ts +2 -0
  76. package/dist/application/coordinator.d.ts +27 -0
  77. package/dist/application/credential-process.d.ts +13 -0
  78. package/dist/application/host.d.ts +7 -0
  79. package/dist/application/management.d.ts +68 -0
  80. package/dist/application/notes.d.ts +5 -0
  81. package/dist/application/offline-migration.d.ts +16 -0
  82. package/dist/application/personal-state.d.ts +5 -0
  83. package/dist/application/review-channel.d.ts +23 -0
  84. package/dist/application/review-tickets.d.ts +29 -0
  85. package/dist/application/runtime-binding.d.ts +4 -0
  86. package/dist/application-cli-wfh08g41.js +184 -0
  87. package/dist/application-cli-z3f9pvcf.js +209 -0
  88. package/dist/arguments-75r85mvc.js +27 -0
  89. package/dist/arguments-x24bbqvd.js +22 -0
  90. package/dist/audit/index.js +16 -472
  91. package/dist/audit-pack-1gnych0m.js +93 -0
  92. package/dist/{audit-pack-s9n693by.js → audit-pack-h44kjkbj.js} +17 -11
  93. package/dist/calendar-2xw0rr7b.js +49 -0
  94. package/dist/cli/application-cli.d.ts +2 -0
  95. package/dist/cli/arguments.d.ts +14 -1
  96. package/dist/cli/auto-approve-setup.d.ts +13 -0
  97. package/dist/cli/configured-harness.d.ts +1 -2
  98. package/dist/cli/console/console-budget.d.ts +16 -2
  99. package/dist/cli/console/console-checkpoints.d.ts +12 -0
  100. package/dist/cli/console/console-commands.d.ts +3 -3
  101. package/dist/cli/console/console-compaction.d.ts +1 -1
  102. package/dist/cli/console/console-diff.d.ts +2 -0
  103. package/dist/cli/console/console-input.d.ts +29 -1
  104. package/dist/cli/console/console-navigation.d.ts +2 -2
  105. package/dist/cli/console/console-outcome.d.ts +10 -0
  106. package/dist/cli/console/console-presentation.d.ts +17 -2
  107. package/dist/cli/console/console-pricing.d.ts +14 -0
  108. package/dist/cli/console/console-reasoning.d.ts +1 -1
  109. package/dist/cli/console/console-recovery.d.ts +2 -0
  110. package/dist/cli/console/console-review.d.ts +34 -0
  111. package/dist/cli/console/console-run-policy.d.ts +5 -0
  112. package/dist/cli/console/console-run-view.d.ts +28 -0
  113. package/dist/cli/console/console-task.d.ts +30 -0
  114. package/dist/cli/console/console-welcome.d.ts +13 -3
  115. package/dist/cli/console/review-diff.d.ts +20 -0
  116. package/dist/cli/presentation.d.ts +8 -6
  117. package/dist/cli/service-checkpoints.d.ts +234 -0
  118. package/dist/cli/terminal/activity-history.d.ts +4 -2
  119. package/dist/cli/terminal/activity-stream.d.ts +33 -0
  120. package/dist/cli/terminal/file-diff.d.ts +11 -0
  121. package/dist/cli/terminal/terminal-theme.d.ts +9 -0
  122. package/dist/cli/terminal/terminal-ui.d.ts +44 -2
  123. package/dist/cli/terminal/tool-activity.d.ts +6 -2
  124. package/dist/{cli-entry-hdtfef27.js → cli-entry-68kqraj7.js} +95 -43
  125. package/dist/{cli-entry-1epvek01.js → cli-entry-86rcbmwh.js} +294 -14
  126. package/dist/cli-entry-btkpb4h1.js +3627 -0
  127. package/dist/cli-entry-bxjbs6qq.js +200 -0
  128. package/dist/cli-entry-cpm89r9q.js +624 -0
  129. package/dist/{cli-entry-mbcq96nx.js → cli-entry-dksm56sj.js} +39 -293
  130. package/dist/{cli-entry-rsx0wpvs.js → cli-entry-eka68ttb.js} +4087 -4625
  131. package/dist/cli-entry-h7dcah4p.js +137 -0
  132. package/dist/cli-entry-kwk23ktq.js +33 -0
  133. package/dist/{cli-entry-nyzyvf24.js → cli-entry-vmce694z.js} +1286 -3142
  134. package/dist/cli-entry-wanv05db.js +1113 -0
  135. package/dist/{cli-yxvq8qf1.js → cli-z7vhm1rk.js} +1767 -380
  136. package/dist/cli.js +8 -6
  137. package/dist/client/json-contracts.d.ts +153 -0
  138. package/dist/client/local-service.d.ts +7 -12
  139. package/dist/client/local-transport.d.ts +14 -0
  140. package/dist/client/protocol.d.ts +43 -1
  141. package/dist/compat/cli-options.d.ts +7 -1
  142. package/dist/compat/cli.d.ts +2 -0
  143. package/dist/compat/cli.js +4043 -0
  144. package/dist/compat/code-support.d.ts +4 -0
  145. package/dist/compat/code-support.js +50 -28
  146. package/dist/{config-r9fdhce6.js → config-hw78440t.js} +5 -5
  147. package/dist/{config-vyajmksy.js → config-v7s8hp37.js} +1 -1
  148. package/dist/context/adaptive-compaction.d.ts +1 -0
  149. package/dist/context/lossless-lines.d.ts +13 -0
  150. package/dist/context/numbered-read-lines.d.ts +15 -0
  151. package/dist/context/read-attempts.d.ts +21 -0
  152. package/dist/context/request-projection.d.ts +32 -4
  153. package/dist/context/scoped-context.d.ts +31 -5
  154. package/dist/context/working-read-replay.d.ts +12 -0
  155. package/dist/coordinator-client-nzysqxf0.js +10 -0
  156. package/dist/engine/acp.js +27 -21
  157. package/dist/engine/application-client.d.ts +11 -0
  158. package/dist/engine/application-client.js +18 -0
  159. package/dist/engine/application-protocol.d.ts +5 -0
  160. package/dist/engine/application-protocol.js +7 -0
  161. package/dist/engine/application.d.ts +43 -0
  162. package/dist/engine/application.js +206 -0
  163. package/dist/engine/assistant/automation/scheduler.d.ts +2 -0
  164. package/dist/engine/assistant/automation/scheduler.js +11 -0
  165. package/dist/engine/assistant/automation/summary.d.ts +3 -0
  166. package/dist/engine/assistant/automation/summary.js +8 -0
  167. package/dist/engine/assistant/automation/time.d.ts +5 -0
  168. package/dist/engine/assistant/automation/time.js +15 -0
  169. package/dist/engine/assistant/calendar/calendar.d.ts +5 -0
  170. package/dist/engine/assistant/calendar/calendar.js +12 -0
  171. package/dist/engine/assistant/calendar/connection.d.ts +2 -0
  172. package/dist/engine/assistant/calendar/connection.js +11 -0
  173. package/dist/engine/assistant/calendar/environment.d.ts +1 -0
  174. package/dist/engine/assistant/calendar/environment.js +7 -0
  175. package/dist/engine/assistant/calendar/http.d.ts +3 -0
  176. package/dist/engine/assistant/calendar/http.js +9 -0
  177. package/dist/engine/assistant/calendar/oauth.d.ts +5 -0
  178. package/dist/engine/assistant/calendar/oauth.js +12 -0
  179. package/dist/engine/assistant/calendar/store.d.ts +2 -0
  180. package/dist/engine/assistant/calendar/store.js +8 -0
  181. package/dist/engine/assistant/calendar/tools.d.ts +2 -0
  182. package/dist/engine/assistant/calendar/tools.js +46 -0
  183. package/dist/engine/assistant/client.d.ts +2 -0
  184. package/dist/engine/assistant/client.js +33 -0
  185. package/dist/engine/assistant/config.d.ts +1 -0
  186. package/dist/engine/assistant/config.js +102 -0
  187. package/dist/engine/assistant/contracts.d.ts +10 -0
  188. package/dist/engine/assistant/contracts.js +78 -0
  189. package/dist/engine/assistant/daily/service.d.ts +12 -0
  190. package/dist/engine/assistant/daily/service.js +27 -0
  191. package/dist/engine/assistant/doctor.d.ts +1 -0
  192. package/dist/engine/assistant/doctor.js +116 -0
  193. package/dist/engine/assistant/evaluation.d.ts +2 -0
  194. package/dist/engine/assistant/evaluation.js +76 -0
  195. package/dist/engine/assistant/host.d.ts +2 -0
  196. package/dist/engine/assistant/host.js +63 -0
  197. package/dist/engine/assistant/integrations/google.d.ts +9 -0
  198. package/dist/engine/assistant/integrations/google.js +30 -0
  199. package/dist/engine/assistant/integrations/public-web.d.ts +3 -0
  200. package/dist/engine/assistant/integrations/public-web.js +11 -0
  201. package/dist/engine/assistant/managed/secrets.d.ts +1 -0
  202. package/dist/engine/assistant/managed/secrets.js +0 -0
  203. package/dist/engine/assistant/managed/setup-state.d.ts +11 -0
  204. package/dist/engine/assistant/managed/setup-state.js +84 -0
  205. package/dist/engine/assistant/managed/setup.d.ts +3 -0
  206. package/dist/engine/assistant/managed/setup.js +85 -0
  207. package/dist/engine/assistant/microsoft/connection.d.ts +7 -0
  208. package/dist/engine/assistant/microsoft/connection.js +21 -0
  209. package/dist/engine/assistant/microsoft/tools.d.ts +8 -0
  210. package/dist/engine/assistant/microsoft/tools.js +30 -0
  211. package/dist/engine/assistant/modules/calendar.d.ts +1 -0
  212. package/dist/engine/assistant/modules/calendar.js +49 -0
  213. package/dist/engine/assistant/modules/catalog.d.ts +3 -0
  214. package/dist/engine/assistant/modules/catalog.js +67 -0
  215. package/dist/engine/assistant/modules/daily.d.ts +1 -0
  216. package/dist/engine/assistant/modules/daily.js +48 -0
  217. package/dist/engine/assistant/modules/github.d.ts +1 -0
  218. package/dist/engine/assistant/modules/github.js +43 -0
  219. package/dist/engine/assistant/modules/google.d.ts +1 -0
  220. package/dist/engine/assistant/modules/google.js +53 -0
  221. package/dist/engine/assistant/modules/mcp.d.ts +1 -0
  222. package/dist/engine/assistant/modules/mcp.js +42 -0
  223. package/dist/engine/assistant/modules/microsoft.d.ts +1 -0
  224. package/dist/engine/assistant/modules/microsoft.js +53 -0
  225. package/dist/engine/assistant/modules/module.d.ts +5 -0
  226. package/dist/engine/assistant/modules/module.js +42 -0
  227. package/dist/engine/assistant/modules/tools.d.ts +2 -0
  228. package/dist/engine/assistant/modules/tools.js +42 -0
  229. package/dist/engine/assistant/modules/web.d.ts +1 -0
  230. package/dist/engine/assistant/modules/web.js +45 -0
  231. package/dist/engine/assistant/private-directory.d.ts +1 -0
  232. package/dist/engine/assistant/private-directory.js +7 -0
  233. package/dist/engine/assistant/proactive/service.d.ts +6 -0
  234. package/dist/engine/assistant/proactive/service.js +16 -0
  235. package/dist/engine/assistant/providers/openai-compatible.d.ts +4 -0
  236. package/dist/engine/assistant/providers/openai-compatible.js +12 -0
  237. package/dist/engine/assistant/providers/provider.d.ts +7 -0
  238. package/dist/engine/assistant/providers/provider.js +54 -0
  239. package/dist/engine/assistant/providers/web-citations.d.ts +1 -0
  240. package/dist/engine/assistant/providers/web-citations.js +7 -0
  241. package/dist/engine/assistant/runtime.d.ts +2 -0
  242. package/dist/engine/assistant/runtime.js +73 -0
  243. package/dist/engine/assistant/task-metrics.d.ts +8 -0
  244. package/dist/engine/assistant/task-metrics.js +17 -0
  245. package/dist/engine/assistant/telegram/api.d.ts +5 -0
  246. package/dist/engine/assistant/telegram/api.js +11 -0
  247. package/dist/engine/assistant/telegram/bridge.d.ts +2 -0
  248. package/dist/engine/assistant/telegram/bridge.js +40 -0
  249. package/dist/engine/assistant/telegram/store.d.ts +2 -0
  250. package/dist/engine/assistant/telegram/store.js +8 -0
  251. package/dist/engine/client.js +26 -18
  252. package/dist/engine/desktop-providers-v1.js +4 -4
  253. package/dist/engine/desktop-state-v1.js +16 -13
  254. package/dist/engine/index.d.ts +4 -0
  255. package/dist/engine/index.js +117 -159
  256. package/dist/engine/mcp-stdio-v1.js +13 -12
  257. package/dist/engine/models.js +65 -23
  258. package/dist/engine/protocol.js +10 -6
  259. package/dist/engine/service.js +32 -21
  260. package/dist/hostile-repository-demo.js +2329 -1096
  261. package/dist/index-09rsdr2d.js +1744 -0
  262. package/dist/index-0csc5sc7.js +139 -0
  263. package/dist/{index-4mn6m3bq.js → index-0dkty795.js} +8 -6
  264. package/dist/index-0kkgqvg7.js +0 -0
  265. package/dist/index-0mzz9axm.js +58 -0
  266. package/dist/index-1e69ar8r.js +38 -0
  267. package/dist/index-1z0xhkh9.js +18 -0
  268. package/dist/index-2cef1k92.js +356 -0
  269. package/dist/{index-rgqzdgv6.js → index-2j0v1xwr.js} +17 -13
  270. package/dist/index-2jw9jd7h.js +116 -0
  271. package/dist/index-2n9qx4km.js +0 -0
  272. package/dist/index-3rvk23e8.js +877 -0
  273. package/dist/index-3wa4j0yk.js +71 -0
  274. package/dist/index-41q1k17x.js +210 -0
  275. package/dist/index-4vz4bqqw.js +33 -0
  276. package/dist/index-5jxm2wy5.js +123 -0
  277. package/dist/index-5rk6ss42.js +216 -0
  278. package/dist/index-5v1skxf7.js +1852 -0
  279. package/dist/{index-fqqz1yt8.js → index-6ehtssyz.js} +369 -335
  280. package/dist/index-76kpdbpw.js +80 -0
  281. package/dist/{index-5nmm0642.js → index-7nbmhmw5.js} +10 -10
  282. package/dist/index-8mx0yrkz.js +31 -0
  283. package/dist/index-8tjev5ds.js +11 -0
  284. package/dist/index-91n5wr6s.js +163 -0
  285. package/dist/index-91trs3ew.js +151 -0
  286. package/dist/index-9y8p5vy5.js +222 -0
  287. package/dist/index-abxahprd.js +55 -0
  288. package/dist/index-aptyr511.js +84 -0
  289. package/dist/{index-8sm2a1wa.js → index-ay26xfxt.js} +28 -20
  290. package/dist/index-b4yed1s3.js +657 -0
  291. package/dist/index-bb7phvtg.js +23 -0
  292. package/dist/index-bk5tn9b8.js +236 -0
  293. package/dist/index-bw34861c.js +292 -0
  294. package/dist/index-c6fnjhgv.js +55 -0
  295. package/dist/{index-qfsrrnz6.js → index-cjevq9s8.js} +2 -2
  296. package/dist/{index-c39197wq.js → index-ctcwrkrc.js} +4 -4
  297. package/dist/{index-yx52bt4a.js → index-cztmcesv.js} +2 -2
  298. package/dist/index-dpbmxnrf.js +564 -0
  299. package/dist/index-ekxdcy36.js +134 -0
  300. package/dist/index-f8zpcsx3.js +289 -0
  301. package/dist/{index-6dxrbnxm.js → index-f970qtb4.js} +7 -143
  302. package/dist/index-fatcn6fp.js +2791 -0
  303. package/dist/index-fbzykqxy.js +105 -0
  304. package/dist/{index-1265j7t2.js → index-fwf274vc.js} +24 -14
  305. package/dist/index-fy4w0a7v.js +0 -0
  306. package/dist/index-gvva3e5x.js +76 -0
  307. package/dist/index-h7dcah4p.js +137 -0
  308. package/dist/index-hm9r120s.js +42 -0
  309. package/dist/index-j3d2tw97.js +328 -0
  310. package/dist/index-jfqj20x8.js +41 -0
  311. package/dist/{index-hhrnrqfc.js → index-k529a278.js} +6 -6
  312. package/dist/{index-bt2p8x7r.js → index-kbrf5bx7.js} +110 -106
  313. package/dist/index-kwk23ktq.js +33 -0
  314. package/dist/index-kz857p1j.js +557 -0
  315. package/dist/{index-j466sekf.js → index-mkt5yrax.js} +31 -105
  316. package/dist/{index-nxmk6re7.js → index-ndgnvjez.js} +18 -18
  317. package/dist/index-nemn4epv.js +43 -0
  318. package/dist/index-nkwy5bjr.js +1225 -0
  319. package/dist/index-nvvzr4ny.js +136 -0
  320. package/dist/index-pkspzsfs.js +78 -0
  321. package/dist/{index-fm84men1.js → index-px1tnqgt.js} +2 -2
  322. package/dist/index-q7qdw883.js +79 -0
  323. package/dist/{index-mzydbzp8.js → index-qvbg6tx1.js} +65 -23
  324. package/dist/index-r3mwr5fb.js +0 -0
  325. package/dist/index-rdr78m0k.js +91 -0
  326. package/dist/index-rtamqsfs.js +59 -0
  327. package/dist/index-s125ss45.js +38 -0
  328. package/dist/{index-vn91b9z1.js → index-sx1t6dnd.js} +3721 -2382
  329. package/dist/index-tar0ngkm.js +359 -0
  330. package/dist/index-tn58cr6w.js +471 -0
  331. package/dist/{index-w0m1nckc.js → index-v79s9bf9.js} +118 -45
  332. package/dist/index-vk3rq21m.js +17 -0
  333. package/dist/index-vmvnr28y.js +72 -0
  334. package/dist/index-vz629cg8.js +49 -0
  335. package/dist/{index-eps3c3g6.js → index-w292hdpz.js} +197 -960
  336. package/dist/{index-amjttjaj.js → index-w9eqg6p9.js} +24 -302
  337. package/dist/index-wj96kdw2.js +57 -0
  338. package/dist/index-wyck5yhd.js +141 -0
  339. package/dist/index-xvtk8pxs.js +674 -0
  340. package/dist/{index-bpc596v3.js → index-xwb691v9.js} +2 -2
  341. package/dist/index-ym69x168.js +518 -0
  342. package/dist/index-yprdjk9v.js +65 -0
  343. package/dist/index-z2a81ccr.js +35 -0
  344. package/dist/{index-3ah1f369.js → index-z69cqk74.js} +3 -3
  345. package/dist/index-zaakvmzq.js +62 -0
  346. package/dist/index-zk3m4mzg.js +232 -0
  347. package/dist/index-zx3wgvx4.js +218 -0
  348. package/dist/index.js +102 -83
  349. package/dist/persistence/migration-guard.d.ts +3 -0
  350. package/dist/runtime/agent-profile.d.ts +12 -0
  351. package/dist/runtime/harness.d.ts +13 -0
  352. package/dist/runtime/known-file-preload.d.ts +35 -0
  353. package/dist/service-cli.js +130 -40
  354. package/dist/service-client-cli-2rzxy5mj.js +1166 -0
  355. package/dist/service-client-cli-5ne8q5ej.js +543 -0
  356. package/dist/tools/ooxml-zip.d.ts +21 -0
  357. package/dist/tools/presentations.d.ts +47 -0
  358. package/dist/tools/tabular-data.d.ts +114 -0
  359. package/dist/tools/workspace.d.ts +76 -0
  360. package/dist/verify-historical-migrations.js +2249 -1016
  361. package/dist/workspace/workspace.d.ts +13 -1
  362. package/dist/zhx.js +8 -6
  363. package/docs/APPLICATION_MIGRATION.md +32 -0
  364. package/docs/CLI.md +166 -2
  365. package/docs/CODE_RELEASE.md +11 -5
  366. package/docs/CODE_WEB_TASKS.md +3 -114
  367. package/docs/CONTEXT_ENGINEERING.md +93 -0
  368. package/docs/ENGINE_API.md +9 -2
  369. package/docs/EXTENSIBILITY.md +1 -1
  370. package/docs/FIRST_USE.md +6 -6
  371. package/docs/INTERNAL_ARCHIVE.md +43 -0
  372. package/docs/LOCAL_SERVICE.md +1 -1
  373. package/docs/MODEL_CATALOG.md +14 -0
  374. package/docs/PROJECT_MEMORY.md +1 -1
  375. package/docs/README.md +23 -4
  376. package/evaluations/representative-assembly-matrix.json +19 -1
  377. package/examples/README.md +4 -4
  378. package/examples/assistant/compatible-calendar.json +17 -0
  379. package/examples/assistant/composed-modules.json +23 -0
  380. package/examples/assistant/connected-tools.json +9 -0
  381. package/examples/assistant/daily-tools.json +6 -0
  382. package/examples/assistant/offline.mjs +24 -0
  383. package/fixtures/cli-compatibility/README.md +10 -0
  384. package/fixtures/cli-compatibility/inventory.json +7858 -0
  385. package/package.json +232 -26
  386. package/dist/cli/console/console-model-catalog.d.ts +0 -8
  387. package/dist/index-2yyfg69h.js +0 -619
  388. package/dist/index-3wwfn5n6.js +0 -270
  389. package/dist/index-4gt045j0.js +0 -288
  390. package/dist/index-4jw3tvy8.js +0 -301
  391. package/dist/service-client-cli-xbj7j5kj.js +0 -1251
package/dist/acp-cli.js CHANGED
@@ -1,1102 +1,49 @@
1
1
  #!/usr/bin/env node
2
- import"./index-4jw3tvy8.js";
3
2
  import {
4
- CLI_OPTION_DEFINITIONS,
5
- parseHarnessModelRoute,
6
- resolveHarnessModelRoutes,
7
- validateCliCommandOptions
8
- } from "./index-8sm2a1wa.js";
3
+ createConfiguredHarness
4
+ } from "./index-09rsdr2d.js";
5
+ import {
6
+ applyCliProfile,
7
+ parseCliArgs
8
+ } from "./index-nkwy5bjr.js";
9
+ import"./index-2n9qx4km.js";
10
+ import"./index-3rvk23e8.js";
11
+ import"./index-0kkgqvg7.js";
12
+ import"./index-dpbmxnrf.js";
13
+ import"./index-cjevq9s8.js";
9
14
  import {
10
15
  serveAcpStdio
11
- } from "./index-3ah1f369.js";
16
+ } from "./index-z69cqk74.js";
12
17
  import {
13
18
  createHarnessClientAdapter
14
- } from "./index-j466sekf.js";
15
- import"./index-4mn6m3bq.js";
16
- import {
17
- createHarness
18
- } from "./index-vn91b9z1.js";
19
- import"./index-amjttjaj.js";
20
- import"./index-hhrnrqfc.js";
21
- import"./index-w0m1nckc.js";
22
- import {
23
- HARNESS_REQUIRED_CAPABILITIES,
24
- HARNESS_SUBAGENT_PROFILES,
25
- PROVIDERS,
26
- createProviderModel,
27
- parseProvider,
28
- providerDescriptor,
29
- reasoningEffortSchema,
30
- resolveHarnessConfig
31
- } from "./index-1265j7t2.js";
32
- import"./index-c39197wq.js";
33
- import"./index-mzydbzp8.js";
34
- import"./index-bt2p8x7r.js";
35
- import {
36
- usagePricingSchema
37
- } from "./index-fqqz1yt8.js";
38
- import"./index-3wwfn5n6.js";
39
- import {
40
- FileChangedWhileReadingError,
41
- FileSizeLimitError,
42
- UnsafeFileTypeError,
43
- readRegularFileNoFollow
44
- } from "./index-6dxrbnxm.js";
45
- import"./index-4gt045j0.js";
46
- import {
47
- HarnessConfigError,
48
- HarnessError
49
- } from "./index-bpc596v3.js";
50
- import"./index-fm84men1.js";
51
- import {
52
- __require
53
- } from "./index-1bx83sw4.js";
19
+ } from "./index-mkt5yrax.js";
20
+ import"./index-ay26xfxt.js";
21
+ import"./index-1z0xhkh9.js";
22
+ import"./index-q7qdw883.js";
23
+ import"./index-0dkty795.js";
24
+ import"./index-sx1t6dnd.js";
25
+ import"./index-k529a278.js";
26
+ import"./index-bw34861c.js";
27
+ import"./index-w9eqg6p9.js";
28
+ import"./index-v79s9bf9.js";
29
+ import"./index-fwf274vc.js";
30
+ import"./index-ctcwrkrc.js";
31
+ import"./index-qvbg6tx1.js";
32
+ import"./index-kbrf5bx7.js";
33
+ import"./index-kwk23ktq.js";
34
+ import"./index-6ehtssyz.js";
35
+ import"./index-f970qtb4.js";
36
+ import"./index-h7dcah4p.js";
37
+ import"./index-rdr78m0k.js";
38
+ import"./index-5jxm2wy5.js";
39
+ import"./index-xwb691v9.js";
40
+ import"./index-px1tnqgt.js";
41
+ import"./index-76kpdbpw.js";
42
+ import"./index-1bx83sw4.js";
54
43
 
55
- // src/acp-cli.ts
44
+ // packages/core/src/acp-cli.ts
56
45
  import { realpathSync } from "node:fs";
57
46
  import { fileURLToPath } from "node:url";
58
-
59
- // src/cli/cli-help.ts
60
- var usage = {
61
- "memory:remember": 'zhx memory remember "content" [--source "provenance"]',
62
- "memory:suggest": 'zhx memory suggest "content" [--source "provenance"]',
63
- "memory:list": "zhx memory list",
64
- "memory:read": "zhx memory read <id>",
65
- "memory:update": 'zhx memory update <id> <revision> "content" [--source "provenance"]',
66
- "memory:forget": "zhx memory forget <id> <revision>",
67
- "memory:accept": "zhx memory accept <id> <reviewedRevision>",
68
- "memory:clear": "zhx memory clear",
69
- "memory:enable": "zhx memory enable",
70
- "memory:disable": "zhx memory disable",
71
- "memory:context": 'zhx memory context "query"',
72
- "checkpoints:storage": "zhx checkpoints storage",
73
- "checkpoints:prune-review": "zhx checkpoints prune-review <checkpoint:id|restore:id> [...]",
74
- "checkpoints:prune-apply": "zhx checkpoints prune-apply <reviewedPlanId> <checkpoint:id|restore:id> [...]",
75
- "checkpoints:list": "zhx checkpoints list <sessionId>",
76
- "checkpoints:capture": "zhx checkpoints capture <sessionId> <turnId> <path> [paths...]",
77
- "checkpoints:inspect": "zhx checkpoints inspect <checkpointId>",
78
- "checkpoints:prepare": "zhx checkpoints prepare <checkpointId>",
79
- "checkpoints:review": "zhx checkpoints review <operationId>",
80
- "checkpoints:apply": "zhx checkpoints apply <operationId> <reviewedProposalId>",
81
- "checkpoints:recover": "zhx checkpoints recover <operationId> <existingForkSessionId>",
82
- init: "zhx init [--provider <id>] [--model <id>] [--profile <name>] [--update]",
83
- run: 'zhx run [options] "task" | zhx run [options] -',
84
- review: 'zhx review [options] "review task" | zhx review [options] -',
85
- chat: "zhx [--continue | --session <id>]",
86
- providers: "zhx providers [--json]",
87
- policy: "zhx policy [options] [--json]",
88
- doctor: "zhx doctor [options]",
89
- resume: "zhx resume <runId> --approve|--deny",
90
- "runs:list": "zhx runs list [options]",
91
- "runs:inspect": "zhx runs inspect <runId>",
92
- "runs:cancel": "zhx runs cancel <runId> [options]",
93
- "runs:cleanup": "zhx runs cleanup --before <date> [options]",
94
- "runs:export": "zhx runs export <runId>",
95
- "runs:report": "zhx runs report <runId> [envelope.json] [--session <sessionId>] [--json]",
96
- "sessions:list": "zhx sessions list [--search <text>]",
97
- "sessions:inspect": "zhx sessions inspect <sessionId>",
98
- "sessions:rename": 'zhx sessions rename <sessionId> "title"',
99
- "sessions:fork": "zhx sessions fork <sessionId>",
100
- "sessions:archive": "zhx sessions archive <sessionId>",
101
- "changes:create": "zhx changes create <input.json> --patch <artifact>",
102
- "changes:verify": "zhx changes verify <envelope.json> --patch <artifact> [options]",
103
- "state:status": "zhx state status",
104
- "state:export": "zhx state export <backup.json>",
105
- "state:import": "zhx state import <backup.json> [--apply]",
106
- "export-audit": "zhx export-audit <task-id> --out <directory> [--session <sessionId>]",
107
- "verify-audit": "zhx verify-audit --out <directory>",
108
- version: "zhx --version"
109
- };
110
- function resolveHelpTopic(parts, explicit) {
111
- if (!explicit || !parts.length)
112
- return;
113
- const topic = parts.join(":");
114
- if (topic === "all" || Object.hasOwn(usage, topic) || Object.keys(usage).some((key) => key.startsWith(`${topic}:`)))
115
- return topic;
116
- throw new Error(`Unknown help topic: ${parts.join(" ")}. Use zhx help all.`);
117
- }
118
-
119
- // src/cli/arguments.ts
120
- import { z as z2 } from "zod";
121
-
122
- // src/cli/cli-profiles.ts
123
- import { lstat, mkdir, open, unlink, rename } from "node:fs/promises";
124
- import os from "node:os";
125
- import path from "node:path";
126
- import { z } from "zod";
127
- var CLI_PROFILE_SCHEMA_VERSION = 1;
128
- var CLI_PROFILE_CONFIG_DIRECTORY_ENV = "ZHIVEX_HARNESS_CONFIG_DIR";
129
- var MAX_CLI_PROFILE_BYTES = 16 * 1024;
130
- var profileNamePattern = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
131
- var cliProfileSchema = z.strictObject({
132
- schemaVersion: z.literal(CLI_PROFILE_SCHEMA_VERSION),
133
- provider: z.enum(PROVIDERS),
134
- reasoningEffort: reasoningEffortSchema.optional(),
135
- model: z.string().min(1).max(512).refine((value) => !/[\u0000-\u001f\u007f]/.test(value), "model must contain printable characters")
136
- });
137
- var absoluteDirectory = (value, source, pathApi = path) => {
138
- if (!pathApi.isAbsolute(value)) {
139
- throw new HarnessConfigError(`${source} must be an absolute path.`);
140
- }
141
- return pathApi.normalize(value);
142
- };
143
- var validateCliProfileName = (name) => {
144
- if (!profileNamePattern.test(name)) {
145
- throw new HarnessConfigError("Profile names must use 1-64 letters, digits, dot, underscore, or hyphen and start with a letter or digit.");
146
- }
147
- return name;
148
- };
149
- var resolveCliProfileConfigDirectory = (context = {}) => {
150
- const env = context.env ?? process.env;
151
- const platform = context.platform ?? process.platform;
152
- const homeDirectory = context.homeDirectory ?? os.homedir();
153
- const pathApi = platform === "win32" ? path.win32 : path;
154
- const override = env[CLI_PROFILE_CONFIG_DIRECTORY_ENV]?.trim();
155
- if (override) {
156
- return absoluteDirectory(override, CLI_PROFILE_CONFIG_DIRECTORY_ENV, pathApi);
157
- }
158
- if (platform === "darwin") {
159
- return pathApi.join(homeDirectory, "Library", "Application Support", "zhivex-harness");
160
- }
161
- if (platform === "win32") {
162
- const appData = env.APPDATA?.trim();
163
- if (!appData) {
164
- throw new HarnessConfigError(`APPDATA is required to locate Zhivex Harness profiles on ${platform}.`);
165
- }
166
- return pathApi.join(absoluteDirectory(appData, "APPDATA", pathApi), "zhivex-harness");
167
- }
168
- const xdgConfigHome = env.XDG_CONFIG_HOME?.trim();
169
- const configHome = xdgConfigHome ? absoluteDirectory(xdgConfigHome, "XDG_CONFIG_HOME", pathApi) : pathApi.join(homeDirectory, ".config");
170
- return pathApi.join(configHome, "zhivex-harness");
171
- };
172
- var resolveCliProfilePath = (name, context = {}) => path.join(resolveCliProfileConfigDirectory(context), "profiles", `${validateCliProfileName(name)}.json`);
173
- var validatePrivateDirectory = async (directory) => {
174
- const directoryStat = await lstat(directory);
175
- if (!directoryStat.isDirectory() || directoryStat.isSymbolicLink()) {
176
- throw new HarnessConfigError(`CLI profile directory must be a real directory: ${directory}`);
177
- }
178
- if ((directoryStat.mode & 18) !== 0) {
179
- throw new HarnessConfigError(`CLI profile directory must not be writable by group or others: ${directory}`);
180
- }
181
- };
182
- var profileReadError = (profilePath, error) => {
183
- if (error instanceof UnsafeFileTypeError) {
184
- throw new HarnessConfigError(`CLI profile must be a regular non-linked file: ${profilePath}`);
185
- }
186
- if (error instanceof FileSizeLimitError) {
187
- throw new HarnessConfigError(`CLI profile exceeds the ${MAX_CLI_PROFILE_BYTES}-byte limit: ${profilePath}`);
188
- }
189
- if (error instanceof FileChangedWhileReadingError) {
190
- throw new HarnessConfigError(`CLI profile changed while it was being read: ${profilePath}`);
191
- }
192
- const code = error && typeof error === "object" && "code" in error ? error.code : undefined;
193
- if (code === "ENOENT") {
194
- throw new HarnessConfigError(`CLI profile was not found: ${profilePath}. Create it with zhx init --profile <name>.`);
195
- }
196
- throw error;
197
- };
198
- var loadCliProfile = async (name, context = {}) => {
199
- const profilePath = resolveCliProfilePath(name, context);
200
- let file;
201
- try {
202
- await validatePrivateDirectory(resolveCliProfileConfigDirectory(context));
203
- await validatePrivateDirectory(path.dirname(profilePath));
204
- file = await readRegularFileNoFollow(profilePath, {
205
- label: `CLI profile ${name}`,
206
- maxBytes: MAX_CLI_PROFILE_BYTES,
207
- requireSingleLink: true
208
- });
209
- } catch (error) {
210
- return profileReadError(profilePath, error);
211
- }
212
- if ((file.stat.mode & 63) !== 0) {
213
- throw new HarnessConfigError(`CLI profile permissions are too broad; expected owner-only access: ${profilePath}`);
214
- }
215
- let document;
216
- try {
217
- document = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(file.contents));
218
- } catch {
219
- throw new HarnessConfigError(`CLI profile is not valid UTF-8 JSON: ${profilePath}`);
220
- }
221
- const parsed = cliProfileSchema.safeParse(document);
222
- if (!parsed.success) {
223
- throw new HarnessConfigError(`CLI profile is invalid: ${parsed.error.issues[0]?.message ?? "schema mismatch"}`);
224
- }
225
- return parsed.data;
226
- };
227
- var applyCliProfile = async (options, context = {}) => {
228
- if (!options.profile)
229
- return options;
230
- const profile = await loadCliProfile(options.profile, context);
231
- return {
232
- provider: profile.provider,
233
- model: profile.model,
234
- ...profile.reasoningEffort && (!options.provider || options.provider === profile.provider) && (!options.model || options.model === profile.model) ? { reasoningEffort: profile.reasoningEffort } : {},
235
- ...options
236
- };
237
- };
238
-
239
- // src/cli/arguments.ts
240
- var CLI_COMMANDS = ["init", "run", "review", "chat", "providers", "doctor", "policy", "resume", "runs", "sessions", "checkpoints", "changes", "state", "memory", "export-audit", "verify-audit", "help", "version"];
241
- var CLI_RUNS_COMMANDS = ["list", "inspect", "cancel", "cleanup", "export", "report"];
242
- var CLI_SESSIONS_COMMANDS = ["list", "inspect", "rename", "fork", "archive"];
243
- var CLI_CHANGES_COMMANDS = ["create", "verify"];
244
- var CLI_STATE_COMMANDS = ["status", "export", "import"];
245
- var COMMANDS = new Set(CLI_COMMANDS);
246
- var RUNS_COMMANDS = new Set(CLI_RUNS_COMMANDS);
247
- var SESSIONS_COMMANDS = new Set(CLI_SESSIONS_COMMANDS);
248
- var CHANGES_COMMANDS = new Set(CLI_CHANGES_COMMANDS);
249
- var STATE_COMMANDS = new Set(CLI_STATE_COMMANDS);
250
- var CLI_TIMESTAMP_SCHEMA = z2.iso.datetime({ precision: 3 });
251
- var RUN_STATUSES = new Set([
252
- "queued",
253
- "running",
254
- "completed",
255
- "suspended",
256
- "waiting_approval",
257
- "cancel_requested",
258
- "failed",
259
- "cancelled",
260
- "timed_out"
261
- ]);
262
-
263
- class CliUsageError extends HarnessError {
264
- constructor(message) {
265
- super(message, { code: "CLI_USAGE_INVALID", category: "usage" });
266
- this.name = "CliUsageError";
267
- }
268
- }
269
- var optionValue = (argv, index, name) => {
270
- const value = argv[index + 1];
271
- if (!value || value.startsWith("-")) {
272
- throw new CliUsageError(`Missing value for ${name}.`);
273
- }
274
- return value;
275
- };
276
- var parseCliArgs = (argv) => {
277
- const booleanOptions = new Set(["--token-budget", "--no-token-budget", "--yes", "--approve", "--deny", "--json", "--jsonl", "--continue", "--cascade", "--final", "--apply", "--help", "--version", "--no-project-context", "--no-memory", "--update"]);
278
- const separator = argv.indexOf("--");
279
- argv = argv.flatMap((arg, index) => {
280
- const equals = arg.indexOf("=");
281
- const name = arg.slice(0, equals);
282
- return (separator < 0 || index < separator) && equals > 0 && name in CLI_OPTION_DEFINITIONS && !booleanOptions.has(name) ? [name, arg.slice(equals + 1)] : [arg];
283
- });
284
- let command = "run";
285
- let commandWasExplicit = false;
286
- const positional = [];
287
- const options = {
288
- command,
289
- cascade: false,
290
- final: false,
291
- apply: false,
292
- yes: false,
293
- json: false,
294
- jsonl: false,
295
- continueSession: false,
296
- implicitCommand: true
297
- };
298
- let positionalOnly = false;
299
- const optionCounts = new Map;
300
- const helpIndex = argv.findIndex((arg, index) => (arg === "--help" || arg === "-h") && (argv.indexOf("--") < 0 || index < argv.indexOf("--")));
301
- if (helpIndex >= 0) {
302
- const words = [];
303
- for (let index = 0;index < argv.length && argv[index] !== "--"; index++) {
304
- const arg = argv[index];
305
- if (arg.startsWith("-")) {
306
- if (arg in CLI_OPTION_DEFINITIONS && !booleanOptions.has(arg) && argv[index + 1] && !argv[index + 1].startsWith("-"))
307
- index++;
308
- } else
309
- words.push(arg);
310
- }
311
- const first = words[0];
312
- const parts = first === "help" ? words.slice(1) : first && COMMANDS.has(first) ? words.slice(0, ["runs", "sessions", "checkpoints", "changes", "state", "memory"].includes(first) ? 2 : 1) : [];
313
- try {
314
- const topic = resolveHelpTopic(parts, parts.length > 0);
315
- return { ...options, command: "help", ...topic ? { helpTopic: topic } : {} };
316
- } catch (error) {
317
- throw new CliUsageError(error instanceof Error ? error.message : String(error));
318
- }
319
- }
320
- for (let index = 0;index < argv.length; index += 1) {
321
- const argument = argv[index];
322
- if (!argument) {
323
- continue;
324
- }
325
- if (positionalOnly) {
326
- positional.push(argument);
327
- continue;
328
- }
329
- if (argument === "--") {
330
- positionalOnly = true;
331
- continue;
332
- }
333
- const canonicalOption = argument === "-h" ? "--help" : argument === "-v" ? "--version" : argument;
334
- if (canonicalOption in CLI_OPTION_DEFINITIONS) {
335
- optionCounts.set(canonicalOption, (optionCounts.get(canonicalOption) ?? 0) + 1);
336
- }
337
- if (!commandWasExplicit && COMMANDS.has(argument)) {
338
- command = argument;
339
- options.command = command;
340
- commandWasExplicit = true;
341
- continue;
342
- }
343
- switch (argument) {
344
- case "--no-memory":
345
- options.projectMemory = false;
346
- break;
347
- case "--source":
348
- options.memorySource = optionValue(argv, index, argument);
349
- index += 1;
350
- break;
351
- case "--update":
352
- options.updateProfile = true;
353
- break;
354
- case "-":
355
- positional.push(argument);
356
- break;
357
- case "--profile":
358
- try {
359
- options.profile = validateCliProfileName(optionValue(argv, index, argument));
360
- } catch (error) {
361
- throw new CliUsageError(error instanceof Error ? error.message : String(error));
362
- }
363
- index += 1;
364
- break;
365
- case "--provider":
366
- try {
367
- options.provider = parseProvider(optionValue(argv, index, argument));
368
- } catch (error) {
369
- throw new CliUsageError(error instanceof Error ? error.message : String(error));
370
- }
371
- index += 1;
372
- break;
373
- case "--model":
374
- options.model = optionValue(argv, index, argument);
375
- index += 1;
376
- break;
377
- case "--route": {
378
- const value = optionValue(argv, index, argument);
379
- try {
380
- parseHarnessModelRoute(value);
381
- } catch (error) {
382
- throw new CliUsageError(error instanceof Error ? error.message : String(error));
383
- }
384
- options.routes ??= [];
385
- options.routes.push(value);
386
- if (options.routes.length > HARNESS_SUBAGENT_PROFILES.length) {
387
- throw new CliUsageError(`--route cannot be repeated more than ${HARNESS_SUBAGENT_PROFILES.length} times.`);
388
- }
389
- index += 1;
390
- break;
391
- }
392
- case "--workspace":
393
- options.workspace = optionValue(argv, index, argument);
394
- index += 1;
395
- break;
396
- case "--state-dir":
397
- options.stateDirectory = optionValue(argv, index, argument);
398
- index += 1;
399
- break;
400
- case "--mcp-config":
401
- options.mcpConfigPath = optionValue(argv, index, argument);
402
- index += 1;
403
- break;
404
- case "--tool-policy":
405
- options.toolPolicyFile = optionValue(argv, index, argument);
406
- index += 1;
407
- break;
408
- case "--context-config":
409
- options.contextConfigPath = optionValue(argv, index, argument);
410
- index += 1;
411
- break;
412
- case "--token-budget":
413
- options.unlimitedTokens = false;
414
- break;
415
- case "--no-token-budget":
416
- options.unlimitedTokens = true;
417
- break;
418
- case "--no-project-context":
419
- options.projectContext = false;
420
- break;
421
- case "--patch":
422
- options.patchPath = optionValue(argv, index, argument);
423
- index += 1;
424
- break;
425
- case "--preconditions":
426
- options.preconditionsPath = optionValue(argv, index, argument);
427
- index += 1;
428
- break;
429
- case "--now": {
430
- const value = optionValue(argv, index, argument);
431
- if (!CLI_TIMESTAMP_SCHEMA.safeParse(value).success) {
432
- throw new CliUsageError("--now must be a millisecond-precision ISO-8601 UTC timestamp.");
433
- }
434
- options.verificationTime = value;
435
- index += 1;
436
- break;
437
- }
438
- case "--reasoning":
439
- options.reasoningEffort = reasoningEffortSchema.parse(optionValue(argv, index, argument));
440
- index += 1;
441
- break;
442
- case "--require-verified-delivery":
443
- options.requireVerifiedDelivery = true;
444
- break;
445
- case "--execution":
446
- options.executionBackend = optionValue(argv, index, argument);
447
- index += 1;
448
- break;
449
- case "--oci-runtime":
450
- options.ociRuntime = optionValue(argv, index, argument);
451
- index += 1;
452
- break;
453
- case "--oci-image":
454
- options.ociImage = optionValue(argv, index, argument);
455
- index += 1;
456
- break;
457
- case "--oci-allow-command": {
458
- const value = optionValue(argv, index, argument);
459
- if (!/^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/.test(value)) {
460
- throw new CliUsageError("--oci-allow-command requires a bare executable name.");
461
- }
462
- options.ociAllowedCommands ??= [];
463
- options.ociAllowedCommands.push(value);
464
- index += 1;
465
- break;
466
- }
467
- case "--oci-shell":
468
- options.ociShellMode = optionValue(argv, index, argument);
469
- if (!["deny", "ask"].includes(options.ociShellMode)) {
470
- throw new CliUsageError("--oci-shell must be deny or ask.");
471
- }
472
- index += 1;
473
- break;
474
- case "--store":
475
- options.storeBackend = optionValue(argv, index, argument);
476
- index += 1;
477
- break;
478
- case "--tenant":
479
- options.tenantId = optionValue(argv, index, argument);
480
- index += 1;
481
- break;
482
- case "--user":
483
- options.userId = optionValue(argv, index, argument);
484
- index += 1;
485
- break;
486
- case "--namespace":
487
- options.namespace = optionValue(argv, index, argument);
488
- index += 1;
489
- break;
490
- case "--idempotency-key":
491
- options.idempotencyKey = optionValue(argv, index, argument);
492
- if (options.idempotencyKey.length > 256) {
493
- throw new CliUsageError("--idempotency-key cannot exceed 256 characters.");
494
- }
495
- index += 1;
496
- break;
497
- case "--max-steps": {
498
- const value = optionValue(argv, index, argument);
499
- options.maxSteps = Number(value);
500
- if (!Number.isSafeInteger(options.maxSteps) || options.maxSteps < 1) {
501
- throw new CliUsageError("--max-steps must be a positive safe integer.");
502
- }
503
- index += 1;
504
- break;
505
- }
506
- case "--timeout-ms":
507
- case "--max-tool-calls":
508
- case "--max-tool-errors":
509
- case "--context-tokens":
510
- case "--max-input-tokens":
511
- case "--max-output-tokens":
512
- case "--max-total-tokens":
513
- case "--subagent-max-steps":
514
- case "--subagent-max-tool-calls":
515
- case "--subagent-max-tool-errors":
516
- case "--subagent-max-input-tokens":
517
- case "--subagent-max-output-tokens":
518
- case "--subagent-max-total-tokens":
519
- case "--subagent-timeout-ms":
520
- case "--max-parallel-reviews": {
521
- const value = Number(optionValue(argv, index, argument));
522
- if (!Number.isSafeInteger(value) || value < 0) {
523
- throw new CliUsageError(`${argument} must be a non-negative integer.`);
524
- }
525
- if (argument === "--timeout-ms")
526
- options.timeoutMs = value;
527
- if (argument === "--max-tool-calls")
528
- options.maxToolCalls = value;
529
- if (argument === "--max-tool-errors")
530
- options.maxToolErrors = value;
531
- if (argument === "--context-tokens")
532
- options.compactionMaxEstimatedInputTokens = value;
533
- if (argument === "--max-input-tokens")
534
- options.maxInputTokens = value;
535
- if (argument === "--max-output-tokens")
536
- options.maxOutputTokens = value;
537
- if (argument === "--max-total-tokens")
538
- options.maxTotalTokens = value;
539
- if (argument === "--subagent-max-steps")
540
- options.subagentMaxSteps = value;
541
- if (argument === "--subagent-max-tool-calls")
542
- options.subagentMaxToolCalls = value;
543
- if (argument === "--subagent-max-tool-errors")
544
- options.subagentMaxToolErrors = value;
545
- if (argument === "--subagent-max-input-tokens")
546
- options.subagentMaxInputTokens = value;
547
- if (argument === "--subagent-max-output-tokens")
548
- options.subagentMaxOutputTokens = value;
549
- if (argument === "--subagent-max-total-tokens")
550
- options.subagentMaxTotalTokens = value;
551
- if (argument === "--subagent-timeout-ms")
552
- options.subagentTimeoutMs = value;
553
- if (argument === "--max-parallel-reviews")
554
- options.maxParallelReviews = value;
555
- index += 1;
556
- break;
557
- }
558
- case "--oci-max-process-runtime-ms":
559
- case "--oci-max-process-output-bytes":
560
- case "--oci-max-memory-mb":
561
- case "--oci-max-pids":
562
- case "--oci-max-cpus":
563
- case "--oci-max-workspace-bytes":
564
- case "--oci-max-file-write-bytes":
565
- case "--oci-tmpfs-mb": {
566
- const value = Number(optionValue(argv, index, argument));
567
- if (!Number.isSafeInteger(value) || value < 1) {
568
- throw new CliUsageError(`${argument} must be a positive integer.`);
569
- }
570
- if (argument === "--oci-max-process-runtime-ms")
571
- options.ociMaxProcessRuntimeMs = value;
572
- if (argument === "--oci-max-process-output-bytes")
573
- options.ociMaxProcessOutputBytes = value;
574
- if (argument === "--oci-max-memory-mb")
575
- options.ociMaxMemoryMb = value;
576
- if (argument === "--oci-max-pids")
577
- options.ociMaxPids = value;
578
- if (argument === "--oci-max-cpus")
579
- options.ociMaxCpus = value;
580
- if (argument === "--oci-max-workspace-bytes")
581
- options.ociMaxWorkspaceBytes = value;
582
- if (argument === "--oci-max-file-write-bytes")
583
- options.ociMaxFileWriteBytes = value;
584
- if (argument === "--oci-tmpfs-mb")
585
- options.ociTmpfsMb = value;
586
- index += 1;
587
- break;
588
- }
589
- case "--search":
590
- options.sessionSearch = optionValue(argv, index, argument);
591
- index += 1;
592
- break;
593
- case "--pricing-file":
594
- options.pricingFile = optionValue(argv, index, argument);
595
- index += 1;
596
- break;
597
- case "--compaction-model":
598
- options.compactionModel = optionValue(argv, index, argument);
599
- index += 1;
600
- break;
601
- case "--compaction-provider":
602
- options.compactionProvider = parseProvider(optionValue(argv, index, argument));
603
- index += 1;
604
- break;
605
- case "--usage-limit-usd": {
606
- const value = Number(optionValue(argv, index, argument));
607
- if (!Number.isFinite(value) || value <= 0)
608
- throw new CliUsageError("--usage-limit-usd must be positive USD.");
609
- options.usageLimitUsd = value;
610
- index += 1;
611
- break;
612
- }
613
- case "--max-cost-usd":
614
- case "--input-cost-per-million":
615
- case "--output-cost-per-million": {
616
- const value = Number(optionValue(argv, index, argument));
617
- if (!Number.isFinite(value) || value < 0) {
618
- throw new CliUsageError(`${argument} must be a non-negative number.`);
619
- }
620
- if (argument === "--max-cost-usd")
621
- options.maxCostUsd = value;
622
- if (argument === "--input-cost-per-million")
623
- options.inputCostPerMillion = value;
624
- if (argument === "--output-cost-per-million")
625
- options.outputCostPerMillion = value;
626
- index += 1;
627
- break;
628
- }
629
- case "--allow-check": {
630
- const value = optionValue(argv, index, argument);
631
- if (!/^[A-Za-z0-9][A-Za-z0-9:_-]{0,63}$/.test(value)) {
632
- throw new CliUsageError("--allow-check must use 1-64 letters, digits, colon, underscore, or hyphen.");
633
- }
634
- options.allowedChecks ??= [];
635
- options.allowedChecks.push(value);
636
- if (options.allowedChecks.length > 50) {
637
- throw new CliUsageError("--allow-check cannot be repeated more than 50 times.");
638
- }
639
- index += 1;
640
- break;
641
- }
642
- case "--require-capability": {
643
- const value = optionValue(argv, index, argument);
644
- if (!HARNESS_REQUIRED_CAPABILITIES.includes(value)) {
645
- throw new CliUsageError(`--require-capability must be one of: ${HARNESS_REQUIRED_CAPABILITIES.join(", ")}.`);
646
- }
647
- options.requiredCapabilities ??= [];
648
- options.requiredCapabilities.push(value);
649
- index += 1;
650
- break;
651
- }
652
- case "--subagent": {
653
- const value = optionValue(argv, index, argument);
654
- if (!HARNESS_SUBAGENT_PROFILES.includes(value)) {
655
- throw new CliUsageError(`--subagent must be one of: ${HARNESS_SUBAGENT_PROFILES.join(", ")}.`);
656
- }
657
- options.subagentProfiles ??= [];
658
- options.subagentProfiles.push(value);
659
- index += 1;
660
- break;
661
- }
662
- case "--reviewer": {
663
- const value = optionValue(argv, index, argument);
664
- if (value !== "explorer" && value !== "reviewer") {
665
- throw new CliUsageError("--reviewer must be explorer or reviewer.");
666
- }
667
- options.reviewers ??= [];
668
- options.reviewers.push(value);
669
- index += 1;
670
- break;
671
- }
672
- case "--approval-mode": {
673
- const mode = optionValue(argv, index, argument);
674
- if (mode !== "ask" && mode !== "auto" && mode !== "restricted")
675
- throw new CliUsageError("--approval-mode must be ask, auto or restricted.");
676
- options.approvalMode = mode;
677
- options.yes = mode === "auto";
678
- index += 1;
679
- break;
680
- }
681
- case "--yes":
682
- options.yes = true;
683
- break;
684
- case "--approve":
685
- if (options.approve === false) {
686
- throw new CliUsageError("You cannot combine --approve and --deny.");
687
- }
688
- options.approve = true;
689
- break;
690
- case "--deny":
691
- if (options.approve === true) {
692
- throw new CliUsageError("You cannot combine --approve and --deny.");
693
- }
694
- options.approve = false;
695
- break;
696
- case "--json":
697
- options.json = true;
698
- break;
699
- case "--jsonl":
700
- options.jsonl = true;
701
- break;
702
- case "--service":
703
- options.serviceFile = optionValue(argv, index, argument);
704
- index += 1;
705
- break;
706
- case "--session":
707
- options.sessionId = optionValue(argv, index, argument);
708
- index += 1;
709
- break;
710
- case "--continue":
711
- options.continueSession = true;
712
- break;
713
- case "--status": {
714
- const value = optionValue(argv, index, argument);
715
- if (!RUN_STATUSES.has(value)) {
716
- throw new CliUsageError(`Unsupported run status: ${value}.`);
717
- }
718
- options.statuses ??= [];
719
- options.statuses.push(value);
720
- index += 1;
721
- break;
722
- }
723
- case "--limit": {
724
- const value = Number(optionValue(argv, index, argument));
725
- if (!Number.isSafeInteger(value) || value < 1 || value > 1000) {
726
- throw new CliUsageError("--limit must be an integer between 1 and 1000.");
727
- }
728
- options.limit = value;
729
- index += 1;
730
- break;
731
- }
732
- case "--cursor":
733
- options.cursor = optionValue(argv, index, argument);
734
- index += 1;
735
- break;
736
- case "--before": {
737
- const value = optionValue(argv, index, argument);
738
- const timestamp = /^\d+$/.test(value) ? Number(value) : Date.parse(value);
739
- if (!Number.isFinite(timestamp) || timestamp < 0) {
740
- throw new CliUsageError("--before must be an ISO-8601 date or millisecond timestamp.");
741
- }
742
- options.before = timestamp;
743
- index += 1;
744
- break;
745
- }
746
- case "--reason":
747
- options.reason = optionValue(argv, index, argument);
748
- if (options.reason.length > 500) {
749
- throw new CliUsageError("--reason cannot exceed 500 characters.");
750
- }
751
- index += 1;
752
- break;
753
- case "--cascade":
754
- options.cascade = true;
755
- break;
756
- case "--final":
757
- options.final = true;
758
- break;
759
- case "--apply":
760
- options.apply = true;
761
- break;
762
- case "--help":
763
- case "-h":
764
- options.command = "help";
765
- break;
766
- case "--version":
767
- case "-v":
768
- options.command = "version";
769
- break;
770
- case "--out":
771
- options.auditOut = optionValue(argv, index, argument);
772
- index += 1;
773
- break;
774
- case "--signing-key-file":
775
- options.signingKeyFile = optionValue(argv, index, argument);
776
- index += 1;
777
- break;
778
- default:
779
- if (argument.startsWith("-")) {
780
- throw new CliUsageError(`Unknown option: ${argument}`);
781
- }
782
- positional.push(argument);
783
- }
784
- }
785
- if (options.command === "help") {
786
- try {
787
- validateCliCommandOptions("help", optionCounts);
788
- const topic = resolveHelpTopic(command === "help" ? positional : [command, ...positional], commandWasExplicit);
789
- if (topic)
790
- options.helpTopic = topic;
791
- } catch (error) {
792
- throw new CliUsageError(error instanceof Error ? error.message : String(error));
793
- }
794
- return options;
795
- }
796
- options.implicitCommand = !commandWasExplicit;
797
- if (options.json && options.jsonl) {
798
- throw new CliUsageError("You cannot combine --json and --jsonl.");
799
- }
800
- if (options.sessionId && options.continueSession) {
801
- throw new CliUsageError("You cannot combine --session and --continue.");
802
- }
803
- if (options.jsonl && options.command !== "run" && options.command !== "resume") {
804
- throw new CliUsageError("--jsonl is supported by run and resume.");
805
- }
806
- if (options.command !== "changes" && (options.patchPath || options.preconditionsPath || options.verificationTime)) {
807
- throw new CliUsageError("--patch, --preconditions, and --now are supported only by changes.");
808
- }
809
- if (options.command === "resume") {
810
- const runId = positional.shift();
811
- if (runId) {
812
- options.runId = runId;
813
- }
814
- if (positional.length > 0) {
815
- throw new CliUsageError("resume accepts exactly one runId.");
816
- }
817
- } else if (options.command === "runs") {
818
- const runsCommand = positional.shift();
819
- if (!runsCommand || !RUNS_COMMANDS.has(runsCommand)) {
820
- throw new CliUsageError("runs requires one of: list, inspect, cancel, cleanup, export, report.");
821
- }
822
- options.runsCommand = runsCommand;
823
- if (runsCommand === "inspect" || runsCommand === "cancel" || runsCommand === "export" || runsCommand === "report") {
824
- const runId = positional.shift();
825
- if (!runId) {
826
- throw new CliUsageError(`runs ${runsCommand} requires a runId.`);
827
- }
828
- options.runId = runId;
829
- }
830
- if (runsCommand === "report" && positional.length)
831
- options.reportEnvelopePath = positional.shift();
832
- if (positional.length > 0) {
833
- throw new CliUsageError(`runs ${runsCommand} received unexpected positional arguments.`);
834
- }
835
- } else if (options.command === "sessions") {
836
- const sessionsCommand = positional.shift();
837
- if (!sessionsCommand || !SESSIONS_COMMANDS.has(sessionsCommand)) {
838
- throw new CliUsageError("sessions requires one of: list, inspect, rename, fork, archive.");
839
- }
840
- options.sessionsCommand = sessionsCommand;
841
- if (sessionsCommand !== "list") {
842
- const sessionId = positional.shift();
843
- if (!sessionId)
844
- throw new CliUsageError(`sessions ${sessionsCommand} requires a sessionId.`);
845
- options.sessionId = sessionId;
846
- }
847
- if (sessionsCommand === "rename") {
848
- const title = positional.join(" ").trim();
849
- if (!title)
850
- throw new CliUsageError("sessions rename requires a title.");
851
- options.sessionTitle = title;
852
- positional.length = 0;
853
- }
854
- if (positional.length > 0) {
855
- throw new CliUsageError(`sessions ${sessionsCommand} received unexpected positional arguments.`);
856
- }
857
- } else if (options.command === "checkpoints") {
858
- const command2 = positional.shift();
859
- const counts = { list: [1, 1], capture: [3, 22], inspect: [1, 1], prepare: [1, 1], review: [1, 1], apply: [2, 2], recover: [2, 2], storage: [0, 0], "prune-review": [1, 100], "prune-apply": [2, 101] };
860
- if (!command2 || !Object.hasOwn(counts, command2))
861
- throw new CliUsageError("checkpoints requires list, capture, inspect, prepare, review, apply, recover, storage, prune-review or prune-apply.");
862
- const [min, max] = counts[command2];
863
- if (positional.length < min || positional.length > max)
864
- throw new CliUsageError(`Invalid arguments for checkpoints ${command2}; use --help.`);
865
- options.checkpointsCommand = command2;
866
- options.checkpointArguments = positional.splice(0);
867
- } else if (options.command === "changes") {
868
- const changesCommand = positional.shift();
869
- if (!changesCommand || !CHANGES_COMMANDS.has(changesCommand)) {
870
- throw new CliUsageError("changes requires one of: create, verify.");
871
- }
872
- options.changesCommand = changesCommand;
873
- const artifactPath = positional.shift();
874
- if (!artifactPath) {
875
- throw new CliUsageError(`changes ${changesCommand} requires an input JSON file.`);
876
- }
877
- options.artifactPath = artifactPath;
878
- if (changesCommand === "create" && (options.preconditionsPath || options.verificationTime)) {
879
- throw new CliUsageError("--preconditions and --now are only supported by changes verify.");
880
- }
881
- if (positional.length > 0) {
882
- throw new CliUsageError(`changes ${changesCommand} received unexpected positional arguments.`);
883
- }
884
- } else if (options.command === "memory") {
885
- const subcommand = positional.shift();
886
- const counts = { remember: 1, list: 0, read: 1, update: 3, forget: 2, suggest: 1, accept: 2, clear: 0, enable: 0, disable: 0, context: 1 };
887
- if (!subcommand || !Object.hasOwn(counts, subcommand) || positional.length !== counts[subcommand])
888
- throw new CliUsageError("Invalid memory arguments. Use memory --help; quote content as one argument.");
889
- options.memoryCommand = subcommand;
890
- options.memoryArguments = positional.splice(0);
891
- } else if (options.command === "state") {
892
- const stateCommand = positional.shift();
893
- if (!stateCommand || !STATE_COMMANDS.has(stateCommand)) {
894
- throw new CliUsageError("state requires one of: status, export, import.");
895
- }
896
- options.stateCommand = stateCommand;
897
- if (stateCommand !== "status") {
898
- const backupPath = positional.shift();
899
- if (!backupPath)
900
- throw new CliUsageError(`state ${stateCommand} requires a backup JSON path.`);
901
- options.backupPath = backupPath;
902
- }
903
- if (positional.length > 0) {
904
- throw new CliUsageError(`state ${stateCommand} received unexpected positional arguments.`);
905
- }
906
- } else if (options.command === "export-audit" || options.command === "verify-audit") {
907
- const allowed = new Set(["--workspace", "--state-dir", "--store", "--tenant", "--user", "--namespace", "--json", ...options.command === "export-audit" ? ["--session"] : []]);
908
- for (const name of optionCounts.keys()) {
909
- if (!allowed.has(name))
910
- throw new CliUsageError(`${name} is not supported by ${options.command}.`);
911
- }
912
- if (!options.auditOut)
913
- throw new CliUsageError(`${options.command} requires --out <path>.`);
914
- if (options.command === "export-audit") {
915
- const taskId = positional.shift();
916
- if (!taskId)
917
- throw new CliUsageError("export-audit requires a task id.");
918
- options.runId = taskId;
919
- }
920
- if (positional.length > 0)
921
- throw new CliUsageError(`${options.command} received unexpected positional arguments.`);
922
- return options;
923
- } else if (options.command === "run" || options.command === "review") {
924
- if (positional.includes("-") && positional.length !== 1) {
925
- throw new CliUsageError("Use - alone to read the task from stdin, or provide a task argument.");
926
- }
927
- const prompt = positional.join(" ").trim();
928
- if (prompt) {
929
- options.prompt = prompt;
930
- }
931
- } else if (positional.length > 0) {
932
- throw new CliUsageError(`${options.command} does not accept positional arguments.`);
933
- }
934
- if (options.auditOut || options.signingKeyFile) {
935
- throw new CliUsageError("--out and --signing-key-file are supported only by export-audit and verify-audit.");
936
- }
937
- if (options.implicitCommand && options.command === "run" && !options.prompt && (options.continueSession || options.sessionId) && !options.json && !options.jsonl)
938
- options.command = "chat";
939
- if (options.serviceFile) {
940
- const allowed = new Set(["--service", "--session", "--idempotency-key", "--yes", "--json", "--jsonl", "--approve", "--deny", "--search", "--continue"]);
941
- for (const arg of optionCounts.keys())
942
- if (arg.startsWith("--") && !allowed.has(arg))
943
- throw new CliUsageError(`Service mode does not accept ${arg}; runtime configuration belongs to the service host.`);
944
- } else if (["run", "resume"].includes(options.command) && optionCounts.has("--session")) {
945
- throw new CliUsageError("--session for run/resume requires --service.");
946
- }
947
- const commandKey = options.command === "checkpoints" ? `checkpoints:${options.checkpointsCommand}` : options.command === "runs" ? `runs:${options.runsCommand}` : options.command === "sessions" ? `sessions:${options.sessionsCommand}` : options.command === "changes" ? `changes:${options.changesCommand}` : options.command === "memory" ? `memory:${options.memoryCommand}` : options.command === "state" ? `state:${options.stateCommand}` : options.command;
948
- try {
949
- validateCliCommandOptions(commandKey, optionCounts);
950
- } catch (error) {
951
- throw new CliUsageError(error instanceof Error ? error.message : String(error));
952
- }
953
- if (options.command === "review") {
954
- const invalidRoute = options.routes?.map((route) => parseHarnessModelRoute(route)).find((route) => route.profile !== "explorer" && route.profile !== "reviewer");
955
- if (invalidRoute) {
956
- throw new CliUsageError(`review cannot route the unused ${invalidRoute.profile} profile; use explorer or reviewer.`);
957
- }
958
- }
959
- return options;
960
- };
961
-
962
- // src/cli/cli-credentials.ts
963
- async function credentialModel(config, env, modelFactory) {
964
- const { createProviderModel: createProviderModel2 } = await import("./config-r9fdhce6.js");
965
- const { wrapLanguageModel } = await import("@zhivex-ai/core");
966
- const secrets = providerDescriptor(config.provider).credentialNames.map((name) => env[name]).filter((value) => !!value);
967
- const safeError = (error) => {
968
- let message = error instanceof Error ? error.message : "Provider request failed.";
969
- for (const secret of secrets)
970
- message = message.split(secret).join("[REDACTED]");
971
- const safe = new Error(message);
972
- if (error instanceof Error && error.name === "AbortError")
973
- safe.name = "AbortError";
974
- return safe;
975
- };
976
- const model = (modelFactory ?? createProviderModel2)(config, env);
977
- return wrapLanguageModel(model, [{
978
- name: "cli-credential-errors",
979
- wrapGenerate: async (_context, next) => {
980
- try {
981
- return await next();
982
- } catch (error) {
983
- throw safeError(error);
984
- }
985
- },
986
- wrapStream: async (_context, next) => {
987
- let events;
988
- try {
989
- events = await next();
990
- } catch (error) {
991
- throw safeError(error);
992
- }
993
- return async function* () {
994
- try {
995
- for await (const event of events) {
996
- if (event.type === "error")
997
- throw safeError(event.error);
998
- yield event;
999
- }
1000
- } catch (error) {
1001
- throw safeError(error);
1002
- }
1003
- }();
1004
- }
1005
- }]);
1006
- }
1007
-
1008
- // src/cli/configured-harness.ts
1009
- import path2 from "node:path";
1010
-
1011
- // src/cli/routing.ts
1012
- var resolvedRouting = (options) => {
1013
- return resolveHarnessModelRoutes(options.routes);
1014
- };
1015
- var assertRoutePricingIsSafe = (routes, costBudget) => {
1016
- if (routes.size > 0 && costBudget !== undefined) {
1017
- throw new CliUsageError("Cost budgets cannot be combined with model routes until pricing is configured per role.");
1018
- }
1019
- };
1020
- // src/cli/terminal/terminal-table.ts
1021
- var segments = new Intl.Segmenter(undefined, { granularity: "grapheme" });
1022
-
1023
- // src/cli/presentation.ts
1024
- import {
1025
- createRedactionPolicy
1026
- } from "@zhivex-ai/agents";
1027
- var CLI_STREAM_ERROR_SEQUENCE = Symbol("cliStreamErrorSequence");
1028
- var terminalErrorRedaction = createRedactionPolicy({ includeEmails: true });
1029
- var proseLineOpen = new WeakSet;
1030
- var conversationStarted = new WeakSet;
1031
- var toolActivities = new WeakMap;
1032
- var lastTerminalFailures = new WeakMap;
1033
- var orchestrationObserver = (json) => async (event) => {
1034
- if (json)
1035
- return;
1036
- if (event.type === "subagent-start") {
1037
- process.stderr.write(`
1038
- subagent start · ${event.childAgentId ?? event.toolName}
1039
- `);
1040
- } else if (event.type === "subagent-finish") {
1041
- process.stderr.write(`
1042
- subagent finish · ${event.childRun.agentId ?? event.childRun.toolName} · ${event.childRun.status}
1043
- `);
1044
- }
1045
- };
1046
-
1047
- // src/cli/configured-harness.ts
1048
- var createConfiguredHarness = async (options, extraProfiles = [], persistedRoutes, credentials) => {
1049
- const routes = persistedRoutes ?? resolvedRouting(options);
1050
- const resolvedConfig = resolveHarnessConfig(options);
1051
- if (options.usageLimitUsd !== undefined && resolvedConfig.costBudget)
1052
- throw new CliUsageError("Choose one monetary policy: --usage-limit-usd or the legacy cost budget.");
1053
- assertRoutePricingIsSafe(routes, resolvedConfig.costBudget);
1054
- const profiles = [...new Set([
1055
- ...options.subagentProfiles ?? [],
1056
- ...extraProfiles,
1057
- ...routes.keys()
1058
- ])];
1059
- const quietTelemetry = options.json || options.jsonl;
1060
- const providerEnv = credentials ? await credentials.store.providerEnvironment(resolvedConfig.provider, credentials.input) : undefined;
1061
- const transportEnv = { ...process.env };
1062
- const bindTransport = (env) => {
1063
- for (const name of ["QWEN_BASE_URL", "QWEN_REGION", "QWEN_WORKSPACE_ID"]) {
1064
- if (env[name] === undefined)
1065
- delete transportEnv[name];
1066
- else
1067
- transportEnv[name] = env[name];
1068
- }
1069
- };
1070
- if (providerEnv && resolvedConfig.provider === "qwen")
1071
- bindTransport(providerEnv);
1072
- const routeModels = {};
1073
- for (const [role, route] of routes) {
1074
- const routeEnv = credentials ? await credentials.store.providerEnvironment(route.provider, credentials.input) : process.env;
1075
- if (route.provider === "qwen")
1076
- bindTransport(routeEnv);
1077
- routeModels[role] = credentials ? await credentialModel(route, routeEnv) : createProviderModel(route, routeEnv);
1078
- }
1079
- const compactionEnv = resolvedConfig.compaction.model && credentials ? await credentials.store.providerEnvironment(resolvedConfig.compaction.model.provider, credentials.input) : undefined;
1080
- if (compactionEnv && resolvedConfig.compaction.model?.provider === "qwen")
1081
- bindTransport(compactionEnv);
1082
- const compactionModelInstance = resolvedConfig.compaction.model && compactionEnv ? await credentialModel(resolvedConfig.compaction.model, compactionEnv) : undefined;
1083
- const harness = await createHarness({
1084
- ...options,
1085
- ...{ projectMemory: options.projectMemory ?? true },
1086
- usageAccounting: {
1087
- ...options.pricingFile ? { pricing: usagePricingSchema.parse(JSON.parse((await readRegularFileNoFollow(path2.resolve(options.pricingFile), { maxBytes: 128 * 1024, label: "Usage pricing" })).contents.toString("utf8"))) } : {},
1088
- ...options.usageLimitUsd !== undefined ? { limitUsd: options.usageLimitUsd } : {}
1089
- },
1090
- subagentProfiles: profiles,
1091
- subagentModels: routeModels,
1092
- ...compactionModelInstance ? { compactionModelInstance } : {},
1093
- ...providerEnv ? { env: transportEnv, modelInstance: await credentialModel(resolvedConfig, providerEnv) } : {},
1094
- onTelemetryEvent: orchestrationObserver(quietTelemetry)
1095
- });
1096
- return { harness, routes };
1097
- };
1098
-
1099
- // src/acp-cli.ts
1100
47
  var acpMain = async (argv = process.argv.slice(2)) => {
1101
48
  if (argv.includes("--help") || argv.includes("-h")) {
1102
49
  process.stderr.write(`Usage: zhx-acp --workspace /absolute/project --provider openai --model MODEL