@aiden-ade/sandbox-agent 0.1.84 → 0.1.85

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 (342) hide show
  1. package/dist/__tests__/binding-switch-git.test.d.ts +2 -0
  2. package/dist/__tests__/binding-switch-git.test.d.ts.map +1 -0
  3. package/dist/__tests__/binding-switch-git.test.js +610 -0
  4. package/dist/__tests__/binding-switch-git.test.js.map +1 -0
  5. package/dist/__tests__/cli-ensure-install.test.d.ts +2 -0
  6. package/dist/__tests__/cli-ensure-install.test.d.ts.map +1 -0
  7. package/dist/__tests__/cli-ensure-install.test.js +109 -0
  8. package/dist/__tests__/cli-ensure-install.test.js.map +1 -0
  9. package/dist/__tests__/cli-executable.test.d.ts +2 -0
  10. package/dist/__tests__/cli-executable.test.d.ts.map +1 -0
  11. package/dist/__tests__/cli-executable.test.js +129 -0
  12. package/dist/__tests__/cli-executable.test.js.map +1 -0
  13. package/dist/__tests__/cli-help.test.d.ts +2 -0
  14. package/dist/__tests__/cli-help.test.d.ts.map +1 -0
  15. package/dist/__tests__/cli-help.test.js +34 -0
  16. package/dist/__tests__/cli-help.test.js.map +1 -0
  17. package/dist/__tests__/computer-readiness.test.d.ts +2 -0
  18. package/dist/__tests__/computer-readiness.test.d.ts.map +1 -0
  19. package/dist/__tests__/computer-readiness.test.js +63 -0
  20. package/dist/__tests__/computer-readiness.test.js.map +1 -0
  21. package/dist/__tests__/core-agent-workflow-context.test.d.ts +2 -0
  22. package/dist/__tests__/core-agent-workflow-context.test.d.ts.map +1 -0
  23. package/dist/__tests__/core-agent-workflow-context.test.js +139 -0
  24. package/dist/__tests__/core-agent-workflow-context.test.js.map +1 -0
  25. package/dist/__tests__/daemon-reconcile-ask.test.d.ts +2 -0
  26. package/dist/__tests__/daemon-reconcile-ask.test.d.ts.map +1 -0
  27. package/dist/__tests__/daemon-reconcile-ask.test.js +86 -0
  28. package/dist/__tests__/daemon-reconcile-ask.test.js.map +1 -0
  29. package/dist/__tests__/daemon-socket.integration.test.d.ts +2 -0
  30. package/dist/__tests__/daemon-socket.integration.test.d.ts.map +1 -0
  31. package/dist/__tests__/daemon-socket.integration.test.js +450 -0
  32. package/dist/__tests__/daemon-socket.integration.test.js.map +1 -0
  33. package/dist/__tests__/daemon.test.d.ts +2 -0
  34. package/dist/__tests__/daemon.test.d.ts.map +1 -0
  35. package/dist/__tests__/daemon.test.js +3975 -0
  36. package/dist/__tests__/daemon.test.js.map +1 -0
  37. package/dist/__tests__/ensure-shared-checkout-branch.test.d.ts +2 -0
  38. package/dist/__tests__/ensure-shared-checkout-branch.test.d.ts.map +1 -0
  39. package/dist/__tests__/ensure-shared-checkout-branch.test.js +129 -0
  40. package/dist/__tests__/ensure-shared-checkout-branch.test.js.map +1 -0
  41. package/dist/__tests__/event-outbox-persist-failure.test.d.ts +2 -0
  42. package/dist/__tests__/event-outbox-persist-failure.test.d.ts.map +1 -0
  43. package/dist/__tests__/event-outbox-persist-failure.test.js +84 -0
  44. package/dist/__tests__/event-outbox-persist-failure.test.js.map +1 -0
  45. package/dist/__tests__/event-outbox.test.d.ts +2 -0
  46. package/dist/__tests__/event-outbox.test.d.ts.map +1 -0
  47. package/dist/__tests__/event-outbox.test.js +256 -0
  48. package/dist/__tests__/event-outbox.test.js.map +1 -0
  49. package/dist/__tests__/fake-provider-cli.test.d.ts +2 -0
  50. package/dist/__tests__/fake-provider-cli.test.d.ts.map +1 -0
  51. package/dist/__tests__/fake-provider-cli.test.js +46 -0
  52. package/dist/__tests__/fake-provider-cli.test.js.map +1 -0
  53. package/dist/__tests__/generated-images.test.d.ts +2 -0
  54. package/dist/__tests__/generated-images.test.d.ts.map +1 -0
  55. package/dist/__tests__/generated-images.test.js +132 -0
  56. package/dist/__tests__/generated-images.test.js.map +1 -0
  57. package/dist/__tests__/lifecycle-logger.test.d.ts +2 -0
  58. package/dist/__tests__/lifecycle-logger.test.d.ts.map +1 -0
  59. package/dist/__tests__/lifecycle-logger.test.js +49 -0
  60. package/dist/__tests__/lifecycle-logger.test.js.map +1 -0
  61. package/dist/__tests__/local-skill-scan.test.d.ts +2 -0
  62. package/dist/__tests__/local-skill-scan.test.d.ts.map +1 -0
  63. package/dist/__tests__/local-skill-scan.test.js +91 -0
  64. package/dist/__tests__/local-skill-scan.test.js.map +1 -0
  65. package/dist/__tests__/local-workspace-migration.test.d.ts +2 -0
  66. package/dist/__tests__/local-workspace-migration.test.d.ts.map +1 -0
  67. package/dist/__tests__/local-workspace-migration.test.js +195 -0
  68. package/dist/__tests__/local-workspace-migration.test.js.map +1 -0
  69. package/dist/__tests__/mcp-inspect-timeout.test.d.ts +2 -0
  70. package/dist/__tests__/mcp-inspect-timeout.test.d.ts.map +1 -0
  71. package/dist/__tests__/mcp-inspect-timeout.test.js +97 -0
  72. package/dist/__tests__/mcp-inspect-timeout.test.js.map +1 -0
  73. package/dist/__tests__/mcp-readiness.test.d.ts +2 -0
  74. package/dist/__tests__/mcp-readiness.test.d.ts.map +1 -0
  75. package/dist/__tests__/mcp-readiness.test.js +267 -0
  76. package/dist/__tests__/mcp-readiness.test.js.map +1 -0
  77. package/dist/__tests__/mcp-registration-cli.test.d.ts +2 -0
  78. package/dist/__tests__/mcp-registration-cli.test.d.ts.map +1 -0
  79. package/dist/__tests__/mcp-registration-cli.test.js +71 -0
  80. package/dist/__tests__/mcp-registration-cli.test.js.map +1 -0
  81. package/dist/__tests__/mcp-registration.test.d.ts +2 -0
  82. package/dist/__tests__/mcp-registration.test.d.ts.map +1 -0
  83. package/dist/__tests__/mcp-registration.test.js +426 -0
  84. package/dist/__tests__/mcp-registration.test.js.map +1 -0
  85. package/dist/__tests__/model-scan-runner.test.d.ts +2 -0
  86. package/dist/__tests__/model-scan-runner.test.d.ts.map +1 -0
  87. package/dist/__tests__/model-scan-runner.test.js +67 -0
  88. package/dist/__tests__/model-scan-runner.test.js.map +1 -0
  89. package/dist/__tests__/network-diagnostics.test.d.ts +2 -0
  90. package/dist/__tests__/network-diagnostics.test.d.ts.map +1 -0
  91. package/dist/__tests__/network-diagnostics.test.js +26 -0
  92. package/dist/__tests__/network-diagnostics.test.js.map +1 -0
  93. package/dist/__tests__/observable-map.test.d.ts +2 -0
  94. package/dist/__tests__/observable-map.test.d.ts.map +1 -0
  95. package/dist/__tests__/observable-map.test.js +54 -0
  96. package/dist/__tests__/observable-map.test.js.map +1 -0
  97. package/dist/__tests__/provider-auth-preflight.test.d.ts +2 -0
  98. package/dist/__tests__/provider-auth-preflight.test.d.ts.map +1 -0
  99. package/dist/__tests__/provider-auth-preflight.test.js +123 -0
  100. package/dist/__tests__/provider-auth-preflight.test.js.map +1 -0
  101. package/dist/__tests__/provider-model-discovery.test.d.ts +2 -0
  102. package/dist/__tests__/provider-model-discovery.test.d.ts.map +1 -0
  103. package/dist/__tests__/provider-model-discovery.test.js +472 -0
  104. package/dist/__tests__/provider-model-discovery.test.js.map +1 -0
  105. package/dist/__tests__/remove-worktrees-if-clean.test.d.ts +2 -0
  106. package/dist/__tests__/remove-worktrees-if-clean.test.d.ts.map +1 -0
  107. package/dist/__tests__/remove-worktrees-if-clean.test.js +221 -0
  108. package/dist/__tests__/remove-worktrees-if-clean.test.js.map +1 -0
  109. package/dist/__tests__/resume-fallback-env.test.d.ts +2 -0
  110. package/dist/__tests__/resume-fallback-env.test.d.ts.map +1 -0
  111. package/dist/__tests__/resume-fallback-env.test.js +28 -0
  112. package/dist/__tests__/resume-fallback-env.test.js.map +1 -0
  113. package/dist/__tests__/run-journal.test.d.ts +2 -0
  114. package/dist/__tests__/run-journal.test.d.ts.map +1 -0
  115. package/dist/__tests__/run-journal.test.js +121 -0
  116. package/dist/__tests__/run-journal.test.js.map +1 -0
  117. package/dist/__tests__/run-start-gate.test.d.ts +2 -0
  118. package/dist/__tests__/run-start-gate.test.d.ts.map +1 -0
  119. package/dist/__tests__/run-start-gate.test.js +29 -0
  120. package/dist/__tests__/run-start-gate.test.js.map +1 -0
  121. package/dist/__tests__/runtime-capabilities-sync.test.d.ts +2 -0
  122. package/dist/__tests__/runtime-capabilities-sync.test.d.ts.map +1 -0
  123. package/dist/__tests__/runtime-capabilities-sync.test.js +66 -0
  124. package/dist/__tests__/runtime-capabilities-sync.test.js.map +1 -0
  125. package/dist/__tests__/runtime-config.test.d.ts +2 -0
  126. package/dist/__tests__/runtime-config.test.d.ts.map +1 -0
  127. package/dist/__tests__/runtime-config.test.js +102 -0
  128. package/dist/__tests__/runtime-config.test.js.map +1 -0
  129. package/dist/__tests__/runtime-presenter-heartbeat.test.d.ts +2 -0
  130. package/dist/__tests__/runtime-presenter-heartbeat.test.d.ts.map +1 -0
  131. package/dist/__tests__/runtime-presenter-heartbeat.test.js +159 -0
  132. package/dist/__tests__/runtime-presenter-heartbeat.test.js.map +1 -0
  133. package/dist/__tests__/sandbox-outbox.test.d.ts +2 -0
  134. package/dist/__tests__/sandbox-outbox.test.d.ts.map +1 -0
  135. package/dist/__tests__/sandbox-outbox.test.js +214 -0
  136. package/dist/__tests__/sandbox-outbox.test.js.map +1 -0
  137. package/dist/__tests__/sandbox-workflow-context.test.d.ts +2 -0
  138. package/dist/__tests__/sandbox-workflow-context.test.d.ts.map +1 -0
  139. package/dist/__tests__/sandbox-workflow-context.test.js +396 -0
  140. package/dist/__tests__/sandbox-workflow-context.test.js.map +1 -0
  141. package/dist/__tests__/service-manager.test.d.ts +2 -0
  142. package/dist/__tests__/service-manager.test.d.ts.map +1 -0
  143. package/dist/__tests__/service-manager.test.js +50 -0
  144. package/dist/__tests__/service-manager.test.js.map +1 -0
  145. package/dist/__tests__/sleep-inhibitor.test.d.ts +2 -0
  146. package/dist/__tests__/sleep-inhibitor.test.d.ts.map +1 -0
  147. package/dist/__tests__/sleep-inhibitor.test.js +236 -0
  148. package/dist/__tests__/sleep-inhibitor.test.js.map +1 -0
  149. package/dist/__tests__/status-local-workspace.test.d.ts +2 -0
  150. package/dist/__tests__/status-local-workspace.test.d.ts.map +1 -0
  151. package/dist/__tests__/status-local-workspace.test.js +121 -0
  152. package/dist/__tests__/status-local-workspace.test.js.map +1 -0
  153. package/dist/__tests__/suspension-detector.test.d.ts +2 -0
  154. package/dist/__tests__/suspension-detector.test.d.ts.map +1 -0
  155. package/dist/__tests__/suspension-detector.test.js +112 -0
  156. package/dist/__tests__/suspension-detector.test.js.map +1 -0
  157. package/dist/__tests__/web-presenter-parent-events.test.d.ts +2 -0
  158. package/dist/__tests__/web-presenter-parent-events.test.d.ts.map +1 -0
  159. package/dist/__tests__/web-presenter-parent-events.test.js +130 -0
  160. package/dist/__tests__/web-presenter-parent-events.test.js.map +1 -0
  161. package/dist/__tests__/workspace-relocation.test.d.ts +2 -0
  162. package/dist/__tests__/workspace-relocation.test.d.ts.map +1 -0
  163. package/dist/__tests__/workspace-relocation.test.js +66 -0
  164. package/dist/__tests__/workspace-relocation.test.js.map +1 -0
  165. package/dist/__tests__/workspace-run-lease.test.d.ts +2 -0
  166. package/dist/__tests__/workspace-run-lease.test.d.ts.map +1 -0
  167. package/dist/__tests__/workspace-run-lease.test.js +230 -0
  168. package/dist/__tests__/workspace-run-lease.test.js.map +1 -0
  169. package/dist/__tests__/ws-client-heartbeat-volatile.test.d.ts +2 -0
  170. package/dist/__tests__/ws-client-heartbeat-volatile.test.d.ts.map +1 -0
  171. package/dist/__tests__/ws-client-heartbeat-volatile.test.js +61 -0
  172. package/dist/__tests__/ws-client-heartbeat-volatile.test.js.map +1 -0
  173. package/dist/__tests__/ws-client-heartbeat.integration.test.d.ts +2 -0
  174. package/dist/__tests__/ws-client-heartbeat.integration.test.d.ts.map +1 -0
  175. package/dist/__tests__/ws-client-heartbeat.integration.test.js +109 -0
  176. package/dist/__tests__/ws-client-heartbeat.integration.test.js.map +1 -0
  177. package/dist/__tests__/ws-client-user-message-ack.integration.test.d.ts +2 -0
  178. package/dist/__tests__/ws-client-user-message-ack.integration.test.d.ts.map +1 -0
  179. package/dist/__tests__/ws-client-user-message-ack.integration.test.js +167 -0
  180. package/dist/__tests__/ws-client-user-message-ack.integration.test.js.map +1 -0
  181. package/dist/aiden-system-prompt.d.ts +6 -0
  182. package/dist/aiden-system-prompt.d.ts.map +1 -0
  183. package/dist/aiden-system-prompt.js +6 -0
  184. package/dist/aiden-system-prompt.js.map +1 -0
  185. package/dist/binding-switch-git.d.ts +26 -0
  186. package/dist/binding-switch-git.d.ts.map +1 -0
  187. package/dist/binding-switch-git.js +973 -0
  188. package/dist/binding-switch-git.js.map +1 -0
  189. package/dist/cli-ensure-install.d.ts +39 -0
  190. package/dist/cli-ensure-install.d.ts.map +1 -0
  191. package/dist/cli-ensure-install.js +133 -0
  192. package/dist/cli-ensure-install.js.map +1 -0
  193. package/dist/cli-executable.d.ts +97 -0
  194. package/dist/cli-executable.d.ts.map +1 -0
  195. package/dist/cli-executable.js +432 -0
  196. package/dist/cli-executable.js.map +1 -0
  197. package/dist/cli-help.d.ts +7 -0
  198. package/dist/cli-help.d.ts.map +1 -0
  199. package/dist/cli-help.js +49 -0
  200. package/dist/cli-help.js.map +1 -0
  201. package/dist/computer-readiness.d.ts +42 -0
  202. package/dist/computer-readiness.d.ts.map +1 -0
  203. package/dist/computer-readiness.js +191 -0
  204. package/dist/computer-readiness.js.map +1 -0
  205. package/dist/core-agent.d.ts +47 -0
  206. package/dist/core-agent.d.ts.map +1 -0
  207. package/dist/core-agent.js +364 -0
  208. package/dist/core-agent.js.map +1 -0
  209. package/dist/daemon.d.ts +392 -0
  210. package/dist/daemon.d.ts.map +1 -0
  211. package/dist/daemon.js +4711 -0
  212. package/dist/daemon.js.map +1 -0
  213. package/dist/event-outbox.d.ts +83 -0
  214. package/dist/event-outbox.d.ts.map +1 -0
  215. package/dist/event-outbox.js +440 -0
  216. package/dist/event-outbox.js.map +1 -0
  217. package/dist/fake-provider-cli.d.ts +13 -0
  218. package/dist/fake-provider-cli.d.ts.map +1 -0
  219. package/dist/fake-provider-cli.js +53 -0
  220. package/dist/fake-provider-cli.js.map +1 -0
  221. package/dist/generated-images.d.ts +2 -0
  222. package/dist/generated-images.d.ts.map +1 -0
  223. package/dist/generated-images.js +2 -0
  224. package/dist/generated-images.js.map +1 -0
  225. package/dist/index.cjs +266 -161
  226. package/dist/index.d.ts +6 -0
  227. package/dist/index.d.ts.map +1 -0
  228. package/dist/index.js +209 -0
  229. package/dist/index.js.map +1 -0
  230. package/dist/lifecycle-logger.d.ts +25 -0
  231. package/dist/lifecycle-logger.d.ts.map +1 -0
  232. package/dist/lifecycle-logger.js +73 -0
  233. package/dist/lifecycle-logger.js.map +1 -0
  234. package/dist/local-skill-scan.d.ts +21 -0
  235. package/dist/local-skill-scan.d.ts.map +1 -0
  236. package/dist/local-skill-scan.js +109 -0
  237. package/dist/local-skill-scan.js.map +1 -0
  238. package/dist/local-workspace-migration.d.ts +68 -0
  239. package/dist/local-workspace-migration.d.ts.map +1 -0
  240. package/dist/local-workspace-migration.js +157 -0
  241. package/dist/local-workspace-migration.js.map +1 -0
  242. package/dist/mcp-readiness.d.ts +59 -0
  243. package/dist/mcp-readiness.d.ts.map +1 -0
  244. package/dist/mcp-readiness.js +202 -0
  245. package/dist/mcp-readiness.js.map +1 -0
  246. package/dist/mcp-registration.d.ts +75 -0
  247. package/dist/mcp-registration.d.ts.map +1 -0
  248. package/dist/mcp-registration.js +563 -0
  249. package/dist/mcp-registration.js.map +1 -0
  250. package/dist/model-scan-runner.d.ts +15 -0
  251. package/dist/model-scan-runner.d.ts.map +1 -0
  252. package/dist/model-scan-runner.js +51 -0
  253. package/dist/model-scan-runner.js.map +1 -0
  254. package/dist/network-diagnostics.d.ts +8 -0
  255. package/dist/network-diagnostics.d.ts.map +1 -0
  256. package/dist/network-diagnostics.js +56 -0
  257. package/dist/network-diagnostics.js.map +1 -0
  258. package/dist/observable-map.d.ts +25 -0
  259. package/dist/observable-map.d.ts.map +1 -0
  260. package/dist/observable-map.js +42 -0
  261. package/dist/observable-map.js.map +1 -0
  262. package/dist/provider-auth-preflight.d.ts +22 -0
  263. package/dist/provider-auth-preflight.d.ts.map +1 -0
  264. package/dist/provider-auth-preflight.js +110 -0
  265. package/dist/provider-auth-preflight.js.map +1 -0
  266. package/dist/provider-model-discovery.d.ts +38 -0
  267. package/dist/provider-model-discovery.d.ts.map +1 -0
  268. package/dist/provider-model-discovery.js +519 -0
  269. package/dist/provider-model-discovery.js.map +1 -0
  270. package/dist/resume-fallback-env.d.ts +20 -0
  271. package/dist/resume-fallback-env.d.ts.map +1 -0
  272. package/dist/resume-fallback-env.js +30 -0
  273. package/dist/resume-fallback-env.js.map +1 -0
  274. package/dist/run-journal.d.ts +53 -0
  275. package/dist/run-journal.d.ts.map +1 -0
  276. package/dist/run-journal.js +193 -0
  277. package/dist/run-journal.js.map +1 -0
  278. package/dist/run-start-gate.d.ts +9 -0
  279. package/dist/run-start-gate.d.ts.map +1 -0
  280. package/dist/run-start-gate.js +24 -0
  281. package/dist/run-start-gate.js.map +1 -0
  282. package/dist/runtime-backends.d.ts +2 -0
  283. package/dist/runtime-backends.d.ts.map +1 -0
  284. package/dist/runtime-backends.js +2 -0
  285. package/dist/runtime-backends.js.map +1 -0
  286. package/dist/runtime-capabilities-sync.d.ts +33 -0
  287. package/dist/runtime-capabilities-sync.d.ts.map +1 -0
  288. package/dist/runtime-capabilities-sync.js +56 -0
  289. package/dist/runtime-capabilities-sync.js.map +1 -0
  290. package/dist/runtime-config.d.ts +24 -0
  291. package/dist/runtime-config.d.ts.map +1 -0
  292. package/dist/runtime-config.js +124 -0
  293. package/dist/runtime-config.js.map +1 -0
  294. package/dist/sandbox-outbox.d.ts +122 -0
  295. package/dist/sandbox-outbox.d.ts.map +1 -0
  296. package/dist/sandbox-outbox.js +180 -0
  297. package/dist/sandbox-outbox.js.map +1 -0
  298. package/dist/sandbox.d.ts +44 -0
  299. package/dist/sandbox.d.ts.map +1 -0
  300. package/dist/sandbox.js +438 -0
  301. package/dist/sandbox.js.map +1 -0
  302. package/dist/service-manager.d.ts +28 -0
  303. package/dist/service-manager.d.ts.map +1 -0
  304. package/dist/service-manager.js +259 -0
  305. package/dist/service-manager.js.map +1 -0
  306. package/dist/sleep-inhibitor.d.ts +111 -0
  307. package/dist/sleep-inhibitor.d.ts.map +1 -0
  308. package/dist/sleep-inhibitor.js +412 -0
  309. package/dist/sleep-inhibitor.js.map +1 -0
  310. package/dist/suspension-detector.d.ts +48 -0
  311. package/dist/suspension-detector.d.ts.map +1 -0
  312. package/dist/suspension-detector.js +89 -0
  313. package/dist/suspension-detector.js.map +1 -0
  314. package/dist/types.d.ts +6 -0
  315. package/dist/types.d.ts.map +1 -0
  316. package/dist/types.js +6 -0
  317. package/dist/types.js.map +1 -0
  318. package/dist/updater.d.ts +15 -0
  319. package/dist/updater.d.ts.map +1 -0
  320. package/dist/updater.js +50 -0
  321. package/dist/updater.js.map +1 -0
  322. package/dist/version.d.ts +2 -0
  323. package/dist/version.d.ts.map +1 -0
  324. package/dist/version.js +2 -0
  325. package/dist/version.js.map +1 -0
  326. package/dist/web-presenter.d.ts +55 -0
  327. package/dist/web-presenter.d.ts.map +1 -0
  328. package/dist/web-presenter.js +265 -0
  329. package/dist/web-presenter.js.map +1 -0
  330. package/dist/workspace-relocation.d.ts +22 -0
  331. package/dist/workspace-relocation.d.ts.map +1 -0
  332. package/dist/workspace-relocation.js +90 -0
  333. package/dist/workspace-relocation.js.map +1 -0
  334. package/dist/workspace-run-lease.d.ts +97 -0
  335. package/dist/workspace-run-lease.d.ts.map +1 -0
  336. package/dist/workspace-run-lease.js +241 -0
  337. package/dist/workspace-run-lease.js.map +1 -0
  338. package/dist/ws-client.d.ts +194 -0
  339. package/dist/ws-client.d.ts.map +1 -0
  340. package/dist/ws-client.js +282 -0
  341. package/dist/ws-client.js.map +1 -0
  342. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -15240,7 +15240,7 @@ function describeError(error61) {
15240
15240
  }
