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,147 @@
1
+ export const EFFORTS = [
2
+ 'default',
3
+ 'none',
4
+ 'minimal',
5
+ 'low',
6
+ 'medium',
7
+ 'high',
8
+ 'xhigh',
9
+ 'max',
10
+ 'ultra',
11
+ ];
12
+ export const CLI_IDS = [
13
+ 'antigravity',
14
+ 'codex',
15
+ 'claude',
16
+ 'kimi',
17
+ 'mimo',
18
+ 'zcode',
19
+ 'grok',
20
+ 'omp',
21
+ 'pi',
22
+ 'hermes',
23
+ 'opencode',
24
+ ];
25
+ export const RETIRED_HARNESS_NOTICE = '外部 Harness CLI 入口已移除;历史记录仅供查看。请新建 Hermes Agent 任务。';
26
+ export const isRetiredCli = (cli) => cli === 'harness';
27
+ export const CLI_LABELS = {
28
+ antigravity: 'Antigravity',
29
+ codex: 'Codex',
30
+ claude: 'Claude Code',
31
+ kimi: 'Kimi',
32
+ mimo: 'MiMo',
33
+ zcode: 'ZCode',
34
+ grok: 'Grok Build',
35
+ omp: 'OMP',
36
+ pi: 'Pi',
37
+ hermes: 'Hermes Agent',
38
+ harness: 'Harness(已移除)',
39
+ opencode: 'OpenCode',
40
+ };
41
+ /** Short CLI stems used for automatic Worker names; protocol IDs remain unchanged. */
42
+ export const CLI_SHORT_NAMES = {
43
+ antigravity: 'agy',
44
+ codex: 'codex',
45
+ claude: 'claude',
46
+ kimi: 'kimi',
47
+ mimo: 'mimo',
48
+ zcode: 'zcode',
49
+ grok: 'grok',
50
+ omp: 'omp',
51
+ pi: 'pi',
52
+ hermes: 'hermes',
53
+ harness: 'harness',
54
+ opencode: 'opencode',
55
+ };
56
+ export const cliOf = (preference) => preference.cli ?? 'antigravity';
57
+ export const effortLabel = (effort) => effort === 'default' ? '默认' : effort.charAt(0).toUpperCase() + effort.slice(1);
58
+ export const LEGACY_ACCOUNT_RECORD_NOTICE = '此历史任务缺少账号记录,请新建任务';
59
+ /** Stable, non-mutating name for histories created before named workers. */
60
+ export const workerName = (worker) => worker.agentName || `智能体-${worker.id.slice(0, 6)}`;
61
+ export const active = (status) => status === 'queued' || status === 'running' || status === 'stopping';
62
+ /** Fold repeated step updates without duplicating streamed text or the final response. */
63
+ export function foldEvents(events, endedRun) {
64
+ const rows = [];
65
+ const steps = new Map();
66
+ const markEnded = (runId, status) => {
67
+ for (const row of rows) {
68
+ if (row.kind === 'tool' &&
69
+ row.id.startsWith(runId + ':') &&
70
+ ['ACTIVE', 'RUNNING', 'PENDING', 'QUEUED', 'IN_PROGRESS'].includes(row.state ?? ''))
71
+ row.runStatus = status;
72
+ }
73
+ };
74
+ for (const event of events) {
75
+ if (event.kind === 'status') {
76
+ const terminal = event.state ?? event.text;
77
+ if (terminal === 'completed' || terminal === 'failed' || terminal === 'interrupted')
78
+ markEnded(event.runId, terminal);
79
+ }
80
+ if (event.kind === 'result') {
81
+ const lastAssistant = rows.findLast((row) => row.kind === 'assistant' && row.id.startsWith(event.runId + ':'));
82
+ if (lastAssistant) {
83
+ // agy may repeat all earlier response steps in its final response.
84
+ // Strip only exact earlier prefixes, leaving interleaved tool rows intact.
85
+ let finalText = event.text.trimStart();
86
+ const earlier = rows.filter((row) => row !== lastAssistant && row.kind === 'assistant' && row.id.startsWith(event.runId + ':'));
87
+ for (const row of earlier) {
88
+ const prefix = row.text.trim();
89
+ if (!prefix)
90
+ continue;
91
+ if (finalText.startsWith(prefix))
92
+ finalText = finalText.slice(prefix.length).trimStart();
93
+ else
94
+ break;
95
+ }
96
+ if (event.text)
97
+ lastAssistant.text = finalText;
98
+ continue;
99
+ }
100
+ }
101
+ const key = event.step === undefined
102
+ ? `${event.runId}:event:${event.seq}`
103
+ : `${event.runId}:${event.kind}:${event.step}`;
104
+ const existing = steps.get(key);
105
+ if (existing) {
106
+ if (event.kind === 'assistant')
107
+ existing.text += event.text;
108
+ else if (event.text)
109
+ existing.text = event.text;
110
+ if (event.state)
111
+ existing.state = event.state;
112
+ if (event.detail)
113
+ existing.detail = event.detail;
114
+ }
115
+ else {
116
+ const row = {
117
+ id: key,
118
+ kind: event.kind === 'result' ? 'assistant' : event.kind,
119
+ text: event.text,
120
+ time: event.time,
121
+ state: event.state,
122
+ detail: event.detail,
123
+ };
124
+ steps.set(key, row);
125
+ rows.push(row);
126
+ }
127
+ }
128
+ // Use full persisted events before pagination. Duration includes admission/queue time.
129
+ const timing = new Map();
130
+ for (const event of events) {
131
+ const run = timing.get(event.runId) ?? {};
132
+ if (event.kind === 'user' && !run.runStartedAt)
133
+ run.runStartedAt = event.time;
134
+ if (event.kind === 'status' &&
135
+ ['completed', 'failed', 'interrupted'].includes(event.state ?? event.text)) {
136
+ run.runEndedAt = event.time;
137
+ run.runOutcome = (event.state ?? event.text);
138
+ }
139
+ timing.set(event.runId, run);
140
+ }
141
+ for (const row of rows)
142
+ Object.assign(row, timing.get(row.id.split(':')[0]));
143
+ if (endedRun)
144
+ markEnded(endedRun.runId, endedRun.status);
145
+ return rows;
146
+ }
147
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,SAAS;IACT,MAAM;IACN,SAAS;IACT,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;IACP,KAAK;IACL,OAAO;CACC,CAAA;AACV,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,aAAa;IACb,OAAO;IACP,QAAQ;IACR,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,IAAI;IACJ,QAAQ;IACR,UAAU;CACF,CAAA;AAIV,MAAM,CAAC,MAAM,sBAAsB,GACjC,oDAAoD,CAAA;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAU,EAAoB,EAAE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AAQ;YACvB,CAAC,WAAW,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,EAC1E,CAAC;YACD,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAA;YAC3B,GAAG,CAAC,UAAU,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAiB,CAAA;QAC9D,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC9B,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAA;IAC7E,IAAI,QAAQ;QAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACxD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,44 @@
1
+ param(
2
+ [Parameter(Mandatory=$true)][string]$Directory,
3
+ [Parameter(Mandatory=$true)][string]$RuntimePath,
4
+ [Parameter(Mandatory=$true)][string]$LaunchPath,
5
+ [Parameter(Mandatory=$true)][string]$ArgumentsBase64
6
+ )
7
+ $ErrorActionPreference = 'Stop'
8
+ # A console-subsystem root is necessary: Electron's GUI executable can attach
9
+ # to a different parent console even with ELECTRON_RUN_AS_NODE. Do not run any
10
+ # native CLI until this exact PowerShell root and its console belong to the Job.
11
+ $pidFile=Join-Path $Directory 'pid'
12
+ [System.IO.File]::WriteAllText(($pidFile+'.tmp'),[string]$PID)
13
+ [System.IO.File]::Move(($pidFile+'.tmp'),$pidFile)
14
+ [Console]::Out.Write(([char]27).ToString()+'[0m')
15
+ $until=[DateTime]::UtcNow.AddSeconds(15)
16
+ while (!(Test-Path -LiteralPath (Join-Path $Directory 'ready'))) {
17
+ if ([DateTime]::UtcNow -ge $until) { exit 1 }
18
+ Start-Sleep -Milliseconds 20
19
+ }
20
+ if (!(Test-Path -LiteralPath (Join-Path $Directory 'cancel')) -and !(Test-Path -LiteralPath (Join-Path $Directory 'stop'))) {
21
+ try {
22
+ # PowerShell's native pipeline may background a GUI executable or convert
23
+ # stderr to an error. Start the fixed helper without redirection and wait.
24
+ # Only fixed paths plus Base64 JSON are quoted here; CLI argv stays data.
25
+ $quote = { param([string]$Value) '"' + [regex]::Replace([regex]::Replace($Value, '(\\*)"', '$1$1\"'), '(\\+)$', '$1$1') + '"' }
26
+ $start = New-Object System.Diagnostics.ProcessStartInfo
27
+ $start.FileName = $RuntimePath
28
+ $start.Arguments = ((& $quote $LaunchPath), (& $quote $Directory), (& $quote $ArgumentsBase64)) -join ' '
29
+ $start.UseShellExecute = $false
30
+ $start.RedirectStandardInput = $false
31
+ $start.RedirectStandardOutput = $false
32
+ $start.RedirectStandardError = $false
33
+ $start.CreateNoWindow = $false
34
+ $runtime = [System.Diagnostics.Process]::Start($start)
35
+ try { $runtime.WaitForExit() } finally { $runtime.Dispose() }
36
+ if (!(Test-Path -LiteralPath (Join-Path $Directory 'exit'))) {
37
+ [System.IO.File]::WriteAllText((Join-Path $Directory 'exit'),'{"exitCode":1,"signal":null}')
38
+ }
39
+ } catch {
40
+ [System.IO.File]::WriteAllText((Join-Path $Directory 'exit'),'{"exitCode":1,"signal":null}')
41
+ }
42
+ }
43
+ # Host owns disposal, including native exit and startup cancellation paths.
44
+ while ($true) { Start-Sleep -Milliseconds 1000 }
@@ -0,0 +1,47 @@
1
+ // Windows account PTY bootstrap. No native CLI runs until its process has been
2
+ // assigned to the separate lifecycle Job owner; no task sandbox is applied.
3
+ import { accountInput } from './windows-account-stdio.mjs'
4
+ import { fileURLToPath } from 'node:url'
5
+ import { spawnNativeProcess } from './native-spawn.mjs'
6
+ import { writeFileSync, existsSync } from 'node:fs'
7
+ import { join } from 'node:path'
8
+ import { setTimeout as delay } from 'node:timers/promises'
9
+ import { nativeLaunchArgv } from './native-launch.mjs'
10
+ process.umask(0o077)
11
+ const [directory, encoded] = process.argv.slice(2)
12
+ let requested
13
+ try { requested = JSON.parse(Buffer.from(encoded, 'base64').toString('utf8')) } catch { process.exit(1) }
14
+ if (!directory || !Array.isArray(requested) || !requested.length || requested.some(value => typeof value !== 'string')) process.exit(1)
15
+ // This exact plugin wrapper only sets umask and delegates an argv array. This
16
+ // helper already does both; avoid another GUI runtime losing console stdin.
17
+ if (requested[0] === process.execPath && requested[1] === fileURLToPath(new URL('./private-launch.mjs', import.meta.url)))
18
+ requested = requested.slice(2)
19
+ const until = Date.now() + 15_000
20
+ while (!existsSync(join(directory, 'ready'))) {
21
+ if (Date.now() >= until) process.exit(1)
22
+ await delay(20)
23
+ }
24
+ // Keep ConPTY alive after the native command exits so Host can dispose its
25
+ // native worker before closing the entire Job. Only the exit code is exposed.
26
+ setInterval(() => {}, 1000)
27
+ const recordExit = (code, signal) => {
28
+ const exitCode = Number.isInteger(code) ? code : 1
29
+ writeFileSync(join(directory, 'exit'), JSON.stringify({ exitCode, signal: signal ?? null }), { mode: 0o600 })
30
+ }
31
+ if (!existsSync(join(directory, 'cancel')) && !existsSync(join(directory, 'stop'))) {
32
+ try {
33
+ const [executable, ...argv] = nativeLaunchArgv(requested)
34
+ // Node-based CLI account UIs also need their own Electron stdin restored.
35
+ // This fixed preload is scoped to that child, never NODE_OPTIONS or Host.
36
+ if (executable === process.execPath && process.versions.electron)
37
+ argv.unshift('--import', new URL('./windows-account-stdio.mjs', import.meta.url).href)
38
+ // Keep the existing ConPTY handles; a GUI-subsystem parent must not cause
39
+ // the native CLI to present an additional Windows console window.
40
+ const child = spawnNativeProcess(executable, argv, { env: process.env, stdio: [accountInput, 1, 2] })
41
+ child.once('error', () => { process.stderr.write('CLI launch failed\r\n') })
42
+ child.once('close', recordExit)
43
+ } catch {
44
+ process.stderr.write('CLI launch failed\r\n')
45
+ recordExit(1)
46
+ }
47
+ }
@@ -0,0 +1,137 @@
1
+ param([Parameter(Mandatory=$true)][string]$Directory, [Parameter(Mandatory=$true)][int]$HostProcessId)
2
+ $ErrorActionPreference = 'Stop'
3
+ # Fixed process ownership only: no resource, privilege, network, or filesystem limits.
4
+ Add-Type -TypeDefinition @'
5
+ using System;
6
+ using System.Diagnostics;
7
+ using System.ComponentModel;
8
+ using System.Runtime.InteropServices;
9
+ public sealed class CwnAccountJob : IDisposable {
10
+ [StructLayout(LayoutKind.Sequential)] struct BasicLimits { public long ProcessTime, JobTime; public uint Flags; public UIntPtr MinWorking, MaxWorking; public uint ActiveLimit; public UIntPtr Affinity; public uint Priority, Scheduling; }
11
+ [StructLayout(LayoutKind.Sequential)] struct Io { public ulong ReadOps, WriteOps, OtherOps, ReadBytes, WriteBytes, OtherBytes; }
12
+ [StructLayout(LayoutKind.Sequential)] struct ExtendedLimits { public BasicLimits Basic; public Io Io; public UIntPtr ProcessMemory, JobMemory, PeakProcessMemory, PeakJobMemory; }
13
+ [StructLayout(LayoutKind.Sequential)] struct Accounting { public long User, Kernel, PeriodUser, PeriodKernel; public uint PageFaults, TotalProcesses, ActiveProcesses, TerminatedProcesses; }
14
+ [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern IntPtr CreateJobObject(IntPtr attr, string name);
15
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool SetInformationJobObject(IntPtr job, int kind, ref ExtendedLimits limits, uint size);
16
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool QueryInformationJobObject(IntPtr job, int kind, out Accounting info, uint size, IntPtr length);
17
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
18
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool TerminateJobObject(IntPtr job, uint code);
19
+ [DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
20
+ [DllImport("kernel32.dll")] static extern bool FreeConsole();
21
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool AttachConsole(uint pid);
22
+ [DllImport("kernel32.dll")] static extern IntPtr GetConsoleWindow();
23
+ [DllImport("user32.dll", SetLastError=true)] static extern uint GetWindowThreadProcessId(IntPtr window, out uint pid);
24
+ [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern IntPtr GetModuleHandle(string name);
25
+ [DllImport("kernel32.dll", SetLastError=true)] static extern IntPtr GetProcAddress(IntPtr module, IntPtr ordinal);
26
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)] delegate uint RealWindowOwner(IntPtr window);
27
+ IntPtr job; Process root;
28
+ public CwnAccountJob() { job=CreateJobObject(IntPtr.Zero,null); if(job==IntPtr.Zero) throw new Win32Exception(Marshal.GetLastWin32Error()); var l=new ExtendedLimits(); l.Basic.Flags=0x2000; if(!SetInformationJobObject(job,9,ref l,(uint)Marshal.SizeOf(l))) { var error=Marshal.GetLastWin32Error(); Dispose(); throw new Win32Exception(error); } }
29
+ public void Attach(int pid, DateTime receiptTime, DateTime earliest) { root=Process.GetProcessById(pid); var handle=root.Handle; var started=root.StartTime.ToUniversalTime(); if(started>receiptTime || started<earliest) throw new Exception("process identity changed"); if(!AssignProcessToJobObject(job,handle)) throw new Win32Exception(Marshal.GetLastWin32Error()); }
30
+ public static int ConsoleOwner(int pid) {
31
+ FreeConsole(); if(!AttachConsole((uint)pid)) throw new Win32Exception(Marshal.GetLastWin32Error());
32
+ try {
33
+ var window=GetConsoleWindow(); uint owner;
34
+ if(window==IntPtr.Zero || GetWindowThreadProcessId(window,out owner)==0 || owner==0) throw new Exception("console owner unavailable");
35
+ // Modern ConPTY gives its message-only window to the root client, not
36
+ // conhost: microsoft/terminal#14196. Resolve this same HWND's real owner
37
+ // using the maintainer's dynamic API from discussion #16447. The ordinal
38
+ // is not a stable public API; absence or an invalid result fails closed.
39
+ if(owner==(uint)pid) {
40
+ var module=GetModuleHandle("user32.dll");
41
+ var address=module==IntPtr.Zero?IntPtr.Zero:GetProcAddress(module,new IntPtr(2712));
42
+ if(address==IntPtr.Zero) throw new Exception("real console owner unavailable");
43
+ var getOwner=(RealWindowOwner)Marshal.GetDelegateForFunctionPointer(address,typeof(RealWindowOwner));
44
+ owner=getOwner(window);
45
+ }
46
+ if(owner==0 || owner>(uint)Int32.MaxValue || owner==(uint)pid) throw new Exception("console owner unavailable");
47
+ return (int)owner;
48
+ } finally { FreeConsole(); }
49
+ }
50
+ public string ConsoleIdentityReason { get; private set; }
51
+ public string ConsoleImageKind { get; private set; }
52
+ public bool ConsoleImageDevicePrefix { get; private set; }
53
+ public void AttachConsoleHost(int pid, DateTime latest, DateTime earliest) {
54
+ using(var p=Process.GetProcessById(pid)) {
55
+ var handle=p.Handle; var started=p.StartTime.ToUniversalTime();
56
+ var expected=System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System),"conhost.exe");
57
+ if(started>latest) { ConsoleIdentityReason="after-receipt"; throw new Exception("console identity changed"); }
58
+ if(started<earliest) { ConsoleIdentityReason="before-directory"; throw new Exception("console identity changed"); }
59
+ var image=p.MainModule.FileName; var leaf=System.IO.Path.GetFileName(image);
60
+ ConsoleImageKind=String.Equals(leaf,"conhost.exe",StringComparison.OrdinalIgnoreCase)?"conhost.exe":String.Equals(leaf,"openconsole.exe",StringComparison.OrdinalIgnoreCase)?"openconsole.exe":"other";
61
+ ConsoleImageDevicePrefix=image!=null && (image.StartsWith(@"\\?\") || image.StartsWith(@"\??\"));
62
+ if(!String.Equals(image,expected,StringComparison.OrdinalIgnoreCase)) { ConsoleIdentityReason="wrong-image"; throw new Exception("console identity changed"); }
63
+ if(!AssignProcessToJobObject(job,handle)) throw new Win32Exception(Marshal.GetLastWin32Error());
64
+ }
65
+ }
66
+ public bool RootExited { get { return root.HasExited; } }
67
+ public void Stop() { if(!TerminateJobObject(job,143)) throw new Win32Exception(Marshal.GetLastWin32Error()); }
68
+ public bool Empty { get { Accounting a; if(!QueryInformationJobObject(job,1,out a,(uint)Marshal.SizeOf(typeof(Accounting)),IntPtr.Zero)) throw new Win32Exception(Marshal.GetLastWin32Error()); return a.ActiveProcesses==0; } }
69
+ public void Dispose() { if(job!=IntPtr.Zero) { CloseHandle(job); job=IntPtr.Zero; } if(root!=null) root.Dispose(); }
70
+ }
71
+ '@
72
+ $job=$null
73
+ $stage='await-bootstrap'
74
+ $consolePid=$null
75
+ $consoleParentPid=$null
76
+ try {
77
+ $earliest=[System.IO.Directory]::GetCreationTimeUtc($Directory).AddSeconds(-1)
78
+ $pidFile=Join-Path $Directory 'pid'
79
+ $stopFile=Join-Path $Directory 'stop'
80
+ [System.IO.File]::WriteAllText((Join-Path $Directory 'owner-ready'),'owner-ready')
81
+ $until=[DateTime]::UtcNow.AddSeconds(15)
82
+ while (!(Test-Path -LiteralPath $pidFile)) {
83
+ if ([DateTime]::UtcNow -ge $until) { throw 'bootstrap timeout' }
84
+ Start-Sleep -Milliseconds 20
85
+ }
86
+ $childPid=0
87
+ if (![int]::TryParse([System.IO.File]::ReadAllText($pidFile),[ref]$childPid) -or $childPid -le 0) { throw 'invalid bootstrap receipt' }
88
+ $stage='create-job'
89
+ $job=New-Object CwnAccountJob
90
+ $stage='attach-root'
91
+ $job.Attach($childPid,[System.IO.File]::GetLastWriteTimeUtc($pidFile),$earliest)
92
+ # The ConPTY console is a sibling of the bootstrap, created by the Host.
93
+ # Resolve it through this exact console, then validate parent and creation
94
+ # identity before adding it; never enumerate/kill processes by image name.
95
+ $stage='resolve-console'
96
+ $consolePid=[CwnAccountJob]::ConsoleOwner($childPid)
97
+ $stage='validate-console-parent'
98
+ $console=Get-CimInstance Win32_Process -Filter "ProcessId=$consolePid"
99
+ if ($null -ne $console) { $consoleParentPid=$console.ParentProcessId }
100
+ if ($null -eq $console -or $console.ParentProcessId -ne $HostProcessId) { throw 'console owner mismatch' }
101
+ $stage='attach-console'
102
+ $job.AttachConsoleHost($consolePid,[System.IO.File]::GetLastWriteTimeUtc($pidFile),$earliest)
103
+ $stage='await-stop'
104
+ [System.IO.File]::WriteAllText((Join-Path $Directory 'ready'),'ready')
105
+ while (!$job.RootExited -and !(Test-Path -LiteralPath $stopFile)) { Start-Sleep -Milliseconds 50 }
106
+ $stage='stop-job'
107
+ $job.Stop()
108
+ $stage='confirm-empty'
109
+ $until=[DateTime]::UtcNow.AddSeconds(8)
110
+ while (!$job.Empty) {
111
+ if ([DateTime]::UtcNow -ge $until) { throw 'empty receipt timeout' }
112
+ Start-Sleep -Milliseconds 20
113
+ }
114
+ [System.IO.File]::WriteAllText((Join-Path $Directory 'closed'),'closed')
115
+ exit 0
116
+ } catch {
117
+ # Fixed stage and numeric metadata only; no exception text/argv/environment.
118
+ $failure=@{ stage=$stage; hostPid=$HostProcessId; ownerPid=$PID }
119
+ if ($null -ne $consolePid) { $failure.consolePid=$consolePid }
120
+ if ($null -ne $consoleParentPid) { $failure.consoleParentPid=$consoleParentPid }
121
+ if ($null -ne $job -and $job.ConsoleIdentityReason -in @('before-directory','after-receipt','wrong-image')) {
122
+ $failure.identityReason=$job.ConsoleIdentityReason
123
+ if ($job.ConsoleImageKind -in @('conhost.exe','openconsole.exe','other')) {
124
+ $failure.imageKind=$job.ConsoleImageKind
125
+ $failure.imageDevicePrefix=$job.ConsoleImageDevicePrefix
126
+ }
127
+ }
128
+ $errorObject=$_.Exception
129
+ while ($null -ne $errorObject) {
130
+ if ($errorObject -is [System.ComponentModel.Win32Exception]) { $failure.win32Code=$errorObject.NativeErrorCode; break }
131
+ $errorObject=$errorObject.InnerException
132
+ }
133
+ try { [System.IO.File]::WriteAllText((Join-Path $Directory 'failure'),($failure | ConvertTo-Json -Compress)) } catch {}
134
+ # Fixed classification only: never emit native exception/context/environment.
135
+ [Console]::Error.WriteLine('Windows account process ownership failed')
136
+ exit 2
137
+ } finally { if ($null -ne $job) { $job.Dispose() } }
@@ -0,0 +1,19 @@
1
+ // Imported only by the Windows account-terminal runtime and its Electron CLI
2
+ // child. Electron attaches stdout/stderr to the parent console, but its GUI
3
+ // executable can leave fd 0 mapped to NUL. Reopen this already-owned console;
4
+ // do not redirect stdin for task processes or change the shared Host.
5
+ import { openSync, closeSync } from 'node:fs'
6
+ import { isatty, ReadStream } from 'node:tty'
7
+ export let accountInput = 0
8
+ if (process.platform === 'win32' && !isatty(0)) {
9
+ try {
10
+ accountInput = openSync('\\\\.\\CONIN$', 'r+')
11
+ if (!isatty(accountInput)) throw new Error('not a console')
12
+ const input = new ReadStream(accountInput)
13
+ Object.defineProperty(process, 'stdin', { value: input, configurable: true })
14
+ process.once('exit', () => { try { closeSync(accountInput) } catch {} })
15
+ } catch {
16
+ if (accountInput) { try { closeSync(accountInput) } catch {} }
17
+ throw new Error('Windows account console input unavailable')
18
+ }
19
+ }
@@ -0,0 +1,81 @@
1
+ # Read only Antigravity's own native Windows credential. Never emit its blob.
2
+ $ErrorActionPreference = 'Stop'
3
+ [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
4
+ try {
5
+ Add-Type @'
6
+ using System;
7
+ using System.Runtime.InteropServices;
8
+ using System.Text;
9
+ public static class CwnAgyCredential {
10
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] struct Credential {
11
+ public uint Flags, Type;
12
+ public string TargetName, Comment;
13
+ public System.Runtime.InteropServices.ComTypes.FILETIME LastWritten;
14
+ public uint CredentialBlobSize;
15
+ public IntPtr CredentialBlob;
16
+ public uint Persist, AttributeCount;
17
+ public IntPtr Attributes;
18
+ public string TargetAlias, UserName;
19
+ }
20
+ [DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
21
+ static extern bool CredRead(string target, uint type, uint flags, out IntPtr value);
22
+ [DllImport("advapi32.dll")] static extern void CredFree(IntPtr value);
23
+ public static string Read() {
24
+ IntPtr value;
25
+ if (!CredRead("gemini:antigravity", 1, 0, out value)) {
26
+ if (Marshal.GetLastWin32Error() == 1168) return null;
27
+ throw new Exception("Credential store unavailable");
28
+ }
29
+ byte[] bytes = null;
30
+ try {
31
+ var credential = (Credential)Marshal.PtrToStructure(value, typeof(Credential));
32
+ if (credential.CredentialBlobSize > 65536) throw new Exception("Invalid credential");
33
+ bytes = new byte[credential.CredentialBlobSize];
34
+ Marshal.Copy(credential.CredentialBlob, bytes, 0, bytes.Length);
35
+ return bytes.Length > 1 && bytes[1] == 0
36
+ ? new UnicodeEncoding(false, false, true).GetString(bytes)
37
+ : new UTF8Encoding(false, true).GetString(bytes);
38
+ } finally {
39
+ if (bytes != null) Array.Clear(bytes, 0, bytes.Length);
40
+ CredFree(value);
41
+ }
42
+ }
43
+ }
44
+ '@
45
+ $raw = [CwnAgyCredential]::Read()
46
+ if ($null -eq $raw) { @{ state = 'unconfigured' } | ConvertTo-Json -Compress; exit 0 }
47
+ $account = $raw | ConvertFrom-Json
48
+ $raw = $null
49
+ if ($account.auth_method -ne 'consumer' -or -not $account.token) {
50
+ @{ state = 'unknown' } | ConvertTo-Json -Compress; exit 0
51
+ }
52
+ $active = $false
53
+ if ($account.token.access_token -is [string] -and $account.token.access_token.Trim()) {
54
+ try { $active = [DateTimeOffset]::Parse($account.token.expiry) -gt [DateTimeOffset]::UtcNow } catch {}
55
+ }
56
+ $refreshable = $account.token.refresh_token -is [string] -and $account.token.refresh_token.Trim().Length -gt 0
57
+ if (-not $active -and -not $refreshable) {
58
+ @{ state = 'unauthenticated' } | ConvertTo-Json -Compress; exit 0
59
+ }
60
+ $result = @{ state = 'authenticated' }
61
+ if ($account.id_token -is [string] -and $account.id_token.Length -le 32768 -and $account.id_token -match '^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$') {
62
+ $encoded = $account.id_token.Split('.')[1].Replace('-','+').Replace('_','/')
63
+ $encoded = $encoded.PadRight($encoded.Length + ((4 - $encoded.Length % 4) % 4), '=')
64
+ $bytes = [Convert]::FromBase64String($encoded)
65
+ try { $claims = [Text.Encoding]::UTF8.GetString($bytes) | ConvertFrom-Json }
66
+ finally { [Array]::Clear($bytes, 0, $bytes.Length) }
67
+ if ($claims.iss -in @('accounts.google.com', 'https://accounts.google.com') -and $claims.sub -is [string] -and $claims.sub -match '^[A-Za-z0-9_-]{6,128}$') {
68
+ $hash = [Security.Cryptography.SHA256]::Create()
69
+ $principal = [Text.Encoding]::UTF8.GetBytes('google:' + $claims.sub)
70
+ try { $result.principalHash = ([BitConverter]::ToString($hash.ComputeHash($principal))).Replace('-','').ToLowerInvariant() }
71
+ finally { [Array]::Clear($principal, 0, $principal.Length); $hash.Dispose() }
72
+ if ($claims.email -is [string] -and $claims.email.Length -le 254 -and $claims.email -match '^[^\s<>@]+@[^\s<>@]+\.[^\s<>@]+$') { $result.email = $claims.email }
73
+ }
74
+ }
75
+ $account = $null; $claims = $null
76
+ $result | ConvertTo-Json -Compress
77
+ } catch {
78
+ # Neither exception strings nor credential fragments cross the process boundary.
79
+ @{ state = 'unavailable' } | ConvertTo-Json -Compress
80
+ exit 1
81
+ }
@@ -0,0 +1,49 @@
1
+ // A GUI-subsystem Electron root avoids Windows Terminal's console delegation.
2
+ // The enclosing Harness Job still owns this root and every native descendant.
3
+ import { Socket } from 'node:net'
4
+ import { forwardNativeStdio, spawnNativeProcess } from './native-spawn.mjs'
5
+
6
+ // Pinned Harness 0.2.0-rc.2 public control contract. This helper must remain
7
+ // self-contained: an ordinary child does not use the Host's SDK module loader.
8
+ const marker = process.env.DSH_SUBPROCESS_CONTROL
9
+ delete process.env.DSH_SUBPROCESS_CONTROL
10
+ if (marker !== 'pipe') throw new Error('Windows background control channel is unavailable')
11
+ const control = new Socket({ fd: 7, readable: true, writable: true, allowHalfOpen: true })
12
+ let child, sent = false
13
+ function receipt(value) {
14
+ if (sent) return
15
+ sent = true
16
+ control.end(JSON.stringify(value) + '\n', () => control.destroy())
17
+ }
18
+ control.on('error', () => {
19
+ child?.kill('SIGTERM')
20
+ process.exitCode = 1
21
+ })
22
+ try {
23
+ const [encoded, executable, ...argv] = process.argv.slice(2)
24
+ const restore = JSON.parse(encoded)
25
+ if (!restore || !Object.hasOwn(restore, 'nodeEnv') ||
26
+ (restore.nodeEnv !== null && typeof restore.nodeEnv !== 'string') || !executable)
27
+ throw new Error('Invalid fixed bootstrap arguments')
28
+ if (restore.privateUmask === true) process.umask(0o077)
29
+ // ELECTRON_RUN_AS_NODE belongs only to this GUI bootstrap. Preserve the
30
+ // original target environment, including an explicit deletion of that value.
31
+ const env = { ...process.env }
32
+ for (const key of Object.keys(env))
33
+ if (key.toUpperCase() === 'ELECTRON_RUN_AS_NODE') delete env[key]
34
+ if (restore.nodeEnv !== null) env.ELECTRON_RUN_AS_NODE = restore.nodeEnv
35
+ child = spawnNativeProcess(executable, argv, { env, stdio: ['pipe', 'pipe', 'pipe'], detached: false })
36
+ forwardNativeStdio(child)
37
+ child.once('error', error => receipt({
38
+ kind: 'spawn-error',
39
+ code: ['ENOENT', 'EACCES', 'ENOEXEC', 'EINVAL'].includes(error.code) ? error.code : 'UNKNOWN',
40
+ }))
41
+ // A descendant may keep these pipes open after the native parent exits.
42
+ // Report its actual exit now; keep forwarding bytes until the pipes close.
43
+ // The Host's original Job remains responsible for the entire process range.
44
+ child.once('exit', (exitCode, signal) => receipt({ kind: 'exit', exitCode, signal }))
45
+ for (const signal of ['SIGTERM', 'SIGINT'])
46
+ process.on(signal, () => child.kill(signal))
47
+ } catch {
48
+ receipt({ kind: 'spawn-error', code: 'UNKNOWN' })
49
+ }