@alan-ai-hq/agent-manager 0.1.80 → 0.1.82

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/index.cjs +436 -499
  2. package/package.json +1 -1
  3. package/dist/__tests__/binding-switch-git.test.d.ts +0 -2
  4. package/dist/__tests__/binding-switch-git.test.d.ts.map +0 -1
  5. package/dist/__tests__/binding-switch-git.test.js +0 -610
  6. package/dist/__tests__/binding-switch-git.test.js.map +0 -1
  7. package/dist/__tests__/cli-ensure-install.test.d.ts +0 -2
  8. package/dist/__tests__/cli-ensure-install.test.d.ts.map +0 -1
  9. package/dist/__tests__/cli-ensure-install.test.js +0 -109
  10. package/dist/__tests__/cli-ensure-install.test.js.map +0 -1
  11. package/dist/__tests__/cli-executable.test.d.ts +0 -2
  12. package/dist/__tests__/cli-executable.test.d.ts.map +0 -1
  13. package/dist/__tests__/cli-executable.test.js +0 -129
  14. package/dist/__tests__/cli-executable.test.js.map +0 -1
  15. package/dist/__tests__/cli-help.test.d.ts +0 -2
  16. package/dist/__tests__/cli-help.test.d.ts.map +0 -1
  17. package/dist/__tests__/cli-help.test.js +0 -34
  18. package/dist/__tests__/cli-help.test.js.map +0 -1
  19. package/dist/__tests__/computer-readiness.test.d.ts +0 -2
  20. package/dist/__tests__/computer-readiness.test.d.ts.map +0 -1
  21. package/dist/__tests__/computer-readiness.test.js +0 -63
  22. package/dist/__tests__/computer-readiness.test.js.map +0 -1
  23. package/dist/__tests__/core-agent-workflow-context.test.d.ts +0 -2
  24. package/dist/__tests__/core-agent-workflow-context.test.d.ts.map +0 -1
  25. package/dist/__tests__/core-agent-workflow-context.test.js +0 -139
  26. package/dist/__tests__/core-agent-workflow-context.test.js.map +0 -1
  27. package/dist/__tests__/daemon-reconcile-ask.test.d.ts +0 -2
  28. package/dist/__tests__/daemon-reconcile-ask.test.d.ts.map +0 -1
  29. package/dist/__tests__/daemon-reconcile-ask.test.js +0 -86
  30. package/dist/__tests__/daemon-reconcile-ask.test.js.map +0 -1
  31. package/dist/__tests__/daemon-socket.integration.test.d.ts +0 -2
  32. package/dist/__tests__/daemon-socket.integration.test.d.ts.map +0 -1
  33. package/dist/__tests__/daemon-socket.integration.test.js +0 -450
  34. package/dist/__tests__/daemon-socket.integration.test.js.map +0 -1
  35. package/dist/__tests__/daemon.test.d.ts +0 -2
  36. package/dist/__tests__/daemon.test.d.ts.map +0 -1
  37. package/dist/__tests__/daemon.test.js +0 -3975
  38. package/dist/__tests__/daemon.test.js.map +0 -1
  39. package/dist/__tests__/ensure-shared-checkout-branch.test.d.ts +0 -2
  40. package/dist/__tests__/ensure-shared-checkout-branch.test.d.ts.map +0 -1
  41. package/dist/__tests__/ensure-shared-checkout-branch.test.js +0 -129
  42. package/dist/__tests__/ensure-shared-checkout-branch.test.js.map +0 -1
  43. package/dist/__tests__/event-outbox-persist-failure.test.d.ts +0 -2
  44. package/dist/__tests__/event-outbox-persist-failure.test.d.ts.map +0 -1
  45. package/dist/__tests__/event-outbox-persist-failure.test.js +0 -84
  46. package/dist/__tests__/event-outbox-persist-failure.test.js.map +0 -1
  47. package/dist/__tests__/event-outbox.test.d.ts +0 -2
  48. package/dist/__tests__/event-outbox.test.d.ts.map +0 -1
  49. package/dist/__tests__/event-outbox.test.js +0 -256
  50. package/dist/__tests__/event-outbox.test.js.map +0 -1
  51. package/dist/__tests__/fake-provider-cli.test.d.ts +0 -2
  52. package/dist/__tests__/fake-provider-cli.test.d.ts.map +0 -1
  53. package/dist/__tests__/fake-provider-cli.test.js +0 -46
  54. package/dist/__tests__/fake-provider-cli.test.js.map +0 -1
  55. package/dist/__tests__/generated-images.test.d.ts +0 -2
  56. package/dist/__tests__/generated-images.test.d.ts.map +0 -1
  57. package/dist/__tests__/generated-images.test.js +0 -132
  58. package/dist/__tests__/generated-images.test.js.map +0 -1
  59. package/dist/__tests__/lifecycle-logger.test.d.ts +0 -2
  60. package/dist/__tests__/lifecycle-logger.test.d.ts.map +0 -1
  61. package/dist/__tests__/lifecycle-logger.test.js +0 -49
  62. package/dist/__tests__/lifecycle-logger.test.js.map +0 -1
  63. package/dist/__tests__/local-skill-scan.test.d.ts +0 -2
  64. package/dist/__tests__/local-skill-scan.test.d.ts.map +0 -1
  65. package/dist/__tests__/local-skill-scan.test.js +0 -91
  66. package/dist/__tests__/local-skill-scan.test.js.map +0 -1
  67. package/dist/__tests__/local-workspace-migration.test.d.ts +0 -2
  68. package/dist/__tests__/local-workspace-migration.test.d.ts.map +0 -1
  69. package/dist/__tests__/local-workspace-migration.test.js +0 -195
  70. package/dist/__tests__/local-workspace-migration.test.js.map +0 -1
  71. package/dist/__tests__/mcp-inspect-timeout.test.d.ts +0 -2
  72. package/dist/__tests__/mcp-inspect-timeout.test.d.ts.map +0 -1
  73. package/dist/__tests__/mcp-inspect-timeout.test.js +0 -97
  74. package/dist/__tests__/mcp-inspect-timeout.test.js.map +0 -1
  75. package/dist/__tests__/mcp-readiness.test.d.ts +0 -2
  76. package/dist/__tests__/mcp-readiness.test.d.ts.map +0 -1
  77. package/dist/__tests__/mcp-readiness.test.js +0 -267
  78. package/dist/__tests__/mcp-readiness.test.js.map +0 -1
  79. package/dist/__tests__/mcp-registration-cli.test.d.ts +0 -2
  80. package/dist/__tests__/mcp-registration-cli.test.d.ts.map +0 -1
  81. package/dist/__tests__/mcp-registration-cli.test.js +0 -71
  82. package/dist/__tests__/mcp-registration-cli.test.js.map +0 -1
  83. package/dist/__tests__/mcp-registration.test.d.ts +0 -2
  84. package/dist/__tests__/mcp-registration.test.d.ts.map +0 -1
  85. package/dist/__tests__/mcp-registration.test.js +0 -426
  86. package/dist/__tests__/mcp-registration.test.js.map +0 -1
  87. package/dist/__tests__/model-scan-runner.test.d.ts +0 -2
  88. package/dist/__tests__/model-scan-runner.test.d.ts.map +0 -1
  89. package/dist/__tests__/model-scan-runner.test.js +0 -67
  90. package/dist/__tests__/model-scan-runner.test.js.map +0 -1
  91. package/dist/__tests__/network-diagnostics.test.d.ts +0 -2
  92. package/dist/__tests__/network-diagnostics.test.d.ts.map +0 -1
  93. package/dist/__tests__/network-diagnostics.test.js +0 -26
  94. package/dist/__tests__/network-diagnostics.test.js.map +0 -1
  95. package/dist/__tests__/observable-map.test.d.ts +0 -2
  96. package/dist/__tests__/observable-map.test.d.ts.map +0 -1
  97. package/dist/__tests__/observable-map.test.js +0 -54
  98. package/dist/__tests__/observable-map.test.js.map +0 -1
  99. package/dist/__tests__/provider-auth-preflight.test.d.ts +0 -2
  100. package/dist/__tests__/provider-auth-preflight.test.d.ts.map +0 -1
  101. package/dist/__tests__/provider-auth-preflight.test.js +0 -123
  102. package/dist/__tests__/provider-auth-preflight.test.js.map +0 -1
  103. package/dist/__tests__/provider-model-discovery.test.d.ts +0 -2
  104. package/dist/__tests__/provider-model-discovery.test.d.ts.map +0 -1
  105. package/dist/__tests__/provider-model-discovery.test.js +0 -472
  106. package/dist/__tests__/provider-model-discovery.test.js.map +0 -1
  107. package/dist/__tests__/remove-worktrees-if-clean.test.d.ts +0 -2
  108. package/dist/__tests__/remove-worktrees-if-clean.test.d.ts.map +0 -1
  109. package/dist/__tests__/remove-worktrees-if-clean.test.js +0 -221
  110. package/dist/__tests__/remove-worktrees-if-clean.test.js.map +0 -1
  111. package/dist/__tests__/resume-fallback-env.test.d.ts +0 -2
  112. package/dist/__tests__/resume-fallback-env.test.d.ts.map +0 -1
  113. package/dist/__tests__/resume-fallback-env.test.js +0 -28
  114. package/dist/__tests__/resume-fallback-env.test.js.map +0 -1
  115. package/dist/__tests__/run-journal.test.d.ts +0 -2
  116. package/dist/__tests__/run-journal.test.d.ts.map +0 -1
  117. package/dist/__tests__/run-journal.test.js +0 -121
  118. package/dist/__tests__/run-journal.test.js.map +0 -1
  119. package/dist/__tests__/run-start-gate.test.d.ts +0 -2
  120. package/dist/__tests__/run-start-gate.test.d.ts.map +0 -1
  121. package/dist/__tests__/run-start-gate.test.js +0 -29
  122. package/dist/__tests__/run-start-gate.test.js.map +0 -1
  123. package/dist/__tests__/runtime-capabilities-sync.test.d.ts +0 -2
  124. package/dist/__tests__/runtime-capabilities-sync.test.d.ts.map +0 -1
  125. package/dist/__tests__/runtime-capabilities-sync.test.js +0 -66
  126. package/dist/__tests__/runtime-capabilities-sync.test.js.map +0 -1
  127. package/dist/__tests__/runtime-config.test.d.ts +0 -2
  128. package/dist/__tests__/runtime-config.test.d.ts.map +0 -1
  129. package/dist/__tests__/runtime-config.test.js +0 -102
  130. package/dist/__tests__/runtime-config.test.js.map +0 -1
  131. package/dist/__tests__/runtime-presenter-heartbeat.test.d.ts +0 -2
  132. package/dist/__tests__/runtime-presenter-heartbeat.test.d.ts.map +0 -1
  133. package/dist/__tests__/runtime-presenter-heartbeat.test.js +0 -159
  134. package/dist/__tests__/runtime-presenter-heartbeat.test.js.map +0 -1
  135. package/dist/__tests__/sandbox-outbox.test.d.ts +0 -2
  136. package/dist/__tests__/sandbox-outbox.test.d.ts.map +0 -1
  137. package/dist/__tests__/sandbox-outbox.test.js +0 -214
  138. package/dist/__tests__/sandbox-outbox.test.js.map +0 -1
  139. package/dist/__tests__/sandbox-workflow-context.test.d.ts +0 -2
  140. package/dist/__tests__/sandbox-workflow-context.test.d.ts.map +0 -1
  141. package/dist/__tests__/sandbox-workflow-context.test.js +0 -396
  142. package/dist/__tests__/sandbox-workflow-context.test.js.map +0 -1
  143. package/dist/__tests__/service-manager.test.d.ts +0 -2
  144. package/dist/__tests__/service-manager.test.d.ts.map +0 -1
  145. package/dist/__tests__/service-manager.test.js +0 -50
  146. package/dist/__tests__/service-manager.test.js.map +0 -1
  147. package/dist/__tests__/sleep-inhibitor.test.d.ts +0 -2
  148. package/dist/__tests__/sleep-inhibitor.test.d.ts.map +0 -1
  149. package/dist/__tests__/sleep-inhibitor.test.js +0 -236
  150. package/dist/__tests__/sleep-inhibitor.test.js.map +0 -1
  151. package/dist/__tests__/status-local-workspace.test.d.ts +0 -2
  152. package/dist/__tests__/status-local-workspace.test.d.ts.map +0 -1
  153. package/dist/__tests__/status-local-workspace.test.js +0 -121
  154. package/dist/__tests__/status-local-workspace.test.js.map +0 -1
  155. package/dist/__tests__/suspension-detector.test.d.ts +0 -2
  156. package/dist/__tests__/suspension-detector.test.d.ts.map +0 -1
  157. package/dist/__tests__/suspension-detector.test.js +0 -112
  158. package/dist/__tests__/suspension-detector.test.js.map +0 -1
  159. package/dist/__tests__/web-presenter-parent-events.test.d.ts +0 -2
  160. package/dist/__tests__/web-presenter-parent-events.test.d.ts.map +0 -1
  161. package/dist/__tests__/web-presenter-parent-events.test.js +0 -130
  162. package/dist/__tests__/web-presenter-parent-events.test.js.map +0 -1
  163. package/dist/__tests__/workspace-relocation.test.d.ts +0 -2
  164. package/dist/__tests__/workspace-relocation.test.d.ts.map +0 -1
  165. package/dist/__tests__/workspace-relocation.test.js +0 -66
  166. package/dist/__tests__/workspace-relocation.test.js.map +0 -1
  167. package/dist/__tests__/workspace-run-lease.test.d.ts +0 -2
  168. package/dist/__tests__/workspace-run-lease.test.d.ts.map +0 -1
  169. package/dist/__tests__/workspace-run-lease.test.js +0 -230
  170. package/dist/__tests__/workspace-run-lease.test.js.map +0 -1
  171. package/dist/__tests__/ws-client-heartbeat-volatile.test.d.ts +0 -2
  172. package/dist/__tests__/ws-client-heartbeat-volatile.test.d.ts.map +0 -1
  173. package/dist/__tests__/ws-client-heartbeat-volatile.test.js +0 -61
  174. package/dist/__tests__/ws-client-heartbeat-volatile.test.js.map +0 -1
  175. package/dist/__tests__/ws-client-heartbeat.integration.test.d.ts +0 -2
  176. package/dist/__tests__/ws-client-heartbeat.integration.test.d.ts.map +0 -1
  177. package/dist/__tests__/ws-client-heartbeat.integration.test.js +0 -109
  178. package/dist/__tests__/ws-client-heartbeat.integration.test.js.map +0 -1
  179. package/dist/__tests__/ws-client-user-message-ack.integration.test.d.ts +0 -2
  180. package/dist/__tests__/ws-client-user-message-ack.integration.test.d.ts.map +0 -1
  181. package/dist/__tests__/ws-client-user-message-ack.integration.test.js +0 -167
  182. package/dist/__tests__/ws-client-user-message-ack.integration.test.js.map +0 -1
  183. package/dist/aiden-system-prompt.d.ts +0 -6
  184. package/dist/aiden-system-prompt.d.ts.map +0 -1
  185. package/dist/aiden-system-prompt.js +0 -6
  186. package/dist/aiden-system-prompt.js.map +0 -1
  187. package/dist/binding-switch-git.d.ts +0 -26
  188. package/dist/binding-switch-git.d.ts.map +0 -1
  189. package/dist/binding-switch-git.js +0 -973
  190. package/dist/binding-switch-git.js.map +0 -1
  191. package/dist/cli-ensure-install.d.ts +0 -39
  192. package/dist/cli-ensure-install.d.ts.map +0 -1
  193. package/dist/cli-ensure-install.js +0 -133
  194. package/dist/cli-ensure-install.js.map +0 -1
  195. package/dist/cli-executable.d.ts +0 -97
  196. package/dist/cli-executable.d.ts.map +0 -1
  197. package/dist/cli-executable.js +0 -432
  198. package/dist/cli-executable.js.map +0 -1
  199. package/dist/cli-help.d.ts +0 -7
  200. package/dist/cli-help.d.ts.map +0 -1
  201. package/dist/cli-help.js +0 -49
  202. package/dist/cli-help.js.map +0 -1
  203. package/dist/computer-readiness.d.ts +0 -42
  204. package/dist/computer-readiness.d.ts.map +0 -1
  205. package/dist/computer-readiness.js +0 -191
  206. package/dist/computer-readiness.js.map +0 -1
  207. package/dist/core-agent.d.ts +0 -47
  208. package/dist/core-agent.d.ts.map +0 -1
  209. package/dist/core-agent.js +0 -364
  210. package/dist/core-agent.js.map +0 -1
  211. package/dist/daemon.d.ts +0 -392
  212. package/dist/daemon.d.ts.map +0 -1
  213. package/dist/daemon.js +0 -4711
  214. package/dist/daemon.js.map +0 -1
  215. package/dist/event-outbox.d.ts +0 -83
  216. package/dist/event-outbox.d.ts.map +0 -1
  217. package/dist/event-outbox.js +0 -440
  218. package/dist/event-outbox.js.map +0 -1
  219. package/dist/fake-provider-cli.d.ts +0 -13
  220. package/dist/fake-provider-cli.d.ts.map +0 -1
  221. package/dist/fake-provider-cli.js +0 -53
  222. package/dist/fake-provider-cli.js.map +0 -1
  223. package/dist/generated-images.d.ts +0 -2
  224. package/dist/generated-images.d.ts.map +0 -1
  225. package/dist/generated-images.js +0 -2
  226. package/dist/generated-images.js.map +0 -1
  227. package/dist/index.d.ts +0 -6
  228. package/dist/index.d.ts.map +0 -1
  229. package/dist/index.js +0 -209
  230. package/dist/index.js.map +0 -1
  231. package/dist/lifecycle-logger.d.ts +0 -25
  232. package/dist/lifecycle-logger.d.ts.map +0 -1
  233. package/dist/lifecycle-logger.js +0 -73
  234. package/dist/lifecycle-logger.js.map +0 -1
  235. package/dist/local-skill-scan.d.ts +0 -21
  236. package/dist/local-skill-scan.d.ts.map +0 -1
  237. package/dist/local-skill-scan.js +0 -109
  238. package/dist/local-skill-scan.js.map +0 -1
  239. package/dist/local-workspace-migration.d.ts +0 -68
  240. package/dist/local-workspace-migration.d.ts.map +0 -1
  241. package/dist/local-workspace-migration.js +0 -157
  242. package/dist/local-workspace-migration.js.map +0 -1
  243. package/dist/mcp-readiness.d.ts +0 -59
  244. package/dist/mcp-readiness.d.ts.map +0 -1
  245. package/dist/mcp-readiness.js +0 -202
  246. package/dist/mcp-readiness.js.map +0 -1
  247. package/dist/mcp-registration.d.ts +0 -75
  248. package/dist/mcp-registration.d.ts.map +0 -1
  249. package/dist/mcp-registration.js +0 -563
  250. package/dist/mcp-registration.js.map +0 -1
  251. package/dist/model-scan-runner.d.ts +0 -15
  252. package/dist/model-scan-runner.d.ts.map +0 -1
  253. package/dist/model-scan-runner.js +0 -51
  254. package/dist/model-scan-runner.js.map +0 -1
  255. package/dist/network-diagnostics.d.ts +0 -8
  256. package/dist/network-diagnostics.d.ts.map +0 -1
  257. package/dist/network-diagnostics.js +0 -56
  258. package/dist/network-diagnostics.js.map +0 -1
  259. package/dist/observable-map.d.ts +0 -25
  260. package/dist/observable-map.d.ts.map +0 -1
  261. package/dist/observable-map.js +0 -42
  262. package/dist/observable-map.js.map +0 -1
  263. package/dist/provider-auth-preflight.d.ts +0 -22
  264. package/dist/provider-auth-preflight.d.ts.map +0 -1
  265. package/dist/provider-auth-preflight.js +0 -110
  266. package/dist/provider-auth-preflight.js.map +0 -1
  267. package/dist/provider-model-discovery.d.ts +0 -38
  268. package/dist/provider-model-discovery.d.ts.map +0 -1
  269. package/dist/provider-model-discovery.js +0 -519
  270. package/dist/provider-model-discovery.js.map +0 -1
  271. package/dist/resume-fallback-env.d.ts +0 -20
  272. package/dist/resume-fallback-env.d.ts.map +0 -1
  273. package/dist/resume-fallback-env.js +0 -30
  274. package/dist/resume-fallback-env.js.map +0 -1
  275. package/dist/run-journal.d.ts +0 -53
  276. package/dist/run-journal.d.ts.map +0 -1
  277. package/dist/run-journal.js +0 -193
  278. package/dist/run-journal.js.map +0 -1
  279. package/dist/run-start-gate.d.ts +0 -9
  280. package/dist/run-start-gate.d.ts.map +0 -1
  281. package/dist/run-start-gate.js +0 -24
  282. package/dist/run-start-gate.js.map +0 -1
  283. package/dist/runtime-backends.d.ts +0 -2
  284. package/dist/runtime-backends.d.ts.map +0 -1
  285. package/dist/runtime-backends.js +0 -2
  286. package/dist/runtime-backends.js.map +0 -1
  287. package/dist/runtime-capabilities-sync.d.ts +0 -33
  288. package/dist/runtime-capabilities-sync.d.ts.map +0 -1
  289. package/dist/runtime-capabilities-sync.js +0 -56
  290. package/dist/runtime-capabilities-sync.js.map +0 -1
  291. package/dist/runtime-config.d.ts +0 -24
  292. package/dist/runtime-config.d.ts.map +0 -1
  293. package/dist/runtime-config.js +0 -124
  294. package/dist/runtime-config.js.map +0 -1
  295. package/dist/sandbox-outbox.d.ts +0 -122
  296. package/dist/sandbox-outbox.d.ts.map +0 -1
  297. package/dist/sandbox-outbox.js +0 -180
  298. package/dist/sandbox-outbox.js.map +0 -1
  299. package/dist/sandbox.d.ts +0 -44
  300. package/dist/sandbox.d.ts.map +0 -1
  301. package/dist/sandbox.js +0 -438
  302. package/dist/sandbox.js.map +0 -1
  303. package/dist/service-manager.d.ts +0 -28
  304. package/dist/service-manager.d.ts.map +0 -1
  305. package/dist/service-manager.js +0 -259
  306. package/dist/service-manager.js.map +0 -1
  307. package/dist/sleep-inhibitor.d.ts +0 -111
  308. package/dist/sleep-inhibitor.d.ts.map +0 -1
  309. package/dist/sleep-inhibitor.js +0 -412
  310. package/dist/sleep-inhibitor.js.map +0 -1
  311. package/dist/suspension-detector.d.ts +0 -48
  312. package/dist/suspension-detector.d.ts.map +0 -1
  313. package/dist/suspension-detector.js +0 -89
  314. package/dist/suspension-detector.js.map +0 -1
  315. package/dist/types.d.ts +0 -6
  316. package/dist/types.d.ts.map +0 -1
  317. package/dist/types.js +0 -6
  318. package/dist/types.js.map +0 -1
  319. package/dist/updater.d.ts +0 -15
  320. package/dist/updater.d.ts.map +0 -1
  321. package/dist/updater.js +0 -50
  322. package/dist/updater.js.map +0 -1
  323. package/dist/version.d.ts +0 -2
  324. package/dist/version.d.ts.map +0 -1
  325. package/dist/version.js +0 -2
  326. package/dist/version.js.map +0 -1
  327. package/dist/web-presenter.d.ts +0 -55
  328. package/dist/web-presenter.d.ts.map +0 -1
  329. package/dist/web-presenter.js +0 -265
  330. package/dist/web-presenter.js.map +0 -1
  331. package/dist/workspace-relocation.d.ts +0 -22
  332. package/dist/workspace-relocation.d.ts.map +0 -1
  333. package/dist/workspace-relocation.js +0 -90
  334. package/dist/workspace-relocation.js.map +0 -1
  335. package/dist/workspace-run-lease.d.ts +0 -97
  336. package/dist/workspace-run-lease.d.ts.map +0 -1
  337. package/dist/workspace-run-lease.js +0 -241
  338. package/dist/workspace-run-lease.js.map +0 -1
  339. package/dist/ws-client.d.ts +0 -194
  340. package/dist/ws-client.d.ts.map +0 -1
  341. package/dist/ws-client.js +0 -282
  342. package/dist/ws-client.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -14973,7 +14973,7 @@ function resolveCommand(args, env) {
14973
14973
 
14974
14974
  // src/daemon.ts
14975
14975
  var import_node_crypto17 = require("crypto");
14976
- var import_node_os11 = require("os");
14976
+ var import_node_os12 = require("os");
14977
14977
 
14978
14978
  // src/sleep-inhibitor.ts
14979
14979
  var import_node_child_process2 = require("child_process");
@@ -15240,7 +15240,7 @@ function describeError(error61) {
15240
15240
  }
15241
15241
 
15242
15242
  // src/version.ts
15243
- var AGENT_VERSION = "0.1.80";
15243
+ var AGENT_VERSION = "0.1.82";
15244
15244
 
15245
15245
  // src/daemon-worktree.ts
15246
15246
  var import_node_child_process3 = require("child_process");
@@ -15296,104 +15296,6 @@ function isInteractiveToolName(name, input2) {
15296
15296
  var ALAN_AGENT_WORKOS_USER_ID_PREFIX = "alan-agent:";
15297
15297
  var ALAN_AGENT_WORKOS_USER_ID_LIKE_PATTERN = `${ALAN_AGENT_WORKOS_USER_ID_PREFIX}%`;
15298
15298
 
15299
- // ../shared/dist/constants/colors.js
15300
- var CATEGORICAL_COLORS = {
15301
- slate: "#7280a0",
15302
- slateMuted: "#8892a4",
15303
- slateCool: "#6b7a96",
15304
- slateDeep: "#64748b",
15305
- slateClosed: "#7a8295",
15306
- slateLight: "#94a3b8",
15307
- slatePale: "#cbd5e1",
15308
- blue: "#5583b5",
15309
- blueMuted: "#6a90b0",
15310
- blueBright: "#3b82f6",
15311
- blueSoft: "#7d9fc2",
15312
- cyan: "#3a92a8",
15313
- cyanBright: "#2f9ab5",
15314
- cyanSoft: "#6dadb8",
15315
- teal: "#4895a5",
15316
- tealDeep: "#2e9e80",
15317
- green: "#3d9170",
15318
- greenBright: "#3a9c6f",
15319
- greenMuted: "#5a9a6a",
15320
- greenSoft: "#6daa94",
15321
- greenLeaf: "#74b080",
15322
- purple: "#7e6db2",
15323
- dubaiPurple: "#6366f1",
15324
- purpleMuted: "#9a6daa",
15325
- purpleSoft: "#9a8cbd",
15326
- violet: "#8b6bbf",
15327
- indigo: "#6b75d6",
15328
- indigoMuted: "#838cc0",
15329
- gold: "#b08a45",
15330
- goldMuted: "#a89248",
15331
- amber: "#c49a30",
15332
- yellow: "#eab308",
15333
- orange: "#c27058",
15334
- orangeDeep: "#c47d3a",
15335
- orangeBright: "#f97316",
15336
- orangeSoft: "#d49872",
15337
- orangePale: "#fdba74",
15338
- red: "#c25858",
15339
- redBright: "#ef4444",
15340
- redSoft: "#c47474",
15341
- pink: "#b25a8a",
15342
- pinkMuted: "#b86078",
15343
- pinkSoft: "#c07a9a",
15344
- rose: "#c44d8a",
15345
- bronze: "#8a8258",
15346
- avatarBlue: "#4a7fc4",
15347
- avatarPurple: "#7b62c4",
15348
- avatarOrange: "#c4703a"
15349
- };
15350
- var CATEGORICAL_COLOR_VALUES = Object.values(CATEGORICAL_COLORS);
15351
- var CATEGORICAL_COLOR_VALUE_SET = new Set(CATEGORICAL_COLOR_VALUES);
15352
-
15353
- // ../shared/dist/constants/labels.js
15354
- var LABEL_COLOR_PRESETS = {
15355
- bug: CATEGORICAL_COLORS.red,
15356
- feature: CATEGORICAL_COLORS.purple,
15357
- improvement: CATEGORICAL_COLORS.blue,
15358
- refactor: CATEGORICAL_COLORS.gold,
15359
- docs: CATEGORICAL_COLORS.green,
15360
- chore: CATEGORICAL_COLORS.slate,
15361
- design: CATEGORICAL_COLORS.pink,
15362
- research: CATEGORICAL_COLORS.cyan
15363
- };
15364
- var LABEL_COLOR_PALETTE = [
15365
- CATEGORICAL_COLORS.orange,
15366
- CATEGORICAL_COLORS.goldMuted,
15367
- CATEGORICAL_COLORS.greenMuted,
15368
- CATEGORICAL_COLORS.teal,
15369
- CATEGORICAL_COLORS.indigo,
15370
- CATEGORICAL_COLORS.purpleMuted,
15371
- CATEGORICAL_COLORS.pinkMuted,
15372
- CATEGORICAL_COLORS.bronze,
15373
- CATEGORICAL_COLORS.blueMuted
15374
- ];
15375
- var LABEL_COLOR_CHOICES = [
15376
- CATEGORICAL_COLORS.slate,
15377
- CATEGORICAL_COLORS.blue,
15378
- CATEGORICAL_COLORS.purple,
15379
- CATEGORICAL_COLORS.green,
15380
- CATEGORICAL_COLORS.red,
15381
- CATEGORICAL_COLORS.orange,
15382
- CATEGORICAL_COLORS.gold,
15383
- CATEGORICAL_COLORS.pink,
15384
- CATEGORICAL_COLORS.cyan,
15385
- CATEGORICAL_COLORS.teal
15386
- ];
15387
- var AVATAR_COLOR_PALETTE = [
15388
- CATEGORICAL_COLORS.avatarBlue,
15389
- CATEGORICAL_COLORS.avatarPurple,
15390
- CATEGORICAL_COLORS.indigo,
15391
- CATEGORICAL_COLORS.rose,
15392
- CATEGORICAL_COLORS.avatarOrange,
15393
- CATEGORICAL_COLORS.greenBright,
15394
- CATEGORICAL_COLORS.cyanBright
15395
- ];
15396
-
15397
15299
  // ../shared/dist/constants/local-workspace.js
15398
15300
  var ALAN_DEFAULT_WORKSPACE_URI = "alan://workspace";
15399
15301
  function isAlanDefaultWorkspace(value2) {
@@ -15412,166 +15314,6 @@ Before create_task:
15412
15314
  4. Use list_team_labels and apply matching labels when creating or updating; do not invent label variants.
15413
15315
  5. Similarity hits are hints only \u2014 synthesize context and use judgment, not fixed thresholds.`;
15414
15316
 
15415
- // ../shared/dist/constants/tasks.js
15416
- var STATUS_OPTIONS = [
15417
- {
15418
- value: "backlog",
15419
- label: "Backlog",
15420
- color: CATEGORICAL_COLORS.slateMuted,
15421
- group: "not_started",
15422
- dotClass: "text-muted-foreground",
15423
- headerBg: "bg-muted/60"
15424
- },
15425
- {
15426
- value: "todo",
15427
- label: "Todo",
15428
- color: CATEGORICAL_COLORS.slateCool,
15429
- group: "not_started",
15430
- dotClass: "text-muted-foreground/70",
15431
- headerBg: "bg-muted/40"
15432
- },
15433
- {
15434
- value: "in_progress",
15435
- label: "In Progress",
15436
- color: CATEGORICAL_COLORS.amber,
15437
- group: "active",
15438
- dotClass: "text-amber-700 dark:text-amber-400",
15439
- headerBg: "bg-amber-400/15"
15440
- },
15441
- {
15442
- value: "in_review",
15443
- label: "In Review",
15444
- color: CATEGORICAL_COLORS.violet,
15445
- group: "active",
15446
- dotClass: "text-violet-500 dark:text-violet-400",
15447
- headerBg: "bg-violet-400/15"
15448
- },
15449
- {
15450
- value: "done",
15451
- label: "Done",
15452
- color: CATEGORICAL_COLORS.tealDeep,
15453
- group: "done",
15454
- dotClass: "text-teal-600 dark:text-teal-400",
15455
- headerBg: "bg-teal-400/15"
15456
- },
15457
- {
15458
- value: "cancelled",
15459
- label: "Cancelled",
15460
- color: CATEGORICAL_COLORS.slateClosed,
15461
- group: "closed",
15462
- dotClass: "text-muted-foreground/60",
15463
- headerBg: "bg-muted/60"
15464
- }
15465
- ];
15466
- var DEFAULT_TEAM_STATUSES = STATUS_OPTIONS.map((o) => ({
15467
- id: o.value,
15468
- label: o.label,
15469
- color: o.color,
15470
- group: o.group
15471
- }));
15472
- var EPIC_STATUS_OPTIONS = [
15473
- {
15474
- value: "backlog",
15475
- label: "Backlog",
15476
- color: CATEGORICAL_COLORS.slateMuted,
15477
- group: "not_started"
15478
- },
15479
- {
15480
- value: "planned",
15481
- label: "Planned",
15482
- color: CATEGORICAL_COLORS.blueSoft,
15483
- group: "not_started"
15484
- },
15485
- {
15486
- value: "in_progress",
15487
- label: "In Progress",
15488
- color: CATEGORICAL_COLORS.amber,
15489
- group: "active"
15490
- },
15491
- {
15492
- value: "completed",
15493
- label: "Completed",
15494
- color: CATEGORICAL_COLORS.tealDeep,
15495
- group: "done"
15496
- },
15497
- {
15498
- value: "canceled",
15499
- label: "Canceled",
15500
- color: CATEGORICAL_COLORS.slateClosed,
15501
- group: "closed"
15502
- }
15503
- ];
15504
- var DEFAULT_EPIC_STATUSES = EPIC_STATUS_OPTIONS.map((o) => ({
15505
- id: o.value,
15506
- label: o.label,
15507
- color: o.color,
15508
- group: o.group
15509
- }));
15510
- var PRIORITY_OPTIONS = [
15511
- {
15512
- value: "p0",
15513
- label: "Urgent",
15514
- detail: "Urgent",
15515
- color: CATEGORICAL_COLORS.redBright,
15516
- iconClass: "text-red-500/70",
15517
- flagClass: "text-red-600 dark:text-red-400"
15518
- },
15519
- {
15520
- value: "p1",
15521
- label: "High",
15522
- detail: "High",
15523
- color: CATEGORICAL_COLORS.orangeBright,
15524
- iconClass: "text-orange-500/70",
15525
- flagClass: "text-orange-600 dark:text-orange-400"
15526
- },
15527
- {
15528
- value: "p2",
15529
- label: "Medium",
15530
- detail: "Medium",
15531
- color: CATEGORICAL_COLORS.yellow,
15532
- iconClass: "text-amber-500/70 dark:text-amber-400/70",
15533
- flagClass: "text-amber-600 dark:text-amber-400"
15534
- },
15535
- {
15536
- value: "p3",
15537
- label: "Low",
15538
- detail: "Low",
15539
- color: CATEGORICAL_COLORS.blueBright,
15540
- iconClass: "text-blue-500/70 dark:text-blue-400/70",
15541
- flagClass: "text-blue-600 dark:text-blue-400"
15542
- },
15543
- {
15544
- value: "none",
15545
- label: "No priority",
15546
- detail: "No priority",
15547
- color: CATEGORICAL_COLORS.slateDeep,
15548
- iconClass: "text-muted-foreground/40",
15549
- flagClass: "text-muted-foreground/50"
15550
- }
15551
- ];
15552
-
15553
- // ../shared/dist/constants/workspace-retention.js
15554
- var RESOURCE_CLASS_GC_TIME_MS = {
15555
- /**
15556
- * Small, stable, expensive-to-refetch descriptors: team lists, member lists,
15557
- * label sets, status metadata. Kilobytes that rarely change.
15558
- */
15559
- metadata: 30 * 6e4,
15560
- /** Everything not explicitly classified. The previous global default. */
15561
- standard: 10 * 6e4,
15562
- /**
15563
- * Large per-entity payloads: transcripts, diffs, file trees, image sets,
15564
- * paginated bulk lists. Megabytes that are cheap to re-fetch on return.
15565
- */
15566
- bulk: 9e4,
15567
- /**
15568
- * Immutable content addressed by a content hash (commit diffs). Retaining it
15569
- * is a pure win while it fits the budget, and the budget controller drops it
15570
- * first under pressure precisely because it can always be re-derived.
15571
- */
15572
- immutable: 60 * 6e4
15573
- };
15574
-
15575
15317
  // ../shared/dist/node/local-workspace.js
15576
15318
  var import_node_fs2 = require("fs");
15577
15319
  var import_node_os2 = require("os");
@@ -37211,16 +36953,6 @@ function isCodexTransientReconnectNotice(message) {
37211
36953
  return false;
37212
36954
  }
37213
36955
 
37214
- // ../shared/dist/utils/agent-run-status.js
37215
- var ACTIVE_AGENT_RUN_STATUSES = [
37216
- "pending",
37217
- "awaiting_agent",
37218
- "awaiting_sandbox",
37219
- "dispatched",
37220
- "running"
37221
- ];
37222
- var STOPPABLE_AGENT_RUN_STATUSES = [...ACTIVE_AGENT_RUN_STATUSES, "paused"];
37223
-
37224
36956
  // ../shared/dist/agent/types.js
37225
36957
  function resolveEffectiveBackendKind(backendKind) {
37226
36958
  if (backendKind === "codex")
@@ -39191,6 +38923,8 @@ function classifyCliErrorDetailed(stderr, _exitCode, opts) {
39191
38923
  "grok build usage balance"
39192
38924
  ) || has("payment required") && has("status 402"))
39193
38925
  return specForErrorKind("usage_limit");
38926
+ if (has("creditserror", "no payment method")) return specForErrorKind("subscription_required");
38927
+ if (has("datapolicyerror", "requires explicit opt in")) return specForErrorKind("model_mismatch");
39194
38928
  if (has("no chat found", "chat not found", "session not found", "could not resume"))
39195
38929
  return specForErrorKind("resume_failed");
39196
38930
  if (has("rate_limit", "rate limit") || /\b429\b/.test(haystack))
@@ -45773,6 +45507,20 @@ function classifyOpenCodeError(errorRecord, fallbackMessage) {
45773
45507
  recoveryClass: "user_fixable"
45774
45508
  };
45775
45509
  }
45510
+ if (name === "CreditsError") {
45511
+ return {
45512
+ message: extracted || fallbackMessage,
45513
+ errorKind: "subscription_required",
45514
+ recoveryClass: "user_fixable"
45515
+ };
45516
+ }
45517
+ if (name === "DataPolicyError") {
45518
+ return {
45519
+ message: extracted || fallbackMessage,
45520
+ errorKind: "model_mismatch",
45521
+ recoveryClass: "user_fixable"
45522
+ };
45523
+ }
45776
45524
  const message = extracted || fallbackMessage;
45777
45525
  const detailed = classifyCliErrorDetailed(message, 1);
45778
45526
  return { message, errorKind: detailed.errorKind, recoveryClass: detailed.recoveryClass };
@@ -49117,9 +48865,14 @@ function removeAlanOwnedLocalArtifacts() {
49117
48865
 
49118
48866
  // src/provider-model-discovery.ts
49119
48867
  var import_node_fs12 = require("fs");
48868
+ var import_node_os6 = require("os");
48869
+ var import_node_path11 = require("path");
49120
48870
  var MODEL_DISCOVERY_TIMEOUT_MS = 8e3;
49121
48871
  var ANTIGRAVITY_MODEL_DISCOVERY_TIMEOUT_MS = 12e3;
49122
48872
  var OPENCODE_ZEN_MODEL_IDS = OPENCODE_ZEN_MODELS.map((model) => model.id);
48873
+ var OPENCODE_ZEN_STATIC_BILLING = new Map(
48874
+ OPENCODE_ZEN_MODELS.filter((model) => model.billing).map((model) => [model.id, model.billing])
48875
+ );
49123
48876
  var CLAUDE_MODEL_ID_PATTERN = /claude-(?:sonnet|opus|haiku|fable)-[a-z0-9][a-z0-9-]*/g;
49124
48877
  var CLAUDE_MODEL_ALIASES = ["sonnet", "opus", "haiku", "fable"];
49125
48878
  var CLAUDE_MODEL_ALIAS_SET = new Set(CLAUDE_MODEL_ALIASES);
@@ -49191,7 +48944,7 @@ function extractCodexDiscoveredModelIdsFromDebugJson(value2) {
49191
48944
  }
49192
48945
  return [...new Set(ids)];
49193
48946
  }
49194
- var OPENCODE_MODEL_ID_LINE_PATTERN = /^[a-z0-9][\w.-]*\/[\w.-]+$/i;
48947
+ var OPENCODE_MODEL_ID_LINE_PATTERN = /^[a-z0-9][\w.-]*(?:\/[\w.-]+)+$/i;
49195
48948
  function parseOpenCodeVerboseModelOutput(text) {
49196
48949
  const entries = [];
49197
48950
  const lines = text.split(/\r?\n/);
@@ -49379,7 +49132,190 @@ async function probeJsonOrTextModels(executable, env, argSets, options) {
49379
49132
  }
49380
49133
  return [];
49381
49134
  }
49135
+ var OPENCODE_ZEN_MODELS_URL = "https://opencode.ai/zen/v1/models";
49136
+ var ZEN_ENTITLEMENT_TIMEOUT_MS = 5e3;
49137
+ var OPENCODE_ZEN_ID_PREFIX = "opencode/";
49138
+ function readOpenCodeZenCredential(env) {
49139
+ const direct = env.OPENCODE_API_KEY?.trim();
49140
+ if (direct) return direct;
49141
+ return readZenCredentialFromAuthDocument(readOpenCodeAuthDocument(env) ?? void 0);
49142
+ }
49143
+ function readOpenCodeAuthDocument(env) {
49144
+ const injected = env.OPENCODE_AUTH_CONTENT?.trim();
49145
+ if (injected) return injected;
49146
+ const dataHome = env.XDG_DATA_HOME?.trim() || (0, import_node_path11.join)((0, import_node_os6.homedir)(), ".local", "share");
49147
+ try {
49148
+ return (0, import_node_fs12.readFileSync)((0, import_node_path11.join)(dataHome, "opencode", "auth.json"), "utf8");
49149
+ } catch {
49150
+ return null;
49151
+ }
49152
+ }
49153
+ var OPENCODE_PROVIDER_ENV_KEYS = [
49154
+ ["OPENROUTER_API_KEY", "openrouter"],
49155
+ ["ANTHROPIC_API_KEY", "anthropic"],
49156
+ ["OPENAI_API_KEY", "openai"],
49157
+ ["GEMINI_API_KEY", "google"],
49158
+ ["GOOGLE_GENERATIVE_AI_API_KEY", "google"],
49159
+ ["XAI_API_KEY", "xai"],
49160
+ ["GROQ_API_KEY", "groq"],
49161
+ ["MISTRAL_API_KEY", "mistral"],
49162
+ ["DEEPSEEK_API_KEY", "deepseek"]
49163
+ ];
49164
+ function readConfiguredOpenCodeProviders(env) {
49165
+ const configured = /* @__PURE__ */ new Set(["opencode", "opencode-go"]);
49166
+ const document2 = readOpenCodeAuthDocument(env);
49167
+ if (document2) {
49168
+ try {
49169
+ const parsed = JSON.parse(document2);
49170
+ if (parsed && typeof parsed === "object") {
49171
+ for (const providerId of Object.keys(parsed)) configured.add(providerId);
49172
+ }
49173
+ } catch {
49174
+ }
49175
+ }
49176
+ for (const [envKey, namespace] of OPENCODE_PROVIDER_ENV_KEYS) {
49177
+ if (env[envKey]?.trim()) configured.add(namespace);
49178
+ }
49179
+ return configured;
49180
+ }
49181
+ function readZenCredentialFromAuthDocument(content) {
49182
+ const trimmed = content?.trim();
49183
+ if (!trimmed) return null;
49184
+ try {
49185
+ const entry = JSON.parse(trimmed).opencode;
49186
+ if (!entry || typeof entry !== "object") return null;
49187
+ const { key, access: access2 } = entry;
49188
+ for (const candidate of [key, access2]) {
49189
+ if (typeof candidate === "string" && candidate.trim()) return candidate.trim();
49190
+ }
49191
+ return null;
49192
+ } catch {
49193
+ return null;
49194
+ }
49195
+ }
49196
+ async function fetchZenEntitledModelIds(credential) {
49197
+ try {
49198
+ const response = await fetch(OPENCODE_ZEN_MODELS_URL, {
49199
+ headers: credential ? { Authorization: `Bearer ${credential}` } : {},
49200
+ signal: AbortSignal.timeout(ZEN_ENTITLEMENT_TIMEOUT_MS)
49201
+ });
49202
+ if (!response.ok) return null;
49203
+ const data = (await response.json())?.data;
49204
+ if (!Array.isArray(data)) return null;
49205
+ const ids = data.map((entry) => entry?.id).filter((id) => typeof id === "string" && id.length > 0);
49206
+ return ids.length > 0 ? new Set(ids) : null;
49207
+ } catch {
49208
+ return null;
49209
+ }
49210
+ }
49211
+ function applyZenEntitlement(discovery, entitled) {
49212
+ const zenId = (id) => `${OPENCODE_ZEN_ID_PREFIX}${id}`;
49213
+ const kept = discovery.models.filter(
49214
+ (id) => !id.startsWith(OPENCODE_ZEN_ID_PREFIX) || entitled.has(id.slice(OPENCODE_ZEN_ID_PREFIX.length))
49215
+ );
49216
+ const keptSet = new Set(kept);
49217
+ const scannedSet = new Set(discovery.models);
49218
+ const unscannedEntitled = [...entitled].map(zenId);
49219
+ return {
49220
+ ...discovery,
49221
+ models: [...kept, ...unscannedEntitled.filter((id) => !keptSet.has(id))],
49222
+ catalogModels: [
49223
+ ...discovery.catalogModels ?? discovery.models,
49224
+ ...unscannedEntitled.filter((id) => !scannedSet.has(id))
49225
+ ]
49226
+ };
49227
+ }
49228
+ var OPENCODE_CATALOGUE_CACHE_SEGMENTS = ["opencode", "models.json"];
49229
+ var OPENCODE_CACHE_PROVIDER_KEYS = ["opencode", "opencode-go"];
49230
+ function readOpenCodeCatalogueCache(env) {
49231
+ const cacheHome = env.XDG_CACHE_HOME?.trim() || (0, import_node_path11.join)((0, import_node_os6.homedir)(), ".cache");
49232
+ let parsed;
49233
+ try {
49234
+ parsed = JSON.parse(
49235
+ (0, import_node_fs12.readFileSync)((0, import_node_path11.join)(cacheHome, ...OPENCODE_CATALOGUE_CACHE_SEGMENTS), "utf8")
49236
+ );
49237
+ } catch {
49238
+ return null;
49239
+ }
49240
+ if (!parsed || typeof parsed !== "object") return null;
49241
+ const variants = {};
49242
+ const billing = {};
49243
+ const deprecated = /* @__PURE__ */ new Set();
49244
+ for (const providerKey of OPENCODE_CACHE_PROVIDER_KEYS) {
49245
+ const models = parsed[providerKey]?.models;
49246
+ if (!models || typeof models !== "object") continue;
49247
+ for (const [modelId, entry] of Object.entries(models)) {
49248
+ if (!entry || typeof entry !== "object") continue;
49249
+ const id = `${providerKey}/${modelId}`;
49250
+ const record2 = entry;
49251
+ if (record2.status === "deprecated") deprecated.add(id);
49252
+ const options = Array.isArray(record2.reasoning_options) ? record2.reasoning_options : [];
49253
+ const effort = options.find(
49254
+ (option2) => option2?.type === "effort"
49255
+ );
49256
+ const values = Array.isArray(effort?.values) ? effort.values.filter((value2) => typeof value2 === "string") : [];
49257
+ if (values.length > 0) variants[id] = values;
49258
+ const cost = record2.cost;
49259
+ if (typeof cost?.input === "number" && typeof cost?.output === "number") {
49260
+ billing[id] = cost.input === 0 && cost.output === 0 ? "free" : "paid";
49261
+ }
49262
+ }
49263
+ }
49264
+ return Object.keys(variants).length > 0 || Object.keys(billing).length > 0 ? { variants, billing, deprecated } : null;
49265
+ }
49266
+ function hydrateOpenCodeMetadata(discovery, cache2) {
49267
+ const ids = /* @__PURE__ */ new Set([...discovery.models, ...discovery.catalogModels ?? []]);
49268
+ const modelVariants = { ...discovery.modelVariants };
49269
+ const modelBilling = { ...discovery.modelBilling };
49270
+ for (const id of ids) {
49271
+ if (!Object.hasOwn(modelVariants, id) && cache2.variants[id]) {
49272
+ modelVariants[id] = cache2.variants[id];
49273
+ }
49274
+ if (!Object.hasOwn(modelBilling, id) && cache2.billing[id]) {
49275
+ modelBilling[id] = cache2.billing[id];
49276
+ }
49277
+ }
49278
+ return {
49279
+ ...discovery,
49280
+ ...Object.keys(modelVariants).length > 0 ? { modelVariants } : {},
49281
+ ...Object.keys(modelBilling).length > 0 ? { modelBilling } : {}
49282
+ };
49283
+ }
49382
49284
  async function discoverOpenCodeModels(executable, env) {
49285
+ const credential = readOpenCodeZenCredential(env);
49286
+ const [rawScan, entitled] = await Promise.all([
49287
+ scanOpenCodeModels(executable, env),
49288
+ fetchZenEntitledModelIds(credential)
49289
+ ]);
49290
+ const configured = readConfiguredOpenCodeProviders(env);
49291
+ const inConfigured = (id) => {
49292
+ const slash = id.indexOf("/");
49293
+ return slash > 0 && configured.has(id.slice(0, slash));
49294
+ };
49295
+ const scanned = {
49296
+ ...rawScan,
49297
+ models: rawScan.models.filter(inConfigured),
49298
+ ...rawScan.catalogModels ? { catalogModels: rawScan.catalogModels.filter(inConfigured) } : {}
49299
+ };
49300
+ const filtered = entitled ? applyZenEntitlement(scanned, entitled) : scanned;
49301
+ const cache2 = readOpenCodeCatalogueCache(env);
49302
+ const hydrated = cache2 ? hydrateOpenCodeMetadata(filtered, cache2) : filtered;
49303
+ const keyEntitled = credential && entitled ? entitled : null;
49304
+ const withoutDeprecated = cache2 ? hydrated.models.filter(
49305
+ (id) => !cache2.deprecated.has(id) || keyEntitled !== null && id.startsWith(OPENCODE_ZEN_ID_PREFIX) && keyEntitled.has(id.slice(OPENCODE_ZEN_ID_PREFIX.length))
49306
+ ) : hydrated.models;
49307
+ return {
49308
+ ...hydrated,
49309
+ models: credential ? withoutDeprecated : filterZenToFreeModels(withoutDeprecated, hydrated.modelBilling)
49310
+ };
49311
+ }
49312
+ function filterZenToFreeModels(models, billing) {
49313
+ return models.filter((id) => {
49314
+ if (!id.startsWith("opencode/") && !id.startsWith("opencode-go/")) return true;
49315
+ return (billing?.[id] ?? OPENCODE_ZEN_STATIC_BILLING.get(id)) === "free";
49316
+ });
49317
+ }
49318
+ async function scanOpenCodeModels(executable, env) {
49383
49319
  const verbose = await runCliProbeAsync(
49384
49320
  executable,
49385
49321
  withModelProbeEnv(env),
@@ -49642,6 +49578,7 @@ function discoverCapabilities() {
49642
49578
  available,
49643
49579
  ...version2 ? { version: version2 } : {},
49644
49580
  models: modelDiscovery?.models ?? [],
49581
+ ...modelDiscovery?.catalogModels ? { catalogModels: modelDiscovery.catalogModels } : {},
49645
49582
  ...modelDiscovery?.modelVariants ? { modelVariants: modelDiscovery.modelVariants } : {},
49646
49583
  ...modelDiscovery?.modelBilling ? { modelBilling: modelDiscovery.modelBilling } : {},
49647
49584
  lastCheckedAt: now,
@@ -49889,8 +49826,8 @@ function scheduleRuntimeModelScan(getBaseMetadata, options) {
49889
49826
  var import_node_crypto16 = require("crypto");
49890
49827
  var import_node_fs20 = require("fs");
49891
49828
  var import_node_http = __toESM(require("http"), 1);
49892
- var import_node_os10 = require("os");
49893
- var import_node_path22 = require("path");
49829
+ var import_node_os11 = require("os");
49830
+ var import_node_path23 = require("path");
49894
49831
 
49895
49832
  // ../../node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js
49896
49833
  var XMLHttpRequestModule = __toESM(require_XMLHttpRequest(), 1);
@@ -53450,8 +53387,8 @@ Object.assign(lookup, {
53450
53387
  var import_node_child_process7 = require("child_process");
53451
53388
  var import_node_crypto5 = require("crypto");
53452
53389
  var import_node_fs13 = require("fs");
53453
- var import_node_os6 = require("os");
53454
- var import_node_path11 = require("path");
53390
+ var import_node_os7 = require("os");
53391
+ var import_node_path12 = require("path");
53455
53392
  var import_node_url = require("url");
53456
53393
  var BINDING_SWITCH_GIT_METHODS = [
53457
53394
  "git.status",
@@ -53503,8 +53440,8 @@ async function waitForCheckpointTestBarrier() {
53503
53440
  const barrierDir = process.env.NODE_ENV === "test" ? process.env.ALAN_TEST_GIT_CHECKPOINT_BARRIER_DIR : void 0;
53504
53441
  if (!barrierDir) return;
53505
53442
  (0, import_node_fs13.mkdirSync)(barrierDir, { recursive: true });
53506
- const readyPath = (0, import_node_path11.join)(barrierDir, "ready");
53507
- const releasePath = (0, import_node_path11.join)(barrierDir, "release");
53443
+ const readyPath = (0, import_node_path12.join)(barrierDir, "ready");
53444
+ const releasePath = (0, import_node_path12.join)(barrierDir, "release");
53508
53445
  (0, import_node_fs13.writeFileSync)(readyPath, "ready\n");
53509
53446
  const deadline = Date.now() + 5e3;
53510
53447
  while (!(0, import_node_fs13.existsSync)(releasePath)) {
@@ -53521,8 +53458,8 @@ async function waitForCheckpointFinalizeTestBarrier() {
53521
53458
  const barrierDir = process.env.NODE_ENV === "test" ? process.env.ALAN_TEST_GIT_CHECKPOINT_FINALIZE_BARRIER_DIR : void 0;
53522
53459
  if (!barrierDir) return;
53523
53460
  (0, import_node_fs13.mkdirSync)(barrierDir, { recursive: true });
53524
- const readyPath = (0, import_node_path11.join)(barrierDir, "ready");
53525
- const releasePath = (0, import_node_path11.join)(barrierDir, "release");
53461
+ const readyPath = (0, import_node_path12.join)(barrierDir, "ready");
53462
+ const releasePath = (0, import_node_path12.join)(barrierDir, "release");
53526
53463
  (0, import_node_fs13.writeFileSync)(readyPath, "ready\n");
53527
53464
  const deadline = Date.now() + 5e3;
53528
53465
  while (!(0, import_node_fs13.existsSync)(releasePath)) {
@@ -53663,7 +53600,7 @@ function acquireCheckpointRepositoryLocks(repoRoot) {
53663
53600
  "checkpoint_lock_unavailable"
53664
53601
  );
53665
53602
  const locks = {
53666
- headLockPath: (0, import_node_path11.join)(gitDir, "HEAD.lock"),
53603
+ headLockPath: (0, import_node_path12.join)(gitDir, "HEAD.lock"),
53667
53604
  headLockHeld: false,
53668
53605
  indexLockPath: `${indexPath}.lock`,
53669
53606
  indexLockHeld: false,
@@ -53705,8 +53642,8 @@ function assertCheckpointHead(repoRoot, expectedRef, expectedHeadSha) {
53705
53642
  }
53706
53643
  }
53707
53644
  function createCheckpointIndexBaseline(repoRoot, checkpointSha) {
53708
- const tempDir = (0, import_node_fs13.mkdtempSync)((0, import_node_path11.join)((0, import_node_os6.tmpdir)(), "alan-checkpoint-index-"));
53709
- const indexPath = (0, import_node_path11.join)(tempDir, "index");
53645
+ const tempDir = (0, import_node_fs13.mkdtempSync)((0, import_node_path12.join)((0, import_node_os7.tmpdir)(), "alan-checkpoint-index-"));
53646
+ const indexPath = (0, import_node_path12.join)(tempDir, "index");
53710
53647
  try {
53711
53648
  runGitWithOptions(
53712
53649
  repoRoot,
@@ -53767,7 +53704,7 @@ function commonRequest(params) {
53767
53704
  return {
53768
53705
  switchId: requiredString2(params, "switchId"),
53769
53706
  repoKey: requiredString2(params, "repoKey"),
53770
- repoPath: (0, import_node_path11.resolve)(requiredString2(params, "repoPath"))
53707
+ repoPath: (0, import_node_path12.resolve)(requiredString2(params, "repoPath"))
53771
53708
  };
53772
53709
  }
53773
53710
  function assertCommitSha(sha, key) {
@@ -53801,8 +53738,8 @@ function canonicalRemoteUrl(repoRoot, value2) {
53801
53738
  }
53802
53739
  const scpStyle = trimmed.match(/^([^/@:\s]+)@([^/:\s]+):(.+)$/);
53803
53740
  const urlValue = scpStyle ? `ssh://${scpStyle[1]}@${scpStyle[2]}/${scpStyle[3]}` : trimmed;
53804
- if ((0, import_node_path11.isAbsolute)(urlValue) || urlValue.startsWith("./") || urlValue.startsWith("../")) {
53805
- const absolute = (0, import_node_path11.isAbsolute)(urlValue) ? urlValue : (0, import_node_path11.resolve)(repoRoot, urlValue);
53741
+ if ((0, import_node_path12.isAbsolute)(urlValue) || urlValue.startsWith("./") || urlValue.startsWith("../")) {
53742
+ const absolute = (0, import_node_path12.isAbsolute)(urlValue) ? urlValue : (0, import_node_path12.resolve)(repoRoot, urlValue);
53806
53743
  return `file://${canonicalPathWithMissingTail(absolute).replace(/\/+$/, "").replace(/\.git$/, "")}`;
53807
53744
  }
53808
53745
  let parsed;
@@ -53868,24 +53805,24 @@ function inspectedRemoteUrl(repoRoot, params) {
53868
53805
  return urls[0];
53869
53806
  }
53870
53807
  function isPathContained2(childPath, parentPath) {
53871
- const rel = (0, import_node_path11.relative)((0, import_node_path11.resolve)(parentPath), (0, import_node_path11.resolve)(childPath));
53872
- return rel === "" || !(0, import_node_path11.isAbsolute)(rel) && rel !== ".." && !rel.startsWith(`..${import_node_path11.sep}`);
53808
+ const rel = (0, import_node_path12.relative)((0, import_node_path12.resolve)(parentPath), (0, import_node_path12.resolve)(childPath));
53809
+ return rel === "" || !(0, import_node_path12.isAbsolute)(rel) && rel !== ".." && !rel.startsWith(`..${import_node_path12.sep}`);
53873
53810
  }
53874
53811
  function canonicalPathWithMissingTail(path2) {
53875
53812
  const missingSegments = [];
53876
- let cursor = (0, import_node_path11.resolve)(path2);
53813
+ let cursor = (0, import_node_path12.resolve)(path2);
53877
53814
  while (!(0, import_node_fs13.existsSync)(cursor)) {
53878
- const parent = (0, import_node_path11.dirname)(cursor);
53815
+ const parent = (0, import_node_path12.dirname)(cursor);
53879
53816
  if (parent === cursor) {
53880
53817
  throw new BindingSwitchGitError(
53881
53818
  "path_canonicalization_failed",
53882
53819
  "The selected path has no existing canonical ancestor"
53883
53820
  );
53884
53821
  }
53885
- missingSegments.unshift((0, import_node_path11.basename)(cursor));
53822
+ missingSegments.unshift((0, import_node_path12.basename)(cursor));
53886
53823
  cursor = parent;
53887
53824
  }
53888
- return (0, import_node_path11.join)(import_node_fs13.realpathSync.native(cursor), ...missingSegments);
53825
+ return (0, import_node_path12.join)(import_node_fs13.realpathSync.native(cursor), ...missingSegments);
53889
53826
  }
53890
53827
  function assertCanonicalPathContained(childPath, parentPath, code, message) {
53891
53828
  if (!isPathContained2(
@@ -53896,7 +53833,7 @@ function assertCanonicalPathContained(childPath, parentPath, code, message) {
53896
53833
  }
53897
53834
  }
53898
53835
  function alanWorktreeRoot(projectRoot) {
53899
- return (0, import_node_path11.join)((0, import_node_path11.dirname)(projectRoot), `${(0, import_node_path11.basename)(projectRoot)}-alan-worktrees`);
53836
+ return (0, import_node_path12.join)((0, import_node_path12.dirname)(projectRoot), `${(0, import_node_path12.basename)(projectRoot)}-alan-worktrees`);
53900
53837
  }
53901
53838
  function resolveRepositoryRoot(requestedPath) {
53902
53839
  if (!(0, import_node_fs13.existsSync)(requestedPath)) {
@@ -53912,7 +53849,7 @@ function resolveRepositoryRoot(requestedPath) {
53912
53849
  "The selected folder is not inside a Git repository"
53913
53850
  );
53914
53851
  }
53915
- return import_node_fs13.realpathSync.native((0, import_node_path11.resolve)(root.stdout.trim()));
53852
+ return import_node_fs13.realpathSync.native((0, import_node_path12.resolve)(root.stdout.trim()));
53916
53853
  }
53917
53854
  function listWorktrees(repoRoot) {
53918
53855
  return runGit(repoRoot, ["worktree", "list", "--porcelain"]).split("\n\n").flatMap((entry) => {
@@ -53931,7 +53868,7 @@ function resolveAuthorizedRepository(params, requireTrustedContext = false) {
53931
53868
  const { repoPath } = commonRequest(params);
53932
53869
  const repoRoot = resolveRepositoryRoot(repoPath);
53933
53870
  const expectedRepoRoot = requireTrustedContext ? requiredString2(params, "expectedRepoRoot") : optionalString(params, "expectedRepoRoot");
53934
- if (expectedRepoRoot && resolveRepositoryRoot((0, import_node_path11.resolve)(expectedRepoRoot)) !== repoRoot) {
53871
+ if (expectedRepoRoot && resolveRepositoryRoot((0, import_node_path12.resolve)(expectedRepoRoot)) !== repoRoot) {
53935
53872
  throw new BindingSwitchGitError(
53936
53873
  "repository_path_changed",
53937
53874
  "The selected path now resolves to a different Git repository"
@@ -53939,7 +53876,7 @@ function resolveAuthorizedRepository(params, requireTrustedContext = false) {
53939
53876
  }
53940
53877
  const projectPath = requireTrustedContext ? requiredString2(params, "projectPath") : optionalString(params, "projectPath");
53941
53878
  if (!projectPath) return repoRoot;
53942
- const projectRoot = resolveRepositoryRoot((0, import_node_path11.resolve)(projectPath));
53879
+ const projectRoot = resolveRepositoryRoot((0, import_node_path12.resolve)(projectPath));
53943
53880
  const registrations = listWorktrees(projectRoot);
53944
53881
  const registered = registrations.find(({ path: path2 }) => path2 === repoRoot);
53945
53882
  if (!registered) {
@@ -53975,8 +53912,8 @@ function updateLengthPrefixed(hash2, value2) {
53975
53912
  hash2.update("\0");
53976
53913
  }
53977
53914
  function proposedTreeSha(repoRoot, headSha) {
53978
- const tempDir = (0, import_node_fs13.mkdtempSync)((0, import_node_path11.join)((0, import_node_os6.tmpdir)(), "alan-switch-index-"));
53979
- const indexPath = (0, import_node_path11.join)(tempDir, "index");
53915
+ const tempDir = (0, import_node_fs13.mkdtempSync)((0, import_node_path12.join)((0, import_node_os7.tmpdir)(), "alan-switch-index-"));
53916
+ const indexPath = (0, import_node_path12.join)(tempDir, "index");
53980
53917
  const options = { env: { GIT_INDEX_FILE: indexPath } };
53981
53918
  try {
53982
53919
  if (headSha) {
@@ -54438,12 +54375,12 @@ async function prepareWorktree(params) {
54438
54375
  "Worktree preparation requires the Project's main checkout"
54439
54376
  );
54440
54377
  }
54441
- const worktreePath = (0, import_node_path11.resolve)(requiredString2(params, "worktreePath"));
54378
+ const worktreePath = (0, import_node_path12.resolve)(requiredString2(params, "worktreePath"));
54442
54379
  const managedRoot = alanWorktreeRoot(projectRoot);
54443
54380
  const pathError = "The destination worktree path is outside the Alan-managed worktree directory";
54444
- const intendedManagedRoot = (0, import_node_path11.join)(
54445
- import_node_fs13.realpathSync.native((0, import_node_path11.dirname)(managedRoot)),
54446
- (0, import_node_path11.basename)(managedRoot)
54381
+ const intendedManagedRoot = (0, import_node_path12.join)(
54382
+ import_node_fs13.realpathSync.native((0, import_node_path12.dirname)(managedRoot)),
54383
+ (0, import_node_path12.basename)(managedRoot)
54447
54384
  );
54448
54385
  if (canonicalPathWithMissingTail(managedRoot) !== intendedManagedRoot) {
54449
54386
  throw new BindingSwitchGitError("worktree_path_not_authorized", pathError);
@@ -54503,7 +54440,7 @@ async function prepareWorktree(params) {
54503
54440
  );
54504
54441
  }
54505
54442
  }
54506
- (0, import_node_fs13.mkdirSync)((0, import_node_path11.dirname)(worktreePath), { recursive: true });
54443
+ (0, import_node_fs13.mkdirSync)((0, import_node_path12.dirname)(worktreePath), { recursive: true });
54507
54444
  if (branchExists) {
54508
54445
  runGit(repoRoot, ["worktree", "add", worktreePath, branch], "worktree_prepare_failed");
54509
54446
  const currentHead = runGit(worktreePath, ["rev-parse", "HEAD"]);
@@ -54582,11 +54519,11 @@ async function executeBindingSwitchGitRpc(method, params) {
54582
54519
 
54583
54520
  // src/daemon-execute.ts
54584
54521
  var import_node_fs15 = require("fs");
54585
- var import_node_path13 = require("path");
54522
+ var import_node_path14 = require("path");
54586
54523
 
54587
54524
  // src/cli-ensure-install.ts
54588
54525
  var import_node_child_process8 = require("child_process");
54589
- var import_node_os7 = require("os");
54526
+ var import_node_os8 = require("os");
54590
54527
  var CLI_RUNTIME_VERSIONS_ENV = "ALAN_CLI_RUNTIME_VERSIONS";
54591
54528
  var INSTALLABLE_PROVIDER_PACKAGES = {
54592
54529
  claude_cli: { npmPackage: "@anthropic-ai/claude-code", command: "claude", label: "Claude Code" },
@@ -54614,7 +54551,7 @@ function versionPolicy(npmPackage) {
54614
54551
  }
54615
54552
  function runNpmInstall(installSpec, env, timeoutMs) {
54616
54553
  return new Promise((resolve15) => {
54617
- const isWin = (0, import_node_os7.platform)() === "win32";
54554
+ const isWin = (0, import_node_os8.platform)() === "win32";
54618
54555
  let child;
54619
54556
  try {
54620
54557
  child = (0, import_node_child_process8.spawn)("npm", ["install", "-g", installSpec], {
@@ -54684,13 +54621,13 @@ function ensureProviderCliInstalled(backendKind, options) {
54684
54621
  }
54685
54622
 
54686
54623
  // src/core-agent.ts
54687
- var import_node_os9 = require("os");
54624
+ var import_node_os10 = require("os");
54688
54625
 
54689
54626
  // src/mcp-registration.ts
54690
54627
  var import_node_crypto6 = require("crypto");
54691
54628
  var import_node_fs14 = require("fs");
54692
- var import_node_os8 = require("os");
54693
- var import_node_path12 = require("path");
54629
+ var import_node_os9 = require("os");
54630
+ var import_node_path13 = require("path");
54694
54631
 
54695
54632
  // ../../node_modules/smol-toml/dist/error.js
54696
54633
  function getLineColFromPtr(string4, ptr) {
@@ -55631,7 +55568,7 @@ var inspectAlanMcpThroughProviderCli = async (backendKind, expectedUrl, home) =>
55631
55568
  return result;
55632
55569
  };
55633
55570
  async function waitForConfigLock(lockPath) {
55634
- (0, import_node_fs14.mkdirSync)((0, import_node_path12.dirname)(lockPath), { recursive: true });
55571
+ (0, import_node_fs14.mkdirSync)((0, import_node_path13.dirname)(lockPath), { recursive: true });
55635
55572
  const startedAt = Date.now();
55636
55573
  while (true) {
55637
55574
  try {
@@ -55712,8 +55649,8 @@ function atomicWriteManagedConfig(path2, content) {
55712
55649
  (0, import_node_fs14.rmSync)(pendingPath, { force: true });
55713
55650
  }
55714
55651
  }
55715
- async function configureAntigravityApiKeyMode(home = (0, import_node_os8.homedir)()) {
55716
- const path2 = (0, import_node_path12.join)(home, ".gemini", "antigravity-cli", "settings.json");
55652
+ async function configureAntigravityApiKeyMode(home = (0, import_node_os9.homedir)()) {
55653
+ const path2 = (0, import_node_path13.join)(home, ".gemini", "antigravity-cli", "settings.json");
55717
55654
  const releaseLock = await waitForConfigLock(`${path2}.alan-lock`);
55718
55655
  try {
55719
55656
  const existingContent = (0, import_node_fs14.existsSync)(path2) ? (0, import_node_fs14.readFileSync)(path2, "utf8") : "";
@@ -55726,13 +55663,13 @@ async function configureAntigravityApiKeyMode(home = (0, import_node_os8.homedir
55726
55663
  releaseLock();
55727
55664
  }
55728
55665
  }
55729
- async function ensureAlanMcpRegistered(backendKind, registration, home = (0, import_node_os8.homedir)(), inspectCli = inspectAlanMcpThroughProviderCli) {
55666
+ async function ensureAlanMcpRegistered(backendKind, registration, home = (0, import_node_os9.homedir)(), inspectCli = inspectAlanMcpThroughProviderCli) {
55730
55667
  try {
55731
55668
  const mcpServers = buildAlanMcpServers(registration);
55732
55669
  const files = alanMcpConfigFilesForBackend(backendKind, mcpServers, home);
55733
55670
  const paths = [];
55734
55671
  for (const file2 of files) {
55735
- (0, import_node_fs14.mkdirSync)((0, import_node_path12.dirname)(file2.path), { recursive: true });
55672
+ (0, import_node_fs14.mkdirSync)((0, import_node_path13.dirname)(file2.path), { recursive: true });
55736
55673
  const releaseLock = await waitForConfigLock(`${file2.path}.alan-lock`);
55737
55674
  try {
55738
55675
  const current = (0, import_node_fs14.existsSync)(file2.path) ? (0, import_node_fs14.readFileSync)(file2.path, "utf8") : null;
@@ -55797,7 +55734,7 @@ async function ensureAlanMcpRegistered(backendKind, registration, home = (0, imp
55797
55734
  return { ok: false, paths: [], error: err instanceof Error ? err.message : String(err) };
55798
55735
  }
55799
55736
  }
55800
- async function restoreStaticAlanMcp(backendKind, apiUrl, home = (0, import_node_os8.homedir)()) {
55737
+ async function restoreStaticAlanMcp(backendKind, apiUrl, home = (0, import_node_os9.homedir)()) {
55801
55738
  let url3;
55802
55739
  try {
55803
55740
  url3 = new URL("/mcp", apiUrl).toString();
@@ -55813,7 +55750,7 @@ async function restoreStaticAlanMcp(backendKind, apiUrl, home = (0, import_node_
55813
55750
  verification: { method: "file" }
55814
55751
  }));
55815
55752
  }
55816
- async function verifyAlanMcpRegistered(backendKind, home = (0, import_node_os8.homedir)(), inspectCli = inspectAlanMcpThroughProviderCli) {
55753
+ async function verifyAlanMcpRegistered(backendKind, home = (0, import_node_os9.homedir)(), inspectCli = inspectAlanMcpThroughProviderCli) {
55817
55754
  const files = alanMcpConfigFilesForBackend(backendKind, {}, home);
55818
55755
  const missing = files.map((f) => f.path).filter((p) => !(0, import_node_fs14.existsSync)(p));
55819
55756
  const presentEntries = files.map((file2) => ({
@@ -56125,7 +56062,7 @@ var CoreAgent = class _CoreAgent extends BaseMachineAgent {
56125
56062
  if (backendKind === "antigravity_cli" && augmented.GEMINI_API_KEY?.trim()) {
56126
56063
  await configureAntigravityApiKeyMode(augmented.HOME ?? augmented.USERPROFILE);
56127
56064
  }
56128
- if ((0, import_node_os9.platform)() !== "win32") {
56065
+ if ((0, import_node_os10.platform)() !== "win32") {
56129
56066
  const home = augmented.HOME ?? "/home/user";
56130
56067
  const extraPaths = [`${home}/.local/node/bin`, `${home}/.local/bin`];
56131
56068
  const separator = ":";
@@ -73174,24 +73111,24 @@ async function handleAgentExecute(ctx, payload) {
73174
73111
  let workspaceReadiness = inspectWorkspaceReadiness(workspaceRequired ? cwd : void 0);
73175
73112
  const expectedRepoUrls = [
73176
73113
  ...(payload.repoLocalPaths ?? []).filter(
73177
- (repo) => explicitWorkspacePath ? (0, import_node_path13.resolve)(repo.localPath) === (0, import_node_path13.resolve)(explicitWorkspacePath) : false
73114
+ (repo) => explicitWorkspacePath ? (0, import_node_path14.resolve)(repo.localPath) === (0, import_node_path14.resolve)(explicitWorkspacePath) : false
73178
73115
  ).map((repo) => repo.repoUrl),
73179
73116
  ...payload.localRepoUrls ?? []
73180
73117
  ];
73181
73118
  if (workspaceReadiness.code === "workspace_missing" && explicitWorkspacePath && !payload.worktreeInfo) {
73182
- const previousPath = (0, import_node_path13.resolve)(explicitWorkspacePath);
73119
+ const previousPath = (0, import_node_path14.resolve)(explicitWorkspacePath);
73183
73120
  const remembered = workspaceRelocations.get(previousPath);
73184
73121
  const rememberedPath = remembered?.canonicalPath;
73185
73122
  const relocated = rememberedPath && workspaceMatchesExpectedRepositories({
73186
73123
  workspacePath: rememberedPath,
73187
73124
  expectedRepoUrls
73188
- }) ? (0, import_node_path13.resolve)(rememberedPath) : discoverRelocatedWorkspace({
73125
+ }) ? (0, import_node_path14.resolve)(rememberedPath) : discoverRelocatedWorkspace({
73189
73126
  missingPath: explicitWorkspacePath,
73190
73127
  approvedWorkspacePaths: payload.approvedWorkspacePaths,
73191
73128
  expectedRepoUrls
73192
73129
  });
73193
73130
  if (relocated) {
73194
- if (!remembered || (0, import_node_path13.resolve)(remembered.canonicalPath) !== relocated) {
73131
+ if (!remembered || (0, import_node_path14.resolve)(remembered.canonicalPath) !== relocated) {
73195
73132
  workspaceRelocations.set(previousPath, {
73196
73133
  conversationId: payload.conversationId,
73197
73134
  runId: payload.runId,
@@ -73975,7 +73912,7 @@ function transcriptGraceExpired(observedAt, now, graceMs) {
73975
73912
  // src/native-hook-inbox.ts
73976
73913
  var import_node_crypto8 = require("crypto");
73977
73914
  var import_node_fs16 = require("fs");
73978
- var import_node_path14 = require("path");
73915
+ var import_node_path15 = require("path");
73979
73916
  var INBOX_FILE_VERSION = 1;
73980
73917
  var DEFAULT_MAX_BYTES = 64 * 1024 * 1024;
73981
73918
  var DEFAULT_MAX_ENTRIES = 1e4;
@@ -74022,8 +73959,8 @@ var EncryptedNativeHookInbox = class {
74022
73959
  };
74023
73960
  const monotonic = process.hrtime.bigint().toString().padStart(20, "0");
74024
73961
  const prefix = `${String(Date.now()).padStart(13, "0")}-${monotonic}-${envelope.eventId}`;
74025
- const temporaryPath = (0, import_node_path14.join)(this.path, `.${prefix}-${(0, import_node_crypto8.randomUUID)()}.tmp`);
74026
- const finalPath = (0, import_node_path14.join)(this.path, `${prefix}.event`);
73962
+ const temporaryPath = (0, import_node_path15.join)(this.path, `.${prefix}-${(0, import_node_crypto8.randomUUID)()}.tmp`);
73963
+ const finalPath = (0, import_node_path15.join)(this.path, `${prefix}.event`);
74027
73964
  (0, import_node_fs16.writeFileSync)(temporaryPath, JSON.stringify(file2), { mode: 384, flag: "wx" });
74028
73965
  (0, import_node_fs16.chmodSync)(temporaryPath, 384);
74029
73966
  (0, import_node_fs16.renameSync)(temporaryPath, finalPath);
@@ -74041,9 +73978,9 @@ var EncryptedNativeHookInbox = class {
74041
73978
  const result = { attempted: 0, acknowledged: 0, deferred: 0 };
74042
73979
  const names = encryptedEntryNames(this.path).filter((name) => name.endsWith(".event")).slice(0, Math.max(0, limit));
74043
73980
  for (const name of names) {
74044
- const sourcePath = (0, import_node_path14.join)(this.path, name);
73981
+ const sourcePath = (0, import_node_path15.join)(this.path, name);
74045
73982
  const claimedName = `${name.slice(0, -".event".length)}.processing-${(0, import_node_crypto8.randomUUID)()}`;
74046
- const claimedPath = (0, import_node_path14.join)(this.path, claimedName);
73983
+ const claimedPath = (0, import_node_path15.join)(this.path, claimedName);
74047
73984
  try {
74048
73985
  (0, import_node_fs16.renameSync)(sourcePath, claimedPath);
74049
73986
  } catch {
@@ -74090,14 +74027,14 @@ var EncryptedNativeHookInbox = class {
74090
74027
  if (name.endsWith(".quarantine")) continue;
74091
74028
  const marker = name.indexOf(".processing-");
74092
74029
  if (marker === -1) continue;
74093
- const claimedPath = (0, import_node_path14.join)(this.path, name);
74094
- const eventPath = (0, import_node_path14.join)(this.path, `${name.slice(0, marker)}.event`);
74030
+ const claimedPath = (0, import_node_path15.join)(this.path, name);
74031
+ const eventPath = (0, import_node_path15.join)(this.path, `${name.slice(0, marker)}.event`);
74095
74032
  if ((0, import_node_fs16.existsSync)(eventPath)) (0, import_node_fs16.rmSync)(claimedPath, { force: true });
74096
74033
  else (0, import_node_fs16.renameSync)(claimedPath, eventPath);
74097
74034
  }
74098
74035
  }
74099
74036
  enforceBounds() {
74100
- const entries = encryptedEntryNames(this.path).filter((name) => name.endsWith(".event")).map((name) => ({ name, bytes: (0, import_node_fs16.statSync)((0, import_node_path14.join)(this.path, name)).size }));
74037
+ const entries = encryptedEntryNames(this.path).filter((name) => name.endsWith(".event")).map((name) => ({ name, bytes: (0, import_node_fs16.statSync)((0, import_node_path15.join)(this.path, name)).size }));
74101
74038
  const totalBytes = entries.reduce((sum, entry) => sum + entry.bytes, 0);
74102
74039
  if (entries.length > this.maxEntries || totalBytes > this.maxBytes) {
74103
74040
  throw new Error(
@@ -74107,13 +74044,13 @@ var EncryptedNativeHookInbox = class {
74107
74044
  }
74108
74045
  };
74109
74046
  function nativeHookInboxPath(configPath) {
74110
- return (0, import_node_path14.join)((0, import_node_path14.dirname)(configPath), "native-hook-inbox");
74047
+ return (0, import_node_path15.join)((0, import_node_path15.dirname)(configPath), "native-hook-inbox");
74111
74048
  }
74112
74049
 
74113
74050
  // src/native-transcript-cursor.ts
74114
74051
  var import_node_crypto9 = require("crypto");
74115
74052
  var import_node_fs17 = require("fs");
74116
- var import_node_path15 = require("path");
74053
+ var import_node_path16 = require("path");
74117
74054
  var CURSOR_FILE_VERSION = 1;
74118
74055
  function nativeTranscriptCursorKey(input2) {
74119
74056
  return (0, import_node_crypto9.createHash)("sha256").update(`${input2.provider}\0${input2.externalSessionId}\0${input2.transcriptPath}`).digest("base64url");
@@ -74144,7 +74081,7 @@ var NativeTranscriptCursorStore = class {
74144
74081
  return parsed.entries;
74145
74082
  }
74146
74083
  persist() {
74147
- (0, import_node_fs17.mkdirSync)((0, import_node_path15.dirname)(this.path), { recursive: true, mode: 448 });
74084
+ (0, import_node_fs17.mkdirSync)((0, import_node_path16.dirname)(this.path), { recursive: true, mode: 448 });
74148
74085
  const pendingPath = `${this.path}.pending-${process.pid}-${(0, import_node_crypto9.randomBytes)(6).toString("hex")}`;
74149
74086
  try {
74150
74087
  (0, import_node_fs17.writeFileSync)(
@@ -74550,7 +74487,7 @@ var ObservableMap = class extends Map {
74550
74487
 
74551
74488
  // src/run-journal.ts
74552
74489
  var import_node_fs19 = require("fs");
74553
- var import_node_path16 = require("path");
74490
+ var import_node_path17 = require("path");
74554
74491
  var JOURNAL_VERSION = 1;
74555
74492
  var INTERRUPTED_ENTRY_TTL_MS = 24 * 60 * 6e4;
74556
74493
  function isEntry(value2) {
@@ -74694,7 +74631,7 @@ var RuntimeRunJournal = class {
74694
74631
  }
74695
74632
  persist() {
74696
74633
  const pendingPath = `${this.path}.pending`;
74697
- (0, import_node_fs19.mkdirSync)((0, import_node_path16.dirname)(this.path), { recursive: true });
74634
+ (0, import_node_fs19.mkdirSync)((0, import_node_path17.dirname)(this.path), { recursive: true });
74698
74635
  try {
74699
74636
  (0, import_node_fs19.writeFileSync)(
74700
74637
  pendingPath,
@@ -74735,13 +74672,13 @@ var RunStartGate = class {
74735
74672
  var import_node_buffer2 = require("buffer");
74736
74673
  var import_node_crypto12 = require("crypto");
74737
74674
  var import_promises2 = require("fs/promises");
74738
- var import_node_path18 = __toESM(require("path"), 1);
74675
+ var import_node_path19 = __toESM(require("path"), 1);
74739
74676
 
74740
74677
  // ../shared/dist/node/skill-package.js
74741
74678
  var import_node_buffer = require("buffer");
74742
74679
  var import_node_crypto11 = require("crypto");
74743
74680
  var import_promises = require("fs/promises");
74744
- var import_node_path17 = require("path");
74681
+ var import_node_path18 = require("path");
74745
74682
  var import_yaml = __toESM(require_dist2(), 1);
74746
74683
 
74747
74684
  // ../shared/dist/skills/domain.js
@@ -75165,7 +75102,7 @@ async function inspectSkillPackage(packageRoot, options = {}) {
75165
75102
  }
75166
75103
  const inspectedFiles = await Promise.all(files.map(readPackageFile));
75167
75104
  inspectedFiles.sort(comparePackageFiles);
75168
- const parsedMetadata = parseSkillMetadata(inspectedFiles.find((file2) => file2.manifest.path === "SKILL.md")?.bytes, options.expectedName === void 0 ? (0, import_node_path17.basename)(root) : options.expectedName);
75105
+ const parsedMetadata = parseSkillMetadata(inspectedFiles.find((file2) => file2.manifest.path === "SKILL.md")?.bytes, options.expectedName === void 0 ? (0, import_node_path18.basename)(root) : options.expectedName);
75169
75106
  const manifestFiles = inspectedFiles.map((file2) => file2.manifest);
75170
75107
  const diagnostics = [
75171
75108
  ...parsedMetadata.conformance,
@@ -75189,7 +75126,7 @@ async function readSkillPackageFile(packageRoot, path2, expectedSha256) {
75189
75126
  if (!normalizedPath || normalizedPath !== path2 || normalizedPath.includes("\\") || components.some((component) => !component || component === "." || component === "..")) {
75190
75127
  throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${path2}`, path2);
75191
75128
  }
75192
- const absolutePath = await (0, import_promises.realpath)((0, import_node_path17.resolve)(root, ...components)).catch(() => null);
75129
+ const absolutePath = await (0, import_promises.realpath)((0, import_node_path18.resolve)(root, ...components)).catch(() => null);
75193
75130
  if (!absolutePath || normalizeRelativePath(root, absolutePath) !== normalizedPath) {
75194
75131
  throw new SkillPackageError("INVALID_PATH", `Skill package file was not found: ${path2}`, path2);
75195
75132
  }
@@ -75210,7 +75147,7 @@ async function readSkillPackageFile(packageRoot, path2, expectedSha256) {
75210
75147
  return { file: read.manifest, bytes: read.bytes };
75211
75148
  }
75212
75149
  async function requirePackageRoot(packageRoot) {
75213
- const root = await (0, import_promises.realpath)((0, import_node_path17.resolve)(packageRoot)).catch(() => null);
75150
+ const root = await (0, import_promises.realpath)((0, import_node_path18.resolve)(packageRoot)).catch(() => null);
75214
75151
  if (!root) {
75215
75152
  throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
75216
75153
  }
@@ -75236,7 +75173,7 @@ async function walkPackage(root, ignoredPaths) {
75236
75173
  async function walkDirectory(directory) {
75237
75174
  const entries = await (0, import_promises.readdir)(directory, { withFileTypes: true });
75238
75175
  for (const entry of entries) {
75239
- const absolutePath = (0, import_node_path17.resolve)(directory, entry.name);
75176
+ const absolutePath = (0, import_node_path18.resolve)(directory, entry.name);
75240
75177
  const normalizedPath = normalizeRelativePath(root, absolutePath);
75241
75178
  if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored))
75242
75179
  continue;
@@ -75303,12 +75240,12 @@ function globToRegExp(pattern) {
75303
75240
  return new RegExp(`${source}(?:/.*)?$`);
75304
75241
  }
75305
75242
  function normalizeRelativePath(root, absolutePath) {
75306
- const nativeRelativePath = (0, import_node_path17.relative)(root, absolutePath);
75307
- if (!nativeRelativePath || nativeRelativePath.startsWith(`..${import_node_path17.sep}`) || nativeRelativePath === "..") {
75243
+ const nativeRelativePath = (0, import_node_path18.relative)(root, absolutePath);
75244
+ if (!nativeRelativePath || nativeRelativePath.startsWith(`..${import_node_path18.sep}`) || nativeRelativePath === "..") {
75308
75245
  throw new SkillPackageError("INVALID_PATH", "Skill package path escapes its root");
75309
75246
  }
75310
- const normalized = nativeRelativePath.split(import_node_path17.sep).join("/").normalize("NFC");
75311
- if (normalized.includes("\0") || normalized.includes("\uFFFD") || import_node_path17.posix.isAbsolute(normalized)) {
75247
+ const normalized = nativeRelativePath.split(import_node_path18.sep).join("/").normalize("NFC");
75248
+ if (normalized.includes("\0") || normalized.includes("\uFFFD") || import_node_path18.posix.isAbsolute(normalized)) {
75312
75249
  throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${normalized}`);
75313
75250
  }
75314
75251
  return normalized;
@@ -75343,7 +75280,7 @@ function requireSafeFile(path2, size, normalizedPaths) {
75343
75280
  }
75344
75281
  }
75345
75282
  function isSecretPath(path2) {
75346
- const name = import_node_path17.posix.basename(path2).toLowerCase();
75283
+ const name = import_node_path18.posix.basename(path2).toLowerCase();
75347
75284
  if (SECRET_BASENAMES.has(name) || name.startsWith(".env."))
75348
75285
  return true;
75349
75286
  return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
@@ -75371,12 +75308,12 @@ function classifyFileKind(path2) {
75371
75308
  return "reference";
75372
75309
  if (path2.startsWith("assets/"))
75373
75310
  return "asset";
75374
- if (/^(?:licen[cs]e|copying|notice)(?:\.|$)/i.test(import_node_path17.posix.basename(path2)))
75311
+ if (/^(?:licen[cs]e|copying|notice)(?:\.|$)/i.test(import_node_path18.posix.basename(path2)))
75375
75312
  return "license";
75376
75313
  return "other";
75377
75314
  }
75378
75315
  function classifyPreview(path2, bytes) {
75379
- const extension = import_node_path17.posix.extname(path2).toLowerCase();
75316
+ const extension = import_node_path18.posix.extname(path2).toLowerCase();
75380
75317
  if (IMAGE_EXTENSIONS.has(extension))
75381
75318
  return "image";
75382
75319
  if (bytes.includes(0))
@@ -75480,7 +75417,7 @@ function normalizePackageReference(value2) {
75480
75417
  const withoutSuffix = trimmed.split(/[?#]/, 1)[0];
75481
75418
  if (!withoutSuffix)
75482
75419
  return null;
75483
- const normalized = import_node_path17.posix.normalize(withoutSuffix).replace(/^\.\//, "").normalize("NFC");
75420
+ const normalized = import_node_path18.posix.normalize(withoutSuffix).replace(/^\.\//, "").normalize("NFC");
75484
75421
  if (normalized === ".." || normalized.startsWith("../"))
75485
75422
  return null;
75486
75423
  return normalized;
@@ -75717,9 +75654,9 @@ var LocalSkillSource = class {
75717
75654
  */
75718
75655
  async scanRootAsPackage(resolvedRoot, ignoredPaths, mode) {
75719
75656
  const directory = resolvedRoot.directory;
75720
- if (!await pathExists((0, import_node_path18.join)(directory, "SKILL.md"))) return null;
75657
+ if (!await pathExists((0, import_node_path19.join)(directory, "SKILL.md"))) return null;
75721
75658
  const canonicalRoot = await (0, import_promises2.realpath)(directory).catch(() => directory);
75722
- const name = import_node_path18.default.basename(canonicalRoot);
75659
+ const name = import_node_path19.default.basename(canonicalRoot);
75723
75660
  try {
75724
75661
  const fingerprint = await fingerprintPackage(canonicalRoot);
75725
75662
  const ignoreSignature = JSON.stringify(ignoredPaths);
@@ -75789,7 +75726,7 @@ var LocalSkillSource = class {
75789
75726
  );
75790
75727
  for (const entry of entries) {
75791
75728
  if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
75792
- const candidatePath = (0, import_node_path18.join)(resolvedRoot.directory, entry.name);
75729
+ const candidatePath = (0, import_node_path19.join)(resolvedRoot.directory, entry.name);
75793
75730
  const canonicalPath = await (0, import_promises2.realpath)(candidatePath).catch(() => null);
75794
75731
  if (!canonicalPath) {
75795
75732
  diagnostics.push({
@@ -75855,7 +75792,7 @@ async function fingerprintPackage(root) {
75855
75792
  entries.sort((left, right) => import_node_buffer2.Buffer.compare(import_node_buffer2.Buffer.from(left.name), import_node_buffer2.Buffer.from(right.name)));
75856
75793
  for (const entry of entries) {
75857
75794
  const path2 = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
75858
- const absolutePath = (0, import_node_path18.join)(directory, entry.name);
75795
+ const absolutePath = (0, import_node_path19.join)(directory, entry.name);
75859
75796
  const metadata = await (0, import_promises2.lstat)(absolutePath);
75860
75797
  hash2.update(path2.normalize("NFC")).update("\0").update(
75861
75798
  entry.isDirectory() ? "d" : entry.isFile() ? "f" : entry.isSymbolicLink() ? "l" : "o"
@@ -75880,12 +75817,12 @@ async function canonicalDirectories(directories) {
75880
75817
  return [...new Set(canonical)];
75881
75818
  }
75882
75819
  function isWithinDirectory(parent, candidate) {
75883
- const path2 = (0, import_node_path18.relative)(parent, candidate);
75884
- return path2 !== ".." && !path2.startsWith(`..${import_node_path18.sep}`) && !(0, import_node_path18.isAbsolute)(path2);
75820
+ const path2 = (0, import_node_path19.relative)(parent, candidate);
75821
+ return path2 !== ".." && !path2.startsWith(`..${import_node_path19.sep}`) && !(0, import_node_path19.isAbsolute)(path2);
75885
75822
  }
75886
75823
  async function loadSkillSourceConfig(homeDirectory2) {
75887
- const configDirectory = (0, import_node_path18.join)(homeDirectory2, ".alan");
75888
- const configPath = (0, import_node_path18.join)(configDirectory, "config.toml");
75824
+ const configDirectory = (0, import_node_path19.join)(homeDirectory2, ".alan");
75825
+ const configPath = (0, import_node_path19.join)(configDirectory, "config.toml");
75889
75826
  await (0, import_promises2.mkdir)(configDirectory, { recursive: true, mode: 448 });
75890
75827
  let created = false;
75891
75828
  try {
@@ -75919,7 +75856,7 @@ async function resolveSkillScanInput(homeDirectory2, declared) {
75919
75856
  }
75920
75857
  const { config: config2 } = loaded;
75921
75858
  if (!config2.enabled) return { ...declared, roots: [], ignoredPaths: config2.ignoredPaths };
75922
- const draftsPath = (0, import_node_path18.resolve)((0, import_node_path18.join)(homeDirectory2, ".alan", "skill-sources"));
75859
+ const draftsPath = (0, import_node_path19.resolve)((0, import_node_path19.join)(homeDirectory2, ".alan", "skill-sources"));
75923
75860
  const enabledProviders = new Set(declared.enabledProviderKinds ?? []);
75924
75861
  const configured = [];
75925
75862
  for (const source of config2.sources) {
@@ -75927,7 +75864,7 @@ async function resolveSkillScanInput(homeDirectory2, declared) {
75927
75864
  continue;
75928
75865
  }
75929
75866
  configured.push(
75930
- (0, import_node_path18.resolve)(source.path) === draftsPath ? { kind: "drafts", path: source.path, label: "Alan drafts" } : {
75867
+ (0, import_node_path19.resolve)(source.path) === draftsPath ? { kind: "drafts", path: source.path, label: "Alan drafts" } : {
75931
75868
  kind: "configured",
75932
75869
  declarationId: source.declarationId,
75933
75870
  path: source.path,
@@ -75974,7 +75911,7 @@ function parseSkillSourceConfig(content, homeDirectory2) {
75974
75911
  value2.providers,
75975
75912
  `skills.sources[${index}].providers`
75976
75913
  );
75977
- const relativeDirectory = import_node_path18.default.relative(homeDirectory2, sourcePath);
75914
+ const relativeDirectory = import_node_path19.default.relative(homeDirectory2, sourcePath);
75978
75915
  const inferredProviders = providerKindsForUserDirectory(relativeDirectory);
75979
75916
  const declaredProviders = value2.providers === void 0 ? inferredProviders : [...new Set(explicitProviders.map((provider) => provider.trim()).filter(Boolean))];
75980
75917
  const stale = staleCodexDeclaration(relativeDirectory, label, declaredProviders);
@@ -76004,7 +75941,7 @@ function requiredSourceId(value2, field) {
76004
75941
  }
76005
75942
  return value2;
76006
75943
  }
76007
- function resolveSkillSourcePath(sourcePath, homeDirectory2, pathApi = import_node_path18.default) {
75944
+ function resolveSkillSourcePath(sourcePath, homeDirectory2, pathApi = import_node_path19.default) {
76008
75945
  const trimmed = sourcePath.trim();
76009
75946
  if (trimmed === "~") return pathApi.resolve(homeDirectory2);
76010
75947
  if (trimmed.startsWith("~/") || trimmed.startsWith("~\\")) {
@@ -76039,7 +75976,7 @@ function resolveScanRoots(roots, enabledProviderKinds) {
76039
75976
  ).entries()) {
76040
75977
  resolved.push({
76041
75978
  root,
76042
- directory: (0, import_node_path18.join)(root.path, relativeDirectory),
75979
+ directory: (0, import_node_path19.join)(root.path, relativeDirectory),
76043
75980
  order: `1:${root.repositoryId}:${String(index).padStart(2, "0")}`
76044
75981
  });
76045
75982
  }
@@ -76098,7 +76035,7 @@ async function pathExists(candidate) {
76098
76035
  }
76099
76036
  async function hasManagedMarker(directory) {
76100
76037
  try {
76101
- await (0, import_promises2.access)((0, import_node_path18.join)(directory, ".alan-managed.json"));
76038
+ await (0, import_promises2.access)((0, import_node_path19.join)(directory, ".alan-managed.json"));
76102
76039
  return true;
76103
76040
  } catch {
76104
76041
  return false;
@@ -76267,12 +76204,12 @@ var RuntimeSkillCoordinator = class {
76267
76204
  var import_node_buffer5 = require("buffer");
76268
76205
  var import_node_crypto15 = require("crypto");
76269
76206
  var import_promises5 = require("fs/promises");
76270
- var import_node_path21 = require("path");
76207
+ var import_node_path22 = require("path");
76271
76208
 
76272
76209
  // src/skills/managed-skill-store.ts
76273
76210
  var import_node_crypto13 = require("crypto");
76274
76211
  var import_promises3 = require("fs/promises");
76275
- var import_node_path19 = require("path");
76212
+ var import_node_path20 = require("path");
76276
76213
  var EMPTY_STATE = {
76277
76214
  version: 1,
76278
76215
  sources: {},
@@ -76291,7 +76228,7 @@ var ManagedSkillStore = class _ManagedSkillStore {
76291
76228
  static async open(baseDirectory) {
76292
76229
  await (0, import_promises3.mkdir)(baseDirectory, { recursive: true, mode: 448 });
76293
76230
  try {
76294
- const parsed = JSON.parse(await (0, import_promises3.readFile)((0, import_node_path19.join)(baseDirectory, "state.json"), "utf8"));
76231
+ const parsed = JSON.parse(await (0, import_promises3.readFile)((0, import_node_path20.join)(baseDirectory, "state.json"), "utf8"));
76295
76232
  return new _ManagedSkillStore(baseDirectory, parseState(parsed), "verified");
76296
76233
  } catch (error61) {
76297
76234
  if (isMissingPath2(error61)) {
@@ -76390,8 +76327,8 @@ var ManagedSkillStore = class _ManagedSkillStore {
76390
76327
  this.canRemoveManagedFiles = true;
76391
76328
  }
76392
76329
  async persist() {
76393
- const statePath = (0, import_node_path19.join)(this.baseDirectory, "state.json");
76394
- const pendingPath = (0, import_node_path19.join)(
76330
+ const statePath = (0, import_node_path20.join)(this.baseDirectory, "state.json");
76331
+ const pendingPath = (0, import_node_path20.join)(
76395
76332
  this.baseDirectory,
76396
76333
  `.state.json.pending-${process.pid}-${(0, import_node_crypto13.randomBytes)(6).toString("hex")}`
76397
76334
  );
@@ -76476,7 +76413,7 @@ function isMissingPath2(error61) {
76476
76413
  var import_node_buffer3 = require("buffer");
76477
76414
  var import_node_crypto14 = require("crypto");
76478
76415
  var import_promises4 = require("fs/promises");
76479
- var import_node_path20 = require("path");
76416
+ var import_node_path21 = require("path");
76480
76417
  var import_node_stream = require("stream");
76481
76418
  var import_node_zlib = require("zlib");
76482
76419
  var import_tar_stream = __toESM(require_tar_stream(), 1);
@@ -76485,7 +76422,7 @@ async function createSkillBundle(packageRoot) {
76485
76422
  const archive = (0, import_tar_stream.pack)();
76486
76423
  const tarPromise = collectStream(archive);
76487
76424
  for (const file2 of before.files) {
76488
- const bytes2 = await (0, import_promises4.readFile)((0, import_node_path20.join)(packageRoot, ...file2.path.split("/")));
76425
+ const bytes2 = await (0, import_promises4.readFile)((0, import_node_path21.join)(packageRoot, ...file2.path.split("/")));
76489
76426
  await addArchiveEntry(archive, {
76490
76427
  name: file2.path,
76491
76428
  type: "file",
@@ -76600,13 +76537,13 @@ async function extractEntry(header, stream, destination, limits) {
76600
76537
  if (bytes.byteLength !== declaredSize) {
76601
76538
  throw new Error(`Skill archive file size is invalid: ${path2}`);
76602
76539
  }
76603
- const outputPath = (0, import_node_path20.join)(destination, ...path2.split("/"));
76604
- await (0, import_promises4.mkdir)((0, import_node_path20.dirname)(outputPath), { recursive: true, mode: 448 });
76540
+ const outputPath = (0, import_node_path21.join)(destination, ...path2.split("/"));
76541
+ await (0, import_promises4.mkdir)((0, import_node_path21.dirname)(outputPath), { recursive: true, mode: 448 });
76605
76542
  await (0, import_promises4.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
76606
76543
  }
76607
76544
  function requireSafeArchivePath(value2) {
76608
76545
  const normalized = value2.replaceAll("\\", "/").normalize("NFC");
76609
- if (!normalized || normalized.startsWith("/") || normalized.includes("\0") || import_node_path20.posix.normalize(normalized) !== normalized || normalized === ".." || normalized.startsWith("../")) {
76546
+ if (!normalized || normalized.startsWith("/") || normalized.includes("\0") || import_node_path21.posix.normalize(normalized) !== normalized || normalized === ".." || normalized.startsWith("../")) {
76610
76547
  throw new Error(`Skill archive contains an unsafe path: ${value2}`);
76611
76548
  }
76612
76549
  return normalized;
@@ -76685,14 +76622,14 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
76685
76622
  }
76686
76623
  reconcileTail = Promise.resolve();
76687
76624
  static async open(options) {
76688
- const skillsStateDirectory = (0, import_node_path21.join)(options.homeDirectory, ".alan", "skills");
76689
- const managedSkillsDirectory = (0, import_node_path21.join)(options.homeDirectory, ".agents", "skills");
76625
+ const skillsStateDirectory = (0, import_node_path22.join)(options.homeDirectory, ".alan", "skills");
76626
+ const managedSkillsDirectory = (0, import_node_path22.join)(options.homeDirectory, ".agents", "skills");
76690
76627
  const store = await ManagedSkillStore.open(skillsStateDirectory);
76691
76628
  return new _RuntimeSkillManager(
76692
76629
  skillsStateDirectory,
76693
76630
  managedSkillsDirectory,
76694
- (0, import_node_path21.join)(options.homeDirectory, ".claude", "skills"),
76695
- (0, import_node_path21.join)(options.homeDirectory, ".alan", "sync-manifest.json"),
76631
+ (0, import_node_path22.join)(options.homeDirectory, ".claude", "skills"),
76632
+ (0, import_node_path22.join)(options.homeDirectory, ".alan", "sync-manifest.json"),
76696
76633
  store,
76697
76634
  options.downloadBundle ?? downloadBundleWithFetch,
76698
76635
  options.localSource ?? new LocalSkillSource(),
@@ -76851,7 +76788,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
76851
76788
  if (!runtimeDirectory) {
76852
76789
  throw new Error("Selected Skill version is not installed on this runtime");
76853
76790
  }
76854
- const packageDirectory = (0, import_node_path21.join)(this.managedSkillsDirectory, runtimeDirectory);
76791
+ const packageDirectory = (0, import_node_path22.join)(this.managedSkillsDirectory, runtimeDirectory);
76855
76792
  const marker = await readMarker(packageDirectory);
76856
76793
  if (!marker || marker.skillId !== invocation.skillId || marker.versionId !== invocation.versionId) {
76857
76794
  throw new Error("Selected Skill projection is missing or no longer owned by Alan");
@@ -76865,11 +76802,11 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
76865
76802
  async reconcileUnlocked(manifest) {
76866
76803
  const desired = desiredSkillManifestSchema.parse(manifest);
76867
76804
  await (0, import_promises5.mkdir)(this.managedSkillsDirectory, { recursive: true, mode: 448 });
76868
- await (0, import_promises5.mkdir)((0, import_node_path21.join)(this.skillsStateDirectory, "cache", "sha256"), {
76805
+ await (0, import_promises5.mkdir)((0, import_node_path22.join)(this.skillsStateDirectory, "cache", "sha256"), {
76869
76806
  recursive: true,
76870
76807
  mode: 448
76871
76808
  });
76872
- await (0, import_promises5.mkdir)((0, import_node_path21.join)(this.skillsStateDirectory, "tmp"), { recursive: true, mode: 448 });
76809
+ await (0, import_promises5.mkdir)((0, import_node_path22.join)(this.skillsStateDirectory, "tmp"), { recursive: true, mode: 448 });
76873
76810
  const results = [];
76874
76811
  const nextProjections = {};
76875
76812
  for (const entry of desired.skills) {
@@ -76920,7 +76857,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
76920
76857
  };
76921
76858
  }
76922
76859
  async reuseCurrentProjection(entry) {
76923
- const destination = (0, import_node_path21.join)(this.managedSkillsDirectory, entry.runtimeDirectory);
76860
+ const destination = (0, import_node_path22.join)(this.managedSkillsDirectory, entry.runtimeDirectory);
76924
76861
  const marker = await readMarker(destination);
76925
76862
  if (marker?.skillId !== entry.skillId || marker.versionId !== entry.versionId || marker.contentHash !== entry.contentHash || !await packageMatches(destination, entry.contentHash)) {
76926
76863
  return null;
@@ -76929,19 +76866,19 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
76929
76866
  return entry.contentHash;
76930
76867
  }
76931
76868
  async adoptLegacyProjection(entry) {
76932
- const destination = (0, import_node_path21.join)(this.managedSkillsDirectory, entry.runtimeDirectory);
76869
+ const destination = (0, import_node_path22.join)(this.managedSkillsDirectory, entry.runtimeDirectory);
76933
76870
  if (await pathExists2(destination)) return;
76934
76871
  const manifest = await readLegacyManifest(this.legacyManifestPath);
76935
76872
  const legacy = manifest?.skills[entry.slug];
76936
76873
  if (!legacy) return;
76937
- const source = (0, import_node_path21.join)(this.managedSkillsDirectory, entry.slug);
76874
+ const source = (0, import_node_path22.join)(this.managedSkillsDirectory, entry.slug);
76938
76875
  if (!await legacyFileMatches(source, legacy.hash) || !await packageMatches(source, entry.contentHash)) {
76939
76876
  return;
76940
76877
  }
76941
76878
  await (0, import_promises5.rename)(source, destination);
76942
76879
  try {
76943
76880
  await (0, import_promises5.writeFile)(
76944
- (0, import_node_path21.join)(destination, ".alan-managed.json"),
76881
+ (0, import_node_path22.join)(destination, ".alan-managed.json"),
76945
76882
  `${JSON.stringify(markerFor(entry), null, 2)}
76946
76883
  `,
76947
76884
  { encoding: "utf8", flag: "wx", mode: 384 }
@@ -76950,19 +76887,19 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
76950
76887
  await (0, import_promises5.rename)(destination, source).catch(() => void 0);
76951
76888
  throw error61;
76952
76889
  }
76953
- await removeExactLegacySkill((0, import_node_path21.join)(this.compatibilitySkillsDirectory, entry.slug), legacy.hash);
76890
+ await removeExactLegacySkill((0, import_node_path22.join)(this.compatibilitySkillsDirectory, entry.slug), legacy.hash);
76954
76891
  }
76955
76892
  async retireLegacySyncManifest() {
76956
76893
  const manifest = await readLegacyManifest(this.legacyManifestPath);
76957
76894
  if (!manifest) return;
76958
76895
  for (const [command, entry] of Object.entries(manifest.skills)) {
76959
- await removeExactLegacySkill((0, import_node_path21.join)(this.managedSkillsDirectory, command), entry.hash);
76960
- await removeExactLegacySkill((0, import_node_path21.join)(this.compatibilitySkillsDirectory, command), entry.hash);
76896
+ await removeExactLegacySkill((0, import_node_path22.join)(this.managedSkillsDirectory, command), entry.hash);
76897
+ await removeExactLegacySkill((0, import_node_path22.join)(this.compatibilitySkillsDirectory, command), entry.hash);
76961
76898
  }
76962
76899
  await (0, import_promises5.rm)(this.legacyManifestPath, { force: true });
76963
76900
  }
76964
76901
  async ensureCached(entry) {
76965
- const cacheDirectory = (0, import_node_path21.join)(
76902
+ const cacheDirectory = (0, import_node_path22.join)(
76966
76903
  this.skillsStateDirectory,
76967
76904
  "cache",
76968
76905
  "sha256",
@@ -76976,7 +76913,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
76976
76913
  `Downloaded Skill bundle length ${bytes.byteLength} does not match ${entry.compressedBytes}`
76977
76914
  );
76978
76915
  }
76979
- const pendingDirectory = (0, import_node_path21.join)(
76916
+ const pendingDirectory = (0, import_node_path22.join)(
76980
76917
  this.skillsStateDirectory,
76981
76918
  "tmp",
76982
76919
  `cache-${process.pid}-${(0, import_node_crypto15.randomBytes)(8).toString("hex")}`
@@ -76997,22 +76934,22 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
76997
76934
  return cacheDirectory;
76998
76935
  }
76999
76936
  async project(entry, cacheDirectory) {
77000
- const destination = (0, import_node_path21.join)(this.managedSkillsDirectory, entry.runtimeDirectory);
76937
+ const destination = (0, import_node_path22.join)(this.managedSkillsDirectory, entry.runtimeDirectory);
77001
76938
  const existing = await readMarker(destination);
77002
76939
  if (existing?.skillId === entry.skillId && existing.versionId === entry.versionId && existing.contentHash === entry.contentHash && await packageMatches(destination, entry.contentHash)) {
77003
76940
  await this.ensureCompatibilityProjection(entry, destination);
77004
76941
  return entry.contentHash;
77005
76942
  }
77006
76943
  const suffix = `${process.pid}-${(0, import_node_crypto15.randomBytes)(8).toString("hex")}`;
77007
- const pending = (0, import_node_path21.join)(this.managedSkillsDirectory, `.pending-${suffix}`);
77008
- const backup = (0, import_node_path21.join)(this.managedSkillsDirectory, `.backup-${suffix}`);
76944
+ const pending = (0, import_node_path22.join)(this.managedSkillsDirectory, `.pending-${suffix}`);
76945
+ const backup = (0, import_node_path22.join)(this.managedSkillsDirectory, `.backup-${suffix}`);
77009
76946
  let movedExisting = false;
77010
76947
  let installedPending = false;
77011
76948
  let completed = false;
77012
76949
  try {
77013
76950
  await (0, import_promises5.cp)(cacheDirectory, pending, { recursive: true, errorOnExist: true, force: false });
77014
76951
  await (0, import_promises5.writeFile)(
77015
- (0, import_node_path21.join)(pending, ".alan-managed.json"),
76952
+ (0, import_node_path22.join)(pending, ".alan-managed.json"),
77016
76953
  `${JSON.stringify(markerFor(entry), null, 2)}
77017
76954
  `,
77018
76955
  { encoding: "utf8", flag: "wx", mode: 384 }
@@ -77053,7 +76990,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
77053
76990
  }
77054
76991
  }
77055
76992
  async requireReplaceable(entry) {
77056
- const destination = (0, import_node_path21.join)(this.managedSkillsDirectory, entry.runtimeDirectory);
76993
+ const destination = (0, import_node_path22.join)(this.managedSkillsDirectory, entry.runtimeDirectory);
77057
76994
  if (!await pathExists2(destination)) return;
77058
76995
  const marker = await readMarker(destination);
77059
76996
  if (!marker) throw unmanagedPathConflict(entry.runtimeDirectory);
@@ -77070,8 +77007,8 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
77070
77007
  if (!this.store.inspect().canRemoveManagedFiles) return failures;
77071
77008
  for (const [runtimeDirectory, recorded] of Object.entries(this.store.projections())) {
77072
77009
  if (desired[runtimeDirectory]) continue;
77073
- const destination = (0, import_node_path21.join)(this.managedSkillsDirectory, runtimeDirectory);
77074
- const compatibility = (0, import_node_path21.join)(this.compatibilitySkillsDirectory, runtimeDirectory);
77010
+ const destination = (0, import_node_path22.join)(this.managedSkillsDirectory, runtimeDirectory);
77011
+ const compatibility = (0, import_node_path22.join)(this.compatibilitySkillsDirectory, runtimeDirectory);
77075
77012
  const marker = await readMarker(destination);
77076
77013
  if (!await pathExists2(destination)) continue;
77077
77014
  if (marker && markerMatchesProjection(marker, recorded)) {
@@ -77102,7 +77039,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
77102
77039
  }
77103
77040
  async ensureCompatibilityProjection(entry, canonicalDirectory) {
77104
77041
  await (0, import_promises5.mkdir)(this.compatibilitySkillsDirectory, { recursive: true, mode: 448 });
77105
- const destination = (0, import_node_path21.join)(this.compatibilitySkillsDirectory, entry.runtimeDirectory);
77042
+ const destination = (0, import_node_path22.join)(this.compatibilitySkillsDirectory, entry.runtimeDirectory);
77106
77043
  if (await pathExists2(destination)) {
77107
77044
  if (await compatibilityProjectionMatches(destination, canonicalDirectory, entry)) return;
77108
77045
  throw unmanagedCompatibilityConflict(entry.runtimeDirectory);
@@ -77117,7 +77054,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
77117
77054
  try {
77118
77055
  await (0, import_promises5.cp)(canonicalDirectory, pending, { recursive: true, errorOnExist: true, force: false });
77119
77056
  await (0, import_promises5.writeFile)(
77120
- (0, import_node_path21.join)(pending, ".alan-compatibility.json"),
77057
+ (0, import_node_path22.join)(pending, ".alan-compatibility.json"),
77121
77058
  `${JSON.stringify({ ...markerFor(entry), canonicalDirectory }, null, 2)}
77122
77059
  `,
77123
77060
  { encoding: "utf8", flag: "wx", mode: 384 }
@@ -77142,14 +77079,14 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
77142
77079
  }
77143
77080
  async withMachineLock(work) {
77144
77081
  await (0, import_promises5.mkdir)(this.skillsStateDirectory, { recursive: true, mode: 448 });
77145
- const lockDirectory = (0, import_node_path21.join)(this.skillsStateDirectory, "manager.lock");
77082
+ const lockDirectory = (0, import_node_path22.join)(this.skillsStateDirectory, "manager.lock");
77146
77083
  const deadline = Date.now() + 3e4;
77147
77084
  while (true) {
77148
77085
  try {
77149
77086
  await (0, import_promises5.mkdir)(lockDirectory, { mode: 448 });
77150
77087
  try {
77151
77088
  await (0, import_promises5.writeFile)(
77152
- (0, import_node_path21.join)(lockDirectory, "owner.json"),
77089
+ (0, import_node_path22.join)(lockDirectory, "owner.json"),
77153
77090
  `${JSON.stringify({ pid: process.pid, acquiredAt: (/* @__PURE__ */ new Date()).toISOString() })}
77154
77091
  `,
77155
77092
  { encoding: "utf8", flag: "wx", mode: 384 }
@@ -77199,7 +77136,7 @@ async function packageMatches(directory, expectedHash) {
77199
77136
  async function readMarker(directory) {
77200
77137
  try {
77201
77138
  const value2 = JSON.parse(
77202
- await (0, import_promises5.readFile)((0, import_node_path21.join)(directory, ".alan-managed.json"), "utf8")
77139
+ await (0, import_promises5.readFile)((0, import_node_path22.join)(directory, ".alan-managed.json"), "utf8")
77203
77140
  );
77204
77141
  if (typeof value2 !== "object" || value2 === null || !("protocolVersion" in value2) || value2.protocolVersion !== SKILLS_PROTOCOL_VERSION || !("skillId" in value2) || typeof value2.skillId !== "string" || !("versionId" in value2) || typeof value2.versionId !== "string" || !("contentHash" in value2) || typeof value2.contentHash !== "string" || !/^sha256:[a-f0-9]{64}$/.test(value2.contentHash)) {
77205
77142
  return null;
@@ -77213,7 +77150,7 @@ async function compatibilityProjectionMatches(destination, canonicalDirectory, e
77213
77150
  const metadata = await (0, import_promises5.lstat)(destination);
77214
77151
  if (metadata.isSymbolicLink()) {
77215
77152
  const target = await (0, import_promises5.readlink)(destination);
77216
- return (0, import_node_path21.resolve)((0, import_node_path21.dirname)(destination), target) === (0, import_node_path21.resolve)(canonicalDirectory);
77153
+ return (0, import_node_path22.resolve)((0, import_node_path22.dirname)(destination), target) === (0, import_node_path22.resolve)(canonicalDirectory);
77217
77154
  }
77218
77155
  if (!metadata.isDirectory()) return false;
77219
77156
  const marker = await readCompatibilityMarker(destination);
@@ -77224,7 +77161,7 @@ async function removeCompatibilityProjection(destination, canonicalDirectory, pr
77224
77161
  const metadata = await (0, import_promises5.lstat)(destination);
77225
77162
  if (metadata.isSymbolicLink()) {
77226
77163
  const target = await (0, import_promises5.readlink)(destination);
77227
- if ((0, import_node_path21.resolve)((0, import_node_path21.dirname)(destination), target) !== (0, import_node_path21.resolve)(canonicalDirectory)) return false;
77164
+ if ((0, import_node_path22.resolve)((0, import_node_path22.dirname)(destination), target) !== (0, import_node_path22.resolve)(canonicalDirectory)) return false;
77228
77165
  await (0, import_promises5.rm)(destination, { force: true });
77229
77166
  return true;
77230
77167
  }
@@ -77236,7 +77173,7 @@ async function removeCompatibilityProjection(destination, canonicalDirectory, pr
77236
77173
  async function readCompatibilityMarker(directory) {
77237
77174
  try {
77238
77175
  const value2 = JSON.parse(
77239
- await (0, import_promises5.readFile)((0, import_node_path21.join)(directory, ".alan-compatibility.json"), "utf8")
77176
+ await (0, import_promises5.readFile)((0, import_node_path22.join)(directory, ".alan-compatibility.json"), "utf8")
77240
77177
  );
77241
77178
  if (value2.protocolVersion !== SKILLS_PROTOCOL_VERSION || typeof value2.skillId !== "string" || typeof value2.versionId !== "string" || !/^sha256:[a-f0-9]{64}$/.test(value2.contentHash) || typeof value2.canonicalDirectory !== "string") {
77242
77179
  return null;
@@ -77276,7 +77213,7 @@ async function legacyFileMatches(directory, expectedHash) {
77276
77213
  try {
77277
77214
  const metadata = await (0, import_promises5.lstat)(directory);
77278
77215
  if (!metadata.isDirectory() || metadata.isSymbolicLink()) return false;
77279
- const content = await (0, import_promises5.readFile)((0, import_node_path21.join)(directory, "SKILL.md"));
77216
+ const content = await (0, import_promises5.readFile)((0, import_node_path22.join)(directory, "SKILL.md"));
77280
77217
  return (0, import_node_crypto15.createHash)("sha256").update(content).digest("hex").slice(0, 16) === expectedHash;
77281
77218
  } catch {
77282
77219
  return false;
@@ -77284,7 +77221,7 @@ async function legacyFileMatches(directory, expectedHash) {
77284
77221
  }
77285
77222
  async function removeExactLegacySkill(directory, expectedHash) {
77286
77223
  if (!await legacyFileMatches(directory, expectedHash)) return;
77287
- await (0, import_promises5.rm)((0, import_node_path21.join)(directory, "SKILL.md"), { force: true });
77224
+ await (0, import_promises5.rm)((0, import_node_path22.join)(directory, "SKILL.md"), { force: true });
77288
77225
  const remaining = await (0, import_promises5.readdir)(directory);
77289
77226
  if (remaining.length === 0) await (0, import_promises5.rm)(directory, { recursive: true, force: true });
77290
77227
  }
@@ -77444,13 +77381,13 @@ async function startDaemon(args) {
77444
77381
  getRuntimeToken: () => runtimeToken
77445
77382
  });
77446
77383
  const runtimeSkillManager = await RuntimeSkillManager.open({
77447
- homeDirectory: (0, import_node_os10.homedir)(),
77384
+ homeDirectory: (0, import_node_os11.homedir)(),
77448
77385
  controlClient: skillControl
77449
77386
  });
77450
77387
  const runtimeSkillCoordinator = new RuntimeSkillCoordinator(
77451
77388
  runtimeSkillManager,
77452
77389
  skillControl,
77453
- (input2) => resolveSkillScanInput((0, import_node_os10.homedir)(), input2)
77390
+ (input2) => resolveSkillScanInput((0, import_node_os11.homedir)(), input2)
77454
77391
  );
77455
77392
  const runSkillSync = (reason) => {
77456
77393
  const operation = reason === "startup" ? runtimeSkillCoordinator.runStartup() : reason === "interval" ? runtimeSkillCoordinator.runIncremental() : reason === "refresh" ? runtimeSkillCoordinator.runAudit() : runtimeSkillCoordinator.run();
@@ -77524,10 +77461,10 @@ async function startDaemon(args) {
77524
77461
  installationId
77525
77462
  });
77526
77463
  const recentLogs = [];
77527
- const daemonLogPath = (0, import_node_path22.join)((0, import_node_path22.dirname)(configPath), "logs", "daemon.log");
77464
+ const daemonLogPath = (0, import_node_path23.join)((0, import_node_path23.dirname)(configPath), "logs", "daemon.log");
77528
77465
  const persistDaemonLog = (line) => {
77529
77466
  try {
77530
- (0, import_node_fs20.mkdirSync)((0, import_node_path22.dirname)(daemonLogPath), { recursive: true });
77467
+ (0, import_node_fs20.mkdirSync)((0, import_node_path23.dirname)(daemonLogPath), { recursive: true });
77531
77468
  try {
77532
77469
  if ((0, import_node_fs20.statSync)(daemonLogPath).size > 5 * 1024 * 1024) {
77533
77470
  (0, import_node_fs20.renameSync)(daemonLogPath, `${daemonLogPath}.1`);
@@ -77659,7 +77596,7 @@ async function startDaemon(args) {
77659
77596
  };
77660
77597
  for (const relocation of stored.workspaceRelocations ?? []) {
77661
77598
  if (relocation?.conversationId && relocation.runId && relocation.previousPath && relocation.canonicalPath) {
77662
- workspaceRelocations.set((0, import_node_path22.resolve)(relocation.previousPath), relocation);
77599
+ workspaceRelocations.set((0, import_node_path23.resolve)(relocation.previousPath), relocation);
77663
77600
  }
77664
77601
  }
77665
77602
  if (stored.localApiPort !== localApiPort || stored.localApiToken !== localApiToken || stored.localServiceId !== localServiceId || stored.localServiceSecret !== localServiceSecret || stored.eventSpoolKey !== eventSpoolKey || stored.daemonEpoch !== daemonEpoch || stored.installationId !== installationId) {
@@ -78367,7 +78304,7 @@ async function setupDaemon(args) {
78367
78304
  const teamId = argValue(args, "--team") ?? process.env.ALAN_TEAM_ID;
78368
78305
  const setupToken = argValue(args, "--setup-token") ?? process.env.ALAN_RUNTIME_SETUP_TOKEN;
78369
78306
  const token = argValue(args, "--token") ?? process.env.ALAN_SETUP_TOKEN;
78370
- const displayName = argValue(args, "--name") ?? (0, import_node_os11.hostname)();
78307
+ const displayName = argValue(args, "--name") ?? (0, import_node_os12.hostname)();
78371
78308
  const scope = argValue(args, "--scope") ?? process.env.ALAN_RUNTIME_SCOPE ?? (setupToken ? "team" : "user");
78372
78309
  const installationId = argValue(args, "--installation-id") ?? previousConfig.installationId ?? (0, import_node_crypto17.randomUUID)();
78373
78310
  if (scope !== "team" && scope !== "user") {
@@ -78390,7 +78327,7 @@ async function setupDaemon(args) {
78390
78327
  ...teamId ? { teamId } : {},
78391
78328
  ...setupToken ? { setupToken, registrationAttemptId } : {},
78392
78329
  displayName,
78393
- hostname: (0, import_node_os11.hostname)(),
78330
+ hostname: (0, import_node_os12.hostname)(),
78394
78331
  runtimeKind: "machine",
78395
78332
  managementKind: "user_managed",
78396
78333
  hostKind: "daemon",
@@ -78474,7 +78411,7 @@ async function loginWithDeviceCode(args) {
78474
78411
  }
78475
78412
  const previousConfig = readConfigForRegistration();
78476
78413
  const { apiUrl, wsUrl, endpointProfile } = resolveEndpoints(args);
78477
- const displayName = argValue(args, "--name") ?? (0, import_node_os11.hostname)();
78414
+ const displayName = argValue(args, "--name") ?? (0, import_node_os12.hostname)();
78478
78415
  const maxPolls = Number.parseInt(argValue(args, "--max-polls") ?? "300", 10);
78479
78416
  const resumed = readPendingDeviceAuthorization(apiUrl);
78480
78417
  const installationId = resumed?.installationId ?? previousConfig.installationId ?? (0, import_node_crypto17.randomUUID)();
@@ -78486,7 +78423,7 @@ async function loginWithDeviceCode(args) {
78486
78423
  headers: { "content-type": "application/json" },
78487
78424
  body: JSON.stringify({
78488
78425
  displayName,
78489
- hostname: (0, import_node_os11.hostname)(),
78426
+ hostname: (0, import_node_os12.hostname)(),
78490
78427
  capabilities: discoverCapabilities(),
78491
78428
  metadata: {
78492
78429
  ...await collectRuntimeMetadataWithProviderLimits(),
@@ -78910,8 +78847,8 @@ async function printDoctor(args = []) {
78910
78847
  // src/mcp-config-adapters.ts
78911
78848
  var import_node_crypto18 = require("crypto");
78912
78849
  var import_node_fs21 = require("fs");
78913
- var import_node_os12 = require("os");
78914
- var import_node_path23 = require("path");
78850
+ var import_node_os13 = require("os");
78851
+ var import_node_path24 = require("path");
78915
78852
  var log = {
78916
78853
  info: (...args) => console.info("[mcp-config-adapters]", ...args),
78917
78854
  warn: (...args) => console.warn("[mcp-config-adapters]", ...args),
@@ -78920,7 +78857,7 @@ var log = {
78920
78857
  };
78921
78858
  var homeDirectoryOverride;
78922
78859
  function homeDirectory() {
78923
- return homeDirectoryOverride ?? (0, import_node_os12.homedir)();
78860
+ return homeDirectoryOverride ?? (0, import_node_os13.homedir)();
78924
78861
  }
78925
78862
  var MalformedToolConfigError = class extends Error {
78926
78863
  };
@@ -78939,7 +78876,7 @@ function readFileOr(path2) {
78939
78876
  return (0, import_node_fs21.existsSync)(path2) ? (0, import_node_fs21.readFileSync)(path2, "utf-8") : null;
78940
78877
  }
78941
78878
  function acquireConfigLock2(path2) {
78942
- (0, import_node_fs21.mkdirSync)((0, import_node_path23.dirname)(path2), { recursive: true });
78879
+ (0, import_node_fs21.mkdirSync)((0, import_node_path24.dirname)(path2), { recursive: true });
78943
78880
  const lockPath = `${path2}.alan-lock`;
78944
78881
  const startedAt = Date.now();
78945
78882
  while (true) {
@@ -78965,7 +78902,7 @@ function acquireConfigLock2(path2) {
78965
78902
  }
78966
78903
  }
78967
78904
  function writeFileSafe2(path2, content) {
78968
- (0, import_node_fs21.mkdirSync)((0, import_node_path23.dirname)(path2), { recursive: true });
78905
+ (0, import_node_fs21.mkdirSync)((0, import_node_path24.dirname)(path2), { recursive: true });
78969
78906
  const pendingPath = `${path2}.alan-pending-${process.pid}-${(0, import_node_crypto18.randomBytes)(6).toString("hex")}`;
78970
78907
  try {
78971
78908
  (0, import_node_fs21.writeFileSync)(pendingPath, content, { encoding: "utf8", mode: 384, flag: "wx" });
@@ -78983,7 +78920,7 @@ function saveMalformedBackup2(path2, content) {
78983
78920
  var claudeAdapter = {
78984
78921
  cli: "Claude Code",
78985
78922
  get configPath() {
78986
- return (0, import_node_path23.join)(homeDirectory(), ".claude.json");
78923
+ return (0, import_node_path24.join)(homeDirectory(), ".claude.json");
78987
78924
  },
78988
78925
  get guardDir() {
78989
78926
  return homeDirectory();
@@ -79016,10 +78953,10 @@ var claudeAdapter = {
79016
78953
  var codexAdapter = {
79017
78954
  cli: "Codex",
79018
78955
  get configPath() {
79019
- return (0, import_node_path23.join)(homeDirectory(), ".codex", "config.toml");
78956
+ return (0, import_node_path24.join)(homeDirectory(), ".codex", "config.toml");
79020
78957
  },
79021
78958
  get guardDir() {
79022
- return (0, import_node_path23.join)(homeDirectory(), ".codex");
78959
+ return (0, import_node_path24.join)(homeDirectory(), ".codex");
79023
78960
  },
79024
78961
  merge(existing, servers) {
79025
78962
  let config2 = {};
@@ -79062,10 +78999,10 @@ var codexAdapter = {
79062
78999
  var cursorAdapter = {
79063
79000
  cli: "Cursor",
79064
79001
  get configPath() {
79065
- return (0, import_node_path23.join)(homeDirectory(), ".cursor", "mcp.json");
79002
+ return (0, import_node_path24.join)(homeDirectory(), ".cursor", "mcp.json");
79066
79003
  },
79067
79004
  get guardDir() {
79068
- return (0, import_node_path23.join)(homeDirectory(), ".cursor");
79005
+ return (0, import_node_path24.join)(homeDirectory(), ".cursor");
79069
79006
  },
79070
79007
  merge(existing, servers) {
79071
79008
  const config2 = parseJsonSafe2(existing);
@@ -79096,10 +79033,10 @@ function createAntigravityAdapter() {
79096
79033
  return {
79097
79034
  cli: "Antigravity CLI",
79098
79035
  get configPath() {
79099
- return (0, import_node_path23.join)(homeDirectory(), ".gemini", "config", "mcp_config.json");
79036
+ return (0, import_node_path24.join)(homeDirectory(), ".gemini", "config", "mcp_config.json");
79100
79037
  },
79101
79038
  get guardDir() {
79102
- return (0, import_node_path23.join)(homeDirectory(), ".gemini", "config");
79039
+ return (0, import_node_path24.join)(homeDirectory(), ".gemini", "config");
79103
79040
  },
79104
79041
  merge(existing, servers) {
79105
79042
  const config2 = parseJsonSafe2(existing);
@@ -79131,10 +79068,10 @@ var antigravityAdapter = createAntigravityAdapter();
79131
79068
  var kimiAdapter = {
79132
79069
  cli: "Kimi CLI",
79133
79070
  get configPath() {
79134
- return (0, import_node_path23.join)(homeDirectory(), ".kimi", "mcp.json");
79071
+ return (0, import_node_path24.join)(homeDirectory(), ".kimi", "mcp.json");
79135
79072
  },
79136
79073
  get guardDir() {
79137
- return (0, import_node_path23.join)(homeDirectory(), ".kimi");
79074
+ return (0, import_node_path24.join)(homeDirectory(), ".kimi");
79138
79075
  },
79139
79076
  merge(existing, servers) {
79140
79077
  const config2 = parseJsonSafe2(existing);
@@ -79164,10 +79101,10 @@ var kimiAdapter = {
79164
79101
  var opencodeAdapter = {
79165
79102
  cli: "OpenCode",
79166
79103
  get configPath() {
79167
- return (0, import_node_path23.join)(homeDirectory(), ".config", "opencode", "opencode.json");
79104
+ return (0, import_node_path24.join)(homeDirectory(), ".config", "opencode", "opencode.json");
79168
79105
  },
79169
79106
  get guardDir() {
79170
- return (0, import_node_path23.join)(homeDirectory(), ".config", "opencode");
79107
+ return (0, import_node_path24.join)(homeDirectory(), ".config", "opencode");
79171
79108
  },
79172
79109
  merge(existing, servers) {
79173
79110
  const config2 = parseJsonSafe2(existing);
@@ -79197,10 +79134,10 @@ var opencodeAdapter = {
79197
79134
  var factoryAdapter = {
79198
79135
  cli: "Factory Droid",
79199
79136
  get configPath() {
79200
- return (0, import_node_path23.join)(homeDirectory(), ".factory", "mcp.json");
79137
+ return (0, import_node_path24.join)(homeDirectory(), ".factory", "mcp.json");
79201
79138
  },
79202
79139
  get guardDir() {
79203
- return (0, import_node_path23.join)(homeDirectory(), ".factory");
79140
+ return (0, import_node_path24.join)(homeDirectory(), ".factory");
79204
79141
  },
79205
79142
  merge(existing, servers) {
79206
79143
  const config2 = parseJsonSafe2(existing);
@@ -79237,10 +79174,10 @@ var factoryAdapter = {
79237
79174
  var ampAdapter = {
79238
79175
  cli: "Amp",
79239
79176
  get configPath() {
79240
- return (0, import_node_path23.join)(homeDirectory(), ".config", "amp", "settings.json");
79177
+ return (0, import_node_path24.join)(homeDirectory(), ".config", "amp", "settings.json");
79241
79178
  },
79242
79179
  get guardDir() {
79243
- return (0, import_node_path23.join)(homeDirectory(), ".config", "amp");
79180
+ return (0, import_node_path24.join)(homeDirectory(), ".config", "amp");
79244
79181
  },
79245
79182
  merge(existing, servers) {
79246
79183
  const config2 = parseJsonSafe2(existing);
@@ -79665,8 +79602,8 @@ var McpSyncService = class {
79665
79602
 
79666
79603
  // src/native-hook-config.ts
79667
79604
  var import_node_fs22 = require("fs");
79668
- var import_node_os13 = require("os");
79669
- var import_node_path24 = require("path");
79605
+ var import_node_os14 = require("os");
79606
+ var import_node_path25 = require("path");
79670
79607
  var ALAN_HOOK_MARKER = "# alan-native-session-hook";
79671
79608
  var ALAN_KIMI_HOOKS_START = "# alan-native-session-hooks:start";
79672
79609
  var ALAN_KIMI_HOOKS_END = "# alan-native-session-hooks:end";
@@ -79759,7 +79696,7 @@ function nativeHookCommand(input2) {
79759
79696
  if (environment.length === 0) {
79760
79697
  return { type: "command", command: input2.nodeExecutable, args, timeout: 5 };
79761
79698
  }
79762
- if ((input2.platform ?? (0, import_node_os13.platform)()) === "win32") {
79699
+ if ((input2.platform ?? (0, import_node_os14.platform)()) === "win32") {
79763
79700
  const environmentPrefix2 = environment.map(([key, value2]) => `$env:${key}=${powershellQuote(value2)}`).join("; ");
79764
79701
  const command2 = [input2.nodeExecutable, ...args].map(powershellQuote).join(" ");
79765
79702
  return {
@@ -79804,11 +79741,11 @@ function resolveRuntime(input2 = {}) {
79804
79741
  }
79805
79742
  return {
79806
79743
  configPath,
79807
- homeDir: input2.homeDir ?? (0, import_node_os13.homedir)(),
79744
+ homeDir: input2.homeDir ?? (0, import_node_os14.homedir)(),
79808
79745
  nodeExecutable: input2.nodeExecutable ?? process.execPath,
79809
79746
  cliEntry,
79810
79747
  environment: input2.environment,
79811
- platform: input2.platform ?? (0, import_node_os13.platform)()
79748
+ platform: input2.platform ?? (0, import_node_os14.platform)()
79812
79749
  };
79813
79750
  }
79814
79751
  function readSettings(path2, providerLabel) {
@@ -79835,7 +79772,7 @@ function writeSettings(path2, settings) {
79835
79772
  const serialized = `${JSON.stringify(settings, null, 2)}
79836
79773
  `;
79837
79774
  if ((0, import_node_fs22.existsSync)(path2) && (0, import_node_fs22.readFileSync)(path2, "utf8") === serialized) return false;
79838
- (0, import_node_fs22.mkdirSync)((0, import_node_path24.dirname)(path2), { recursive: true, mode: 448 });
79775
+ (0, import_node_fs22.mkdirSync)((0, import_node_path25.dirname)(path2), { recursive: true, mode: 448 });
79839
79776
  const temporary = `${path2}.${process.pid}.tmp`;
79840
79777
  (0, import_node_fs22.writeFileSync)(temporary, serialized, { mode: 384 });
79841
79778
  (0, import_node_fs22.renameSync)(temporary, path2);
@@ -79843,7 +79780,7 @@ function writeSettings(path2, settings) {
79843
79780
  }
79844
79781
  function writeTextFile(path2, content) {
79845
79782
  if ((0, import_node_fs22.existsSync)(path2) && (0, import_node_fs22.readFileSync)(path2, "utf8") === content) return false;
79846
- (0, import_node_fs22.mkdirSync)((0, import_node_path24.dirname)(path2), { recursive: true, mode: 448 });
79783
+ (0, import_node_fs22.mkdirSync)((0, import_node_path25.dirname)(path2), { recursive: true, mode: 448 });
79847
79784
  const temporary = `${path2}.${process.pid}.tmp`;
79848
79785
  (0, import_node_fs22.writeFileSync)(temporary, content, { mode: 384 });
79849
79786
  (0, import_node_fs22.renameSync)(temporary, path2);
@@ -79887,7 +79824,7 @@ function removeNestedCommandHooks(path2, providerLabel) {
79887
79824
  function reconcileClaudeNativeHooks(input2 = {}) {
79888
79825
  const runtime = resolveRuntime(input2);
79889
79826
  return reconcileNestedCommandHooks({
79890
- path: (0, import_node_path24.join)(runtime.homeDir, ".claude", "settings.json"),
79827
+ path: (0, import_node_path25.join)(runtime.homeDir, ".claude", "settings.json"),
79891
79828
  providerLabel: "Claude",
79892
79829
  events: CLAUDE_HOOK_EVENTS,
79893
79830
  command: (event) => ({
@@ -79899,13 +79836,13 @@ function reconcileClaudeNativeHooks(input2 = {}) {
79899
79836
  })
79900
79837
  });
79901
79838
  }
79902
- function removeClaudeNativeHooks(homeDir = (0, import_node_os13.homedir)()) {
79903
- return removeNestedCommandHooks((0, import_node_path24.join)(homeDir, ".claude", "settings.json"), "Claude");
79839
+ function removeClaudeNativeHooks(homeDir = (0, import_node_os14.homedir)()) {
79840
+ return removeNestedCommandHooks((0, import_node_path25.join)(homeDir, ".claude", "settings.json"), "Claude");
79904
79841
  }
79905
79842
  function reconcileCodexNativeHooks(input2 = {}) {
79906
79843
  const runtime = resolveRuntime(input2);
79907
79844
  return reconcileNestedCommandHooks({
79908
- path: (0, import_node_path24.join)(runtime.homeDir, ".codex", "hooks.json"),
79845
+ path: (0, import_node_path25.join)(runtime.homeDir, ".codex", "hooks.json"),
79909
79846
  providerLabel: "Codex",
79910
79847
  events: CODEX_HOOK_EVENTS,
79911
79848
  command: (event) => ({
@@ -79916,12 +79853,12 @@ function reconcileCodexNativeHooks(input2 = {}) {
79916
79853
  })
79917
79854
  });
79918
79855
  }
79919
- function removeCodexNativeHooks(homeDir = (0, import_node_os13.homedir)()) {
79920
- return removeNestedCommandHooks((0, import_node_path24.join)(homeDir, ".codex", "hooks.json"), "Codex");
79856
+ function removeCodexNativeHooks(homeDir = (0, import_node_os14.homedir)()) {
79857
+ return removeNestedCommandHooks((0, import_node_path25.join)(homeDir, ".codex", "hooks.json"), "Codex");
79921
79858
  }
79922
79859
  function reconcileCopilotNativeHooks(input2 = {}) {
79923
79860
  const runtime = resolveRuntime(input2);
79924
- const path2 = (0, import_node_path24.join)(runtime.homeDir, ".copilot", "hooks", "alan-native-session.json");
79861
+ const path2 = (0, import_node_path25.join)(runtime.homeDir, ".copilot", "hooks", "alan-native-session.json");
79925
79862
  if ((0, import_node_fs22.existsSync)(path2) && !(0, import_node_fs22.readFileSync)(path2, "utf8").includes(ALAN_HOOK_MARKER)) {
79926
79863
  throw new Error(`Refusing to overwrite non-Alan Copilot hook configuration at ${path2}`);
79927
79864
  }
@@ -79940,8 +79877,8 @@ function reconcileCopilotNativeHooks(input2 = {}) {
79940
79877
  );
79941
79878
  return writeSettings(path2, { version: 1, hooks });
79942
79879
  }
79943
- function removeCopilotNativeHooks(homeDir = (0, import_node_os13.homedir)()) {
79944
- const path2 = (0, import_node_path24.join)(homeDir, ".copilot", "hooks", "alan-native-session.json");
79880
+ function removeCopilotNativeHooks(homeDir = (0, import_node_os14.homedir)()) {
79881
+ const path2 = (0, import_node_path25.join)(homeDir, ".copilot", "hooks", "alan-native-session.json");
79945
79882
  if (!(0, import_node_fs22.existsSync)(path2)) return false;
79946
79883
  if (!(0, import_node_fs22.readFileSync)(path2, "utf8").includes(ALAN_HOOK_MARKER)) return false;
79947
79884
  (0, import_node_fs22.rmSync)(path2);
@@ -79949,7 +79886,7 @@ function removeCopilotNativeHooks(homeDir = (0, import_node_os13.homedir)()) {
79949
79886
  }
79950
79887
  function reconcileCursorNativeHooks(input2 = {}) {
79951
79888
  const runtime = resolveRuntime(input2);
79952
- const path2 = (0, import_node_path24.join)(runtime.homeDir, ".cursor", "hooks.json");
79889
+ const path2 = (0, import_node_path25.join)(runtime.homeDir, ".cursor", "hooks.json");
79953
79890
  const settings = readSettings(path2, "Cursor");
79954
79891
  const currentHooks = settings.hooks && typeof settings.hooks === "object" && !Array.isArray(settings.hooks) ? settings.hooks : {};
79955
79892
  const hooks = { ...currentHooks };
@@ -79965,8 +79902,8 @@ function reconcileCursorNativeHooks(input2 = {}) {
79965
79902
  }
79966
79903
  return writeSettings(path2, { ...settings, version: settings.version ?? 1, hooks });
79967
79904
  }
79968
- function removeCursorNativeHooks(homeDir = (0, import_node_os13.homedir)()) {
79969
- const path2 = (0, import_node_path24.join)(homeDir, ".cursor", "hooks.json");
79905
+ function removeCursorNativeHooks(homeDir = (0, import_node_os14.homedir)()) {
79906
+ const path2 = (0, import_node_path25.join)(homeDir, ".cursor", "hooks.json");
79970
79907
  if (!(0, import_node_fs22.existsSync)(path2)) return false;
79971
79908
  const settings = readSettings(path2, "Cursor");
79972
79909
  if (!settings.hooks || typeof settings.hooks !== "object" || Array.isArray(settings.hooks)) {
@@ -79996,15 +79933,15 @@ ${ALAN_KIMI_HOOKS_END}`;
79996
79933
  }
79997
79934
  function reconcileKimiNativeHooks(input2 = {}) {
79998
79935
  const runtime = resolveRuntime(input2);
79999
- const path2 = (0, import_node_path24.join)(runtime.homeDir, ".kimi-code", "config.toml");
79936
+ const path2 = (0, import_node_path25.join)(runtime.homeDir, ".kimi-code", "config.toml");
80000
79937
  const current = (0, import_node_fs22.existsSync)(path2) ? (0, import_node_fs22.readFileSync)(path2, "utf8") : "";
80001
79938
  const userContent = withoutMarkedSection(current, ALAN_KIMI_HOOKS_START, ALAN_KIMI_HOOKS_END);
80002
79939
  const content = `${userContent.trimEnd()}${userContent.trim() ? "\n\n" : ""}${kimiHookSection(runtime)}
80003
79940
  `;
80004
79941
  return writeTextFile(path2, content);
80005
79942
  }
80006
- function removeKimiNativeHooks(homeDir = (0, import_node_os13.homedir)()) {
80007
- const path2 = (0, import_node_path24.join)(homeDir, ".kimi-code", "config.toml");
79943
+ function removeKimiNativeHooks(homeDir = (0, import_node_os14.homedir)()) {
79944
+ const path2 = (0, import_node_path25.join)(homeDir, ".kimi-code", "config.toml");
80008
79945
  if (!(0, import_node_fs22.existsSync)(path2)) return false;
80009
79946
  const current = (0, import_node_fs22.readFileSync)(path2, "utf8");
80010
79947
  const content = withoutMarkedSection(current, ALAN_KIMI_HOOKS_START, ALAN_KIMI_HOOKS_END);
@@ -80014,7 +79951,7 @@ function removeKimiNativeHooks(homeDir = (0, import_node_os13.homedir)()) {
80014
79951
  }
80015
79952
  function reconcileGrokNativeHooks(input2 = {}) {
80016
79953
  const runtime = resolveRuntime(input2);
80017
- const path2 = (0, import_node_path24.join)(runtime.homeDir, ".grok", "hooks", "alan-native-session.json");
79954
+ const path2 = (0, import_node_path25.join)(runtime.homeDir, ".grok", "hooks", "alan-native-session.json");
80018
79955
  if ((0, import_node_fs22.existsSync)(path2) && !(0, import_node_fs22.readFileSync)(path2, "utf8").includes(ALAN_HOOK_MARKER)) {
80019
79956
  throw new Error(`Refusing to overwrite non-Alan Grok hook configuration at ${path2}`);
80020
79957
  }
@@ -80029,8 +79966,8 @@ function reconcileGrokNativeHooks(input2 = {}) {
80029
79966
  })
80030
79967
  });
80031
79968
  }
80032
- function removeGrokNativeHooks(homeDir = (0, import_node_os13.homedir)()) {
80033
- const path2 = (0, import_node_path24.join)(homeDir, ".grok", "hooks", "alan-native-session.json");
79969
+ function removeGrokNativeHooks(homeDir = (0, import_node_os14.homedir)()) {
79970
+ const path2 = (0, import_node_path25.join)(homeDir, ".grok", "hooks", "alan-native-session.json");
80034
79971
  if (!(0, import_node_fs22.existsSync)(path2)) return false;
80035
79972
  if (!(0, import_node_fs22.readFileSync)(path2, "utf8").includes(ALAN_HOOK_MARKER)) return false;
80036
79973
  (0, import_node_fs22.rmSync)(path2);
@@ -80121,20 +80058,20 @@ export const AlanNativeSessionPlugin = async ({ directory }) => {
80121
80058
  }
80122
80059
  function reconcileOpencodeNativePlugin(input2 = {}) {
80123
80060
  const runtime = resolveRuntime(input2);
80124
- const path2 = (0, import_node_path24.join)(runtime.homeDir, ".config", "opencode", "plugins", "alan-native-session.js");
80061
+ const path2 = (0, import_node_path25.join)(runtime.homeDir, ".config", "opencode", "plugins", "alan-native-session.js");
80125
80062
  if ((0, import_node_fs22.existsSync)(path2) && !(0, import_node_fs22.readFileSync)(path2, "utf8").includes(ALAN_OPENCODE_PLUGIN_MARKER)) {
80126
80063
  throw new Error(`Refusing to overwrite non-Alan OpenCode plugin at ${path2}`);
80127
80064
  }
80128
80065
  const source = opencodePluginSource(runtime);
80129
80066
  if ((0, import_node_fs22.existsSync)(path2) && (0, import_node_fs22.readFileSync)(path2, "utf8") === source) return false;
80130
- (0, import_node_fs22.mkdirSync)((0, import_node_path24.dirname)(path2), { recursive: true, mode: 448 });
80067
+ (0, import_node_fs22.mkdirSync)((0, import_node_path25.dirname)(path2), { recursive: true, mode: 448 });
80131
80068
  const temporary = `${path2}.${process.pid}.tmp`;
80132
80069
  (0, import_node_fs22.writeFileSync)(temporary, source, { mode: 384 });
80133
80070
  (0, import_node_fs22.renameSync)(temporary, path2);
80134
80071
  return true;
80135
80072
  }
80136
- function removeOpencodeNativePlugin(homeDir = (0, import_node_os13.homedir)()) {
80137
- const path2 = (0, import_node_path24.join)(homeDir, ".config", "opencode", "plugins", "alan-native-session.js");
80073
+ function removeOpencodeNativePlugin(homeDir = (0, import_node_os14.homedir)()) {
80074
+ const path2 = (0, import_node_path25.join)(homeDir, ".config", "opencode", "plugins", "alan-native-session.js");
80138
80075
  if (!(0, import_node_fs22.existsSync)(path2)) return false;
80139
80076
  if (!(0, import_node_fs22.readFileSync)(path2, "utf8").includes(ALAN_OPENCODE_PLUGIN_MARKER)) return false;
80140
80077
  (0, import_node_fs22.rmSync)(path2);
@@ -80148,32 +80085,32 @@ function configFileContainsMarker(path2, marker) {
80148
80085
  return false;
80149
80086
  }
80150
80087
  }
80151
- function inspectNativeHooksConfigured(providerKind, homeDir = (0, import_node_os13.homedir)()) {
80088
+ function inspectNativeHooksConfigured(providerKind, homeDir = (0, import_node_os14.homedir)()) {
80152
80089
  switch (providerKind) {
80153
80090
  case "claude_cli":
80154
- return configFileContainsMarker((0, import_node_path24.join)(homeDir, ".claude", "settings.json"), ALAN_HOOK_MARKER);
80091
+ return configFileContainsMarker((0, import_node_path25.join)(homeDir, ".claude", "settings.json"), ALAN_HOOK_MARKER);
80155
80092
  case "codex_app_server":
80156
- return configFileContainsMarker((0, import_node_path24.join)(homeDir, ".codex", "hooks.json"), ALAN_HOOK_MARKER);
80093
+ return configFileContainsMarker((0, import_node_path25.join)(homeDir, ".codex", "hooks.json"), ALAN_HOOK_MARKER);
80157
80094
  case "copilot_cli":
80158
80095
  return configFileContainsMarker(
80159
- (0, import_node_path24.join)(homeDir, ".copilot", "hooks", "alan-native-session.json"),
80096
+ (0, import_node_path25.join)(homeDir, ".copilot", "hooks", "alan-native-session.json"),
80160
80097
  ALAN_HOOK_MARKER
80161
80098
  );
80162
80099
  case "cursor_agent_cli":
80163
- return configFileContainsMarker((0, import_node_path24.join)(homeDir, ".cursor", "hooks.json"), ALAN_HOOK_MARKER);
80100
+ return configFileContainsMarker((0, import_node_path25.join)(homeDir, ".cursor", "hooks.json"), ALAN_HOOK_MARKER);
80164
80101
  case "kimi_cli":
80165
80102
  return configFileContainsMarker(
80166
- (0, import_node_path24.join)(homeDir, ".kimi-code", "config.toml"),
80103
+ (0, import_node_path25.join)(homeDir, ".kimi-code", "config.toml"),
80167
80104
  ALAN_KIMI_HOOKS_START
80168
80105
  );
80169
80106
  case "grok_cli":
80170
80107
  return configFileContainsMarker(
80171
- (0, import_node_path24.join)(homeDir, ".grok", "hooks", "alan-native-session.json"),
80108
+ (0, import_node_path25.join)(homeDir, ".grok", "hooks", "alan-native-session.json"),
80172
80109
  ALAN_HOOK_MARKER
80173
80110
  );
80174
80111
  case "opencode_cli":
80175
80112
  return configFileContainsMarker(
80176
- (0, import_node_path24.join)(homeDir, ".config", "opencode", "plugins", "alan-native-session.js"),
80113
+ (0, import_node_path25.join)(homeDir, ".config", "opencode", "plugins", "alan-native-session.js"),
80177
80114
  ALAN_OPENCODE_PLUGIN_MARKER
80178
80115
  );
80179
80116
  default:
@@ -80337,8 +80274,8 @@ function omitUndefined(record2) {
80337
80274
  // src/native-hook-command.ts
80338
80275
  var import_node_crypto19 = require("crypto");
80339
80276
  var import_node_fs23 = require("fs");
80340
- var import_node_os14 = require("os");
80341
- var import_node_path25 = require("path");
80277
+ var import_node_os15 = require("os");
80278
+ var import_node_path26 = require("path");
80342
80279
 
80343
80280
  // src/native-session.ts
80344
80281
  var NATIVE_SESSION_PROVIDER_CAPABILITIES = [
@@ -80572,19 +80509,19 @@ function nonNegativeIntegerField(payload, ...names) {
80572
80509
  return void 0;
80573
80510
  }
80574
80511
  function resolveCodexSessionIdFromTranscriptPath(transcriptPath) {
80575
- const fileName = (0, import_node_path25.basename)(transcriptPath);
80512
+ const fileName = (0, import_node_path26.basename)(transcriptPath);
80576
80513
  const match = /^rollout-.*-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/i.exec(
80577
80514
  fileName
80578
80515
  );
80579
80516
  return match?.[1];
80580
80517
  }
80581
- function resolveKimiTranscriptPath(externalSessionId, kimiHomeDir = process.env.KIMI_CODE_HOME?.trim() || (0, import_node_path25.join)((0, import_node_os14.homedir)(), ".kimi-code")) {
80582
- if ((0, import_node_path25.basename)(externalSessionId) !== externalSessionId) return void 0;
80583
- const sessionsDir = (0, import_node_path25.join)(kimiHomeDir, "sessions");
80518
+ function resolveKimiTranscriptPath(externalSessionId, kimiHomeDir = process.env.KIMI_CODE_HOME?.trim() || (0, import_node_path26.join)((0, import_node_os15.homedir)(), ".kimi-code")) {
80519
+ if ((0, import_node_path26.basename)(externalSessionId) !== externalSessionId) return void 0;
80520
+ const sessionsDir = (0, import_node_path26.join)(kimiHomeDir, "sessions");
80584
80521
  if (!(0, import_node_fs23.existsSync)(sessionsDir)) return void 0;
80585
80522
  for (const workspace of (0, import_node_fs23.readdirSync)(sessionsDir, { withFileTypes: true })) {
80586
80523
  if (!workspace.isDirectory()) continue;
80587
- const transcriptPath = (0, import_node_path25.join)(
80524
+ const transcriptPath = (0, import_node_path26.join)(
80588
80525
  sessionsDir,
80589
80526
  workspace.name,
80590
80527
  externalSessionId,
@@ -80669,8 +80606,8 @@ function parseNativeHookEnvelope(input2) {
80669
80606
  observedAt: (input2.now ?? /* @__PURE__ */ new Date()).toISOString(),
80670
80607
  externalSessionId,
80671
80608
  ...(eventType === "subagent_start" || eventType === "subagent_end") && parentSessionId ? { parentExternalSessionId: parentSessionId } : {},
80672
- ...cwd ? { cwd: (0, import_node_path25.resolve)(cwd) } : {},
80673
- ...transcriptPath ? { transcriptPath: (0, import_node_path25.resolve)(transcriptPath) } : {},
80609
+ ...cwd ? { cwd: (0, import_node_path26.resolve)(cwd) } : {},
80610
+ ...transcriptPath ? { transcriptPath: (0, import_node_path26.resolve)(transcriptPath) } : {},
80674
80611
  ...cursor ? { sourceCursor: cursor } : {},
80675
80612
  providerPayload
80676
80613
  };
@@ -80797,7 +80734,7 @@ function collectNativeIntegrationStatus(args = []) {
80797
80734
  bindConfigPath(args);
80798
80735
  const config2 = readConfig();
80799
80736
  const env = getDaemonCliEnvironment();
80800
- const homeDir = (0, import_node_os14.homedir)();
80737
+ const homeDir = (0, import_node_os15.homedir)();
80801
80738
  return NATIVE_SESSION_PROVIDER_CAPABILITIES.map((capability) => ({
80802
80739
  provider: capability.providerKind,
80803
80740
  command: capability.command,
@@ -80826,7 +80763,7 @@ function decodeResumeFallbackContext(encoded) {
80826
80763
  }
80827
80764
 
80828
80765
  // src/sandbox.ts
80829
- var import_node_os15 = require("os");
80766
+ var import_node_os16 = require("os");
80830
80767
 
80831
80768
  // src/execution-activity-tracker.ts
80832
80769
  var ExecutionActivityTracker = class {
@@ -82123,7 +82060,7 @@ async function runSandbox(config2) {
82123
82060
  }
82124
82061
  const presenter = new WebPresenter(wsClient, config2.sessionId, config2.projectPath);
82125
82062
  presenter.setSuppressSessionLifecycle(true);
82126
- const runtimeSkillManager = await RuntimeSkillManager.open({ homeDirectory: (0, import_node_os15.homedir)() });
82063
+ const runtimeSkillManager = await RuntimeSkillManager.open({ homeDirectory: (0, import_node_os16.homedir)() });
82127
82064
  let lastProviderSessionId = config2.providerSessionId;
82128
82065
  let resumeFallbackContext = config2.resumeFallbackContext;
82129
82066
  let activeBackendKind = config2.backendKind || "claude_cli";
@@ -82423,8 +82360,8 @@ async function runSandbox(config2) {
82423
82360
  // src/service-manager.ts
82424
82361
  var import_node_child_process9 = require("child_process");
82425
82362
  var import_node_fs25 = require("fs");
82426
- var import_node_os16 = require("os");
82427
- var import_node_path26 = require("path");
82363
+ var import_node_os17 = require("os");
82364
+ var import_node_path27 = require("path");
82428
82365
  var SERVICE_LABEL = "ai.tryalan.agent";
82429
82366
  var SYSTEMD_UNIT = "alan-agent.service";
82430
82367
  var WINDOWS_TASK = "Alan Agent";
@@ -82444,8 +82381,8 @@ function buildDaemonServicePlan(input2) {
82444
82381
  if (userId === void 0) throw new Error("Cannot determine the current macOS user ID");
82445
82382
  const domain2 = `gui/${userId}`;
82446
82383
  const serviceTarget = `${domain2}/${SERVICE_LABEL}`;
82447
- const manifestPath = (0, import_node_path26.join)(input2.homeDir, "Library", "LaunchAgents", `${SERVICE_LABEL}.plist`);
82448
- const logDir = (0, import_node_path26.join)(input2.homeDir, ".alan", "agent", "logs");
82384
+ const manifestPath = (0, import_node_path27.join)(input2.homeDir, "Library", "LaunchAgents", `${SERVICE_LABEL}.plist`);
82385
+ const logDir = (0, import_node_path27.join)(input2.homeDir, ".alan", "agent", "logs");
82449
82386
  const programArguments = daemonArgs.map((arg) => ` <string>${xml(arg)}</string>`).join("\n");
82450
82387
  const environmentEntries = Object.entries(input2.environment ?? {}).map(([key, value2]) => ` <key>${xml(key)}</key>
82451
82388
  <string>${xml(value2)}</string>`).join("\n");
@@ -82474,9 +82411,9 @@ ${environmentBlock} <key>RunAtLoad</key>
82474
82411
  <key>ThrottleInterval</key>
82475
82412
  <integer>5</integer>
82476
82413
  <key>StandardOutPath</key>
82477
- <string>${xml((0, import_node_path26.join)(logDir, "daemon.log"))}</string>
82414
+ <string>${xml((0, import_node_path27.join)(logDir, "daemon.log"))}</string>
82478
82415
  <key>StandardErrorPath</key>
82479
- <string>${xml((0, import_node_path26.join)(logDir, "daemon-error.log"))}</string>
82416
+ <string>${xml((0, import_node_path27.join)(logDir, "daemon-error.log"))}</string>
82480
82417
  </dict>
82481
82418
  </plist>
82482
82419
  `;
@@ -82515,7 +82452,7 @@ ${environmentBlock} <key>RunAtLoad</key>
82515
82452
  };
82516
82453
  }
82517
82454
  if (input2.platform === "linux") {
82518
- const manifestPath = (0, import_node_path26.join)(input2.homeDir, ".config", "systemd", "user", SYSTEMD_UNIT);
82455
+ const manifestPath = (0, import_node_path27.join)(input2.homeDir, ".config", "systemd", "user", SYSTEMD_UNIT);
82519
82456
  const environmentLines = Object.entries(input2.environment ?? {}).map(([key, value2]) => `Environment=${systemdArg(`${key}=${value2}`)}`).join("\n");
82520
82457
  const manifest = `[Unit]
82521
82458
  Description=Alan local agent daemon
@@ -82616,7 +82553,7 @@ WantedBy=default.target
82616
82553
  };
82617
82554
  }
82618
82555
  function currentServicePlan(args, runtime) {
82619
- const currentPlatform = (0, import_node_os16.platform)();
82556
+ const currentPlatform = (0, import_node_os17.platform)();
82620
82557
  if (currentPlatform !== "darwin" && currentPlatform !== "linux" && currentPlatform !== "win32") {
82621
82558
  throw new Error(`Daemon service installation is not supported on ${currentPlatform}`);
82622
82559
  }
@@ -82625,15 +82562,15 @@ function currentServicePlan(args, runtime) {
82625
82562
  if (!cliEntry) throw new Error("Cannot determine the alan-agent executable path");
82626
82563
  return buildDaemonServicePlan({
82627
82564
  platform: currentPlatform,
82628
- homeDir: (0, import_node_os16.homedir)(),
82565
+ homeDir: (0, import_node_os17.homedir)(),
82629
82566
  nodeExecutable: runtime?.executable ?? process.execPath,
82630
- cliEntry: (0, import_node_path26.resolve)(cliEntry),
82567
+ cliEntry: (0, import_node_path27.resolve)(cliEntry),
82631
82568
  profile,
82632
82569
  environment: runtime?.environment
82633
82570
  });
82634
82571
  }
82635
82572
  function writeManifest(path2, contents) {
82636
- (0, import_node_fs25.mkdirSync)((0, import_node_path26.dirname)(path2), { recursive: true, mode: 448 });
82573
+ (0, import_node_fs25.mkdirSync)((0, import_node_path27.dirname)(path2), { recursive: true, mode: 448 });
82637
82574
  const pendingPath = `${path2}.pending-${process.pid}`;
82638
82575
  try {
82639
82576
  (0, import_node_fs25.writeFileSync)(pendingPath, contents, { mode: 384 });
@@ -82662,8 +82599,8 @@ function installDaemonService(args = [], runtime) {
82662
82599
  }
82663
82600
  const plan = currentServicePlan(args, runtime);
82664
82601
  if (plan.manifestPath && plan.manifest) {
82665
- if ((0, import_node_os16.platform)() === "darwin") {
82666
- (0, import_node_fs25.mkdirSync)((0, import_node_path26.join)((0, import_node_os16.homedir)(), ".alan", "agent", "logs"), { recursive: true, mode: 448 });
82602
+ if ((0, import_node_os17.platform)() === "darwin") {
82603
+ (0, import_node_fs25.mkdirSync)((0, import_node_path27.join)((0, import_node_os17.homedir)(), ".alan", "agent", "logs"), { recursive: true, mode: 448 });
82667
82604
  }
82668
82605
  writeManifest(plan.manifestPath, plan.manifest);
82669
82606
  }
@@ -82685,11 +82622,11 @@ function printDaemonServiceStatus(args = []) {
82685
82622
 
82686
82623
  // src/skills/skill-cli.ts
82687
82624
  var import_promises6 = require("fs/promises");
82688
- var import_node_os17 = require("os");
82689
- var import_node_path27 = require("path");
82625
+ var import_node_os18 = require("os");
82626
+ var import_node_path28 = require("path");
82690
82627
  async function runSkillsCommand(args) {
82691
82628
  const [subcommand, ...options] = args;
82692
- const homeDirectory2 = option(options, "--home") ?? (0, import_node_os17.homedir)();
82629
+ const homeDirectory2 = option(options, "--home") ?? (0, import_node_os18.homedir)();
82693
82630
  const manager = await RuntimeSkillManager.open({ homeDirectory: homeDirectory2 });
82694
82631
  if (subcommand === "scan") {
82695
82632
  const inputPath = option(options, "--input");
@@ -82730,7 +82667,7 @@ async function defaultScanInput(homeDirectory2) {
82730
82667
  });
82731
82668
  }
82732
82669
  async function readProtectedJson(path2) {
82733
- const absolutePath = (0, import_node_path27.resolve)(path2);
82670
+ const absolutePath = (0, import_node_path28.resolve)(path2);
82734
82671
  const stat2 = await (0, import_promises6.lstat)(absolutePath);
82735
82672
  if (!stat2.isFile()) throw new Error(`Skill input is not a regular file: ${absolutePath}`);
82736
82673
  if (process.platform !== "win32" && (stat2.mode & 63) !== 0) {