@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
@@ -0,0 +1,17 @@
1
+ /** Launch a persistent service only when discovery finds no live endpoint; the manager lease resolves races. */
2
+ export declare function ensureApplicationCoordinator(directory: string, launcher: {
3
+ executable: string;
4
+ entry: string;
5
+ }): Promise<{
6
+ call: <T = unknown>(method: import("./contracts.js").CoordinatorMethod | 'hello', input?: unknown) => Promise<T>;
7
+ protocol: {
8
+ version: 1;
9
+ projectionVersion?: 1 | undefined;
10
+ activityVersion?: 1 | undefined;
11
+ generation?: string | undefined;
12
+ capabilities: string[];
13
+ };
14
+ capabilities: string[];
15
+ catalog: () => Promise<import("./contracts.js").ApplicationCatalogSnapshot>;
16
+ state: () => Promise<import("./coordinator-client.js").CoordinatorSnapshot>;
17
+ }>;
@@ -0,0 +1,2 @@
1
+ /** Node launcher adapter; the core receives secrets through the same injected interface as Electron. */
2
+ export declare function launchApplicationCoordinator(directory: string): Promise<void>;
@@ -0,0 +1,27 @@
1
+ import type { ApplicationCatalogSnapshot } from './contracts.js';
2
+ import { startManagedAssistant } from './assistant/managed/setup.js';
3
+ import type { CoordinatorSnapshot } from './coordinator-client.js';
4
+ /** One manager lease and one authenticated control endpoint per private application directory. */
5
+ export declare function startApplicationCoordinator(directory: string, options: Parameters<typeof startManagedAssistant>[1]): Promise<{
6
+ credentialsPath: string;
7
+ state: () => CoordinatorSnapshot;
8
+ close: () => Promise<void>;
9
+ }>;
10
+ /** Both launchers use the same discovery and lease-race resolution. Attached clients never own shutdown. */
11
+ export declare function acquireApplicationCoordinator(directory: string, options: Parameters<typeof startManagedAssistant>[1]): Promise<{
12
+ client: {
13
+ call: <T = unknown>(method: import("./contracts.js").CoordinatorMethod | 'hello', input?: unknown) => Promise<T>;
14
+ protocol: {
15
+ version: 1;
16
+ projectionVersion?: 1 | undefined;
17
+ activityVersion?: 1 | undefined;
18
+ generation?: string | undefined;
19
+ capabilities: string[];
20
+ };
21
+ capabilities: string[];
22
+ catalog: () => Promise<ApplicationCatalogSnapshot>;
23
+ state: () => Promise<CoordinatorSnapshot>;
24
+ };
25
+ ownsService: boolean;
26
+ close: () => Promise<void>;
27
+ }>;
@@ -0,0 +1,13 @@
1
+ import type { SecretStore } from './assistant/managed/secrets.js';
2
+ /** One killable process per native request. Secrets travel only through private pipes.
3
+ * A write with no confirmed response locks writes until an explicit successful read.
4
+ */
5
+ export declare function createProcessSecretStore(directory: string, options: {
6
+ executable: string;
7
+ entry: string;
8
+ args?: string[];
9
+ env?: NodeJS.ProcessEnv;
10
+ timeoutMs?: number;
11
+ }): Promise<SecretStore>;
12
+ /** Internal worker entrypoint. Never logs native errors or credential values. */
13
+ export declare function runCredentialWorker(createStore: (account: string) => Promise<SecretStore>): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import { createApplicationReviewChannel } from "./review-channel.js";
2
+ import type { ZhivexHarness } from "../runtime/harness.js";
3
+ import { type HarnessLocalServiceOptions } from "../client/local-service.js";
4
+ /** The application owns lifecycle; the existing engine retains authoritative state,
5
+ * admission, revisions and leases. Callers must close the harness if startup fails.
6
+ */
7
+ export declare function startApplicationHost(harness: ZhivexHarness, options: HarnessLocalServiceOptions, review?: Parameters<typeof createApplicationReviewChannel>[2]): Promise<import("../index.js").HarnessLocalService>;
@@ -0,0 +1,68 @@
1
+ import type { ManagedApplication } from './coordinator-client.js';
2
+ /** Shared management operations. The coordinator serializes these with setup and project changes. */
3
+ export declare function manageApplication(manager: ManagedApplication, raw: unknown): Promise<{
4
+ schemaVersion: 1;
5
+ kind: 'application-agents';
6
+ agents: {
7
+ id: string;
8
+ name: string;
9
+ active: boolean;
10
+ connectionId?: string | undefined;
11
+ provider: import("./contracts.js").ProviderSummary | null;
12
+ integrations: {
13
+ microsoft: boolean;
14
+ microsoftEmail?: string | undefined;
15
+ outlookMail: boolean;
16
+ outlookCalendar: boolean;
17
+ daily: boolean;
18
+ github: boolean;
19
+ web: boolean;
20
+ mail: boolean;
21
+ drive: boolean;
22
+ calendar: boolean;
23
+ calendarEmail?: string | undefined;
24
+ telegram: boolean;
25
+ };
26
+ }[];
27
+ draft: {
28
+ name: string | undefined;
29
+ tools: {
30
+ daily: boolean;
31
+ proactive?: boolean | undefined;
32
+ github?: {
33
+ account: string;
34
+ authorizationEnv: string;
35
+ } | undefined;
36
+ web?: {
37
+ apiKeyEnv: string;
38
+ } | undefined;
39
+ };
40
+ } | null;
41
+ ready: boolean;
42
+ connections?: never;
43
+ } | {
44
+ agents?: never;
45
+ draft?: never;
46
+ ready?: never;
47
+ schemaVersion: 1;
48
+ kind: 'application-connections';
49
+ connections: ({
50
+ id: string;
51
+ agents: {
52
+ id: string;
53
+ name: string;
54
+ }[];
55
+ draft: boolean;
56
+ label: string;
57
+ } & Partial<import("./contracts.js").ProviderSummary>)[];
58
+ } | {
59
+ projects: import("./contracts.js").CodeProject[];
60
+ active?: string | undefined;
61
+ ready: boolean;
62
+ error: string | null;
63
+ agents?: never;
64
+ draft?: never;
65
+ connections?: never;
66
+ schemaVersion: 1;
67
+ kind: 'application-projects';
68
+ }>;
@@ -0,0 +1,5 @@
1
+ import type { NotesSnapshot } from './contracts.js';
2
+ export type { NotesSnapshot } from './contracts.js';
3
+ import type { ManagedApplication } from './coordinator-client.js';
4
+ /** Reads only: writing and deleting notes require the runtime's reviewed tools. */
5
+ export declare function readNotes(manager: ManagedApplication, raw: unknown): Promise<NotesSnapshot>;
@@ -0,0 +1,16 @@
1
+ /** Offline only: no schema inference, credential access, identity remapping or relocation.
2
+ * Every caller-provided application/state root is copied byte-for-byte. Unknown files
3
+ * are retained; sockets and cooperative lock inodes are operational, not user state.
4
+ */
5
+ export declare function applicationMigration(options: {
6
+ roots: string[];
7
+ backup: string;
8
+ action: 'backup' | 'inspect' | 'abort' | 'inspect-rollback' | 'rollback';
9
+ expectedCurrentSha256?: string;
10
+ afterWrite?: () => Promise<void>;
11
+ }): Promise<{
12
+ manifestSha256: string;
13
+ currentSha256: string;
14
+ phase: "aborted" | "copying" | "ready" | "restored" | "restoring";
15
+ files: number;
16
+ }>;
@@ -0,0 +1,5 @@
1
+ import type { PersonalSnapshot } from './contracts.js';
2
+ export type { PersonalSnapshot } from './contracts.js';
3
+ import type { ManagedApplication } from './coordinator-client.js';
4
+ /** Read projection only. Mutations continue through the runtime's reviewed tools. */
5
+ export declare function readPersonalState(manager: ManagedApplication, raw: unknown): Promise<PersonalSnapshot>;
@@ -0,0 +1,23 @@
1
+ import { type HarnessClientAdapter, type HarnessClientResponse, type HarnessClientRun } from "../client/protocol.js";
2
+ import { type ApprovalReview } from "./approval-review.js";
3
+ import { type TicketedApprovalReview } from "./review-tickets.js";
4
+ export type ApplicationReviewResponse = {
5
+ ok: true;
6
+ review: TicketedApprovalReview;
7
+ } | {
8
+ ok: false;
9
+ error: {
10
+ code: string;
11
+ };
12
+ };
13
+ /** Enabled only by the application host on its authenticated, owner-private socket.
14
+ * Raw engine commands never acquire reviewed authority. A client must first get
15
+ * the bounded host projection and resolve its connection-bound, single-use receipt.
16
+ */
17
+ export declare function createApplicationReviewChannel(adapter: HarnessClientAdapter, secrets: readonly string[], options?: {
18
+ tools?: readonly string[];
19
+ project?: (run: HarnessClientRun, redact: (text: string) => string, redactContactDetails: (text: string) => string) => Promise<ApprovalReview>;
20
+ }): {
21
+ review(value: unknown): Promise<ApplicationReviewResponse>;
22
+ decide(value: unknown): Promise<HarnessClientResponse>;
23
+ };
@@ -0,0 +1,29 @@
1
+ import type { ApprovalReview } from "./approval-review.js";
2
+ /** Host-owned receipts: renderer supplies only an opaque ticket and a boolean decision. */
3
+ export declare class ReviewTickets {
4
+ private readonly supported;
5
+ constructor(additionalTools?: readonly string[]);
6
+ private readonly entries;
7
+ issue(sessionId: string, review: ApprovalReview): {
8
+ schemaVersion: 1;
9
+ runId: string;
10
+ revision: number;
11
+ status: string;
12
+ items: import("./approval-review.js").ApprovalReviewItem[];
13
+ ticketId: `${string}-${string}-${string}-${string}-${string}`;
14
+ canApprove: boolean;
15
+ };
16
+ consume(ticketId: unknown, approve: unknown, now?: number): {
17
+ method: "approval.resolve";
18
+ sessionId: string;
19
+ runId: string;
20
+ expectedRevision: number;
21
+ idempotencyKey: string;
22
+ decisions: {
23
+ approvalId: string;
24
+ digest: string;
25
+ approve: boolean;
26
+ }[];
27
+ };
28
+ }
29
+ export type TicketedApprovalReview = ReturnType<ReviewTickets["issue"]>;
@@ -0,0 +1,4 @@
1
+ import type { ZhivexHarness } from '../runtime/harness.js';
2
+ import type { ApplicationRuntimeBinding } from './contracts.js';
3
+ /** Only immutable identity and tool names cross the presentation boundary. */
4
+ export declare function applicationRuntimeBinding(harness: ZhivexHarness): ApplicationRuntimeBinding;
@@ -0,0 +1,184 @@
1
+ import {
2
+ sanitizeTerminalText
3
+ } from "./index-3rvk23e8.js";
4
+ import"./index-dpbmxnrf.js";
5
+ import"./index-cjevq9s8.js";
6
+ import {
7
+ validZone
8
+ } from "./index-rtamqsfs.js";
9
+ import"./index-sx1t6dnd.js";
10
+ import"./index-k529a278.js";
11
+ import"./index-bw34861c.js";
12
+ import"./index-w9eqg6p9.js";
13
+ import"./index-v79s9bf9.js";
14
+ import"./index-fwf274vc.js";
15
+ import"./index-ctcwrkrc.js";
16
+ import"./index-qvbg6tx1.js";
17
+ import"./index-kbrf5bx7.js";
18
+ import"./index-kwk23ktq.js";
19
+ import"./index-6ehtssyz.js";
20
+ import"./index-f970qtb4.js";
21
+ import"./index-h7dcah4p.js";
22
+ import {
23
+ connectCoordinator
24
+ } from "./index-s125ss45.js";
25
+ import {
26
+ connectApplication
27
+ } from "./index-0mzz9axm.js";
28
+ import"./index-3wa4j0yk.js";
29
+ import {
30
+ HarnessConfigError
31
+ } from "./index-xwb691v9.js";
32
+ import"./index-px1tnqgt.js";
33
+ import"./index-76kpdbpw.js";
34
+ import"./index-1bx83sw4.js";
35
+
36
+ // packages/core/src/cli/application-cli.ts
37
+ import { z } from "zod";
38
+ import path from "node:path";
39
+ import os from "node:os";
40
+ import { realpath } from "node:fs/promises";
41
+
42
+ // packages/core/src/application/coordinator-discovery.ts
43
+ import { spawn } from "node:child_process";
44
+ var unavailable = (error) => error.code === "ENOENT" || error instanceof Error && error.message === "LOCAL_SERVICE_UNAVAILABLE";
45
+ async function ensureApplicationCoordinator(directory, launcher) {
46
+ try {
47
+ return await connectCoordinator(directory);
48
+ } catch (error) {
49
+ if (!unavailable(error))
50
+ throw error;
51
+ }
52
+ const child = spawn(launcher.executable, [launcher.entry, "--application-directory", directory], { detached: true, stdio: "ignore", env: process.env });
53
+ let failed = false;
54
+ child.once("error", () => {
55
+ failed = true;
56
+ });
57
+ child.unref();
58
+ for (let attempt = 0;attempt < 300; attempt++) {
59
+ try {
60
+ return await connectCoordinator(directory);
61
+ } catch (error) {
62
+ if (!unavailable(error))
63
+ throw error;
64
+ }
65
+ if (failed)
66
+ throw new Error("COORDINATOR_LAUNCH_FAILED");
67
+ if (child.exitCode !== null && child.exitCode !== 0)
68
+ throw new Error("COORDINATOR_LAUNCH_FAILED");
69
+ await new Promise((resolve) => setTimeout(resolve, 100));
70
+ }
71
+ throw new Error("COORDINATOR_START_UNCONFIRMED");
72
+ }
73
+
74
+ // packages/core/src/cli/application-cli.ts
75
+ async function useApplicationCli(options) {
76
+ const automationInput = options.command === "automations" && options.automationCommand === "apply" ? parseAutomationInput(options.managementInput) : undefined;
77
+ const directory = path.resolve(options.applicationDirectory ?? path.join(os.homedir(), ".zhx-app"));
78
+ const lifecycle = options.command === "application" ? options.applicationCommand : undefined;
79
+ let client;
80
+ try {
81
+ if (lifecycle === "status" || lifecycle === "stop")
82
+ client = await connectCoordinator(directory);
83
+ else {
84
+ const entry = await realpath(process.argv[1]);
85
+ const launcher = path.join(path.dirname(entry), entry.endsWith(".ts") ? "service-cli.ts" : "service-cli.js");
86
+ client = await ensureApplicationCoordinator(directory, { executable: process.execPath, entry: launcher });
87
+ }
88
+ } catch (error) {
89
+ if (lifecycle === "status" && (error.code === "ENOENT" || error instanceof Error && error.message === "LOCAL_SERVICE_UNAVAILABLE")) {
90
+ print({ schemaVersion: 1, kind: "application-status", status: "unavailable", directory }, options.json);
91
+ return;
92
+ }
93
+ throw new HarnessConfigError(`Application service unavailable (${error instanceof Error ? error.message : "unknown"}). Inspect its state before retrying.`);
94
+ }
95
+ if (lifecycle === "stop") {
96
+ await client.call("shutdown", { confirmed: true });
97
+ print({ schemaVersion: 1, kind: "application-status", status: "stop-requested", directory }, options.json);
98
+ return;
99
+ }
100
+ if (options.command === "projects" && options.managementAction === "context") {
101
+ if (!client.capabilities.includes("application.code-context"))
102
+ throw new HarnessConfigError("The running host does not support Code context. Update and restart the host.");
103
+ const snapshot2 = await client.state();
104
+ if (!snapshot2.codeCredentialsPath)
105
+ throw new HarnessConfigError("No active Code project is ready. Open or select a project first.");
106
+ const code = await connectApplication(snapshot2.codeCredentialsPath);
107
+ const context = await client.call("code-tools", { action: "context", value: { projectId: code.projectId } });
108
+ print({ ...context, kind: "application-code-context", projectId: code.projectId }, options.json);
109
+ return;
110
+ }
111
+ if (["agents", "connections", "projects"].includes(options.command)) {
112
+ if (!client.capabilities.includes("application.management"))
113
+ throw new HarnessConfigError("The running application host does not support management commands. Stop it explicitly and restart with the updated version.");
114
+ try {
115
+ const result = await client.call("management", { resource: options.command, action: options.managementAction, args: options.managementArgs ?? [], ...options.managementInput === undefined ? {} : { input: options.managementInput }, confirmed: options.yes });
116
+ print(result, options.json);
117
+ return;
118
+ } catch (error) {
119
+ throw new HarnessConfigError(`Application configuration failed (${error instanceof Error ? error.message : "unknown"}). Inspect the shared draft and state before retrying.`);
120
+ }
121
+ }
122
+ const snapshot = await client.state();
123
+ if (options.command === "automations") {
124
+ if (!client.capabilities.includes("application.automation"))
125
+ throw new HarnessConfigError("The running host does not support automations. Update and restart the host.");
126
+ if (!snapshot.credentialsPath)
127
+ throw new HarnessConfigError("No active Assistant is ready. Configure or select an agent first.");
128
+ const assistant = await connectApplication(snapshot.credentialsPath);
129
+ if (automationInput && automationInput.projectId !== assistant.projectId)
130
+ throw new HarnessConfigError("APPLICATION_SCOPE_CHANGED: review automation status for the active Assistant.");
131
+ try {
132
+ const automation = await client.call("automation", { projectId: assistant.projectId, ...automationInput ? { change: { ...automationInput.change, confirmed: true } } : {} });
133
+ print({ schemaVersion: 1, kind: "application-automation", projectId: assistant.projectId, ...automation }, options.json);
134
+ } catch (error) {
135
+ throw new HarnessConfigError(`Automation configuration failed (${error instanceof Error ? error.message : "unknown"}). Read automations status before retrying; do not automatically repeat an uncertain change.`);
136
+ }
137
+ return;
138
+ }
139
+ if (options.command === "personal") {
140
+ const notesCommand = ["notes", "search-notes", "note"].includes(options.personalCommand ?? "");
141
+ if (!client.capabilities.includes(notesCommand ? "application.notes" : "application.personal-state"))
142
+ throw new HarnessConfigError("The running host does not support personal state. Update and restart the host.");
143
+ if (!snapshot.credentialsPath)
144
+ throw new HarnessConfigError("No active Assistant is ready. Configure or select an agent first.");
145
+ const assistant = await connectApplication(snapshot.credentialsPath);
146
+ if (notesCommand) {
147
+ const notes = await client.call("notes", { projectId: assistant.projectId, offset: options.personalOffset ?? 0, query: options.personalQuery ?? "", ...options.personalNoteId ? { noteId: options.personalNoteId } : {} });
148
+ print({ schemaVersion: 1, kind: "application-notes", projectId: assistant.projectId, ...notes }, options.json);
149
+ return;
150
+ }
151
+ const personal = await client.call("personal-state", { projectId: assistant.projectId, offset: options.personalOffset ?? 0 });
152
+ const base = { schemaVersion: 1, projectId: assistant.projectId, enabled: personal.enabled };
153
+ print(options.personalCommand === "tasks" ? { ...base, kind: "application-tasks", tasks: personal.tasks, total: personal.total, nextOffset: personal.nextOffset } : { ...base, kind: "application-reminders", reminders: personal.reminders }, options.json);
154
+ return;
155
+ }
156
+ if (lifecycle) {
157
+ print({ schemaVersion: 1, kind: "application-status", status: "running", directory, assistantReady: snapshot.state.ready, assistantLocked: snapshot.state.locked, assistantError: snapshot.state.error, codeReady: snapshot.code.ready }, options.json);
158
+ return;
159
+ }
160
+ const area = options.applicationArea ?? "assistant";
161
+ const file = area === "assistant" ? snapshot.credentialsPath : snapshot.codeCredentialsPath;
162
+ if (!file)
163
+ throw new HarnessConfigError(area === "assistant" ? "The shared Assistant is not configured. Configure its agent and connection before running a task." : "No shared Code project is open. Select a Git project and model connection before running a task.");
164
+ return file;
165
+ }
166
+ function print(value, json) {
167
+ const text = JSON.stringify(value, null, 2);
168
+ process.stdout.write((json ? text : sanitizeTerminalText(text)) + `
169
+ `);
170
+ }
171
+ function parseAutomationInput(value) {
172
+ const common = { expectedDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/) };
173
+ const schema = z.object({ projectId: z.string().min(1), change: z.discriminatedUnion("action", [
174
+ z.object({ ...common, action: z.literal("configure"), localTime: z.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d$/), timeZone: z.string().refine(validZone) }).strict(),
175
+ z.object({ ...common, action: z.enum(["pause", "resume", "delete", "forget"]) }).strict()
176
+ ]) }).strict();
177
+ const result = schema.safeParse(value);
178
+ if (!result.success)
179
+ throw new HarnessConfigError("Invalid automation configuration. Supply projectId and change with action and expectedDigest; configure also requires localTime (HH:mm) and a valid timeZone.");
180
+ return result.data;
181
+ }
182
+ export {
183
+ useApplicationCli
184
+ };
@@ -0,0 +1,209 @@
1
+ import {
2
+ connectApplication,
3
+ readHarnessLocalCredentials,
4
+ requestLocalServiceDocument
5
+ } from "./cli-entry-bxjbs6qq.js";
6
+ import {
7
+ sanitizeTerminalText
8
+ } from "./cli-entry-eka68ttb.js";
9
+ import"./cli-entry-vmce694z.js";
10
+ import"./cli-entry-kwk23ktq.js";
11
+ import"./cli-entry-h7dcah4p.js";
12
+ import {
13
+ HarnessConfigError
14
+ } from "./cli-entry-68kqraj7.js";
15
+ import"./cli-entry-1bx83sw4.js";
16
+
17
+ // packages/core/src/cli/application-cli.ts
18
+ import { z as z2 } from "zod";
19
+
20
+ // packages/core/src/application/assistant/automation/time.ts
21
+ var cache = new Map;
22
+ function validZone(zone) {
23
+ try {
24
+ return zone.length <= 100 && !!new Intl.DateTimeFormat("en", { timeZone: zone }).resolvedOptions().timeZone;
25
+ } catch {
26
+ return false;
27
+ }
28
+ }
29
+
30
+ // packages/core/src/cli/application-cli.ts
31
+ import path2 from "node:path";
32
+ import os from "node:os";
33
+ import { realpath } from "node:fs/promises";
34
+
35
+ // packages/core/src/application/coordinator-client.ts
36
+ import path from "node:path";
37
+ import { z } from "zod";
38
+ async function connectCoordinator(directory, options = {}) {
39
+ const credentials = await readHarnessLocalCredentials(path.join(directory, "coordinator.json"));
40
+ const call = async (method, input) => {
41
+ const result = await requestLocalServiceDocument(credentials, "application", { version: 1, method, input }, method === "hello" || method === "state" ? 3000 : 120000);
42
+ if (!result.ok)
43
+ throw new ApplicationCoordinatorError(result.error ?? "COORDINATOR_RESPONSE_INVALID", result.detail);
44
+ return result.result;
45
+ };
46
+ const hello = z.object({ version: z.literal(1), projectionVersion: z.literal(1).optional(), activityVersion: z.literal(1).optional(), generation: z.string().uuid().optional(), capabilities: z.array(z.string()).max(100) }).parse(await call("hello", { versions: options.versions ?? [1] }));
47
+ if (options.requiredCapabilities?.some((capability) => !hello.capabilities.includes(capability)))
48
+ throw new ApplicationCoordinatorError("COORDINATOR_CAPABILITY_UNSUPPORTED", { schemaVersion: 1, code: "COORDINATOR_CAPABILITY_UNSUPPORTED", recovery: "upgrade" });
49
+ return { call, protocol: hello, capabilities: hello.capabilities, catalog: () => {
50
+ if (!hello.capabilities.includes("application.catalog"))
51
+ throw new ApplicationCoordinatorError("COORDINATOR_CAPABILITY_UNSUPPORTED");
52
+ return call("catalog");
53
+ }, state: () => call("state") };
54
+ }
55
+
56
+ class ApplicationCoordinatorError extends Error {
57
+ code;
58
+ detail;
59
+ constructor(code, detail) {
60
+ super(code);
61
+ this.name = "ApplicationCoordinatorError";
62
+ this.code = code;
63
+ this.detail = detail;
64
+ }
65
+ }
66
+
67
+ // packages/core/src/application/coordinator-discovery.ts
68
+ import { spawn } from "node:child_process";
69
+ var unavailable = (error) => error.code === "ENOENT" || error instanceof Error && error.message === "LOCAL_SERVICE_UNAVAILABLE";
70
+ async function ensureApplicationCoordinator(directory, launcher) {
71
+ try {
72
+ return await connectCoordinator(directory);
73
+ } catch (error) {
74
+ if (!unavailable(error))
75
+ throw error;
76
+ }
77
+ const child = spawn(launcher.executable, [launcher.entry, "--application-directory", directory], { detached: true, stdio: "ignore", env: process.env });
78
+ let failed = false;
79
+ child.once("error", () => {
80
+ failed = true;
81
+ });
82
+ child.unref();
83
+ for (let attempt = 0;attempt < 300; attempt++) {
84
+ try {
85
+ return await connectCoordinator(directory);
86
+ } catch (error) {
87
+ if (!unavailable(error))
88
+ throw error;
89
+ }
90
+ if (failed)
91
+ throw new Error("COORDINATOR_LAUNCH_FAILED");
92
+ if (child.exitCode !== null && child.exitCode !== 0)
93
+ throw new Error("COORDINATOR_LAUNCH_FAILED");
94
+ await new Promise((resolve) => setTimeout(resolve, 100));
95
+ }
96
+ throw new Error("COORDINATOR_START_UNCONFIRMED");
97
+ }
98
+
99
+ // packages/core/src/cli/application-cli.ts
100
+ async function useApplicationCli(options) {
101
+ const automationInput = options.command === "automations" && options.automationCommand === "apply" ? parseAutomationInput(options.managementInput) : undefined;
102
+ const directory = path2.resolve(options.applicationDirectory ?? path2.join(os.homedir(), ".zhx-app"));
103
+ const lifecycle = options.command === "application" ? options.applicationCommand : undefined;
104
+ let client;
105
+ try {
106
+ if (lifecycle === "status" || lifecycle === "stop")
107
+ client = await connectCoordinator(directory);
108
+ else {
109
+ const entry = await realpath(process.argv[1]);
110
+ const launcher = path2.join(path2.dirname(entry), entry.endsWith(".ts") ? "service-cli.ts" : "service-cli.js");
111
+ client = await ensureApplicationCoordinator(directory, { executable: process.execPath, entry: launcher });
112
+ }
113
+ } catch (error) {
114
+ if (lifecycle === "status" && (error.code === "ENOENT" || error instanceof Error && error.message === "LOCAL_SERVICE_UNAVAILABLE")) {
115
+ print({ schemaVersion: 1, kind: "application-status", status: "unavailable", directory }, options.json);
116
+ return;
117
+ }
118
+ throw new HarnessConfigError(`Application service unavailable (${error instanceof Error ? error.message : "unknown"}). Inspect its state before retrying.`);
119
+ }
120
+ if (lifecycle === "stop") {
121
+ await client.call("shutdown", { confirmed: true });
122
+ print({ schemaVersion: 1, kind: "application-status", status: "stop-requested", directory }, options.json);
123
+ return;
124
+ }
125
+ if (options.command === "projects" && options.managementAction === "context") {
126
+ if (!client.capabilities.includes("application.code-context"))
127
+ throw new HarnessConfigError("The running host does not support Code context. Update and restart the host.");
128
+ const snapshot2 = await client.state();
129
+ if (!snapshot2.codeCredentialsPath)
130
+ throw new HarnessConfigError("No active Code project is ready. Open or select a project first.");
131
+ const code = await connectApplication(snapshot2.codeCredentialsPath);
132
+ const context = await client.call("code-tools", { action: "context", value: { projectId: code.projectId } });
133
+ print({ ...context, kind: "application-code-context", projectId: code.projectId }, options.json);
134
+ return;
135
+ }
136
+ if (["agents", "connections", "projects"].includes(options.command)) {
137
+ if (!client.capabilities.includes("application.management"))
138
+ throw new HarnessConfigError("The running application host does not support management commands. Stop it explicitly and restart with the updated version.");
139
+ try {
140
+ const result = await client.call("management", { resource: options.command, action: options.managementAction, args: options.managementArgs ?? [], ...options.managementInput === undefined ? {} : { input: options.managementInput }, confirmed: options.yes });
141
+ print(result, options.json);
142
+ return;
143
+ } catch (error) {
144
+ throw new HarnessConfigError(`Application configuration failed (${error instanceof Error ? error.message : "unknown"}). Inspect the shared draft and state before retrying.`);
145
+ }
146
+ }
147
+ const snapshot = await client.state();
148
+ if (options.command === "automations") {
149
+ if (!client.capabilities.includes("application.automation"))
150
+ throw new HarnessConfigError("The running host does not support automations. Update and restart the host.");
151
+ if (!snapshot.credentialsPath)
152
+ throw new HarnessConfigError("No active Assistant is ready. Configure or select an agent first.");
153
+ const assistant = await connectApplication(snapshot.credentialsPath);
154
+ if (automationInput && automationInput.projectId !== assistant.projectId)
155
+ throw new HarnessConfigError("APPLICATION_SCOPE_CHANGED: review automation status for the active Assistant.");
156
+ try {
157
+ const automation = await client.call("automation", { projectId: assistant.projectId, ...automationInput ? { change: { ...automationInput.change, confirmed: true } } : {} });
158
+ print({ schemaVersion: 1, kind: "application-automation", projectId: assistant.projectId, ...automation }, options.json);
159
+ } catch (error) {
160
+ throw new HarnessConfigError(`Automation configuration failed (${error instanceof Error ? error.message : "unknown"}). Read automations status before retrying; do not automatically repeat an uncertain change.`);
161
+ }
162
+ return;
163
+ }
164
+ if (options.command === "personal") {
165
+ const notesCommand = ["notes", "search-notes", "note"].includes(options.personalCommand ?? "");
166
+ if (!client.capabilities.includes(notesCommand ? "application.notes" : "application.personal-state"))
167
+ throw new HarnessConfigError("The running host does not support personal state. Update and restart the host.");
168
+ if (!snapshot.credentialsPath)
169
+ throw new HarnessConfigError("No active Assistant is ready. Configure or select an agent first.");
170
+ const assistant = await connectApplication(snapshot.credentialsPath);
171
+ if (notesCommand) {
172
+ const notes = await client.call("notes", { projectId: assistant.projectId, offset: options.personalOffset ?? 0, query: options.personalQuery ?? "", ...options.personalNoteId ? { noteId: options.personalNoteId } : {} });
173
+ print({ schemaVersion: 1, kind: "application-notes", projectId: assistant.projectId, ...notes }, options.json);
174
+ return;
175
+ }
176
+ const personal = await client.call("personal-state", { projectId: assistant.projectId, offset: options.personalOffset ?? 0 });
177
+ const base = { schemaVersion: 1, projectId: assistant.projectId, enabled: personal.enabled };
178
+ print(options.personalCommand === "tasks" ? { ...base, kind: "application-tasks", tasks: personal.tasks, total: personal.total, nextOffset: personal.nextOffset } : { ...base, kind: "application-reminders", reminders: personal.reminders }, options.json);
179
+ return;
180
+ }
181
+ if (lifecycle) {
182
+ print({ schemaVersion: 1, kind: "application-status", status: "running", directory, assistantReady: snapshot.state.ready, assistantLocked: snapshot.state.locked, assistantError: snapshot.state.error, codeReady: snapshot.code.ready }, options.json);
183
+ return;
184
+ }
185
+ const area = options.applicationArea ?? "assistant";
186
+ const file = area === "assistant" ? snapshot.credentialsPath : snapshot.codeCredentialsPath;
187
+ if (!file)
188
+ throw new HarnessConfigError(area === "assistant" ? "The shared Assistant is not configured. Configure its agent and connection before running a task." : "No shared Code project is open. Select a Git project and model connection before running a task.");
189
+ return file;
190
+ }
191
+ function print(value, json) {
192
+ const text = JSON.stringify(value, null, 2);
193
+ process.stdout.write((json ? text : sanitizeTerminalText(text)) + `
194
+ `);
195
+ }
196
+ function parseAutomationInput(value) {
197
+ const common = { expectedDigest: z2.string().regex(/^sha256:[a-f0-9]{64}$/) };
198
+ const schema = z2.object({ projectId: z2.string().min(1), change: z2.discriminatedUnion("action", [
199
+ z2.object({ ...common, action: z2.literal("configure"), localTime: z2.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d$/), timeZone: z2.string().refine(validZone) }).strict(),
200
+ z2.object({ ...common, action: z2.enum(["pause", "resume", "delete", "forget"]) }).strict()
201
+ ]) }).strict();
202
+ const result = schema.safeParse(value);
203
+ if (!result.success)
204
+ throw new HarnessConfigError("Invalid automation configuration. Supply projectId and change with action and expectedDigest; configure also requires localTime (HH:mm) and a valid timeZone.");
205
+ return result.data;
206
+ }
207
+ export {
208
+ useApplicationCli
209
+ };
@@ -0,0 +1,27 @@
1
+ import {
2
+ CLI_CHANGES_COMMANDS,
3
+ CLI_COMMANDS,
4
+ CLI_RUNS_COMMANDS,
5
+ CLI_SESSIONS_COMMANDS,
6
+ CLI_STATE_COMMANDS,
7
+ CliUsageError,
8
+ parseCliArgs
9
+ } from "./index-nkwy5bjr.js";
10
+ import"./index-0kkgqvg7.js";
11
+ import"./index-ay26xfxt.js";
12
+ import"./index-fwf274vc.js";
13
+ import"./index-ctcwrkrc.js";
14
+ import"./index-qvbg6tx1.js";
15
+ import"./index-h7dcah4p.js";
16
+ import"./index-xwb691v9.js";
17
+ import"./index-px1tnqgt.js";
18
+ import"./index-1bx83sw4.js";
19
+ export {
20
+ CLI_CHANGES_COMMANDS,
21
+ CLI_COMMANDS,
22
+ CLI_RUNS_COMMANDS,
23
+ CLI_SESSIONS_COMMANDS,
24
+ CLI_STATE_COMMANDS,
25
+ CliUsageError,
26
+ parseCliArgs
27
+ };