@bf-meishijian/aip 0.0.43 → 0.0.44

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 (760) hide show
  1. package/README.md +3 -3
  2. package/dist/coding-run-manager.d.ts +1 -0
  3. package/dist/coding-run-manager.d.ts.map +1 -1
  4. package/dist/coding-run-manager.js +60 -4
  5. package/dist/coding-run-manager.js.map +1 -1
  6. package/dist/daemon.d.ts.map +1 -1
  7. package/dist/daemon.js +48 -5
  8. package/dist/daemon.js.map +1 -1
  9. package/dist/diagnostics.d.ts.map +1 -1
  10. package/dist/general-run-client.d.ts.map +1 -1
  11. package/dist/host-status.d.ts.map +1 -1
  12. package/dist/host-update.d.ts.map +1 -1
  13. package/dist/host-update.js +21 -82
  14. package/dist/host-update.js.map +1 -1
  15. package/dist/host-updater.d.ts +4 -0
  16. package/dist/host-updater.d.ts.map +1 -0
  17. package/dist/host-updater.js +246 -0
  18. package/dist/host-updater.js.map +1 -0
  19. package/dist/installer.d.ts.map +1 -1
  20. package/dist/installer.js +10 -2
  21. package/dist/installer.js.map +1 -1
  22. package/dist/pi-model-service.d.ts.map +1 -1
  23. package/dist/platform-client.d.ts +22 -0
  24. package/dist/platform-client.d.ts.map +1 -1
  25. package/dist/platform-client.js +9 -0
  26. package/dist/platform-client.js.map +1 -1
  27. package/dist/runtime-download.d.ts +11 -0
  28. package/dist/runtime-download.d.ts.map +1 -0
  29. package/dist/runtime-download.js +136 -0
  30. package/dist/runtime-download.js.map +1 -0
  31. package/dist/runtime-update-control.d.ts +14 -0
  32. package/dist/runtime-update-control.d.ts.map +1 -0
  33. package/dist/runtime-update-control.js +111 -0
  34. package/dist/runtime-update-control.js.map +1 -0
  35. package/dist/runtime-update-state.d.ts +24 -0
  36. package/dist/runtime-update-state.d.ts.map +1 -0
  37. package/dist/runtime-update-state.js +38 -0
  38. package/dist/runtime-update-state.js.map +1 -0
  39. package/dist/update-service.d.ts +19 -0
  40. package/dist/update-service.d.ts.map +1 -0
  41. package/dist/update-service.js +119 -0
  42. package/dist/update-service.js.map +1 -0
  43. package/dist/workflow-guidance.js +1 -1
  44. package/dist/workspace-diff.d.ts.map +1 -1
  45. package/dist/workspace-diff.js +7 -1
  46. package/dist/workspace-diff.js.map +1 -1
  47. package/package.json +4 -4
  48. package/dist/apps/local-coding-host/src/bash-discovery.d.ts +0 -8
  49. package/dist/apps/local-coding-host/src/bash-discovery.d.ts.map +0 -1
  50. package/dist/apps/local-coding-host/src/bash-discovery.js +0 -66
  51. package/dist/apps/local-coding-host/src/bash-discovery.js.map +0 -1
  52. package/dist/apps/local-coding-host/src/cli.d.ts +0 -4
  53. package/dist/apps/local-coding-host/src/cli.d.ts.map +0 -1
  54. package/dist/apps/local-coding-host/src/cli.js +0 -388
  55. package/dist/apps/local-coding-host/src/cli.js.map +0 -1
  56. package/dist/apps/local-coding-host/src/coding-run-manager.d.ts +0 -174
  57. package/dist/apps/local-coding-host/src/coding-run-manager.d.ts.map +0 -1
  58. package/dist/apps/local-coding-host/src/coding-run-manager.js +0 -1587
  59. package/dist/apps/local-coding-host/src/coding-run-manager.js.map +0 -1
  60. package/dist/apps/local-coding-host/src/coding-subagent-child.d.ts +0 -22
  61. package/dist/apps/local-coding-host/src/coding-subagent-child.d.ts.map +0 -1
  62. package/dist/apps/local-coding-host/src/coding-subagent-child.js +0 -96
  63. package/dist/apps/local-coding-host/src/coding-subagent-child.js.map +0 -1
  64. package/dist/apps/local-coding-host/src/coding-subagents.d.ts +0 -65
  65. package/dist/apps/local-coding-host/src/coding-subagents.d.ts.map +0 -1
  66. package/dist/apps/local-coding-host/src/coding-subagents.js +0 -521
  67. package/dist/apps/local-coding-host/src/coding-subagents.js.map +0 -1
  68. package/dist/apps/local-coding-host/src/command-executor.d.ts +0 -9
  69. package/dist/apps/local-coding-host/src/command-executor.d.ts.map +0 -1
  70. package/dist/apps/local-coding-host/src/command-executor.js +0 -222
  71. package/dist/apps/local-coding-host/src/command-executor.js.map +0 -1
  72. package/dist/apps/local-coding-host/src/command-wakeup.d.ts +0 -19
  73. package/dist/apps/local-coding-host/src/command-wakeup.d.ts.map +0 -1
  74. package/dist/apps/local-coding-host/src/command-wakeup.js +0 -109
  75. package/dist/apps/local-coding-host/src/command-wakeup.js.map +0 -1
  76. package/dist/apps/local-coding-host/src/daemon.d.ts +0 -8
  77. package/dist/apps/local-coding-host/src/daemon.d.ts.map +0 -1
  78. package/dist/apps/local-coding-host/src/daemon.js +0 -314
  79. package/dist/apps/local-coding-host/src/daemon.js.map +0 -1
  80. package/dist/apps/local-coding-host/src/delivery-files.d.ts +0 -39
  81. package/dist/apps/local-coding-host/src/delivery-files.d.ts.map +0 -1
  82. package/dist/apps/local-coding-host/src/delivery-files.js +0 -237
  83. package/dist/apps/local-coding-host/src/delivery-files.js.map +0 -1
  84. package/dist/apps/local-coding-host/src/delivery-tools.d.ts +0 -30
  85. package/dist/apps/local-coding-host/src/delivery-tools.d.ts.map +0 -1
  86. package/dist/apps/local-coding-host/src/delivery-tools.js +0 -196
  87. package/dist/apps/local-coding-host/src/delivery-tools.js.map +0 -1
  88. package/dist/apps/local-coding-host/src/diagnostic-log.d.ts +0 -20
  89. package/dist/apps/local-coding-host/src/diagnostic-log.d.ts.map +0 -1
  90. package/dist/apps/local-coding-host/src/diagnostic-log.js +0 -61
  91. package/dist/apps/local-coding-host/src/diagnostic-log.js.map +0 -1
  92. package/dist/apps/local-coding-host/src/diagnostics.d.ts +0 -38
  93. package/dist/apps/local-coding-host/src/diagnostics.d.ts.map +0 -1
  94. package/dist/apps/local-coding-host/src/diagnostics.js +0 -217
  95. package/dist/apps/local-coding-host/src/diagnostics.js.map +0 -1
  96. package/dist/apps/local-coding-host/src/execution-process-observer.d.ts +0 -19
  97. package/dist/apps/local-coding-host/src/execution-process-observer.d.ts.map +0 -1
  98. package/dist/apps/local-coding-host/src/execution-process-observer.js +0 -35
  99. package/dist/apps/local-coding-host/src/execution-process-observer.js.map +0 -1
  100. package/dist/apps/local-coding-host/src/execution-process-tree.d.ts +0 -32
  101. package/dist/apps/local-coding-host/src/execution-process-tree.d.ts.map +0 -1
  102. package/dist/apps/local-coding-host/src/execution-process-tree.js +0 -288
  103. package/dist/apps/local-coding-host/src/execution-process-tree.js.map +0 -1
  104. package/dist/apps/local-coding-host/src/execution-process.d.ts +0 -59
  105. package/dist/apps/local-coding-host/src/execution-process.d.ts.map +0 -1
  106. package/dist/apps/local-coding-host/src/execution-process.js +0 -112
  107. package/dist/apps/local-coding-host/src/execution-process.js.map +0 -1
  108. package/dist/apps/local-coding-host/src/execution-receipts.d.ts +0 -12
  109. package/dist/apps/local-coding-host/src/execution-receipts.d.ts.map +0 -1
  110. package/dist/apps/local-coding-host/src/execution-receipts.js +0 -89
  111. package/dist/apps/local-coding-host/src/execution-receipts.js.map +0 -1
  112. package/dist/apps/local-coding-host/src/execution-supervisor.d.ts +0 -25
  113. package/dist/apps/local-coding-host/src/execution-supervisor.d.ts.map +0 -1
  114. package/dist/apps/local-coding-host/src/execution-supervisor.js +0 -482
  115. package/dist/apps/local-coding-host/src/execution-supervisor.js.map +0 -1
  116. package/dist/apps/local-coding-host/src/execution-worker.d.ts +0 -42
  117. package/dist/apps/local-coding-host/src/execution-worker.d.ts.map +0 -1
  118. package/dist/apps/local-coding-host/src/execution-worker.js +0 -165
  119. package/dist/apps/local-coding-host/src/execution-worker.js.map +0 -1
  120. package/dist/apps/local-coding-host/src/general-run-client.d.ts +0 -111
  121. package/dist/apps/local-coding-host/src/general-run-client.d.ts.map +0 -1
  122. package/dist/apps/local-coding-host/src/general-run-client.js +0 -41
  123. package/dist/apps/local-coding-host/src/general-run-client.js.map +0 -1
  124. package/dist/apps/local-coding-host/src/general-run-manager.d.ts +0 -33
  125. package/dist/apps/local-coding-host/src/general-run-manager.d.ts.map +0 -1
  126. package/dist/apps/local-coding-host/src/general-run-manager.js +0 -363
  127. package/dist/apps/local-coding-host/src/general-run-manager.js.map +0 -1
  128. package/dist/apps/local-coding-host/src/general-run-supervisor.d.ts +0 -12
  129. package/dist/apps/local-coding-host/src/general-run-supervisor.d.ts.map +0 -1
  130. package/dist/apps/local-coding-host/src/general-run-supervisor.js +0 -160
  131. package/dist/apps/local-coding-host/src/general-run-supervisor.js.map +0 -1
  132. package/dist/apps/local-coding-host/src/general-run-tools.d.ts +0 -25
  133. package/dist/apps/local-coding-host/src/general-run-tools.d.ts.map +0 -1
  134. package/dist/apps/local-coding-host/src/general-run-tools.js +0 -123
  135. package/dist/apps/local-coding-host/src/general-run-tools.js.map +0 -1
  136. package/dist/apps/local-coding-host/src/git-credential-environment.d.ts +0 -3
  137. package/dist/apps/local-coding-host/src/git-credential-environment.d.ts.map +0 -1
  138. package/dist/apps/local-coding-host/src/git-credential-environment.js +0 -46
  139. package/dist/apps/local-coding-host/src/git-credential-environment.js.map +0 -1
  140. package/dist/apps/local-coding-host/src/git-credential-helper.d.ts +0 -2
  141. package/dist/apps/local-coding-host/src/git-credential-helper.d.ts.map +0 -1
  142. package/dist/apps/local-coding-host/src/git-credential-helper.js +0 -38
  143. package/dist/apps/local-coding-host/src/git-credential-helper.js.map +0 -1
  144. package/dist/apps/local-coding-host/src/git-http-migration.d.ts +0 -24
  145. package/dist/apps/local-coding-host/src/git-http-migration.d.ts.map +0 -1
  146. package/dist/apps/local-coding-host/src/git-http-migration.js +0 -197
  147. package/dist/apps/local-coding-host/src/git-http-migration.js.map +0 -1
  148. package/dist/apps/local-coding-host/src/git-process.d.ts +0 -25
  149. package/dist/apps/local-coding-host/src/git-process.d.ts.map +0 -1
  150. package/dist/apps/local-coding-host/src/git-process.js +0 -85
  151. package/dist/apps/local-coding-host/src/git-process.js.map +0 -1
  152. package/dist/apps/local-coding-host/src/git-transport.d.ts +0 -6
  153. package/dist/apps/local-coding-host/src/git-transport.d.ts.map +0 -1
  154. package/dist/apps/local-coding-host/src/git-transport.js +0 -57
  155. package/dist/apps/local-coding-host/src/git-transport.js.map +0 -1
  156. package/dist/apps/local-coding-host/src/gitlab-cli.d.ts +0 -2
  157. package/dist/apps/local-coding-host/src/gitlab-cli.d.ts.map +0 -1
  158. package/dist/apps/local-coding-host/src/gitlab-cli.js +0 -39
  159. package/dist/apps/local-coding-host/src/gitlab-cli.js.map +0 -1
  160. package/dist/apps/local-coding-host/src/gitlab-credentials.d.ts +0 -18
  161. package/dist/apps/local-coding-host/src/gitlab-credentials.d.ts.map +0 -1
  162. package/dist/apps/local-coding-host/src/gitlab-credentials.js +0 -137
  163. package/dist/apps/local-coding-host/src/gitlab-credentials.js.map +0 -1
  164. package/dist/apps/local-coding-host/src/handoff-cli.d.ts +0 -2
  165. package/dist/apps/local-coding-host/src/handoff-cli.d.ts.map +0 -1
  166. package/dist/apps/local-coding-host/src/handoff-cli.js +0 -86
  167. package/dist/apps/local-coding-host/src/handoff-cli.js.map +0 -1
  168. package/dist/apps/local-coding-host/src/harness.d.ts +0 -2
  169. package/dist/apps/local-coding-host/src/harness.d.ts.map +0 -1
  170. package/dist/apps/local-coding-host/src/harness.js +0 -2
  171. package/dist/apps/local-coding-host/src/harness.js.map +0 -1
  172. package/dist/apps/local-coding-host/src/host-log.d.ts +0 -13
  173. package/dist/apps/local-coding-host/src/host-log.d.ts.map +0 -1
  174. package/dist/apps/local-coding-host/src/host-log.js +0 -43
  175. package/dist/apps/local-coding-host/src/host-log.js.map +0 -1
  176. package/dist/apps/local-coding-host/src/host-shell.d.ts +0 -2
  177. package/dist/apps/local-coding-host/src/host-shell.d.ts.map +0 -1
  178. package/dist/apps/local-coding-host/src/host-shell.js +0 -2
  179. package/dist/apps/local-coding-host/src/host-shell.js.map +0 -1
  180. package/dist/apps/local-coding-host/src/host-status.d.ts +0 -57
  181. package/dist/apps/local-coding-host/src/host-status.d.ts.map +0 -1
  182. package/dist/apps/local-coding-host/src/host-status.js +0 -144
  183. package/dist/apps/local-coding-host/src/host-status.js.map +0 -1
  184. package/dist/apps/local-coding-host/src/host-tools.d.ts +0 -15
  185. package/dist/apps/local-coding-host/src/host-tools.d.ts.map +0 -1
  186. package/dist/apps/local-coding-host/src/host-tools.js +0 -178
  187. package/dist/apps/local-coding-host/src/host-tools.js.map +0 -1
  188. package/dist/apps/local-coding-host/src/host-update.d.ts +0 -3
  189. package/dist/apps/local-coding-host/src/host-update.d.ts.map +0 -1
  190. package/dist/apps/local-coding-host/src/host-update.js +0 -95
  191. package/dist/apps/local-coding-host/src/host-update.js.map +0 -1
  192. package/dist/apps/local-coding-host/src/installer.d.ts +0 -28
  193. package/dist/apps/local-coding-host/src/installer.d.ts.map +0 -1
  194. package/dist/apps/local-coding-host/src/installer.js +0 -346
  195. package/dist/apps/local-coding-host/src/installer.js.map +0 -1
  196. package/dist/apps/local-coding-host/src/linux-service.d.ts +0 -14
  197. package/dist/apps/local-coding-host/src/linux-service.d.ts.map +0 -1
  198. package/dist/apps/local-coding-host/src/linux-service.js +0 -63
  199. package/dist/apps/local-coding-host/src/linux-service.js.map +0 -1
  200. package/dist/apps/local-coding-host/src/live-employee.d.ts +0 -17
  201. package/dist/apps/local-coding-host/src/live-employee.d.ts.map +0 -1
  202. package/dist/apps/local-coding-host/src/live-employee.js +0 -74
  203. package/dist/apps/local-coding-host/src/live-employee.js.map +0 -1
  204. package/dist/apps/local-coding-host/src/local-employee-runtime.d.ts +0 -30
  205. package/dist/apps/local-coding-host/src/local-employee-runtime.d.ts.map +0 -1
  206. package/dist/apps/local-coding-host/src/local-employee-runtime.js +0 -521
  207. package/dist/apps/local-coding-host/src/local-employee-runtime.js.map +0 -1
  208. package/dist/apps/local-coding-host/src/local-handoff-workspace.d.ts +0 -27
  209. package/dist/apps/local-coding-host/src/local-handoff-workspace.d.ts.map +0 -1
  210. package/dist/apps/local-coding-host/src/local-handoff-workspace.js +0 -71
  211. package/dist/apps/local-coding-host/src/local-handoff-workspace.js.map +0 -1
  212. package/dist/apps/local-coding-host/src/local-mcp.d.ts +0 -246
  213. package/dist/apps/local-coding-host/src/local-mcp.d.ts.map +0 -1
  214. package/dist/apps/local-coding-host/src/local-mcp.js +0 -173
  215. package/dist/apps/local-coding-host/src/local-mcp.js.map +0 -1
  216. package/dist/apps/local-coding-host/src/local-model-usage.d.ts +0 -6
  217. package/dist/apps/local-coding-host/src/local-model-usage.d.ts.map +0 -1
  218. package/dist/apps/local-coding-host/src/local-model-usage.js +0 -40
  219. package/dist/apps/local-coding-host/src/local-model-usage.js.map +0 -1
  220. package/dist/apps/local-coding-host/src/login-url.d.ts +0 -3
  221. package/dist/apps/local-coding-host/src/login-url.d.ts.map +0 -1
  222. package/dist/apps/local-coding-host/src/login-url.js +0 -30
  223. package/dist/apps/local-coding-host/src/login-url.js.map +0 -1
  224. package/dist/apps/local-coding-host/src/managed-process.d.ts +0 -21
  225. package/dist/apps/local-coding-host/src/managed-process.d.ts.map +0 -1
  226. package/dist/apps/local-coding-host/src/managed-process.js +0 -119
  227. package/dist/apps/local-coding-host/src/managed-process.js.map +0 -1
  228. package/dist/apps/local-coding-host/src/merge-requests.d.ts +0 -54
  229. package/dist/apps/local-coding-host/src/merge-requests.d.ts.map +0 -1
  230. package/dist/apps/local-coding-host/src/merge-requests.js +0 -230
  231. package/dist/apps/local-coding-host/src/merge-requests.js.map +0 -1
  232. package/dist/apps/local-coding-host/src/model-stores.d.ts +0 -20
  233. package/dist/apps/local-coding-host/src/model-stores.d.ts.map +0 -1
  234. package/dist/apps/local-coding-host/src/model-stores.js +0 -77
  235. package/dist/apps/local-coding-host/src/model-stores.js.map +0 -1
  236. package/dist/apps/local-coding-host/src/open-browser.d.ts +0 -2
  237. package/dist/apps/local-coding-host/src/open-browser.d.ts.map +0 -1
  238. package/dist/apps/local-coding-host/src/open-browser.js +0 -20
  239. package/dist/apps/local-coding-host/src/open-browser.js.map +0 -1
  240. package/dist/apps/local-coding-host/src/operation-context.d.ts +0 -31
  241. package/dist/apps/local-coding-host/src/operation-context.d.ts.map +0 -1
  242. package/dist/apps/local-coding-host/src/operation-context.js +0 -166
  243. package/dist/apps/local-coding-host/src/operation-context.js.map +0 -1
  244. package/dist/apps/local-coding-host/src/outcome-cli.d.ts +0 -3
  245. package/dist/apps/local-coding-host/src/outcome-cli.d.ts.map +0 -1
  246. package/dist/apps/local-coding-host/src/outcome-cli.js +0 -91
  247. package/dist/apps/local-coding-host/src/outcome-cli.js.map +0 -1
  248. package/dist/apps/local-coding-host/src/paths.d.ts +0 -30
  249. package/dist/apps/local-coding-host/src/paths.d.ts.map +0 -1
  250. package/dist/apps/local-coding-host/src/paths.js +0 -52
  251. package/dist/apps/local-coding-host/src/paths.js.map +0 -1
  252. package/dist/apps/local-coding-host/src/pi-message-queue.d.ts +0 -20
  253. package/dist/apps/local-coding-host/src/pi-message-queue.d.ts.map +0 -1
  254. package/dist/apps/local-coding-host/src/pi-message-queue.js +0 -78
  255. package/dist/apps/local-coding-host/src/pi-message-queue.js.map +0 -1
  256. package/dist/apps/local-coding-host/src/pi-model-service.d.ts +0 -91
  257. package/dist/apps/local-coding-host/src/pi-model-service.d.ts.map +0 -1
  258. package/dist/apps/local-coding-host/src/pi-model-service.js +0 -372
  259. package/dist/apps/local-coding-host/src/pi-model-service.js.map +0 -1
  260. package/dist/apps/local-coding-host/src/platform-client.d.ts +0 -398
  261. package/dist/apps/local-coding-host/src/platform-client.d.ts.map +0 -1
  262. package/dist/apps/local-coding-host/src/platform-client.js +0 -255
  263. package/dist/apps/local-coding-host/src/platform-client.js.map +0 -1
  264. package/dist/apps/local-coding-host/src/platform-gitlab-credential.d.ts +0 -8
  265. package/dist/apps/local-coding-host/src/platform-gitlab-credential.d.ts.map +0 -1
  266. package/dist/apps/local-coding-host/src/platform-gitlab-credential.js +0 -31
  267. package/dist/apps/local-coding-host/src/platform-gitlab-credential.js.map +0 -1
  268. package/dist/apps/local-coding-host/src/platform.d.ts +0 -2
  269. package/dist/apps/local-coding-host/src/platform.d.ts.map +0 -1
  270. package/dist/apps/local-coding-host/src/platform.js +0 -15
  271. package/dist/apps/local-coding-host/src/platform.js.map +0 -1
  272. package/dist/apps/local-coding-host/src/profile.d.ts +0 -9
  273. package/dist/apps/local-coding-host/src/profile.d.ts.map +0 -1
  274. package/dist/apps/local-coding-host/src/profile.js +0 -43
  275. package/dist/apps/local-coding-host/src/profile.js.map +0 -1
  276. package/dist/apps/local-coding-host/src/project-facts.d.ts +0 -20
  277. package/dist/apps/local-coding-host/src/project-facts.d.ts.map +0 -1
  278. package/dist/apps/local-coding-host/src/project-facts.js +0 -94
  279. package/dist/apps/local-coding-host/src/project-facts.js.map +0 -1
  280. package/dist/apps/local-coding-host/src/provider-auth-error.d.ts +0 -3
  281. package/dist/apps/local-coding-host/src/provider-auth-error.d.ts.map +0 -1
  282. package/dist/apps/local-coding-host/src/provider-auth-error.js +0 -12
  283. package/dist/apps/local-coding-host/src/provider-auth-error.js.map +0 -1
  284. package/dist/apps/local-coding-host/src/qa-contract.d.ts +0 -2
  285. package/dist/apps/local-coding-host/src/qa-contract.d.ts.map +0 -1
  286. package/dist/apps/local-coding-host/src/qa-contract.js +0 -3
  287. package/dist/apps/local-coding-host/src/qa-contract.js.map +0 -1
  288. package/dist/apps/local-coding-host/src/qa-project-checkout.d.ts +0 -16
  289. package/dist/apps/local-coding-host/src/qa-project-checkout.d.ts.map +0 -1
  290. package/dist/apps/local-coding-host/src/qa-project-checkout.js +0 -92
  291. package/dist/apps/local-coding-host/src/qa-project-checkout.js.map +0 -1
  292. package/dist/apps/local-coding-host/src/qa-session-manager.d.ts +0 -83
  293. package/dist/apps/local-coding-host/src/qa-session-manager.d.ts.map +0 -1
  294. package/dist/apps/local-coding-host/src/qa-session-manager.js +0 -782
  295. package/dist/apps/local-coding-host/src/qa-session-manager.js.map +0 -1
  296. package/dist/apps/local-coding-host/src/run-resources.d.ts +0 -17
  297. package/dist/apps/local-coding-host/src/run-resources.d.ts.map +0 -1
  298. package/dist/apps/local-coding-host/src/run-resources.js +0 -115
  299. package/dist/apps/local-coding-host/src/run-resources.js.map +0 -1
  300. package/dist/apps/local-coding-host/src/runtime-cleanup.d.ts +0 -5
  301. package/dist/apps/local-coding-host/src/runtime-cleanup.d.ts.map +0 -1
  302. package/dist/apps/local-coding-host/src/runtime-cleanup.js +0 -187
  303. package/dist/apps/local-coding-host/src/runtime-cleanup.js.map +0 -1
  304. package/dist/apps/local-coding-host/src/runtime-environment.d.ts +0 -2
  305. package/dist/apps/local-coding-host/src/runtime-environment.d.ts.map +0 -1
  306. package/dist/apps/local-coding-host/src/runtime-environment.js +0 -7
  307. package/dist/apps/local-coding-host/src/runtime-environment.js.map +0 -1
  308. package/dist/apps/local-coding-host/src/runtime-search-tools.d.ts +0 -3
  309. package/dist/apps/local-coding-host/src/runtime-search-tools.d.ts.map +0 -1
  310. package/dist/apps/local-coding-host/src/runtime-search-tools.js +0 -30
  311. package/dist/apps/local-coding-host/src/runtime-search-tools.js.map +0 -1
  312. package/dist/apps/local-coding-host/src/secure-json.d.ts +0 -12
  313. package/dist/apps/local-coding-host/src/secure-json.d.ts.map +0 -1
  314. package/dist/apps/local-coding-host/src/secure-json.js +0 -129
  315. package/dist/apps/local-coding-host/src/secure-json.js.map +0 -1
  316. package/dist/apps/local-coding-host/src/self-check.d.ts +0 -3
  317. package/dist/apps/local-coding-host/src/self-check.d.ts.map +0 -1
  318. package/dist/apps/local-coding-host/src/self-check.js +0 -9
  319. package/dist/apps/local-coding-host/src/self-check.js.map +0 -1
  320. package/dist/apps/local-coding-host/src/skill-bundle-cache.d.ts +0 -11
  321. package/dist/apps/local-coding-host/src/skill-bundle-cache.d.ts.map +0 -1
  322. package/dist/apps/local-coding-host/src/skill-bundle-cache.js +0 -76
  323. package/dist/apps/local-coding-host/src/skill-bundle-cache.js.map +0 -1
  324. package/dist/apps/local-coding-host/src/skill-storage.d.ts +0 -18
  325. package/dist/apps/local-coding-host/src/skill-storage.d.ts.map +0 -1
  326. package/dist/apps/local-coding-host/src/skill-storage.js +0 -287
  327. package/dist/apps/local-coding-host/src/skill-storage.js.map +0 -1
  328. package/dist/apps/local-coding-host/src/stage-delivery.d.ts +0 -2
  329. package/dist/apps/local-coding-host/src/stage-delivery.d.ts.map +0 -1
  330. package/dist/apps/local-coding-host/src/stage-delivery.js +0 -3
  331. package/dist/apps/local-coding-host/src/stage-delivery.js.map +0 -1
  332. package/dist/apps/local-coding-host/src/state.d.ts +0 -55
  333. package/dist/apps/local-coding-host/src/state.d.ts.map +0 -1
  334. package/dist/apps/local-coding-host/src/state.js +0 -151
  335. package/dist/apps/local-coding-host/src/state.js.map +0 -1
  336. package/dist/apps/local-coding-host/src/storage-maintenance.d.ts +0 -13
  337. package/dist/apps/local-coding-host/src/storage-maintenance.d.ts.map +0 -1
  338. package/dist/apps/local-coding-host/src/storage-maintenance.js +0 -62
  339. package/dist/apps/local-coding-host/src/storage-maintenance.js.map +0 -1
  340. package/dist/apps/local-coding-host/src/test-cli.d.ts +0 -2
  341. package/dist/apps/local-coding-host/src/test-cli.d.ts.map +0 -1
  342. package/dist/apps/local-coding-host/src/test-cli.js +0 -48
  343. package/dist/apps/local-coding-host/src/test-cli.js.map +0 -1
  344. package/dist/apps/local-coding-host/src/test-executor.d.ts +0 -41
  345. package/dist/apps/local-coding-host/src/test-executor.d.ts.map +0 -1
  346. package/dist/apps/local-coding-host/src/test-executor.js +0 -483
  347. package/dist/apps/local-coding-host/src/test-executor.js.map +0 -1
  348. package/dist/apps/local-coding-host/src/test-reports.d.ts +0 -25
  349. package/dist/apps/local-coding-host/src/test-reports.d.ts.map +0 -1
  350. package/dist/apps/local-coding-host/src/test-reports.js +0 -129
  351. package/dist/apps/local-coding-host/src/test-reports.js.map +0 -1
  352. package/dist/apps/local-coding-host/src/test-run-manager.d.ts +0 -34
  353. package/dist/apps/local-coding-host/src/test-run-manager.d.ts.map +0 -1
  354. package/dist/apps/local-coding-host/src/test-run-manager.js +0 -180
  355. package/dist/apps/local-coding-host/src/test-run-manager.js.map +0 -1
  356. package/dist/apps/local-coding-host/src/tool-dispatch.d.ts +0 -14
  357. package/dist/apps/local-coding-host/src/tool-dispatch.d.ts.map +0 -1
  358. package/dist/apps/local-coding-host/src/tool-dispatch.js +0 -59
  359. package/dist/apps/local-coding-host/src/tool-dispatch.js.map +0 -1
  360. package/dist/apps/local-coding-host/src/tool-probe.d.ts +0 -31
  361. package/dist/apps/local-coding-host/src/tool-probe.d.ts.map +0 -1
  362. package/dist/apps/local-coding-host/src/tool-probe.js +0 -95
  363. package/dist/apps/local-coding-host/src/tool-probe.js.map +0 -1
  364. package/dist/apps/local-coding-host/src/windows-runtime.d.ts +0 -9
  365. package/dist/apps/local-coding-host/src/windows-runtime.d.ts.map +0 -1
  366. package/dist/apps/local-coding-host/src/windows-runtime.js +0 -64
  367. package/dist/apps/local-coding-host/src/windows-runtime.js.map +0 -1
  368. package/dist/apps/local-coding-host/src/windows-service.d.ts +0 -22
  369. package/dist/apps/local-coding-host/src/windows-service.d.ts.map +0 -1
  370. package/dist/apps/local-coding-host/src/windows-service.js +0 -126
  371. package/dist/apps/local-coding-host/src/windows-service.js.map +0 -1
  372. package/dist/apps/local-coding-host/src/workflow-guidance.d.ts +0 -2
  373. package/dist/apps/local-coding-host/src/workflow-guidance.d.ts.map +0 -1
  374. package/dist/apps/local-coding-host/src/workflow-guidance.js +0 -3
  375. package/dist/apps/local-coding-host/src/workflow-guidance.js.map +0 -1
  376. package/dist/apps/local-coding-host/src/workspace-diff.d.ts +0 -6
  377. package/dist/apps/local-coding-host/src/workspace-diff.d.ts.map +0 -1
  378. package/dist/apps/local-coding-host/src/workspace-diff.js +0 -280
  379. package/dist/apps/local-coding-host/src/workspace-diff.js.map +0 -1
  380. package/dist/apps/local-coding-host/src/workspace-gc.d.ts +0 -25
  381. package/dist/apps/local-coding-host/src/workspace-gc.d.ts.map +0 -1
  382. package/dist/apps/local-coding-host/src/workspace-gc.js +0 -417
  383. package/dist/apps/local-coding-host/src/workspace-gc.js.map +0 -1
  384. package/dist/apps/local-coding-host/tests/bash-discovery.test.d.ts +0 -2
  385. package/dist/apps/local-coding-host/tests/bash-discovery.test.d.ts.map +0 -1
  386. package/dist/apps/local-coding-host/tests/bash-discovery.test.js +0 -36
  387. package/dist/apps/local-coding-host/tests/bash-discovery.test.js.map +0 -1
  388. package/dist/apps/local-coding-host/tests/cli-startup.test.d.ts +0 -2
  389. package/dist/apps/local-coding-host/tests/cli-startup.test.d.ts.map +0 -1
  390. package/dist/apps/local-coding-host/tests/cli-startup.test.js +0 -176
  391. package/dist/apps/local-coding-host/tests/cli-startup.test.js.map +0 -1
  392. package/dist/apps/local-coding-host/tests/coding-run-manager.test.d.ts +0 -2
  393. package/dist/apps/local-coding-host/tests/coding-run-manager.test.d.ts.map +0 -1
  394. package/dist/apps/local-coding-host/tests/coding-run-manager.test.js +0 -3211
  395. package/dist/apps/local-coding-host/tests/coding-run-manager.test.js.map +0 -1
  396. package/dist/apps/local-coding-host/tests/coding-subagent-child.test.d.ts +0 -2
  397. package/dist/apps/local-coding-host/tests/coding-subagent-child.test.d.ts.map +0 -1
  398. package/dist/apps/local-coding-host/tests/coding-subagent-child.test.js +0 -223
  399. package/dist/apps/local-coding-host/tests/coding-subagent-child.test.js.map +0 -1
  400. package/dist/apps/local-coding-host/tests/coding-subagents.integration.test.d.ts +0 -2
  401. package/dist/apps/local-coding-host/tests/coding-subagents.integration.test.d.ts.map +0 -1
  402. package/dist/apps/local-coding-host/tests/coding-subagents.integration.test.js +0 -390
  403. package/dist/apps/local-coding-host/tests/coding-subagents.integration.test.js.map +0 -1
  404. package/dist/apps/local-coding-host/tests/command-wakeup.test.d.ts +0 -2
  405. package/dist/apps/local-coding-host/tests/command-wakeup.test.d.ts.map +0 -1
  406. package/dist/apps/local-coding-host/tests/command-wakeup.test.js +0 -148
  407. package/dist/apps/local-coding-host/tests/command-wakeup.test.js.map +0 -1
  408. package/dist/apps/local-coding-host/tests/daemon-wakeup.test.d.ts +0 -2
  409. package/dist/apps/local-coding-host/tests/daemon-wakeup.test.d.ts.map +0 -1
  410. package/dist/apps/local-coding-host/tests/daemon-wakeup.test.js +0 -636
  411. package/dist/apps/local-coding-host/tests/daemon-wakeup.test.js.map +0 -1
  412. package/dist/apps/local-coding-host/tests/database-tool-transport.test.d.ts +0 -2
  413. package/dist/apps/local-coding-host/tests/database-tool-transport.test.d.ts.map +0 -1
  414. package/dist/apps/local-coding-host/tests/database-tool-transport.test.js +0 -37
  415. package/dist/apps/local-coding-host/tests/database-tool-transport.test.js.map +0 -1
  416. package/dist/apps/local-coding-host/tests/delivery-files.test.d.ts +0 -2
  417. package/dist/apps/local-coding-host/tests/delivery-files.test.d.ts.map +0 -1
  418. package/dist/apps/local-coding-host/tests/delivery-files.test.js +0 -655
  419. package/dist/apps/local-coding-host/tests/delivery-files.test.js.map +0 -1
  420. package/dist/apps/local-coding-host/tests/device-gitlab-sync.test.d.ts +0 -2
  421. package/dist/apps/local-coding-host/tests/device-gitlab-sync.test.d.ts.map +0 -1
  422. package/dist/apps/local-coding-host/tests/device-gitlab-sync.test.js +0 -116
  423. package/dist/apps/local-coding-host/tests/device-gitlab-sync.test.js.map +0 -1
  424. package/dist/apps/local-coding-host/tests/diagnostic-logging.test.d.ts +0 -2
  425. package/dist/apps/local-coding-host/tests/diagnostic-logging.test.d.ts.map +0 -1
  426. package/dist/apps/local-coding-host/tests/diagnostic-logging.test.js +0 -143
  427. package/dist/apps/local-coding-host/tests/diagnostic-logging.test.js.map +0 -1
  428. package/dist/apps/local-coding-host/tests/execution-process.test.d.ts +0 -2
  429. package/dist/apps/local-coding-host/tests/execution-process.test.d.ts.map +0 -1
  430. package/dist/apps/local-coding-host/tests/execution-process.test.js +0 -127
  431. package/dist/apps/local-coding-host/tests/execution-process.test.js.map +0 -1
  432. package/dist/apps/local-coding-host/tests/execution-receipts.test.d.ts +0 -2
  433. package/dist/apps/local-coding-host/tests/execution-receipts.test.d.ts.map +0 -1
  434. package/dist/apps/local-coding-host/tests/execution-receipts.test.js +0 -72
  435. package/dist/apps/local-coding-host/tests/execution-receipts.test.js.map +0 -1
  436. package/dist/apps/local-coding-host/tests/execution-supervisor.test.d.ts +0 -2
  437. package/dist/apps/local-coding-host/tests/execution-supervisor.test.d.ts.map +0 -1
  438. package/dist/apps/local-coding-host/tests/execution-supervisor.test.js +0 -488
  439. package/dist/apps/local-coding-host/tests/execution-supervisor.test.js.map +0 -1
  440. package/dist/apps/local-coding-host/tests/general-employee-fixture.d.ts +0 -3
  441. package/dist/apps/local-coding-host/tests/general-employee-fixture.d.ts.map +0 -1
  442. package/dist/apps/local-coding-host/tests/general-employee-fixture.js +0 -43
  443. package/dist/apps/local-coding-host/tests/general-employee-fixture.js.map +0 -1
  444. package/dist/apps/local-coding-host/tests/general-run-manager.test.d.ts +0 -2
  445. package/dist/apps/local-coding-host/tests/general-run-manager.test.d.ts.map +0 -1
  446. package/dist/apps/local-coding-host/tests/general-run-manager.test.js +0 -506
  447. package/dist/apps/local-coding-host/tests/general-run-manager.test.js.map +0 -1
  448. package/dist/apps/local-coding-host/tests/general-run-supervisor.test.d.ts +0 -2
  449. package/dist/apps/local-coding-host/tests/general-run-supervisor.test.d.ts.map +0 -1
  450. package/dist/apps/local-coding-host/tests/general-run-supervisor.test.js +0 -252
  451. package/dist/apps/local-coding-host/tests/general-run-supervisor.test.js.map +0 -1
  452. package/dist/apps/local-coding-host/tests/general-run-tools.test.d.ts +0 -2
  453. package/dist/apps/local-coding-host/tests/general-run-tools.test.d.ts.map +0 -1
  454. package/dist/apps/local-coding-host/tests/general-run-tools.test.js +0 -202
  455. package/dist/apps/local-coding-host/tests/general-run-tools.test.js.map +0 -1
  456. package/dist/apps/local-coding-host/tests/general-run.integration.test.d.ts +0 -2
  457. package/dist/apps/local-coding-host/tests/general-run.integration.test.d.ts.map +0 -1
  458. package/dist/apps/local-coding-host/tests/general-run.integration.test.js +0 -150
  459. package/dist/apps/local-coding-host/tests/general-run.integration.test.js.map +0 -1
  460. package/dist/apps/local-coding-host/tests/git-http-migration.test.d.ts +0 -2
  461. package/dist/apps/local-coding-host/tests/git-http-migration.test.d.ts.map +0 -1
  462. package/dist/apps/local-coding-host/tests/git-http-migration.test.js +0 -140
  463. package/dist/apps/local-coding-host/tests/git-http-migration.test.js.map +0 -1
  464. package/dist/apps/local-coding-host/tests/git-process.test.d.ts +0 -2
  465. package/dist/apps/local-coding-host/tests/git-process.test.d.ts.map +0 -1
  466. package/dist/apps/local-coding-host/tests/git-process.test.js +0 -106
  467. package/dist/apps/local-coding-host/tests/git-process.test.js.map +0 -1
  468. package/dist/apps/local-coding-host/tests/git-transport.test.d.ts +0 -2
  469. package/dist/apps/local-coding-host/tests/git-transport.test.d.ts.map +0 -1
  470. package/dist/apps/local-coding-host/tests/git-transport.test.js +0 -56
  471. package/dist/apps/local-coding-host/tests/git-transport.test.js.map +0 -1
  472. package/dist/apps/local-coding-host/tests/gitlab-credentials.test.d.ts +0 -2
  473. package/dist/apps/local-coding-host/tests/gitlab-credentials.test.d.ts.map +0 -1
  474. package/dist/apps/local-coding-host/tests/gitlab-credentials.test.js +0 -130
  475. package/dist/apps/local-coding-host/tests/gitlab-credentials.test.js.map +0 -1
  476. package/dist/apps/local-coding-host/tests/gitlab-platform-credentials.test.d.ts +0 -2
  477. package/dist/apps/local-coding-host/tests/gitlab-platform-credentials.test.d.ts.map +0 -1
  478. package/dist/apps/local-coding-host/tests/gitlab-platform-credentials.test.js +0 -273
  479. package/dist/apps/local-coding-host/tests/gitlab-platform-credentials.test.js.map +0 -1
  480. package/dist/apps/local-coding-host/tests/host-log.test.d.ts +0 -2
  481. package/dist/apps/local-coding-host/tests/host-log.test.d.ts.map +0 -1
  482. package/dist/apps/local-coding-host/tests/host-log.test.js +0 -51
  483. package/dist/apps/local-coding-host/tests/host-log.test.js.map +0 -1
  484. package/dist/apps/local-coding-host/tests/host-status-workspace.test.d.ts +0 -2
  485. package/dist/apps/local-coding-host/tests/host-status-workspace.test.d.ts.map +0 -1
  486. package/dist/apps/local-coding-host/tests/host-status-workspace.test.js +0 -256
  487. package/dist/apps/local-coding-host/tests/host-status-workspace.test.js.map +0 -1
  488. package/dist/apps/local-coding-host/tests/host-tool-stages.test.d.ts +0 -2
  489. package/dist/apps/local-coding-host/tests/host-tool-stages.test.d.ts.map +0 -1
  490. package/dist/apps/local-coding-host/tests/host-tool-stages.test.js +0 -82
  491. package/dist/apps/local-coding-host/tests/host-tool-stages.test.js.map +0 -1
  492. package/dist/apps/local-coding-host/tests/host-tools-logging.test.d.ts +0 -2
  493. package/dist/apps/local-coding-host/tests/host-tools-logging.test.d.ts.map +0 -1
  494. package/dist/apps/local-coding-host/tests/host-tools-logging.test.js +0 -110
  495. package/dist/apps/local-coding-host/tests/host-tools-logging.test.js.map +0 -1
  496. package/dist/apps/local-coding-host/tests/host-tools.test.d.ts +0 -2
  497. package/dist/apps/local-coding-host/tests/host-tools.test.d.ts.map +0 -1
  498. package/dist/apps/local-coding-host/tests/host-tools.test.js +0 -96
  499. package/dist/apps/local-coding-host/tests/host-tools.test.js.map +0 -1
  500. package/dist/apps/local-coding-host/tests/host-update.test.d.ts +0 -2
  501. package/dist/apps/local-coding-host/tests/host-update.test.d.ts.map +0 -1
  502. package/dist/apps/local-coding-host/tests/host-update.test.js +0 -102
  503. package/dist/apps/local-coding-host/tests/host-update.test.js.map +0 -1
  504. package/dist/apps/local-coding-host/tests/install-scripts.test.d.ts +0 -2
  505. package/dist/apps/local-coding-host/tests/install-scripts.test.d.ts.map +0 -1
  506. package/dist/apps/local-coding-host/tests/install-scripts.test.js +0 -80
  507. package/dist/apps/local-coding-host/tests/install-scripts.test.js.map +0 -1
  508. package/dist/apps/local-coding-host/tests/linux-service.test.d.ts +0 -2
  509. package/dist/apps/local-coding-host/tests/linux-service.test.d.ts.map +0 -1
  510. package/dist/apps/local-coding-host/tests/linux-service.test.js +0 -32
  511. package/dist/apps/local-coding-host/tests/linux-service.test.js.map +0 -1
  512. package/dist/apps/local-coding-host/tests/live-employee.test.d.ts +0 -2
  513. package/dist/apps/local-coding-host/tests/live-employee.test.d.ts.map +0 -1
  514. package/dist/apps/local-coding-host/tests/live-employee.test.js +0 -739
  515. package/dist/apps/local-coding-host/tests/live-employee.test.js.map +0 -1
  516. package/dist/apps/local-coding-host/tests/local-handoff-workspace-errors.test.d.ts +0 -2
  517. package/dist/apps/local-coding-host/tests/local-handoff-workspace-errors.test.d.ts.map +0 -1
  518. package/dist/apps/local-coding-host/tests/local-handoff-workspace-errors.test.js +0 -33
  519. package/dist/apps/local-coding-host/tests/local-handoff-workspace-errors.test.js.map +0 -1
  520. package/dist/apps/local-coding-host/tests/local-handoff-workspace.test.d.ts +0 -2
  521. package/dist/apps/local-coding-host/tests/local-handoff-workspace.test.d.ts.map +0 -1
  522. package/dist/apps/local-coding-host/tests/local-handoff-workspace.test.js +0 -67
  523. package/dist/apps/local-coding-host/tests/local-handoff-workspace.test.js.map +0 -1
  524. package/dist/apps/local-coding-host/tests/local-host.test.d.ts +0 -2
  525. package/dist/apps/local-coding-host/tests/local-host.test.d.ts.map +0 -1
  526. package/dist/apps/local-coding-host/tests/local-host.test.js +0 -1009
  527. package/dist/apps/local-coding-host/tests/local-host.test.js.map +0 -1
  528. package/dist/apps/local-coding-host/tests/local-intake-recovery.test.d.ts +0 -2
  529. package/dist/apps/local-coding-host/tests/local-intake-recovery.test.d.ts.map +0 -1
  530. package/dist/apps/local-coding-host/tests/local-intake-recovery.test.js +0 -71
  531. package/dist/apps/local-coding-host/tests/local-intake-recovery.test.js.map +0 -1
  532. package/dist/apps/local-coding-host/tests/local-mcp.test.d.ts +0 -2
  533. package/dist/apps/local-coding-host/tests/local-mcp.test.d.ts.map +0 -1
  534. package/dist/apps/local-coding-host/tests/local-mcp.test.js +0 -193
  535. package/dist/apps/local-coding-host/tests/local-mcp.test.js.map +0 -1
  536. package/dist/apps/local-coding-host/tests/local-model-usage.test.d.ts +0 -2
  537. package/dist/apps/local-coding-host/tests/local-model-usage.test.d.ts.map +0 -1
  538. package/dist/apps/local-coding-host/tests/local-model-usage.test.js +0 -55
  539. package/dist/apps/local-coding-host/tests/local-model-usage.test.js.map +0 -1
  540. package/dist/apps/local-coding-host/tests/local-outcome-workspace.test.d.ts +0 -2
  541. package/dist/apps/local-coding-host/tests/local-outcome-workspace.test.d.ts.map +0 -1
  542. package/dist/apps/local-coding-host/tests/local-outcome-workspace.test.js +0 -87
  543. package/dist/apps/local-coding-host/tests/local-outcome-workspace.test.js.map +0 -1
  544. package/dist/apps/local-coding-host/tests/login-url.test.d.ts +0 -2
  545. package/dist/apps/local-coding-host/tests/login-url.test.d.ts.map +0 -1
  546. package/dist/apps/local-coding-host/tests/login-url.test.js +0 -82
  547. package/dist/apps/local-coding-host/tests/login-url.test.js.map +0 -1
  548. package/dist/apps/local-coding-host/tests/material-fixture.d.ts +0 -13
  549. package/dist/apps/local-coding-host/tests/material-fixture.d.ts.map +0 -1
  550. package/dist/apps/local-coding-host/tests/material-fixture.js +0 -32
  551. package/dist/apps/local-coding-host/tests/material-fixture.js.map +0 -1
  552. package/dist/apps/local-coding-host/tests/merge-requests.test.d.ts +0 -2
  553. package/dist/apps/local-coding-host/tests/merge-requests.test.d.ts.map +0 -1
  554. package/dist/apps/local-coding-host/tests/merge-requests.test.js +0 -318
  555. package/dist/apps/local-coding-host/tests/merge-requests.test.js.map +0 -1
  556. package/dist/apps/local-coding-host/tests/model-stores.test.d.ts +0 -2
  557. package/dist/apps/local-coding-host/tests/model-stores.test.d.ts.map +0 -1
  558. package/dist/apps/local-coding-host/tests/model-stores.test.js +0 -152
  559. package/dist/apps/local-coding-host/tests/model-stores.test.js.map +0 -1
  560. package/dist/apps/local-coding-host/tests/operation-context.test.d.ts +0 -2
  561. package/dist/apps/local-coding-host/tests/operation-context.test.d.ts.map +0 -1
  562. package/dist/apps/local-coding-host/tests/operation-context.test.js +0 -171
  563. package/dist/apps/local-coding-host/tests/operation-context.test.js.map +0 -1
  564. package/dist/apps/local-coding-host/tests/outcome-cli.test.d.ts +0 -2
  565. package/dist/apps/local-coding-host/tests/outcome-cli.test.d.ts.map +0 -1
  566. package/dist/apps/local-coding-host/tests/outcome-cli.test.js +0 -208
  567. package/dist/apps/local-coding-host/tests/outcome-cli.test.js.map +0 -1
  568. package/dist/apps/local-coding-host/tests/pi-message-queue.test.d.ts +0 -2
  569. package/dist/apps/local-coding-host/tests/pi-message-queue.test.d.ts.map +0 -1
  570. package/dist/apps/local-coding-host/tests/pi-message-queue.test.js +0 -91
  571. package/dist/apps/local-coding-host/tests/pi-message-queue.test.js.map +0 -1
  572. package/dist/apps/local-coding-host/tests/pi-model-switch.test.d.ts +0 -2
  573. package/dist/apps/local-coding-host/tests/pi-model-switch.test.d.ts.map +0 -1
  574. package/dist/apps/local-coding-host/tests/pi-model-switch.test.js +0 -244
  575. package/dist/apps/local-coding-host/tests/pi-model-switch.test.js.map +0 -1
  576. package/dist/apps/local-coding-host/tests/pi-native-capabilities.test.d.ts +0 -2
  577. package/dist/apps/local-coding-host/tests/pi-native-capabilities.test.d.ts.map +0 -1
  578. package/dist/apps/local-coding-host/tests/pi-native-capabilities.test.js +0 -75
  579. package/dist/apps/local-coding-host/tests/pi-native-capabilities.test.js.map +0 -1
  580. package/dist/apps/local-coding-host/tests/pi-overflow-recovery.test.d.ts +0 -2
  581. package/dist/apps/local-coding-host/tests/pi-overflow-recovery.test.d.ts.map +0 -1
  582. package/dist/apps/local-coding-host/tests/pi-overflow-recovery.test.js +0 -183
  583. package/dist/apps/local-coding-host/tests/pi-overflow-recovery.test.js.map +0 -1
  584. package/dist/apps/local-coding-host/tests/pi-session-restore.test.d.ts +0 -2
  585. package/dist/apps/local-coding-host/tests/pi-session-restore.test.d.ts.map +0 -1
  586. package/dist/apps/local-coding-host/tests/pi-session-restore.test.js +0 -84
  587. package/dist/apps/local-coding-host/tests/pi-session-restore.test.js.map +0 -1
  588. package/dist/apps/local-coding-host/tests/platform-client-status.test.d.ts +0 -2
  589. package/dist/apps/local-coding-host/tests/platform-client-status.test.d.ts.map +0 -1
  590. package/dist/apps/local-coding-host/tests/platform-client-status.test.js +0 -29
  591. package/dist/apps/local-coding-host/tests/platform-client-status.test.js.map +0 -1
  592. package/dist/apps/local-coding-host/tests/platform-models.test.d.ts +0 -2
  593. package/dist/apps/local-coding-host/tests/platform-models.test.d.ts.map +0 -1
  594. package/dist/apps/local-coding-host/tests/platform-models.test.js +0 -395
  595. package/dist/apps/local-coding-host/tests/platform-models.test.js.map +0 -1
  596. package/dist/apps/local-coding-host/tests/powershell-resolution.test.d.ts +0 -2
  597. package/dist/apps/local-coding-host/tests/powershell-resolution.test.d.ts.map +0 -1
  598. package/dist/apps/local-coding-host/tests/powershell-resolution.test.js +0 -138
  599. package/dist/apps/local-coding-host/tests/powershell-resolution.test.js.map +0 -1
  600. package/dist/apps/local-coding-host/tests/profile-installer.test.d.ts +0 -2
  601. package/dist/apps/local-coding-host/tests/profile-installer.test.d.ts.map +0 -1
  602. package/dist/apps/local-coding-host/tests/profile-installer.test.js +0 -88
  603. package/dist/apps/local-coding-host/tests/profile-installer.test.js.map +0 -1
  604. package/dist/apps/local-coding-host/tests/profile.test.d.ts +0 -2
  605. package/dist/apps/local-coding-host/tests/profile.test.d.ts.map +0 -1
  606. package/dist/apps/local-coding-host/tests/profile.test.js +0 -88
  607. package/dist/apps/local-coding-host/tests/profile.test.js.map +0 -1
  608. package/dist/apps/local-coding-host/tests/provider-auth-status.test.d.ts +0 -2
  609. package/dist/apps/local-coding-host/tests/provider-auth-status.test.d.ts.map +0 -1
  610. package/dist/apps/local-coding-host/tests/provider-auth-status.test.js +0 -82
  611. package/dist/apps/local-coding-host/tests/provider-auth-status.test.js.map +0 -1
  612. package/dist/apps/local-coding-host/tests/qa-project-checkout.test.d.ts +0 -2
  613. package/dist/apps/local-coding-host/tests/qa-project-checkout.test.d.ts.map +0 -1
  614. package/dist/apps/local-coding-host/tests/qa-project-checkout.test.js +0 -101
  615. package/dist/apps/local-coding-host/tests/qa-project-checkout.test.js.map +0 -1
  616. package/dist/apps/local-coding-host/tests/qa-session-manager.test.d.ts +0 -2
  617. package/dist/apps/local-coding-host/tests/qa-session-manager.test.d.ts.map +0 -1
  618. package/dist/apps/local-coding-host/tests/qa-session-manager.test.js +0 -1493
  619. package/dist/apps/local-coding-host/tests/qa-session-manager.test.js.map +0 -1
  620. package/dist/apps/local-coding-host/tests/qa-verification-contract.test.d.ts +0 -2
  621. package/dist/apps/local-coding-host/tests/qa-verification-contract.test.d.ts.map +0 -1
  622. package/dist/apps/local-coding-host/tests/qa-verification-contract.test.js +0 -208
  623. package/dist/apps/local-coding-host/tests/qa-verification-contract.test.js.map +0 -1
  624. package/dist/apps/local-coding-host/tests/recovery-workspace.test.d.ts +0 -2
  625. package/dist/apps/local-coding-host/tests/recovery-workspace.test.d.ts.map +0 -1
  626. package/dist/apps/local-coding-host/tests/recovery-workspace.test.js +0 -69
  627. package/dist/apps/local-coding-host/tests/recovery-workspace.test.js.map +0 -1
  628. package/dist/apps/local-coding-host/tests/review-query.test.d.ts +0 -2
  629. package/dist/apps/local-coding-host/tests/review-query.test.d.ts.map +0 -1
  630. package/dist/apps/local-coding-host/tests/review-query.test.js +0 -66
  631. package/dist/apps/local-coding-host/tests/review-query.test.js.map +0 -1
  632. package/dist/apps/local-coding-host/tests/run-resources.test.d.ts +0 -2
  633. package/dist/apps/local-coding-host/tests/run-resources.test.d.ts.map +0 -1
  634. package/dist/apps/local-coding-host/tests/run-resources.test.js +0 -207
  635. package/dist/apps/local-coding-host/tests/run-resources.test.js.map +0 -1
  636. package/dist/apps/local-coding-host/tests/runtime-cleanup.test.d.ts +0 -2
  637. package/dist/apps/local-coding-host/tests/runtime-cleanup.test.d.ts.map +0 -1
  638. package/dist/apps/local-coding-host/tests/runtime-cleanup.test.js +0 -161
  639. package/dist/apps/local-coding-host/tests/runtime-cleanup.test.js.map +0 -1
  640. package/dist/apps/local-coding-host/tests/runtime-package-install.test.d.ts +0 -2
  641. package/dist/apps/local-coding-host/tests/runtime-package-install.test.d.ts.map +0 -1
  642. package/dist/apps/local-coding-host/tests/runtime-package-install.test.js +0 -63
  643. package/dist/apps/local-coding-host/tests/runtime-package-install.test.js.map +0 -1
  644. package/dist/apps/local-coding-host/tests/runtime-version.test.d.ts +0 -2
  645. package/dist/apps/local-coding-host/tests/runtime-version.test.d.ts.map +0 -1
  646. package/dist/apps/local-coding-host/tests/runtime-version.test.js +0 -15
  647. package/dist/apps/local-coding-host/tests/runtime-version.test.js.map +0 -1
  648. package/dist/apps/local-coding-host/tests/secure-json.test.d.ts +0 -2
  649. package/dist/apps/local-coding-host/tests/secure-json.test.d.ts.map +0 -1
  650. package/dist/apps/local-coding-host/tests/secure-json.test.js +0 -64
  651. package/dist/apps/local-coding-host/tests/secure-json.test.js.map +0 -1
  652. package/dist/apps/local-coding-host/tests/skill-storage-gc.test.d.ts +0 -2
  653. package/dist/apps/local-coding-host/tests/skill-storage-gc.test.d.ts.map +0 -1
  654. package/dist/apps/local-coding-host/tests/skill-storage-gc.test.js +0 -312
  655. package/dist/apps/local-coding-host/tests/skill-storage-gc.test.js.map +0 -1
  656. package/dist/apps/local-coding-host/tests/storage-maintenance.test.d.ts +0 -2
  657. package/dist/apps/local-coding-host/tests/storage-maintenance.test.d.ts.map +0 -1
  658. package/dist/apps/local-coding-host/tests/storage-maintenance.test.js +0 -135
  659. package/dist/apps/local-coding-host/tests/storage-maintenance.test.js.map +0 -1
  660. package/dist/apps/local-coding-host/tests/test-executor.test.d.ts +0 -2
  661. package/dist/apps/local-coding-host/tests/test-executor.test.d.ts.map +0 -1
  662. package/dist/apps/local-coding-host/tests/test-executor.test.js +0 -365
  663. package/dist/apps/local-coding-host/tests/test-executor.test.js.map +0 -1
  664. package/dist/apps/local-coding-host/tests/test-reports.test.d.ts +0 -2
  665. package/dist/apps/local-coding-host/tests/test-reports.test.d.ts.map +0 -1
  666. package/dist/apps/local-coding-host/tests/test-reports.test.js +0 -68
  667. package/dist/apps/local-coding-host/tests/test-reports.test.js.map +0 -1
  668. package/dist/apps/local-coding-host/tests/test-run-manager.test.d.ts +0 -2
  669. package/dist/apps/local-coding-host/tests/test-run-manager.test.d.ts.map +0 -1
  670. package/dist/apps/local-coding-host/tests/test-run-manager.test.js +0 -287
  671. package/dist/apps/local-coding-host/tests/test-run-manager.test.js.map +0 -1
  672. package/dist/apps/local-coding-host/tests/tool-dispatch.integration.test.d.ts +0 -2
  673. package/dist/apps/local-coding-host/tests/tool-dispatch.integration.test.d.ts.map +0 -1
  674. package/dist/apps/local-coding-host/tests/tool-dispatch.integration.test.js +0 -224
  675. package/dist/apps/local-coding-host/tests/tool-dispatch.integration.test.js.map +0 -1
  676. package/dist/apps/local-coding-host/tests/tool-dispatch.test.d.ts +0 -2
  677. package/dist/apps/local-coding-host/tests/tool-dispatch.test.d.ts.map +0 -1
  678. package/dist/apps/local-coding-host/tests/tool-dispatch.test.js +0 -47
  679. package/dist/apps/local-coding-host/tests/tool-dispatch.test.js.map +0 -1
  680. package/dist/apps/local-coding-host/tests/tool-probe.test.d.ts +0 -2
  681. package/dist/apps/local-coding-host/tests/tool-probe.test.d.ts.map +0 -1
  682. package/dist/apps/local-coding-host/tests/tool-probe.test.js +0 -55
  683. package/dist/apps/local-coding-host/tests/tool-probe.test.js.map +0 -1
  684. package/dist/apps/local-coding-host/tests/windows-background-check.test.d.ts +0 -2
  685. package/dist/apps/local-coding-host/tests/windows-background-check.test.d.ts.map +0 -1
  686. package/dist/apps/local-coding-host/tests/windows-background-check.test.js +0 -60
  687. package/dist/apps/local-coding-host/tests/windows-background-check.test.js.map +0 -1
  688. package/dist/apps/local-coding-host/tests/windows-install-script.test.d.ts +0 -2
  689. package/dist/apps/local-coding-host/tests/windows-install-script.test.d.ts.map +0 -1
  690. package/dist/apps/local-coding-host/tests/windows-install-script.test.js +0 -170
  691. package/dist/apps/local-coding-host/tests/windows-install-script.test.js.map +0 -1
  692. package/dist/apps/local-coding-host/tests/windows-installer.test.d.ts +0 -2
  693. package/dist/apps/local-coding-host/tests/windows-installer.test.d.ts.map +0 -1
  694. package/dist/apps/local-coding-host/tests/windows-installer.test.js +0 -244
  695. package/dist/apps/local-coding-host/tests/windows-installer.test.js.map +0 -1
  696. package/dist/apps/local-coding-host/tests/windows-task-configuration.test.d.ts +0 -2
  697. package/dist/apps/local-coding-host/tests/windows-task-configuration.test.d.ts.map +0 -1
  698. package/dist/apps/local-coding-host/tests/windows-task-configuration.test.js +0 -34
  699. package/dist/apps/local-coding-host/tests/windows-task-configuration.test.js.map +0 -1
  700. package/dist/apps/local-coding-host/tests/workflow-rule-projection.test.d.ts +0 -2
  701. package/dist/apps/local-coding-host/tests/workflow-rule-projection.test.d.ts.map +0 -1
  702. package/dist/apps/local-coding-host/tests/workflow-rule-projection.test.js +0 -370
  703. package/dist/apps/local-coding-host/tests/workflow-rule-projection.test.js.map +0 -1
  704. package/dist/apps/local-coding-host/tests/workspace-diff.test.d.ts +0 -2
  705. package/dist/apps/local-coding-host/tests/workspace-diff.test.d.ts.map +0 -1
  706. package/dist/apps/local-coding-host/tests/workspace-diff.test.js +0 -166
  707. package/dist/apps/local-coding-host/tests/workspace-diff.test.js.map +0 -1
  708. package/dist/apps/local-coding-host/tests/workspace-gc.test.d.ts +0 -2
  709. package/dist/apps/local-coding-host/tests/workspace-gc.test.d.ts.map +0 -1
  710. package/dist/apps/local-coding-host/tests/workspace-gc.test.js +0 -391
  711. package/dist/apps/local-coding-host/tests/workspace-gc.test.js.map +0 -1
  712. package/dist/services/platform-api/src/coding-run/coding-tool-definitions.d.ts +0 -83
  713. package/dist/services/platform-api/src/coding-run/coding-tool-definitions.d.ts.map +0 -1
  714. package/dist/services/platform-api/src/coding-run/coding-tool-definitions.js +0 -282
  715. package/dist/services/platform-api/src/coding-run/coding-tool-definitions.js.map +0 -1
  716. package/dist/services/platform-api/src/coding-run/delivery-requirements.d.ts +0 -15
  717. package/dist/services/platform-api/src/coding-run/delivery-requirements.d.ts.map +0 -1
  718. package/dist/services/platform-api/src/coding-run/delivery-requirements.js +0 -60
  719. package/dist/services/platform-api/src/coding-run/delivery-requirements.js.map +0 -1
  720. package/dist/services/platform-api/src/coding-run/development-test-report.d.ts +0 -10
  721. package/dist/services/platform-api/src/coding-run/development-test-report.d.ts.map +0 -1
  722. package/dist/services/platform-api/src/coding-run/development-test-report.js +0 -32
  723. package/dist/services/platform-api/src/coding-run/development-test-report.js.map +0 -1
  724. package/dist/services/platform-api/src/coding-run/host-tool-dispatch.d.ts +0 -21
  725. package/dist/services/platform-api/src/coding-run/host-tool-dispatch.d.ts.map +0 -1
  726. package/dist/services/platform-api/src/coding-run/host-tool-dispatch.js +0 -86
  727. package/dist/services/platform-api/src/coding-run/host-tool-dispatch.js.map +0 -1
  728. package/dist/services/platform-api/src/coding-run/workspace-materials.d.ts +0 -37
  729. package/dist/services/platform-api/src/coding-run/workspace-materials.d.ts.map +0 -1
  730. package/dist/services/platform-api/src/coding-run/workspace-materials.js +0 -99
  731. package/dist/services/platform-api/src/coding-run/workspace-materials.js.map +0 -1
  732. package/dist/services/platform-api/src/common/app-exception.d.ts +0 -17
  733. package/dist/services/platform-api/src/common/app-exception.d.ts.map +0 -1
  734. package/dist/services/platform-api/src/common/app-exception.js +0 -46
  735. package/dist/services/platform-api/src/common/app-exception.js.map +0 -1
  736. package/dist/services/platform-api/src/config/environment.d.ts +0 -30
  737. package/dist/services/platform-api/src/config/environment.d.ts.map +0 -1
  738. package/dist/services/platform-api/src/config/environment.js +0 -123
  739. package/dist/services/platform-api/src/config/environment.js.map +0 -1
  740. package/dist/services/platform-api/src/database/database.service.d.ts +0 -38
  741. package/dist/services/platform-api/src/database/database.service.d.ts.map +0 -1
  742. package/dist/services/platform-api/src/database/database.service.js +0 -520
  743. package/dist/services/platform-api/src/database/database.service.js.map +0 -1
  744. package/dist/services/platform-api/src/database/migration-ledger.d.ts +0 -5
  745. package/dist/services/platform-api/src/database/migration-ledger.d.ts.map +0 -1
  746. package/dist/services/platform-api/src/database/migration-ledger.js +0 -33
  747. package/dist/services/platform-api/src/database/migration-ledger.js.map +0 -1
  748. package/dist/services/platform-api/src/digital-employee/local-skill-bundles.d.ts +0 -13
  749. package/dist/services/platform-api/src/digital-employee/local-skill-bundles.d.ts.map +0 -1
  750. package/dist/services/platform-api/src/digital-employee/local-skill-bundles.js +0 -25
  751. package/dist/services/platform-api/src/digital-employee/local-skill-bundles.js.map +0 -1
  752. package/dist/services/platform-api/src/mcp-connection/mcp-tool-name.d.ts +0 -6
  753. package/dist/services/platform-api/src/mcp-connection/mcp-tool-name.d.ts.map +0 -1
  754. package/dist/services/platform-api/src/mcp-connection/mcp-tool-name.js +0 -20
  755. package/dist/services/platform-api/src/mcp-connection/mcp-tool-name.js.map +0 -1
  756. package/dist/services/platform-api/src/qa/qa-tool-definitions.d.ts +0 -100
  757. package/dist/services/platform-api/src/qa/qa-tool-definitions.d.ts.map +0 -1
  758. package/dist/services/platform-api/src/qa/qa-tool-definitions.js +0 -498
  759. package/dist/services/platform-api/src/qa/qa-tool-definitions.js.map +0 -1
  760. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,1587 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { mkdir, open, realpath, stat } from "node:fs/promises";