15241
15241
 
15242
15242
  // src/version.ts
15243
- var AGENT_VERSION = "0.1.84";
15243
+ var AGENT_VERSION = "0.1.85";
15244
15244
 
15245
15245
  // src/daemon-worktree.ts
15246
15246
  var import_node_child_process3 = require("child_process");
@@ -35303,6 +35303,8 @@ var activeRunSlotSchema = external_exports.object({
35303
35303
  providerPid: external_exports.number().int().positive().nullable().optional(),
35304
35304
  acceptedAtMs: external_exports.number().int().nonnegative().optional(),
35305
35305
  lastActivityAtMs: external_exports.number().int().nonnegative().optional(),
35306
+ /** A live interactive prompt still owns capacity even without stream activity. */
35307
+ awaitingUser: external_exports.boolean().optional(),
35306
35308
  stale: external_exports.boolean().optional()
35307
35309
  });
35308
35310
  var RUNNER_CAPACITY_SOURCES = ["default", "config", "provider_limit"];
@@ -35409,7 +35411,7 @@ function countNonStaleActiveRuns(activeRuns, nowMs = Date.now(), graceMs = RUNNE
35409
35411
  let staleRunCount = 0;
35410
35412
  for (const run of activeRuns) {
35411
35413
  const lastActivity = run.lastActivityAtMs ?? run.acceptedAtMs ?? 0;
35412
- const stale = run.stale === true || lastActivity > 0 && nowMs - lastActivity >= graceMs;
35414
+ const stale = run.stale === true || run.awaitingUser !== true && lastActivity > 0 && nowMs - lastActivity >= graceMs;
35413
35415
  if (stale)
35414
35416
  staleRunCount += 1;
35415
35417
  else
@@ -38898,7 +38900,9 @@ function mapProviderApiError(errorCode2, apiStatus) {
38898
38900
  return "model_mismatch";
38899
38901
  }
38900
38902
  if (code.includes("authentication") || code.includes("permission_error")) return "auth_invalid";
38901
- if (code.includes("rate_limit")) return "rate_limited";
38903
+ if (code.includes("rate_limit") || code.includes("resource_exhausted")) {
38904
+ return "rate_limited";
38905
+ }
38902
38906
  if (code.includes("overloaded")) return "overloaded";
38903
38907
  if (code.includes("insufficient_quota") || code.includes("billing")) return "quota_exceeded";
38904
38908
  }
@@ -38955,7 +38959,7 @@ function classifyCliErrorDetailed(stderr, _exitCode, opts) {
38955
38959
  if (has("datapolicyerror", "requires explicit opt in")) return specForErrorKind("model_mismatch");
38956
38960
  if (has("no chat found", "chat not found", "session not found", "could not resume"))
38957
38961
  return specForErrorKind("resume_failed");
38958
- if (has("rate_limit", "rate limit") || /\b429\b/.test(haystack))
38962
+ if (has("rate_limit", "rate limit", "resource_exhausted", "resource exhausted") || /\b429\b/.test(haystack))
38959
38963
  return specForErrorKind("rate_limited");
38960
38964
  if (has("authentication_failed", "authentication error", "authentication failed") || isLikelyProviderAuthError(haystack))
38961
38965
  return specForErrorKind("auth_invalid");
@@ -39027,7 +39031,7 @@ function classifyCliErrorDetailed(stderr, _exitCode, opts) {
39027
39031
  }
39028
39032
  function isTransientError(errorMessage) {
39029
39033
  const lower = errorMessage.toLowerCase();
39030
- return lower.includes("rate limit") || lower.includes("overloaded") || /(?:http|status)\s*500\b|\[500\]|\b500 internal server error\b/.test(lower) || lower.includes("502") || lower.includes("503") || lower.includes("504") || lower.includes("524") || lower.includes("429") || lower.includes("service unavailable") || // Node's generic fetch() network-layer failure (opencode_serve's SSE/HTTP calls).
39034
+ return lower.includes("rate limit") || lower.includes("resource_exhausted") || lower.includes("resource exhausted") || lower.includes("overloaded") || /(?:http|status)\s*500\b|\[500\]|\b500 internal server error\b/.test(lower) || lower.includes("502") || lower.includes("503") || lower.includes("504") || lower.includes("524") || lower.includes("429") || lower.includes("service unavailable") || // Node's generic fetch() network-layer failure (opencode_serve's SSE/HTTP calls).
39031
39035
  lower.includes("fetch failed") || lower.includes("etimedout") || lower.includes("econnreset") || lower.includes("econnrefused") || // DNS resolution blips (e.g. "getaddrinfo ENOTFOUND api2.cursor.sh") are
39032
39036
  // transient connectivity failures — the machine briefly can't resolve the
39033
39037
  // provider host and recovers seconds later. Retry with backoff instead of
@@ -39891,8 +39895,10 @@ function createGenericCliBackend(options) {
39891
39895
  }
39892
39896
  const stderrText = (stderrLines.join("\n") || stderrChunks.join("")).trim();
39893
39897
  const hasStructuredError = exitCode === 0 && !!state.error?.trim();
39898
+ const cursorRetrievalResourceExhaustedBeforeTurn = options.kind === "cursor_agent_cli" && state.iterations === 0 && !state.resultReceived && !state.summary.trim() && stderrText.toLowerCase().includes("cursor-retrieval") && /resource[_ ]exhausted/i.test(stderrText);
39899
+ const exitedWithoutResponse = options.kind === "codex_app_server" && exitCode === 0 && exitSignal === null && !state.resultReceived && !hasRenderableTurn && !midSubagentParentExit;
39894
39900
  const expectedExitGraceKill = state.exitGraceKillTriggered === true && !state.error?.trim() && !midSubagentParentExit && (state.summary.trim().length > 0 || state.iterations > 0 || Boolean(state.resultReceived));
39895
- const failed = !expectedExitGraceKill && (exitCode !== 0 || exitSignal !== null) || hasStructuredError || midSubagentParentExit;
39901
+ const failed = !expectedExitGraceKill && (exitCode !== 0 || exitSignal !== null) || hasStructuredError || midSubagentParentExit || exitedWithoutResponse;
39896
39902
  if (cursorResumeSilentlyFailed && !failed) {
39897
39903
  const problem = createCliProblem(
39898
39904
  {
@@ -39945,6 +39951,10 @@ function createGenericCliBackend(options) {
39945
39951
  classifiedError = midExit.message;
39946
39952
  classifiedErrorKind = midExit.errorKind;
39947
39953
  classifiedRecoveryClass = midExit.recoveryClass;
39954
+ } else if (exitedWithoutResponse) {
39955
+ classifiedError = "The agent exited without producing a response. Send your message again to retry.";
39956
+ classifiedErrorKind = "provider_error";
39957
+ classifiedRecoveryClass = "retry";
39948
39958
  } else {
39949
39959
  const detailed = classifyCliErrorDetailed(
39950
39960
  state.error?.trim() || stderrText || "",
@@ -39967,7 +39977,7 @@ function createGenericCliBackend(options) {
39967
39977
  harness: options.kind,
39968
39978
  phase: classifiedErrorKind === "resume_failed" ? "resume" : "shutdown",
39969
39979
  finality: "terminal",
39970
- outcomeCertainty: "effect_unknown",
39980
+ outcomeCertainty: cursorRetrievalResourceExhaustedBeforeTurn ? "no_effect" : "effect_unknown",
39971
39981
  scope: {
39972
39982
  ...context.config.conversationId ? { conversationId: context.config.conversationId } : {}
39973
39983
  },
@@ -48847,16 +48857,40 @@ var DurablePendingRunStarts = class extends Map {
48847
48857
  }
48848
48858
  startedAtByRunId = /* @__PURE__ */ new Map();
48849
48859
  set(runId, conversationId) {
48850
- if (!this.startedAtByRunId.has(runId)) this.startedAtByRunId.set(runId, Date.now());
48860
+ const previousConversationId = super.get(runId);
48861
+ const previousStartedAt = this.startedAtByRunId.get(runId);
48862
+ if (previousStartedAt === void 0) this.startedAtByRunId.set(runId, Date.now());
48851
48863
  super.set(runId, conversationId);
48852
- this.persist();
48864
+ try {
48865
+ this.persist();
48866
+ } catch (error61) {
48867
+ if (previousConversationId === void 0) {
48868
+ super.delete(runId);
48869
+ } else {
48870
+ super.set(runId, previousConversationId);
48871
+ }
48872
+ if (previousStartedAt === void 0) {
48873
+ this.startedAtByRunId.delete(runId);
48874
+ } else {
48875
+ this.startedAtByRunId.set(runId, previousStartedAt);
48876
+ }
48877
+ throw error61;
48878
+ }
48853
48879
  return this;
48854
48880
  }
48855
48881
  delete(runId) {
48882
+ const previousConversationId = super.get(runId);
48883
+ const previousStartedAt = this.startedAtByRunId.get(runId);
48856
48884
  const deleted = super.delete(runId);
48857
48885
  if (deleted) {
48858
48886
  this.startedAtByRunId.delete(runId);
48859
- this.persist();
48887
+ try {
48888
+ this.persist();
48889
+ } catch (error61) {
48890
+ if (previousConversationId !== void 0) super.set(runId, previousConversationId);
48891
+ if (previousStartedAt !== void 0) this.startedAtByRunId.set(runId, previousStartedAt);
48892
+ throw error61;
48893
+ }
48860
48894
  }
48861
48895
  return deleted;
48862
48896
  }
@@ -48917,10 +48951,10 @@ function buildAbortResult(reason) {
48917
48951
  }
48918
48952
  function abortActiveAgent(entry, options) {
48919
48953
  const awaitingAsk = (entry.presenter.pendingAskUserToolIds?.size ?? 0) > 0;
48920
- if (awaitingAsk && !options?.userInitiated) {
48954
+ const reason = options?.reason ?? (options?.userInitiated ? "user" : "runner_stalled");
48955
+ if (awaitingAsk && !options?.userInitiated && reason !== "runtime_shutdown") {
48921
48956
  return;
48922
48957
  }
48923
- const reason = options?.reason ?? (options?.userInitiated ? "user" : "runner_stalled");
48924
48958
  entry.presenter.onComplete(buildAbortResult(reason));
48925
48959
  entry.agent.kill();
48926
48960
  }
@@ -48937,7 +48971,8 @@ function buildActiveRunSlots(activeAgents, nowMs = Date.now()) {
48937
48971
  return [...activeAgents.entries()].map(([runId, entry]) => {
48938
48972
  const staleByGrace = nowMs - entry.lastActivityAtMs >= RUNNER_RECOVERY_GRACE_MS_LOCAL;
48939
48973
  const staleByDeadPid = entry.providerPid !== null && !isProviderProcessAlive(entry.providerPid);
48940
- const stale = staleByGrace || staleByDeadPid;
48974
+ const awaitingAsk = (entry.presenter.pendingAskUserToolIds?.size ?? 0) > 0;
48975
+ const stale = staleByDeadPid || staleByGrace && !awaitingAsk;
48941
48976
  return {
48942
48977
  runId,
48943
48978
  conversationId: entry.conversationId,
@@ -48945,6 +48980,7 @@ function buildActiveRunSlots(activeAgents, nowMs = Date.now()) {
48945
48980
  providerPid: entry.providerPid,
48946
48981
  acceptedAtMs: entry.acceptedAtMs,
48947
48982
  lastActivityAtMs: entry.lastActivityAtMs,
48983
+ awaitingUser: awaitingAsk,
48948
48984
  stale
48949
48985
  };
48950
48986
  });
@@ -49139,6 +49175,9 @@ async function collectRuntimeMetadataWithProviderLimits() {
49139
49175
  }
49140
49176
 
49141
49177
  // src/daemon-local-control.ts
49178
+ function isNativeTaskLinkingEnabled(config2) {
49179
+ return config2.nativeTaskLinkingEnabled === true;
49180
+ }
49142
49181
  var LOCAL_SERVICE_OWNER_VERSION = 1;
49143
49182
  var LOCAL_SERVICE_CHALLENGE_TTL_MS = 5e3;
49144
49183
  function localServiceOwnerPayload(owner) {
@@ -55539,13 +55578,13 @@ function ensureProviderCliInstalled(backendKind, options) {
55539
55578
  }
55540
55579
 
55541
55580
  // src/core-agent.ts
55542
- var import_node_os10 = require("os");
55581
+ var import_node_os11 = require("os");
55543
55582
 
55544
55583
  // src/mcp-registration.ts
55545
55584
  var import_node_crypto8 = require("crypto");
55546
- var import_node_fs16 = require("fs");
55547
- var import_node_os9 = require("os");
55548
- var import_node_path14 = require("path");
55585
+ var import_node_fs17 = require("fs");
55586
+ var import_node_os10 = require("os");
55587
+ var import_node_path15 = require("path");
55549
55588
 
55550
55589
  // ../../node_modules/smol-toml/dist/error.js
55551
55590
  function getLineColFromPtr(string4, ptr) {
@@ -56378,6 +56417,74 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
56378
56417
  return str;
56379
56418
  }
56380
56419
 
56420
+ // src/provider-startup-isolation.ts
56421
+ var import_node_fs16 = require("fs");
56422
+ var import_node_os9 = require("os");
56423
+ var import_node_path14 = require("path");
56424
+ function resolveProviderStartupIsolation(backendKind, _runtimePlatform) {
56425
+ switch (backendKind) {
56426
+ case "claude_cli":
56427
+ return { mode: "shared_config", lockKey: "claude_cli" };
56428
+ case "supatest_cli":
56429
+ return { mode: "shared_config", lockKey: "supatest_cli" };
56430
+ case "codex_app_server":
56431
+ return {
56432
+ mode: "run_scoped_home",
56433
+ envForRunRoot: (runRoot) => ({
56434
+ CODEX_HOME: (0, import_node_path14.join)(runRoot, ".codex")
56435
+ }),
56436
+ // Symlink ~/.codex/sessions into the per-run CODEX_HOME so Codex
56437
+ // writes session logs to the real user home and they survive cleanup().
56438
+ // Without this, cleanup() deletes the session log, findCodexSessionLog
56439
+ // returns null on the next run, and the "previous Codex session not
56440
+ // found" fallback fires every turn — feeding previous messages back in.
56441
+ hostStateLinks: [".codex/sessions"]
56442
+ };
56443
+ case "opencode_cli":
56444
+ case "opencode_serve":
56445
+ return { mode: "shared_config", lockKey: backendKind };
56446
+ default: {
56447
+ const key = backendKind?.trim() || "unknown";
56448
+ return { mode: "shared_config", lockKey: key };
56449
+ }
56450
+ }
56451
+ }
56452
+ function runScopedHomePath(runId, baseDir = (0, import_node_os9.tmpdir)()) {
56453
+ return (0, import_node_path14.join)(baseDir, "alan-runs", runId);
56454
+ }
56455
+ function prepareRunScopedProviderHome(input2) {
56456
+ const hostHome = input2.hostHome ?? (0, import_node_os9.homedir)();
56457
+ const runRoot = runScopedHomePath(input2.runId, input2.baseDir);
56458
+ (0, import_node_fs16.mkdirSync)(runRoot, { recursive: true, mode: 448 });
56459
+ for (const relative6 of input2.isolation.hostStateLinks) {
56460
+ const hostPath = (0, import_node_path14.join)(hostHome, relative6);
56461
+ const linkPath = (0, import_node_path14.join)(runRoot, relative6);
56462
+ if (!(0, import_node_fs16.existsSync)(hostPath)) {
56463
+ try {
56464
+ (0, import_node_fs16.mkdirSync)(hostPath, { recursive: true, mode: 448 });
56465
+ } catch {
56466
+ continue;
56467
+ }
56468
+ }
56469
+ (0, import_node_fs16.mkdirSync)((0, import_node_path14.dirname)(linkPath), { recursive: true, mode: 448 });
56470
+ if ((0, import_node_fs16.existsSync)(linkPath)) continue;
56471
+ try {
56472
+ const hostStat = (0, import_node_fs16.lstatSync)(hostPath);
56473
+ (0, import_node_fs16.symlinkSync)(hostPath, linkPath, hostStat.isDirectory() ? "dir" : "file");
56474
+ } catch {
56475
+ }
56476
+ }
56477
+ const mcpHome = runRoot;
56478
+ return {
56479
+ runRoot,
56480
+ mcpHome,
56481
+ env: input2.isolation.envForRunRoot(mcpHome),
56482
+ cleanup: () => {
56483
+ (0, import_node_fs16.rmSync)(runRoot, { recursive: true, force: true });
56484
+ }
56485
+ };
56486
+ }
56487
+
56381
56488
  // src/mcp-registration.ts
56382
56489
  var CONFIG_LOCK_STALE_MS = 3e4;
56383
56490
  var CONFIG_LOCK_WAIT_MS = 2e3;
@@ -56402,10 +56509,10 @@ var inspectAlanMcpThroughProviderCli = async (backendKind, expectedUrl, home) =>
56402
56509
  if (cached2 && cached2.expiresAt > Date.now()) {
56403
56510
  return cached2.result;
56404
56511
  }
56512
+ const startupIsolation = resolveProviderStartupIsolation(backendKind);
56405
56513
  const env = {
56406
56514
  ...getDaemonCliEnvironment(),
56407
- HOME: home,
56408
- USERPROFILE: home
56515
+ ...startupIsolation.mode === "run_scoped_home" ? startupIsolation.envForRunRoot(home) : { HOME: home, USERPROFILE: home }
56409
56516
  };
56410
56517
  const executable = resolveBackendRuntimeCommand(backendKind, env);
56411
56518
  const command = [plan.command, ...plan.args].join(" ");
@@ -56486,18 +56593,18 @@ var inspectAlanMcpThroughProviderCli = async (backendKind, expectedUrl, home) =>
56486
56593
  return result;
56487
56594
  };
56488
56595
  async function waitForConfigLock(lockPath) {
56489
- (0, import_node_fs16.mkdirSync)((0, import_node_path14.dirname)(lockPath), { recursive: true });
56596
+ (0, import_node_fs17.mkdirSync)((0, import_node_path15.dirname)(lockPath), { recursive: true });
56490
56597
  const startedAt = Date.now();
56491
56598
  while (true) {
56492
56599
  try {
56493
- (0, import_node_fs16.mkdirSync)(lockPath);
56494
- return () => (0, import_node_fs16.rmSync)(lockPath, { recursive: true, force: true });
56600
+ (0, import_node_fs17.mkdirSync)(lockPath);
56601
+ return () => (0, import_node_fs17.rmSync)(lockPath, { recursive: true, force: true });
56495
56602
  } catch (error61) {
56496
56603
  const code = error61 && typeof error61 === "object" && "code" in error61 ? error61.code : void 0;
56497
56604
  if (code !== "EEXIST") throw error61;
56498
56605
  try {
56499
- if (Date.now() - (0, import_node_fs16.statSync)(lockPath).mtimeMs > CONFIG_LOCK_STALE_MS) {
56500
- (0, import_node_fs16.rmSync)(lockPath, { recursive: true, force: true });
56606
+ if (Date.now() - (0, import_node_fs17.statSync)(lockPath).mtimeMs > CONFIG_LOCK_STALE_MS) {
56607
+ (0, import_node_fs17.rmSync)(lockPath, { recursive: true, force: true });
56501
56608
  continue;
56502
56609
  }
56503
56610
  } catch {
@@ -56513,7 +56620,7 @@ async function waitForConfigLock(lockPath) {
56513
56620
  function saveMalformedBackup(path2, content) {
56514
56621
  const hash2 = (0, import_node_crypto8.createHash)("sha256").update(content).digest("hex").slice(0, 12);
56515
56622
  const backupPath = `${path2}.alan-backup-${hash2}`;
56516
- if (!(0, import_node_fs16.existsSync)(backupPath)) (0, import_node_fs16.copyFileSync)(path2, backupPath);
56623
+ if (!(0, import_node_fs17.existsSync)(backupPath)) (0, import_node_fs17.copyFileSync)(path2, backupPath);
56517
56624
  return backupPath;
56518
56625
  }
56519
56626
  function parseJsonObject2(path2, content) {
@@ -56561,17 +56668,17 @@ function mergeCodexAlanSection(path2, existingContent, desiredContent) {
56561
56668
  function atomicWriteManagedConfig(path2, content) {
56562
56669
  const pendingPath = `${path2}.alan-pending-${process.pid}-${(0, import_node_crypto8.randomBytes)(6).toString("hex")}`;
56563
56670
  try {
56564
- (0, import_node_fs16.writeFileSync)(pendingPath, content, { encoding: "utf8", mode: 384, flag: "wx" });
56565
- (0, import_node_fs16.renameSync)(pendingPath, path2);
56671
+ (0, import_node_fs17.writeFileSync)(pendingPath, content, { encoding: "utf8", mode: 384, flag: "wx" });
56672
+ (0, import_node_fs17.renameSync)(pendingPath, path2);
56566
56673
  } finally {
56567
- (0, import_node_fs16.rmSync)(pendingPath, { force: true });
56674
+ (0, import_node_fs17.rmSync)(pendingPath, { force: true });
56568
56675
  }
56569
56676
  }
56570
- async function configureAntigravityApiKeyMode(home = (0, import_node_os9.homedir)()) {
56571
- const path2 = (0, import_node_path14.join)(home, ".gemini", "antigravity-cli", "settings.json");
56677
+ async function configureAntigravityApiKeyMode(home = (0, import_node_os10.homedir)()) {
56678
+ const path2 = (0, import_node_path15.join)(home, ".gemini", "antigravity-cli", "settings.json");
56572
56679
  const releaseLock = await waitForConfigLock(`${path2}.alan-lock`);
56573
56680
  try {
56574
- const existingContent = (0, import_node_fs16.existsSync)(path2) ? (0, import_node_fs16.readFileSync)(path2, "utf8") : "";
56681
+ const existingContent = (0, import_node_fs17.existsSync)(path2) ? (0, import_node_fs17.readFileSync)(path2, "utf8") : "";
56575
56682
  const settings = existingContent.trim() ? parseJsonObject2(path2, existingContent) : {};
56576
56683
  if (settings.modelProvider === "gemini") return false;
56577
56684
  settings.modelProvider = "gemini";
@@ -56581,16 +56688,16 @@ async function configureAntigravityApiKeyMode(home = (0, import_node_os9.homedir
56581
56688
  releaseLock();
56582
56689
  }
56583
56690
  }
56584
- async function ensureAlanMcpRegistered(backendKind, registration, home = (0, import_node_os9.homedir)(), inspectCli = inspectAlanMcpThroughProviderCli) {
56691
+ async function ensureAlanMcpRegistered(backendKind, registration, home = (0, import_node_os10.homedir)(), inspectCli = inspectAlanMcpThroughProviderCli) {
56585
56692
  try {
56586
56693
  const mcpServers = buildAlanMcpServers(registration);
56587
56694
  const files = alanMcpConfigFilesForBackend(backendKind, mcpServers, home);
56588
56695
  const paths = [];
56589
56696
  for (const file2 of files) {
56590
- (0, import_node_fs16.mkdirSync)((0, import_node_path14.dirname)(file2.path), { recursive: true });
56697
+ (0, import_node_fs17.mkdirSync)((0, import_node_path15.dirname)(file2.path), { recursive: true });
56591
56698
  const releaseLock = await waitForConfigLock(`${file2.path}.alan-lock`);
56592
56699
  try {
56593
- const current = (0, import_node_fs16.existsSync)(file2.path) ? (0, import_node_fs16.readFileSync)(file2.path, "utf8") : null;
56700
+ const current = (0, import_node_fs17.existsSync)(file2.path) ? (0, import_node_fs17.readFileSync)(file2.path, "utf8") : null;
56594
56701
  const content = file2.path.endsWith(".toml") ? mergeCodexAlanSection(file2.path, current, file2.content) : mergeJsonConfig(file2.path, current, file2.content);
56595
56702
  if (current !== content) atomicWriteManagedConfig(file2.path, content);
56596
56703
  paths.push(file2.path);
@@ -56652,7 +56759,7 @@ async function ensureAlanMcpRegistered(backendKind, registration, home = (0, imp
56652
56759
  return { ok: false, paths: [], error: err instanceof Error ? err.message : String(err) };
56653
56760
  }
56654
56761
  }
56655
- async function restoreStaticAlanMcp(backendKind, apiUrl, home = (0, import_node_os9.homedir)()) {
56762
+ async function restoreStaticAlanMcp(backendKind, apiUrl, home = (0, import_node_os10.homedir)()) {
56656
56763
  let url3;
56657
56764
  try {
56658
56765
  url3 = new URL("/mcp", apiUrl).toString();
@@ -56668,13 +56775,13 @@ async function restoreStaticAlanMcp(backendKind, apiUrl, home = (0, import_node_
56668
56775
  verification: { method: "file" }
56669
56776
  }));
56670
56777
  }
56671
- async function verifyAlanMcpRegistered(backendKind, home = (0, import_node_os9.homedir)(), inspectCli = inspectAlanMcpThroughProviderCli) {
56778
+ async function verifyAlanMcpRegistered(backendKind, home = (0, import_node_os10.homedir)(), inspectCli = inspectAlanMcpThroughProviderCli) {
56672
56779
  const files = alanMcpConfigFilesForBackend(backendKind, {}, home);
56673
- const missing = files.map((f) => f.path).filter((p) => !(0, import_node_fs16.existsSync)(p));
56780
+ const missing = files.map((f) => f.path).filter((p) => !(0, import_node_fs17.existsSync)(p));
56674
56781
  const presentEntries = files.map((file2) => ({
56675
56782
  path: file2.path,
56676
- registration: (0, import_node_fs16.existsSync)(file2.path) ? readAlanMcpRegistration(file2.path) : null
56677
- })).filter((entry) => (0, import_node_fs16.existsSync)(entry.path));
56783
+ registration: (0, import_node_fs17.existsSync)(file2.path) ? readAlanMcpRegistration(file2.path) : null
56784
+ })).filter((entry) => (0, import_node_fs17.existsSync)(entry.path));
56678
56785
  let invalid = presentEntries.filter(
56679
56786
  (entry) => !entry.registration || !hasUsableRegistrationCredential(entry.registration.headers)
56680
56787
  ).map((entry) => entry.path);
@@ -56775,7 +56882,7 @@ function hasUsableRegistrationCredential(headers) {
56775
56882
  return Boolean(normalized.get("x-alan-run-reference") || normalized.get("authorization"));
56776
56883
  }
56777
56884
  function readAlanMcpRegistration(path2) {
56778
- return parseAlanMcpRegistration(path2, (0, import_node_fs16.readFileSync)(path2, "utf8"));
56885
+ return parseAlanMcpRegistration(path2, (0, import_node_fs17.readFileSync)(path2, "utf8"));
56779
56886
  }
56780
56887
  function parseAlanMcpRegistration(path2, content) {
56781
56888
  if (path2.endsWith(".toml")) {
@@ -56985,7 +57092,7 @@ var CoreAgent = class _CoreAgent extends BaseMachineAgent {
56985
57092
  if (backendKind === "antigravity_cli" && augmented.GEMINI_API_KEY?.trim()) {
56986
57093
  await configureAntigravityApiKeyMode(augmented.HOME ?? augmented.USERPROFILE);
56987
57094
  }
56988
- if ((0, import_node_os10.platform)() !== "win32") {
57095
+ if ((0, import_node_os11.platform)() !== "win32") {
56989
57096
  const home = augmented.HOME ?? "/home/user";
56990
57097
  const extraPaths = [`${home}/.local/node/bin`, `${home}/.local/bin`];
56991
57098
  const separator = ":";
@@ -73874,90 +73981,6 @@ async function prepareAlanMcpForRun(backendKind, registration, options = {}) {
73874
73981
  return { ...probed, providerLoadStatus: registered.providerLoadStatus };
73875
73982
  }
73876
73983
 
73877
- // src/provider-startup-isolation.ts
73878
- var import_node_fs17 = require("fs");
73879
- var import_node_os11 = require("os");
73880
- var import_node_path15 = require("path");
73881
- function resolveProviderStartupIsolation(backendKind, runtimePlatform = (0, import_node_os11.platform)()) {
73882
- switch (backendKind) {
73883
- case "claude_cli":
73884
- if (runtimePlatform === "darwin") {
73885
- return { mode: "shared_config", lockKey: "claude_cli" };
73886
- }
73887
- return {
73888
- mode: "run_scoped_home",
73889
- envForRunRoot: (runRoot) => ({
73890
- HOME: runRoot,
73891
- USERPROFILE: runRoot
73892
- }),
73893
- // Auth + session state live under ~/.claude; MCP is ~/.claude.json in the run root.
73894
- hostStateLinks: [".claude"]
73895
- };
73896
- case "supatest_cli":
73897
- return {
73898
- mode: "run_scoped_home",
73899
- envForRunRoot: (runRoot) => ({
73900
- HOME: runRoot,
73901
- USERPROFILE: runRoot
73902
- }),
73903
- // Auth + session state live under ~/.claude; MCP is ~/.claude.json in the run root.
73904
- hostStateLinks: [".claude"]
73905
- };
73906
- case "codex_app_server":
73907
- return {
73908
- mode: "run_scoped_home",
73909
- envForRunRoot: (runRoot) => ({
73910
- CODEX_HOME: (0, import_node_path15.join)(runRoot, ".codex")
73911
- }),
73912
- // Auth tokens stay in the host Codex home; only config.toml is run-scoped.
73913
- hostStateLinks: [".codex/auth.json", ".codex/.credentials.json"]
73914
- };
73915
- case "opencode_cli":
73916
- case "opencode_serve":
73917
- return {
73918
- mode: "run_scoped_home",
73919
- envForRunRoot: (runRoot) => ({
73920
- HOME: runRoot,
73921
- USERPROFILE: runRoot,
73922
- XDG_CONFIG_HOME: (0, import_node_path15.join)(runRoot, ".config")
73923
- }),
73924
- hostStateLinks: []
73925
- };
73926
- default: {
73927
- const key = backendKind?.trim() || "unknown";
73928
- return { mode: "shared_config", lockKey: key };
73929
- }
73930
- }
73931
- }
73932
- function runScopedHomePath(runId, baseDir = (0, import_node_os11.tmpdir)()) {
73933
- return (0, import_node_path15.join)(baseDir, "alan-runs", runId);
73934
- }
73935
- function prepareRunScopedProviderHome(input2) {
73936
- const hostHome = input2.hostHome ?? (0, import_node_os11.homedir)();
73937
- const runRoot = runScopedHomePath(input2.runId, input2.baseDir);
73938
- (0, import_node_fs17.mkdirSync)(runRoot, { recursive: true, mode: 448 });
73939
- for (const relative6 of input2.isolation.hostStateLinks) {
73940
- const hostPath = (0, import_node_path15.join)(hostHome, relative6);
73941
- const linkPath = (0, import_node_path15.join)(runRoot, relative6);
73942
- if (!(0, import_node_fs17.existsSync)(hostPath)) continue;
73943
- (0, import_node_fs17.mkdirSync)((0, import_node_path15.dirname)(linkPath), { recursive: true, mode: 448 });
73944
- if ((0, import_node_fs17.existsSync)(linkPath)) continue;
73945
- try {
73946
- const hostStat = (0, import_node_fs17.lstatSync)(hostPath);
73947
- (0, import_node_fs17.symlinkSync)(hostPath, linkPath, hostStat.isDirectory() ? "dir" : "file");
73948
- } catch {
73949
- }
73950
- }
73951
- return {
73952
- runRoot,
73953
- mcpHome: runRoot,
73954
- env: input2.isolation.envForRunRoot(runRoot),
73955
- cleanup: () => {
73956
- (0, import_node_fs17.rmSync)(runRoot, { recursive: true, force: true });
73957
- }
73958
- };
73959
- }
73960
-
73961
73984
  // src/run-start-gate.ts
73962
73985
  var DEFAULT_STARTUP_CONFIG_LOCK_TIMEOUT_MS = 5e3;
73963
73986
  function startupConfigLockTimeoutMs() {
@@ -74636,7 +74659,16 @@ async function handleAgentExecute(ctx, payload) {
74636
74659
  runtimeCommand = revalidateBackendRuntimeCommand(backendKind);
74637
74660
  }
74638
74661
  if (!runtimeCommand && backendKind && canInstallProviderCli(backendKind)) {
74639
- pendingRunStarts.set(payload.runId, payload.conversationId);
74662
+ try {
74663
+ pendingRunStarts.set(payload.runId, payload.conversationId);
74664
+ } catch (error61) {
74665
+ socket.emit("agent.rejected", {
74666
+ runId: payload.runId,
74667
+ message: `Unable to reserve local runtime capacity: ${error61 instanceof Error ? error61.message : String(error61)}`,
74668
+ code: "runner_reservation_failed"
74669
+ });
74670
+ return;
74671
+ }
74640
74672
  try {
74641
74673
  const installed = await ensureProviderCliInstalled(backendKind, {
74642
74674
  notify: (message) => {
@@ -74777,7 +74809,16 @@ async function handleAgentExecute(ctx, payload) {
74777
74809
  });
74778
74810
  return;
74779
74811
  }
74780
- pendingRunStarts.set(payload.runId, payload.conversationId);
74812
+ try {
74813
+ pendingRunStarts.set(payload.runId, payload.conversationId);
74814
+ } catch (error61) {
74815
+ socket.emit("agent.rejected", {
74816
+ runId: payload.runId,
74817
+ message: `Unable to reserve local runtime capacity: ${error61 instanceof Error ? error61.message : String(error61)}`,
74818
+ code: "runner_reservation_failed"
74819
+ });
74820
+ return;
74821
+ }
74781
74822
  publishCapacityChange();
74782
74823
  const releaseCapacity = () => {
74783
74824
  if (!pendingRunStarts.delete(payload.runId)) return;
@@ -76969,7 +77010,7 @@ var LocalSkillSource = class {
76969
77010
  try {
76970
77011
  entries = await (0, import_promises2.readdir)(resolvedRoot.directory, { withFileTypes: true });
76971
77012
  } catch (error61) {
76972
- if (isMissingPath(error61)) return { candidates: [], diagnostics: [], incomplete: false };
77013
+ if (isAbsentDirectory(error61)) return { candidates: [], diagnostics: [], incomplete: false };
76973
77014
  return {
76974
77015
  candidates: [],
76975
77016
  diagnostics: [
@@ -77305,8 +77346,8 @@ async function isDirectory(path2) {
77305
77346
  return false;
77306
77347
  }
77307
77348
  }
77308
- function isMissingPath(error61) {
77309
- return typeof error61 === "object" && error61 !== null && "code" in error61 && error61.code === "ENOENT";
77349
+ function isAbsentDirectory(error61) {
77350
+ return typeof error61 === "object" && error61 !== null && "code" in error61 && ["ENOENT", "ENOTDIR"].includes(String(error61.code));
77310
77351
  }
77311
77352
  function isAlreadyPresent(error61) {
77312
77353
  return typeof error61 === "object" && error61 !== null && "code" in error61 && error61.code === "EEXIST";
@@ -77499,7 +77540,7 @@ var ManagedSkillStore = class _ManagedSkillStore {
77499
77540
  const parsed = JSON.parse(await (0, import_promises3.readFile)((0, import_node_path22.join)(baseDirectory, "state.json"), "utf8"));
77500
77541
  return new _ManagedSkillStore(baseDirectory, parseState(parsed), "verified");
77501
77542
  } catch (error61) {
77502
- if (isMissingPath2(error61)) {
77543
+ if (isMissingPath(error61)) {
77503
77544
  return new _ManagedSkillStore(baseDirectory, EMPTY_STATE, "verified");
77504
77545
  }
77505
77546
  return new _ManagedSkillStore(baseDirectory, EMPTY_STATE, "rebuilt");
@@ -77621,7 +77662,7 @@ function isSha256(value2) {
77621
77662
  function isRecord5(value2) {
77622
77663
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
77623
77664
  }
77624
- function isMissingPath2(error61) {
77665
+ function isMissingPath(error61) {
77625
77666
  return typeof error61 === "object" && error61 !== null && "code" in error61 && error61.code === "ENOENT";
77626
77667
  }
77627
77668
 
@@ -78688,7 +78729,7 @@ async function pathExists2(path2) {
78688
78729
  await (0, import_promises5.lstat)(path2);
78689
78730
  return true;
78690
78731
  } catch (error61) {
78691
- if (isMissingPath3(error61)) return false;
78732
+ if (isMissingPath2(error61)) return false;
78692
78733
  throw error61;
78693
78734
  }
78694
78735
  }
@@ -78714,7 +78755,7 @@ function errorCode(error61) {
78714
78755
  }
78715
78756
  return "SKILL_RECONCILE_FAILED";
78716
78757
  }
78717
- function isMissingPath3(error61) {
78758
+ function isMissingPath2(error61) {
78718
78759
  return typeof error61 === "object" && error61 !== null && "code" in error61 && error61.code === "ENOENT";
78719
78760
  }
78720
78761
  function isAlreadyPresent2(error61) {
@@ -78786,7 +78827,7 @@ async function startDaemon(args) {
78786
78827
  const runtimeId = argValue(args, "--runtime-id") ?? process.env.ALAN_RUNTIME_ID ?? stored.runtimeId;
78787
78828
  const runtimeTokenOverride = argValue(args, "--token") ?? process.env.ALAN_RUNTIME_TOKEN;
78788
78829
  let runtimeToken = runtimeTokenOverride ?? stored.runtimeToken;
78789
- const runtimeRenewalToken = runtimeTokenOverride ? void 0 : stored.runtimeRenewalToken;
78830
+ let runtimeRenewalToken = runtimeTokenOverride ? void 0 : stored.runtimeRenewalToken;
78790
78831
  const wsUrlOverride = argValue(args, "--ws-url") ?? process.env.ALAN_WS_URL;
78791
78832
  const endpointMismatch = wsUrlOverride ? null : checkStoredEndpointConsistency(stored, readEndpointDefaults());
78792
78833
  let wsUrl = wsUrlOverride ?? stored.wsUrl;
@@ -78920,6 +78961,24 @@ async function startDaemon(args) {
78920
78961
  let disconnectedSinceMs = null;
78921
78962
  let lastConnectError = null;
78922
78963
  let lastConnectErrorCode = null;
78964
+ const TERMINAL_RUNTIME_AUTH_CODES = /* @__PURE__ */ new Set([
78965
+ "invalid_runtime_token",
78966
+ "runtime_renewal_rejected",
78967
+ "runtime_deleted",
78968
+ "runtime_disabled"
78969
+ ]);
78970
+ let terminalAuthFailureCode = null;
78971
+ const rememberConnectErrorCode = (code) => {
78972
+ if (code && TERMINAL_RUNTIME_AUTH_CODES.has(code)) {
78973
+ terminalAuthFailureCode = code;
78974
+ }
78975
+ lastConnectErrorCode = terminalAuthFailureCode ?? code;
78976
+ };
78977
+ const clearConnectErrors = () => {
78978
+ lastConnectError = null;
78979
+ lastConnectErrorCode = null;
78980
+ terminalAuthFailureCode = null;
78981
+ };
78923
78982
  const pendingDeliveryLost = [];
78924
78983
  const currentCapabilities = () => discoverCapabilities();
78925
78984
  const currentMetadata = async () => ({
@@ -79135,7 +79194,29 @@ async function startDaemon(args) {
79135
79194
  const renewRuntimeLease = () => {
79136
79195
  if (runtimeRenewalInFlight) return runtimeRenewalInFlight;
79137
79196
  const attempt = (async () => {
79138
- if (!stored.apiUrl || !runtimeRenewalToken) return false;
79197
+ const adoptRewrittenCredentials = () => {
79198
+ const current2 = readConfig();
79199
+ if (current2.runtimeId !== runtimeId) return false;
79200
+ const nextToken = current2.runtimeToken;
79201
+ const nextRenewal = current2.runtimeRenewalToken;
79202
+ if (typeof nextToken !== "string" || !nextToken.startsWith("alan_runtime_") || typeof nextRenewal !== "string" || !nextRenewal.startsWith("alan_runtime_renew_")) {
79203
+ return false;
79204
+ }
79205
+ if (nextToken === runtimeToken && nextRenewal === runtimeRenewalToken) {
79206
+ return false;
79207
+ }
79208
+ runtimeToken = nextToken;
79209
+ runtimeRenewalToken = nextRenewal;
79210
+ socket.auth = { token: nextToken };
79211
+ clearConnectErrors();
79212
+ pushLog("runtime-credentials-reloaded-from-config");
79213
+ socket.connect();
79214
+ return true;
79215
+ };
79216
+ if (!stored.apiUrl || !runtimeRenewalToken) {
79217
+ if (adoptRewrittenCredentials()) return true;
79218
+ return false;
79219
+ }
79139
79220
  let response = null;
79140
79221
  let transportError = null;
79141
79222
  for (let retry = 1; retry <= 3; retry += 1) {
@@ -79159,27 +79240,32 @@ async function startDaemon(args) {
79159
79240
  await sleep(retry * 250);
79160
79241
  }
79161
79242
  if (!response) {
79162
- lastConnectErrorCode = "backend_unreachable";
79243
+ rememberConnectErrorCode("backend_unreachable");
79163
79244
  lastConnectError = `Runtime renewal could not reach Alan: ${transportError instanceof Error ? transportError.message : String(transportError)}`;
79164
79245
  pushLog(`runtime-renewal-transport-failed ${lastConnectError}`);
79165
79246
  return false;
79166
79247
  }
79167
79248
  if (!response.ok) {
79168
- lastConnectErrorCode = response.status === 401 ? "runtime_renewal_rejected" : response.status === 403 ? "runtime_disabled" : response.status === 410 ? "runtime_deleted" : response.status >= 500 ? "backend_unreachable" : "runtime_renewal_failed";
79249
+ if (response.status === 401 && adoptRewrittenCredentials()) {
79250
+ return true;
79251
+ }
79252
+ const code = response.status === 401 ? "runtime_renewal_rejected" : response.status === 403 ? "runtime_disabled" : response.status === 410 ? "runtime_deleted" : response.status >= 500 ? "backend_unreachable" : "runtime_renewal_failed";
79253
+ rememberConnectErrorCode(code);
79169
79254
  lastConnectError = `Runtime renewal failed: ${response.status} ${await response.text()}`;
79170
79255
  pushLog(`runtime-renewal-rejected ${lastConnectError}`);
79171
79256
  return false;
79172
79257
  }
79173
79258
  const body = await response.json();
79174
79259
  if (typeof body.runtimeToken !== "string" || !body.runtimeToken.startsWith("alan_runtime_")) {
79175
- lastConnectErrorCode = "runtime_renewal_failed";
79260
+ rememberConnectErrorCode("runtime_renewal_failed");
79176
79261
  lastConnectError = "Runtime renewal returned an invalid access token";
79177
79262
  pushLog("runtime-renewal-invalid-response");
79178
79263
  return false;
79179
79264
  }
79180
79265
  const current = readConfig();
79181
79266
  if (current.runtimeId !== runtimeId || current.runtimeRenewalToken !== runtimeRenewalToken) {
79182
- lastConnectErrorCode = "runtime_renewal_superseded";
79267
+ if (adoptRewrittenCredentials()) return true;
79268
+ rememberConnectErrorCode("runtime_renewal_superseded");
79183
79269
  lastConnectError = "Runtime credentials changed while renewal was in progress";
79184
79270
  pushLog("runtime-renewal-superseded");
79185
79271
  return false;
@@ -79187,15 +79273,14 @@ async function startDaemon(args) {
79187
79273
  try {
79188
79274
  writeConfig({ ...current, runtimeToken: body.runtimeToken });
79189
79275
  } catch (error61) {
79190
- lastConnectErrorCode = "config_write_failed";
79276
+ rememberConnectErrorCode("config_write_failed");
79191
79277
  lastConnectError = `Runtime renewal could not save its replacement: ${error61.message}`;
79192
79278
  pushLog(`runtime-renewal-config-write-failed ${error61.message}`);
79193
79279
  return false;
79194
79280
  }
79195
79281
  runtimeToken = body.runtimeToken;
79196
79282
  socket.auth = { token: body.runtimeToken };
79197
- lastConnectError = null;
79198
- lastConnectErrorCode = null;
79283
+ clearConnectErrors();
79199
79284
  pushLog("runtime-renewal-succeeded");
79200
79285
  socket.connect();
79201
79286
  return true;
@@ -79346,8 +79431,7 @@ async function startDaemon(args) {
79346
79431
  workspaceLeaseMonitor.unref?.();
79347
79432
  socket.on("connect", () => {
79348
79433
  disconnectedSinceMs = null;
79349
- lastConnectError = null;
79350
- lastConnectErrorCode = null;
79434
+ clearConnectErrors();
79351
79435
  setConnectedRuntimeSocket(socket);
79352
79436
  pushLog(`connected runtime=${runtimeId}`);
79353
79437
  console.info("[alan-agent] Daemon connected", { runtimeId, wsUrl, version: AGENT_VERSION });
@@ -79395,13 +79479,15 @@ async function startDaemon(args) {
79395
79479
  if (!socket.connected && disconnectedSinceMs === null) disconnectedSinceMs = Date.now();
79396
79480
  lastConnectError = error61.message;
79397
79481
  const errorCode2 = error61?.data?.code;
79398
- lastConnectErrorCode = typeof errorCode2 === "string" ? errorCode2 : classifyTransportFailure(error61);
79482
+ rememberConnectErrorCode(
79483
+ typeof errorCode2 === "string" ? errorCode2 : classifyTransportFailure(error61)
79484
+ );
79399
79485
  pushLog(
79400
79486
  `connect_error ${error61.message}${lastConnectErrorCode ? ` code=${lastConnectErrorCode}` : ""}`
79401
79487
  );
79402
- if (lastConnectErrorCode === "invalid_runtime_token" && runtimeRenewalToken) {
79488
+ if ((lastConnectErrorCode === "invalid_runtime_token" || terminalAuthFailureCode === "invalid_runtime_token") && runtimeRenewalToken) {
79403
79489
  void renewRuntimeLease().catch((renewalError) => {
79404
- lastConnectErrorCode = "runtime_renewal_failed";
79490
+ rememberConnectErrorCode("runtime_renewal_failed");
79405
79491
  lastConnectError = `Runtime renewal failed unexpectedly: ${renewalError.message}`;
79406
79492
  pushLog(`runtime-renewal-unexpected-failure ${renewalError.message}`);
79407
79493
  });
@@ -79620,7 +79706,11 @@ async function startDaemon(args) {
79620
79706
  lastConnectError = v;
79621
79707
  },
79622
79708
  setLastConnectErrorCode: (v) => {
79623
- lastConnectErrorCode = v;
79709
+ if (v === null) {
79710
+ lastConnectErrorCode = terminalAuthFailureCode;
79711
+ return;
79712
+ }
79713
+ rememberConnectErrorCode(v);
79624
79714
  },
79625
79715
  workspaceAccessTracker,
79626
79716
  recentLogs,
@@ -79722,6 +79812,7 @@ async function startDaemon(args) {
79722
79812
  const stop = async () => {
79723
79813
  if (stopped) return;
79724
79814
  stopped = true;
79815
+ let providersExited = true;
79725
79816
  try {
79726
79817
  clearInterval(heartbeat);
79727
79818
  clearInterval(versionRefresh);
@@ -79730,9 +79821,16 @@ async function startDaemon(args) {
79730
79821
  clearInterval(skillAuditInterval);
79731
79822
  clearInterval(nativeHookDrainInterval);
79732
79823
  suspensionDetector.stop();
79733
- for (const entry of activeAgents.values()) {
79824
+ const stoppingEntries = [...activeAgents.values()];
79825
+ for (const entry of stoppingEntries) {
79734
79826
  abortActiveAgent(entry, { reason: "runtime_shutdown" });
79735
79827
  }
79828
+ const providerPids = stoppingEntries.map((entry) => entry.providerPid).filter((pid) => pid !== null && pid > 0 && pid !== process.pid);
79829
+ const gracefulDeadline = Date.now() + 250;
79830
+ while (providerPids.some((pid) => isProviderProcessAlive(pid)) && Date.now() < gracefulDeadline) {
79831
+ await new Promise((resolve15) => setTimeout(resolve15, 25));
79832
+ }
79833
+ providersExited = providerPids.every((pid) => !isProviderProcessAlive(pid));
79736
79834
  activeAgents.clear();
79737
79835
  socket.disconnect();
79738
79836
  await new Promise((resolve15) => {
@@ -79740,7 +79838,7 @@ async function startDaemon(args) {
79740
79838
  });
79741
79839
  } finally {
79742
79840
  sleepInhibitor.dispose();
79743
- releaseOwnerLease();
79841
+ if (providersExited) releaseOwnerLease();
79744
79842
  }
79745
79843
  };
79746
79844
  const controller = {
@@ -81231,7 +81329,7 @@ function nativeHookCommand(input2) {
81231
81329
  timeout: 5
81232
81330
  };
81233
81331
  }
81234
- function nativeShellCommand(runtime, provider, event, platform7 = runtime.platform) {
81332
+ function nativeShellCommand(runtime, provider, event, platform6 = runtime.platform) {
81235
81333
  const args = hookArgs({
81236
81334
  configPath: runtime.configPath,
81237
81335
  cliEntry: runtime.cliEntry,
@@ -81239,7 +81337,7 @@ function nativeShellCommand(runtime, provider, event, platform7 = runtime.platfo
81239
81337
  event
81240
81338
  });
81241
81339
  const environment = checkedEnvironment(runtime.environment);
81242
- if (platform7 === "win32") {
81340
+ if (platform6 === "win32") {
81243
81341
  const prefix2 = environment.map(([key, value2]) => `$env:${key}=${powershellQuote(value2)}`).join("; ");
81244
81342
  const command2 = `& ${[runtime.nodeExecutable, ...args].map(powershellQuote).join(" ")}`;
81245
81343
  return prefix2 ? `${prefix2}; ${command2}` : command2;
@@ -82273,10 +82371,12 @@ function enqueueNativeHookFromConfig(input2) {
82273
82371
  function runNativeHookCommand(args) {
82274
82372
  try {
82275
82373
  const payload = readBoundedHookPayload();
82276
- const enqueued = enqueueNativeHookFromConfig({ args, payload });
82374
+ bindConfigPath(args);
82375
+ const config2 = readConfig();
82376
+ const enqueued = enqueueNativeHookFromConfig({ args, payload, config: config2 });
82277
82377
  const hookEvent = argumentValue(args, "--event");
82278
82378
  const normalizedEvent = normalizeHookEvent(hookEvent ?? "notification");
82279
- if (enqueued && (normalizedEvent === "user_prompt" || normalizedEvent === "session_start")) {
82379
+ if (enqueued && isNativeTaskLinkingEnabled(config2) && (normalizedEvent === "user_prompt" || normalizedEvent === "session_start")) {
82280
82380
  const providerKind = argumentValue(args, "--provider");
82281
82381
  const externalSessionId = stringField4(
82282
82382
  payload,
@@ -84178,10 +84278,12 @@ WantedBy=default.target
84178
84278
  environmentPrefix ? `-NoProfile -NonInteractive -WindowStyle Hidden -Command "${environmentPrefix}; & ${powershellLiteral(input2.nodeExecutable)} ${powershellLiteral(input2.cliEntry)} daemon --profile ${input2.profile}"` : directArgument
84179
84279
  );
84180
84280
  const registerScript = [
84281
+ "$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name",
84181
84282
  `$action = New-ScheduledTaskAction -Execute ${executable} -Argument ${argument}`,
84182
- "$trigger = New-ScheduledTaskTrigger -AtLogOn",
84283
+ "$trigger = New-ScheduledTaskTrigger -AtLogOn -User $currentUser",
84284
+ "$principal = New-ScheduledTaskPrincipal -UserId $currentUser -LogonType Interactive -RunLevel Limited",
84183
84285
  "$settings = New-ScheduledTaskSettingsSet -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1) -ExecutionTimeLimit ([TimeSpan]::Zero)",
84184
- `Register-ScheduledTask -TaskName ${powershellLiteral(WINDOWS_TASK)} -Action $action -Trigger $trigger -Settings $settings -Force | Out-Null`
84286
+ `Register-ScheduledTask -TaskName ${powershellLiteral(WINDOWS_TASK)} -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force | Out-Null`
84185
84287
  ].join("; ");
84186
84288
  return {
84187
84289
  platform: "win32",
@@ -84319,8 +84421,14 @@ function defaultSleep(ms) {
84319
84421
  });
84320
84422
  }
84321
84423
  function parseServiceHostState(servicePlatform, result) {
84322
- if (result.status !== 0) return "unknown";
84323
84424
  const output2 = result.output;
84425
+ if (servicePlatform === "linux") {
84426
+ const trimmed = output2.trim().toLowerCase();
84427
+ if (trimmed === "inactive" || trimmed === "failed" || trimmed === "dead" || /\binactive\b/i.test(output2) || /\bfailed\b/i.test(output2)) {
84428
+ return "stopped";
84429
+ }
84430
+ }
84431
+ if (result.status !== 0) return "unknown";
84324
84432
  if (servicePlatform === "darwin") {
84325
84433
  if (/\bstate\s*=\s*running\b/i.test(output2)) return "running";
84326
84434
  if (/\bstate\s*=\s*(not running|waiting|stopped)\b/i.test(output2)) return "stopped";
@@ -84332,9 +84440,6 @@ function parseServiceHostState(servicePlatform, result) {
84332
84440
  const trimmed = output2.trim().toLowerCase();
84333
84441
  if (trimmed === "active" || /\bactive\s*\(running\)/i.test(output2)) return "running";
84334
84442
  if (trimmed === "activating" || trimmed === "reloading") return "starting";
84335
- if (trimmed === "inactive" || trimmed === "failed" || trimmed === "dead" || /\binactive\b/i.test(output2) || /\bfailed\b/i.test(output2)) {
84336
- return "stopped";
84337
- }
84338
84443
  return "unknown";
84339
84444
  }
84340
84445
  const stateMatch = output2.match(/\b(?:State|state)\s*[:=]\s*(\w+)/);