dsh-cliworker-now 0.0.0-stage → 0.7.7

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 (344) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +364 -0
  3. package/README.md +368 -2
  4. package/cordis.patch.yml +3 -0
  5. package/lib/account-models.mjs +262 -0
  6. package/lib/client.js +22139 -0
  7. package/lib/client.js.map +1 -0
  8. package/lib/grok-catalog.mjs +145 -0
  9. package/lib/hermes-native-entry.py +96 -0
  10. package/lib/hermes-nous-refresh.py +331 -0
  11. package/lib/index.js +14544 -0
  12. package/lib/index.js.map +1 -0
  13. package/lib/native-launch.mjs +234 -0
  14. package/lib/native-spawn.mjs +32 -0
  15. package/lib/own-account-lease.mjs +105 -0
  16. package/lib/pi-installation.mjs +87 -0
  17. package/lib/pi-login.mjs +80 -0
  18. package/lib/pi-native-catalog.mjs +417 -0
  19. package/lib/pi-omp-bridge.mjs +602 -0
  20. package/lib/pi-omp-environment.mjs +15 -0
  21. package/lib/pi-omp-refresh.mjs +324 -0
  22. package/lib/private-launch.mjs +23 -0
  23. package/lib/terminal-bridge.mjs +18 -0
  24. package/lib/typert.host.d.ts +3 -0
  25. package/lib/typert.host.js +1430 -0
  26. package/lib/typert.remote-client.d.ts +72 -0
  27. package/lib/typert.remote-client.d.ts.map +1 -0
  28. package/lib/typert.remote-client.js +1256 -0
  29. package/lib/types/client/account-query-queue.d.ts +16 -0
  30. package/lib/types/client/account-query-queue.js +61 -0
  31. package/lib/types/client/account-query-queue.js.map +1 -0
  32. package/lib/types/client/account-terminal-css.d.ts +1 -0
  33. package/lib/types/client/account-terminal-css.js +3 -0
  34. package/lib/types/client/account-terminal-css.js.map +1 -0
  35. package/lib/types/client/account-terminal.d.ts +17 -0
  36. package/lib/types/client/account-terminal.js +525 -0
  37. package/lib/types/client/account-terminal.js.map +1 -0
  38. package/lib/types/client/assets/antigravity.png +0 -0
  39. package/lib/types/client/assets/claude-code.png +0 -0
  40. package/lib/types/client/assets/cliworker-now-logo.png +0 -0
  41. package/lib/types/client/assets/codex.png +0 -0
  42. package/lib/types/client/assets/grok.png +0 -0
  43. package/lib/types/client/assets/hermes.png +0 -0
  44. package/lib/types/client/assets/kimi-dark.png +0 -0
  45. package/lib/types/client/assets/kimi-light.png +0 -0
  46. package/lib/types/client/assets/mimo-code.png +0 -0
  47. package/lib/types/client/assets/omp.png +0 -0
  48. package/lib/types/client/assets/opencode.png +0 -0
  49. package/lib/types/client/assets/pi.png +0 -0
  50. package/lib/types/client/assets/zcode.png +0 -0
  51. package/lib/types/client/composer-keymap.d.ts +18 -0
  52. package/lib/types/client/composer-keymap.js +49 -0
  53. package/lib/types/client/composer-keymap.js.map +1 -0
  54. package/lib/types/client/conversation-timeline.d.ts +6 -0
  55. package/lib/types/client/conversation-timeline.js +65 -0
  56. package/lib/types/client/conversation-timeline.js.map +1 -0
  57. package/lib/types/client/copy-text.d.ts +5 -0
  58. package/lib/types/client/copy-text.js +45 -0
  59. package/lib/types/client/copy-text.js.map +1 -0
  60. package/lib/types/client/icons.d.ts +21 -0
  61. package/lib/types/client/icons.js +68 -0
  62. package/lib/types/client/icons.js.map +1 -0
  63. package/lib/types/client/index.d.ts +3 -0
  64. package/lib/types/client/index.js +124 -0
  65. package/lib/types/client/index.js.map +1 -0
  66. package/lib/types/client/management-styles.d.ts +1 -0
  67. package/lib/types/client/management-styles.js +17 -0
  68. package/lib/types/client/management-styles.js.map +1 -0
  69. package/lib/types/client/name-copy.d.ts +5 -0
  70. package/lib/types/client/name-copy.js +107 -0
  71. package/lib/types/client/name-copy.js.map +1 -0
  72. package/lib/types/client/native-job-overlay.d.ts +11 -0
  73. package/lib/types/client/native-job-overlay.js +129 -0
  74. package/lib/types/client/native-job-overlay.js.map +1 -0
  75. package/lib/types/client/operation-error.d.ts +2 -0
  76. package/lib/types/client/operation-error.js +12 -0
  77. package/lib/types/client/operation-error.js.map +1 -0
  78. package/lib/types/client/panel.d.ts +8 -0
  79. package/lib/types/client/panel.js +310 -0
  80. package/lib/types/client/panel.js.map +1 -0
  81. package/lib/types/client/rename-copy-styles.d.ts +1 -0
  82. package/lib/types/client/rename-copy-styles.js +21 -0
  83. package/lib/types/client/rename-copy-styles.js.map +1 -0
  84. package/lib/types/client/rename-worker.d.ts +9 -0
  85. package/lib/types/client/rename-worker.js +53 -0
  86. package/lib/types/client/rename-worker.js.map +1 -0
  87. package/lib/types/client/role-presets.d.ts +6 -0
  88. package/lib/types/client/role-presets.js +111 -0
  89. package/lib/types/client/role-presets.js.map +1 -0
  90. package/lib/types/client/settings-dialog.d.ts +13 -0
  91. package/lib/types/client/settings-dialog.js +442 -0
  92. package/lib/types/client/settings-dialog.js.map +1 -0
  93. package/lib/types/client/stat-popover.d.ts +10 -0
  94. package/lib/types/client/stat-popover.js +32 -0
  95. package/lib/types/client/stat-popover.js.map +1 -0
  96. package/lib/types/client/styles.d.ts +9 -0
  97. package/lib/types/client/styles.js +221 -0
  98. package/lib/types/client/styles.js.map +1 -0
  99. package/lib/types/client/telemetry.d.ts +11 -0
  100. package/lib/types/client/telemetry.js +24 -0
  101. package/lib/types/client/telemetry.js.map +1 -0
  102. package/lib/types/client/worker-card.d.ts +10 -0
  103. package/lib/types/client/worker-card.js +75 -0
  104. package/lib/types/client/worker-card.js.map +1 -0
  105. package/lib/types/client/worker-model-menu.d.ts +9 -0
  106. package/lib/types/client/worker-model-menu.js +136 -0
  107. package/lib/types/client/worker-model-menu.js.map +1 -0
  108. package/lib/types/client/workers.d.ts +21 -0
  109. package/lib/types/client/workers.js +59 -0
  110. package/lib/types/client/workers.js.map +1 -0
  111. package/lib/types/client/zcode-login-link-provider.d.ts +9 -0
  112. package/lib/types/client/zcode-login-link-provider.js +105 -0
  113. package/lib/types/client/zcode-login-link-provider.js.map +1 -0
  114. package/lib/types/client/zcode-login-link.d.ts +16 -0
  115. package/lib/types/client/zcode-login-link.js +194 -0
  116. package/lib/types/client/zcode-login-link.js.map +1 -0
  117. package/lib/types/host/account-identity.d.ts +16 -0
  118. package/lib/types/host/account-identity.js +126 -0
  119. package/lib/types/host/account-identity.js.map +1 -0
  120. package/lib/types/host/account-login.d.ts +10 -0
  121. package/lib/types/host/account-login.js +126 -0
  122. package/lib/types/host/account-login.js.map +1 -0
  123. package/lib/types/host/account-models.d.mts +21 -0
  124. package/lib/types/host/account-models.mjs +262 -0
  125. package/lib/types/host/accounts.d.ts +42 -0
  126. package/lib/types/host/accounts.js +945 -0
  127. package/lib/types/host/accounts.js.map +1 -0
  128. package/lib/types/host/adapters.d.ts +24 -0
  129. package/lib/types/host/adapters.js +380 -0
  130. package/lib/types/host/adapters.js.map +1 -0
  131. package/lib/types/host/agy-context.d.ts +8 -0
  132. package/lib/types/host/agy-context.js +122 -0
  133. package/lib/types/host/agy-context.js.map +1 -0
  134. package/lib/types/host/agy-models.d.ts +5 -0
  135. package/lib/types/host/agy-models.js +37 -0
  136. package/lib/types/host/agy-models.js.map +1 -0
  137. package/lib/types/host/agy-windows-account.d.ts +14 -0
  138. package/lib/types/host/agy-windows-account.js +104 -0
  139. package/lib/types/host/agy-windows-account.js.map +1 -0
  140. package/lib/types/host/authorized-catalog.d.ts +14 -0
  141. package/lib/types/host/authorized-catalog.js +35 -0
  142. package/lib/types/host/authorized-catalog.js.map +1 -0
  143. package/lib/types/host/bridge-protocol.d.ts +15 -0
  144. package/lib/types/host/bridge-protocol.js +80 -0
  145. package/lib/types/host/bridge-protocol.js.map +1 -0
  146. package/lib/types/host/claude-native-oauth.d.ts +17 -0
  147. package/lib/types/host/claude-native-oauth.js +272 -0
  148. package/lib/types/host/claude-native-oauth.js.map +1 -0
  149. package/lib/types/host/claude-own-route.d.ts +33 -0
  150. package/lib/types/host/claude-own-route.js +250 -0
  151. package/lib/types/host/claude-own-route.js.map +1 -0
  152. package/lib/types/host/cli-account-binding.d.ts +33 -0
  153. package/lib/types/host/cli-account-binding.js +540 -0
  154. package/lib/types/host/cli-account-binding.js.map +1 -0
  155. package/lib/types/host/cli-protocol.d.ts +27 -0
  156. package/lib/types/host/cli-protocol.js +212 -0
  157. package/lib/types/host/cli-protocol.js.map +1 -0
  158. package/lib/types/host/codex-account.d.ts +8 -0
  159. package/lib/types/host/codex-account.js +143 -0
  160. package/lib/types/host/codex-account.js.map +1 -0
  161. package/lib/types/host/codex-models.d.ts +6 -0
  162. package/lib/types/host/codex-models.js +169 -0
  163. package/lib/types/host/codex-models.js.map +1 -0
  164. package/lib/types/host/extended-adapters.d.ts +44 -0
  165. package/lib/types/host/extended-adapters.js +207 -0
  166. package/lib/types/host/extended-adapters.js.map +1 -0
  167. package/lib/types/host/first-party-account-context.d.ts +26 -0
  168. package/lib/types/host/first-party-account-context.js +55 -0
  169. package/lib/types/host/first-party-account-context.js.map +1 -0
  170. package/lib/types/host/first-party-models.d.ts +29 -0
  171. package/lib/types/host/first-party-models.js +459 -0
  172. package/lib/types/host/first-party-models.js.map +1 -0
  173. package/lib/types/host/grok-adapter.d.ts +44 -0
  174. package/lib/types/host/grok-adapter.js +293 -0
  175. package/lib/types/host/grok-adapter.js.map +1 -0
  176. package/lib/types/host/grok-models.d.ts +47 -0
  177. package/lib/types/host/grok-models.js +320 -0
  178. package/lib/types/host/grok-models.js.map +1 -0
  179. package/lib/types/host/harness-opencode-accounts.d.ts +17 -0
  180. package/lib/types/host/harness-opencode-accounts.js +80 -0
  181. package/lib/types/host/harness-opencode-accounts.js.map +1 -0
  182. package/lib/types/host/hermes-account-context.d.ts +8 -0
  183. package/lib/types/host/hermes-account-context.js +99 -0
  184. package/lib/types/host/hermes-account-context.js.map +1 -0
  185. package/lib/types/host/hermes-accounts.d.ts +19 -0
  186. package/lib/types/host/hermes-accounts.js +356 -0
  187. package/lib/types/host/hermes-accounts.js.map +1 -0
  188. package/lib/types/host/hermes-adapter.d.ts +93 -0
  189. package/lib/types/host/hermes-adapter.js +455 -0
  190. package/lib/types/host/hermes-adapter.js.map +1 -0
  191. package/lib/types/host/hermes-env.d.ts +4 -0
  192. package/lib/types/host/hermes-env.js +22 -0
  193. package/lib/types/host/hermes-env.js.map +1 -0
  194. package/lib/types/host/hermes-installation.d.ts +10 -0
  195. package/lib/types/host/hermes-installation.js +181 -0
  196. package/lib/types/host/hermes-installation.js.map +1 -0
  197. package/lib/types/host/hermes-models.d.ts +26 -0
  198. package/lib/types/host/hermes-models.js +328 -0
  199. package/lib/types/host/hermes-models.js.map +1 -0
  200. package/lib/types/host/hermes-native-entry.py +96 -0
  201. package/lib/types/host/hermes-nous-refresh.py +331 -0
  202. package/lib/types/host/hermes-nous.d.ts +53 -0
  203. package/lib/types/host/hermes-nous.js +343 -0
  204. package/lib/types/host/hermes-nous.js.map +1 -0
  205. package/lib/types/host/hermes-renewal.d.ts +27 -0
  206. package/lib/types/host/hermes-renewal.js +292 -0
  207. package/lib/types/host/hermes-renewal.js.map +1 -0
  208. package/lib/types/host/hermes-suppression.d.ts +7 -0
  209. package/lib/types/host/hermes-suppression.js +69 -0
  210. package/lib/types/host/hermes-suppression.js.map +1 -0
  211. package/lib/types/host/hermes-windows-installation.d.ts +5 -0
  212. package/lib/types/host/hermes-windows-installation.js +91 -0
  213. package/lib/types/host/hermes-windows-installation.js.map +1 -0
  214. package/lib/types/host/index.d.ts +140 -0
  215. package/lib/types/host/index.js +947 -0
  216. package/lib/types/host/index.js.map +1 -0
  217. package/lib/types/host/kimi-accounts.d.ts +17 -0
  218. package/lib/types/host/kimi-accounts.js +220 -0
  219. package/lib/types/host/kimi-accounts.js.map +1 -0
  220. package/lib/types/host/kimi-oauth-models.d.ts +14 -0
  221. package/lib/types/host/kimi-oauth-models.js +246 -0
  222. package/lib/types/host/kimi-oauth-models.js.map +1 -0
  223. package/lib/types/host/managed-agent.d.ts +4 -0
  224. package/lib/types/host/managed-agent.js +127 -0
  225. package/lib/types/host/managed-agent.js.map +1 -0
  226. package/lib/types/host/mimo-configuration.d.ts +22 -0
  227. package/lib/types/host/mimo-configuration.js +258 -0
  228. package/lib/types/host/mimo-configuration.js.map +1 -0
  229. package/lib/types/host/mimo-metadata-cache.d.ts +22 -0
  230. package/lib/types/host/mimo-metadata-cache.js +121 -0
  231. package/lib/types/host/mimo-metadata-cache.js.map +1 -0
  232. package/lib/types/host/native-capability-cache.d.ts +11 -0
  233. package/lib/types/host/native-capability-cache.js +94 -0
  234. package/lib/types/host/native-capability-cache.js.map +1 -0
  235. package/lib/types/host/native-launch.d.mts +2 -0
  236. package/lib/types/host/native-launch.mjs +234 -0
  237. package/lib/types/host/native-process.d.ts +5 -0
  238. package/lib/types/host/native-process.js +41 -0
  239. package/lib/types/host/native-process.js.map +1 -0
  240. package/lib/types/host/native-spawn.mjs +32 -0
  241. package/lib/types/host/opencode-adapter.d.ts +94 -0
  242. package/lib/types/host/opencode-adapter.js +507 -0
  243. package/lib/types/host/opencode-adapter.js.map +1 -0
  244. package/lib/types/host/opencode-native.d.ts +27 -0
  245. package/lib/types/host/opencode-native.js +403 -0
  246. package/lib/types/host/opencode-native.js.map +1 -0
  247. package/lib/types/host/own-account-lease.d.mts +5 -0
  248. package/lib/types/host/own-account-lease.mjs +105 -0
  249. package/lib/types/host/pi-installation.d.mts +7 -0
  250. package/lib/types/host/pi-installation.mjs +87 -0
  251. package/lib/types/host/pi-omp-accounts.d.ts +28 -0
  252. package/lib/types/host/pi-omp-accounts.js +175 -0
  253. package/lib/types/host/pi-omp-accounts.js.map +1 -0
  254. package/lib/types/host/pi-omp-adapter.d.ts +32 -0
  255. package/lib/types/host/pi-omp-adapter.js +190 -0
  256. package/lib/types/host/pi-omp-adapter.js.map +1 -0
  257. package/lib/types/host/pi-omp-environment.d.mts +1 -0
  258. package/lib/types/host/pi-omp-environment.mjs +15 -0
  259. package/lib/types/host/pi-omp-identity.d.ts +2 -0
  260. package/lib/types/host/pi-omp-identity.js +142 -0
  261. package/lib/types/host/pi-omp-identity.js.map +1 -0
  262. package/lib/types/host/pi-omp-logout.d.ts +3 -0
  263. package/lib/types/host/pi-omp-logout.js +152 -0
  264. package/lib/types/host/pi-omp-logout.js.map +1 -0
  265. package/lib/types/host/pi-omp-native.d.ts +71 -0
  266. package/lib/types/host/pi-omp-native.js +753 -0
  267. package/lib/types/host/pi-omp-native.js.map +1 -0
  268. package/lib/types/host/pi-omp-refresh.d.mts +7 -0
  269. package/lib/types/host/pi-omp-refresh.mjs +324 -0
  270. package/lib/types/host/private-launch.mjs +23 -0
  271. package/lib/types/host/process.d.ts +43 -0
  272. package/lib/types/host/process.js +134 -0
  273. package/lib/types/host/process.js.map +1 -0
  274. package/lib/types/host/protocol.d.ts +23 -0
  275. package/lib/types/host/protocol.js +112 -0
  276. package/lib/types/host/protocol.js.map +1 -0
  277. package/lib/types/host/roles.d.ts +34 -0
  278. package/lib/types/host/roles.js +80 -0
  279. package/lib/types/host/roles.js.map +1 -0
  280. package/lib/types/host/routing.d.ts +31 -0
  281. package/lib/types/host/routing.js +248 -0
  282. package/lib/types/host/routing.js.map +1 -0
  283. package/lib/types/host/runtime.d.ts +60 -0
  284. package/lib/types/host/runtime.js +598 -0
  285. package/lib/types/host/runtime.js.map +1 -0
  286. package/lib/types/host/storage.d.ts +48 -0
  287. package/lib/types/host/storage.js +449 -0
  288. package/lib/types/host/storage.js.map +1 -0
  289. package/lib/types/host/telemetry.d.ts +17 -0
  290. package/lib/types/host/telemetry.js +158 -0
  291. package/lib/types/host/telemetry.js.map +1 -0
  292. package/lib/types/host/windows-account-bootstrap.ps1 +44 -0
  293. package/lib/types/host/windows-account-launch.mjs +47 -0
  294. package/lib/types/host/windows-account-owner.ps1 +137 -0
  295. package/lib/types/host/windows-account-stdio.mjs +19 -0
  296. package/lib/types/host/windows-account-terminal.d.ts +17 -0
  297. package/lib/types/host/windows-account-terminal.js +208 -0
  298. package/lib/types/host/windows-account-terminal.js.map +1 -0
  299. package/lib/types/host/windows-agy-account.ps1 +81 -0
  300. package/lib/types/host/windows-cli-installation.d.ts +31 -0
  301. package/lib/types/host/windows-cli-installation.js +157 -0
  302. package/lib/types/host/windows-cli-installation.js.map +1 -0
  303. package/lib/types/host/windows-hidden-launch.mjs +49 -0
  304. package/lib/types/host/windows-hidden-process.d.ts +12 -0
  305. package/lib/types/host/windows-hidden-process.js +116 -0
  306. package/lib/types/host/windows-hidden-process.js.map +1 -0
  307. package/lib/types/host/zcode-account-models.d.ts +16 -0
  308. package/lib/types/host/zcode-account-models.js +114 -0
  309. package/lib/types/host/zcode-account-models.js.map +1 -0
  310. package/lib/types/host/zcode-adapter.d.ts +93 -0
  311. package/lib/types/host/zcode-adapter.js +808 -0
  312. package/lib/types/host/zcode-adapter.js.map +1 -0
  313. package/lib/types/host/zcode-grok-accounts.d.ts +30 -0
  314. package/lib/types/host/zcode-grok-accounts.js +408 -0
  315. package/lib/types/host/zcode-grok-accounts.js.map +1 -0
  316. package/lib/types/shared/accounts.d.ts +47 -0
  317. package/lib/types/shared/accounts.js +2 -0
  318. package/lib/types/shared/accounts.js.map +1 -0
  319. package/lib/types/shared/builtin-presets.d.ts +2 -0
  320. package/lib/types/shared/builtin-presets.js +231 -0
  321. package/lib/types/shared/builtin-presets.js.map +1 -0
  322. package/lib/types/shared/cli-settings.d.ts +5 -0
  323. package/lib/types/shared/cli-settings.js +2 -0
  324. package/lib/types/shared/cli-settings.js.map +1 -0
  325. package/lib/types/shared/model-presentation.d.ts +10 -0
  326. package/lib/types/shared/model-presentation.js +95 -0
  327. package/lib/types/shared/model-presentation.js.map +1 -0
  328. package/lib/types/shared/models.d.ts +7 -0
  329. package/lib/types/shared/models.js +35 -0
  330. package/lib/types/shared/models.js.map +1 -0
  331. package/lib/types/shared/telemetry.d.ts +18 -0
  332. package/lib/types/shared/telemetry.js +16 -0
  333. package/lib/types/shared/telemetry.js.map +1 -0
  334. package/lib/types/shared/types.d.ts +127 -0
  335. package/lib/types/shared/types.js +147 -0
  336. package/lib/types/shared/types.js.map +1 -0
  337. package/lib/windows-account-bootstrap.ps1 +44 -0
  338. package/lib/windows-account-launch.mjs +47 -0
  339. package/lib/windows-account-owner.ps1 +137 -0
  340. package/lib/windows-account-stdio.mjs +19 -0
  341. package/lib/windows-agy-account.ps1 +81 -0
  342. package/lib/windows-hidden-launch.mjs +49 -0
  343. package/lib/zcode-resume.mjs +423 -0
  344. package/package.json +109 -4