3
- import { basename, dirname, join, resolve } from "node:path";
4
- import { createAgentSession, DefaultResourceLoader, SessionManager, } from "@earendil-works/pi-coding-agent";
5
- import { deliveryTools } from "./delivery-tools.js";
6
- import { execGitFile as execFileAsync, gitFailure, missingGitRef } from "./git-process.js";
7
- import { ensureHttpOrigin, gitTransportUrl, matchesRepository, HTTP_ACCESS_HINT, } from "./git-transport.js";
8
- import { logGitPreparationFailure, logHostEvent, redactHostText } from "./host-log.js";
9
- import { inspectHandoffWorkspace, synchronizeRemoteWorkspace } from "./local-handoff-workspace.js";
10
- import { localModelUsage } from "./local-model-usage.js";
11
- import { worktreeTreeHash } from "./project-facts.js";
12
- import { isProviderLoginRequired } from "./provider-auth-error.js";
13
- export { redactHostText } from "./host-log.js";
14
- export { worktreeTreeHash } from "./project-facts.js";
15
- import { createCodingSubagents } from "./coding-subagents.js";
16
- import { commandMaterialReader, deliveryDirectory, initializeDeliveryFiles, publishReviewMaterials, } from "./delivery-files.js";
17
- import { liveEmployee } from "./live-employee.js";
18
- import { paths } from "./paths.js";
19
- import { acquireOperationLock, OperationContext, operationCleanupConfirmed, throwIfOperationAborted, waitForOperation, } from "./operation-context.js";
20
- import { PiMessageQueue } from "./pi-message-queue.js";
21
- import { PlatformClientError } from "./platform-client.js";
22
- import { inspectRunResources } from "./run-resources.js";
23
- import { readJson, writeSecureJson } from "./secure-json.js";
24
- import { stageEmployeeIds } from "./stage-delivery.js";
25
- const EVENT_APPEND_MAX_ATTEMPTS = 8;
26
- export class CodingRunManager {
27
- pi;
28
- active = new Map();
29
- commands = new Set();
30
- context;
31
- constructor(pi, signal) {
32
- this.pi = pi;
33
- this.context = new OperationContext(signal);
34
- signal?.addEventListener("abort", () => {
35
- for (const active of this.active.values()) {
36
- active.stopping = true;
37
- active.observed.stopping = true;
38
- void active.subagents?.stop().catch(() => {
39
- this.context.cleanupConfirmed = false;
40
- });
41
- void active.session.abort().catch(() => {
42
- this.context.cleanupConfirmed = false;
43
- });
44
- }
45
- }, { once: true });
46
- }
47
- get cleanupConfirmed() {
48
- return this.context.cleanupConfirmed;
49
- }
50
- isBusy() {
51
- return this.commands.size > 0 || this.active.size > 0;
52
- }
53
- async settled() {
54
- while (this.isBusy()) {
55
- const pending = [
56
- ...this.commands,
57
- ...[...this.active.values()]
58
- .map((run) => run.finished)
59
- .filter((task) => task !== undefined),
60
- ];
61
- if (!pending.length)
62
- return;
63
- await Promise.allSettled(pending);
64
- }
65
- }
66
- execute(client, host, command) {
67
- const task = this.context.run(() => this.executeCommand(client, host, command));
68
- this.commands.add(task);
69
- void task.finally(() => this.commands.delete(task)).catch(() => undefined);
70
- return task;
71
- }
72
- async executeCommand(client, host, command) {
73
- if (command.run?.action !== "STOP")
74
- throwIfOperationAborted();
75
- const readMaterial = commandMaterialReader((source) => client.commandMaterial(command.id, {
76
- hostId: host.hostId,
77
- generation: host.generation,
78
- contentHash: source.contentHash,
79
- }));
80
- if (!command.run)
81
- throw new Error("CODING_RUN_COMMAND_INVALID");
82
- if (command.run.action === "CHECK_RESOURCES") {
83
- const input = command.run.runInput;
84
- return {
85
- resources: await inspectRunResources(command.run.runId, input, this.active.has(command.run.runId) || this.active.has(`${command.run.runId}:discussion`)),
86
- };
87
- }
88
- if (command.run.action === "STOP" && command.run.runInput?.discussionTurn) {
89
- const discussion = this.active.get(`${command.run.runId}:discussion`);
90
- if (discussion && discussion.turnId === command.run.turnId) {
91
- discussion.stopping = true;
92
- discussion.observed.stopping = true;
93
- await discussion.subagents?.stop();
94
- await discussion.session.abort();
95
- await discussion.emit("RUN_STOPPED", { phase: "DEVELOPMENT" });
96
- }
97
- else {
98
- const stateFile = join(paths().runState, `${command.run.runId}.json`);
99
- const state = await readJson(stateFile);
100
- await eventEmitter(client, host, command.run.runId, command.run.turnId, state?.lastEventSequence ?? 0, async (sequence) => {
101
- const current = await readJson(stateFile);
102
- if (current)
103
- await writeSecureJson(stateFile, { ...current, lastEventSequence: sequence });
104
- }, undefined, true)("RUN_STOPPED", { phase: "DEVELOPMENT" });
105
- }
106
- return;
107
- }
108
- if (command.run.action === "RECALL_QUEUE") {
109
- return {
110
- recalledMessageIds: this.active.get(command.run.runId)?.observed.messageQueue?.recall() ?? [],
111
- };
112
- }
113
- const imageRun = command.run;
114
- let images;
115
- try {
116
- images = await Promise.all((command.run.attachments ?? []).map((attachment) => client.attachmentContent(imageRun.runId, attachment.id, {
117
- hostId: host.hostId,
118
- generation: host.generation,
119
- turnId: imageRun.turnId,
120
- })));
121
- }
122
- catch (error) {
123
- const active = this.active.get(imageRun.runId);
124
- if (active?.turnId === imageRun.turnId) {
125
- active.stopping = true;
126
- active.observed.stopping = true;
127
- await active.subagents?.stop();
128
- await active.session.abort();
129
- await waitForOperation(active.finished ?? Promise.resolve());
130
- if (this.active.get(imageRun.runId) === active)
131
- this.active.delete(imageRun.runId);
132
- }
133
- throw error;
134
- }
135
- if (command.run.runInput?.discussionTurn) {
136
- await this.start(readMaterial, client, host, command.run.runId, command.run.turnId, command.run.runInput, true, command.run.contentMarkdown, images);
137
- const discussion = this.active.get(`${command.run.runId}:discussion`);
138
- if (discussion && command.run.messageId)
139
- await discussion.emit("MESSAGE_QUEUE_UPDATED", {
140
- messageId: command.run.messageId,
141
- deliveryStatus: "READ",
142
- });
143
- return;
144
- }
145
- if (command.run.action === "START") {
146
- const input = command.run.runInput;
147
- await this.start(readMaterial, client, host, command.run.runId, command.run.turnId, input, false, command.run.contentMarkdown, images);
148
- }
149
- else if (command.run.action === "CONTINUE") {
150
- const active = this.active.get(command.run.runId);
151
- if (active) {
152
- await waitForOperation(active.finished ?? Promise.resolve());
153
- if (active.stopping ||
154
- active.observed.userIntervened ||
155
- active.observed.obsoleteContinuationAudits?.has(command.run.continuation?.auditId ?? ""))
156
- return;
157
- }
158
- if (!command.run.runInput || !command.run.contentMarkdown || !command.run.continuation)
159
- throw new Error("CODING_RUN_CONTINUATION_MISSING");
160
- await this.start(readMaterial, client, host, command.run.runId, command.run.turnId, command.run.runInput, true, command.run.contentMarkdown, [], command.run.continuation);
161
- }
162
- else if (command.run.action === "STEER" || command.run.action === "FOLLOW_UP") {
163
- let active = this.active.get(command.run.runId);
164
- if (!command.run.contentMarkdown && images.length === 0)
165
- throw new Error("CODING_RUN_MESSAGE_MISSING");
166
- if (active && active.turnId !== command.run.turnId) {
167
- if (!active.observed.terminalReached)
168
- throw new Error("CODING_RUN_TURN_MISMATCH");
169
- active.stopping = true;
170
- active.observed.stopping = true;
171
- await active.emit("EXECUTION_DECIDED", {
172
- phase: active.input.phase,
173
- decision: "SKIP",
174
- reason: "SUPERSEDED",
175
- stopReason: "SUPERSEDED",
176
- });
177
- await active.subagents?.stop();
178
- await active.session.abort();
179
- if (this.active.get(command.run.runId) === active)
180
- this.active.delete(command.run.runId);
181
- active = undefined;
182
- }
183
- if (active) {
184
- if (command.run.runInput)
185
- active.input.handoff = command.run.runInput.handoff ?? null;
186
- if (images.length > 0 && !active.supportsImages)
187
- throw new Error("MODEL_IMAGES_UNSUPPORTED");
188
- active.observed.userIntervened = true;
189
- const handoff = active.observed.awaitingDecision || active.session.isIdle;
190
- if (handoff)
191
- active.observed.handingOffInput = true;
192
- await active.emit("AUTO_CONTINUATION_CHANGED", {
193
- phase: active.input.phase,
194
- autoContinueEnabled: false,
195
- reason: "USER_MESSAGE",
196
- source: "HOST_HANDLED",
197
- });
198
- if (handoff || active.session.isIdle || active.observed.awaitingDecision) {
199
- active.observed.handingOffInput = true;
200
- // Pi is idle: steer only queues input and cannot start a new model turn.
201
- // Finish the old judge operation before opening the user turn.
202
- await waitForOperation(active.finished ?? Promise.resolve());
203
- if (!command.run.runInput)
204
- throw new Error("CODING_RUN_INPUT_MISSING");
205
- await this.start(readMaterial, client, host, command.run.runId, command.run.turnId, command.run.runInput, true, command.run.contentMarkdown, images);
206
- if (command.run.messageId)
207
- await this.active.get(command.run.runId)?.emit("MESSAGE_QUEUE_UPDATED", {
208
- messageId: command.run.messageId,
209
- deliveryStatus: "READ",
210
- });
211
- return;
212
- }
213
- if (!command.run.messageId)
214
- throw new Error("CODING_RUN_MESSAGE_ID_MISSING");
215
- await active.observed.messageQueue.submit(command.run.messageId, command.run.action, command.run.contentMarkdown ?? "", images.length ? images : undefined);
216
- await active.emit("MESSAGE_QUEUE_UPDATED", {
217
- messageId: command.run.messageId,
218
- deliveryStatus: "QUEUED",
219
- });
220
- }
221
- else {
222
- if (!command.run.runInput)
223
- throw new Error("CODING_RUN_INPUT_MISSING");
224
- await this.start(readMaterial, client, host, command.run.runId, command.run.turnId, command.run.runInput, true, command.run.contentMarkdown, images);
225
- if (command.run.messageId)
226
- await this.active.get(command.run.runId)?.emit("MESSAGE_QUEUE_UPDATED", {
227
- messageId: command.run.messageId,
228
- deliveryStatus: "READ",
229
- });
230
- }
231
- }
232
- else if (command.run.action === "STOP") {
233
- const active = this.active.get(command.run.runId);
234
- if (active) {
235
- if (active.turnId !== command.run.turnId)
236
- throw new Error("CODING_RUN_TURN_MISMATCH");
237
- active.stopping = true;
238
- active.observed.stopping = true;
239
- await active.subagents?.stop();
240
- await active.session.abort();
241
- await active.emit("AUTO_CONTINUATION_CHANGED", {
242
- phase: active.input.phase,
243
- autoContinueEnabled: false,
244
- reason: "USER_STOP",
245
- source: "HOST_HANDLED",
246
- });
247
- await active.emit.flush();
248
- await active.emit("EXECUTION_DECIDED", {
249
- phase: active.input.phase,
250
- decision: "SKIP",
251
- reason: "STOP_REQUESTED",
252
- stopReason: "USER_STOPPED",
253
- });
254
- await active.emit("RUN_STOPPED", {
255
- phase: active.input.phase,
256
- reason: "USER_STOPPED",
257
- workspaceChanges: await Promise.all(active.input.projects.map(async (project) => ({
258
- projectId: project.id,
259
- ...(await inspectHandoffWorkspace(join(active.runRoot, safeName(project.name)))),
260
- }))),
261
- });
262
- }
263
- else {
264
- const stateFile = join(paths().runState, `${command.run.runId}.json`);
265
- const state = await readJson(stateFile);
266
- await eventEmitter(client, host, command.run.runId, command.run.turnId, state?.lastEventSequence ?? 0, (sequence) => writeSecureJson(stateFile, { ...state, lastEventSequence: sequence }), (value) => redactHostText(value, [paths().root]))("RUN_STOPPED", {
267
- phase: state?.phase,
268
- reason: "USER_STOPPED",
269
- reminderDecision: "NO_REMINDER",
270
- workspaceChanges: state?.mrContext?.projects
271
- ? await Promise.all(state.mrContext.projects.map(async (project) => ({
272
- projectId: project.id,
273
- ...(await inspectHandoffWorkspace(join(paths().runWorktrees, command.run.runId, safeName(project.name)))),
274
- })))
275
- : [],
276
- });
277
- }
278
- }
279
- else if (command.run.action === "RESUME") {
280
- await this.start(readMaterial, client, host, command.run.runId, command.run.turnId, command.run.runInput, true, command.run.contentMarkdown, images);
281
- }
282
- if (command.run.messageId &&
283
- ["START", "RESUME", "STEER", "FOLLOW_UP"].includes(command.run.action)) {
284
- const active = this.active.get(command.run.runId);
285
- if (active &&
286
- (command.run.action === "RESUME" ||
287
- command.run.action === "START" ||
288
- !active.observed.messageQueue))
289
- await active.emit("MESSAGE_QUEUE_UPDATED", {
290
- messageId: command.run.messageId,
291
- deliveryStatus: "READ",
292
- });
293
- }
294
- }
295
- async start(readMaterial, client, host, runId, turnId, input, resume, resumePrompt, images = [], continuation) {
296
- throwIfOperationAborted();
297
- if (!input.discussionTurn && input.phase === "DEVELOPMENT") {
298
- const discussion = this.active.get(`${runId}:discussion`);
299
- if (discussion) {
300
- discussion.stopping = true;
301
- discussion.observed.stopping = true;
302
- await discussion.subagents?.stop();
303
- await discussion.session.abort();
304
- await discussion.emit("RUN_STOPPED", { phase: "DEVELOPMENT" });
305
- await waitForOperation(discussion.finished ?? Promise.resolve());
306
- }
307
- }
308
- const activeKey = input.discussionTurn ? `${runId}:discussion` : runId;
309
- const active = this.active.get(activeKey);
310
- if (active) {
311
- if (active.turnId === turnId)
312
- return;
313
- if (!active.observed.terminalReached && !active.stopping)
314
- throw new Error("CODING_RUN_TURN_MISMATCH");
315
- await waitForOperation(active.finished ?? Promise.resolve());
316
- if (this.active.get(activeKey) === active)
317
- this.active.delete(activeKey);
318
- }
319
- if (process.env.AIP_TEST_PI === "1" && !input.discussionTurn) {
320
- await this.synthetic(client, host, runId, turnId, input);
321
- return;
322
- }
323
- const local = paths();
324
- const developmentRoot = join(local.runWorktrees, runId);
325
- const deploymentSession = input.phase === "DEPLOYMENT" && input.executionPurpose !== "RELEASE";
326
- const runRoot = deploymentSession
327
- ? join(local.root, "workspaces", "deployments", runId)
328
- : developmentRoot;
329
- await mkdir(runRoot, { recursive: true, mode: 0o700 });
330
- const stateFile = join(local.runState, `${runId}.json`);
331
- const storedState = await readJson(stateFile);
332
- const newDeploymentRequest = deploymentSession &&
333
- Boolean(input.deploymentRequestId) &&
334
- input.deploymentRequestId !== storedState?.deploymentRequestId;
335
- for (const project of input.projects)
336
- project.devBranch ||=
337
- storedState?.mrContext?.projects.find((p) => p.id === project.id)?.devBranch ||
338
- `aip/${input.workItem.key}`;
339
- let recoveryWorkspacePresent = false;
340
- if (input.sessionRecovery) {
341
- const facts = await inspectRunResources(runId, {
342
- ...input,
343
- expectedSessionId: input.sessionRecovery.expectedSessionId,
344
- });
345
- recoveryWorkspacePresent = facts.workspace === "PRESENT";
346
- if (facts.workspace === "INVALID")
347
- throw new Error("CODING_RUN_WORKTREE_INVALID");
348
- if (input.sessionRecovery.mode === "RESUME" && facts.workspace !== "PRESENT")
349
- throw new Error("CODING_RUN_WORKTREE_MISSING");
350
- if (input.sessionRecovery.mode === "RESUME" && facts.session !== "PRESENT")
351
- throw new Error(facts.session === "INVALID" ? "PI_SESSION_INVALID" : "PI_SESSION_NOT_FOUND");
352
- if (input.sessionRecovery.mode === "NEW_SESSION" &&
353
- facts.workspace !== "PRESENT" &&
354
- facts.remoteBranch !== "PRESENT")
355
- throw new Error("CODING_BRANCH_NOT_PUBLISHED");
356
- }
357
- if (storedState?.phaseSessions &&
358
- Object.keys(storedState.phaseSessions).length &&
359
- storedState.harness !== "pi")
360
- throw new Error("PRIOR_HARNESS_SESSION_UNSUPPORTED:请新建执行,历史文件和工作目录已保留。");
361
- const transferNotes = input.transferContinuation && !storedState?.prepared
362
- ? await inspectPriorTransferWorkspaces(local.runWorktrees, input.transferWorkspaces?.priorRunIds ?? [], input.projects)
363
- : [];
364
- const pendingLocalIntake = !input.discussionTurn &&
365
- input.localIntake &&
366
- storedState?.appliedLocalIntake !== input.localIntake.id
367
- ? input.localIntake
368
- : undefined;
369
- if (pendingLocalIntake) {
370
- for (const project of input.projects) {
371
- const accepted = pendingLocalIntake.projects.find((fact) => fact.projectId === project.id);
372
- if (!accepted || accepted.branch !== project.devBranch)
373
- throw new Error("LOCAL_INTAKE_PROJECT_MISMATCH");
374
- }
375
- }
376
- logHostEvent("workspace_preparation_started", { runId, turnId, phase: input.phase });
377
- if (!input.discussionTurn && deploymentSession && (newDeploymentRequest || pendingLocalIntake))
378
- await prepareProjects(local.repositoryCache, developmentRoot, input.workItem.key, input.projects, false, true);
379
- const newSessionOnDifferentHost = input.sessionRecovery?.mode === "NEW_SESSION" && input.sessionRecovery.hostChanged;
380
- const cwd = input.discussionTurn
381
- ? input.projects.length === 1
382
- ? join(runRoot, safeName(input.projects[0].name))
383
- : runRoot
384
- : deploymentSession
385
- ? await prepareDeploymentProjects(runRoot, input.projects, input.deploymentConfiguration)
386
- : await prepareProjects(local.repositoryCache, runRoot, input.workItem.key, input.projects, input.sessionRecovery ? recoveryWorkspacePresent : Boolean(storedState?.prepared), Boolean(pendingLocalIntake) ||
387
- input.transferContinuation === true ||
388
- input.sessionRecovery?.mode === "NEW_SESSION", pendingLocalIntake ? undefined : input.transferWorkspaces?.uninitializedProjectIds, Boolean(input.sessionRecovery) && !newSessionOnDifferentHost && !pendingLocalIntake);
389
- let appliedLocalIntake = storedState?.appliedLocalIntake;
390
- if (pendingLocalIntake) {
391
- appliedLocalIntake = pendingLocalIntake.id;
392
- await writeSecureJson(stateFile, { ...storedState, appliedLocalIntake });
393
- }
394
- const preparationBaselines = storedState?.preparationBaselines ?? {};
395
- if (input.phase === "PREPARATION" && !storedState?.prepared) {
396
- for (const project of input.projects)
397
- preparationBaselines[project.id] ??= (await execFileAsync("git", ["rev-parse", "HEAD"], {
398
- cwd: join(runRoot, safeName(project.name)),
399
- })).stdout.trim();
400
- await writeSecureJson(stateFile, { ...storedState, preparationBaselines });
401
- }
402
- throwIfOperationAborted();
403
- logHostEvent("workspace_repositories_ready", { runId, turnId });
404
- await initializeDeliveryFiles(runRoot, input, Boolean(storedState?.prepared), readMaterial);
405
- throwIfOperationAborted();
406
- logHostEvent("workspace_materials_ready", { runId, turnId });
407
- const deliveryInputHash = createHash("sha256")
408
- .update(JSON.stringify([
409
- input.primaryProjectId,
410
- input.requirement?.source.contentHash,
411
- input.technicalDesign?.source.contentHash,
412
- ]))
413
- .digest("hex");
414
- const deploymentRequestId = deploymentSession
415
- ? input.deploymentRequestId
416
- : storedState?.deploymentRequestId;
417
- const delegations = storedState?.delegations ?? {};
418
- let pendingDelivery = newDeploymentRequest ||
419
- storedState?.phase !== input.phase ||
420
- resumePrompt ||
421
- images.length > 0 ||
422
- (storedState?.deliveryInputHash && storedState.deliveryInputHash !== deliveryInputHash)
423
- ? undefined
424
- : storedState?.pendingDelivery
425
- ? {
426
- ...storedState.pendingDelivery,
427
- turnId,
428
- hostId: host.hostId,
429
- generation: host.generation,
430
- }
431
- : undefined;
432
- const phaseSessions = { ...storedState?.phaseSessions };
433
- const sessionPhase = input.executionPurpose === "RELEASE" ? "DEVELOPMENT" : input.phase;
434
- let sessionRef = input.sessionRecovery
435
- ? input.sessionRecovery.mode === "NEW_SESSION"
436
- ? undefined
437
- : (input.sessionRecovery.expectedSessionId ?? phaseSessions[sessionPhase])
438
- : phaseSessions[sessionPhase];
439
- let lastEventSequence = Math.max(storedState?.lastEventSequence ?? 0, input.sessionRecovery?.lastEventSequence ?? 0);
440
- const observed = {
441
- userIntervened: input.autoContinueEnabled === false,
442
- activeTasks: new Map(),
443
- stopping: false,
444
- terminalReached: false,
445
- };
446
- const persistState = () => input.discussionTurn
447
- ? Promise.resolve()
448
- : writeSecureJson(stateFile, {
449
- phase: input.phase,
450
- appliedLocalIntake,
451
- mrContext: {
452
- runId,
453
- turnId,
454
- workItem: input.workItem,
455
- projects: input.projects,
456
- primaryProjectId: input.primaryProjectId,
457
- },
458
- prepared: true,
459
- preparationBaselines,
460
- phaseSessions,
461
- deploymentRequestId,
462
- sessionRef,
463
- harness: "pi",
464
- lastEventSequence,
465
- delegations,
466
- pendingDelivery,
467
- deliveryInputHash,
468
- });
469
- const redact = (value) => redactHostText(value, [runRoot, local.root]);
470
- const emit = eventEmitter(client, host, runId, turnId, lastEventSequence, input.discussionTurn
471
- ? async (sequence) => {
472
- const current = await readJson(stateFile);
473
- if (current)
474
- await writeSecureJson(stateFile, { ...current, lastEventSequence: sequence });
475
- }
476
- : (sequence) => {
477
- lastEventSequence = sequence;
478
- return persistState();
479
- }, redact, Boolean(input.discussionTurn));
480
- if (transferNotes.length)
481
- await emit("MESSAGE_COMPLETED", {
482
- contentMarkdown: `旧工作区检查:\n${transferNotes.join("\n")}`,
483
- });
484
- if (!storedState?.prepared)
485
- await publishReviewMaterials(runRoot, input, readMaterial);
486
- if (input.phase === "PREPARATION") {
487
- await persistState();
488
- await emit("PREPARATION_COMPLETED", {
489
- primaryProjectId: input.primaryProjectId,
490
- projects: await Promise.all(input.projects.map(async (p) => ({
491
- projectId: p.id,
492
- projectName: p.name,
493
- baselineCommit: preparationBaselines[p.id] ?? p.baselineCommit,
494
- directory: join(runRoot, safeName(p.name)),
495
- branch: (await execFileAsync("git", ["branch", "--show-current"], {
496
- cwd: join(runRoot, safeName(p.name)),
497
- })).stdout.trim(),
498
- }))),
499
- });
500
- return;
501
- }
502
- const binding = {
503
- hostId: host.hostId,
504
- generation: host.generation,
505
- turnId,
506
- member: "supervisor",
507
- };
508
- const initialEmployeeConfig = await client.employeeConfig(runId, {
509
- ...binding,
510
- purpose: "LOAD",
511
- });
512
- const terminal = deliveryTools(client, host, runId, turnId, developmentRoot, input, observed, async (batch) => {
513
- pendingDelivery = batch;
514
- await persistState();
515
- }, () => pendingDelivery, () => emit.flush(), initialEmployeeConfig.toolDefinitions);
516
- if (!this.pi.resolveRuntimeModel)
517
- throw new Error("MODEL_RUNTIME_UNAVAILABLE");
518
- const resolved = await this.pi.resolveRuntimeModel(input.providerId, input.modelId, {
519
- runId,
520
- turnId,
521
- hostId: host.hostId,
522
- generation: host.generation,
523
- });
524
- if (images.length > 0 && !resolved.model.input?.includes("image"))
525
- throw new Error("MODEL_IMAGES_UNSUPPORTED");
526
- const availableAgents = stageEmployeeIds(input);
527
- const live = liveEmployee(client, runId, binding, initialEmployeeConfig, runRoot, Boolean(input.team), input.executionPurpose === "RELEASE", input.phase, () => observed.terminalReached, () => executionInstructions(input, runRoot), () => {
528
- observed.terminalClosed = true;
529
- });
530
- const delegation = input.executionPurpose === "RELEASE"
531
- ? undefined
532
- : await createCodingSubagents({
533
- client,
534
- toolDefinitions: initialEmployeeConfig.toolDefinitions,
535
- config: {
536
- runId,
537
- turnId,
538
- hostId: host.hostId,
539
- generation: host.generation,
540
- runRoot,
541
- providerId: input.providerId,
542
- modelId: input.modelId,
543
- phase: input.phase,
544
- },
545
- cwd,
546
- directory: join(local.runState, runId, "subagents", input.phase),
547
- team: Boolean(input.team),
548
- agents: availableAgents.map((id) => ({
549
- id,
550
- name: input.teamEmployees?.[id]?.name ?? id,
551
- description: input.teamEmployees?.[id]?.description ?? "",
552
- })),
553
- records: delegations,
554
- emit,
555
- persist: persistState,
556
- started(activityKey, agentId) {
557
- observed.activeTasks.set(activityKey, agentId);
558
- },
559
- async completed(activityKey) {
560
- observed.activeTasks.delete(activityKey);
561
- },
562
- });
563
- const opened = await openPiSession({
564
- cwd,
565
- sessionDir: local.piSessions,
566
- agentDir: local.piAgent,
567
- existingId: sessionRef,
568
- modelRuntime: resolved.runtime,
569
- model: resolved.model,
570
- thinkingLevel: input.thinkingLevel,
571
- extensions: [...(delegation ? [delegation.extension] : []), terminal, live.extension],
572
- systemPrompt: input.team
573
- ? "当前为团队主负责人会话,员工配置由平台下发。"
574
- : "当前为工单主会话,员工配置由平台下发。",
575
- runId,
576
- });
577
- live.attach(opened.session);
578
- const session = opened.session;
579
- sessionRef = opened.sessionId;
580
- observed.messageQueue = new PiMessageQueue(session);
581
- subscribeSession(session, (kind, payload) => {
582
- const activityKey = String(payload.activityKey ?? "");
583
- if (kind === "SUBAGENT_STARTED")
584
- observed.activeTasks.set(activityKey, String(payload.agentId));
585
- if (["SUBAGENT_COMPLETED", "SUBAGENT_FAILED", "SUBAGENT_STOPPED"].includes(kind))
586
- observed.activeTasks.delete(activityKey);
587
- return emit(kind, {
588
- ...payload,
589
- phase: input.phase,
590
- agentId: payload.agentId ?? "supervisor",
591
- sessionId: sessionRef,
592
- });
593
- }, observed, redact);
594
- const activeRun = {
595
- runRoot,
596
- session,
597
- supportsImages: resolved.model.input?.includes("image") === true,
598
- input,
599
- turnId,
600
- emit,
601
- stopping: false,
602
- observed,
603
- ...(delegation ? { subagents: delegation } : {}),
604
- };
605
- const disposeRun = async () => {
606
- try {
607
- try {
608
- await delegation?.stop();
609
- await delegation?.flush();
610
- }
611
- finally {
612
- await delegation?.dispose();
613
- await session.extensionRunner?.emit({ type: "session_shutdown", reason: "quit" });
614
- }
615
- }
616
- finally {
617
- session.dispose();
618
- if (this.active.get(activeKey) === activeRun)
619
- this.active.delete(activeKey);
620
- }
621
- };
622
- this.active.set(activeKey, activeRun);
623
- let conversationFingerprint;
624
- let prompt;
625
- try {
626
- phaseSessions[sessionPhase] = sessionRef;
627
- await persistState();
628
- await emit("RUN_STARTED", { sessionRef, phase: input.phase });
629
- if (!input.discussionTurn &&
630
- !continuation &&
631
- (input.autoContinueEnabled === false || (!resume && input.autoContinueEnabled === true))) {
632
- await emit("AUTO_CONTINUATION_CHANGED", {
633
- phase: input.phase,
634
- autoContinueEnabled: input.autoContinueEnabled === true,
635
- reason: input.autoContinueEnabled === true ? "SYSTEM_STAGE" : "USER_MESSAGE",
636
- source: "HOST_HANDLED",
637
- });
638
- }
639
- if (!input.discussionTurn && !continuation && (resumePrompt || images.length > 0)) {
640
- await emit("MESSAGE_QUEUE_UPDATED", { deliveryStatus: "QUEUED" });
641
- await emit("MESSAGE_QUEUE_UPDATED", { deliveryStatus: "READ" });
642
- }
643
- conversationFingerprint = await workspaceFingerprint(runRoot, input);
644
- prompt = continuation
645
- ? resumePrompt
646
- : `${initialPrompt(input, runRoot, true, developmentRoot)}${input.sessionRecovery?.context ? `\n\n平台恢复上下文(历史事实,不是用户新消息):\n${input.sessionRecovery.context}` : ""}${transferNotes.length ? `\n\n旧工作区检查:\n${transferNotes.join("\n")}` : ""}${resumePrompt ? `\n\n用户本次消息:${resumePrompt}` : resume && !resumePrompt ? "\n\n继续当前会话未完成的工作,先读取最新文件和交接结果。" : ""}`;
647
- }
648
- catch (error) {
649
- await disposeRun();
650
- throw error;
651
- }
652
- const discussion = async () => {
653
- throwIfOperationAborted();
654
- await session.prompt(prompt, images.length ? { images } : undefined);
655
- await session.waitForIdle();
656
- if (!observed.stopping)
657
- await emit("CONVERSATION_COMPLETED", {
658
- phase: "DEVELOPMENT",
659
- workspaceChanged: conversationFingerprint !== (await workspaceFingerprint(runRoot, input)),
660
- });
661
- };
662
- if (this.context.signal?.aborted) {
663
- activeRun.stopping = true;
664
- observed.stopping = true;
665
- await disposeRun();
666
- throwIfOperationAborted();
667
- }
668
- activeRun.finished = (input.discussionTurn
669
- ? discussion()
670
- : driveToTerminal(session, prompt, observed, client, host, runId, turnId, emit, input.phase, images, async () => {
671
- await emit("CONVERSATION_COMPLETED", {
672
- workspaceChanged: conversationFingerprint !== (await workspaceFingerprint(runRoot, input)),
673
- });
674
- }, continuation))
675
- .catch(async (error) => {
676
- if (activeRun.stopping)
677
- return;
678
- if (!input.discussionTurn)
679
- await emit("EXECUTION_DECIDED", {
680
- phase: input.phase,
681
- decision: "SKIP",
682
- reason: "MODEL_ERROR",
683
- stopReason: "error",
684
- });
685
- await emit("RUN_FAILED", {
686
- phase: input.phase,
687
- code: error instanceof Error && /^[A-Z][A-Z0-9_]+$/u.test(error.message)
688
- ? error.message.slice(0, 200)
689
- : "PI_RUN_FAILED",
690
- message: redact(error instanceof Error ? error.message : String(error)),
691
- });
692
- })
693
- .finally(async () => {
694
- try {
695
- await emit.flush();
696
- }
697
- finally {
698
- await disposeRun();
699
- }
700
- });
701
- }
702
- async synthetic(client, host, runId, turnId, input) {
703
- const emit = eventEmitter(client, host, runId, turnId);
704
- await emit("RUN_STARTED", { sessionRef: `synthetic:${runId}` });
705
- const member = stageEmployeeIds(input)[0];
706
- if (member)
707
- await emit("SUBAGENT_STARTED", {
708
- activityKey: "member-1",
709
- agentId: member,
710
- summary: "审查实现",
711
- });
712
- if (member)
713
- await emit("SUBAGENT_COMPLETED", {
714
- activityKey: "member-1",
715
- agentId: member,
716
- summary: "审查通过",
717
- });
718
- await emit("MESSAGE_COMPLETED", {
719
- contentMarkdown: "实现、测试与代码审查已经完成,等待确认交付。",
720
- });
721
- await client.reportCodingTerminal(runId, {
722
- hostId: host.hostId,
723
- generation: host.generation,
724
- turnId,
725
- kind: "DELIVERY",
726
- summary: "本地 Coding Run 验收交付",
727
- knownIssues: "",
728
- projectFacts: input.projects.map((project) => ({
729
- projectId: project.id,
730
- projectName: project.name,
731
- commitSha: project.baselineCommit,
732
- treeHash: "a".repeat(40),
733
- branch: project.testBranch,
734
- })),
735
- testFacts: [],
736
- });
737
- }
738
- }
739
- const eventStreams = new WeakMap();
740
- function eventEmitter(client, host, runId, turnId, initialSequence = 0, persistSequence, redact = (value) => redactHostText(value), preservePersist = false) {
741
- let streams = eventStreams.get(client);
742
- if (!streams) {
743
- streams = new Map();
744
- eventStreams.set(client, streams);
745
- }
746
- let stream = streams.get(runId);
747
- if (!stream) {
748
- stream = { sequence: initialSequence, queue: Promise.resolve() };
749
- streams.set(runId, stream);
750
- }
751
- stream.sequence = Math.max(stream.sequence, initialSequence);
752
- if (persistSequence && (!preservePersist || !stream.persist))
753
- stream.persist = persistSequence;
754
- const state = stream;
755
- const emit = (kind, payload) => {
756
- state.queue = state.queue
757
- .catch(() => { })
758
- .then(async () => {
759
- const event = {
760
- eventId: crypto.randomUUID(),
761
- sequence: state.sequence + 1,
762
- turnId,
763
- kind,
764
- payload: kind === "PREPARATION_COMPLETED" ? payload : redactPayload(payload, redact),
765
- createdAt: new Date().toISOString(),
766
- };
767
- for (let attempt = 1; attempt <= EVENT_APPEND_MAX_ATTEMPTS; attempt++) {
768
- try {
769
- await client.appendCodingEvents(runId, {
770
- hostId: host.hostId,
771
- generation: host.generation,
772
- events: [event],
773
- });
774
- state.sequence = event.sequence;
775
- await state.persist?.(event.sequence);
776
- return;
777
- }
778
- catch (error) {
779
- if (error instanceof PlatformClientError &&
780
- error.status === 409 &&
781
- error.code === "CODING_EVENT_TURN_STALE") {
782
- // 平台已切换轮次后拒收的旧轮事件:只记标识,便于核对时间线缺口,不重试、不放行。
783
- logHostEvent("coding_event_turn_stale", {
784
- runId,
785
- turnId,
786
- sequence: event.sequence,
787
- kind,
788
- ...(typeof payload.toolName === "string" ? { toolName: payload.toolName } : {}),
789
- ...(typeof payload.activityKey === "string"
790
- ? { activityKey: payload.activityKey }
791
- : {}),
792
- });
793
- if ([
794
- "PREPARATION_COMPLETED",
795
- "EXECUTION_STARTED",
796
- "EXECUTION_PAUSED",
797
- "CONVERSATION_COMPLETED",
798
- ].includes(kind))
799
- throw error;
800
- return;
801
- }
802
- process.stderr.write(`[local-coding-host] 事件上报失败:${redact(error instanceof Error ? error.message : String(error))}\n`);
803
- if (attempt === EVENT_APPEND_MAX_ATTEMPTS) {
804
- process.stderr.write(`[local-coding-host] 事件上报放弃:${event.kind} sequence=${event.sequence} attempts=${attempt}\n`);
805
- if ([
806
- "PREPARATION_COMPLETED",
807
- "EXECUTION_STARTED",
808
- "EXECUTION_PAUSED",
809
- "CONVERSATION_COMPLETED",
810
- ].includes(kind))
811
- throw error;
812
- return;
813
- }
814
- await new Promise((resolve) => setTimeout(resolve, 0));
815
- }
816
- }
817
- });
818
- return state.queue;
819
- };
820
- return Object.assign(emit, { flush: () => state.queue });
821
- }
822
- function redactPayload(value, redact) {
823
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactPayloadValue(item, redact)]));
824
- }
825
- function redactPayloadValue(value, redact) {
826
- if (typeof value === "string")
827
- return redact(value);
828
- if (Array.isArray(value))
829
- return value.map((item) => redactPayloadValue(item, redact));
830
- if (value && typeof value === "object")
831
- return redactPayload(value, redact);
832
- return value;
833
- }
834
- export async function openPiSession(options) {
835
- await mkdir(options.sessionDir, { recursive: true, mode: 0o700 });
836
- await mkdir(options.agentDir, { recursive: true, mode: 0o700 });
837
- let sessionManager;
838
- if (options.existingId) {
839
- const listed = await SessionManager.listAll(options.sessionDir);
840
- const match = listed.find((item) => item.id === options.existingId);
841
- if (!match)
842
- throw new Error("PI_SESSION_NOT_FOUND");
843
- sessionManager = SessionManager.open(match.path, options.sessionDir, options.cwd);
844
- }
845
- else {
846
- sessionManager = SessionManager.create(options.cwd, options.sessionDir);
847
- const allocated = sessionManager.getSessionFile();
848
- if (!allocated)
849
- throw new Error("PI_SESSION_FILE_MISSING");
850
- await mkdir(dirname(allocated), { recursive: true, mode: 0o700 });
851
- const placeholder = await open(allocated, "wx", 0o600);
852
- await placeholder.close();
853
- sessionManager.setSessionFile(allocated);
854
- sessionManager.appendCustomEntry("aip-run-binding", { runId: options.runId });
855
- }
856
- const sessionId = sessionManager.getSessionId();
857
- const sessionFile = sessionManager.getSessionFile();
858
- if (!sessionFile || !(await exists(sessionFile)))
859
- throw new Error("PI_SESSION_FILE_NOT_PERSISTED");
860
- const loader = new DefaultResourceLoader({
861
- cwd: options.cwd,
862
- agentDir: options.agentDir,
863
- extensionFactories: options.extensions,
864
- noSkills: true,
865
- noExtensions: true,
866
- noPromptTemplates: true,
867
- noThemes: true,
868
- noContextFiles: true,
869
- systemPrompt: options.systemPrompt,
870
- });
871
- await loader.reload();
872
- const { session } = await createAgentSession({
873
- cwd: options.cwd,
874
- agentDir: options.agentDir,
875
- modelRuntime: options.modelRuntime,
876
- model: options.model,
877
- thinkingLevel: options.thinkingLevel,
878
- resourceLoader: loader,
879
- sessionManager,
880
- });
881
- const savedModel = sessionManager.buildSessionContext().model;
882
- if (options.model &&
883
- (savedModel?.provider !== options.model.provider || savedModel?.modelId !== options.model.id)) {
884
- try {
885
- // SDK 的显式 model 决定本轮调用,已有会话的模型变更仍通过原生接口落盘。
886
- await session.setModel(options.model);
887
- }
888
- catch (error) {
889
- session.dispose();
890
- throw error;
891
- }
892
- }
893
- // SDK 的显式 thinkingLevel 不更新已有会话元数据,补记本轮实际档位。
894
- if (sessionManager.buildSessionContext().thinkingLevel !== session.thinkingLevel) {
895
- sessionManager.appendThinkingLevelChange(session.thinkingLevel);
896
- }
897
- await session.bindExtensions({ mode: "print" });
898
- session.setAutoCompactionEnabled(true);
899
- return { session, sessionId };
900
- }
901
- function subscribeSession(session, emit, observed, redact) {
902
- const publishContext = (compacting = false) => {
903
- const model = session.model;
904
- if (!model)
905
- return;
906
- const usage = session.getContextUsage();
907
- if (!usage)
908
- return;
909
- const settings = session.settingsManager.getCompactionSettings(model);
910
- void emit("CONTEXT_UPDATED", {
911
- contextUsage: {
912
- modelId: `${model.provider}/${model.id}`,
913
- contextWindow: usage.contextWindow,
914
- tokens: compacting ? null : usage.tokens,
915
- status: compacting ? "COMPACTING" : usage.tokens === null ? "UNKNOWN" : "READY",
916
- source: "ESTIMATE",
917
- compressionThreshold: settings.enabled
918
- ? Math.max(1, usage.contextWindow - settings.reserveTokens)
919
- : null,
920
- },
921
- });
922
- };
923
- publishContext();
924
- let messageId = crypto.randomUUID();
925
- let pendingText = "";
926
- let textFlushTimer;
927
- const pendingToolUpdates = new Map();
928
- const toolUpdateTimers = new Map();
929
- const flushText = () => {
930
- if (textFlushTimer)
931
- clearTimeout(textFlushTimer);
932
- textFlushTimer = undefined;
933
- if (!pendingText)
934
- return;
935
- const text = pendingText;
936
- pendingText = "";
937
- void emit("TEXT_DELTA", { text, messageId });
938
- };
939
- const flushToolUpdate = (activityKey) => {
940
- const timer = toolUpdateTimers.get(activityKey);
941
- if (timer)
942
- clearTimeout(timer);
943
- toolUpdateTimers.delete(activityKey);
944
- const update = pendingToolUpdates.get(activityKey);
945
- pendingToolUpdates.delete(activityKey);
946
- if (update)
947
- void emit(update.kind, update.payload);
948
- };
949
- session.subscribe((event) => {
950
- if (event.type === "agent_start") {
951
- observed.executionRevision = (observed.executionRevision ?? 0) + 1;
952
- observed.awaitingDecision = false;
953
- publishContext();
954
- if (observed.messageQueue)
955
- void emit("MESSAGE_QUEUE_UPDATED", { mainAgentRunning: true });
956
- }
957
- else if (event.type === "agent_settled") {
958
- publishContext();
959
- if (observed.messageQueue)
960
- void emit("MESSAGE_QUEUE_UPDATED", { mainAgentRunning: false });
961
- }
962
- else if (event.type === "message_start" && event.message.role === "assistant") {
963
- messageId = crypto.randomUUID();
964
- void emit("MESSAGE_STARTED", { messageId });
965
- }
966
- else if (event.type === "message_start" && event.message.role === "user") {
967
- const id = observed.messageQueue?.consumed(event.message);
968
- if (id)
969
- void emit("MESSAGE_QUEUE_UPDATED", { messageId: id, deliveryStatus: "READ" });
970
- }
971
- else if (event.type === "agent_end") {
972
- observed.nativeWillRetry = event.willRetry === true;
973
- }
974
- else if (event.type === "auto_retry_end") {
975
- observed.nativeWillRetry = false;
976
- if (event.success === false && event.finalError)
977
- observed.lastModelError = event.finalError;
978
- }
979
- else if (event.type === "message_update" &&
980
- event.assistantMessageEvent.type === "text_delta" &&
981
- event.assistantMessageEvent.delta) {
982
- pendingText += redact(event.assistantMessageEvent.delta);
983
- if (pendingText.length >= 4_000)
984
- flushText();
985
- else
986
- textFlushTimer ??= setTimeout(flushText, 200);
987
- }
988
- else if (event.type === "tool_execution_start") {
989
- flushText();
990
- if (event.toolName === "subagent")
991
- return;
992
- void emit("TOOL_STARTED", {
993
- activityKey: event.toolCallId,
994
- toolName: event.toolName,
995
- summary: `执行 ${event.toolName}`,
996
- });
997
- }
998
- else if (event.type === "tool_execution_update") {
999
- if (event.toolName === "subagent")
1000
- return;
1001
- pendingToolUpdates.set(event.toolCallId, {
1002
- kind: "TOOL_UPDATED",
1003
- payload: {
1004
- activityKey: event.toolCallId,
1005
- toolName: event.toolName,
1006
- currentAction: redact(textFromResult(event.partialResult)),
1007
- },
1008
- });
1009
- if (!toolUpdateTimers.has(event.toolCallId))
1010
- toolUpdateTimers.set(event.toolCallId, setTimeout(() => flushToolUpdate(event.toolCallId), 200));
1011
- }
1012
- else if (event.type === "tool_execution_end") {
1013
- publishContext();
1014
- if (event.toolName === "subagent")
1015
- return;
1016
- flushToolUpdate(event.toolCallId);
1017
- void emit("TOOL_COMPLETED", {
1018
- activityKey: event.toolCallId,
1019
- toolName: event.toolName,
1020
- isError: event.isError === true,
1021
- summary: redact(textFromResult(event.result)),
1022
- });
1023
- }
1024
- else if (event.type === "bash_execution_update" && event.delta) {
1025
- const activityKey = event.id ?? "bash";
1026
- pendingToolUpdates.set(activityKey, {
1027
- kind: "TOOL_UPDATED",
1028
- payload: {
1029
- activityKey,
1030
- toolName: "bash",
1031
- currentAction: redact(event.delta),
1032
- },
1033
- });
1034
- if (!toolUpdateTimers.has(activityKey))
1035
- toolUpdateTimers.set(activityKey, setTimeout(() => flushToolUpdate(activityKey), 200));
1036
- }
1037
- else if (event.type === "compaction_start") {
1038
- publishContext(true);
1039
- flushText();
1040
- void emit("TOOL_STARTED", {
1041
- activityKey: `compaction:${event.reason}`,
1042
- toolName: "compaction",
1043
- summary: `上下文压缩(${event.reason})`,
1044
- });
1045
- }
1046
- else if (event.type === "compaction_end") {
1047
- publishContext();
1048
- void emit("TOOL_COMPLETED", {
1049
- activityKey: `compaction:${event.reason}`,
1050
- toolName: "compaction",
1051
- isError: event.aborted === true || Boolean(event.errorMessage),
1052
- summary: redact(event.result?.summary ??
1053
- event.errorMessage ??
1054
- (event.aborted ? "压缩已取消" : "压缩完成")),
1055
- });
1056
- }
1057
- else if (event.type === "message_end" && event.message.role === "assistant") {
1058
- publishContext();
1059
- flushText();
1060
- if ("stopReason" in event.message && event.message.stopReason)
1061
- observed.lastModelStopReason = String(event.message.stopReason);
1062
- if ("errorMessage" in event.message && event.message.errorMessage)
1063
- observed.lastModelError = String(event.message.errorMessage);
1064
- const content = textFromMessage(event.message.content);
1065
- const usage = event.message.usage;
1066
- const payload = {
1067
- contentMarkdown: redact(content),
1068
- messageId,
1069
- };
1070
- Object.assign(payload, localModelUsage(event.message, session.model));
1071
- if (content.trim() || usage)
1072
- void emit("MESSAGE_COMPLETED", payload);
1073
- }
1074
- });
1075
- }
1076
- function textFromMessage(content) {
1077
- if (typeof content === "string")
1078
- return content;
1079
- if (!Array.isArray(content))
1080
- return "";
1081
- return content
1082
- .map((part) => part && typeof part === "object" && "text" in part ? String(part.text ?? "") : "")
1083
- .join("");
1084
- }
1085
- function textFromResult(value) {
1086
- if (!value || typeof value !== "object")
1087
- return "";
1088
- return textFromMessage(value.content);
1089
- }
1090
- async function driveToTerminal(session, initial, observed, client, host, runId, turnId, emit, phase, images = [], completeConversation = async () => { }, continuation) {
1091
- if (observed.stopping)
1092
- return;
1093
- if (continuation && observed.userIntervened)
1094
- return;
1095
- const execution = images.length > 0 ? session.prompt(initial, { images }) : session.prompt(initial);
1096
- // Observe a synchronous rejection while the invocation fact is persisted.
1097
- const outcome = execution.then(() => ({ ok: true }), (error) => ({ ok: false, error }));
1098
- if (continuation) {
1099
- await emit("EXECUTION_CONTINUED", {
1100
- phase,
1101
- ...continuation,
1102
- prompt: initial,
1103
- deliveryStatus: "SUBMITTED",
1104
- });
1105
- }
1106
- const result = await outcome;
1107
- if (!result.ok)
1108
- throw result.error;
1109
- while (!observed.stopping) {
1110
- await session.waitForIdle();
1111
- if (session.isIdle === false)
1112
- continue;
1113
- const executionRevision = observed.executionRevision ?? 0;
1114
- const superseded = () => (observed.executionRevision ?? 0) !== executionRevision;
1115
- observed.awaitingDecision = true;
1116
- if (observed.stopping)
1117
- return;
1118
- const stopReason = observed.terminalClosed
1119
- ? "TERMINAL_CLOSED"
1120
- : (observed.lastModelStopReason ?? "idle");
1121
- const endFact = { phase, stopReason, nativeStopReason: observed.lastModelStopReason ?? null };
1122
- if (observed.terminalReached) {
1123
- await emit("EXECUTION_DECIDED", {
1124
- ...endFact,
1125
- decision: "SKIP",
1126
- reason: observed.deploymentCheckPaused ? "DEPLOYMENT_CHECK_PAUSED" : "TERMINAL_ACCEPTED",
1127
- model: null,
1128
- });
1129
- return;
1130
- }
1131
- if (observed.lastModelStopReason === "aborted" ||
1132
- (observed.lastModelStopReason === "error" && observed.nativeWillRetry !== true)) {
1133
- const loginRequired = isProviderLoginRequired(observed.lastModelError);
1134
- const code = loginRequired
1135
- ? "PROVIDER_LOGIN_REQUIRED"
1136
- : observed.lastModelError?.split("\n")[0]?.slice(0, 200) ||
1137
- (observed.lastModelStopReason === "aborted"
1138
- ? "PI_MODEL_ABORTED"
1139
- : "MODEL_REQUEST_FAILED");
1140
- const message = loginRequired
1141
- ? "模型服务登录已失效,请到本地开发环境重新登录对应订阅后重试。"
1142
- : (observed.lastModelError ?? code);
1143
- await emit("EXECUTION_DECIDED", {
1144
- ...endFact,
1145
- decision: "SKIP",
1146
- reason: "MODEL_ERROR",
1147
- model: null,
1148
- });
1149
- if (observed.stopping)
1150
- return;
1151
- await client.reportCodingTerminal(runId, {
1152
- hostId: host.hostId,
1153
- generation: host.generation,
1154
- turnId,
1155
- kind: "FAILED",
1156
- summary: message,
1157
- knownIssues: "",
1158
- failureCode: code,
1159
- projectFacts: [],
1160
- testFacts: [],
1161
- });
1162
- observed.terminalReached = true;
1163
- await emit("RUN_FAILED", { phase, code, message });
1164
- return;
1165
- }
1166
- // Judge reads durable messages. It queues automatic work through the same command
1167
- // claim boundary that gives user messages and stop priority.
1168
- await emit.flush();
1169
- if (observed.stopping)
1170
- return;
1171
- if (superseded())
1172
- continue;
1173
- let decision;
1174
- try {
1175
- decision = await client.evaluateContinuation(runId, {
1176
- hostId: host.hostId,
1177
- generation: host.generation,
1178
- turnId,
1179
- stopReason,
1180
- ...(observed.lastDeliveryError
1181
- ? { lastDeliveryError: observed.lastDeliveryError.slice(0, 2000) }
1182
- : {}),
1183
- });
1184
- }
1185
- catch (error) {
1186
- if (observed.stopping)
1187
- return;
1188
- if (superseded())
1189
- continue;
1190
- await emit("EXECUTION_DECIDED", {
1191
- ...endFact,
1192
- decision: "SKIP",
1193
- reason: "JUDGE_REQUEST_FAILED",
1194
- model: null,
1195
- explanation: error instanceof Error ? error.message : String(error),
1196
- });
1197
- if (observed.handingOffInput)
1198
- return;
1199
- if (superseded())
1200
- continue;
1201
- await completeConversation();
1202
- observed.terminalReached = true;
1203
- return;
1204
- }
1205
- if (observed.stopping)
1206
- return;
1207
- await emit("EXECUTION_DECIDED", {
1208
- ...endFact,
1209
- ...decision,
1210
- ...(superseded() ? { decision: "SKIP", reason: "EXECUTION_RESUMED" } : {}),
1211
- });
1212
- if (superseded()) {
1213
- if (decision.auditId) {
1214
- observed.obsoleteContinuationAudits ??= new Set();
1215
- observed.obsoleteContinuationAudits.add(decision.auditId);
1216
- }
1217
- continue;
1218
- }
1219
- // The platform has queued the continuation; never execute the returned prompt
1220
- // directly, because a user can cancel it before the host claims the command.
1221
- if (decision.decision === "CONTINUE")
1222
- return;
1223
- if (observed.stopping || observed.handingOffInput)
1224
- return;
1225
- await completeConversation();
1226
- observed.terminalReached = true;
1227
- return;
1228
- }
1229
- }
1230
- export async function prepareDeploymentProjects(runRoot, projects, configuration) {
1231
- throwIfOperationAborted();
1232
- await mkdir(runRoot, { recursive: true, mode: 0o700 });
1233
- for (const project of projects) {
1234
- throwIfOperationAborted();
1235
- const target = join(runRoot, safeName(project.name));
1236
- const branch = configuration?.projects.find((p) => p.projectId === project.id)?.testBranch ??
1237
- project.testBranch;
1238
- if (!branch)
1239
- throw new Error("DEPLOYMENT_TEST_BRANCH_REQUIRED");
1240
- if (!(await exists(target))) {
1241
- await execFileAsync("git", [
1242
- "clone",
1243
- "--branch",
1244
- branch,
1245
- "--",
1246
- await gitTransportUrl(project.repositoryUrl),
1247
- target,
1248
- ]).catch((error) => {
1249
- logGitPreparationFailure(error, {
1250
- projectId: project.id,
1251
- projectName: project.name,
1252
- branch,
1253
- target,
1254
- });
1255
- throw gitFailure(`DEPLOYMENT_REPOSITORY_PREPARE_FAILED:${HTTP_ACCESS_HINT}`, error);
1256
- });
1257
- }
1258
- // Reuse the interrupted deployment as-is; the employee resolves its Git state.
1259
- const [{ stdout: origin }, { stdout: common }] = await Promise.all([
1260
- execFileAsync("git", ["config", "--get", "remote.origin.url"], { cwd: target }),
1261
- execFileAsync("git", ["rev-parse", "--git-common-dir"], { cwd: target }),
1262
- ]);
1263
- if (!(await matchesRepository(origin.trim(), project.repositoryUrl)))
1264
- throw new Error("CODING_REPOSITORY_ORIGIN_MISMATCH");
1265
- if ((await realpath(resolve(target, common.trim()))) !== (await realpath(join(target, ".git"))))
1266
- throw new Error("DEPLOYMENT_REPOSITORY_NOT_ISOLATED");
1267
- await ensureHttpOrigin(target, project.repositoryUrl);
1268
- }
1269
- return projects.length === 1 ? join(runRoot, safeName(projects[0].name)) : runRoot;
1270
- }
1271
- export async function prepareProjects(cacheRoot, runRoot, workItemKey, projects, resume, verifyRemote = false, uninitializedProjectIds = [], preserveExisting = false) {
1272
- throwIfOperationAborted();
1273
- await mkdir(cacheRoot, { recursive: true, mode: 0o700 });
1274
- for (const project of projects) {
1275
- const mirror = join(cacheRoot, `${project.id}.git`);
1276
- // 跨 Worker 与 CLI 保护同一镜像;取消等待者不能释放当前持有者的锁。
1277
- logHostEvent("repository_preparation_waiting", { projectId: project.id, workItemKey });
1278
- const release = await acquireOperationLock(mirror);
1279
- try {
1280
- throwIfOperationAborted();
1281
- logHostEvent("repository_preparation_started", { projectId: project.id, workItemKey });
1282
- const target = join(runRoot, safeName(project.name));
1283
- const expectedBranch = project.devBranch || `aip/${workItemKey}`;
1284
- const existingWorktree = await exists(target);
1285
- // 会话接续只校验并复用现有现场;远端同步属于交接流程,不应覆盖或阻塞本机成果。
1286
- if (preserveExisting && existingWorktree) {
1287
- await validateWorktree(mirror, target, expectedBranch, true, project.repositoryUrl);
1288
- logHostEvent("repository_preparation_completed", { projectId: project.id, workItemKey });
1289
- continue;
1290
- }
1291
- if (!(await exists(mirror))) {
1292
- await execFileAsync("git", [
1293
- "clone",
1294
- "--bare",
1295
- await gitTransportUrl(project.repositoryUrl),
1296
- mirror,
1297
- ]).catch((error) => {
1298
- throw gitFailure(`CODING_REPOSITORY_ACCESS_FAILED:${HTTP_ACCESS_HINT}`, error);
1299
- });
1300
- }
1301
- else {
1302
- const [{ stdout: bare }, { stdout: origin }] = await Promise.all([
1303
- execFileAsync("git", ["--git-dir", mirror, "rev-parse", "--is-bare-repository"]),
1304
- execFileAsync("git", ["--git-dir", mirror, "config", "--get", "remote.origin.url"]),
1305
- ]);
1306
- if (bare.trim() !== "true")
1307
- throw new Error("CODING_REPOSITORY_CACHE_NOT_BARE");
1308
- if (!(await matchesRepository(origin.trim(), project.repositoryUrl)))
1309
- throw new Error("CODING_REPOSITORY_ORIGIN_MISMATCH");
1310
- }
1311
- await ensureHttpOrigin(mirror, project.repositoryUrl);
1312
- if (!resume || verifyRemote) {
1313
- // Never fetch into local branch refs: stopped worktrees may contain unpublished commits.
1314
- await execFileAsync("git", [
1315
- "--git-dir",
1316
- mirror,
1317
- "config",
1318
- "--replace-all",
1319
- "remote.origin.fetch",
1320
- "+refs/heads/*:refs/remotes/origin/*",
1321
- ]);
1322
- await execFileAsync("git", ["--git-dir", mirror, "fetch", "--prune", "origin"]).catch((error) => {
1323
- throw gitFailure(`CODING_REPOSITORY_ACCESS_FAILED:${HTTP_ACCESS_HINT}`, error);
1324
- });
1325
- }
1326
- if (!existingWorktree) {
1327
- if (resume)
1328
- throw new Error("CODING_RUN_WORKTREE_MISSING");
1329
- const remoteExists = await execFileAsync("git", [
1330
- "--git-dir",
1331
- mirror,
1332
- "show-ref",
1333
- "--verify",
1334
- "--quiet",
1335
- `refs/remotes/origin/${expectedBranch}`,
1336
- ]).then(() => true, missingGitRef);
1337
- const localExists = await execFileAsync("git", [
1338
- "--git-dir",
1339
- mirror,
1340
- "show-ref",
1341
- "--verify",
1342
- "--quiet",
1343
- `refs/heads/${expectedBranch}`,
1344
- ]).then(() => true, missingGitRef);
1345
- if (remoteExists) {
1346
- // A new execution owns its branch ref; an old execution keeps its worktree untouched.
1347
- await execFileAsync("git", [
1348
- "clone",
1349
- "--single-branch",
1350
- "--branch",
1351
- expectedBranch,
1352
- await gitTransportUrl(project.repositoryUrl),
1353
- target,
1354
- ]).catch((error) => {
1355
- throw gitFailure(`CODING_REPOSITORY_ACCESS_FAILED:${HTTP_ACCESS_HINT}`, error);
1356
- });
1357
- }
1358
- else {
1359
- if (localExists || (verifyRemote && !uninitializedProjectIds.includes(project.id)))
1360
- throw new Error(localExists
1361
- ? "CODING_BRANCH_NOT_PUBLISHED:本机工单分支尚未推送,请检查并同步后再继续。"
1362
- : "CODING_BRANCH_INITIALIZATION_UNCONFIRMED:远端尚无工单分支,原工作区初始化状态未确认,请检查后再继续。");
1363
- const startingPoint = `refs/remotes/origin/${project.baselineBranch}`;
1364
- await execFileAsync("git", ["--git-dir", mirror, "cat-file", "-e", startingPoint]).catch((error) => {
1365
- throw gitFailure("CODING_BASELINE_BRANCH_UNAVAILABLE", error);
1366
- });
1367
- await execFileAsync("git", [
1368
- "--git-dir",
1369
- mirror,
1370
- "worktree",
1371
- "add",
1372
- "-b",
1373
- expectedBranch,
1374
- target,
1375
- startingPoint,
1376
- ]).catch((error) => {
1377
- throw gitFailure("CODING_WORKTREE_CREATE_FAILED", error);
1378
- });
1379
- }
1380
- }
1381
- if (!existingWorktree)
1382
- await writeSecureJson(join(mirror, ".aip-last-checkout.json"), {
1383
- usedAt: new Date().toISOString(),
1384
- });
1385
- await validateWorktree(mirror, target, expectedBranch, resume || existingWorktree, project.repositoryUrl);
1386
- if (existingWorktree && verifyRemote)
1387
- await synchronizeRemoteWorkspace(target, expectedBranch);
1388
- logHostEvent("repository_preparation_completed", { projectId: project.id, workItemKey });
1389
- }
1390
- finally {
1391
- if (operationCleanupConfirmed())
1392
- await release();
1393
- }
1394
- }
1395
- const onlyProject = projects.length === 1 ? projects[0] : null;
1396
- return onlyProject ? join(runRoot, safeName(onlyProject.name)) : runRoot;
1397
- }
1398
- async function validateWorktree(mirror, target, expectedBranch, resume, repositoryUrl) {
1399
- const facts = await Promise.all([
1400
- execFileAsync("git", ["rev-parse", "--is-inside-work-tree"], { cwd: target }),
1401
- execFileAsync("git", ["rev-parse", "--git-common-dir"], { cwd: target }),
1402
- execFileAsync("git", ["branch", "--show-current"], { cwd: target }),
1403
- ]).catch((error) => {
1404
- throw gitFailure("CODING_WORKTREE_OWNERSHIP_INVALID", error);
1405
- });
1406
- const [{ stdout: inside }, { stdout: common }, { stdout: branch }] = facts;
1407
- if (inside.trim() !== "true")
1408
- throw new Error("CODING_WORKTREE_OWNERSHIP_INVALID");
1409
- const commonPath = common.trim();
1410
- const [actualCommon, expectedCommon] = await Promise.all([
1411
- realpath(commonPath.startsWith("/") ? commonPath : resolve(target, commonPath)),
1412
- realpath(mirror).catch((error) => {
1413
- if (error.code === "ENOENT")
1414
- return null;
1415
- throw error;
1416
- }),
1417
- ]);
1418
- if (actualCommon !== expectedCommon) {
1419
- if (actualCommon !== (await realpath(join(target, ".git"))))
1420
- throw new Error("CODING_WORKTREE_OWNERSHIP_INVALID");
1421
- const { stdout: origin } = await execFileAsync("git", ["config", "--get", "remote.origin.url"], {
1422
- cwd: target,
1423
- });
1424
- if (!(await matchesRepository(origin.trim(), repositoryUrl)))
1425
- throw new Error("CODING_REPOSITORY_ORIGIN_MISMATCH");
1426
- }
1427
- if (branch.trim() !== expectedBranch)
1428
- throw new Error("CODING_WORKTREE_BRANCH_MISMATCH");
1429
- await ensureHttpOrigin(target, repositoryUrl);
1430
- if (resume)
1431
- return;
1432
- const { stdout: status } = await execFileAsync("git", ["status", "--porcelain"], {
1433
- cwd: target,
1434
- });
1435
- if (status.trim())
1436
- throw new Error("CODING_WORKTREE_NOT_CLEAN");
1437
- }
1438
- function executionInstructions(input, runRoot) {
1439
- // 环境事实与授权单独呈现,业务方法由平台 nodeRules 提供。
1440
- return `本轮执行上下文:\n${JSON.stringify({
1441
- phase: input.phase,
1442
- executionPurpose: input.executionPurpose ?? null,
1443
- discussionOnly: input.conversationContext?.discussionOnly ?? false,
1444
- ...(input.executionPurpose === "RELEASE"
1445
- ? {
1446
- mergeRequests: input.projects.map((project) => ({
1447
- project: project.name,
1448
- sourceBranch: project.releaseBranch ?? project.devBranch,
1449
- targetBranch: project.baselineBranch,
1450
- remoteReleaseBranch: Boolean(project.releaseBranch),
1451
- })),
1452
- }
1453
- : {}),
1454
- ...(input.phase === "DEPLOYMENT"
1455
- ? { deploymentConfiguration: input.deploymentConfiguration ?? null }
1456
- : {}),
1457
- testHandoff: input.testHandoff
1458
- ? {
1459
- summary: input.testHandoff.summary,
1460
- ...(input.testHandoff.files
1461
- ? {
1462
- files: input.testHandoff.files.map(({ source, baseSource, materialPath, baseMaterialPath, ...metadata }) => ({
1463
- ...metadata,
1464
- materialPath: join(deliveryDirectory(runRoot, input), materialPath),
1465
- ...(baseMaterialPath
1466
- ? {
1467
- baseMaterialPath: join(deliveryDirectory(runRoot, input), baseMaterialPath),
1468
- }
1469
- : {}),
1470
- })),
1471
- }
1472
- : {}),
1473
- }
1474
- : null,
1475
- }, null, 2)}`;
1476
- }
1477
- async function workspaceFingerprint(runRoot, input) {
1478
- return JSON.stringify(await Promise.all(input.projects.map(async (project) => {
1479
- const cwd = join(runRoot, safeName(project.name));
1480
- const [head, branch, tree] = await Promise.all([
1481
- execFileAsync("git", ["rev-parse", "HEAD"], { cwd }),
1482
- execFileAsync("git", ["symbolic-ref", "--short", "-q", "HEAD"], { cwd }),
1483
- worktreeTreeHash(cwd),
1484
- ]);
1485
- return [project.id, head.stdout.trim(), branch.stdout.trim(), tree];
1486
- })));
1487
- }
1488
- export function initialPrompt(input, runRoot, _responsible = true, materialRoot = runRoot) {
1489
- const directory = deliveryDirectory(materialRoot, input);
1490
- const projects = input.projects
1491
- .map((p) => `- ${p.name}: ${join(runRoot, safeName(p.name))}(开发分支 ${p.devBranch},基准分支 ${p.baselineBranch}${input.phase === "DEPLOYMENT" ? `;测试分支 ${p.testBranch}` : ""})${p.id === input.primaryProjectId ? "(主项目)" : ""}`)
1492
- .join("\n");
1493
- return `工单:${input.workItem.key} ${input.workItem.title}。\n当前阶段:${input.executionPurpose === "RELEASE" ? "RELEASE" : input.phase}。\n项目:\n${projects}\n输入材料:${input.materialPreparation.inputPaths.map((path) => join(directory, path)).join("、")}。\n交付目录:${directory}。${input.inputConflict ? "正式输入材料已更新。" : ""}\n${executionInstructions(input, materialRoot)}`;
1494
- }
1495
- function safeName(value) {
1496
- return basename(value).replace(/[^a-zA-Z0-9._-]/gu, "-") || "project";
1497
- }
1498
- async function exists(path) {
1499
- try {
1500
- await stat(path);
1501
- return true;
1502
- }
1503
- catch {
1504
- return false;
1505
- }
1506
- }
1507
- /** 检查失败命令自己的已知工作区,不从空准备结果推测初始化状态。 */
1508
- export async function inspectWorkspaceInitialization(runId, input) {
1509
- const local = paths();
1510
- return Promise.all(input.projects.map(async (project) => {
1511
- let status = "UNKNOWN";
1512
- try {
1513
- const target = join(local.runWorktrees, runId, safeName(project.name));
1514
- const mirror = join(local.repositoryCache, `${project.id}.git`);
1515
- const present = async (path) => {
1516
- try {
1517
- await stat(path);
1518
- return true;
1519
- }
1520
- catch (error) {
1521
- if (error.code === "ENOENT")
1522
- return false;
1523
- throw error;
1524
- }
1525
- };
1526
- if (await present(target)) {
1527
- const branch = (await execFileAsync("git", ["branch", "--show-current"], { cwd: target })).stdout.trim();
1528
- await execFileAsync("git", ["rev-parse", "--verify", "HEAD^{commit}"], { cwd: target });
1529
- if (branch === (project.devBranch || `aip/${input.workItem.key}`))
1530
- status = "INITIALIZED";
1531
- }
1532
- else if (!(await present(mirror)))
1533
- status = "NOT_INITIALIZED";
1534
- else {
1535
- const refs = await execFileAsync("git", [
1536
- "--git-dir",
1537
- mirror,
1538
- "for-each-ref",
1539
- "--format=%(refname)",
1540
- `refs/heads/${project.devBranch || `aip/${input.workItem.key}`}`,
1541
- ]);
1542
- status = refs.stdout.trim() ? "INITIALIZED" : "NOT_INITIALIZED";
1543
- }
1544
- }
1545
- catch {
1546
- /* 不可访问或损坏的缓存不能证明没有旧成果。 */
1547
- }
1548
- return { projectId: project.id, status };
1549
- }));
1550
- }
1551
- export async function inspectPriorTransferWorkspaces(root, runIds, projects) {
1552
- const notes = [];
1553
- for (const id of runIds) {
1554
- if (!/^[0-9a-f-]{36}$/iu.test(id))
1555
- throw new Error("CODING_PRIOR_RUN_ID_INVALID");
1556
- for (const project of projects) {
1557
- const cwd = join(root, id, safeName(project.name));
1558
- try {
1559
- try {
1560
- await stat(cwd);
1561
- }
1562
- catch (error) {
1563
- if (error.code === "ENOENT")
1564
- continue;
1565
- throw error;
1566
- }
1567
- const origin = (await execFileAsync("git", ["config", "--get", "remote.origin.url"], { cwd })).stdout.trim();
1568
- const branch = (await execFileAsync("git", ["branch", "--show-current"], { cwd })).stdout.trim();
1569
- if (!(await matchesRepository(origin, project.repositoryUrl)) ||
1570
- branch !== project.devBranch)
1571
- throw new Error("WORKSPACE_IDENTITY_MISMATCH");
1572
- await ensureHttpOrigin(cwd, project.repositoryUrl);
1573
- await execFileAsync("git", ["fetch", "origin", `+refs/heads/${branch}:refs/remotes/origin/${branch}`], { cwd });
1574
- const counts = (await execFileAsync("git", ["rev-list", "--left-right", "--count", `HEAD...refs/remotes/origin/${branch}`], { cwd })).stdout
1575
- .trim()
1576
- .split(/\s+/u);
1577
- const dirty = Boolean((await execFileAsync("git", ["status", "--porcelain"], { cwd })).stdout.trim());
1578
- notes.push(`${project.name},旧执行 ${id}:${dirty ? "有未提交修改" : "无未提交修改"},本地领先 ${counts[0]}、远端领先 ${counts[1]}${Number(counts[0]) && Number(counts[1]) ? "(已分叉)" : ""}。旧现场保留在 ${cwd};本次使用独立工作区,请核对需要保留的修改。`);
1579
- }
1580
- catch {
1581
- notes.push(`${project.name},旧执行 ${id}:无法确认旧现场与远端差异,旧现场未改动,请检查 ${cwd}。`);
1582
- }
1583
- }
1584
- }
1585
- return notes;
1586
- }
1587
- //# sourceMappingURL=coding-run-manager.js.map