@@ -0,0 +1,947 @@
1
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
2
+ var useValue = arguments.length > 2;
3
+ for (var i = 0; i < initializers.length; i++) {
4
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
5
+ }
6
+ return useValue ? value : void 0;
7
+ };
8
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
9
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
10
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
11
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
12
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13
+ var _, done = false;
14
+ for (var i = decorators.length - 1; i >= 0; i--) {
15
+ var context = {};
16
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
17
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
18
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
19
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
20
+ if (kind === "accessor") {
21
+ if (result === void 0) continue;
22
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
23
+ if (_ = accept(result.get)) descriptor.get = _;
24
+ if (_ = accept(result.set)) descriptor.set = _;
25
+ if (_ = accept(result.init)) initializers.unshift(_);
26
+ }
27
+ else if (_ = accept(result)) {
28
+ if (kind === "field") initializers.unshift(_);
29
+ else descriptor[key] = _;
30
+ }
31
+ }
32
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
33
+ done = true;
34
+ };
35
+ import { resolveModel } from "../shared/models.js";
36
+ import { visibleModelChoices } from "../shared/model-presentation.js";
37
+ import z from '@deepseek-ai/schemastery';
38
+ import { z as validate } from 'zod';
39
+ import { homedir } from 'node:os';
40
+ import { join } from 'node:path';
41
+ import { defineTool } from '@deepseek-ai/dsh-tools';
42
+ import { Remote, RemoteError, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
43
+ import { CLI_IDS, CLI_LABELS, cliOf, workerName, effortLabel, LEGACY_ACCOUNT_RECORD_NOTICE, EFFORTS, } from "../shared/types.js";
44
+ import { agentNameSchema, readRoleAnswer, roleQuestion } from "./roles.js";
45
+ import { DEFAULT_CONFIG, projectDirectory, ProcessCleanupUnconfirmedError, } from "./process.js";
46
+ import { nativeProcessBackend } from "./native-process.js";
47
+ import { validatePreference } from "./adapters.js";
48
+ import { authorizedCatalog, authorizeSelection } from "./authorized-catalog.js";
49
+ import { WorkerStorage } from "./storage.js";
50
+ import { WorkerRuntime } from "./runtime.js";
51
+ import { AccountManager } from "./accounts.js";
52
+ import { CLI_DELEGATION_GUIDANCE, CLI_NAME_GUIDANCE, registerCliRouting, requireCliName, resolveCliName, } from "./routing.js";
53
+ const preferenceSchema = validate.object({
54
+ cli: validate.enum(CLI_IDS).optional(),
55
+ model: validate.string().min(1),
56
+ effort: validate.enum(EFFORTS),
57
+ });
58
+ const failure = (error) => new RemoteError('cliworker/unavailable', String(error), { reason: String(error) });
59
+ /** Cancel a question/wait independently; late answers cannot commit a selection. */
60
+ function waitForInput(promise, signal) {
61
+ signal.throwIfAborted();
62
+ return new Promise((resolve, reject) => {
63
+ const aborted = () => {
64
+ signal.removeEventListener('abort', aborted);
65
+ reject(signal.reason ?? new Error('选择已取消'));
66
+ };
67
+ signal.addEventListener('abort', aborted, { once: true });
68
+ promise.then(resolve, reject).finally(() => signal.removeEventListener('abort', aborted));
69
+ });
70
+ }
71
+ /** Host owner of CLI conversations, model tools and Remote streams. */
72
+ let CliWorkerService = (() => {
73
+ let _classSuper = TypertRemoteService;
74
+ let _instanceExtraInitializers = [];
75
+ let _watch_decorators;
76
+ let _history_decorators;
77
+ let _cliSettings_decorators;
78
+ let _rolePresets_decorators;
79
+ let _saveRolePreset_decorators;
80
+ let _deleteRolePreset_decorators;
81
+ let _renameWorker_decorators;
82
+ let _renameWorkerTitle_decorators;
83
+ let _deleteWorker_decorators;
84
+ let _restoreWorker_decorators;
85
+ let _setCliEnabled_decorators;
86
+ let _accountStatus_decorators;
87
+ let _accountStart_decorators;
88
+ let _accountStartForSource_decorators;
89
+ let _accountStartForProvider_decorators;
90
+ let _accountWatch_decorators;
91
+ let _accountWrite_decorators;
92
+ let _accountResize_decorators;
93
+ let _accountStop_decorators;
94
+ let _catalog_decorators;
95
+ let _catalogForCli_decorators;
96
+ let _configure_decorators;
97
+ let _configureWorker_decorators;
98
+ let _followup_decorators;
99
+ let _restartWorker_decorators;
100
+ let _stop_decorators;
101
+ return class CliWorkerService extends _classSuper {
102
+ static {
103
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
104
+ _watch_decorators = [Remote({ mode: 'stream' })];
105
+ _history_decorators = [Remote('history')];
106
+ _cliSettings_decorators = [Remote('cliSettings')];
107
+ _rolePresets_decorators = [Remote('rolePresets')];
108
+ _saveRolePreset_decorators = [Remote('saveRolePreset')];
109
+ _deleteRolePreset_decorators = [Remote('deleteRolePreset')];
110
+ _renameWorker_decorators = [Remote('renameWorker')];
111
+ _renameWorkerTitle_decorators = [Remote('renameWorkerTitle')];
112
+ _deleteWorker_decorators = [Remote('deleteWorker')];
113
+ _restoreWorker_decorators = [Remote('restoreWorker')];
114
+ _setCliEnabled_decorators = [Remote('setCliEnabled')];
115
+ _accountStatus_decorators = [Remote('accountStatus')];
116
+ _accountStart_decorators = [Remote('accountStart')];
117
+ _accountStartForSource_decorators = [Remote('accountStartForSource')];
118
+ _accountStartForProvider_decorators = [Remote('accountStartForProvider')];
119
+ _accountWatch_decorators = [Remote({ mode: 'stream' })];
120
+ _accountWrite_decorators = [Remote('accountWrite')];
121
+ _accountResize_decorators = [Remote('accountResize')];
122
+ _accountStop_decorators = [Remote('accountStop')];
123
+ _catalog_decorators = [Remote('catalog')];
124
+ _catalogForCli_decorators = [Remote('catalogForCli')];
125
+ _configure_decorators = [Remote('configure')];
126
+ _configureWorker_decorators = [Remote('configureWorker')];
127
+ _followup_decorators = [Remote('followup')];
128
+ _restartWorker_decorators = [Remote('restartWorker')];
129
+ _stop_decorators = [Remote('stop')];
130
+ __esDecorate(this, null, _watch_decorators, { kind: "method", name: "watch", static: false, private: false, access: { has: obj => "watch" in obj, get: obj => obj.watch }, metadata: _metadata }, null, _instanceExtraInitializers);
131
+ __esDecorate(this, null, _history_decorators, { kind: "method", name: "history", static: false, private: false, access: { has: obj => "history" in obj, get: obj => obj.history }, metadata: _metadata }, null, _instanceExtraInitializers);
132
+ __esDecorate(this, null, _cliSettings_decorators, { kind: "method", name: "cliSettings", static: false, private: false, access: { has: obj => "cliSettings" in obj, get: obj => obj.cliSettings }, metadata: _metadata }, null, _instanceExtraInitializers);
133
+ __esDecorate(this, null, _rolePresets_decorators, { kind: "method", name: "rolePresets", static: false, private: false, access: { has: obj => "rolePresets" in obj, get: obj => obj.rolePresets }, metadata: _metadata }, null, _instanceExtraInitializers);
134
+ __esDecorate(this, null, _saveRolePreset_decorators, { kind: "method", name: "saveRolePreset", static: false, private: false, access: { has: obj => "saveRolePreset" in obj, get: obj => obj.saveRolePreset }, metadata: _metadata }, null, _instanceExtraInitializers);
135
+ __esDecorate(this, null, _deleteRolePreset_decorators, { kind: "method", name: "deleteRolePreset", static: false, private: false, access: { has: obj => "deleteRolePreset" in obj, get: obj => obj.deleteRolePreset }, metadata: _metadata }, null, _instanceExtraInitializers);
136
+ __esDecorate(this, null, _renameWorker_decorators, { kind: "method", name: "renameWorker", static: false, private: false, access: { has: obj => "renameWorker" in obj, get: obj => obj.renameWorker }, metadata: _metadata }, null, _instanceExtraInitializers);
137
+ __esDecorate(this, null, _renameWorkerTitle_decorators, { kind: "method", name: "renameWorkerTitle", static: false, private: false, access: { has: obj => "renameWorkerTitle" in obj, get: obj => obj.renameWorkerTitle }, metadata: _metadata }, null, _instanceExtraInitializers);
138
+ __esDecorate(this, null, _deleteWorker_decorators, { kind: "method", name: "deleteWorker", static: false, private: false, access: { has: obj => "deleteWorker" in obj, get: obj => obj.deleteWorker }, metadata: _metadata }, null, _instanceExtraInitializers);
139
+ __esDecorate(this, null, _restoreWorker_decorators, { kind: "method", name: "restoreWorker", static: false, private: false, access: { has: obj => "restoreWorker" in obj, get: obj => obj.restoreWorker }, metadata: _metadata }, null, _instanceExtraInitializers);
140
+ __esDecorate(this, null, _setCliEnabled_decorators, { kind: "method", name: "setCliEnabled", static: false, private: false, access: { has: obj => "setCliEnabled" in obj, get: obj => obj.setCliEnabled }, metadata: _metadata }, null, _instanceExtraInitializers);
141
+ __esDecorate(this, null, _accountStatus_decorators, { kind: "method", name: "accountStatus", static: false, private: false, access: { has: obj => "accountStatus" in obj, get: obj => obj.accountStatus }, metadata: _metadata }, null, _instanceExtraInitializers);
142
+ __esDecorate(this, null, _accountStart_decorators, { kind: "method", name: "accountStart", static: false, private: false, access: { has: obj => "accountStart" in obj, get: obj => obj.accountStart }, metadata: _metadata }, null, _instanceExtraInitializers);
143
+ __esDecorate(this, null, _accountStartForSource_decorators, { kind: "method", name: "accountStartForSource", static: false, private: false, access: { has: obj => "accountStartForSource" in obj, get: obj => obj.accountStartForSource }, metadata: _metadata }, null, _instanceExtraInitializers);
144
+ __esDecorate(this, null, _accountStartForProvider_decorators, { kind: "method", name: "accountStartForProvider", static: false, private: false, access: { has: obj => "accountStartForProvider" in obj, get: obj => obj.accountStartForProvider }, metadata: _metadata }, null, _instanceExtraInitializers);
145
+ __esDecorate(this, null, _accountWatch_decorators, { kind: "method", name: "accountWatch", static: false, private: false, access: { has: obj => "accountWatch" in obj, get: obj => obj.accountWatch }, metadata: _metadata }, null, _instanceExtraInitializers);
146
+ __esDecorate(this, null, _accountWrite_decorators, { kind: "method", name: "accountWrite", static: false, private: false, access: { has: obj => "accountWrite" in obj, get: obj => obj.accountWrite }, metadata: _metadata }, null, _instanceExtraInitializers);
147
+ __esDecorate(this, null, _accountResize_decorators, { kind: "method", name: "accountResize", static: false, private: false, access: { has: obj => "accountResize" in obj, get: obj => obj.accountResize }, metadata: _metadata }, null, _instanceExtraInitializers);
148
+ __esDecorate(this, null, _accountStop_decorators, { kind: "method", name: "accountStop", static: false, private: false, access: { has: obj => "accountStop" in obj, get: obj => obj.accountStop }, metadata: _metadata }, null, _instanceExtraInitializers);
149
+ __esDecorate(this, null, _catalog_decorators, { kind: "method", name: "catalog", static: false, private: false, access: { has: obj => "catalog" in obj, get: obj => obj.catalog }, metadata: _metadata }, null, _instanceExtraInitializers);
150
+ __esDecorate(this, null, _catalogForCli_decorators, { kind: "method", name: "catalogForCli", static: false, private: false, access: { has: obj => "catalogForCli" in obj, get: obj => obj.catalogForCli }, metadata: _metadata }, null, _instanceExtraInitializers);
151
+ __esDecorate(this, null, _configure_decorators, { kind: "method", name: "configure", static: false, private: false, access: { has: obj => "configure" in obj, get: obj => obj.configure }, metadata: _metadata }, null, _instanceExtraInitializers);
152
+ __esDecorate(this, null, _configureWorker_decorators, { kind: "method", name: "configureWorker", static: false, private: false, access: { has: obj => "configureWorker" in obj, get: obj => obj.configureWorker }, metadata: _metadata }, null, _instanceExtraInitializers);
153
+ __esDecorate(this, null, _followup_decorators, { kind: "method", name: "followup", static: false, private: false, access: { has: obj => "followup" in obj, get: obj => obj.followup }, metadata: _metadata }, null, _instanceExtraInitializers);
154
+ __esDecorate(this, null, _restartWorker_decorators, { kind: "method", name: "restartWorker", static: false, private: false, access: { has: obj => "restartWorker" in obj, get: obj => obj.restartWorker }, metadata: _metadata }, null, _instanceExtraInitializers);
155
+ __esDecorate(this, null, _stop_decorators, { kind: "method", name: "stop", static: false, private: false, access: { has: obj => "stop" in obj, get: obj => obj.stop }, metadata: _metadata }, null, _instanceExtraInitializers);
156
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
157
+ }
158
+ static inject = [
159
+ 'agents',
160
+ 'tools',
161
+ 'systemPrompt',
162
+ 'jobs',
163
+ 'subprocess',
164
+ 'userQuestions',
165
+ 'sandboxPolicy',
166
+ 'typert',
167
+ ];
168
+ static Config = z.object({
169
+ executable: z.string().min(1).default(DEFAULT_CONFIG.executable),
170
+ codexExecutable: z.string().min(1).default('codex'),
171
+ claudeExecutable: z.string().min(1).default('claude'),
172
+ kimiExecutable: z.string().min(1).default('kimi'),
173
+ mimoExecutable: z.string().min(1).default('mimo'),
174
+ zcodeExecutable: z.string(),
175
+ grokExecutable: z.string(),
176
+ ompExecutable: z.string(),
177
+ piExecutable: z.string(),
178
+ hermesExecutable: z.string(),
179
+ hermesHome: z.string(),
180
+ opencodeExecutable: z.string(),
181
+ zcodeAuthDirectory: z.string(),
182
+ zcodeBuiltinConfig: z.string(),
183
+ zaiCredentialRef: z.string(),
184
+ stateDirectory: z.string(),
185
+ maxConcurrent: z.natural().min(1).max(8).default(DEFAULT_CONFIG.maxConcurrent),
186
+ timeoutMs: z.natural().min(1000).max(86400000).default(DEFAULT_CONFIG.timeoutMs),
187
+ graceMs: z.natural().min(100).max(30000).default(DEFAULT_CONFIG.graceMs),
188
+ maxLineBytes: z.natural().min(1024).default(DEFAULT_CONFIG.maxLineBytes),
189
+ maxRunBytes: z.natural().min(1024).default(DEFAULT_CONFIG.maxRunBytes),
190
+ maxTimelineItems: z.natural().min(10).default(DEFAULT_CONFIG.maxTimelineItems),
191
+ });
192
+ runtime = __runInitializers(this, _instanceExtraInitializers);
193
+ accounts;
194
+ accountParents = new Map();
195
+ options;
196
+ backend;
197
+ pending = new Map();
198
+ dispatchWaits = new Map();
199
+ selectionBindings = new WeakMap();
200
+ selectionProjects = new WeakMap();
201
+ displayedBindings = new Map();
202
+ disposed = new AbortController();
203
+ /** @param ctx - Harness services. @param config - Validated deployment options. */
204
+ constructor(ctx, config) {
205
+ super(ctx, 'cliworker', { namespace: 'cliworker' });
206
+ this.options = {
207
+ ...DEFAULT_CONFIG,
208
+ ...config,
209
+ };
210
+ this.backend = nativeProcessBackend(ctx.subprocess);
211
+ this.accounts = new AccountManager(this.backend, this.options);
212
+ this.runtime = new WorkerRuntime(new WorkerStorage(config.stateDirectory ?? join(process.env.DSH_HOME ?? join(homedir(), '.dsh'), 'cliworker-now')), this.backend, this.options);
213
+ ctx.effect(() => () => {
214
+ this.disposed.abort();
215
+ return Promise.all([
216
+ this.runtime.close(),
217
+ this.accounts.close(),
218
+ ...[...this.accountParents.values()].map((dispose) => dispose()),
219
+ ]);
220
+ }, 'cliworker:lifetime');
221
+ this.registerTools();
222
+ registerCliRouting(ctx);
223
+ ctx.effect(() => ctx.systemPrompt.section({
224
+ name: 'cliworker:delegation',
225
+ order: 80,
226
+ text: CLI_DELEGATION_GUIDANCE,
227
+ }), 'cliworker:guidance');
228
+ }
229
+ async parent(id) {
230
+ // Use the same composition-owned resolution policy as native Remote Agent parameters.
231
+ await this.ctx.typert.lookups.get('agent')?.resolve(id);
232
+ const agent = this.ctx.agents.get(id);
233
+ if (!agent)
234
+ throw new Error('请先在主对话发送一条消息以激活会话,然后重试');
235
+ return agent;
236
+ }
237
+ project(agent) {
238
+ if (!agent.session.header.cwd)
239
+ throw new Error('此主对话没有工作目录,请先选择项目');
240
+ return projectDirectory(agent.session.header.cwd);
241
+ }
242
+ assertExecution(agent) {
243
+ if (agent.session.header.origin === 'subagent')
244
+ throw new Error('MVP 只支持主对话下的直接 CLI 子 Agent');
245
+ // agy's terminal sandbox cannot implement Harness's whole-process read-only
246
+ // policy (its native state is writable). Refuse rather than silently weaken it.
247
+ if (agent.ctx.get('planMode')?.get(agent).active)
248
+ throw new Error('请先退出 Harness 规划模式,再运行外部 CLI;本插件不会绕过规划边界');
249
+ if (agent.ctx.get('sandboxPolicy').resolve({ session: agent.session }).mode === 'read-only')
250
+ throw new Error('Harness 当前为只读权限;外部 CLI 需要可写运行状态,请先明确切换项目权限');
251
+ }
252
+ async queryCatalog(...args) {
253
+ try {
254
+ return await authorizedCatalog(...args);
255
+ }
256
+ catch (error) {
257
+ if (error instanceof ProcessCleanupUnconfirmedError)
258
+ this.runtime.blockOnCleanup(error);
259
+ throw error;
260
+ }
261
+ }
262
+ async querySelection(...args) {
263
+ try {
264
+ return await authorizeSelection(...args);
265
+ }
266
+ catch (error) {
267
+ if (error instanceof ProcessCleanupUnconfirmedError)
268
+ this.runtime.blockOnCleanup(error);
269
+ throw error;
270
+ }
271
+ }
272
+ /** Serialize only this conversation's selection; a cancelled waiter never owns the question. */
273
+ async chooseDispatch(agent, callerSignal, cli) {
274
+ const signal = AbortSignal.any([callerSignal, this.disposed.signal]);
275
+ signal.throwIfAborted();
276
+ this.runtime.assertCliEnabled(cli);
277
+ const project = this.project(agent);
278
+ const key = JSON.stringify([agent.id, project, cli]);
279
+ const waits = (this.dispatchWaits ??= new Map());
280
+ const previous = waits.get(key) ?? Promise.resolve();
281
+ let release;
282
+ const owned = new Promise((resolve) => {
283
+ release = resolve;
284
+ });
285
+ const tail = previous.then(() => owned);
286
+ waits.set(key, tail);
287
+ void tail.then(() => {
288
+ if (waits.get(key) === tail)
289
+ waits.delete(key);
290
+ });
291
+ this.pending.set(agent.id, (this.pending.get(agent.id) ?? 0) + 1);
292
+ this.runtime.changed();
293
+ try {
294
+ await waitForInput(previous, signal);
295
+ signal.throwIfAborted();
296
+ this.assertExecution(agent);
297
+ this.runtime.assertCliEnabled(cli);
298
+ const { catalog, binding } = await this.queryCatalog(cli, this.backend, this.options, project, signal);
299
+ signal.throwIfAborted();
300
+ this.runtime.assertCliEnabled(cli);
301
+ const models = catalog.models;
302
+ const valid = (setup) => {
303
+ if (!setup || setup.binding !== binding || cliOf(setup.preference) !== cli)
304
+ return false;
305
+ try {
306
+ validatePreference(setup.preference, catalog);
307
+ return resolveModel(setup.preference, models).model === setup.preference.model;
308
+ }
309
+ catch {
310
+ return false;
311
+ }
312
+ };
313
+ const ask = async (questions) => {
314
+ signal.throwIfAborted();
315
+ const response = await waitForInput(agent.ctx.get('userQuestions').ask({ agent, signal, questions }), signal);
316
+ signal.throwIfAborted();
317
+ this.runtime.assertCliEnabled(cli);
318
+ return response;
319
+ };
320
+ const current = this.runtime.storage.conversationSetup(agent.id, project, cli);
321
+ let setup = valid(current) ? current : undefined;
322
+ let selected = false;
323
+ if (!current) {
324
+ const saved = this.runtime.storage.dispatchSetup(project, cli);
325
+ if (valid(saved)) {
326
+ const modelLabel = models.find((model) => model.id === saved.preference.model ||
327
+ Object.values(model.variants ?? {}).includes(saved.preference.model))?.label ?? saved.preference.model;
328
+ const response = await ask([
329
+ {
330
+ id: 'cliworker_reuse',
331
+ header: '沿用设定',
332
+ question: `是否沿用 ${modelLabel} · ${effortLabel(saved.preference.effort)} · ${saved.role?.name ?? '不使用角色预设'}?`,
333
+ options: [{ label: '沿用' }, { label: '重新选择' }],
334
+ },
335
+ ]);
336
+ const answer = response.answers.find((item) => item.id === 'cliworker_reuse');
337
+ if (answer?.custom !== undefined ||
338
+ answer?.selected.length !== 1 ||
339
+ !['沿用', '重新选择'].includes(answer.selected[0]))
340
+ throw new Error('请选择沿用或重新选择;任务尚未启动');
341
+ if (answer.selected[0] === '沿用')
342
+ setup = saved;
343
+ }
344
+ }
345
+ if (!setup) {
346
+ const choices = visibleModelChoices(models);
347
+ const response = await ask([
348
+ {
349
+ id: 'cliworker_model',
350
+ header: `${CLI_LABELS[cli]} 模型`,
351
+ question: '选择模型',
352
+ options: choices.map((model) => ({ label: model.label })),
353
+ },
354
+ ]);
355
+ const answer = response.answers.find((item) => item.id === 'cliworker_model');
356
+ const chosen = answer?.custom === undefined && answer?.selected.length === 1
357
+ ? choices.find((model) => model.label === answer.selected[0])
358
+ : undefined;
359
+ if (!chosen?.efforts?.length)
360
+ throw new Error('请选择列表中的模型');
361
+ const offered = structuredClone(this.runtime.storage.rolePresets());
362
+ const questions = [];
363
+ if (chosen.efforts.length > 1)
364
+ questions.push({
365
+ id: 'cliworker_effort',
366
+ header: '思考强度',
367
+ question: `选择 ${chosen.label} 的思考强度`,
368
+ options: chosen.efforts.map((effort) => ({ label: effortLabel(effort) })),
369
+ });
370
+ questions.push(roleQuestion(offered));
371
+ const selection = await ask(questions);
372
+ const effortAnswer = selection.answers.find((item) => item.id === 'cliworker_effort');
373
+ const effort = chosen.efforts.length === 1
374
+ ? chosen.efforts[0]
375
+ : effortAnswer?.custom === undefined && effortAnswer?.selected.length === 1
376
+ ? chosen.efforts.find((effort) => effortLabel(effort) === effortAnswer.selected[0])
377
+ : undefined;
378
+ const preference = resolveModel(preferenceSchema.parse({ cli, model: chosen.id, effort }), models);
379
+ setup = { preference, role: readRoleAnswer(offered, selection) ?? null, binding };
380
+ selected = true;
381
+ }
382
+ // A remembered answer is never execution authority. Detect changes during any question.
383
+ const checked = await this.querySelection(setup.preference, this.backend, this.options, project, signal, binding);
384
+ if (checked.preference.model !== setup.preference.model)
385
+ throw new Error('模型与思考强度已变更,请重新选择');
386
+ signal.throwIfAborted();
387
+ this.assertExecution(agent);
388
+ this.runtime.assertCliEnabled(cli);
389
+ if (this.project(agent) !== project)
390
+ throw new Error('项目已变更,请重新选择');
391
+ if (selected)
392
+ this.runtime.storage.setDispatchSetup(project, setup);
393
+ if (current !== setup)
394
+ this.runtime.storage.setConversationSetup(agent.id, project, setup);
395
+ (this.selectionBindings ??= new WeakMap()).set(setup.preference, binding);
396
+ (this.selectionProjects ??= new WeakMap()).set(setup.preference, project);
397
+ return setup;
398
+ }
399
+ finally {
400
+ release();
401
+ const pending = (this.pending.get(agent.id) ?? 1) - 1;
402
+ if (pending)
403
+ this.pending.set(agent.id, pending);
404
+ else
405
+ this.pending.delete(agent.id);
406
+ this.runtime.changed();
407
+ }
408
+ }
409
+ async launch(agent, title, prompt, preference, mode, workerId, identity, signal = this.disposed.signal, restartSourceId) {
410
+ this.assertExecution(agent);
411
+ this.runtime.assertCliEnabled(cliOf(preference));
412
+ if (this.accounts.isBusy(cliOf(preference)))
413
+ throw new Error('此 CLI 正在管理账号,请先关闭账号终端再启动任务');
414
+ const project = this.project(agent);
415
+ const selectedProject = this.selectionProjects?.get(preference);
416
+ if (!workerId && selectedProject && selectedProject !== project)
417
+ throw new Error('项目已变更,请重新选择');
418
+ const expected = workerId
419
+ ? this.runtime.storage.accountBinding(workerId)
420
+ : this.selectionBindings?.get(preference);
421
+ if (workerId && !expected)
422
+ throw new Error(LEGACY_ACCOUNT_RECORD_NOTICE);
423
+ const { binding, preference: authorizedPreference } = await this.querySelection(preference, this.backend, this.options, project, signal, expected);
424
+ if (authorizedPreference.model !== preference.model)
425
+ throw new Error('模型与思考强度不匹配,请重新选择');
426
+ signal.throwIfAborted();
427
+ this.assertExecution(agent);
428
+ this.runtime.assertCliEnabled(cliOf(preference));
429
+ if (this.accounts.isBusy(cliOf(preference)))
430
+ throw new Error('请先关闭账号终端');
431
+ if (this.project(agent) !== project)
432
+ throw new Error('项目已变更,请重新选择');
433
+ if (restartSourceId)
434
+ this.runtime.assertLegacyRestart(agent.id, restartSourceId);
435
+ let submission;
436
+ const id = agent.ctx.get('jobs').start({
437
+ kind: 'cliworker',
438
+ owner: agent.id,
439
+ label: `${CLI_LABELS[cliOf(preference)]} · ${title} · ${workerId ? '续聊' : '新任务'}:${prompt.replace(/\s+/g, ' ').slice(0, 100)}`,
440
+ outputLimitBytes: 12000,
441
+ run: () => {
442
+ const submitted = this.runtime.submit(agent.id, project, title, prompt, preference, mode, workerId, identity, binding);
443
+ submission = submitted;
444
+ return {
445
+ cancel: submitted.cancel,
446
+ done: submitted.done.then((worker) => ({
447
+ status: worker.status === 'completed'
448
+ ? 'completed'
449
+ : worker.status === 'interrupted'
450
+ ? 'killed'
451
+ : 'failed',
452
+ detail: worker.error,
453
+ result: JSON.stringify({
454
+ cli: cliOf(worker.preference),
455
+ workerId: worker.id,
456
+ agentName: workerName(worker),
457
+ runId: worker.runId,
458
+ task: prompt.slice(0, 300),
459
+ status: worker.status,
460
+ response: worker.lastResult ?? worker.error,
461
+ }),
462
+ })),
463
+ };
464
+ },
465
+ });
466
+ if (!submission)
467
+ throw new Error('Harness did not publish the worker job');
468
+ this.runtime.attachJob(submission.worker, id);
469
+ return JSON.stringify({
470
+ cli: cliOf(submission.worker.preference),
471
+ workerId: submission.worker.id,
472
+ agentName: workerName(submission.worker),
473
+ runId: submission.worker.runId,
474
+ jobId: id,
475
+ status: submission.worker.status,
476
+ model: submission.worker.preference.model,
477
+ effort: submission.worker.preference.effort,
478
+ });
479
+ }
480
+ registerTools() {
481
+ const output = {
482
+ schema: { type: 'string' },
483
+ render: (_args, value) => [{ type: 'text', text: value }],
484
+ };
485
+ this.ctx.effect(() => this.ctx.tools.register(defineTool({
486
+ name: 'cliworker_resolve',
487
+ description: `只读解析明确调用中的 CLI 名称、别名或轻微拼写误差,不启动任务、不读取账号、不保存选型。${CLI_NAME_GUIDANCE}。未知、歧义或多个目标返回简短候选错误,不启动、不额外发问题卡。`,
488
+ parameters: {
489
+ name: {
490
+ type: 'string',
491
+ required: true,
492
+ description: '用户要求调用的 CLI 名称;不是任务内容或模型名称。',
493
+ },
494
+ },
495
+ output,
496
+ isConcurrencySafe: () => true,
497
+ execute: async (args) => JSON.stringify(resolveCliName(args.name)),
498
+ })), 'cliworker:resolve');
499
+ this.ctx.effect(() => this.ctx.tools.register(defineTool({
500
+ name: 'cliworker_start',
501
+ description: `用户明确要求“调用 agy cli”或“用 glm cli 完成任务”时,调用本工具打开 CLI Worker 的选型流程。只需提供 CLI、任务标题和任务内容;模型、思考强度与角色由插件收集,完成选型前不会启动任务,不要把它们当作调用本工具的前置输入。${CLI_NAME_GUIDANCE}。Host 仅在首次选择模型、思考强度与角色,或同项目新对话确认是否沿用时提问;同对话后续不重复。不要提前自行提问或增加确认,不代答。返回后台 job、worker ID 和 agentName。已有智能体续聊用 cliworker_followup;歧义返回简短候选错误,不启动、不额外发问题卡。`,
502
+ parameters: {
503
+ cli: {
504
+ type: 'string',
505
+ required: true,
506
+ description: `本次用户明确指定的 CLI 规范 ID 或别名:${CLI_NAME_GUIDANCE}。每次调用必填,Antigravity 也不可省略;不得照搬历史调用中省略 cli 的写法。较长名称仅接受唯一轻微误差;短名须精确,不猜模型。`,
507
+ },
508
+ title: { type: 'string', required: true },
509
+ prompt: { type: 'string', required: true },
510
+ agent_name: {
511
+ type: 'string',
512
+ description: 'Optional user-requested unique worker name within this parent conversation. Otherwise assigned from the CLI short name and an ordinal. Use followup by worker_name to reuse an existing named worker.',
513
+ },
514
+ read_only: {
515
+ type: 'boolean',
516
+ description: 'Use native read-only/plan mode; unsupported by Kimi print mode. Omit or false for coding.',
517
+ },
518
+ },
519
+ output,
520
+ timeoutMs: 1800000,
521
+ isConcurrencySafe: () => true,
522
+ execute: async (args, exec) => {
523
+ if (!exec.agent)
524
+ throw new Error('A parent Agent is required');
525
+ this.assertExecution(exec.agent);
526
+ const cli = requireCliName(args.cli);
527
+ const agentName = args.agent_name === undefined ? undefined : agentNameSchema.parse(args.agent_name);
528
+ if (cli === 'kimi' && args.read_only)
529
+ throw new Error('Kimi 非交互模式不支持只读派遣');
530
+ const setup = await this.chooseDispatch(exec.agent, AbortSignal.any([exec.signal, this.disposed.signal]), cli);
531
+ exec.signal.throwIfAborted();
532
+ return this.launch(exec.agent, args.title, args.prompt, setup.preference, args.read_only ? 'plan' : 'accept-edits', undefined, { agentName, role: setup.role ?? undefined }, AbortSignal.any([exec.signal, this.disposed.signal]));
533
+ },
534
+ })), 'cliworker:start');
535
+ this.ctx.effect(() => this.ctx.tools.register(defineTool({
536
+ name: 'cliworker_status',
537
+ description: 'Read the parent conversation’s CLI workers or one worker’s latest result. Background completion is announced automatically.',
538
+ parameters: { worker_id: { type: 'string' }, worker_name: { type: 'string' } },
539
+ output,
540
+ isConcurrencySafe: () => true,
541
+ execute: async (args, exec) => {
542
+ if (!exec.agent)
543
+ throw new Error('A parent Agent is required');
544
+ if (args.worker_id || args.worker_name) {
545
+ const worker = this.runtime.resolveWorker(exec.agent.id, args.worker_id, args.worker_name);
546
+ return JSON.stringify({ ...worker, agentName: workerName(worker) });
547
+ }
548
+ return JSON.stringify(this.runtime.snapshot(exec.agent.id).workers.map((worker) => ({
549
+ ...worker,
550
+ agentName: workerName(worker),
551
+ })));
552
+ },
553
+ })), 'cliworker:status');
554
+ this.ctx.effect(() => this.ctx.tools.register(defineTool({
555
+ name: 'cliworker_followup',
556
+ description: 'Continue a specific idle CLI worker by worker_id or its exact agentName in worker_name. Retains its role, current model/effort and CLI conversation; never starts another worker.',
557
+ parameters: {
558
+ worker_id: { type: 'string' },
559
+ worker_name: { type: 'string' },
560
+ prompt: { type: 'string', required: true },
561
+ },
562
+ output,
563
+ isConcurrencySafe: () => true,
564
+ execute: async (args, exec) => {
565
+ if (!exec.agent)
566
+ throw new Error('A parent Agent is required');
567
+ const worker = this.runtime.resolveWorker(exec.agent.id, args.worker_id, args.worker_name);
568
+ return this.followup(exec.agent.id, worker.id, args.prompt, exec.signal);
569
+ },
570
+ })), 'cliworker:followup');
571
+ this.ctx.effect(() => this.ctx.tools.register(defineTool({
572
+ name: 'cliworker_stop',
573
+ description: 'Stop a CLI worker and await cleanup of its managed processes.',
574
+ parameters: { worker_id: { type: 'string' }, worker_name: { type: 'string' } },
575
+ output,
576
+ isConcurrencySafe: () => true,
577
+ execute: async (args, exec) => {
578
+ if (!exec.agent)
579
+ throw new Error('A parent Agent is required');
580
+ const worker = this.runtime.resolveWorker(exec.agent.id, args.worker_id, args.worker_name);
581
+ return JSON.stringify(await this.runtime.stop(exec.agent.id, worker.id));
582
+ },
583
+ })), 'cliworker:stop');
584
+ }
585
+ /** @param parentSessionId - Owning Harness session. @param workerId - Selected worker or empty string. @param signal - Stream lifetime. @returns JSON snapshots, initially and after changes. */
586
+ async *watch(parentSessionId, workerId, signal) {
587
+ let wake;
588
+ let dirty = true;
589
+ const notify = () => {
590
+ dirty = true;
591
+ wake?.();
592
+ };
593
+ const unsubscribe = this.runtime.subscribe(notify);
594
+ const lifetime = AbortSignal.any([signal, this.disposed.signal]);
595
+ lifetime.addEventListener('abort', notify);
596
+ try {
597
+ while (!lifetime.aborted) {
598
+ if (!dirty)
599
+ await new Promise((resolve) => {
600
+ wake = resolve;
601
+ });
602
+ wake = undefined;
603
+ if (lifetime.aborted)
604
+ return;
605
+ dirty = false;
606
+ yield JSON.stringify({
607
+ ...this.runtime.snapshot(parentSessionId, workerId || undefined),
608
+ configuring: this.pending.has(parentSessionId),
609
+ });
610
+ }
611
+ }
612
+ finally {
613
+ unsubscribe();
614
+ lifetime.removeEventListener('abort', notify);
615
+ }
616
+ }
617
+ /** @param parentSessionId - Owning parent session. @param workerId - Worker identity. @param anchor - Stable logical row ID, excluded from the result. @param direction - before or after. @returns JSON historical page, at most 200 rows. */
618
+ async history(parentSessionId, workerId, anchor, direction) {
619
+ try {
620
+ return JSON.stringify(this.runtime.history(parentSessionId, workerId, anchor, direction));
621
+ }
622
+ catch (error) {
623
+ throw failure(error);
624
+ }
625
+ }
626
+ /** @param parentSessionId - Owning Harness session. @param signal - Query lifetime. @returns Profile-wide CLI enablement JSON. */
627
+ async cliSettings(parentSessionId, signal) {
628
+ try {
629
+ await this.parent(parentSessionId);
630
+ signal.throwIfAborted();
631
+ return JSON.stringify(this.runtime.storage.cliSettings());
632
+ }
633
+ catch (error) {
634
+ throw failure(error);
635
+ }
636
+ }
637
+ /** @param parentSessionId - Active parent. @param signal - Query lifetime. @returns JSON role preset library. */
638
+ async rolePresets(parentSessionId, signal) {
639
+ try {
640
+ await this.parent(parentSessionId);
641
+ signal.throwIfAborted();
642
+ return JSON.stringify(this.runtime.storage.rolePresets());
643
+ }
644
+ catch (error) {
645
+ throw failure(error);
646
+ }
647
+ }
648
+ /** @param parentSessionId - Active parent. @param requestJSON - Preset fields, optional existing id. @param signal - Mutation lifetime. @returns Saved preset JSON. */
649
+ async saveRolePreset(parentSessionId, requestJSON, signal) {
650
+ try {
651
+ await this.parent(parentSessionId);
652
+ signal.throwIfAborted();
653
+ const preset = this.runtime.storage.saveRolePreset(JSON.parse(requestJSON));
654
+ this.runtime.changed();
655
+ return JSON.stringify(preset);
656
+ }
657
+ catch (error) {
658
+ throw failure(error);
659
+ }
660
+ }
661
+ /** @param parentSessionId - Active parent. @param presetId - Preset to delete. @param signal - Mutation lifetime. @returns Completion. */
662
+ async deleteRolePreset(parentSessionId, presetId, signal) {
663
+ try {
664
+ await this.parent(parentSessionId);
665
+ signal.throwIfAborted();
666
+ this.runtime.storage.deleteRolePreset(presetId);
667
+ this.runtime.changed();
668
+ }
669
+ catch (error) {
670
+ throw failure(error);
671
+ }
672
+ }
673
+ /** @param parentSessionId - Owning parent. @param workerId - Worker identity. @param name - Unique readable name. @param signal - Mutation lifetime. @returns Completion. */
674
+ async renameWorker(parentSessionId, workerId, name, signal) {
675
+ try {
676
+ await this.parent(parentSessionId);
677
+ signal.throwIfAborted();
678
+ this.runtime.renameWorker(parentSessionId, workerId, name);
679
+ }
680
+ catch (error) {
681
+ throw failure(error);
682
+ }
683
+ }
684
+ /** @param parentSessionId - Owning parent. @param workerId - Worker identity. @param title - Single-line chat title, at most 160 characters. @param signal - Mutation lifetime. @returns Completion. */
685
+ async renameWorkerTitle(parentSessionId, workerId, title, signal) {
686
+ try {
687
+ await this.parent(parentSessionId);
688
+ signal.throwIfAborted();
689
+ this.runtime.renameWorkerTitle(parentSessionId, workerId, title);
690
+ }
691
+ catch (error) {
692
+ throw failure(error);
693
+ }
694
+ }
695
+ /** @param parentSessionId - Owning parent. @param workerId - Idle Worker to hide. @param signal - Mutation lifetime. @returns Completion without deleting native data. */
696
+ async deleteWorker(parentSessionId, workerId, signal) {
697
+ try {
698
+ await this.parent(parentSessionId);
699
+ signal.throwIfAborted();
700
+ this.runtime.deleteWorker(parentSessionId, workerId);
701
+ }
702
+ catch (error) {
703
+ throw failure(error);
704
+ }
705
+ }
706
+ /** @param parentSessionId - Owning parent. @param workerId - Deleted Worker identity. @param signal - Mutation lifetime. @returns Completion with the original ID and history. */
707
+ async restoreWorker(parentSessionId, workerId, signal) {
708
+ try {
709
+ await this.parent(parentSessionId);
710
+ signal.throwIfAborted();
711
+ this.runtime.restoreWorker(parentSessionId, workerId);
712
+ }
713
+ catch (error) {
714
+ throw failure(error);
715
+ }
716
+ }
717
+ /** @param parentSessionId - Owning session. @param cli - Selected CLI. @param enabled - Allow new CLI operations. @param signal - Mutation admission lifetime. @returns Updated profile-wide CLI enablement JSON. */
718
+ async setCliEnabled(parentSessionId, cli, enabled, signal) {
719
+ try {
720
+ await this.parent(parentSessionId);
721
+ signal.throwIfAborted();
722
+ const id = validate.enum(CLI_IDS).parse(cli);
723
+ const next = validate.boolean().parse(enabled);
724
+ // The check, persistence, and account startup reservation are synchronous;
725
+ // a pending managed terminal cannot be disabled during its async startup.
726
+ if (!next && this.accounts.isBusy(id))
727
+ throw new Error('此 CLI 正在管理账号,请先关闭账号终端再关闭 CLI');
728
+ signal.throwIfAborted();
729
+ return JSON.stringify(this.runtime.setCliEnabled(id, next));
730
+ }
731
+ catch (error) {
732
+ throw failure(error);
733
+ }
734
+ }
735
+ /** @param parentSessionId - Owning session. @param cli - Selected CLI. @param signal - Query lifetime. @returns Safe account status JSON. */
736
+ async accountStatus(parentSessionId, cli, signal) {
737
+ try {
738
+ const id = validate.enum(CLI_IDS).parse(cli);
739
+ const project = this.project(await this.parent(parentSessionId));
740
+ signal.throwIfAborted();
741
+ this.runtime.assertCliEnabled(id);
742
+ const status = await this.accounts.status(id, project, signal);
743
+ signal.throwIfAborted();
744
+ this.runtime.assertCliEnabled(id);
745
+ return JSON.stringify(status);
746
+ }
747
+ catch (error) {
748
+ throw failure(error);
749
+ }
750
+ }
751
+ /** @param parentSessionId - Owning session. @param cli - Selected CLI. @param action - Explicit human action. @param signal - Startup lifetime. @returns Managed account terminal identity and instruction JSON. */
752
+ async accountStart(parentSessionId, cli, action, signal) {
753
+ return this.startAccount(parentSessionId, cli, action, signal);
754
+ }
755
+ /** @param source - One current CLI-native source, never a filesystem path. */
756
+ async accountStartForSource(parentSessionId, cli, action, source, signal) {
757
+ try {
758
+ const selected = validate.enum(['native', 'plugin']).parse(source);
759
+ return this.startAccount(parentSessionId, cli, action, signal, selected);
760
+ }
761
+ catch (error) {
762
+ throw failure(error);
763
+ }
764
+ }
765
+ /** @param provider - Explicit ZCode native login provider, never a URL or logout source. */
766
+ async accountStartForProvider(parentSessionId, cli, action, provider, signal) {
767
+ try {
768
+ const selected = validate.enum(['bigmodel', 'zai']).parse(provider);
769
+ if (cli !== 'zcode' || action !== 'login')
770
+ throw new Error('不支持的 ZCode 授权来源');
771
+ return this.startAccount(parentSessionId, cli, action, signal, undefined, selected);
772
+ }
773
+ catch (error) {
774
+ throw failure(error);
775
+ }
776
+ }
777
+ async startAccount(parentSessionId, cli, action, signal, source, provider) {
778
+ try {
779
+ const id = validate.enum(CLI_IDS).parse(cli);
780
+ const operation = validate.enum(['login', 'logout', 'manage']).parse(action);
781
+ const parent = await this.parent(parentSessionId);
782
+ this.assertExecution(parent);
783
+ this.runtime.assertCliEnabled(id);
784
+ this.runtime.assertAccountIdle(id);
785
+ if (!this.accountParents.has(parent.id)) {
786
+ const dispose = parent.ctx.effect(() => () => {
787
+ this.accountParents.delete(parent.id);
788
+ return this.accounts.closeParent(parent.id);
789
+ }, 'cliworker:account-parent');
790
+ this.accountParents.set(parent.id, dispose);
791
+ }
792
+ return JSON.stringify(await this.accounts.start(parent.id, id, operation, this.project(parent), signal, source, provider));
793
+ }
794
+ catch (error) {
795
+ throw failure(error);
796
+ }
797
+ }
798
+ /** @param parentSessionId - Owning session. @param accountId - Account terminal identity. @param signal - Stream lifetime. @returns Ephemeral terminal frame JSON. */
799
+ async *accountWatch(parentSessionId, accountId, signal) {
800
+ try {
801
+ await this.parent(parentSessionId);
802
+ for await (const frame of this.accounts.watch(parentSessionId, accountId, signal))
803
+ yield JSON.stringify(frame);
804
+ }
805
+ catch (error) {
806
+ throw failure(error);
807
+ }
808
+ }
809
+ /** @param parentSessionId - Owning session. @param accountId - Account terminal identity. @param data - Human keyboard input. @returns Input accepted. */
810
+ async accountWrite(parentSessionId, accountId, data) {
811
+ try {
812
+ this.assertExecution(await this.parent(parentSessionId));
813
+ await this.accounts.write(parentSessionId, accountId, data);
814
+ return true;
815
+ }
816
+ catch (error) {
817
+ throw failure(error);
818
+ }
819
+ }
820
+ /** @param parentSessionId - Owning session. @param accountId - Account terminal identity. @param cols - Visible columns. @param rows - Visible rows. @returns Resize accepted. */
821
+ async accountResize(parentSessionId, accountId, cols, rows) {
822
+ try {
823
+ await this.parent(parentSessionId);
824
+ await this.accounts.resize(parentSessionId, accountId, cols, rows);
825
+ return true;
826
+ }
827
+ catch (error) {
828
+ throw failure(error);
829
+ }
830
+ }
831
+ /** @param parentSessionId - Owning session. @param accountId - Account terminal identity. @returns Process cleanup completed. */
832
+ async accountStop(parentSessionId, accountId) {
833
+ try {
834
+ await this.accounts.stop(parentSessionId, accountId);
835
+ return true;
836
+ }
837
+ catch (error) {
838
+ throw failure(error);
839
+ }
840
+ }
841
+ /** @param parentSessionId - Parent session identity. @param signal - Caller lifetime. @returns JSON model catalog and project preference. */
842
+ async catalog(parentSessionId, signal) {
843
+ return this.catalogForCli(parentSessionId, 'antigravity', signal);
844
+ }
845
+ /** @param parentSessionId - Parent session identity. @param cli - Selected CLI. @param signal - Caller lifetime. @returns CLI catalog and saved project preference. */
846
+ async catalogForCli(parentSessionId, cli, signal) {
847
+ try {
848
+ const id = validate.enum(CLI_IDS).parse(cli);
849
+ const project = this.project(await this.parent(parentSessionId));
850
+ this.runtime.assertCliEnabled(id);
851
+ const { catalog, binding } = await this.queryCatalog(id, this.backend, this.options, project, signal);
852
+ (this.displayedBindings ??= new Map()).set(JSON.stringify([parentSessionId, id]), binding);
853
+ this.runtime.assertCliEnabled(id);
854
+ return JSON.stringify({
855
+ ...catalog,
856
+ preference: this.runtime.storage.preference(project, id),
857
+ });
858
+ }
859
+ catch (error) {
860
+ throw failure(error);
861
+ }
862
+ }
863
+ /** @param parentSessionId - Parent session identity. @param selection - JSON model and effort. @param signal - Caller lifetime. @returns Saved JSON preference. */
864
+ async configure(parentSessionId, selection, signal) {
865
+ try {
866
+ const agent = await this.parent(parentSessionId);
867
+ let preference = preferenceSchema.parse(JSON.parse(selection));
868
+ const project = this.project(agent);
869
+ this.runtime.assertCliEnabled(cliOf(preference));
870
+ const { catalog } = await this.querySelection(preference, this.backend, this.options, project, signal, this.displayedBindings?.get(JSON.stringify([parentSessionId, cliOf(preference)])));
871
+ validatePreference(preference, catalog);
872
+ preference = resolveModel(preference, catalog.models);
873
+ signal.throwIfAborted();
874
+ this.runtime.assertCliEnabled(cliOf(preference));
875
+ this.runtime.storage.setPreference(project, preference);
876
+ this.runtime.changed();
877
+ return JSON.stringify(preference);
878
+ }
879
+ catch (error) {
880
+ throw failure(error);
881
+ }
882
+ }
883
+ /** @param parentSessionId - Owning session. @param workerId - Idle worker. @param selection - JSON preference. @param signal - Caller lifetime. @returns Saved worker configuration. */
884
+ async configureWorker(parentSessionId, workerId, selection, signal) {
885
+ try {
886
+ const agent = await this.parent(parentSessionId);
887
+ const worker = this.runtime.get(agent.id, workerId);
888
+ const preference = preferenceSchema.parse(JSON.parse(selection));
889
+ if (cliOf(preference) !== cliOf(worker.preference))
890
+ throw new Error('已有会话不能切换 CLI');
891
+ const expected = this.runtime.storage.accountBinding(workerId);
892
+ if (!expected)
893
+ throw new Error(LEGACY_ACCOUNT_RECORD_NOTICE);
894
+ this.runtime.assertCliEnabled(cliOf(preference));
895
+ const { catalog } = await this.querySelection(preference, this.backend, this.options, worker.project, signal, expected);
896
+ validatePreference(preference, catalog);
897
+ signal.throwIfAborted();
898
+ this.runtime.assertCliEnabled(cliOf(preference));
899
+ return JSON.stringify(this.runtime.configureWorker(agent.id, workerId, resolveModel(preference, catalog.models)));
900
+ }
901
+ catch (error) {
902
+ throw failure(error);
903
+ }
904
+ }
905
+ /** @param parentSessionId - Parent session identity. @param workerId - Worker to continue. @param prompt - New task. @param signal - Admission lifetime. @returns Published background receipt. */
906
+ async followup(parentSessionId, workerId, prompt, signal) {
907
+ try {
908
+ const agent = await this.parent(parentSessionId);
909
+ signal.throwIfAborted();
910
+ this.assertExecution(agent);
911
+ const worker = this.runtime.get(agent.id, workerId);
912
+ this.runtime.assertCliEnabled(cliOf(worker.preference));
913
+ return this.launch(agent, worker.title, prompt, worker.preference, worker.mode, workerId, undefined, signal);
914
+ }
915
+ catch (error) {
916
+ throw failure(error);
917
+ }
918
+ }
919
+ /** @param parentSessionId - Owning parent. @param workerId - Idle legacy history without an account binding. @param prompt - Explicit new-dialog task. @param signal - Admission lifetime. @returns JSON background receipt for a fresh Worker. */
920
+ async restartWorker(parentSessionId, workerId, prompt, signal) {
921
+ try {
922
+ const agent = await this.parent(parentSessionId);
923
+ signal.throwIfAborted();
924
+ this.assertExecution(agent);
925
+ const worker = this.runtime.assertLegacyRestart(agent.id, workerId);
926
+ if (this.project(agent) !== worker.project)
927
+ throw new Error('项目已变更,请在原项目新建对话');
928
+ return await this.launch(agent, worker.title, prompt, { ...worker.preference }, worker.mode, undefined, { role: worker.role ? structuredClone(worker.role) : undefined }, signal, workerId);
929
+ }
930
+ catch (error) {
931
+ throw failure(error);
932
+ }
933
+ }
934
+ /** @param parentSessionId - Owning Harness session. @param workerId - Worker to stop. @returns Final worker state after cleanup. */
935
+ async stop(parentSessionId, workerId) {
936
+ try {
937
+ return JSON.stringify(await this.runtime.stop(parentSessionId, workerId));
938
+ }
939
+ catch (error) {
940
+ throw failure(error);
941
+ }
942
+ }
943
+ };
944
+ })();
945
+ export { CliWorkerService };
946
+ export default CliWorkerService;
947
+ //# sourceMappingURL=index.js.map