tower-studio 0.2.43 → 0.2.45

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 (536) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +5 -0
  3. package/.next/standalone/.next/build-manifest.json +3 -3
  4. package/.next/standalone/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/.next/routes-manifest.json +30 -0
  6. package/.next/standalone/.next/server/app/_global-error/page.js +1 -1
  7. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page/react-loadable-manifest.json +2 -2
  16. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +31 -31
  17. package/.next/standalone/.next/server/app/_not-found/page.js +6 -6
  18. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  19. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  20. package/.next/standalone/.next/server/app/api/adapters/test/route.js +3 -3
  21. package/.next/standalone/.next/server/app/api/adapters/test/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/browse-fs/route.js +1 -1
  23. package/.next/standalone/.next/server/app/api/browse-fs/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/files/assets/[projectId]/[filename]/route.js +1 -1
  25. package/.next/standalone/.next/server/app/api/files/assets/[projectId]/[filename]/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/git/route.js +1 -1
  27. package/.next/standalone/.next/server/app/api/git/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/internal/assets/[projectId]/[filename]/route.js +1 -1
  29. package/.next/standalone/.next/server/app/api/internal/assets/[projectId]/[filename]/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/internal/assets/reveal/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/internal/assistant/attachments/route.js +4 -3
  32. package/.next/standalone/.next/server/app/api/internal/assistant/attachments/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/internal/assistant/chat/route.js +1 -1
  34. package/.next/standalone/.next/server/app/api/internal/assistant/chat/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/internal/assistant/route.js +1 -1
  36. package/.next/standalone/.next/server/app/api/internal/assistant/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/internal/assistant/sessions/route.js +1 -1
  38. package/.next/standalone/.next/server/app/api/internal/assistant/sessions/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/internal/backup/import/route.js +3 -2
  40. package/.next/standalone/.next/server/app/api/internal/backup/import/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/internal/cache/[...segments]/route.js +1 -1
  42. package/.next/standalone/.next/server/app/api/internal/cache/[...segments]/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/internal/harness/ask/route/app-paths-manifest.json +3 -0
  44. package/.next/standalone/.next/server/app/api/internal/harness/ask/route/build-manifest.json +9 -0
  45. package/.next/standalone/.next/server/app/api/internal/harness/ask/route/server-reference-manifest.json +4 -0
  46. package/.next/standalone/.next/server/app/api/internal/harness/ask/route.js +7 -0
  47. package/.next/standalone/.next/server/app/api/internal/harness/ask/route.js.nft.json +1 -0
  48. package/.next/standalone/.next/server/app/api/internal/harness/ask/route_client-reference-manifest.js +3 -0
  49. package/.next/standalone/.next/server/app/api/internal/harness/notify/route/app-paths-manifest.json +3 -0
  50. package/.next/standalone/.next/server/app/api/internal/harness/notify/route/build-manifest.json +9 -0
  51. package/.next/standalone/.next/server/app/api/internal/harness/notify/route/server-reference-manifest.json +4 -0
  52. package/.next/standalone/.next/server/app/api/internal/harness/notify/route.js +7 -0
  53. package/.next/standalone/.next/server/app/api/internal/harness/notify/route.js.nft.json +1 -0
  54. package/.next/standalone/.next/server/app/api/internal/harness/notify/route_client-reference-manifest.js +3 -0
  55. package/.next/standalone/.next/server/app/api/internal/harness/pending/route/app-paths-manifest.json +3 -0
  56. package/.next/standalone/.next/server/app/api/internal/harness/pending/route/build-manifest.json +9 -0
  57. package/.next/standalone/.next/server/app/api/internal/harness/pending/route/server-reference-manifest.json +4 -0
  58. package/.next/standalone/.next/server/app/api/internal/harness/pending/route.js +7 -0
  59. package/.next/standalone/.next/server/app/api/internal/harness/pending/route.js.nft.json +1 -0
  60. package/.next/standalone/.next/server/app/api/internal/harness/pending/route_client-reference-manifest.js +3 -0
  61. package/.next/standalone/.next/server/app/api/internal/harness/reply/route/app-paths-manifest.json +3 -0
  62. package/.next/standalone/.next/server/app/api/internal/harness/reply/route/build-manifest.json +9 -0
  63. package/.next/standalone/.next/server/app/api/internal/harness/reply/route/server-reference-manifest.json +4 -0
  64. package/.next/standalone/.next/server/app/api/internal/harness/reply/route.js +12 -0
  65. package/.next/standalone/.next/server/app/api/internal/harness/reply/route.js.nft.json +1 -0
  66. package/.next/standalone/.next/server/app/api/internal/harness/reply/route_client-reference-manifest.js +3 -0
  67. package/.next/standalone/.next/server/app/api/internal/hooks/install/route.js +1 -1
  68. package/.next/standalone/.next/server/app/api/internal/hooks/install/route.js.nft.json +1 -1
  69. package/.next/standalone/.next/server/app/api/internal/hooks/session/route.js +1 -1
  70. package/.next/standalone/.next/server/app/api/internal/hooks/session/route.js.nft.json +1 -1
  71. package/.next/standalone/.next/server/app/api/internal/hooks/stop/route.js +3 -3
  72. package/.next/standalone/.next/server/app/api/internal/hooks/stop/route.js.nft.json +1 -1
  73. package/.next/standalone/.next/server/app/api/internal/hooks/upload/route.js +2 -2
  74. package/.next/standalone/.next/server/app/api/internal/hooks/upload/route.js.nft.json +1 -1
  75. package/.next/standalone/.next/server/app/api/internal/monaco/[...path]/route.js +1 -1
  76. package/.next/standalone/.next/server/app/api/internal/monaco/[...path]/route.js.nft.json +1 -1
  77. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/buffer/route.js +1 -1
  78. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/buffer/route.js.nft.json +1 -1
  79. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/input/route.js +1 -1
  80. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/input/route.js.nft.json +1 -1
  81. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/paste-image/route.js +1 -1
  82. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/paste-image/route.js.nft.json +1 -1
  83. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/resume/route.js +3 -3
  84. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/resume/route.js.nft.json +1 -1
  85. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/start/route.js +5 -5
  86. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/start/route.js.nft.json +1 -1
  87. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/stop/route.js +4 -4
  88. package/.next/standalone/.next/server/app/api/internal/terminal/[taskId]/stop/route.js.nft.json +1 -1
  89. package/.next/standalone/.next/server/app/api/tasks/[taskId]/diff/route.js +2 -2
  90. package/.next/standalone/.next/server/app/api/tasks/[taskId]/diff/route.js.nft.json +1 -1
  91. package/.next/standalone/.next/server/app/api/tasks/[taskId]/diff-patch/route.js +2 -2
  92. package/.next/standalone/.next/server/app/api/tasks/[taskId]/diff-patch/route.js.nft.json +1 -1
  93. package/.next/standalone/.next/server/app/api/tasks/[taskId]/merge/route.js +4 -3
  94. package/.next/standalone/.next/server/app/api/tasks/[taskId]/merge/route.js.nft.json +1 -1
  95. package/.next/standalone/.next/server/app/harness/page/app-paths-manifest.json +3 -0
  96. package/.next/standalone/.next/server/app/harness/page/build-manifest.json +18 -0
  97. package/.next/standalone/.next/server/app/harness/page/next-font-manifest.json +11 -0
  98. package/.next/standalone/.next/server/app/harness/page/react-loadable-manifest.json +18 -0
  99. package/.next/standalone/.next/server/app/harness/page/server-reference-manifest.json +389 -0
  100. package/.next/standalone/.next/server/app/harness/page.js +25 -0
  101. package/.next/standalone/.next/server/app/harness/page.js.nft.json +1 -0
  102. package/.next/standalone/.next/server/app/harness/page_client-reference-manifest.js +3 -0
  103. package/.next/standalone/.next/server/app/missions/page/react-loadable-manifest.json +1 -1
  104. package/.next/standalone/.next/server/app/missions/page/server-reference-manifest.json +68 -68
  105. package/.next/standalone/.next/server/app/missions/page.js +8 -8
  106. package/.next/standalone/.next/server/app/missions/page.js.nft.json +1 -1
  107. package/.next/standalone/.next/server/app/missions/page_client-reference-manifest.js +1 -1
  108. package/.next/standalone/.next/server/app/onboarding/page/react-loadable-manifest.json +2 -2
  109. package/.next/standalone/.next/server/app/onboarding/page/server-reference-manifest.json +31 -31
  110. package/.next/standalone/.next/server/app/onboarding/page.js +6 -6
  111. package/.next/standalone/.next/server/app/onboarding/page.js.nft.json +1 -1
  112. package/.next/standalone/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
  113. package/.next/standalone/.next/server/app/page/react-loadable-manifest.json +2 -2
  114. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +31 -31
  115. package/.next/standalone/.next/server/app/page.js +6 -6
  116. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  117. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  118. package/.next/standalone/.next/server/app/settings/page/react-loadable-manifest.json +2 -2
  119. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +132 -96
  120. package/.next/standalone/.next/server/app/settings/page.js +9 -8
  121. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  122. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  123. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/archive/page/react-loadable-manifest.json +2 -2
  124. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/archive/page/server-reference-manifest.json +106 -106
  125. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/archive/page.js +8 -8
  126. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/archive/page.js.nft.json +1 -1
  127. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/archive/page_client-reference-manifest.js +1 -1
  128. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/assets/page/react-loadable-manifest.json +2 -2
  129. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/assets/page/server-reference-manifest.json +89 -89
  130. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/assets/page.js +7 -7
  131. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/assets/page.js.nft.json +1 -1
  132. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/assets/page_client-reference-manifest.js +1 -1
  133. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/notes/page/react-loadable-manifest.json +2 -2
  134. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/notes/page/server-reference-manifest.json +78 -78
  135. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/notes/page.js +8 -8
  136. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/notes/page.js.nft.json +1 -1
  137. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/notes/page_client-reference-manifest.js +1 -1
  138. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/page/react-loadable-manifest.json +2 -2
  139. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/page/server-reference-manifest.json +77 -77
  140. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/page.js +8 -7
  141. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/page.js.nft.json +1 -1
  142. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/page_client-reference-manifest.js +1 -1
  143. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/projects/[projectId]/page/react-loadable-manifest.json +2 -2
  144. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/projects/[projectId]/page/server-reference-manifest.json +31 -31
  145. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/projects/[projectId]/page.js +7 -7
  146. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/projects/[projectId]/page.js.nft.json +1 -1
  147. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/projects/[projectId]/page_client-reference-manifest.js +1 -1
  148. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/projects/[projectId]/versions/page/react-loadable-manifest.json +2 -2
  149. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/projects/[projectId]/versions/page/server-reference-manifest.json +67 -67
  150. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/projects/[projectId]/versions/page.js +7 -7
  151. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/projects/[projectId]/versions/page.js.nft.json +1 -1
  152. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/projects/[projectId]/versions/page_client-reference-manifest.js +1 -1
  153. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/tasks/[taskId]/page/react-loadable-manifest.json +3 -3
  154. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/tasks/[taskId]/page/server-reference-manifest.json +83 -83
  155. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/tasks/[taskId]/page.js +10 -9
  156. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/tasks/[taskId]/page.js.nft.json +1 -1
  157. package/.next/standalone/.next/server/app/workspaces/[workspaceId]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  158. package/.next/standalone/.next/server/app/workspaces/page/react-loadable-manifest.json +2 -2
  159. package/.next/standalone/.next/server/app/workspaces/page/server-reference-manifest.json +53 -53
  160. package/.next/standalone/.next/server/app/workspaces/page.js +6 -6
  161. package/.next/standalone/.next/server/app/workspaces/page.js.nft.json +1 -1
  162. package/.next/standalone/.next/server/app/workspaces/page_client-reference-manifest.js +1 -1
  163. package/.next/standalone/.next/server/app-paths-manifest.json +5 -0
  164. package/.next/standalone/.next/server/chunks/{_0keginv._.js → 0se9_next_0cuhhky._.js} +3 -3
  165. package/.next/standalone/.next/server/chunks/0se9_next_dist_esm_build_templates_app-route_03qwlhl.js +1 -1
  166. package/.next/standalone/.next/server/chunks/0se9_next_dist_esm_build_templates_app-route_09pca3o.js +1 -1
  167. package/.next/standalone/.next/server/chunks/0se9_next_dist_esm_build_templates_app-route_0eh8dj_.js +1 -1
  168. package/.next/standalone/.next/server/chunks/0se9_next_dist_esm_build_templates_app-route_0gr2wxq.js +3 -0
  169. package/.next/standalone/.next/server/chunks/0se9_next_dist_esm_build_templates_app-route_0h5yr8p.js +1 -1
  170. package/.next/standalone/.next/server/chunks/0se9_next_dist_esm_build_templates_app-route_0m8aavq.js +1 -1
  171. package/.next/standalone/.next/server/chunks/0se9_next_dist_esm_build_templates_app-route_0yp430z.js +1 -1
  172. package/.next/standalone/.next/server/chunks/0se9_next_dist_esm_build_templates_app-route_0yzw48x.js +1 -1
  173. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0lvlooo._.js → [root-of-the-server]__0-kboke._.js} +1 -1
  174. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-z_a1d._.js +1 -1
  175. package/.next/standalone/.next/server/chunks/[root-of-the-server]__02r7j6y._.js +3 -0
  176. package/.next/standalone/.next/server/chunks/[root-of-the-server]__034jopu._.js +4 -0
  177. package/.next/standalone/.next/server/chunks/[root-of-the-server]__06x1zwj._.js +28 -0
  178. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0j7565a._.js → [root-of-the-server]__07xsu6m._.js} +2 -2
  179. package/.next/standalone/.next/server/chunks/[root-of-the-server]__08-bq72._.js +3 -0
  180. package/.next/standalone/.next/server/chunks/[root-of-the-server]__08-s.nv._.js +4 -0
  181. package/.next/standalone/.next/server/chunks/[root-of-the-server]__08clp-r._.js +3 -0
  182. package/.next/standalone/.next/server/chunks/[root-of-the-server]__095t6ga._.js +3 -0
  183. package/.next/standalone/.next/server/chunks/[root-of-the-server]__098.3z2._.js +1 -1
  184. package/.next/standalone/.next/server/chunks/[root-of-the-server]__09arklv._.js +3 -0
  185. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_7_w.g._.js +3 -0
  186. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_~s0z4._.js +3 -0
  187. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0ehx6q.._.js +3 -0
  188. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0gbyryz._.js +3 -0
  189. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0gn0ubd._.js +1 -1
  190. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0gwztza._.js +1 -1
  191. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0k9rz_z._.js +3 -0
  192. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0khq-k0._.js +3 -0
  193. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0l1-djp._.js +1 -1
  194. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0nt7c0f._.js +3 -0
  195. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o6i1wy._.js +3 -0
  196. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0pmamzv._.js +3 -0
  197. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0pr~t0y._.js +3 -0
  198. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0ajay8_._.js → [root-of-the-server]__0pzyjqf._.js} +1 -1
  199. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0qcpe0l._.js +3 -0
  200. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0qfcg6k._.js +3 -0
  201. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0sq5irw._.js +3 -0
  202. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0tplo5s._.js +3 -0
  203. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0tpzojh._.js +3 -0
  204. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0u8tl88._.js +28 -0
  205. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0v98a~t._.js +3 -0
  206. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0vh3112._.js +3 -0
  207. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0wjr-72._.js +3 -0
  208. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0xasom7._.js +4 -0
  209. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0xot7fu._.js +1 -1
  210. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0xy1t4x._.js +4 -0
  211. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0y3adwk._.js +3 -0
  212. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0y~y6sh._.js +3 -0
  213. package/.next/standalone/.next/server/chunks/[root-of-the-server]__10aw_67._.js +3 -0
  214. package/.next/standalone/.next/server/chunks/[root-of-the-server]__10ci~o9._.js +3 -0
  215. package/.next/standalone/.next/server/chunks/[root-of-the-server]__10jnn26._.js +3 -0
  216. package/.next/standalone/.next/server/chunks/[root-of-the-server]__116v_bx._.js +4 -0
  217. package/.next/standalone/.next/server/chunks/[root-of-the-server]__119rbly._.js +3 -0
  218. package/.next/standalone/.next/server/chunks/[root-of-the-server]__12fmxq0._.js +3 -0
  219. package/.next/standalone/.next/server/chunks/[root-of-the-server]__136ty69._.js +3 -0
  220. package/.next/standalone/.next/server/chunks/{_0q10iet._.js → _02hac5p._.js} +1 -1
  221. package/.next/standalone/.next/server/chunks/{_12537g8._.js → _0je3dz2._.js} +1 -1
  222. package/.next/standalone/.next/server/chunks/_0qk_esg._.js +2 -2
  223. package/.next/standalone/.next/server/chunks/_0t31z6q._.js +1 -1
  224. package/.next/standalone/.next/server/chunks/{_0jmdgq~._.js → _0tidm8l._.js} +1 -1
  225. package/.next/standalone/.next/server/chunks/_0zok2an._.js +7 -0
  226. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_internal_harness_ask_route_actions_0_c62hg.js +3 -0
  227. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_internal_harness_notify_route_actions_08hof6m.js +3 -0
  228. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_internal_harness_pending_route_actions_0w9t_9m.js +3 -0
  229. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_internal_harness_reply_route_actions_0qatz~a.js +3 -0
  230. package/.next/standalone/.next/server/chunks/{src_0fq3zjg._.js → src_05balzk._.js} +2 -2
  231. package/.next/standalone/.next/server/chunks/src_0aqjfcv._.js +3 -0
  232. package/.next/standalone/.next/server/chunks/src_0aygchu._.js +3 -0
  233. package/.next/standalone/.next/server/chunks/{src_0~ey84y._.js → src_0gif-f5._.js} +2 -2
  234. package/.next/standalone/.next/server/chunks/{src_0wlyw0g._.js → src_0vp6.co._.js} +2 -2
  235. package/.next/standalone/.next/server/chunks/src_11k6i~l._.js +3 -0
  236. package/.next/standalone/.next/server/chunks/src_actions_agent-actions_ts_10q9r5b._.js +8 -2
  237. package/.next/standalone/.next/server/chunks/src_lib_02llcit._.js +1 -1
  238. package/.next/standalone/.next/server/chunks/src_lib_0aowbzy._.js +1 -1
  239. package/.next/standalone/.next/server/chunks/src_lib_0d~1~wz._.js +3 -0
  240. package/.next/standalone/.next/server/chunks/src_lib_0nw5n~t._.js +1 -1
  241. package/.next/standalone/.next/server/chunks/src_lib_0ylel_1._.js +3 -0
  242. package/.next/standalone/.next/server/chunks/src_lib_ai_0xx6y51._.js +1 -1
  243. package/.next/standalone/.next/server/chunks/src_lib_ai_providers_index_ts_0.y.3vp._.js +1 -1
  244. package/.next/standalone/.next/server/chunks/src_lib_config-defaults_ts_10ayktg._.js +3 -0
  245. package/.next/standalone/.next/server/chunks/src_lib_config-reader_ts_0e5f7vk._.js +3 -0
  246. package/.next/standalone/.next/server/chunks/ssr/0iu._[workspaceId]_projects_[projectId]_versions_version-timeline-client_tsx_07o_kyi._.js +1 -1
  247. package/.next/standalone/.next/server/chunks/ssr/0se9_next_11h0sx_._.js +1 -1
  248. package/.next/standalone/.next/server/chunks/ssr/0se9_next_dist_esm_build_templates_app-page_0fro4ex.js +4 -0
  249. package/.next/standalone/.next/server/chunks/ssr/0ws9_lucide-react_dist_esm_icons_0r~ty--._.js +3 -0
  250. package/.next/standalone/.next/server/chunks/ssr/12k._sonner_dist_index_mjs_0-vmpk5._.js +3 -0
  251. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0.q~~2p._.js +3 -0
  252. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01zrinc._.js +3 -0
  253. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0iln7n_._.js → [root-of-the-server]__03x8axh._.js} +4 -4
  254. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__04wbr9x._.js +1 -1
  255. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__051tpij._.js +30 -0
  256. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__05xg05r._.js +1 -1
  257. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__06s-_gx._.js +30 -0
  258. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0yby8pl._.js → [root-of-the-server]__06t.cx~._.js} +4 -4
  259. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__08etd~v._.js +30 -0
  260. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0k6oo0n._.js → [root-of-the-server]__096w7g2._.js} +2 -2
  261. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0ecd_1d._.js → [root-of-the-server]__0__klx0._.js} +4 -4
  262. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ccy_gg._.js +3 -0
  263. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0cjmeyl._.js +3 -0
  264. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0dfqa5a._.js +30 -0
  265. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0dmjt7o._.js +30 -0
  266. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0dv.-zu._.js +30 -0
  267. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0lws68d._.js → [root-of-the-server]__0dx9sp-._.js} +4 -4
  268. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0f57j8r._.js +47 -0
  269. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0fl0l82._.js +30 -0
  270. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0g2wrd2._.js +30 -0
  271. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0i0k_zi._.js +30 -0
  272. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ixgha6._.js +30 -0
  273. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0j1dx6p._.js +47 -0
  274. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0jymb~t._.js +1 -1
  275. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0kn~asi._.js +47 -0
  276. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__127w3bm._.js → [root-of-the-server]__0lau3k_._.js} +2 -2
  277. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0m.hayd._.js +47 -0
  278. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0mpjat-._.js +1 -1
  279. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0_z5hke._.js → [root-of-the-server]__0o9jkew._.js} +1 -1
  280. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0sg4fde._.js +4 -0
  281. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0t_zq~v._.js +30 -0
  282. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0zzqn5z._.js → [root-of-the-server]__0tb.1li._.js} +2 -2
  283. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__04ednzb._.js → [root-of-the-server]__0vi-5xg._.js} +2 -2
  284. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0w24qox._.js +47 -0
  285. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0wq~4aj._.js +30 -0
  286. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ydiu_y._.js +30 -0
  287. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0yihqy6._.js +3 -0
  288. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ynq8ty._.js +3 -0
  289. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0z7je5_._.js +1 -1
  290. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0zouyfp._.js +3 -0
  291. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0~s8otw._.js +30 -0
  292. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1184s~q._.js +3 -0
  293. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11fp64w._.js +3 -0
  294. package/.next/standalone/.next/server/chunks/ssr/_0-~9em3._.js +1 -1
  295. package/.next/standalone/.next/server/chunks/ssr/_0..h3hk._.js +3 -0
  296. package/.next/standalone/.next/server/chunks/ssr/_0.iq8t8._.js +4 -0
  297. package/.next/standalone/.next/server/chunks/ssr/_00.myc6._.js +3 -0
  298. package/.next/standalone/.next/server/chunks/ssr/_00eymu8._.js +3 -0
  299. package/.next/standalone/.next/server/chunks/ssr/{_07lq-bp._.js → _01fdzzv._.js} +1 -1
  300. package/.next/standalone/.next/server/chunks/ssr/{_0_q41~z._.js → _03-we0p._.js} +4 -4
  301. package/.next/standalone/.next/server/chunks/ssr/{_0uryq~z._.js → _04szgc6._.js} +2 -2
  302. package/.next/standalone/.next/server/chunks/ssr/{_113957g._.js → _078cdw~._.js} +1 -1
  303. package/.next/standalone/.next/server/chunks/ssr/_08bq4g8._.js +1 -1
  304. package/.next/standalone/.next/server/chunks/ssr/{_0j5.ig_._.js → _09rq08e._.js} +1 -1
  305. package/.next/standalone/.next/server/chunks/ssr/_09z-55_._.js +17 -0
  306. package/.next/standalone/.next/server/chunks/ssr/{src_components_ui_popover_tsx_0a78wqo._.js → _0bndp1~._.js} +2 -2
  307. package/.next/standalone/.next/server/chunks/ssr/{_08-x_rp._.js → _0h0b46r._.js} +1 -1
  308. package/.next/standalone/.next/server/chunks/ssr/{_0wqcz3w._.js → _0kd_tda._.js} +4 -4
  309. package/.next/standalone/.next/server/chunks/ssr/{_07q06~v._.js → _0ktexki._.js} +4 -4
  310. package/.next/standalone/.next/server/chunks/ssr/{_0b7smy6._.js → _0ljrvyt._.js} +2 -2
  311. package/.next/standalone/.next/server/chunks/ssr/_0lo1nei._.js +6 -0
  312. package/.next/standalone/.next/server/chunks/ssr/_0mdd702._.js +3 -0
  313. package/.next/standalone/.next/server/chunks/ssr/_0n0q6~9._.js +3 -0
  314. package/.next/standalone/.next/server/chunks/ssr/_0os43sb._.js +3 -0
  315. package/.next/standalone/.next/server/chunks/ssr/_0pab_al._.js +3 -0
  316. package/.next/standalone/.next/server/chunks/ssr/{_047dh-f._.js → _0pg6-.y._.js} +2 -2
  317. package/.next/standalone/.next/server/chunks/ssr/{_05a2u03._.js → _0pvp63a._.js} +4 -4
  318. package/.next/standalone/.next/server/chunks/ssr/_0qi4x-5._.js +3 -0
  319. package/.next/standalone/.next/server/chunks/ssr/{_0s.h4l2._.js → _0qnobd-._.js} +1 -1
  320. package/.next/standalone/.next/server/chunks/ssr/_0rdyrfd._.js +1 -1
  321. package/.next/standalone/.next/server/chunks/ssr/_0ts~td3._.js +3 -0
  322. package/.next/standalone/.next/server/chunks/ssr/_0wbcp88._.js +1 -1
  323. package/.next/standalone/.next/server/chunks/ssr/{_0s.ik0k._.js → _0xnn~jq._.js} +1 -1
  324. package/.next/standalone/.next/server/chunks/ssr/_0y0_4zs._.js +3 -0
  325. package/.next/standalone/.next/server/chunks/ssr/{_0nze-e6._.js → _0ytcm0j._.js} +1 -1
  326. package/.next/standalone/.next/server/chunks/ssr/_0yva1-.._.js +3 -0
  327. package/.next/standalone/.next/server/chunks/ssr/{_0dxbp89._.js → _0yz5dmq._.js} +4 -4
  328. package/.next/standalone/.next/server/chunks/ssr/{_060e1u.._.js → _0~6pqk.._.js} +1 -1
  329. package/.next/standalone/.next/server/chunks/ssr/_11w13--._.js +3 -0
  330. package/.next/standalone/.next/server/chunks/ssr/{_0oeih09._.js → _12la163._.js} +2 -2
  331. package/.next/standalone/.next/server/chunks/ssr/{_0rtydyv._.js → _13_b8hh._.js} +1 -1
  332. package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_09eeb85._.js +3 -0
  333. package/.next/standalone/.next/server/chunks/ssr/src_0djxlqx._.js +1 -1
  334. package/.next/standalone/.next/server/chunks/ssr/src_0eufeyj._.js +1 -1
  335. package/.next/standalone/.next/server/chunks/ssr/src_0vv366l._.js +3 -0
  336. package/.next/standalone/.next/server/chunks/ssr/src_actions_agent-actions_ts_0~wc.sy._.js +8 -2
  337. package/.next/standalone/.next/server/chunks/ssr/src_actions_file-actions_ts_0gcvqwm._.js +1 -1
  338. package/.next/standalone/.next/server/chunks/ssr/src_app_missions_missions-client_tsx_11429lj._.js +1 -1
  339. package/.next/standalone/.next/server/chunks/ssr/src_app_onboarding_page_tsx_0xf7hpz._.js +1 -1
  340. package/.next/standalone/.next/server/chunks/ssr/src_app_settings_page_tsx_0h9v7dr._.js +1 -1
  341. package/.next/standalone/.next/server/chunks/ssr/src_app_workspaces_[workspaceId]_assets_assets-page-client_tsx_0wyzpam._.js +1 -1
  342. package/.next/standalone/.next/server/chunks/ssr/src_app_workspaces_[workspaceId]_board-page-client_tsx_0gips66._.js +1 -1
  343. package/.next/standalone/.next/server/chunks/ssr/src_app_workspaces_[workspaceId]_notes_notes-page-client_tsx_10gyo3v._.js +1 -1
  344. package/.next/standalone/.next/server/chunks/ssr/src_app_workspaces_[workspaceId]_tasks_[taskId]_task-page-client_tsx_02t7blt._.js +1 -1
  345. package/.next/standalone/.next/server/chunks/ssr/src_components_0rowjw~._.js +7 -0
  346. package/.next/standalone/.next/server/chunks/ssr/{src_lib_0.~.oo-._.js → src_lib_0-x.wbd._.js} +1 -1
  347. package/.next/standalone/.next/server/chunks/ssr/{src_lib_00wjv6n._.js → src_lib_00p-ir2._.js} +1 -1
  348. package/.next/standalone/.next/server/chunks/ssr/src_lib_03x1i~1._.js +5 -0
  349. package/.next/standalone/.next/server/chunks/ssr/{src_lib_005uqbe._.js → src_lib_03xtona._.js} +1 -1
  350. package/.next/standalone/.next/server/chunks/ssr/{src_lib_01sr8_t._.js → src_lib_04y-65j._.js} +1 -1
  351. package/.next/standalone/.next/server/chunks/ssr/src_lib_08gthaz._.js +3 -0
  352. package/.next/standalone/.next/server/chunks/ssr/src_lib_090~6pq._.js +3 -0
  353. package/.next/standalone/.next/server/chunks/ssr/src_lib_0k8dkbn._.js +3 -0
  354. package/.next/standalone/.next/server/chunks/ssr/src_lib_0knbpxk._.js +3 -0
  355. package/.next/standalone/.next/server/chunks/ssr/src_lib_0p_iehl._.js +3 -0
  356. package/.next/standalone/.next/server/chunks/ssr/src_lib_0qve1ri._.js +3 -0
  357. package/.next/standalone/.next/server/chunks/ssr/src_lib_0s35u~4._.js +3 -0
  358. package/.next/standalone/.next/server/chunks/ssr/src_lib_0x2ui80._.js +3 -0
  359. package/.next/standalone/.next/server/chunks/ssr/src_lib_0ypc5_d._.js +3 -0
  360. package/.next/standalone/.next/server/chunks/ssr/src_lib_10jh2mz._.js +3 -0
  361. package/.next/standalone/.next/server/chunks/ssr/src_lib_harness_harness-message_ts_0_3ygf9._.js +3 -0
  362. package/.next/standalone/.next/server/chunks/ssr/src_lib_worktree_ts_06cucy3._.js +1 -1
  363. package/.next/standalone/.next/server/functions-config-manifest.json +5 -0
  364. package/.next/standalone/.next/server/instrumentation.js +1 -1
  365. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  366. package/.next/standalone/.next/server/next-font-manifest.js +1 -1
  367. package/.next/standalone/.next/server/next-font-manifest.json +4 -0
  368. package/.next/standalone/.next/server/pages/500.html +1 -1
  369. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  370. package/.next/standalone/.next/server/server-reference-manifest.json +582 -330
  371. package/.next/standalone/.next/static/chunks/0-nppzqp-r.9c.js +1 -0
  372. package/.next/standalone/.next/static/chunks/{0-vgfstmpuwnx.js → 0-te2tg6~a23u.js} +1 -1
  373. package/.next/standalone/.next/static/chunks/0.64.6c1mh7d2.js +1 -0
  374. package/.next/standalone/.next/static/chunks/0.8n1ce9lggg4.js +1 -0
  375. package/.next/standalone/.next/static/chunks/0.zgqz~m3sjej.js +1 -0
  376. package/.next/standalone/.next/static/chunks/00.eotegra08r.js +1 -0
  377. package/.next/standalone/.next/static/chunks/{0sr-m2t6vck14.js → 02xqrfqu.s8-i.js} +1 -1
  378. package/.next/standalone/.next/static/chunks/03y272e6e9o8i.js +1 -0
  379. package/.next/standalone/.next/static/chunks/08eyd7sq064r0.js +1 -0
  380. package/.next/standalone/.next/static/chunks/09b33znj4m__c.js +1 -0
  381. package/.next/standalone/.next/static/chunks/{0ts___1ygewqp.js → 09bezwcb__18t.js} +1 -1
  382. package/.next/standalone/.next/static/chunks/{14mk_a0k99wbg.js → 0bvhkgitn__gl.js} +1 -1
  383. package/.next/standalone/.next/static/chunks/0c.t.evwah_m4.js +1 -0
  384. package/.next/standalone/.next/static/chunks/{08i9.47-_mxro.js → 0c4-6qdhi645s.js} +1 -1
  385. package/.next/standalone/.next/static/chunks/0d0zm8viq3ol4.js +12 -0
  386. package/.next/standalone/.next/static/chunks/0dktl5t_dtxu..js +1 -0
  387. package/.next/standalone/.next/static/chunks/0e5~nzt657k92.js +1 -0
  388. package/.next/standalone/.next/static/chunks/0erwxvpb9w29_.js +1 -0
  389. package/.next/standalone/.next/static/chunks/{04op7bjge~n4l.js → 0gy79dfi~lnig.js} +1 -1
  390. package/.next/standalone/.next/static/chunks/{0rjt_ddd~6t8r.js → 0gz3xwb5_8xwv.js} +1 -1
  391. package/.next/standalone/.next/static/chunks/0i75~pu.bp20..js +1 -0
  392. package/.next/standalone/.next/static/chunks/0jn_w5b9r~beu.js +1 -0
  393. package/.next/standalone/.next/static/chunks/0l59z2mf1ouxu.js +1 -0
  394. package/.next/standalone/.next/static/chunks/0m4xd-ie7j.hx.js +1 -0
  395. package/.next/standalone/.next/static/chunks/0mx9ebe6we4z0.js +1 -0
  396. package/.next/standalone/.next/static/chunks/0nsggimu5je3g.js +1 -0
  397. package/.next/standalone/.next/static/chunks/0nw8nx8kafy79.js +1 -0
  398. package/.next/standalone/.next/static/chunks/0pzjryav9pm7p.js +1 -0
  399. package/.next/standalone/.next/static/chunks/0q-rl50zskr35.js +1 -0
  400. package/.next/standalone/.next/static/chunks/0qqy2x-fsmmmx.js +1 -0
  401. package/.next/standalone/.next/static/chunks/0t59wpux0g1~l.js +1 -0
  402. package/.next/standalone/.next/static/chunks/0uezq8wiwkq8d.js +1 -0
  403. package/.next/standalone/.next/static/chunks/0vrc~7m1_cuvl.js +1 -0
  404. package/.next/standalone/.next/static/chunks/0xbh24-hxrt~m.css +1 -0
  405. package/.next/standalone/.next/static/chunks/0xkkmruo8p.l_.js +1 -0
  406. package/.next/standalone/.next/static/chunks/0xx0pe_j2kmr9.js +2 -0
  407. package/.next/standalone/.next/static/chunks/0zqjqiqmorenw.js +5 -0
  408. package/.next/standalone/.next/static/chunks/136l78utn~v08.js +1 -0
  409. package/.next/standalone/.next/static/chunks/171x9kw9wcyk4.js +1 -0
  410. package/.next/standalone/.next/static/chunks/{11p.r-9wyh7_2.js → 17m4o~gdsvuo3.js} +1 -1
  411. package/.next/standalone/package.json +5 -5
  412. package/dist/mcp-server.cjs +227 -25
  413. package/package.json +5 -5
  414. package/prisma/schema.prisma +37 -0
  415. package/scripts/migrations/0005-add-parent-task-id.ts +29 -0
  416. package/scripts/{stop-hook.js → tower-stop-hook.js} +42 -3
  417. package/skills/tower/SKILL.md +31 -0
  418. package/skills/tower/references/unattended-messaging.md +95 -0
  419. package/tsconfig.json +14 -4
  420. package/.next/standalone/.next/server/chunks/[externals]__0m6hc.0._.js +0 -3
  421. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0.p6em~._.js +0 -3
  422. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0.zmhk-._.js +0 -3
  423. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0042hx5._.js +0 -3
  424. package/.next/standalone/.next/server/chunks/[root-of-the-server]__03ufxqq._.js +0 -28
  425. package/.next/standalone/.next/server/chunks/[root-of-the-server]__04--bs7._.js +0 -3
  426. package/.next/standalone/.next/server/chunks/[root-of-the-server]__04m2l8a._.js +0 -3
  427. package/.next/standalone/.next/server/chunks/[root-of-the-server]__04r193~._.js +0 -3
  428. package/.next/standalone/.next/server/chunks/[root-of-the-server]__05abzth._.js +0 -3
  429. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0657y50._.js +0 -3
  430. package/.next/standalone/.next/server/chunks/[root-of-the-server]__075a0hk._.js +0 -3
  431. package/.next/standalone/.next/server/chunks/[root-of-the-server]__08yqoti._.js +0 -3
  432. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_d.s7s._.js +0 -28
  433. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0b25v3p._.js +0 -4
  434. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0clptds._.js +0 -3
  435. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0g.k9o~._.js +0 -3
  436. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0h6bl6t._.js +0 -3
  437. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0i~3dwq._.js +0 -3
  438. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0j05vlm._.js +0 -3
  439. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0j1px8f._.js +0 -3
  440. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0k-5ag7._.js +0 -3
  441. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0otyifi._.js +0 -3
  442. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0q~uf3u._.js +0 -3
  443. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0t31ba_._.js +0 -3
  444. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0t_weyi._.js +0 -3
  445. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0uptkzd._.js +0 -4
  446. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0wkjqrd._.js +0 -3
  447. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0x3kws1._.js +0 -3
  448. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0y8w5di._.js +0 -4
  449. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0~g6-c~._.js +0 -3
  450. package/.next/standalone/.next/server/chunks/[root-of-the-server]__10fv6tt._.js +0 -3
  451. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1189rd1._.js +0 -4
  452. package/.next/standalone/.next/server/chunks/src_0weytpz._.js +0 -3
  453. package/.next/standalone/.next/server/chunks/src_lib_0i2.v2d._.js +0 -3
  454. package/.next/standalone/.next/server/chunks/src_lib_12xey8u._.js +0 -3
  455. package/.next/standalone/.next/server/chunks/ssr/0ws9_lucide-react_dist_esm_icons_0pkla8j._.js +0 -3
  456. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__00dh103._.js +0 -3
  457. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__00ebsjb._.js +0 -30
  458. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01vm_46._.js +0 -47
  459. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__025ol9g._.js +0 -3
  460. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__065f3ii._.js +0 -3
  461. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__06dfcgo._.js +0 -30
  462. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__07xkj1s._.js +0 -47
  463. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__08k-xb7._.js +0 -3
  464. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__08tzbfh._.js +0 -3
  465. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0iaw1ms._.js +0 -3
  466. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0j_-qk5._.js +0 -30
  467. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0oamph.._.js +0 -47
  468. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0pnv7nd._.js +0 -30
  469. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0stlq2_._.js +0 -4
  470. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0tja~wz._.js +0 -30
  471. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ug022w._.js +0 -30
  472. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0x6k.ee._.js +0 -30
  473. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0xr45lx._.js +0 -3
  474. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0xwzk2.._.js +0 -47
  475. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0zxc81t._.js +0 -30
  476. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__10c.a3u._.js +0 -30
  477. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__10n3vn6._.js +0 -30
  478. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__123rmyb._.js +0 -30
  479. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__124zb~p._.js +0 -30
  480. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__12ko8p6._.js +0 -3
  481. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__13ce7v2._.js +0 -30
  482. package/.next/standalone/.next/server/chunks/ssr/_00l85fp._.js +0 -4
  483. package/.next/standalone/.next/server/chunks/ssr/_00odlgv._.js +0 -3
  484. package/.next/standalone/.next/server/chunks/ssr/_0463zy~._.js +0 -3
  485. package/.next/standalone/.next/server/chunks/ssr/_05k76ur._.js +0 -3
  486. package/.next/standalone/.next/server/chunks/ssr/_070t_mh._.js +0 -6
  487. package/.next/standalone/.next/server/chunks/ssr/_0cj9a7y._.js +0 -7
  488. package/.next/standalone/.next/server/chunks/ssr/_0gkid_a._.js +0 -3
  489. package/.next/standalone/.next/server/chunks/ssr/_0rrs.-d._.js +0 -3
  490. package/.next/standalone/.next/server/chunks/ssr/_0rxeqmo._.js +0 -17
  491. package/.next/standalone/.next/server/chunks/ssr/_0syb503._.js +0 -3
  492. package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_03r.9go._.js +0 -3
  493. package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_06f0dao._.js +0 -3
  494. package/.next/standalone/.next/server/chunks/ssr/src_components_ui_select_tsx_0d2ra01._.js +0 -3
  495. package/.next/standalone/.next/server/chunks/ssr/src_lib_08jql1e._.js +0 -3
  496. package/.next/standalone/.next/server/chunks/ssr/src_lib_0b~j-9d._.js +0 -3
  497. package/.next/standalone/.next/server/chunks/ssr/src_lib_0eymyjf._.js +0 -3
  498. package/.next/standalone/.next/server/chunks/ssr/src_lib_0fkv9z3._.js +0 -3
  499. package/.next/standalone/.next/server/chunks/ssr/src_lib_0n-n0.a._.js +0 -3
  500. package/.next/standalone/.next/server/chunks/ssr/src_lib_0sgt~lv._.js +0 -3
  501. package/.next/standalone/.next/server/chunks/ssr/src_lib_0sms4xl._.js +0 -5
  502. package/.next/standalone/.next/server/chunks/ssr/src_lib_0x-iyl1._.js +0 -3
  503. package/.next/standalone/.next/server/chunks/ssr/src_lib_0yjmty1._.js +0 -3
  504. package/.next/standalone/.next/server/chunks/ssr/src_lib_13aevv6._.js +0 -3
  505. package/.next/standalone/.next/static/chunks/0.lqb7y9kz5z6.js +0 -1
  506. package/.next/standalone/.next/static/chunks/0.lyp-cx3zt9..js +0 -2
  507. package/.next/standalone/.next/static/chunks/00z.kuqsfrxq5.js +0 -12
  508. package/.next/standalone/.next/static/chunks/01rbl6a8z.tuw.js +0 -1
  509. package/.next/standalone/.next/static/chunks/01yoibobkdz3x.js +0 -1
  510. package/.next/standalone/.next/static/chunks/05v-c3ir3ik_1.js +0 -5
  511. package/.next/standalone/.next/static/chunks/070fs6rmafi.i.js +0 -1
  512. package/.next/standalone/.next/static/chunks/07i9j5yyg4vs3.js +0 -1
  513. package/.next/standalone/.next/static/chunks/0_yp-y9l0upp~.js +0 -1
  514. package/.next/standalone/.next/static/chunks/0ddt-snh45031.js +0 -1
  515. package/.next/standalone/.next/static/chunks/0evfu1ozaw5ak.js +0 -1
  516. package/.next/standalone/.next/static/chunks/0gq65t6au55oa.js +0 -1
  517. package/.next/standalone/.next/static/chunks/0gz71w_~yw2iu.js +0 -1
  518. package/.next/standalone/.next/static/chunks/0hk3lmsij2x1c.js +0 -1
  519. package/.next/standalone/.next/static/chunks/0j1hqwmeaqnn2.js +0 -1
  520. package/.next/standalone/.next/static/chunks/0jrje~1gt6w85.css +0 -1
  521. package/.next/standalone/.next/static/chunks/0p4w5b_p_yju8.js +0 -1
  522. package/.next/standalone/.next/static/chunks/0prrt_bws8ml6.js +0 -1
  523. package/.next/standalone/.next/static/chunks/0qgqjy.9.-qpi.js +0 -1
  524. package/.next/standalone/.next/static/chunks/0rfq8fy71hj7c.js +0 -1
  525. package/.next/standalone/.next/static/chunks/0rnitheqdpd1..js +0 -1
  526. package/.next/standalone/.next/static/chunks/0vmy6tsqy.xf4.js +0 -1
  527. package/.next/standalone/.next/static/chunks/0wbq-_8jyxjxm.js +0 -1
  528. package/.next/standalone/.next/static/chunks/0xejm4ge9~cn..js +0 -1
  529. package/.next/standalone/.next/static/chunks/0~prx0ure_1i6.js +0 -1
  530. package/.next/standalone/.next/static/chunks/1107zshxaajt9.js +0 -1
  531. package/.next/standalone/.next/static/chunks/11x3_612u8w~9.js +0 -1
  532. /package/.next/standalone/.next/static/{d-Uhp63kgWdPkhPt7Fzyb → f1860bJqnbYj-1WLMj7F-}/_buildManifest.js +0 -0
  533. /package/.next/standalone/.next/static/{d-Uhp63kgWdPkhPt7Fzyb → f1860bJqnbYj-1WLMj7F-}/_clientMiddlewareManifest.js +0 -0
  534. /package/.next/standalone/.next/static/{d-Uhp63kgWdPkhPt7Fzyb → f1860bJqnbYj-1WLMj7F-}/_ssgManifest.js +0 -0
  535. /package/scripts/{post-tool-hook.js → tower-post-tool-hook.js} +0 -0
  536. /package/scripts/{session-start-hook.js → tower-session-start-hook.js} +0 -0
@@ -0,0 +1,3 @@
1
+ module.exports=[215624,e=>{"use strict";var t=e.i(921675),a=e.i(843793),n=e.i(195158),r=e.i(50377),i=e.i(86708);let s=["onboarding.completed","onboarding.lastStep","onboarding.username"];async function o(){let e=await a.db.systemConfig.findMany({where:{key:{in:[...s]}}}),t={};for(let a of e)try{t[a.key]=JSON.parse(a.value)}catch{t[a.key]=null}let n=!0===t["onboarding.completed"],r=t["onboarding.lastStep"],i=t["onboarding.username"];return{isFirstRun:!n,isCompleted:n,lastStep:"number"==typeof r?r:0,username:"string"==typeof i&&i.length>0?i:null}}async function d(e){await a.db.systemConfig.upsert({where:{key:"onboarding.lastStep"},create:{key:"onboarding.lastStep",value:JSON.stringify(e)},update:{value:JSON.stringify(e)}}),(0,n.revalidatePath)("/","layout")}async function l(e,t=4){if(await a.db.systemConfig.upsert({where:{key:"onboarding.completed"},create:{key:"onboarding.completed",value:"true"},update:{value:"true"}}),await a.db.systemConfig.upsert({where:{key:"onboarding.lastStep"},create:{key:"onboarding.lastStep",value:String(t)},update:{value:String(t)}}),void 0!==e){let t=e.trim().slice(0,64).replace(/[\r\n]/g," ");t.length>0&&await a.db.systemConfig.upsert({where:{key:"onboarding.username"},create:{key:"onboarding.username",value:JSON.stringify(t)},update:{value:JSON.stringify(t)}})}(0,n.revalidatePath)("/","layout")}async function u(e,t){await a.db.systemConfig.upsert({where:{key:"onboarding.extensions.requested"},create:{key:"onboarding.extensions.requested",value:JSON.stringify(e)},update:{value:JSON.stringify(e)}}),await a.db.systemConfig.upsert({where:{key:"onboarding.extensions.completed"},create:{key:"onboarding.extensions.completed",value:JSON.stringify(t)},update:{value:JSON.stringify(t)}}),(0,n.revalidatePath)("/","layout")}async function c(t){try{r.logger.create("task-completion").info("Task completion event dispatched",{taskId:t.taskId,taskTitle:t.taskTitle,status:t.status,executionId:t.executionId});let{broadcastNotification:a}=await e.A(590621);a({...t,type:"completion"}),(async()=>{try{let{db:a}=await e.A(989186),{recordHarnessMessage:n}=await e.A(60345),r=await a.task.findUnique({where:{id:t.taskId},select:{unattended:!0}});if(!r?.unattended)return;let i="COMPLETED"===t.status;await n({taskId:t.taskId,executionId:t.executionId,kind:i?"done":"failed",content:i?"任务已完成,进入待审阅。":"任务执行失败,请查看终端。"})}catch{}})()}catch{}}(0,i.ensureServerEntryExports)([o,d,l,u,c]),(0,t.registerServerReference)(o,"0018fbdd66aba52ffae0eea94c547cdac80082d648",null),(0,t.registerServerReference)(d,"4043130a1d362ee33ae88de0ed751aa1fbfa0fb132",null),(0,t.registerServerReference)(l,"602e0b75d87a1db34c3ffadaf61190e40e67bb0a42",null),(0,t.registerServerReference)(u,"603480184e60c27214a54381387436ff640e52b1b6",null),(0,t.registerServerReference)(c,"40a9ab396e79818e2ea0459b4f4c315855196db134",null),e.s(["dispatchTaskCompletionEvent",0,c])},590621,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0~ju4-d._.js","server/chunks/src_lib_0d~1~wz._.js"].map(t=>e.l(t))).then(()=>t(513200)))},989186,e=>{e.v(e=>Promise.resolve().then(()=>e(843793)))},60345,e=>{e.v(e=>Promise.resolve().then(()=>e(108789)))}];
2
+
3
+ //# sourceMappingURL=src_11k6i~l._.js.map
@@ -1,4 +1,10 @@
1
- module.exports=[756264,e=>{"use strict";var t=e.i(921675),a=e.i(843793),r=e.i(195158),i=e.i(248434),n=e.i(83721),s=e.i(50377),d=e.i(572173),o=e.i(89428),c=e.i(924868),l=e.i(446786),u=e.i(814747),w=e.i(86708);let h=s.logger.create("agent-actions"),f=(0,u.join)((0,l.tmpdir)(),"tower-signals");async function p(e,t){try{await (0,c.mkdir)(f,{recursive:!0,mode:448}),await (0,c.writeFile)((0,u.join)(f,`exit-${e}`),String(t),{mode:384})}catch{}}async function k(e,t){let i=await a.db.taskMessage.create({data:{role:"USER",content:t,taskId:e}});return(0,r.revalidatePath)("/workspaces"),{userMessage:i}}async function b(e){return a.db.taskMessage.findMany({where:{taskId:e},orderBy:{createdAt:"asc"}})}async function E(e,t="CLAUDE_CODE",i,n){let s=await a.db.taskExecution.create({data:{taskId:e,agent:t,status:"RUNNING",startedAt:new Date,worktreePath:i??null,worktreeBranch:n??null}});return await a.db.task.update({where:{id:e},data:{status:"IN_PROGRESS"}}),(0,r.revalidatePath)("/workspaces"),s}async function P(e,t="FAILED"){let i=await a.db.taskExecution.update({where:{id:e},data:{status:t,endedAt:new Date}});return(0,r.revalidatePath)("/workspaces"),i}async function m(t){let{destroySession:i,getSession:n}=await e.A(217260),s=n(t),d=s?.getBuffer()??"",o=await a.db.taskExecution.findFirst({where:{taskId:t,status:"RUNNING"},orderBy:{createdAt:"desc"}}),c=await a.db.task.findUnique({where:{id:t},include:{project:{select:{localPath:!0}}}});if(i(t),o){await a.db.taskExecution.update({where:{id:o.id},data:{status:"COMPLETED",endedAt:new Date}}),await a.db.task.update({where:{id:t},data:{status:"IN_REVIEW"}});let r=o.worktreePath||c?.project?.localPath||null,{captureExecutionSummary:i}=await e.A(507603);await i(o.id,t,0,d,r,o.forkCommit)}(0,r.revalidatePath)("/workspaces")}async function g(e){return a.db.taskExecution.findMany({where:{taskId:e},orderBy:{createdAt:"desc"},include:{insightNote:{select:{id:!0,title:!0,content:!0}}}})}async function I(t,i){let s=await a.db.task.findUnique({where:{id:t},include:{project:!0}});if(!s)throw Error("Task not found");if(!s.project?.localPath)throw Error("Project has no local path configured");await a.db.taskExecution.updateMany({where:{taskId:t,status:"RUNNING",NOT:{sessionId:i}},data:{status:"FAILED",endedAt:new Date}});let c=await a.db.taskExecution.findFirst({where:{taskId:t,sessionId:i},orderBy:{createdAt:"desc"}});if(!c)throw Error("Previous execution not found");let l=c.worktreePath??s.project.localPath,w=s.subPath?(0,u.join)(l,s.subPath):l,f=await (0,d.readConfigValue)("terminal.idleTimeoutSec",180),{adapter:k}=await (0,o.resolveCliAdapter)("terminal"),b=k.buildEnvOverrides({taskId:t,taskTitle:s.title,apiUrl:`http://localhost:${process.env.PORT||"3000"}`,callbackUrl:c.callbackUrl??void 0}),E=await a.db.taskExecution.update({where:{id:c.id},data:{status:"RUNNING",endedAt:null}});await a.db.task.update({where:{id:t},data:{status:"IN_PROGRESS"}}),(0,r.revalidatePath)("/workspaces");let P=await (0,d.readConfigValue)("onboarding.username",""),m=k.buildSpawnArgs({taskId:t,prompt:"",cwd:w,resumeSessionId:i,extraArgs:[...P?["--append-system-prompt",`The user's name is ${P}.`]:[]],envOverrides:b}),g=/no conversation found with session id|unknown session|session .* not found/i;return(0,n.createSession)(t,m.command,m.args,w,()=>{},async r=>{await p(t,r);let n=await a.db.taskExecution.findUnique({where:{id:E.id}});if(n?.status!=="RUNNING")return;let{getSession:d}=await e.A(217260),o=d(t),l=o?.getBuffer()??"";if(0!==r&&g.test(l)){h.info("Session resume failed — retrying with fresh execution",{taskId:t,previousSessionId:i}),await a.db.taskExecution.update({where:{id:E.id},data:{status:"FAILED",endedAt:new Date}}).catch(()=>{});try{await N(t,s.title)}catch(e){h.error("Fresh execution retry also failed",e,{taskId:t})}return}await a.db.taskExecution.update({where:{id:E.id},data:{status:0===r?"COMPLETED":"FAILED",endedAt:new Date}}).catch(()=>{});let u=c.worktreePath||s.project.localPath,{captureExecutionSummary:w}=await e.A(507603);await w(E.id,t,r,l,u,E.forkCommit);let{dispatchTaskCompletionEvent:f}=await e.A(136565);await f({taskId:t,taskTitle:s.title,status:0===r?"COMPLETED":"FAILED",executionId:E.id,workspaceId:s.project.workspaceId}),0===r&&await a.db.task.update({where:{id:t},data:{status:"IN_REVIEW"}}).catch(()=>{})},m.env,void 0,1e3*f),{executionId:E.id,worktreePath:c.worktreePath??l??null}}async function A(t){let i=await a.db.task.findUnique({where:{id:t},include:{project:!0}});if(!i)throw Error("Task not found");if(!i.project?.localPath)throw Error("Project has no local path configured");let s=await a.db.taskExecution.findFirst({where:{taskId:t},orderBy:{createdAt:"desc"}}),{destroySession:c}=await e.A(217260);c(t),await a.db.taskExecution.updateMany({where:{taskId:t,status:"RUNNING"},data:{status:"FAILED",endedAt:new Date}});let l=s?.worktreePath??i.project.localPath,w=i.subPath?(0,u.join)(l,i.subPath):l,h=await (0,d.readConfigValue)("terminal.idleTimeoutSec",180),{adapter:f,provider:k}=await (0,o.resolveCliAdapter)("terminal"),b=f.buildEnvOverrides({taskId:t,taskTitle:i.title,apiUrl:`http://localhost:${process.env.PORT||"3000"}`}),E=await a.db.taskExecution.create({data:{taskId:t,agent:k.agentFieldValue,status:"RUNNING",startedAt:new Date,worktreePath:s?.worktreePath??null,worktreeBranch:s?.worktreeBranch??null}});await a.db.task.update({where:{id:t},data:{status:"IN_PROGRESS"}}),(0,r.revalidatePath)("/workspaces");let P=await (0,d.readConfigValue)("onboarding.username",""),m=f.buildSpawnArgs({taskId:t,prompt:"",cwd:w,continueLatest:!0,extraArgs:[...P?["--append-system-prompt",`The user's name is ${P}.`]:[]],envOverrides:b});return(0,n.createSession)(t,m.command,m.args,w,()=>{},async r=>{await p(t,r);let n=await a.db.taskExecution.findUnique({where:{id:E.id}});if(n?.status!=="RUNNING")return;let{getSession:d}=await e.A(217260),o=d(t),c=o?.getBuffer()??"";await a.db.taskExecution.update({where:{id:E.id},data:{status:0===r?"COMPLETED":"FAILED",endedAt:new Date}}).catch(()=>{});let l=s?.worktreePath||i.project.localPath,{captureExecutionSummary:u}=await e.A(507603);await u(E.id,t,r,c,l,s?.forkCommit??null);let{dispatchTaskCompletionEvent:w}=await e.A(136565);await w({taskId:t,taskTitle:i.title,status:0===r?"COMPLETED":"FAILED",executionId:E.id,workspaceId:i.project.workspaceId}),0===r&&await a.db.task.update({where:{id:t},data:{status:"IN_REVIEW"}}).catch(()=>{})},m.env,void 0,1e3*h),{executionId:E.id,worktreePath:s?.worktreePath??l??null}}async function v(t){let{getSession:r}=await e.A(217260),i=r(t);if(i&&!i.killed){let e=await a.db.taskExecution.findFirst({where:{taskId:t,status:"RUNNING"},orderBy:{createdAt:"desc"}});return{mode:"already_running",executionId:e?.id??null,worktreePath:e?.worktreePath??null}}if(await a.db.taskExecution.count({where:{taskId:t}})>0){let e=await A(t);return{mode:"continued",executionId:e.executionId,worktreePath:e.worktreePath}}let n=await N(t,"");return{mode:"started",executionId:n.executionId,worktreePath:n.worktreePath}}async function N(t,s,w,f,k){let b,E,P=await a.db.task.findUnique({where:{id:t},include:{project:!0}});if(!P)throw Error("Task not found");if(!P.project?.localPath)throw Error("Project has no local path configured");let m=await (0,d.readConfigValue)("system.maxConcurrentExecutions",20);if(await a.db.taskExecution.count({where:{status:"RUNNING"}})>=m)throw Error(`已达并发上限(${m}),请等待其他任务完成后再启动`);let g=await (0,d.readConfigValue)("terminal.idleTimeoutSec",180),{adapter:I,provider:A,model:v}=await (0,o.resolveCliAdapter)("terminal");await a.db.taskExecution.updateMany({where:{taskId:t,status:"RUNNING"},data:{status:"FAILED",endedAt:new Date}}),"IN_PROGRESS"!==P.status&&(await a.db.task.update({where:{id:t},data:{status:"IN_PROGRESS"}}),(0,r.revalidatePath)("/workspaces"));let N="";if(!k){let e=await a.db.taskMessage.findMany({where:{taskId:t},orderBy:{createdAt:"desc"},take:10});N=[`Task: ${P.title}`,P.description?`Description: ${P.description}`:"",e.length>0?`Recent conversation:
2
- ${e.reverse().map(e=>`${e.role}: ${e.content}`).join("\n")}`:"",s.trim()?`User message: ${s}`:""].filter(Boolean).join("\n\n")}let x=w??P.promptId;if(x){let e=await a.db.agentPrompt.findUnique({where:{id:x}});e?.content&&(E=await (0,c.mkdtemp)((0,u.join)((0,l.tmpdir)(),"tower-pty-")),b=(0,u.join)(E,"instructions.md"),await (0,c.writeFile)(b,e.content,"utf-8"))}let y=null,R=null;if(P.baseBranch&&P.project.localPath){let{worktreePath:e,worktreeBranch:a}=await (0,i.createWorktree)(P.project.localPath,t,P.baseBranch);y=e,R=a}let j=y??P.project.localPath,S=P.subPath?(0,u.join)(j,P.subPath):j,D=await a.db.taskExecution.create({data:{taskId:t,agent:A.agentFieldValue,status:"RUNNING",startedAt:new Date,worktreePath:y??null,worktreeBranch:R??null,callbackUrl:f??null}}),U=null;if(P.project.localPath)try{let t,{execFileSync:r}=await e.A(144264);(t=y&&P.baseBranch?r("git",["merge-base",P.baseBranch,"HEAD"],{cwd:y,encoding:"utf-8",timeout:5e3}).trim():r("git",["rev-parse","HEAD"],{cwd:P.project.localPath,encoding:"utf-8",timeout:5e3}).trim())&&(U=t,await a.db.taskExecution.update({where:{id:D.id},data:{forkCommit:t}}))}catch{}let T="";if(b){let{readFile:t}=await e.A(260815);T+=await t(b,"utf-8")}let O=await (0,d.readConfigValue)("onboarding.username","");O&&(T+=(T?"\n":"")+`The user's name is ${O}.`);let C=I.buildSpawnArgs({taskId:t,prompt:N,cwd:S,extraArgs:[...T?["--append-system-prompt",T]:[],...v?["--model",v]:[]],envOverrides:I.buildEnvOverrides({taskId:t,taskTitle:P.title,apiUrl:`http://localhost:${process.env.PORT||"3000"}`,callbackUrl:f??void 0})});return(0,n.createSession)(t,C.command,C.args,S,()=>{},async r=>{await p(t,r);let i=await a.db.taskExecution.findUnique({where:{id:D.id}});if(i?.status!=="RUNNING")return;let{getSession:n}=await e.A(217260),s=n(t),d=s?.getBuffer()??"";await a.db.taskExecution.update({where:{id:D.id},data:{status:0===r?"COMPLETED":"FAILED",endedAt:new Date}}).catch(e=>{h.error("Failed to update execution status",e)});let o=y||P.project.localPath,{captureExecutionSummary:l}=await e.A(507603);await l(D.id,t,r,d,o,U);let{dispatchTaskCompletionEvent:u}=await e.A(136565);await u({taskId:t,taskTitle:P.title,status:0===r?"COMPLETED":"FAILED",executionId:D.id,workspaceId:P.project.workspaceId}),0===r&&await a.db.task.update({where:{id:t},data:{status:"IN_REVIEW"}}).catch(e=>{h.error("Failed to update task status",e)}),E&&await (0,c.rm)(E,{recursive:!0,force:!0}).catch(()=>{})},C.env,void 0,1e3*g),{executionId:D.id,worktreePath:y??j??null}}async function x(e,t,a,r,i){try{let n=await N(e,t,a,r,i);return{ok:!0,...n}}catch(t){return h.error("startPtyExecution failed",{taskId:e,error:t instanceof Error?t.stack??t.message:String(t)}),{ok:!1,error:t instanceof Error&&t.message?t.message:String(t)}}}async function y(){return(await a.db.taskExecution.findMany({where:{status:"RUNNING"},orderBy:{startedAt:"asc"},include:{task:{include:{project:{include:{workspace:!0}}}}}})).map(e=>({executionId:e.id,taskId:e.taskId,taskTitle:e.task.title,projectId:e.task.project.id,projectName:e.task.project.name,projectAlias:e.task.project.alias,projectLocalPath:e.task.project.localPath,workspaceId:e.task.project.workspace.id,workspaceName:e.task.project.workspace.name,worktreePath:e.worktreePath,subPath:e.task.subPath??null,startedAt:e.startedAt?.toISOString()??null}))}(0,w.ensureServerEntryExports)([k,b,E,P,m,g,I,A,v,N,x,y]),(0,t.registerServerReference)(k,"603f00de09a600f7d202a25277719712c2ed283aaf",null),(0,t.registerServerReference)(b,"407dd468ac5dbcb334f8a335abaff8acc79403f899",null),(0,t.registerServerReference)(E,"7890193fab5d3eb669ce2b4b704f5b0061973ebd9c",null),(0,t.registerServerReference)(P,"60034fbbd81247db48df931753fa269220fbea04dc",null),(0,t.registerServerReference)(m,"40637f6866f1cba755071a07147fb5965bb2e9b5a6",null),(0,t.registerServerReference)(g,"404d52059c47f9bd69cc1dc54c9a5b0b5329a4a5ce",null),(0,t.registerServerReference)(I,"60b2ad02a90fcd96621307c3f0b52c7dfe56e5f656",null),(0,t.registerServerReference)(A,"40c46a99d6959ba8c380e4f6ac7ccff4b78db03943",null),(0,t.registerServerReference)(v,"407b113b35e24312a4e2cf7bcb7210ae6d8cace6a6",null),(0,t.registerServerReference)(N,"7cebd0f04a21654b0a6c325835a800d3073dbf4f85",null),(0,t.registerServerReference)(x,"7c0868c06b7af021524a56df961ada6682a134b71d",null),(0,t.registerServerReference)(y,"00607be623cf335ac16f02ffbbbdf655bd98fe0111",null),e.s(["continueOrStartTaskExecution",0,v,"startPtyExecution",0,N,"stopPtyExecution",0,m])}];
1
+ module.exports=[756264,e=>{"use strict";var t=e.i(921675),a=e.i(843793),r=e.i(195158),i=e.i(248434),n=e.i(83721),s=e.i(50377),d=e.i(572173),o=e.i(89428),c=e.i(108789),l=e.i(924868),u=e.i(446786),w=e.i(814747),h=e.i(192520),k=e.i(86708);let f=s.logger.create("agent-actions"),p=(0,h.getSignalDir)();async function E(e,t){try{await (0,l.mkdir)(p,{recursive:!0,mode:448}),await (0,l.writeFile)((0,w.join)(p,`exit-${e}`),String(t),{mode:384})}catch{}}async function b(e,t){let i=await a.db.taskMessage.create({data:{role:"USER",content:t,taskId:e}});return(0,r.revalidatePath)("/workspaces"),{userMessage:i}}async function m(e){return a.db.taskMessage.findMany({where:{taskId:e},orderBy:{createdAt:"asc"}})}async function P(e,t="CLAUDE_CODE",i,n){let s=await a.db.taskExecution.create({data:{taskId:e,agent:t,status:"RUNNING",startedAt:new Date,worktreePath:i??null,worktreeBranch:n??null}});return await a.db.task.update({where:{id:e},data:{status:"IN_PROGRESS"}}),(0,r.revalidatePath)("/workspaces"),s}async function g(e,t="FAILED"){let i=await a.db.taskExecution.update({where:{id:e},data:{status:t,endedAt:new Date}});return(0,r.revalidatePath)("/workspaces"),i}async function A(t){await (0,c.cancelOpenAsks)(t).catch(()=>{});let{destroySession:i,getSession:n}=await e.A(217260),s=n(t),d=s?.getBuffer()??"",o=await a.db.taskExecution.findFirst({where:{taskId:t,status:"RUNNING"},orderBy:{createdAt:"desc"}}),l=await a.db.task.findUnique({where:{id:t},include:{project:{select:{localPath:!0}}}});if(i(t),o){await a.db.taskExecution.update({where:{id:o.id},data:{status:"COMPLETED",endedAt:new Date}}),await a.db.task.update({where:{id:t},data:{status:"IN_REVIEW"}});let r=o.worktreePath||l?.project?.localPath||null,{captureExecutionSummary:i}=await e.A(507603);await i(o.id,t,0,d,r,o.forkCommit)}(0,r.revalidatePath)("/workspaces")}async function I(e){return a.db.taskExecution.findMany({where:{taskId:e},orderBy:{createdAt:"desc"},include:{insightNote:{select:{id:!0,title:!0,content:!0}}}})}async function v(t,i){await (0,c.cancelOpenAsks)(t).catch(()=>{});let s=await a.db.task.findUnique({where:{id:t},include:{project:!0}});if(!s)throw Error("Task not found");if(!s.project?.localPath)throw Error("Project has no local path configured");await a.db.taskExecution.updateMany({where:{taskId:t,status:"RUNNING",NOT:{sessionId:i}},data:{status:"FAILED",endedAt:new Date}});let l=await a.db.taskExecution.findFirst({where:{taskId:t,sessionId:i},orderBy:{createdAt:"desc"}});if(!l)throw Error("Previous execution not found");let u=l.worktreePath??s.project.localPath,h=s.subPath?(0,w.join)(u,s.subPath):u,k=await (0,d.readConfigValue)("terminal.idleTimeoutSec",180),{adapter:p}=await (0,o.resolveCliAdapter)("terminal"),b=p.buildEnvOverrides({taskId:t,taskTitle:s.title,apiUrl:`http://localhost:${process.env.PORT||"3000"}`,callbackUrl:l.callbackUrl??void 0}),m=await a.db.taskExecution.update({where:{id:l.id},data:{status:"RUNNING",endedAt:null}});await a.db.task.update({where:{id:t},data:{status:"IN_PROGRESS"}}),(0,r.revalidatePath)("/workspaces");let P=await (0,d.readConfigValue)("onboarding.username",""),g=p.buildSpawnArgs({taskId:t,prompt:"",cwd:h,resumeSessionId:i,extraArgs:[...P?["--append-system-prompt",`The user's name is ${P}.`]:[]],envOverrides:b});s.unattended&&(g.env.TOWER_UNATTENDED="1");let A=/no conversation found with session id|unknown session|session .* not found/i;return(0,n.createSession)(t,g.command,g.args,h,()=>{},async r=>{await E(t,r);let n=await a.db.taskExecution.findUnique({where:{id:m.id}});if(n?.status!=="RUNNING")return;let{getSession:d}=await e.A(217260),o=d(t),c=o?.getBuffer()??"";if(0!==r&&A.test(c)){f.info("Session resume failed — retrying with fresh execution",{taskId:t,previousSessionId:i}),await a.db.taskExecution.update({where:{id:m.id},data:{status:"FAILED",endedAt:new Date}}).catch(()=>{});try{await x(t,s.title)}catch(e){f.error("Fresh execution retry also failed",e,{taskId:t})}return}await a.db.taskExecution.update({where:{id:m.id},data:{status:0===r?"COMPLETED":"FAILED",endedAt:new Date}}).catch(()=>{});let u=l.worktreePath||s.project.localPath,{captureExecutionSummary:w}=await e.A(507603);await w(m.id,t,r,c,u,m.forkCommit);let{dispatchTaskCompletionEvent:h}=await e.A(136565);await h({taskId:t,taskTitle:s.title,status:0===r?"COMPLETED":"FAILED",executionId:m.id,workspaceId:s.project.workspaceId}),0===r&&await a.db.task.update({where:{id:t},data:{status:"IN_REVIEW"}}).catch(()=>{})},g.env,void 0,1e3*k),{executionId:m.id,worktreePath:l.worktreePath??u??null}}async function N(t){await (0,c.cancelOpenAsks)(t).catch(()=>{});let i=await a.db.task.findUnique({where:{id:t},include:{project:!0}});if(!i)throw Error("Task not found");if(!i.project?.localPath)throw Error("Project has no local path configured");let s=await a.db.taskExecution.findFirst({where:{taskId:t},orderBy:{createdAt:"desc"}}),{destroySession:l}=await e.A(217260);l(t),await a.db.taskExecution.updateMany({where:{taskId:t,status:"RUNNING"},data:{status:"FAILED",endedAt:new Date}});let u=s?.worktreePath??i.project.localPath,h=i.subPath?(0,w.join)(u,i.subPath):u,k=await (0,d.readConfigValue)("terminal.idleTimeoutSec",180),{adapter:f,provider:p}=await (0,o.resolveCliAdapter)("terminal"),b=f.buildEnvOverrides({taskId:t,taskTitle:i.title,apiUrl:`http://localhost:${process.env.PORT||"3000"}`}),m=await a.db.taskExecution.create({data:{taskId:t,agent:p.agentFieldValue,status:"RUNNING",startedAt:new Date,worktreePath:s?.worktreePath??null,worktreeBranch:s?.worktreeBranch??null}});await a.db.task.update({where:{id:t},data:{status:"IN_PROGRESS"}}),(0,r.revalidatePath)("/workspaces");let P=await (0,d.readConfigValue)("onboarding.username",""),g=f.buildSpawnArgs({taskId:t,prompt:"",cwd:h,continueLatest:!0,extraArgs:[...P?["--append-system-prompt",`The user's name is ${P}.`]:[]],envOverrides:b});return i.unattended&&(g.env.TOWER_UNATTENDED="1"),(0,n.createSession)(t,g.command,g.args,h,()=>{},async r=>{await E(t,r);let n=await a.db.taskExecution.findUnique({where:{id:m.id}});if(n?.status!=="RUNNING")return;let{getSession:d}=await e.A(217260),o=d(t),c=o?.getBuffer()??"";await a.db.taskExecution.update({where:{id:m.id},data:{status:0===r?"COMPLETED":"FAILED",endedAt:new Date}}).catch(()=>{});let l=s?.worktreePath||i.project.localPath,{captureExecutionSummary:u}=await e.A(507603);await u(m.id,t,r,c,l,s?.forkCommit??null);let{dispatchTaskCompletionEvent:w}=await e.A(136565);await w({taskId:t,taskTitle:i.title,status:0===r?"COMPLETED":"FAILED",executionId:m.id,workspaceId:i.project.workspaceId}),0===r&&await a.db.task.update({where:{id:t},data:{status:"IN_REVIEW"}}).catch(()=>{})},g.env,void 0,1e3*k),{executionId:m.id,worktreePath:s?.worktreePath??u??null}}async function y(t){let{getSession:r}=await e.A(217260),i=r(t);if(i&&!i.killed){let e=await a.db.taskExecution.findFirst({where:{taskId:t,status:"RUNNING"},orderBy:{createdAt:"desc"}});return{mode:"already_running",executionId:e?.id??null,worktreePath:e?.worktreePath??null}}if(await a.db.taskExecution.count({where:{taskId:t}})>0){let e=await N(t);return{mode:"continued",executionId:e.executionId,worktreePath:e.worktreePath}}let n=await x(t,"");return{mode:"started",executionId:n.executionId,worktreePath:n.worktreePath}}async function x(t,s,h,k,p){let b,m;await (0,c.cancelOpenAsks)(t).catch(()=>{});let P=await a.db.task.findUnique({where:{id:t},include:{project:!0}});if(!P)throw Error("Task not found");if(!P.project?.localPath)throw Error("Project has no local path configured");let g=await (0,d.readConfigValue)("system.maxConcurrentExecutions",20);if(await a.db.taskExecution.count({where:{status:"RUNNING"}})>=g)throw Error(`已达并发上限(${g}),请等待其他任务完成后再启动`);let A=await (0,d.readConfigValue)("terminal.idleTimeoutSec",180),{adapter:I,provider:v,model:N}=await (0,o.resolveCliAdapter)("terminal");await a.db.taskExecution.updateMany({where:{taskId:t,status:"RUNNING"},data:{status:"FAILED",endedAt:new Date}}),"IN_PROGRESS"!==P.status&&(await a.db.task.update({where:{id:t},data:{status:"IN_PROGRESS"}}),(0,r.revalidatePath)("/workspaces"));let y="";if(!p){let e=await a.db.taskMessage.findMany({where:{taskId:t},orderBy:{createdAt:"desc"},take:10});y=[`Task: ${P.title}`,P.description?`Description: ${P.description}`:"",e.length>0?`Recent conversation:
2
+ ${e.reverse().map(e=>`${e.role}: ${e.content}`).join("\n")}`:"",s.trim()?`User message: ${s}`:""].filter(Boolean).join("\n\n")}let x=h??P.promptId;if(x){let e=await a.db.agentPrompt.findUnique({where:{id:x}});e?.content&&(m=await (0,l.mkdtemp)((0,w.join)((0,u.tmpdir)(),"tower-pty-")),b=(0,w.join)(m,"instructions.md"),await (0,l.writeFile)(b,e.content,"utf-8"))}let R=null,D=null;if(P.baseBranch&&P.project.localPath){let{worktreePath:e,worktreeBranch:a}=await (0,i.createWorktree)(P.project.localPath,t,P.baseBranch);R=e,D=a}let j=R??P.project.localPath,S=P.subPath?(0,w.join)(j,P.subPath):j,T=await a.db.taskExecution.create({data:{taskId:t,agent:v.agentFieldValue,status:"RUNNING",startedAt:new Date,worktreePath:R??null,worktreeBranch:D??null,callbackUrl:k??null}}),U=null;if(P.project.localPath)try{let t,{execFileSync:r}=await e.A(144264);(t=R&&P.baseBranch?r("git",["merge-base",P.baseBranch,"HEAD"],{cwd:R,encoding:"utf-8",timeout:5e3}).trim():r("git",["rev-parse","HEAD"],{cwd:P.project.localPath,encoding:"utf-8",timeout:5e3}).trim())&&(U=t,await a.db.taskExecution.update({where:{id:T.id},data:{forkCommit:t}}))}catch{}let O="",{CONFIG_DEFAULTS:C}=await e.A(75010),F=await (0,d.readConfigValue)("task.systemDirective",C["task.systemDirective"].defaultValue);if(F&&(O+=F),b){let{readFile:t}=await e.A(260815),a=await t(b,"utf-8");O+=(O?"\n\n":"")+a}let _=await (0,d.readConfigValue)("onboarding.username","");if(_&&(O+=(O?"\n":"")+`The user's name is ${_}.`),P.unattended){let e=await (0,d.readConfigValue)("harness.targets",[]),t=(Array.isArray(e)?e:[]).find(e=>e?.active&&e.gateway),a=t?`## 无人值守外推(ask_human / notify_human)
3
+ \`ask_human\` / \`notify_human\` 工具**只在 Tower 内记录 + park**,绝不替你把消息发给人。要让人真正收到,必须你自己按两步做:
4
+ 1. **先发**:用下列生效渠道对应的平台 MCP 工具把消息发出去。正文**必须逐字带**关联口令 \`[[tower:task=<taskId>]]\`(漏了人回复就无法归属、任务永久卡死)。
5
+ - 生效渠道:网关 ${t.gateway}${t.downstream?` → 下游 ${t.downstream}`:""}
6
+ - 发到哪个群/人由你在正文说明;若只知道名称(群名/人名)而无平台 id,先用平台 MCP 按名称查出 id 再发。
7
+ 2. **再记录**:确认第 1 步**发送成功后**,才调 \`ask_human\`(阻塞、park)或 \`notify_human\`(不阻塞、不 park)让 Tower 留档。
8
+ - 平台发送**失败**时**不要**调 ask_human(否则任务被 park 却没人知道)——重试,或把问题写进 /harness 面板后停下等人。`:"## 无人值守外推\n当前未配置任何发送渠道,你**无法**把消息外推给人(ask_human 会返回 noChannelConfigured)。**不要臆造已通知**——把问题记进 Tower(/harness 面板可见),并明确告知需去「设置 → 通知 → 无人值守发送渠道」配置一条并设为生效。";O+=(O?"\n\n":"")+a}let B=I.buildSpawnArgs({taskId:t,prompt:y,cwd:S,extraArgs:[...O?["--append-system-prompt",O]:[],...N?["--model",N]:[]],envOverrides:I.buildEnvOverrides({taskId:t,taskTitle:P.title,apiUrl:`http://localhost:${process.env.PORT||"3000"}`,callbackUrl:k??void 0})});return P.unattended&&(B.env.TOWER_UNATTENDED="1"),(0,n.createSession)(t,B.command,B.args,S,()=>{},async r=>{await E(t,r);let i=await a.db.taskExecution.findUnique({where:{id:T.id}});if(i?.status!=="RUNNING")return;let{getSession:n}=await e.A(217260),s=n(t),d=s?.getBuffer()??"";await a.db.taskExecution.update({where:{id:T.id},data:{status:0===r?"COMPLETED":"FAILED",endedAt:new Date}}).catch(e=>{f.error("Failed to update execution status",e)});let o=R||P.project.localPath,{captureExecutionSummary:c}=await e.A(507603);await c(T.id,t,r,d,o,U);let{dispatchTaskCompletionEvent:u}=await e.A(136565);await u({taskId:t,taskTitle:P.title,status:0===r?"COMPLETED":"FAILED",executionId:T.id,workspaceId:P.project.workspaceId}),0===r&&await a.db.task.update({where:{id:t},data:{status:"IN_REVIEW"}}).catch(e=>{f.error("Failed to update task status",e)}),m&&await (0,l.rm)(m,{recursive:!0,force:!0}).catch(()=>{})},B.env,void 0,1e3*A),{executionId:T.id,worktreePath:R??j??null}}async function R(e,t,a,r,i){try{let n=await x(e,t,a,r,i);return{ok:!0,...n}}catch(t){return f.error("startPtyExecution failed",{taskId:e,error:t instanceof Error?t.stack??t.message:String(t)}),{ok:!1,error:t instanceof Error&&t.message?t.message:String(t)}}}async function D(){return(await a.db.taskExecution.findMany({where:{status:"RUNNING"},orderBy:{startedAt:"asc"},include:{task:{include:{project:{include:{workspace:!0}}}}}})).map(e=>({executionId:e.id,taskId:e.taskId,taskTitle:e.task.title,projectId:e.task.project.id,projectName:e.task.project.name,projectAlias:e.task.project.alias,projectLocalPath:e.task.project.localPath,workspaceId:e.task.project.workspace.id,workspaceName:e.task.project.workspace.name,worktreePath:e.worktreePath,subPath:e.task.subPath??null,startedAt:e.startedAt?.toISOString()??null}))}(0,k.ensureServerEntryExports)([b,m,P,g,A,I,v,N,y,x,R,D]),(0,t.registerServerReference)(b,"60ae3ebfa8f1c05e65ac7b13ce214332ab8e56798c",null),(0,t.registerServerReference)(m,"405fc1518e581b03c39972f532cd57b2d3217490fd",null),(0,t.registerServerReference)(P,"785b590700763c293c4fe526387929ddfbd05030e9",null),(0,t.registerServerReference)(g,"60cb35af1a931346fdd0a76058abad4077d52ae84c",null),(0,t.registerServerReference)(A,"4002e701556efc923466db3132a1eb9dcf3ed1ef2c",null),(0,t.registerServerReference)(I,"40fa3f329236851a9a8b8ca9c1e58fc01db0cc1a7d",null),(0,t.registerServerReference)(v,"606693c21cce966ba14f407175e65a06ac7f498051",null),(0,t.registerServerReference)(N,"40ddd0314c3c22a36d679760619153e9ec0bccb69f",null),(0,t.registerServerReference)(y,"402a10b1aafae337a85f9ef61950f00bed869774d6",null),(0,t.registerServerReference)(x,"7c63afffbf71f8ba94c960c71a704c1530768065f3",null),(0,t.registerServerReference)(R,"7c2a594c06cd57cecd2ea14b792507a79a0e8762b5",null),(0,t.registerServerReference)(D,"0099ccf1abd659c635da6411eb5c05e03f2300c494",null),e.s(["continueOrStartTaskExecution",0,y,"startPtyExecution",0,x,"stopPtyExecution",0,A])}];
3
9
 
4
10
  //# sourceMappingURL=src_actions_agent-actions_ts_10q9r5b._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[769310,e=>{"use strict";var t=e.i(902157),i=e.i(874533),n=e.i(750227);function r(e=process.platform){return"win32"===e}function s(e){let t=e.replace(/\r\n|\r|\n/g," ");if(!t.length)return'""';let i=t.replace(/"/g,'""');return/[\s"&<>|^()]/.test(i)?`"${i}"`:i}let a=["CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION","CLAUDE_CODE_PARENT_SESSION"];async function o(e,t={}){let i=t.cwd??process.cwd(),s=t.env??process.env,a=t.platform??process.platform;if(e.includes("/")||e.includes("\\")){let t=n.default.isAbsolute(e)?e:n.default.resolve(i,e);return await m(t,a)?t:null}let l=s.PATH??s.Path??"",c=r(a)?";":":",d=l.split(c).filter(Boolean),u=r(a)?(s.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean):[""],p=r(a)&&n.default.extname(e).length>0;for(let t of d)for(let i of r(a)?p?[n.default.join(t,e)]:u.map(i=>n.default.join(t,`${e}${i}`)):[n.default.join(t,e)])if(await m(i,a))return i;return null}let l=e=>(0,i.execSync)(e,{encoding:"utf-8",timeout:5e3,stdio:["ignore","pipe","ignore"]});function c(e,t=process.platform,s=l){if(n.default.extname(e)||e.includes("/")||e.includes("\\"))return e;if(!r(t)){try{let t=(0,i.execFileSync)("which",[e],{encoding:"utf-8",timeout:5e3,stdio:["ignore","pipe","ignore"]}).trim();if(t)return t}catch{}return e}try{let t=s(`where ${e}`).trim().split("\n").map(e=>e.trim()).filter(Boolean),i=t.find(e=>/\.(cmd|bat|exe)$/i.test(e));if(i)return i;if(t.length>0)return t[0]}catch{}return e}async function d(e,t,i={}){let n=i.env??process.env,r=i.platform??process.platform;return u(await o(e,i)??e,t,n,r)}function u(e,t,i,a){if(!r(a))return{command:e,args:t};let o=n.default.extname(e).toLowerCase();return".cmd"===o||".bat"===o||".com"===o?{command:i.ComSpec||"cmd.exe",args:["/d","/s","/c",[s(e),...t.map(s)].join(" ")]}:{command:e,args:t}}async function m(e,i=process.platform){try{return await t.promises.access(e,r(i)?t.constants.F_OK:t.constants.X_OK),!0}catch{return!1}}async function p(e=process.platform){return r(e)?h():f()}async function f(){try{let e=await t.promises.readFile("/etc/shells","utf-8"),i=[],r=new Map;for(let t of e.split("\n")){let e=t.replace(/#.*/,"").trim();if(!e||!e.startsWith("/")||!await m(e))continue;let s=n.default.basename(e),a=r.get(s)??0;r.set(s,a+1),a>0&&(s=`${s} (${a+1})`),i.push({name:s,path:e})}return i}catch{let e=[];for(let t of["/bin/zsh","/bin/bash","/bin/sh"])await m(t)&&e.push({name:n.default.basename(t),path:t});return e}}async function h(){let e=[],t=[],i=await o("git",{platform:"win32"});if(i){let e=n.default.resolve(n.default.dirname(i),"..","..");t.push(n.default.join(e,"bin","bash.exe"),n.default.join(e,"usr","bin","bash.exe"))}for(let e of[process.env.ProgramW6432,process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.LocalAppData?n.default.join(process.env.LocalAppData,"Programs"):null].filter(Boolean))t.push(n.default.join(e,"Git","bin","bash.exe"),n.default.join(e,"Git","usr","bin","bash.exe"));let r=process.env.USERPROFILE??"";for(let i of(r&&t.push(n.default.join(r,"scoop","apps","git","current","bin","bash.exe")),process.env.CLAUDE_CODE_GIT_BASH_PATH&&t.unshift(process.env.CLAUDE_CODE_GIT_BASH_PATH),t))if(await m(i,"win32")){e.push({name:"Git Bash",path:i});break}let s=await o("pwsh",{platform:"win32"});s&&e.push({name:"PowerShell",path:s});let a=process.env.windir??"C:\\WINDOWS",l=n.default.join(a,"System32","WindowsPowerShell","v1.0","powershell.exe");await m(l,"win32")&&e.push({name:"Windows PowerShell",path:l});let c=process.env.ComSpec??n.default.join(a,"System32","cmd.exe");return await m(c,"win32")&&e.push({name:"Command Prompt",path:c}),e}let w=[{name:"Terminal",bundleName:"Terminal"},{name:"iTerm2",bundleName:"iTerm"},{name:"Warp",bundleName:"Warp"},{name:"Alacritty",bundleName:"Alacritty"},{name:"WezTerm",bundleName:"WezTerm"},{name:"kitty",bundleName:"kitty"},{name:"Hyper",bundleName:"Hyper"}];async function b(e=process.platform){if("darwin"===e){let t=[];for(let i of w){let n=await m(`/Applications/${i.bundleName}.app`,e);t.push({name:i.name,value:i.bundleName,installed:n})}return t}if(r(e)){let t=[],i=await o("wt",{platform:e});return i&&t.push({name:"Windows Terminal",value:i,installed:!0}),t}return[]}let _=[{name:"VS Code",command:"code"},{name:"VS Code Insiders",command:"code-insiders"},{name:"Cursor",command:"cursor"},{name:"Windsurf",command:"windsurf"},{name:"Zed",command:"zed"},{name:"Sublime Text",command:"subl"},{name:"IntelliJ IDEA",command:"idea"},{name:"WebStorm",command:"webstorm"},{name:"PyCharm",command:"pycharm"},{name:"GoLand",command:"goland"},{name:"RubyMine",command:"rubymine"},{name:"PhpStorm",command:"phpstorm"},{name:"CLion",command:"clion"},{name:"Rider",command:"rider"}],S={code:{darwin:["/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"],win32:["%LOCALAPPDATA%\\Programs\\Microsoft VS Code\\bin\\code.cmd","%ProgramFiles%\\Microsoft VS Code\\bin\\code.cmd"]},"code-insiders":{darwin:["/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code-insiders"],win32:["%LOCALAPPDATA%\\Programs\\Microsoft VS Code Insiders\\bin\\code-insiders.cmd","%ProgramFiles%\\Microsoft VS Code Insiders\\bin\\code-insiders.cmd"]},cursor:{darwin:["/Applications/Cursor.app/Contents/Resources/app/bin/cursor"],win32:["%LOCALAPPDATA%\\Programs\\cursor\\resources\\app\\bin\\cursor.cmd"]},windsurf:{darwin:["/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf"],win32:["%LOCALAPPDATA%\\Programs\\Windsurf\\bin\\windsurf.cmd"]},zed:{darwin:["/Applications/Zed.app/Contents/MacOS/cli"]},subl:{darwin:["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"],win32:["%ProgramFiles%\\Sublime Text\\subl.exe","%ProgramFiles%\\Sublime Text 3\\subl.exe"]},idea:{darwin:["/Applications/IntelliJ IDEA.app/Contents/MacOS/idea","/Applications/IntelliJ IDEA CE.app/Contents/MacOS/idea"]},webstorm:{darwin:["/Applications/WebStorm.app/Contents/MacOS/webstorm"]},pycharm:{darwin:["/Applications/PyCharm.app/Contents/MacOS/pycharm","/Applications/PyCharm CE.app/Contents/MacOS/pycharm"]},goland:{darwin:["/Applications/GoLand.app/Contents/MacOS/goland"]},rubymine:{darwin:["/Applications/RubyMine.app/Contents/MacOS/rubymine"]},phpstorm:{darwin:["/Applications/PhpStorm.app/Contents/MacOS/phpstorm"]},clion:{darwin:["/Applications/CLion.app/Contents/MacOS/clion"]},rider:{darwin:["/Applications/Rider.app/Contents/MacOS/rider"]}};async function T(e,t={}){let i=t.platform??process.platform,n=t.env??process.env,s=await o(e,t);if(s)return s;for(let t of S[e]?.[i]??[]){let e=r(i)?function(e,t){return e.replace(/%([^%]+)%/g,(e,i)=>{let n=t[i];if(void 0!==n)return n;let r=Object.keys(t).find(e=>e.toLowerCase()===i.toLowerCase());return r?t[r]??e:e})}(t,n):t;if(await m(e,i))return e}return null}async function y(e=process.platform){let t=[];for(let i of _){let n=!!await T(i.command,{platform:e});t.push({name:i.name,command:i.command,installed:n})}return t}e.s(["detectEditors",0,y,"detectShells",0,p,"detectTerminalApps",0,b,"ensurePathInEnv",0,function(e,t=process.platform){let i=r(t)?"Path":"PATH";return(e.PATH??e.Path??"").length>0?e:{...e,[i]:function(e=process.platform){return r(e)?"C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\Wbem":"/usr/local/bin:/opt/homebrew/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"}(t)}},"isWindows",0,r,"resolveCommandPath",0,o,"resolveCommandPathSync",0,c,"resolveSdkExecutable",0,function(e,i=process.platform,s=e=>(0,t.readFileSync)(e,"utf-8"),a=e=>(0,t.existsSync)(e)){if(!r(i))return e;let o=n.default.extname(e).toLowerCase();if(".cmd"!==o&&".bat"!==o)return e;let l=n.default.win32.dirname(e),c="",d=e=>{let t=e.replace(/%~?dp0%/gi,l).replace(/\//g,"\\");return n.default.win32.isAbsolute(t)?n.default.win32.normalize(t):n.default.win32.resolve(l,t)};try{let t=s(e);c=t.replace(/\s+/g," ").slice(0,400);let i=t.match(/"([^"]*\.(?:c?js|mjs))"/i);if(i){let e=d(i[1]);if(a(e))return e;console.error(`[resolveSdkExecutable] parsed cli="${e}" but it doesn't exist`)}for(let e of t.matchAll(/"([^"]*\.exe)"/gi)){let t=d(e[1]);if("node.exe"!==n.default.win32.basename(t).toLowerCase()&&a(t))return t}}catch(e){console.error(`[resolveSdkExecutable] shim read failed: ${e instanceof Error?e.message:e}`)}let u=n.default.win32.join(l,"node_modules","@anthropic-ai","claude-code"),m=n.default.win32.basename(e,n.default.win32.extname(e)),p=[n.default.win32.join(u,"cli.js"),n.default.win32.join(u,"bin",`${m}.exe`)];for(let e of p)if(a(e))return e;return console.error(`[resolveSdkExecutable] could not convert ${e} → guesses=${JSON.stringify(p)} shim="${c}"`),e},"resolveSpawnTarget",0,d,"resolveSpawnTargetSync",0,function(e,t,i=process.platform,n){return u(c(e,i,n),t,process.env,i)},"stripClaudeNestingEnv",0,function(e){let t={...e};for(let e of a)delete t[e];return t}])},519895,e=>{"use strict";var t=e.i(980738),i=e.i(769310);class n{taskId;_pty;killed=!1;disconnectTimer=null;_buffer="";static BUFFER_MAX=51200;_onData;_exitListeners=[];_idleTimer=null;_idleThresholdMs;_onIdle;_idleFired=!1;constructor(e,r,s,a,o,l,c,d,u){this.taskId=e,this._onData=o,this._onIdle=d??null,this._idleThresholdMs=Math.max(u??18e4,18e4);const m={...(0,i.stripClaudeNestingEnv)((0,i.ensurePathInEnv)(process.env)),TERM:"xterm-color",...c};try{this._pty=t.spawn(r,s,{name:"xterm-color",cols:80,rows:24,cwd:a,env:m})}catch(e){throw console.error(`[pty] spawn failed: command="${r}", cwd="${a}", PATH="${m.PATH?.slice(0,200)}"`),e}this._pty.onData(e=>{this._buffer+=e,this._buffer.length>n.BUFFER_MAX&&(this._buffer=this._buffer.slice(this._buffer.length-n.BUFFER_MAX)),this._resetIdleTimer(),this._onData(e)}),this._pty.onExit(({exitCode:e,signal:t})=>{for(let i of(this.killed=!0,this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null),l(e,t),this._exitListeners))i(e)}),this._resetIdleTimer()}_resetIdleTimer(){this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null),null===this._onIdle||this.killed||this._idleFired||(this._idleTimer=setTimeout(()=>{this._idleFired=!0,this._onIdle?.()},this._idleThresholdMs))}setDataListener(e){this._onData=e}setExitListener(e){this._exitListeners=[e]}write(e){this.killed||(this._resetIdleTimer(),this._pty.write(e))}resize(e,t){this.killed||this._pty.resize(e,t)}getBuffer(){return this._buffer}get isIdle(){return this._idleFired}get pid(){return this._pty.pid}kill(e){if(!this.killed){this.killed=!0,this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null);try{this._pty.kill(e)}catch{}}}forceKill(){try{this._pty.kill("SIGKILL")}catch{}this.killed=!0}killTree(e=3e3){if(this.killed)return;this.killed=!0,this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null);let t=this._pty.pid;try{process.kill(-t,"SIGTERM")}catch{try{this._pty.kill()}catch{}return}let i=setTimeout(()=>{try{process.kill(-t,"SIGKILL")}catch{}},e);i.unref?.()}}e.s(["PtySession",0,n])},83721,e=>{"use strict";var t=e.i(519895),i=e.i(769310);e.i(874533);var n=e.i(912714),r=e.i(660526),s=e.i(750227);let a=(0,s.join)((0,r.tmpdir)(),"tower-signals");function o(e){return(0,s.join)(a,`pid-${e}`)}async function l(e,t){try{await (0,n.mkdir)(a,{recursive:!0,mode:448}),await (0,n.writeFile)(o(e),String(t),{mode:384})}catch{}}async function c(e){try{await (0,n.unlink)(o(e))}catch{}}let d=globalThis;d.__ptySessions||(d.__ptySessions=new Map);let u=d.__ptySessions;function m(e){let t=u.get(e);if(t)return u.delete(e),t.disconnectTimer&&(clearTimeout(t.disconnectTimer),t.disconnectTimer=null),t.killTree(),t}function p(e){m(e)&&c(e)}function f(){for(let e of u.keys())p(e)}let h=globalThis;"phase-production-build"===process.env.NEXT_PHASE||h.__ptySignalHandlersRegistered||(h.__ptySignalHandlersRegistered=!0,process.once("SIGTERM",()=>{console.error("[session-store] SIGTERM received — cleaning up PTY sessions"),f()}),process.once("SIGINT",()=>{console.error("[session-store] SIGINT received — cleaning up PTY sessions"),f()})),e.s(["createSession",0,function(e,n,r,s,a,o,c,d,p){m(e);let{command:f,args:h}=(0,i.resolveSpawnTargetSync)(n,r),w=new t.PtySession(e,f,h,s,a,o,c,d,p);return u.set(e,w),l(e,w.pid),w},"destroySession",0,p,"getSession",0,function(e){return u.get(e)}],83721)}];
1
+ module.exports=[769310,e=>{"use strict";var t=e.i(902157),i=e.i(874533),n=e.i(750227);function r(e=process.platform){return"win32"===e}function s(e){let t=e.replace(/\r\n|\r|\n/g," ");if(!t.length)return'""';let i=t.replace(/"/g,'""');return/[\s"&<>|^()]/.test(i)?`"${i}"`:i}let a=["CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION","CLAUDE_CODE_PARENT_SESSION"];async function o(e,t={}){let i=t.cwd??process.cwd(),s=t.env??process.env,a=t.platform??process.platform;if(e.includes("/")||e.includes("\\")){let t=n.default.isAbsolute(e)?e:n.default.resolve(i,e);return await m(t,a)?t:null}let l=s.PATH??s.Path??"",c=r(a)?";":":",d=l.split(c).filter(Boolean),u=r(a)?(s.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean):[""],p=r(a)&&n.default.extname(e).length>0;for(let t of d)for(let i of r(a)?p?[n.default.join(t,e)]:u.map(i=>n.default.join(t,`${e}${i}`)):[n.default.join(t,e)])if(await m(i,a))return i;return null}let l=e=>(0,i.execSync)(e,{encoding:"utf-8",timeout:5e3,stdio:["ignore","pipe","ignore"]});function c(e,t=process.platform,s=l){if(n.default.extname(e)||e.includes("/")||e.includes("\\"))return e;if(!r(t)){try{let t=(0,i.execFileSync)("which",[e],{encoding:"utf-8",timeout:5e3,stdio:["ignore","pipe","ignore"]}).trim();if(t)return t}catch{}return e}try{let t=s(`where ${e}`).trim().split("\n").map(e=>e.trim()).filter(Boolean),i=t.find(e=>/\.(cmd|bat|exe)$/i.test(e));if(i)return i;if(t.length>0)return t[0]}catch{}return e}async function d(e,t,i={}){let n=i.env??process.env,r=i.platform??process.platform;return u(await o(e,i)??e,t,n,r)}function u(e,t,i,a){if(!r(a))return{command:e,args:t};let o=n.default.extname(e).toLowerCase();return".cmd"===o||".bat"===o||".com"===o?{command:i.ComSpec||"cmd.exe",args:["/d","/s","/c",[s(e),...t.map(s)].join(" ")]}:{command:e,args:t}}async function m(e,i=process.platform){try{return await t.promises.access(e,r(i)?t.constants.F_OK:t.constants.X_OK),!0}catch{return!1}}async function p(e=process.platform){return r(e)?h():f()}async function f(){try{let e=await t.promises.readFile("/etc/shells","utf-8"),i=[],r=new Map;for(let t of e.split("\n")){let e=t.replace(/#.*/,"").trim();if(!e||!e.startsWith("/")||!await m(e))continue;let s=n.default.basename(e),a=r.get(s)??0;r.set(s,a+1),a>0&&(s=`${s} (${a+1})`),i.push({name:s,path:e})}return i}catch{let e=[];for(let t of["/bin/zsh","/bin/bash","/bin/sh"])await m(t)&&e.push({name:n.default.basename(t),path:t});return e}}async function h(){let e=[],t=[],i=await o("git",{platform:"win32"});if(i){let e=n.default.resolve(n.default.dirname(i),"..","..");t.push(n.default.join(e,"bin","bash.exe"),n.default.join(e,"usr","bin","bash.exe"))}for(let e of[process.env.ProgramW6432,process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.LocalAppData?n.default.join(process.env.LocalAppData,"Programs"):null].filter(Boolean))t.push(n.default.join(e,"Git","bin","bash.exe"),n.default.join(e,"Git","usr","bin","bash.exe"));let r=process.env.USERPROFILE??"";for(let i of(r&&t.push(n.default.join(r,"scoop","apps","git","current","bin","bash.exe")),process.env.CLAUDE_CODE_GIT_BASH_PATH&&t.unshift(process.env.CLAUDE_CODE_GIT_BASH_PATH),t))if(await m(i,"win32")){e.push({name:"Git Bash",path:i});break}let s=await o("pwsh",{platform:"win32"});s&&e.push({name:"PowerShell",path:s});let a=process.env.windir??"C:\\WINDOWS",l=n.default.join(a,"System32","WindowsPowerShell","v1.0","powershell.exe");await m(l,"win32")&&e.push({name:"Windows PowerShell",path:l});let c=process.env.ComSpec??n.default.join(a,"System32","cmd.exe");return await m(c,"win32")&&e.push({name:"Command Prompt",path:c}),e}let w=[{name:"Terminal",bundleName:"Terminal"},{name:"iTerm2",bundleName:"iTerm"},{name:"Warp",bundleName:"Warp"},{name:"Alacritty",bundleName:"Alacritty"},{name:"WezTerm",bundleName:"WezTerm"},{name:"kitty",bundleName:"kitty"},{name:"Hyper",bundleName:"Hyper"}];async function b(e=process.platform){if("darwin"===e){let t=[];for(let i of w){let n=await m(`/Applications/${i.bundleName}.app`,e);t.push({name:i.name,value:i.bundleName,installed:n})}return t}if(r(e)){let t=[],i=await o("wt",{platform:e});return i&&t.push({name:"Windows Terminal",value:i,installed:!0}),t}return[]}let _=[{name:"VS Code",command:"code"},{name:"VS Code Insiders",command:"code-insiders"},{name:"Cursor",command:"cursor"},{name:"Windsurf",command:"windsurf"},{name:"Zed",command:"zed"},{name:"Sublime Text",command:"subl"},{name:"IntelliJ IDEA",command:"idea"},{name:"WebStorm",command:"webstorm"},{name:"PyCharm",command:"pycharm"},{name:"GoLand",command:"goland"},{name:"RubyMine",command:"rubymine"},{name:"PhpStorm",command:"phpstorm"},{name:"CLion",command:"clion"},{name:"Rider",command:"rider"}],S={code:{darwin:["/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"],win32:["%LOCALAPPDATA%\\Programs\\Microsoft VS Code\\bin\\code.cmd","%ProgramFiles%\\Microsoft VS Code\\bin\\code.cmd"]},"code-insiders":{darwin:["/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code-insiders"],win32:["%LOCALAPPDATA%\\Programs\\Microsoft VS Code Insiders\\bin\\code-insiders.cmd","%ProgramFiles%\\Microsoft VS Code Insiders\\bin\\code-insiders.cmd"]},cursor:{darwin:["/Applications/Cursor.app/Contents/Resources/app/bin/cursor"],win32:["%LOCALAPPDATA%\\Programs\\cursor\\resources\\app\\bin\\cursor.cmd"]},windsurf:{darwin:["/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf"],win32:["%LOCALAPPDATA%\\Programs\\Windsurf\\bin\\windsurf.cmd"]},zed:{darwin:["/Applications/Zed.app/Contents/MacOS/cli"]},subl:{darwin:["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"],win32:["%ProgramFiles%\\Sublime Text\\subl.exe","%ProgramFiles%\\Sublime Text 3\\subl.exe"]},idea:{darwin:["/Applications/IntelliJ IDEA.app/Contents/MacOS/idea","/Applications/IntelliJ IDEA CE.app/Contents/MacOS/idea"]},webstorm:{darwin:["/Applications/WebStorm.app/Contents/MacOS/webstorm"]},pycharm:{darwin:["/Applications/PyCharm.app/Contents/MacOS/pycharm","/Applications/PyCharm CE.app/Contents/MacOS/pycharm"]},goland:{darwin:["/Applications/GoLand.app/Contents/MacOS/goland"]},rubymine:{darwin:["/Applications/RubyMine.app/Contents/MacOS/rubymine"]},phpstorm:{darwin:["/Applications/PhpStorm.app/Contents/MacOS/phpstorm"]},clion:{darwin:["/Applications/CLion.app/Contents/MacOS/clion"]},rider:{darwin:["/Applications/Rider.app/Contents/MacOS/rider"]}};async function T(e,t={}){let i=t.platform??process.platform,n=t.env??process.env,s=await o(e,t);if(s)return s;for(let t of S[e]?.[i]??[]){let e=r(i)?function(e,t){return e.replace(/%([^%]+)%/g,(e,i)=>{let n=t[i];if(void 0!==n)return n;let r=Object.keys(t).find(e=>e.toLowerCase()===i.toLowerCase());return r?t[r]??e:e})}(t,n):t;if(await m(e,i))return e}return null}async function y(e=process.platform){let t=[];for(let i of _){let n=!!await T(i.command,{platform:e});t.push({name:i.name,command:i.command,installed:n})}return t}e.s(["detectEditors",0,y,"detectShells",0,p,"detectTerminalApps",0,b,"ensurePathInEnv",0,function(e,t=process.platform){let i=r(t)?"Path":"PATH";return(e.PATH??e.Path??"").length>0?e:{...e,[i]:function(e=process.platform){return r(e)?"C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\Wbem":"/usr/local/bin:/opt/homebrew/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"}(t)}},"isWindows",0,r,"resolveCommandPath",0,o,"resolveCommandPathSync",0,c,"resolveSdkExecutable",0,function(e,i=process.platform,s=e=>(0,t.readFileSync)(e,"utf-8"),a=e=>(0,t.existsSync)(e)){if(!r(i))return e;let o=n.default.extname(e).toLowerCase();if(".cmd"!==o&&".bat"!==o)return e;let l=n.default.win32.dirname(e),c="",d=e=>{let t=e.replace(/%~?dp0%/gi,l).replace(/\//g,"\\");return n.default.win32.isAbsolute(t)?n.default.win32.normalize(t):n.default.win32.resolve(l,t)};try{let t=s(e);c=t.replace(/\s+/g," ").slice(0,400);let i=t.match(/"([^"]*\.(?:c?js|mjs))"/i);if(i){let e=d(i[1]);if(a(e))return e;console.error(`[resolveSdkExecutable] parsed cli="${e}" but it doesn't exist`)}for(let e of t.matchAll(/"([^"]*\.exe)"/gi)){let t=d(e[1]);if("node.exe"!==n.default.win32.basename(t).toLowerCase()&&a(t))return t}}catch(e){console.error(`[resolveSdkExecutable] shim read failed: ${e instanceof Error?e.message:e}`)}let u=n.default.win32.join(l,"node_modules","@anthropic-ai","claude-code"),m=n.default.win32.basename(e,n.default.win32.extname(e)),p=[n.default.win32.join(u,"cli.js"),n.default.win32.join(u,"bin",`${m}.exe`)];for(let e of p)if(a(e))return e;return console.error(`[resolveSdkExecutable] could not convert ${e} → guesses=${JSON.stringify(p)} shim="${c}"`),e},"resolveSpawnTarget",0,d,"resolveSpawnTargetSync",0,function(e,t,i=process.platform,n){return u(c(e,i,n),t,process.env,i)},"stripClaudeNestingEnv",0,function(e){let t={...e};for(let e of a)delete t[e];return t}])},519895,e=>{"use strict";var t=e.i(980738),i=e.i(769310);class n{taskId;_pty;killed=!1;disconnectTimer=null;_buffer="";static BUFFER_MAX=51200;_onData;_exitListeners=[];_idleTimer=null;_idleThresholdMs;_onIdle;_idleFired=!1;constructor(e,r,s,a,o,l,c,d,u){this.taskId=e,this._onData=o,this._onIdle=d??null,this._idleThresholdMs=Math.max(u??18e4,18e4);const m={...(0,i.stripClaudeNestingEnv)((0,i.ensurePathInEnv)(process.env)),TERM:"xterm-color",...c};try{this._pty=t.spawn(r,s,{name:"xterm-color",cols:80,rows:24,cwd:a,env:m})}catch(e){throw console.error(`[pty] spawn failed: command="${r}", cwd="${a}", PATH="${m.PATH?.slice(0,200)}"`),e}this._pty.onData(e=>{this._buffer+=e,this._buffer.length>n.BUFFER_MAX&&(this._buffer=this._buffer.slice(this._buffer.length-n.BUFFER_MAX)),this._resetIdleTimer(),this._onData(e)}),this._pty.onExit(({exitCode:e,signal:t})=>{for(let i of(this.killed=!0,this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null),l(e,t),this._exitListeners))i(e)}),this._resetIdleTimer()}_resetIdleTimer(){this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null),null===this._onIdle||this.killed||this._idleFired||(this._idleTimer=setTimeout(()=>{this._idleFired=!0,this._onIdle?.()},this._idleThresholdMs))}setDataListener(e){this._onData=e}setExitListener(e){this._exitListeners=[e]}write(e){this.killed||(this._resetIdleTimer(),this._pty.write(e))}resize(e,t){this.killed||this._pty.resize(e,t)}getBuffer(){return this._buffer}get isIdle(){return this._idleFired}get pid(){return this._pty.pid}kill(e){if(!this.killed){this.killed=!0,this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null);try{this._pty.kill(e)}catch{}}}forceKill(){try{this._pty.kill("SIGKILL")}catch{}this.killed=!0}killTree(e=3e3){if(this.killed)return;this.killed=!0,this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null);let t=this._pty.pid;try{process.kill(-t,"SIGTERM")}catch{try{this._pty.kill()}catch{}return}let i=setTimeout(()=>{try{process.kill(-t,"SIGKILL")}catch{}},e);i.unref?.()}}e.s(["PtySession",0,n])},83721,e=>{"use strict";var t=e.i(519895),i=e.i(769310);e.i(874533);var n=e.i(912714),r=e.i(750227);let s=(0,e.i(192520).getSignalDir)();function a(e){return(0,r.join)(s,`pid-${e}`)}async function o(e,t){try{await (0,n.mkdir)(s,{recursive:!0,mode:448}),await (0,n.writeFile)(a(e),String(t),{mode:384})}catch{}}async function l(e){try{await (0,n.unlink)(a(e))}catch{}}let c=globalThis;c.__ptySessions||(c.__ptySessions=new Map);let d=c.__ptySessions;function u(e){let t=d.get(e);if(t)return d.delete(e),t.disconnectTimer&&(clearTimeout(t.disconnectTimer),t.disconnectTimer=null),t.killTree(),t}function m(e){u(e)&&l(e)}function p(){for(let e of d.keys())m(e)}let f=globalThis;"phase-production-build"===process.env.NEXT_PHASE||f.__ptySignalHandlersRegistered||(f.__ptySignalHandlersRegistered=!0,process.once("SIGTERM",()=>{console.error("[session-store] SIGTERM received — cleaning up PTY sessions"),p()}),process.once("SIGINT",()=>{console.error("[session-store] SIGINT received — cleaning up PTY sessions"),p()})),e.s(["createSession",0,function(e,n,r,s,a,l,c,m,p){u(e);let{command:f,args:h}=(0,i.resolveSpawnTargetSync)(n,r),w=new t.PtySession(e,f,h,s,a,l,c,m,p);return d.set(e,w),o(e,w.pid),w},"destroySession",0,m,"getSession",0,function(e){return d.get(e)}],83721)}];
2
2
 
3
3
  //# sourceMappingURL=src_lib_02llcit._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[769310,e=>{"use strict";var t=e.i(902157),n=e.i(874533),r=e.i(750227);function o(e=process.platform){return"win32"===e}function s(e){let t=e.replace(/\r\n|\r|\n/g," ");if(!t.length)return'""';let n=t.replace(/"/g,'""');return/[\s"&<>|^()]/.test(n)?`"${n}"`:n}let i=["CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION","CLAUDE_CODE_PARENT_SESSION"];async function a(e,t={}){let n=t.cwd??process.cwd(),s=t.env??process.env,i=t.platform??process.platform;if(e.includes("/")||e.includes("\\")){let t=r.default.isAbsolute(e)?e:r.default.resolve(n,e);return await u(t,i)?t:null}let l=s.PATH??s.Path??"",c=o(i)?";":":",m=l.split(c).filter(Boolean),d=o(i)?(s.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean):[""],p=o(i)&&r.default.extname(e).length>0;for(let t of m)for(let n of o(i)?p?[r.default.join(t,e)]:d.map(n=>r.default.join(t,`${e}${n}`)):[r.default.join(t,e)])if(await u(n,i))return n;return null}let l=e=>(0,n.execSync)(e,{encoding:"utf-8",timeout:5e3,stdio:["ignore","pipe","ignore"]});function c(e,t=process.platform,s=l){if(r.default.extname(e)||e.includes("/")||e.includes("\\"))return e;if(!o(t)){try{let t=(0,n.execFileSync)("which",[e],{encoding:"utf-8",timeout:5e3,stdio:["ignore","pipe","ignore"]}).trim();if(t)return t}catch{}return e}try{let t=s(`where ${e}`).trim().split("\n").map(e=>e.trim()).filter(Boolean),n=t.find(e=>/\.(cmd|bat|exe)$/i.test(e));if(n)return n;if(t.length>0)return t[0]}catch{}return e}async function m(e,t,n={}){let r=n.env??process.env,o=n.platform??process.platform;return d(await a(e,n)??e,t,r,o)}function d(e,t,n,i){if(!o(i))return{command:e,args:t};let a=r.default.extname(e).toLowerCase();return".cmd"===a||".bat"===a||".com"===a?{command:n.ComSpec||"cmd.exe",args:["/d","/s","/c",[s(e),...t.map(s)].join(" ")]}:{command:e,args:t}}async function u(e,n=process.platform){try{return await t.promises.access(e,o(n)?t.constants.F_OK:t.constants.X_OK),!0}catch{return!1}}async function p(e=process.platform){return o(e)?f():h()}async function h(){try{let e=await t.promises.readFile("/etc/shells","utf-8"),n=[],o=new Map;for(let t of e.split("\n")){let e=t.replace(/#.*/,"").trim();if(!e||!e.startsWith("/")||!await u(e))continue;let s=r.default.basename(e),i=o.get(s)??0;o.set(s,i+1),i>0&&(s=`${s} (${i+1})`),n.push({name:s,path:e})}return n}catch{let e=[];for(let t of["/bin/zsh","/bin/bash","/bin/sh"])await u(t)&&e.push({name:r.default.basename(t),path:t});return e}}async function f(){let e=[],t=[],n=await a("git",{platform:"win32"});if(n){let e=r.default.resolve(r.default.dirname(n),"..","..");t.push(r.default.join(e,"bin","bash.exe"),r.default.join(e,"usr","bin","bash.exe"))}for(let e of[process.env.ProgramW6432,process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.LocalAppData?r.default.join(process.env.LocalAppData,"Programs"):null].filter(Boolean))t.push(r.default.join(e,"Git","bin","bash.exe"),r.default.join(e,"Git","usr","bin","bash.exe"));let o=process.env.USERPROFILE??"";for(let n of(o&&t.push(r.default.join(o,"scoop","apps","git","current","bin","bash.exe")),process.env.CLAUDE_CODE_GIT_BASH_PATH&&t.unshift(process.env.CLAUDE_CODE_GIT_BASH_PATH),t))if(await u(n,"win32")){e.push({name:"Git Bash",path:n});break}let s=await a("pwsh",{platform:"win32"});s&&e.push({name:"PowerShell",path:s});let i=process.env.windir??"C:\\WINDOWS",l=r.default.join(i,"System32","WindowsPowerShell","v1.0","powershell.exe");await u(l,"win32")&&e.push({name:"Windows PowerShell",path:l});let c=process.env.ComSpec??r.default.join(i,"System32","cmd.exe");return await u(c,"win32")&&e.push({name:"Command Prompt",path:c}),e}let g=[{name:"Terminal",bundleName:"Terminal"},{name:"iTerm2",bundleName:"iTerm"},{name:"Warp",bundleName:"Warp"},{name:"Alacritty",bundleName:"Alacritty"},{name:"WezTerm",bundleName:"WezTerm"},{name:"kitty",bundleName:"kitty"},{name:"Hyper",bundleName:"Hyper"}];async function w(e=process.platform){if("darwin"===e){let t=[];for(let n of g){let r=await u(`/Applications/${n.bundleName}.app`,e);t.push({name:n.name,value:n.bundleName,installed:r})}return t}if(o(e)){let t=[],n=await a("wt",{platform:e});return n&&t.push({name:"Windows Terminal",value:n,installed:!0}),t}return[]}let S=[{name:"VS Code",command:"code"},{name:"VS Code Insiders",command:"code-insiders"},{name:"Cursor",command:"cursor"},{name:"Windsurf",command:"windsurf"},{name:"Zed",command:"zed"},{name:"Sublime Text",command:"subl"},{name:"IntelliJ IDEA",command:"idea"},{name:"WebStorm",command:"webstorm"},{name:"PyCharm",command:"pycharm"},{name:"GoLand",command:"goland"},{name:"RubyMine",command:"rubymine"},{name:"PhpStorm",command:"phpstorm"},{name:"CLion",command:"clion"},{name:"Rider",command:"rider"}],y={code:{darwin:["/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"],win32:["%LOCALAPPDATA%\\Programs\\Microsoft VS Code\\bin\\code.cmd","%ProgramFiles%\\Microsoft VS Code\\bin\\code.cmd"]},"code-insiders":{darwin:["/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code-insiders"],win32:["%LOCALAPPDATA%\\Programs\\Microsoft VS Code Insiders\\bin\\code-insiders.cmd","%ProgramFiles%\\Microsoft VS Code Insiders\\bin\\code-insiders.cmd"]},cursor:{darwin:["/Applications/Cursor.app/Contents/Resources/app/bin/cursor"],win32:["%LOCALAPPDATA%\\Programs\\cursor\\resources\\app\\bin\\cursor.cmd"]},windsurf:{darwin:["/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf"],win32:["%LOCALAPPDATA%\\Programs\\Windsurf\\bin\\windsurf.cmd"]},zed:{darwin:["/Applications/Zed.app/Contents/MacOS/cli"]},subl:{darwin:["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"],win32:["%ProgramFiles%\\Sublime Text\\subl.exe","%ProgramFiles%\\Sublime Text 3\\subl.exe"]},idea:{darwin:["/Applications/IntelliJ IDEA.app/Contents/MacOS/idea","/Applications/IntelliJ IDEA CE.app/Contents/MacOS/idea"]},webstorm:{darwin:["/Applications/WebStorm.app/Contents/MacOS/webstorm"]},pycharm:{darwin:["/Applications/PyCharm.app/Contents/MacOS/pycharm","/Applications/PyCharm CE.app/Contents/MacOS/pycharm"]},goland:{darwin:["/Applications/GoLand.app/Contents/MacOS/goland"]},rubymine:{darwin:["/Applications/RubyMine.app/Contents/MacOS/rubymine"]},phpstorm:{darwin:["/Applications/PhpStorm.app/Contents/MacOS/phpstorm"]},clion:{darwin:["/Applications/CLion.app/Contents/MacOS/clion"]},rider:{darwin:["/Applications/Rider.app/Contents/MacOS/rider"]}};async function k(e,t={}){let n=t.platform??process.platform,r=t.env??process.env,s=await a(e,t);if(s)return s;for(let t of y[e]?.[n]??[]){let e=o(n)?function(e,t){return e.replace(/%([^%]+)%/g,(e,n)=>{let r=t[n];if(void 0!==r)return r;let o=Object.keys(t).find(e=>e.toLowerCase()===n.toLowerCase());return o?t[o]??e:e})}(t,r):t;if(await u(e,n))return e}return null}async function C(e=process.platform){let t=[];for(let n of S){let r=!!await k(n.command,{platform:e});t.push({name:n.name,command:n.command,installed:r})}return t}e.s(["detectEditors",0,C,"detectShells",0,p,"detectTerminalApps",0,w,"ensurePathInEnv",0,function(e,t=process.platform){let n=o(t)?"Path":"PATH";return(e.PATH??e.Path??"").length>0?e:{...e,[n]:function(e=process.platform){return o(e)?"C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\Wbem":"/usr/local/bin:/opt/homebrew/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"}(t)}},"isWindows",0,o,"resolveCommandPath",0,a,"resolveCommandPathSync",0,c,"resolveSdkExecutable",0,function(e,n=process.platform,s=e=>(0,t.readFileSync)(e,"utf-8"),i=e=>(0,t.existsSync)(e)){if(!o(n))return e;let a=r.default.extname(e).toLowerCase();if(".cmd"!==a&&".bat"!==a)return e;let l=r.default.win32.dirname(e),c="",m=e=>{let t=e.replace(/%~?dp0%/gi,l).replace(/\//g,"\\");return r.default.win32.isAbsolute(t)?r.default.win32.normalize(t):r.default.win32.resolve(l,t)};try{let t=s(e);c=t.replace(/\s+/g," ").slice(0,400);let n=t.match(/"([^"]*\.(?:c?js|mjs))"/i);if(n){let e=m(n[1]);if(i(e))return e;console.error(`[resolveSdkExecutable] parsed cli="${e}" but it doesn't exist`)}for(let e of t.matchAll(/"([^"]*\.exe)"/gi)){let t=m(e[1]);if("node.exe"!==r.default.win32.basename(t).toLowerCase()&&i(t))return t}}catch(e){console.error(`[resolveSdkExecutable] shim read failed: ${e instanceof Error?e.message:e}`)}let d=r.default.win32.join(l,"node_modules","@anthropic-ai","claude-code"),u=r.default.win32.basename(e,r.default.win32.extname(e)),p=[r.default.win32.join(d,"cli.js"),r.default.win32.join(d,"bin",`${u}.exe`)];for(let e of p)if(i(e))return e;return console.error(`[resolveSdkExecutable] could not convert ${e} → guesses=${JSON.stringify(p)} shim="${c}"`),e},"resolveSpawnTarget",0,m,"resolveSpawnTargetSync",0,function(e,t,n=process.platform,r){return d(c(e,n,r),t,process.env,n)},"stripClaudeNestingEnv",0,function(e){let t={...e};for(let e of i)delete t[e];return t}])},53674,e=>{"use strict";e.s(["getPackageRoot",0,function(){return process.env.TOWER_PACKAGE_ROOT||process.cwd()}])},472129,e=>{"use strict";var t=e.i(902157),n=e.i(660526),r=e.i(750227),o=e.i(769310),s=e.i(53674);let i=["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"];e.s(["ClaudeCliAdapter",0,class{buildSpawnArgs(e){let t=["--dangerously-skip-permissions"];e.extraArgs?.length&&t.push(...e.extraArgs),e.resumeSessionId?t.push("--resume",e.resumeSessionId):e.continueLatest?t.push("--continue"):e.prompt&&t.push(e.prompt);let n={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:n}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readSettings(),t=e.hooks??{},n=(0,s.getPackageRoot)().replace(/\\/g,"/"),o=r.join(n,"scripts","session-start-hook.js").replace(/\\/g,"/"),i=r.join(n,"scripts","post-tool-hook.js").replace(/\\/g,"/"),a=r.join(n,"scripts","stop-hook.js").replace(/\\/g,"/"),l=!1;return l=this.upsertHook(t,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${o}"`,timeout:5,type:"command"}]})||l,l=this.upsertHook(t,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${i}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||l,(l=this.upsertHook(t,"Stop","stop-hook.js",{hooks:[{command:`node "${a}"`,timeout:5,type:"command"}]})||l)&&(e.hooks=t,this.writeSettings(e)),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readSettings(),t=e.hooks??{},n=(0,s.getPackageRoot)().replace(/\\/g,"/"),o=!1;for(let[e,s]of[["SessionStart","session-start-hook.js"],["PostToolUse","post-tool-hook.js"],["Stop","stop-hook.js"]]){let i=this.getHookArray(t,e),a=i.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(s)));if(a<0)continue;let l=r.join(n,"scripts",s).replace(/\\/g,"/"),c=`node "${l}"`,m=i[a]?.hooks?.[0];m&&m.command!==c&&(m.command=c,t[e]=i,o=!0)}o&&(e.hooks=t,this.writeSettings(e))}catch{}}upsertHook(e,t,n,r){let o=this.getHookArray(e,t),s=r?.hooks?.[0]?.command,i=o.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(n)));if(i>=0){if(o[i]?.hooks?.[0]?.command===s)return!1;o.splice(i,1)}return o.push(r),e[t]=o,!0}async uninstallHooks(){try{let e=this.readSettings(),t=e.hooks??{},n=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let e of["SessionStart","PostToolUse","Stop"]){let r=this.getHookArray(t,e);t[e]=r.filter(e=>!e.hooks?.some(e=>n.some(t=>e.command?.includes(t))))}return e.hooks=t,this.writeSettings(e),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readSettings().hooks??{},t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let n=t.scope??"user",r={command:e.command,args:e.args};e.env&&Object.keys(e.env).length>0&&(r.env=e.env);let o=this.resolveCommand(),s=["mcp","add-json","-s",n,e.name,JSON.stringify(r)];try{return await this.runCli(o,["mcp","remove","-s",n,e.name],t.cwd).catch(()=>{}),await this.runCli(o,s,t.cwd),{ok:!0,method:"cli",detail:`${o} ${s.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${o} ${s.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let n=t.scope??"user",r=this.resolveCommand(),o=["mcp","remove","-s",n,e];try{return await this.runCli(r,o,t.cwd),{ok:!0,method:"cli",detail:`${r} ${o.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${r} ${o.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let n=this.resolveCommand();try{return await this.runCli(n,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,n){let s=r.join(this.getConfigDir(),"skills",e);try{if(!t.existsSync(n))return{ok:!1,method:"symlink",detail:s,error:`Source skill dir does not exist: ${n}`};t.mkdirSync(r.dirname(s),{recursive:!0});let e=await t.promises.lstat(s).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,o.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`};else try{let e=await t.promises.readlink(s);if(r.resolve(e)===r.resolve(n))return{ok:!0,method:"symlink",detail:`${s} → ${n} (already)`};await t.promises.unlink(s)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`}}let i=(0,o.isWindows)()?"junction":"dir";return await t.promises.symlink(n,s,i),{ok:!0,method:"symlink",detail:`${s} → ${n}`}}catch(e){return{ok:!1,method:"symlink",detail:s,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let n=r.join(this.getConfigDir(),"skills",e);try{let e=await t.promises.lstat(n).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${n} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:n,error:`Refusing to remove non-symlink at ${n}`};return await t.promises.unlink(n),{ok:!0,method:"symlink",detail:n}}catch(e){return{ok:!1,method:"symlink",detail:n,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,n){let o=r.join(this.getConfigDir(),"skills",e);try{if(!(await t.promises.lstat(o)).isSymbolicLink())return!1;if(!n)return!0;let e=await t.promises.readlink(o),s=r.isAbsolute(e)?e:r.resolve(r.dirname(o),e);return r.resolve(s)===r.resolve(n)}catch{return!1}}async runCli(t,n,r,o=1e4){let{execFile:s}=await e.A(482848),{promisify:i}=await e.A(268548),a=i(s),{stdout:l}=await a(t,n,{cwd:r,timeout:o});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:n}=await e.A(534777),{resolveSpawnTarget:r}=await e.A(200628),o=n(t),s=await r(this.resolveCommand(),["--version"]),{stdout:i}=await o(s.command,s.args,{timeout:5e3});return i.trim()||null}catch{return null}}async getModels(){return i}getConfigDir(){return r.join(n.homedir(),".claude")}getSettingsPath(){return r.join(this.getConfigDir(),"settings.json")}getSessionsDir(){return r.join(this.getConfigDir(),"projects")}getApiKeyInfo(){return{envVar:"ANTHROPIC_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["--print",e,"--output-format","stream-json","--verbose"]}}resolveCommand(){if(process.env.CLAUDE_CODE_PATH)return process.env.CLAUDE_CODE_PATH;if((0,o.isWindows)()){let e=(0,o.resolveCommandPathSync)("claude-code");if("claude-code"!==e)return e}return(0,o.resolveCommandPathSync)("claude")}readSettings(){try{return JSON.parse(t.readFileSync(this.getSettingsPath(),"utf-8"))}catch{return{}}}writeSettings(e){let n=this.getConfigDir();t.existsSync(n)||t.mkdirSync(n,{recursive:!0}),t.writeFileSync(this.getSettingsPath(),JSON.stringify(e,null,2),"utf-8")}getHookArray(e,t){let n=e[t];return Array.isArray(n)?n:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}])}];
1
+ module.exports=[769310,e=>{"use strict";var t=e.i(902157),n=e.i(874533),r=e.i(750227);function o(e=process.platform){return"win32"===e}function s(e){let t=e.replace(/\r\n|\r|\n/g," ");if(!t.length)return'""';let n=t.replace(/"/g,'""');return/[\s"&<>|^()]/.test(n)?`"${n}"`:n}let i=["CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION","CLAUDE_CODE_PARENT_SESSION"];async function a(e,t={}){let n=t.cwd??process.cwd(),s=t.env??process.env,i=t.platform??process.platform;if(e.includes("/")||e.includes("\\")){let t=r.default.isAbsolute(e)?e:r.default.resolve(n,e);return await u(t,i)?t:null}let l=s.PATH??s.Path??"",c=o(i)?";":":",m=l.split(c).filter(Boolean),d=o(i)?(s.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean):[""],p=o(i)&&r.default.extname(e).length>0;for(let t of m)for(let n of o(i)?p?[r.default.join(t,e)]:d.map(n=>r.default.join(t,`${e}${n}`)):[r.default.join(t,e)])if(await u(n,i))return n;return null}let l=e=>(0,n.execSync)(e,{encoding:"utf-8",timeout:5e3,stdio:["ignore","pipe","ignore"]});function c(e,t=process.platform,s=l){if(r.default.extname(e)||e.includes("/")||e.includes("\\"))return e;if(!o(t)){try{let t=(0,n.execFileSync)("which",[e],{encoding:"utf-8",timeout:5e3,stdio:["ignore","pipe","ignore"]}).trim();if(t)return t}catch{}return e}try{let t=s(`where ${e}`).trim().split("\n").map(e=>e.trim()).filter(Boolean),n=t.find(e=>/\.(cmd|bat|exe)$/i.test(e));if(n)return n;if(t.length>0)return t[0]}catch{}return e}async function m(e,t,n={}){let r=n.env??process.env,o=n.platform??process.platform;return d(await a(e,n)??e,t,r,o)}function d(e,t,n,i){if(!o(i))return{command:e,args:t};let a=r.default.extname(e).toLowerCase();return".cmd"===a||".bat"===a||".com"===a?{command:n.ComSpec||"cmd.exe",args:["/d","/s","/c",[s(e),...t.map(s)].join(" ")]}:{command:e,args:t}}async function u(e,n=process.platform){try{return await t.promises.access(e,o(n)?t.constants.F_OK:t.constants.X_OK),!0}catch{return!1}}async function p(e=process.platform){return o(e)?f():h()}async function h(){try{let e=await t.promises.readFile("/etc/shells","utf-8"),n=[],o=new Map;for(let t of e.split("\n")){let e=t.replace(/#.*/,"").trim();if(!e||!e.startsWith("/")||!await u(e))continue;let s=r.default.basename(e),i=o.get(s)??0;o.set(s,i+1),i>0&&(s=`${s} (${i+1})`),n.push({name:s,path:e})}return n}catch{let e=[];for(let t of["/bin/zsh","/bin/bash","/bin/sh"])await u(t)&&e.push({name:r.default.basename(t),path:t});return e}}async function f(){let e=[],t=[],n=await a("git",{platform:"win32"});if(n){let e=r.default.resolve(r.default.dirname(n),"..","..");t.push(r.default.join(e,"bin","bash.exe"),r.default.join(e,"usr","bin","bash.exe"))}for(let e of[process.env.ProgramW6432,process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.LocalAppData?r.default.join(process.env.LocalAppData,"Programs"):null].filter(Boolean))t.push(r.default.join(e,"Git","bin","bash.exe"),r.default.join(e,"Git","usr","bin","bash.exe"));let o=process.env.USERPROFILE??"";for(let n of(o&&t.push(r.default.join(o,"scoop","apps","git","current","bin","bash.exe")),process.env.CLAUDE_CODE_GIT_BASH_PATH&&t.unshift(process.env.CLAUDE_CODE_GIT_BASH_PATH),t))if(await u(n,"win32")){e.push({name:"Git Bash",path:n});break}let s=await a("pwsh",{platform:"win32"});s&&e.push({name:"PowerShell",path:s});let i=process.env.windir??"C:\\WINDOWS",l=r.default.join(i,"System32","WindowsPowerShell","v1.0","powershell.exe");await u(l,"win32")&&e.push({name:"Windows PowerShell",path:l});let c=process.env.ComSpec??r.default.join(i,"System32","cmd.exe");return await u(c,"win32")&&e.push({name:"Command Prompt",path:c}),e}let g=[{name:"Terminal",bundleName:"Terminal"},{name:"iTerm2",bundleName:"iTerm"},{name:"Warp",bundleName:"Warp"},{name:"Alacritty",bundleName:"Alacritty"},{name:"WezTerm",bundleName:"WezTerm"},{name:"kitty",bundleName:"kitty"},{name:"Hyper",bundleName:"Hyper"}];async function w(e=process.platform){if("darwin"===e){let t=[];for(let n of g){let r=await u(`/Applications/${n.bundleName}.app`,e);t.push({name:n.name,value:n.bundleName,installed:r})}return t}if(o(e)){let t=[],n=await a("wt",{platform:e});return n&&t.push({name:"Windows Terminal",value:n,installed:!0}),t}return[]}let S=[{name:"VS Code",command:"code"},{name:"VS Code Insiders",command:"code-insiders"},{name:"Cursor",command:"cursor"},{name:"Windsurf",command:"windsurf"},{name:"Zed",command:"zed"},{name:"Sublime Text",command:"subl"},{name:"IntelliJ IDEA",command:"idea"},{name:"WebStorm",command:"webstorm"},{name:"PyCharm",command:"pycharm"},{name:"GoLand",command:"goland"},{name:"RubyMine",command:"rubymine"},{name:"PhpStorm",command:"phpstorm"},{name:"CLion",command:"clion"},{name:"Rider",command:"rider"}],k={code:{darwin:["/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"],win32:["%LOCALAPPDATA%\\Programs\\Microsoft VS Code\\bin\\code.cmd","%ProgramFiles%\\Microsoft VS Code\\bin\\code.cmd"]},"code-insiders":{darwin:["/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code-insiders"],win32:["%LOCALAPPDATA%\\Programs\\Microsoft VS Code Insiders\\bin\\code-insiders.cmd","%ProgramFiles%\\Microsoft VS Code Insiders\\bin\\code-insiders.cmd"]},cursor:{darwin:["/Applications/Cursor.app/Contents/Resources/app/bin/cursor"],win32:["%LOCALAPPDATA%\\Programs\\cursor\\resources\\app\\bin\\cursor.cmd"]},windsurf:{darwin:["/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf"],win32:["%LOCALAPPDATA%\\Programs\\Windsurf\\bin\\windsurf.cmd"]},zed:{darwin:["/Applications/Zed.app/Contents/MacOS/cli"]},subl:{darwin:["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"],win32:["%ProgramFiles%\\Sublime Text\\subl.exe","%ProgramFiles%\\Sublime Text 3\\subl.exe"]},idea:{darwin:["/Applications/IntelliJ IDEA.app/Contents/MacOS/idea","/Applications/IntelliJ IDEA CE.app/Contents/MacOS/idea"]},webstorm:{darwin:["/Applications/WebStorm.app/Contents/MacOS/webstorm"]},pycharm:{darwin:["/Applications/PyCharm.app/Contents/MacOS/pycharm","/Applications/PyCharm CE.app/Contents/MacOS/pycharm"]},goland:{darwin:["/Applications/GoLand.app/Contents/MacOS/goland"]},rubymine:{darwin:["/Applications/RubyMine.app/Contents/MacOS/rubymine"]},phpstorm:{darwin:["/Applications/PhpStorm.app/Contents/MacOS/phpstorm"]},clion:{darwin:["/Applications/CLion.app/Contents/MacOS/clion"]},rider:{darwin:["/Applications/Rider.app/Contents/MacOS/rider"]}};async function y(e,t={}){let n=t.platform??process.platform,r=t.env??process.env,s=await a(e,t);if(s)return s;for(let t of k[e]?.[n]??[]){let e=o(n)?function(e,t){return e.replace(/%([^%]+)%/g,(e,n)=>{let r=t[n];if(void 0!==r)return r;let o=Object.keys(t).find(e=>e.toLowerCase()===n.toLowerCase());return o?t[o]??e:e})}(t,r):t;if(await u(e,n))return e}return null}async function C(e=process.platform){let t=[];for(let n of S){let r=!!await y(n.command,{platform:e});t.push({name:n.name,command:n.command,installed:r})}return t}e.s(["detectEditors",0,C,"detectShells",0,p,"detectTerminalApps",0,w,"ensurePathInEnv",0,function(e,t=process.platform){let n=o(t)?"Path":"PATH";return(e.PATH??e.Path??"").length>0?e:{...e,[n]:function(e=process.platform){return o(e)?"C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\Wbem":"/usr/local/bin:/opt/homebrew/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"}(t)}},"isWindows",0,o,"resolveCommandPath",0,a,"resolveCommandPathSync",0,c,"resolveSdkExecutable",0,function(e,n=process.platform,s=e=>(0,t.readFileSync)(e,"utf-8"),i=e=>(0,t.existsSync)(e)){if(!o(n))return e;let a=r.default.extname(e).toLowerCase();if(".cmd"!==a&&".bat"!==a)return e;let l=r.default.win32.dirname(e),c="",m=e=>{let t=e.replace(/%~?dp0%/gi,l).replace(/\//g,"\\");return r.default.win32.isAbsolute(t)?r.default.win32.normalize(t):r.default.win32.resolve(l,t)};try{let t=s(e);c=t.replace(/\s+/g," ").slice(0,400);let n=t.match(/"([^"]*\.(?:c?js|mjs))"/i);if(n){let e=m(n[1]);if(i(e))return e;console.error(`[resolveSdkExecutable] parsed cli="${e}" but it doesn't exist`)}for(let e of t.matchAll(/"([^"]*\.exe)"/gi)){let t=m(e[1]);if("node.exe"!==r.default.win32.basename(t).toLowerCase()&&i(t))return t}}catch(e){console.error(`[resolveSdkExecutable] shim read failed: ${e instanceof Error?e.message:e}`)}let d=r.default.win32.join(l,"node_modules","@anthropic-ai","claude-code"),u=r.default.win32.basename(e,r.default.win32.extname(e)),p=[r.default.win32.join(d,"cli.js"),r.default.win32.join(d,"bin",`${u}.exe`)];for(let e of p)if(i(e))return e;return console.error(`[resolveSdkExecutable] could not convert ${e} → guesses=${JSON.stringify(p)} shim="${c}"`),e},"resolveSpawnTarget",0,m,"resolveSpawnTargetSync",0,function(e,t,n=process.platform,r){return d(c(e,n,r),t,process.env,n)},"stripClaudeNestingEnv",0,function(e){let t={...e};for(let e of i)delete t[e];return t}])},53674,e=>{"use strict";e.s(["getPackageRoot",0,function(){return process.env.TOWER_PACKAGE_ROOT||process.cwd()}])},472129,e=>{"use strict";var t=e.i(902157),n=e.i(660526),r=e.i(750227),o=e.i(769310),s=e.i(53674);let i=["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"];e.s(["ClaudeCliAdapter",0,class{buildSpawnArgs(e){let t=["--dangerously-skip-permissions"];e.extraArgs?.length&&t.push(...e.extraArgs),e.resumeSessionId?t.push("--resume",e.resumeSessionId):e.continueLatest?t.push("--continue"):e.prompt&&t.push(e.prompt);let n={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:n}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readSettings(),t=e.hooks??{},n=(0,s.getPackageRoot)().replace(/\\/g,"/"),o=r.join(n,"scripts","tower-session-start-hook.js").replace(/\\/g,"/"),i=r.join(n,"scripts","tower-post-tool-hook.js").replace(/\\/g,"/"),a=r.join(n,"scripts","tower-stop-hook.js").replace(/\\/g,"/"),l=!1;return l=this.upsertHook(t,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${o}"`,timeout:5,type:"command"}]})||l,l=this.upsertHook(t,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${i}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||l,(l=this.upsertHook(t,"Stop","stop-hook.js",{hooks:[{command:`node "${a}"`,timeout:5,type:"command"}]})||l)&&(e.hooks=t,this.writeSettings(e)),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readSettings(),t=e.hooks??{},n=(0,s.getPackageRoot)().replace(/\\/g,"/"),o=!1;for(let[e,s,i]of[["SessionStart","session-start-hook.js","tower-session-start-hook.js"],["PostToolUse","post-tool-hook.js","tower-post-tool-hook.js"],["Stop","stop-hook.js","tower-stop-hook.js"]]){let a=this.getHookArray(t,e),l=a.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(s)));if(l<0)continue;let c=r.join(n,"scripts",i).replace(/\\/g,"/"),m=`node "${c}"`,d=a[l]?.hooks?.[0];d&&d.command!==m&&(d.command=m,t[e]=a,o=!0)}o&&(e.hooks=t,this.writeSettings(e))}catch{}}upsertHook(e,t,n,r){let o=this.getHookArray(e,t),s=r?.hooks?.[0]?.command,i=o.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(n)));if(i>=0){if(o[i]?.hooks?.[0]?.command===s)return!1;o.splice(i,1)}return o.push(r),e[t]=o,!0}async uninstallHooks(){try{let e=this.readSettings(),t=e.hooks??{},n=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let e of["SessionStart","PostToolUse","Stop"]){let r=this.getHookArray(t,e);t[e]=r.filter(e=>!e.hooks?.some(e=>n.some(t=>e.command?.includes(t))))}return e.hooks=t,this.writeSettings(e),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readSettings().hooks??{},t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let n=t.scope??"user",r={command:e.command,args:e.args};e.env&&Object.keys(e.env).length>0&&(r.env=e.env);let o=this.resolveCommand(),s=["mcp","add-json","-s",n,e.name,JSON.stringify(r)];try{return await this.runCli(o,["mcp","remove","-s",n,e.name],t.cwd).catch(()=>{}),await this.runCli(o,s,t.cwd),{ok:!0,method:"cli",detail:`${o} ${s.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${o} ${s.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let n=t.scope??"user",r=this.resolveCommand(),o=["mcp","remove","-s",n,e];try{return await this.runCli(r,o,t.cwd),{ok:!0,method:"cli",detail:`${r} ${o.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${r} ${o.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let n=this.resolveCommand();try{return await this.runCli(n,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,n){let s=r.join(this.getConfigDir(),"skills",e);try{if(!t.existsSync(n))return{ok:!1,method:"symlink",detail:s,error:`Source skill dir does not exist: ${n}`};t.mkdirSync(r.dirname(s),{recursive:!0});let e=await t.promises.lstat(s).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,o.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`};else try{let e=await t.promises.readlink(s);if(r.resolve(e)===r.resolve(n))return{ok:!0,method:"symlink",detail:`${s} → ${n} (already)`};await t.promises.unlink(s)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`}}let i=(0,o.isWindows)()?"junction":"dir";return await t.promises.symlink(n,s,i),{ok:!0,method:"symlink",detail:`${s} → ${n}`}}catch(e){return{ok:!1,method:"symlink",detail:s,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let n=r.join(this.getConfigDir(),"skills",e);try{let e=await t.promises.lstat(n).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${n} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:n,error:`Refusing to remove non-symlink at ${n}`};return await t.promises.unlink(n),{ok:!0,method:"symlink",detail:n}}catch(e){return{ok:!1,method:"symlink",detail:n,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,n){let o=r.join(this.getConfigDir(),"skills",e);try{if(!(await t.promises.lstat(o)).isSymbolicLink())return!1;if(!n)return!0;let e=await t.promises.readlink(o),s=r.isAbsolute(e)?e:r.resolve(r.dirname(o),e);return r.resolve(s)===r.resolve(n)}catch{return!1}}async runCli(t,n,r,o=1e4){let{execFile:s}=await e.A(482848),{promisify:i}=await e.A(268548),a=i(s),{stdout:l}=await a(t,n,{cwd:r,timeout:o});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:n}=await e.A(534777),{resolveSpawnTarget:r}=await e.A(200628),o=n(t),s=await r(this.resolveCommand(),["--version"]),{stdout:i}=await o(s.command,s.args,{timeout:5e3});return i.trim()||null}catch{return null}}async getModels(){return i}getConfigDir(){return r.join(n.homedir(),".claude")}getSettingsPath(){return r.join(this.getConfigDir(),"settings.json")}getSessionsDir(){return r.join(this.getConfigDir(),"projects")}getApiKeyInfo(){return{envVar:"ANTHROPIC_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["--print",e,"--output-format","stream-json","--verbose"]}}resolveCommand(){if(process.env.CLAUDE_CODE_PATH)return process.env.CLAUDE_CODE_PATH;if((0,o.isWindows)()){let e=(0,o.resolveCommandPathSync)("claude-code");if("claude-code"!==e)return e}return(0,o.resolveCommandPathSync)("claude")}readSettings(){try{return JSON.parse(t.readFileSync(this.getSettingsPath(),"utf-8"))}catch{return{}}}writeSettings(e){let n=this.getConfigDir();t.existsSync(n)||t.mkdirSync(n,{recursive:!0}),t.writeFileSync(this.getSettingsPath(),JSON.stringify(e,null,2),"utf-8")}getHookArray(e,t){let n=e[t];return Array.isArray(n)?n:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}])}];
2
2
 
3
3
  //# sourceMappingURL=src_lib_0aowbzy._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[340616,e=>{"use strict";let t=[/\x1b\[[<=>?]?[0-9;]*c/g,/\x1b\[\??[0-9;]*n/g,/\x1b\[\??[0-9;]*\$p/g,/\x1b\[>[0-9;]*q/g,/\x1b\[(?:1[1345689]|2[01])(?:;[0-9]+)*t/g,/\x1b\][0-9;]*;\?(?:\x07|\x1b\\)/g,/\x1bP[$+]q[\s\S]*?\x1b\\/g];e.s(["stripDeviceQueries",0,function(e){if(!e)return e;let r=e;for(let e of t)r=r.replace(e,"");return r}])},423212,e=>{"use strict";e.i(519895);let t=globalThis.__previewSessions??=new Map;function r(){for(let e of[...t.keys()])!function(e){let r=t.get(e);if(r){try{r.stop()}catch{}t.delete(e)}}(e)}globalThis.__previewSignalHandlersRegistered||(process.on("SIGTERM",r),process.on("SIGINT",r),process.on("SIGHUP",r),globalThis.__previewSignalHandlersRegistered=!0),e.s(["getPreviewSession",0,function(e){return t.get(e)}],423212)},117490,e=>{"use strict";let t="__preview__";e.s(["PREVIEW_TASK_ID",0,t,"parsePreviewWsParams",0,function(e){if(e.get("taskId")!==t)return null;let r=e.get("role"),s=e.get("previewKey");if("state"!==r&&"terminal"!==r||!s)return null;let n=e.get("connectionId")??Math.random().toString(36).slice(2);return{role:r,previewKey:decodeURIComponent(s),connectionId:n,taskId:e.get("clientTaskId")}}])},721390,e=>e.a(async(t,r)=>{try{var s=e.i(433541),n=e.i(83721),o=e.i(340616),i=e.i(572173),l=e.i(658053),a=e.i(423212),c=e.i(117490),f=t([s]);[s]=f.then?(await f)():f;let v=new Map;function u(){return w.__notificationClients||(w.__notificationClients=new Set),w.__notificationClients}function d(e){u().add(e)}function g(e){u().delete(e)}let w=globalThis;async function S(){var t;if(w.__wss){let e=w.__wss;w.__wss=void 0,await new Promise(t=>{e.close(()=>t()),setTimeout(t,1e3)})}let r=parseInt(process.env.PORT||"3000",10),o=await (0,i.readConfigValue)("terminal.wsPort",r+1),f=o;for(let r=0;r<10&&await (t=f,new Promise(r=>{let{createServer:s}=e.r(504446),n=s();n.once("error",()=>r(!0)),n.once("listening",()=>{n.close(()=>r(!1))}),n.listen(t,"127.0.0.1")}));r++){if(9===r)return void console.error(`[ws-server] No free port found after trying ${o}–${f} — skipping startup`);console.error(`[ws-server] Port ${f} in use, trying ${f+1}...`),f++}let u=new s.WebSocketServer({port:f,host:"127.0.0.1",perMessageDeflate:!1});w.__wss=u,w.__wsPort=f,f!==o?console.error(`[ws-server] WebSocket server listening on port ${f} (preferred ${o} was occupied)`):console.error(`[ws-server] WebSocket server listening on port ${f}`);let S=()=>{u.close(),w.__wss=void 0,w.__wsPort=void 0};process.once("SIGINT",S),process.once("SIGTERM",S),u.on("connection",(e,t)=>{let r,o=t.headers.origin??"";if(!(r=parseInt(process.env.PORT||"3000",10),new Set([`http://localhost:${r}`,`http://127.0.0.1:${r}`])).has(o)){console.error(`[ws-server] Rejected origin: ${o||"(none)"}`),e.close(1008,"Forbidden");return}let i=new URL(t.url??"/",`http://localhost:${f}`),u=i.searchParams.get("taskId");if(!u)return void e.close(1008,"Missing taskId");let S=(0,c.parsePreviewWsParams)(i.searchParams);if(S){let t=(0,a.getPreviewSession)(S.previewKey),r=null,n=null;function w(){if(t){if(n=t.subscribe(S.connectionId,S.taskId??"unknown",r=>{if("state"===S.role)try{e.send(JSON.stringify({type:"state",previewKey:t.key,state:r}))}catch{}},t=>{if("terminal"===S.role)try{e.send(t)}catch{}}),"terminal"===S.role){let r=t.getBuffer();if(r.length>0)try{e.send(r.join("\n")+"\n")}catch{}}if("state"===S.role)try{e.send(JSON.stringify({type:"state",previewKey:t.key,state:t.getState()}))}catch{}}}if(t)w();else{let n=0;r=setInterval(()=>{n+=500,(t=(0,a.getPreviewSession)(S.previewKey))?(clearInterval(r),r=null,w()):(n>=3e4||e.readyState!==s.WebSocket.OPEN)&&(clearInterval(r),r=null,e.readyState===s.WebSocket.OPEN&&e.close(1008,"No preview session created within timeout."))},500)}e.on("close",()=>{r&&(clearInterval(r),r=null),n&&(n(),n=null)}),e.on("error",()=>{r&&(clearInterval(r),r=null),n&&(n(),n=null)});return}if("__notifications__"===u){d(e),e.on("close",()=>g(e)),e.on("error",()=>g(e));return}console.error(`[ws-server] Connection for task ${u}`);let y=(0,n.getSession)(u),_=null;if(y)p(y,e,u),console.error(`[ws-server] Attached to existing session for task ${u}`);else{console.error(`[ws-server] No session for task ${u} — polling...`);let t=0;_=setInterval(()=>{t+=500,(y=(0,n.getSession)(u))?(clearInterval(_),_=null,p(y,e,u),console.error(`[ws-server] Session appeared for task ${u} after ${t}ms`)):(t>=3e4||e.readyState!==s.WebSocket.OPEN)&&(clearInterval(_),_=null,e.readyState===s.WebSocket.OPEN&&e.close(1008,"No PTY session created within timeout."))},500)}e.on("message",e=>{if(!y)return;let t=e.toString();if(t.startsWith("{"))try{let e=JSON.parse(t);if("resize"===e.type&&"number"==typeof e.cols&&"number"==typeof e.rows)return void y.resize(e.cols,e.rows)}catch{}y.write(t)}),e.on("close",()=>{e._batcher?.flush();let t=v.get(u);if(!t?.has(e)||(t.delete(e),console.error(`[ws-server] WS disconnected for task ${u} (${t.size} remaining)`),t.size>0))return;v.delete(u);let r=(0,n.getSession)(u);if(!r)return;if(r.setDataListener(()=>{}),u===l.ASSISTANT_SESSION_KEY){console.error("[ws-server] Assistant session disconnected — destroying immediately"),(0,n.destroySession)(u);return}let s=r.killed?3e5:72e5;r.disconnectTimer=setTimeout(()=>{console.error(`[ws-server] Keepalive expired for task ${u}`),(0,n.destroySession)(u)},s)}),e.on("error",t=>{console.error(`[ws-server] WS error for task ${u}:`,t.message),_&&(clearInterval(_),_=null);let r=v.get(u);if(!r?.has(e)||(r.delete(e),r.size>0))return;v.delete(u);let s=(0,n.getSession)(u);s&&!s.killed&&s.setDataListener(()=>{})})})}function p(e,t,r){var n;let i,l;e.disconnectTimer&&(clearTimeout(e.disconnectTimer),e.disconnectTimer=null);let a=v.get(r);a||(a=new Set,v.set(r,a)),a.add(t);let c=(n=t,i="",l=null,{send:e=>{i+=e,l||(l=setTimeout(()=>{l=null,n.readyState===s.WebSocket.OPEN&&n.bufferedAmount<65536&&n.send(i),i=""},8))},flush:()=>{l&&(clearTimeout(l),l=null),i&&n.readyState===s.WebSocket.OPEN&&n.bufferedAmount<65536&&n.send(i),i=""}});t._batcher=c;let f=a;e.setDataListener(e=>{for(let t of f){let r=t._batcher;r?r.send(e):t.readyState===s.WebSocket.OPEN&&t.send(e)}});let u=e.getBuffer();if(u&&t.readyState===s.WebSocket.OPEN){let e=(0,o.stripDeviceQueries)(u);e.length!==u.length&&console.error(`[ws-server] Stripped ${u.length-e.length} bytes of device-query sequences from replay for task ${r} (prevents phantom PTY input on reconnect)`),t.send(e)}e.setExitListener(e=>{let t=function(e){if(null==e)return 4255;let t=Number(e);if(!Number.isFinite(t))return 4255;let r=4e3+(t>=0&&t<256?0|t:t>>>0&255);return r<1e3||r>4999?4255:r}(e);for(let e of f)e.readyState===s.WebSocket.OPEN&&e.close(t,"session_end")})}e.s(["addNotificationClient",0,d,"broadcastNotification",0,function(e){let t=JSON.stringify(e);for(let e of u())e.readyState===s.WebSocket.OPEN&&e.send(t)},"getActiveWsPort",0,function(){return w.__wsPort??null},"removeNotificationClient",0,g,"startWsServer",0,S]),r()}catch(e){r(e)}},!1)];
2
+
3
+ //# sourceMappingURL=src_lib_0d~1~wz._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[53674,e=>{"use strict";e.s(["getPackageRoot",0,function(){return process.env.TOWER_PACKAGE_ROOT||process.cwd()}])},472129,e=>{"use strict";var t=e.i(902157),o=e.i(660526),s=e.i(750227),r=e.i(769310),i=e.i(53674);let n=["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"];e.s(["ClaudeCliAdapter",0,class{buildSpawnArgs(e){let t=["--dangerously-skip-permissions"];e.extraArgs?.length&&t.push(...e.extraArgs),e.resumeSessionId?t.push("--resume",e.resumeSessionId):e.continueLatest?t.push("--continue"):e.prompt&&t.push(e.prompt);let o={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:o}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readSettings(),t=e.hooks??{},o=(0,i.getPackageRoot)().replace(/\\/g,"/"),r=s.join(o,"scripts","session-start-hook.js").replace(/\\/g,"/"),n=s.join(o,"scripts","post-tool-hook.js").replace(/\\/g,"/"),a=s.join(o,"scripts","stop-hook.js").replace(/\\/g,"/"),l=!1;return l=this.upsertHook(t,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${r}"`,timeout:5,type:"command"}]})||l,l=this.upsertHook(t,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${n}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||l,(l=this.upsertHook(t,"Stop","stop-hook.js",{hooks:[{command:`node "${a}"`,timeout:5,type:"command"}]})||l)&&(e.hooks=t,this.writeSettings(e)),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readSettings(),t=e.hooks??{},o=(0,i.getPackageRoot)().replace(/\\/g,"/"),r=!1;for(let[e,i]of[["SessionStart","session-start-hook.js"],["PostToolUse","post-tool-hook.js"],["Stop","stop-hook.js"]]){let n=this.getHookArray(t,e),a=n.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(i)));if(a<0)continue;let l=s.join(o,"scripts",i).replace(/\\/g,"/"),c=`node "${l}"`,d=n[a]?.hooks?.[0];d&&d.command!==c&&(d.command=c,t[e]=n,r=!0)}r&&(e.hooks=t,this.writeSettings(e))}catch{}}upsertHook(e,t,o,s){let r=this.getHookArray(e,t),i=s?.hooks?.[0]?.command,n=r.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(o)));if(n>=0){if(r[n]?.hooks?.[0]?.command===i)return!1;r.splice(n,1)}return r.push(s),e[t]=r,!0}async uninstallHooks(){try{let e=this.readSettings(),t=e.hooks??{},o=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let e of["SessionStart","PostToolUse","Stop"]){let s=this.getHookArray(t,e);t[e]=s.filter(e=>!e.hooks?.some(e=>o.some(t=>e.command?.includes(t))))}return e.hooks=t,this.writeSettings(e),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readSettings().hooks??{},t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let o=t.scope??"user",s={command:e.command,args:e.args};e.env&&Object.keys(e.env).length>0&&(s.env=e.env);let r=this.resolveCommand(),i=["mcp","add-json","-s",o,e.name,JSON.stringify(s)];try{return await this.runCli(r,["mcp","remove","-s",o,e.name],t.cwd).catch(()=>{}),await this.runCli(r,i,t.cwd),{ok:!0,method:"cli",detail:`${r} ${i.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${r} ${i.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let o=t.scope??"user",s=this.resolveCommand(),r=["mcp","remove","-s",o,e];try{return await this.runCli(s,r,t.cwd),{ok:!0,method:"cli",detail:`${s} ${r.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${s} ${r.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let o=this.resolveCommand();try{return await this.runCli(o,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,o){let i=s.join(this.getConfigDir(),"skills",e);try{if(!t.existsSync(o))return{ok:!1,method:"symlink",detail:i,error:`Source skill dir does not exist: ${o}`};t.mkdirSync(s.dirname(i),{recursive:!0});let e=await t.promises.lstat(i).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,r.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:i,error:`Refusing to overwrite non-symlink at ${i}`};else try{let e=await t.promises.readlink(i);if(s.resolve(e)===s.resolve(o))return{ok:!0,method:"symlink",detail:`${i} → ${o} (already)`};await t.promises.unlink(i)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:i,error:`Refusing to overwrite non-symlink at ${i}`}}let n=(0,r.isWindows)()?"junction":"dir";return await t.promises.symlink(o,i,n),{ok:!0,method:"symlink",detail:`${i} → ${o}`}}catch(e){return{ok:!1,method:"symlink",detail:i,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let o=s.join(this.getConfigDir(),"skills",e);try{let e=await t.promises.lstat(o).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${o} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:o,error:`Refusing to remove non-symlink at ${o}`};return await t.promises.unlink(o),{ok:!0,method:"symlink",detail:o}}catch(e){return{ok:!1,method:"symlink",detail:o,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,o){let r=s.join(this.getConfigDir(),"skills",e);try{if(!(await t.promises.lstat(r)).isSymbolicLink())return!1;if(!o)return!0;let e=await t.promises.readlink(r),i=s.isAbsolute(e)?e:s.resolve(s.dirname(r),e);return s.resolve(i)===s.resolve(o)}catch{return!1}}async runCli(t,o,s,r=1e4){let{execFile:i}=await e.A(482848),{promisify:n}=await e.A(268548),a=n(i),{stdout:l}=await a(t,o,{cwd:s,timeout:r});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:o}=await e.A(534777),{resolveSpawnTarget:s}=await e.A(200628),r=o(t),i=await s(this.resolveCommand(),["--version"]),{stdout:n}=await r(i.command,i.args,{timeout:5e3});return n.trim()||null}catch{return null}}async getModels(){return n}getConfigDir(){return s.join(o.homedir(),".claude")}getSettingsPath(){return s.join(this.getConfigDir(),"settings.json")}getSessionsDir(){return s.join(this.getConfigDir(),"projects")}getApiKeyInfo(){return{envVar:"ANTHROPIC_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["--print",e,"--output-format","stream-json","--verbose"]}}resolveCommand(){if(process.env.CLAUDE_CODE_PATH)return process.env.CLAUDE_CODE_PATH;if((0,r.isWindows)()){let e=(0,r.resolveCommandPathSync)("claude-code");if("claude-code"!==e)return e}return(0,r.resolveCommandPathSync)("claude")}readSettings(){try{return JSON.parse(t.readFileSync(this.getSettingsPath(),"utf-8"))}catch{return{}}}writeSettings(e){let o=this.getConfigDir();t.existsSync(o)||t.mkdirSync(o,{recursive:!0}),t.writeFileSync(this.getSettingsPath(),JSON.stringify(e,null,2),"utf-8")}getHookArray(e,t){let o=e[t];return Array.isArray(o)?o:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}])},279711,e=>{"use strict";class t{providers=new Map;register(e){this.providers.set(e.name,e)}get(e){return this.providers.get(e)}getAll(){return Array.from(this.providers.values())}getCliAdapter(e){return this.providers.get(e)?.cli?.adapter??null}getQueryAdapter(e,t){let o=this.providers.get(e);return o?"api"===t?o.api?.adapter??null:o.cliQuery?.adapter??null:null}getAllowedCommands(){let e=[];for(let t of this.providers.values())t.cli?.command&&e.push(t.cli.command);return e}async getAvailableProviders(){let e=[];for(let t of this.providers.values()){let o=!!t.cli&&await t.cli.adapter.isAvailable(),s=o&&t.cli?await t.cli.adapter.getVersion():null,r=!!t.api&&!!process.env[t.api.keyEnvVar],i=!!t.api&&r;e.push({name:t.name,displayName:t.displayName,cli:{available:o,version:s},api:{available:i,keyConfigured:r}})}return e}}var o=e.i(472129),s=e.i(902157),r=e.i(660526),i=e.i(750227),n=e.i(769310),a=e.i(53674);let l=["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],c=globalThis;if(!c.__providerRegistry){let d=new t;d.register({name:"claude",displayName:"Claude Code",agentFieldValue:"CLAUDE_CODE",cli:{command:"claude",adapter:new o.ClaudeCliAdapter},models:{cli:["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"],api:[]}}),d.register({name:"codex",displayName:"Codex CLI",agentFieldValue:"CODEX_CLI",cli:{command:"codex",adapter:new class t{buildSpawnArgs(e){let t=[];e.resumeSessionId?t.push("resume",e.resumeSessionId):e.continueLatest?t.push("resume","--last"):(t.push("--full-auto"),e.extraArgs?.length&&t.push(...e.extraArgs),e.prompt&&t.push(e.prompt));let o={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:o}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readHooks(),t=(0,a.getPackageRoot)().replace(/\\/g,"/"),o=i.join(t,"scripts","session-start-hook.js").replace(/\\/g,"/"),s=i.join(t,"scripts","post-tool-hook.js").replace(/\\/g,"/"),r=i.join(t,"scripts","stop-hook.js").replace(/\\/g,"/"),n=!1;return n=this.upsertHook(e,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${o}"`,timeout:5,type:"command"}]})||n,n=this.upsertHook(e,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${s}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||n,(n=this.upsertHook(e,"Stop","stop-hook.js",{hooks:[{command:`node "${r}"`,timeout:5,type:"command"}]})||n)&&(this.writeHooks(e),this.ensureHooksFeatureEnabled()),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readHooks(),t=(0,a.getPackageRoot)().replace(/\\/g,"/"),o=!1;for(let[s,r]of[["SessionStart","session-start-hook.js"],["PostToolUse","post-tool-hook.js"],["Stop","stop-hook.js"]]){let n=this.getHookArray(e,s),a=n.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(r)));if(a<0)continue;let l=i.join(t,"scripts",r).replace(/\\/g,"/"),c=`node "${l}"`,d=n[a]?.hooks?.[0];d&&d.command!==c&&(d.command=c,e[s]=n,o=!0)}o&&(this.writeHooks(e),this.ensureHooksFeatureEnabled())}catch{}}upsertHook(e,t,o,s){let r=this.getHookArray(e,t),i=s?.hooks?.[0]?.command,n=r.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(o)));if(n>=0){if(r[n]?.hooks?.[0]?.command===i)return!1;r.splice(n,1)}return r.push(s),e[t]=r,!0}async uninstallHooks(){try{let e=this.readHooks(),t=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let o of["SessionStart","PostToolUse","Stop"]){let s=this.getHookArray(e,o);e[o]=s.filter(e=>!e.hooks?.some(e=>t.some(t=>e.command?.includes(t))))}return this.writeHooks(e),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readHooks(),t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let o=this.resolveCommand(),s=["mcp","add",e.name];if(e.env)for(let[t,o]of Object.entries(e.env))s.push("--env",`${t}=${o}`);s.push("--",e.command,...e.args);try{return await this.runCli(o,["mcp","remove",e.name],t.cwd).catch(()=>{}),await this.runCli(o,s,t.cwd),{ok:!0,method:"cli",detail:`${o} ${s.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${o} ${s.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let o=this.resolveCommand(),s=["mcp","remove",e];try{return await this.runCli(o,s,t.cwd),{ok:!0,method:"cli",detail:`${o} ${s.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${o} ${s.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let o=this.resolveCommand();try{return await this.runCli(o,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,t){let o=i.join(this.getConfigDir(),"skills",e);try{if(!s.existsSync(t))return{ok:!1,method:"symlink",detail:o,error:`Source skill dir does not exist: ${t}`};s.mkdirSync(i.dirname(o),{recursive:!0});let e=await s.promises.lstat(o).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,n.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:o,error:`Refusing to overwrite non-symlink at ${o}`};else try{let e=await s.promises.readlink(o);if(i.resolve(e)===i.resolve(t))return{ok:!0,method:"symlink",detail:`${o} → ${t} (already)`};await s.promises.unlink(o)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:o,error:`Refusing to overwrite non-symlink at ${o}`}}let r=(0,n.isWindows)()?"junction":"dir";return await s.promises.symlink(t,o,r),{ok:!0,method:"symlink",detail:`${o} → ${t}`}}catch(e){return{ok:!1,method:"symlink",detail:o,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let t=i.join(this.getConfigDir(),"skills",e);try{let e=await s.promises.lstat(t).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${t} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:t,error:`Refusing to remove non-symlink at ${t}`};return await s.promises.unlink(t),{ok:!0,method:"symlink",detail:t}}catch(e){return{ok:!1,method:"symlink",detail:t,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,t){let o=i.join(this.getConfigDir(),"skills",e);try{if(!(await s.promises.lstat(o)).isSymbolicLink())return!1;if(!t)return!0;let e=await s.promises.readlink(o),r=i.isAbsolute(e)?e:i.resolve(i.dirname(o),e);return i.resolve(r)===i.resolve(t)}catch{return!1}}async runCli(t,o,s,r=1e4){let{execFile:i}=await e.A(482848),{promisify:n}=await e.A(268548),a=n(i),{stdout:l}=await a(t,o,{cwd:s,timeout:r});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:o}=await e.A(534777),{resolveSpawnTarget:s}=await e.A(200628),r=o(t),i=await s(this.resolveCommand(),["--version"]),{stdout:n}=await r(i.command,i.args,{timeout:5e3});return n.trim()||null}catch{return null}}async getModels(){return l}getConfigDir(){return i.join(r.homedir(),".codex")}getSettingsPath(){return i.join(this.getConfigDir(),"config.toml")}getSessionsDir(){return i.join(this.getConfigDir(),"sessions")}getApiKeyInfo(){return{envVar:"OPENAI_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["exec",e]}}resolveCommand(){return process.env.CODEX_CLI_PATH?process.env.CODEX_CLI_PATH:(0,n.resolveCommandPathSync)("codex")}getHooksPath(){return i.join(this.getConfigDir(),"hooks.json")}readHooks(){try{return JSON.parse(s.readFileSync(this.getHooksPath(),"utf-8")).hooks??{}}catch{return{}}}writeHooks(e){let t=this.getConfigDir();s.existsSync(t)||s.mkdirSync(t,{recursive:!0}),s.writeFileSync(this.getHooksPath(),JSON.stringify({hooks:e},null,2),"utf-8")}ensureHooksFeatureEnabled(){let e=this.getSettingsPath(),t="";try{t=s.readFileSync(e,"utf-8")}catch{}if(/codex_hooks\s*=\s*true/.test(t))return;/\[features\]/.test(t)?t=t.replace(/\[features\]/,"[features]\ncodex_hooks = true"):t+="\n[features]\ncodex_hooks = true\n";let o=this.getConfigDir();s.existsSync(o)||s.mkdirSync(o,{recursive:!0}),s.writeFileSync(e,t,"utf-8")}getHookArray(e,t){let o=e[t];return Array.isArray(o)?o:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}},models:{cli:["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],api:[]}}),c.__providerRegistry=d}let d=c.__providerRegistry;e.s(["providerRegistry",0,d],279711)}];
1
+ module.exports=[53674,e=>{"use strict";e.s(["getPackageRoot",0,function(){return process.env.TOWER_PACKAGE_ROOT||process.cwd()}])},472129,e=>{"use strict";var t=e.i(902157),o=e.i(660526),s=e.i(750227),r=e.i(769310),i=e.i(53674);let n=["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"];e.s(["ClaudeCliAdapter",0,class{buildSpawnArgs(e){let t=["--dangerously-skip-permissions"];e.extraArgs?.length&&t.push(...e.extraArgs),e.resumeSessionId?t.push("--resume",e.resumeSessionId):e.continueLatest?t.push("--continue"):e.prompt&&t.push(e.prompt);let o={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:o}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readSettings(),t=e.hooks??{},o=(0,i.getPackageRoot)().replace(/\\/g,"/"),r=s.join(o,"scripts","tower-session-start-hook.js").replace(/\\/g,"/"),n=s.join(o,"scripts","tower-post-tool-hook.js").replace(/\\/g,"/"),a=s.join(o,"scripts","tower-stop-hook.js").replace(/\\/g,"/"),l=!1;return l=this.upsertHook(t,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${r}"`,timeout:5,type:"command"}]})||l,l=this.upsertHook(t,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${n}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||l,(l=this.upsertHook(t,"Stop","stop-hook.js",{hooks:[{command:`node "${a}"`,timeout:5,type:"command"}]})||l)&&(e.hooks=t,this.writeSettings(e)),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readSettings(),t=e.hooks??{},o=(0,i.getPackageRoot)().replace(/\\/g,"/"),r=!1;for(let[e,i,n]of[["SessionStart","session-start-hook.js","tower-session-start-hook.js"],["PostToolUse","post-tool-hook.js","tower-post-tool-hook.js"],["Stop","stop-hook.js","tower-stop-hook.js"]]){let a=this.getHookArray(t,e),l=a.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(i)));if(l<0)continue;let c=s.join(o,"scripts",n).replace(/\\/g,"/"),d=`node "${c}"`,m=a[l]?.hooks?.[0];m&&m.command!==d&&(m.command=d,t[e]=a,r=!0)}r&&(e.hooks=t,this.writeSettings(e))}catch{}}upsertHook(e,t,o,s){let r=this.getHookArray(e,t),i=s?.hooks?.[0]?.command,n=r.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(o)));if(n>=0){if(r[n]?.hooks?.[0]?.command===i)return!1;r.splice(n,1)}return r.push(s),e[t]=r,!0}async uninstallHooks(){try{let e=this.readSettings(),t=e.hooks??{},o=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let e of["SessionStart","PostToolUse","Stop"]){let s=this.getHookArray(t,e);t[e]=s.filter(e=>!e.hooks?.some(e=>o.some(t=>e.command?.includes(t))))}return e.hooks=t,this.writeSettings(e),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readSettings().hooks??{},t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let o=t.scope??"user",s={command:e.command,args:e.args};e.env&&Object.keys(e.env).length>0&&(s.env=e.env);let r=this.resolveCommand(),i=["mcp","add-json","-s",o,e.name,JSON.stringify(s)];try{return await this.runCli(r,["mcp","remove","-s",o,e.name],t.cwd).catch(()=>{}),await this.runCli(r,i,t.cwd),{ok:!0,method:"cli",detail:`${r} ${i.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${r} ${i.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let o=t.scope??"user",s=this.resolveCommand(),r=["mcp","remove","-s",o,e];try{return await this.runCli(s,r,t.cwd),{ok:!0,method:"cli",detail:`${s} ${r.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${s} ${r.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let o=this.resolveCommand();try{return await this.runCli(o,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,o){let i=s.join(this.getConfigDir(),"skills",e);try{if(!t.existsSync(o))return{ok:!1,method:"symlink",detail:i,error:`Source skill dir does not exist: ${o}`};t.mkdirSync(s.dirname(i),{recursive:!0});let e=await t.promises.lstat(i).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,r.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:i,error:`Refusing to overwrite non-symlink at ${i}`};else try{let e=await t.promises.readlink(i);if(s.resolve(e)===s.resolve(o))return{ok:!0,method:"symlink",detail:`${i} → ${o} (already)`};await t.promises.unlink(i)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:i,error:`Refusing to overwrite non-symlink at ${i}`}}let n=(0,r.isWindows)()?"junction":"dir";return await t.promises.symlink(o,i,n),{ok:!0,method:"symlink",detail:`${i} → ${o}`}}catch(e){return{ok:!1,method:"symlink",detail:i,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let o=s.join(this.getConfigDir(),"skills",e);try{let e=await t.promises.lstat(o).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${o} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:o,error:`Refusing to remove non-symlink at ${o}`};return await t.promises.unlink(o),{ok:!0,method:"symlink",detail:o}}catch(e){return{ok:!1,method:"symlink",detail:o,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,o){let r=s.join(this.getConfigDir(),"skills",e);try{if(!(await t.promises.lstat(r)).isSymbolicLink())return!1;if(!o)return!0;let e=await t.promises.readlink(r),i=s.isAbsolute(e)?e:s.resolve(s.dirname(r),e);return s.resolve(i)===s.resolve(o)}catch{return!1}}async runCli(t,o,s,r=1e4){let{execFile:i}=await e.A(482848),{promisify:n}=await e.A(268548),a=n(i),{stdout:l}=await a(t,o,{cwd:s,timeout:r});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:o}=await e.A(534777),{resolveSpawnTarget:s}=await e.A(200628),r=o(t),i=await s(this.resolveCommand(),["--version"]),{stdout:n}=await r(i.command,i.args,{timeout:5e3});return n.trim()||null}catch{return null}}async getModels(){return n}getConfigDir(){return s.join(o.homedir(),".claude")}getSettingsPath(){return s.join(this.getConfigDir(),"settings.json")}getSessionsDir(){return s.join(this.getConfigDir(),"projects")}getApiKeyInfo(){return{envVar:"ANTHROPIC_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["--print",e,"--output-format","stream-json","--verbose"]}}resolveCommand(){if(process.env.CLAUDE_CODE_PATH)return process.env.CLAUDE_CODE_PATH;if((0,r.isWindows)()){let e=(0,r.resolveCommandPathSync)("claude-code");if("claude-code"!==e)return e}return(0,r.resolveCommandPathSync)("claude")}readSettings(){try{return JSON.parse(t.readFileSync(this.getSettingsPath(),"utf-8"))}catch{return{}}}writeSettings(e){let o=this.getConfigDir();t.existsSync(o)||t.mkdirSync(o,{recursive:!0}),t.writeFileSync(this.getSettingsPath(),JSON.stringify(e,null,2),"utf-8")}getHookArray(e,t){let o=e[t];return Array.isArray(o)?o:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}])},279711,e=>{"use strict";class t{providers=new Map;register(e){this.providers.set(e.name,e)}get(e){return this.providers.get(e)}getAll(){return Array.from(this.providers.values())}getCliAdapter(e){return this.providers.get(e)?.cli?.adapter??null}getQueryAdapter(e,t){let o=this.providers.get(e);return o?"api"===t?o.api?.adapter??null:o.cliQuery?.adapter??null:null}getAllowedCommands(){let e=[];for(let t of this.providers.values())t.cli?.command&&e.push(t.cli.command);return e}async getAvailableProviders(){let e=[];for(let t of this.providers.values()){let o=!!t.cli&&await t.cli.adapter.isAvailable(),s=o&&t.cli?await t.cli.adapter.getVersion():null,r=!!t.api&&!!process.env[t.api.keyEnvVar],i=!!t.api&&r;e.push({name:t.name,displayName:t.displayName,cli:{available:o,version:s},api:{available:i,keyConfigured:r}})}return e}}var o=e.i(472129),s=e.i(902157),r=e.i(660526),i=e.i(750227),n=e.i(769310),a=e.i(53674);let l=["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],c=globalThis;if(!c.__providerRegistry){let d=new t;d.register({name:"claude",displayName:"Claude Code",agentFieldValue:"CLAUDE_CODE",cli:{command:"claude",adapter:new o.ClaudeCliAdapter},models:{cli:["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"],api:[]}}),d.register({name:"codex",displayName:"Codex CLI",agentFieldValue:"CODEX_CLI",cli:{command:"codex",adapter:new class t{buildSpawnArgs(e){let t=[];e.resumeSessionId?t.push("resume",e.resumeSessionId):e.continueLatest?t.push("resume","--last"):(t.push("--full-auto"),e.extraArgs?.length&&t.push(...e.extraArgs),e.prompt&&t.push(e.prompt));let o={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:o}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readHooks(),t=(0,a.getPackageRoot)().replace(/\\/g,"/"),o=i.join(t,"scripts","tower-session-start-hook.js").replace(/\\/g,"/"),s=i.join(t,"scripts","tower-post-tool-hook.js").replace(/\\/g,"/"),r=i.join(t,"scripts","tower-stop-hook.js").replace(/\\/g,"/"),n=!1;return n=this.upsertHook(e,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${o}"`,timeout:5,type:"command"}]})||n,n=this.upsertHook(e,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${s}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||n,(n=this.upsertHook(e,"Stop","stop-hook.js",{hooks:[{command:`node "${r}"`,timeout:5,type:"command"}]})||n)&&(this.writeHooks(e),this.ensureHooksFeatureEnabled()),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readHooks(),t=(0,a.getPackageRoot)().replace(/\\/g,"/"),o=!1;for(let[s,r,n]of[["SessionStart","session-start-hook.js","tower-session-start-hook.js"],["PostToolUse","post-tool-hook.js","tower-post-tool-hook.js"],["Stop","stop-hook.js","tower-stop-hook.js"]]){let a=this.getHookArray(e,s),l=a.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(r)));if(l<0)continue;let c=i.join(t,"scripts",n).replace(/\\/g,"/"),d=`node "${c}"`,m=a[l]?.hooks?.[0];m&&m.command!==d&&(m.command=d,e[s]=a,o=!0)}o&&(this.writeHooks(e),this.ensureHooksFeatureEnabled())}catch{}}upsertHook(e,t,o,s){let r=this.getHookArray(e,t),i=s?.hooks?.[0]?.command,n=r.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(o)));if(n>=0){if(r[n]?.hooks?.[0]?.command===i)return!1;r.splice(n,1)}return r.push(s),e[t]=r,!0}async uninstallHooks(){try{let e=this.readHooks(),t=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let o of["SessionStart","PostToolUse","Stop"]){let s=this.getHookArray(e,o);e[o]=s.filter(e=>!e.hooks?.some(e=>t.some(t=>e.command?.includes(t))))}return this.writeHooks(e),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readHooks(),t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let o=this.resolveCommand(),s=["mcp","add",e.name];if(e.env)for(let[t,o]of Object.entries(e.env))s.push("--env",`${t}=${o}`);s.push("--",e.command,...e.args);try{return await this.runCli(o,["mcp","remove",e.name],t.cwd).catch(()=>{}),await this.runCli(o,s,t.cwd),{ok:!0,method:"cli",detail:`${o} ${s.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${o} ${s.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let o=this.resolveCommand(),s=["mcp","remove",e];try{return await this.runCli(o,s,t.cwd),{ok:!0,method:"cli",detail:`${o} ${s.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${o} ${s.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let o=this.resolveCommand();try{return await this.runCli(o,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,t){let o=i.join(this.getConfigDir(),"skills",e);try{if(!s.existsSync(t))return{ok:!1,method:"symlink",detail:o,error:`Source skill dir does not exist: ${t}`};s.mkdirSync(i.dirname(o),{recursive:!0});let e=await s.promises.lstat(o).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,n.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:o,error:`Refusing to overwrite non-symlink at ${o}`};else try{let e=await s.promises.readlink(o);if(i.resolve(e)===i.resolve(t))return{ok:!0,method:"symlink",detail:`${o} → ${t} (already)`};await s.promises.unlink(o)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:o,error:`Refusing to overwrite non-symlink at ${o}`}}let r=(0,n.isWindows)()?"junction":"dir";return await s.promises.symlink(t,o,r),{ok:!0,method:"symlink",detail:`${o} → ${t}`}}catch(e){return{ok:!1,method:"symlink",detail:o,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let t=i.join(this.getConfigDir(),"skills",e);try{let e=await s.promises.lstat(t).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${t} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:t,error:`Refusing to remove non-symlink at ${t}`};return await s.promises.unlink(t),{ok:!0,method:"symlink",detail:t}}catch(e){return{ok:!1,method:"symlink",detail:t,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,t){let o=i.join(this.getConfigDir(),"skills",e);try{if(!(await s.promises.lstat(o)).isSymbolicLink())return!1;if(!t)return!0;let e=await s.promises.readlink(o),r=i.isAbsolute(e)?e:i.resolve(i.dirname(o),e);return i.resolve(r)===i.resolve(t)}catch{return!1}}async runCli(t,o,s,r=1e4){let{execFile:i}=await e.A(482848),{promisify:n}=await e.A(268548),a=n(i),{stdout:l}=await a(t,o,{cwd:s,timeout:r});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:o}=await e.A(534777),{resolveSpawnTarget:s}=await e.A(200628),r=o(t),i=await s(this.resolveCommand(),["--version"]),{stdout:n}=await r(i.command,i.args,{timeout:5e3});return n.trim()||null}catch{return null}}async getModels(){return l}getConfigDir(){return i.join(r.homedir(),".codex")}getSettingsPath(){return i.join(this.getConfigDir(),"config.toml")}getSessionsDir(){return i.join(this.getConfigDir(),"sessions")}getApiKeyInfo(){return{envVar:"OPENAI_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["exec",e]}}resolveCommand(){return process.env.CODEX_CLI_PATH?process.env.CODEX_CLI_PATH:(0,n.resolveCommandPathSync)("codex")}getHooksPath(){return i.join(this.getConfigDir(),"hooks.json")}readHooks(){try{return JSON.parse(s.readFileSync(this.getHooksPath(),"utf-8")).hooks??{}}catch{return{}}}writeHooks(e){let t=this.getConfigDir();s.existsSync(t)||s.mkdirSync(t,{recursive:!0}),s.writeFileSync(this.getHooksPath(),JSON.stringify({hooks:e},null,2),"utf-8")}ensureHooksFeatureEnabled(){let e=this.getSettingsPath(),t="";try{t=s.readFileSync(e,"utf-8")}catch{}if(/codex_hooks\s*=\s*true/.test(t))return;/\[features\]/.test(t)?t=t.replace(/\[features\]/,"[features]\ncodex_hooks = true"):t+="\n[features]\ncodex_hooks = true\n";let o=this.getConfigDir();s.existsSync(o)||s.mkdirSync(o,{recursive:!0}),s.writeFileSync(e,t,"utf-8")}getHookArray(e,t){let o=e[t];return Array.isArray(o)?o:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}},models:{cli:["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],api:[]}}),c.__providerRegistry=d}let d=c.__providerRegistry;e.s(["providerRegistry",0,d],279711)}];
2
2
 
3
3
  //# sourceMappingURL=src_lib_0nw5n~t._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[682100,e=>{"use strict";var t=e.i(980738),s=e.i(603484);class r{taskId;_pty;killed=!1;disconnectTimer=null;_buffer="";static BUFFER_MAX=51200;_onData;_exitListeners=[];_idleTimer=null;_idleThresholdMs;_onIdle;_idleFired=!1;constructor(e,i,n,o,l,a,c,d,u){this.taskId=e,this._onData=l,this._onIdle=d??null,this._idleThresholdMs=Math.max(u??18e4,18e4);const f={...(0,s.stripClaudeNestingEnv)((0,s.ensurePathInEnv)(process.env)),TERM:"xterm-color",...c};try{this._pty=t.spawn(i,n,{name:"xterm-color",cols:80,rows:24,cwd:o,env:f})}catch(e){throw console.error(`[pty] spawn failed: command="${i}", cwd="${o}", PATH="${f.PATH?.slice(0,200)}"`),e}this._pty.onData(e=>{this._buffer+=e,this._buffer.length>r.BUFFER_MAX&&(this._buffer=this._buffer.slice(this._buffer.length-r.BUFFER_MAX)),this._resetIdleTimer(),this._onData(e)}),this._pty.onExit(({exitCode:e,signal:t})=>{for(let s of(this.killed=!0,this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null),a(e,t),this._exitListeners))s(e)}),this._resetIdleTimer()}_resetIdleTimer(){this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null),null===this._onIdle||this.killed||this._idleFired||(this._idleTimer=setTimeout(()=>{this._idleFired=!0,this._onIdle?.()},this._idleThresholdMs))}setDataListener(e){this._onData=e}setExitListener(e){this._exitListeners=[e]}write(e){this.killed||(this._resetIdleTimer(),this._pty.write(e))}resize(e,t){this.killed||this._pty.resize(e,t)}getBuffer(){return this._buffer}get isIdle(){return this._idleFired}get pid(){return this._pty.pid}kill(e){if(!this.killed){this.killed=!0,this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null);try{this._pty.kill(e)}catch{}}}forceKill(){try{this._pty.kill("SIGKILL")}catch{}this.killed=!0}killTree(e=3e3){if(this.killed)return;this.killed=!0,this._idleTimer&&(clearTimeout(this._idleTimer),this._idleTimer=null);let t=this._pty.pid;try{process.kill(-t,"SIGTERM")}catch{try{this._pty.kill()}catch{}return}let s=setTimeout(()=>{try{process.kill(-t,"SIGKILL")}catch{}},e);s.unref?.()}}e.s(["PtySession",0,r])},370314,e=>{"use strict";e.i(682100),e.i(603484);var t=e.i(979755);let s=globalThis;s.__ptySessions||(s.__ptySessions=new Map);let r=s.__ptySessions;function i(e){(function(e){let t=r.get(e);if(t)return r.delete(e),t.disconnectTimer&&(clearTimeout(t.disconnectTimer),t.disconnectTimer=null),t.killTree(),t})(e)&&(0,t.clearSessionPid)(e)}function n(){for(let e of r.keys())i(e)}let o=globalThis;"phase-production-build"===process.env.NEXT_PHASE||o.__ptySignalHandlersRegistered||(o.__ptySignalHandlersRegistered=!0,process.once("SIGTERM",()=>{console.error("[session-store] SIGTERM received — cleaning up PTY sessions"),n()}),process.once("SIGINT",()=>{console.error("[session-store] SIGINT received — cleaning up PTY sessions"),n()})),e.s(["destroySession",0,i,"getSession",0,function(e){return r.get(e)}])},991980,e=>{"use strict";let t=[/\x1b\[[<=>?]?[0-9;]*c/g,/\x1b\[\??[0-9;]*n/g,/\x1b\[\??[0-9;]*\$p/g,/\x1b\[>[0-9;]*q/g,/\x1b\[(?:1[1345689]|2[01])(?:;[0-9]+)*t/g,/\x1b\][0-9;]*;\?(?:\x07|\x1b\\)/g,/\x1bP[$+]q[\s\S]*?\x1b\\/g];e.s(["stripDeviceQueries",0,function(e){if(!e)return e;let s=e;for(let e of t)s=s.replace(e,"");return s}])},351495,e=>{"use strict";e.s(["ASSISTANT_SESSION_KEY",0,"__assistant__"])},205314,e=>{"use strict";e.i(682100);let t=globalThis.__previewSessions??=new Map;function s(){for(let e of[...t.keys()])!function(e){let s=t.get(e);if(s){try{s.stop()}catch{}t.delete(e)}}(e)}globalThis.__previewSignalHandlersRegistered||(process.on("SIGTERM",s),process.on("SIGINT",s),process.on("SIGHUP",s),globalThis.__previewSignalHandlersRegistered=!0),e.s(["getPreviewSession",0,function(e){return t.get(e)}],205314)},982377,e=>{"use strict";let t="__preview__";e.s(["PREVIEW_TASK_ID",0,t,"parsePreviewWsParams",0,function(e){if(e.get("taskId")!==t)return null;let s=e.get("role"),r=e.get("previewKey");if("state"!==s&&"terminal"!==s||!r)return null;let i=e.get("connectionId")??Math.random().toString(36).slice(2);return{role:s,previewKey:decodeURIComponent(r),connectionId:i,taskId:e.get("clientTaskId")}}])},723538,e=>e.a(async(t,s)=>{try{var r=e.i(433541),i=e.i(370314),n=e.i(991980),o=e.i(746888),l=e.i(351495),a=e.i(205314),c=e.i(982377),d=t([r]);[r]=d.then?(await d)():d;let S=new Map;function u(){return g.__notificationClients||(g.__notificationClients=new Set),g.__notificationClients}function f(e){u().add(e)}function _(e){u().delete(e)}let g=globalThis;async function h(){var t;if(g.__wss){let e=g.__wss;g.__wss=void 0,await new Promise(t=>{e.close(()=>t()),setTimeout(t,1e3)})}let s=parseInt(process.env.PORT||"3000",10),n=await (0,o.readConfigValue)("terminal.wsPort",s+1),d=n;for(let s=0;s<10&&await (t=d,new Promise(s=>{let{createServer:r}=e.r(504446),i=r();i.once("error",()=>s(!0)),i.once("listening",()=>{i.close(()=>s(!1))}),i.listen(t,"127.0.0.1")}));s++){if(9===s)return void console.error(`[ws-server] No free port found after trying ${n}–${d} — skipping startup`);console.error(`[ws-server] Port ${d} in use, trying ${d+1}...`),d++}let u=new r.WebSocketServer({port:d,host:"127.0.0.1",perMessageDeflate:!1});g.__wss=u,g.__wsPort=d,d!==n?console.error(`[ws-server] WebSocket server listening on port ${d} (preferred ${n} was occupied)`):console.error(`[ws-server] WebSocket server listening on port ${d}`);let h=()=>{u.close(),g.__wss=void 0,g.__wsPort=void 0};process.once("SIGINT",h),process.once("SIGTERM",h),u.on("connection",(e,t)=>{let s,n=t.headers.origin??"";if(!(s=parseInt(process.env.PORT||"3000",10),new Set([`http://localhost:${s}`,`http://127.0.0.1:${s}`])).has(n)){console.error(`[ws-server] Rejected origin: ${n||"(none)"}`),e.close(1008,"Forbidden");return}let o=new URL(t.url??"/",`http://localhost:${d}`),u=o.searchParams.get("taskId");if(!u)return void e.close(1008,"Missing taskId");let h=(0,c.parsePreviewWsParams)(o.searchParams);if(h){let t=(0,a.getPreviewSession)(h.previewKey),s=null,i=null;function g(){if(t){if(i=t.subscribe(h.connectionId,h.taskId??"unknown",s=>{if("state"===h.role)try{e.send(JSON.stringify({type:"state",previewKey:t.key,state:s}))}catch{}},t=>{if("terminal"===h.role)try{e.send(t)}catch{}}),"terminal"===h.role){let s=t.getBuffer();if(s.length>0)try{e.send(s.join("\n")+"\n")}catch{}}if("state"===h.role)try{e.send(JSON.stringify({type:"state",previewKey:t.key,state:t.getState()}))}catch{}}}if(t)g();else{let i=0;s=setInterval(()=>{i+=500,(t=(0,a.getPreviewSession)(h.previewKey))?(clearInterval(s),s=null,g()):(i>=3e4||e.readyState!==r.WebSocket.OPEN)&&(clearInterval(s),s=null,e.readyState===r.WebSocket.OPEN&&e.close(1008,"No preview session created within timeout."))},500)}e.on("close",()=>{s&&(clearInterval(s),s=null),i&&(i(),i=null)}),e.on("error",()=>{s&&(clearInterval(s),s=null),i&&(i(),i=null)});return}if("__notifications__"===u){f(e),e.on("close",()=>_(e)),e.on("error",()=>_(e));return}console.error(`[ws-server] Connection for task ${u}`);let m=(0,i.getSession)(u),v=null;if(m)p(m,e,u),console.error(`[ws-server] Attached to existing session for task ${u}`);else{console.error(`[ws-server] No session for task ${u} — polling...`);let t=0;v=setInterval(()=>{t+=500,(m=(0,i.getSession)(u))?(clearInterval(v),v=null,p(m,e,u),console.error(`[ws-server] Session appeared for task ${u} after ${t}ms`)):(t>=3e4||e.readyState!==r.WebSocket.OPEN)&&(clearInterval(v),v=null,e.readyState===r.WebSocket.OPEN&&e.close(1008,"No PTY session created within timeout."))},500)}e.on("message",e=>{if(!m)return;let t=e.toString();if(t.startsWith("{"))try{let e=JSON.parse(t);if("resize"===e.type&&"number"==typeof e.cols&&"number"==typeof e.rows)return void m.resize(e.cols,e.rows)}catch{}m.write(t)}),e.on("close",()=>{e._batcher?.flush();let t=S.get(u);if(!t?.has(e)||(t.delete(e),console.error(`[ws-server] WS disconnected for task ${u} (${t.size} remaining)`),t.size>0))return;S.delete(u);let s=(0,i.getSession)(u);if(!s)return;if(s.setDataListener(()=>{}),u===l.ASSISTANT_SESSION_KEY){console.error("[ws-server] Assistant session disconnected — destroying immediately"),(0,i.destroySession)(u);return}let r=s.killed?3e5:72e5;s.disconnectTimer=setTimeout(()=>{console.error(`[ws-server] Keepalive expired for task ${u}`),(0,i.destroySession)(u)},r)}),e.on("error",t=>{console.error(`[ws-server] WS error for task ${u}:`,t.message),v&&(clearInterval(v),v=null);let s=S.get(u);if(!s?.has(e)||(s.delete(e),s.size>0))return;S.delete(u);let r=(0,i.getSession)(u);r&&!r.killed&&r.setDataListener(()=>{})})})}function p(e,t,s){var i;let o,l;e.disconnectTimer&&(clearTimeout(e.disconnectTimer),e.disconnectTimer=null);let a=S.get(s);a||(a=new Set,S.set(s,a)),a.add(t);let c=(i=t,o="",l=null,{send:e=>{o+=e,l||(l=setTimeout(()=>{l=null,i.readyState===r.WebSocket.OPEN&&i.bufferedAmount<65536&&i.send(o),o=""},8))},flush:()=>{l&&(clearTimeout(l),l=null),o&&i.readyState===r.WebSocket.OPEN&&i.bufferedAmount<65536&&i.send(o),o=""}});t._batcher=c;let d=a;e.setDataListener(e=>{for(let t of d){let s=t._batcher;s?s.send(e):t.readyState===r.WebSocket.OPEN&&t.send(e)}});let u=e.getBuffer();if(u&&t.readyState===r.WebSocket.OPEN){let e=(0,n.stripDeviceQueries)(u);e.length!==u.length&&console.error(`[ws-server] Stripped ${u.length-e.length} bytes of device-query sequences from replay for task ${s} (prevents phantom PTY input on reconnect)`),t.send(e)}e.setExitListener(e=>{let t=function(e){if(null==e)return 4255;let t=Number(e);if(!Number.isFinite(t))return 4255;let s=4e3+(t>=0&&t<256?0|t:t>>>0&255);return s<1e3||s>4999?4255:s}(e);for(let e of d)e.readyState===r.WebSocket.OPEN&&e.close(t,"session_end")})}e.s(["addNotificationClient",0,f,"broadcastNotification",0,function(e){let t=JSON.stringify(e);for(let e of u())e.readyState===r.WebSocket.OPEN&&e.send(t)},"getActiveWsPort",0,function(){return g.__wsPort??null},"removeNotificationClient",0,_,"startWsServer",0,h]),s()}catch(e){s(e)}},!1),336114,e=>e.a(async(t,s)=>{try{var r=e.i(723538);e.i(982377);var i=t([r]);[r]=i.then?(await i)():i,e.s(["startWsServer",()=>r.startWsServer]),s()}catch(e){s(e)}},!1)];
2
+
3
+ //# sourceMappingURL=src_lib_0ylel_1._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[279711,e=>{"use strict";class t{providers=new Map;register(e){this.providers.set(e.name,e)}get(e){return this.providers.get(e)}getAll(){return Array.from(this.providers.values())}getCliAdapter(e){return this.providers.get(e)?.cli?.adapter??null}getQueryAdapter(e,t){let r=this.providers.get(e);return r?"api"===t?r.api?.adapter??null:r.cliQuery?.adapter??null:null}getAllowedCommands(){let e=[];for(let t of this.providers.values())t.cli?.command&&e.push(t.cli.command);return e}async getAvailableProviders(){let e=[];for(let t of this.providers.values()){let r=!!t.cli&&await t.cli.adapter.isAvailable(),o=r&&t.cli?await t.cli.adapter.getVersion():null,i=!!t.api&&!!process.env[t.api.keyEnvVar],s=!!t.api&&i;e.push({name:t.name,displayName:t.displayName,cli:{available:r,version:o},api:{available:s,keyConfigured:i}})}return e}}var r=e.i(472129),o=e.i(902157),i=e.i(660526),s=e.i(750227),n=e.i(769310),a=e.i(53674);let l=["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],c=globalThis;if(!c.__providerRegistry){let d=new t;d.register({name:"claude",displayName:"Claude Code",agentFieldValue:"CLAUDE_CODE",cli:{command:"claude",adapter:new r.ClaudeCliAdapter},models:{cli:["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"],api:[]}}),d.register({name:"codex",displayName:"Codex CLI",agentFieldValue:"CODEX_CLI",cli:{command:"codex",adapter:new class t{buildSpawnArgs(e){let t=[];e.resumeSessionId?t.push("resume",e.resumeSessionId):e.continueLatest?t.push("resume","--last"):(t.push("--full-auto"),e.extraArgs?.length&&t.push(...e.extraArgs),e.prompt&&t.push(e.prompt));let r={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:r}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readHooks(),t=(0,a.getPackageRoot)().replace(/\\/g,"/"),r=s.join(t,"scripts","session-start-hook.js").replace(/\\/g,"/"),o=s.join(t,"scripts","post-tool-hook.js").replace(/\\/g,"/"),i=s.join(t,"scripts","stop-hook.js").replace(/\\/g,"/"),n=!1;return n=this.upsertHook(e,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${r}"`,timeout:5,type:"command"}]})||n,n=this.upsertHook(e,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${o}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||n,(n=this.upsertHook(e,"Stop","stop-hook.js",{hooks:[{command:`node "${i}"`,timeout:5,type:"command"}]})||n)&&(this.writeHooks(e),this.ensureHooksFeatureEnabled()),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readHooks(),t=(0,a.getPackageRoot)().replace(/\\/g,"/"),r=!1;for(let[o,i]of[["SessionStart","session-start-hook.js"],["PostToolUse","post-tool-hook.js"],["Stop","stop-hook.js"]]){let n=this.getHookArray(e,o),a=n.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(i)));if(a<0)continue;let l=s.join(t,"scripts",i).replace(/\\/g,"/"),c=`node "${l}"`,d=n[a]?.hooks?.[0];d&&d.command!==c&&(d.command=c,e[o]=n,r=!0)}r&&(this.writeHooks(e),this.ensureHooksFeatureEnabled())}catch{}}upsertHook(e,t,r,o){let i=this.getHookArray(e,t),s=o?.hooks?.[0]?.command,n=i.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(r)));if(n>=0){if(i[n]?.hooks?.[0]?.command===s)return!1;i.splice(n,1)}return i.push(o),e[t]=i,!0}async uninstallHooks(){try{let e=this.readHooks(),t=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let r of["SessionStart","PostToolUse","Stop"]){let o=this.getHookArray(e,r);e[r]=o.filter(e=>!e.hooks?.some(e=>t.some(t=>e.command?.includes(t))))}return this.writeHooks(e),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readHooks(),t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let r=this.resolveCommand(),o=["mcp","add",e.name];if(e.env)for(let[t,r]of Object.entries(e.env))o.push("--env",`${t}=${r}`);o.push("--",e.command,...e.args);try{return await this.runCli(r,["mcp","remove",e.name],t.cwd).catch(()=>{}),await this.runCli(r,o,t.cwd),{ok:!0,method:"cli",detail:`${r} ${o.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${r} ${o.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let r=this.resolveCommand(),o=["mcp","remove",e];try{return await this.runCli(r,o,t.cwd),{ok:!0,method:"cli",detail:`${r} ${o.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${r} ${o.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let r=this.resolveCommand();try{return await this.runCli(r,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,t){let r=s.join(this.getConfigDir(),"skills",e);try{if(!o.existsSync(t))return{ok:!1,method:"symlink",detail:r,error:`Source skill dir does not exist: ${t}`};o.mkdirSync(s.dirname(r),{recursive:!0});let e=await o.promises.lstat(r).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,n.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:r,error:`Refusing to overwrite non-symlink at ${r}`};else try{let e=await o.promises.readlink(r);if(s.resolve(e)===s.resolve(t))return{ok:!0,method:"symlink",detail:`${r} → ${t} (already)`};await o.promises.unlink(r)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:r,error:`Refusing to overwrite non-symlink at ${r}`}}let i=(0,n.isWindows)()?"junction":"dir";return await o.promises.symlink(t,r,i),{ok:!0,method:"symlink",detail:`${r} → ${t}`}}catch(e){return{ok:!1,method:"symlink",detail:r,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let t=s.join(this.getConfigDir(),"skills",e);try{let e=await o.promises.lstat(t).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${t} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:t,error:`Refusing to remove non-symlink at ${t}`};return await o.promises.unlink(t),{ok:!0,method:"symlink",detail:t}}catch(e){return{ok:!1,method:"symlink",detail:t,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,t){let r=s.join(this.getConfigDir(),"skills",e);try{if(!(await o.promises.lstat(r)).isSymbolicLink())return!1;if(!t)return!0;let e=await o.promises.readlink(r),i=s.isAbsolute(e)?e:s.resolve(s.dirname(r),e);return s.resolve(i)===s.resolve(t)}catch{return!1}}async runCli(t,r,o,i=1e4){let{execFile:s}=await e.A(482848),{promisify:n}=await e.A(268548),a=n(s),{stdout:l}=await a(t,r,{cwd:o,timeout:i});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:r}=await e.A(534777),{resolveSpawnTarget:o}=await e.A(200628),i=r(t),s=await o(this.resolveCommand(),["--version"]),{stdout:n}=await i(s.command,s.args,{timeout:5e3});return n.trim()||null}catch{return null}}async getModels(){return l}getConfigDir(){return s.join(i.homedir(),".codex")}getSettingsPath(){return s.join(this.getConfigDir(),"config.toml")}getSessionsDir(){return s.join(this.getConfigDir(),"sessions")}getApiKeyInfo(){return{envVar:"OPENAI_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["exec",e]}}resolveCommand(){return process.env.CODEX_CLI_PATH?process.env.CODEX_CLI_PATH:(0,n.resolveCommandPathSync)("codex")}getHooksPath(){return s.join(this.getConfigDir(),"hooks.json")}readHooks(){try{return JSON.parse(o.readFileSync(this.getHooksPath(),"utf-8")).hooks??{}}catch{return{}}}writeHooks(e){let t=this.getConfigDir();o.existsSync(t)||o.mkdirSync(t,{recursive:!0}),o.writeFileSync(this.getHooksPath(),JSON.stringify({hooks:e},null,2),"utf-8")}ensureHooksFeatureEnabled(){let e=this.getSettingsPath(),t="";try{t=o.readFileSync(e,"utf-8")}catch{}if(/codex_hooks\s*=\s*true/.test(t))return;/\[features\]/.test(t)?t=t.replace(/\[features\]/,"[features]\ncodex_hooks = true"):t+="\n[features]\ncodex_hooks = true\n";let r=this.getConfigDir();o.existsSync(r)||o.mkdirSync(r,{recursive:!0}),o.writeFileSync(e,t,"utf-8")}getHookArray(e,t){let r=e[t];return Array.isArray(r)?r:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}},models:{cli:["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],api:[]}}),c.__providerRegistry=d}let d=c.__providerRegistry;e.s(["providerRegistry",0,d],279711)},173215,e=>{"use strict";var t=e.i(902157),r=e.i(660526),o=e.i(750227),i=e.i(279711),s=e.i(192520),n=e.i(53674);let a="tower";function l(){let e=(0,s.getTowerDir)(),t=o.join((0,r.homedir)(),".tower");if(o.resolve(e)===o.resolve(t))return"tower";let i=o.basename(e),n=i.match(/^\.?tower-(.+)$/);return n?`tower-${c(n[1])}`:`tower-${c(i)}`}function c(e){return e.replace(/[^a-z0-9_-]/gi,"-").toLowerCase().slice(0,32)}function d(){let e=(0,n.getPackageRoot)().replace(/\\/g,"/"),r={DATABASE_URL:process.env.DATABASE_URL||`file:${(0,s.getTowerDbPath)().replace(/\\/g,"/")}`,TOWER_DATA_DIR:(0,s.getTowerDir)()},o=`${e}/dist/mcp-server.cjs`,i=l();return(0,t.existsSync)(o)?{name:i,command:"node",args:[o],env:r}:{name:i,command:`${e}/node_modules/.bin/tsx`,args:[`${e}/src/mcp/index.ts`],env:r}}async function m(e,s){let l=i.providerRegistry.get(e),c=l?.cli?.adapter;if(!c||!await c.isAvailable())return{provider:e,available:!1,ok:!1};let m="claude"===e?function(e={}){let i=e.homeDir??r.homedir(),s=e.repoRoot??process.cwd(),n=[];return n.push(function(e){let r=o.join(e,".claude","settings.json");if(!t.existsSync(r))return{removed:!1,path:r};try{let e=t.readFileSync(r,"utf-8"),o=JSON.parse(e),i=o.mcpServers;if("object"!=typeof i||null===i||Array.isArray(i)||!("tower"in i))return{removed:!1,path:r};let s=i.tower;return delete i.tower,0===Object.keys(i).length?delete o.mcpServers:o.mcpServers=i,t.writeFileSync(r,JSON.stringify(o,null,2)+"\n","utf-8"),{removed:!0,path:r,removedEntry:s,reason:"wrong-file"}}catch(e){return{removed:!1,path:r,error:e instanceof Error?e.message:String(e)}}}(i)),n.push(function(e,r,i){if(!t.existsSync(e))return{removed:!1,path:e};try{let s=t.readFileSync(e,"utf-8"),n=JSON.parse(s),a=n.mcpServers;if("object"!=typeof a||null===a||Array.isArray(a))return{removed:!1,path:e};let l=a.tower;if(!l)return{removed:!1,path:e};let c=function(e,r){let i,s=e.args;if(!Array.isArray(s))return"foreign-repo";for(let e of s)if("string"==typeof e&&o.isAbsolute(e)){i=e;break}return i?t.existsSync(i)?o.resolve(i).startsWith(o.resolve(r)+o.sep)?"current-repo":"foreign-repo":"missing-path":"foreign-repo"}(l,i);if("current-repo"===c)return{removed:!1,path:e,reason:"alive-current-repo"};return delete a.tower,0===Object.keys(a).length?delete n.mcpServers:n.mcpServers=a,t.writeFileSync(e,JSON.stringify(n,null,2)+"\n","utf-8"),{removed:!0,path:e,removedEntry:l,reason:`${r}:${c}`}}catch(t){return{removed:!1,path:e,error:t instanceof Error?t.message:String(t)}}}(o.join(i,".mcp.json"),"home-mcp-json",s)),{steps:n,removedAny:n.some(e=>e.removed)}}():void 0,u=d(),h=await c.installMcp(u,{scope:"user"}),p=await c.installHooks(s),g=await c.installSkill(a,o.join((0,n.getPackageRoot)(),"skills",a));return{provider:e,available:!0,migration:m,mcp:h,hooks:p,skill:g,ok:h.ok&&p.ok&&g.ok}}e.s(["buildTowerMcpConfig",0,d,"getTowerMcpName",0,l,"installAllForProvider",0,m],173215)}];
1
+ module.exports=[279711,e=>{"use strict";class t{providers=new Map;register(e){this.providers.set(e.name,e)}get(e){return this.providers.get(e)}getAll(){return Array.from(this.providers.values())}getCliAdapter(e){return this.providers.get(e)?.cli?.adapter??null}getQueryAdapter(e,t){let r=this.providers.get(e);return r?"api"===t?r.api?.adapter??null:r.cliQuery?.adapter??null:null}getAllowedCommands(){let e=[];for(let t of this.providers.values())t.cli?.command&&e.push(t.cli.command);return e}async getAvailableProviders(){let e=[];for(let t of this.providers.values()){let r=!!t.cli&&await t.cli.adapter.isAvailable(),o=r&&t.cli?await t.cli.adapter.getVersion():null,s=!!t.api&&!!process.env[t.api.keyEnvVar],i=!!t.api&&s;e.push({name:t.name,displayName:t.displayName,cli:{available:r,version:o},api:{available:i,keyConfigured:s}})}return e}}var r=e.i(472129),o=e.i(902157),s=e.i(660526),i=e.i(750227),n=e.i(769310),a=e.i(53674);let l=["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],c=globalThis;if(!c.__providerRegistry){let d=new t;d.register({name:"claude",displayName:"Claude Code",agentFieldValue:"CLAUDE_CODE",cli:{command:"claude",adapter:new r.ClaudeCliAdapter},models:{cli:["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"],api:[]}}),d.register({name:"codex",displayName:"Codex CLI",agentFieldValue:"CODEX_CLI",cli:{command:"codex",adapter:new class t{buildSpawnArgs(e){let t=[];e.resumeSessionId?t.push("resume",e.resumeSessionId):e.continueLatest?t.push("resume","--last"):(t.push("--full-auto"),e.extraArgs?.length&&t.push(...e.extraArgs),e.prompt&&t.push(e.prompt));let r={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:r}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readHooks(),t=(0,a.getPackageRoot)().replace(/\\/g,"/"),r=i.join(t,"scripts","tower-session-start-hook.js").replace(/\\/g,"/"),o=i.join(t,"scripts","tower-post-tool-hook.js").replace(/\\/g,"/"),s=i.join(t,"scripts","tower-stop-hook.js").replace(/\\/g,"/"),n=!1;return n=this.upsertHook(e,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${r}"`,timeout:5,type:"command"}]})||n,n=this.upsertHook(e,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${o}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||n,(n=this.upsertHook(e,"Stop","stop-hook.js",{hooks:[{command:`node "${s}"`,timeout:5,type:"command"}]})||n)&&(this.writeHooks(e),this.ensureHooksFeatureEnabled()),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readHooks(),t=(0,a.getPackageRoot)().replace(/\\/g,"/"),r=!1;for(let[o,s,n]of[["SessionStart","session-start-hook.js","tower-session-start-hook.js"],["PostToolUse","post-tool-hook.js","tower-post-tool-hook.js"],["Stop","stop-hook.js","tower-stop-hook.js"]]){let a=this.getHookArray(e,o),l=a.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(s)));if(l<0)continue;let c=i.join(t,"scripts",n).replace(/\\/g,"/"),d=`node "${c}"`,m=a[l]?.hooks?.[0];m&&m.command!==d&&(m.command=d,e[o]=a,r=!0)}r&&(this.writeHooks(e),this.ensureHooksFeatureEnabled())}catch{}}upsertHook(e,t,r,o){let s=this.getHookArray(e,t),i=o?.hooks?.[0]?.command,n=s.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(r)));if(n>=0){if(s[n]?.hooks?.[0]?.command===i)return!1;s.splice(n,1)}return s.push(o),e[t]=s,!0}async uninstallHooks(){try{let e=this.readHooks(),t=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let r of["SessionStart","PostToolUse","Stop"]){let o=this.getHookArray(e,r);e[r]=o.filter(e=>!e.hooks?.some(e=>t.some(t=>e.command?.includes(t))))}return this.writeHooks(e),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readHooks(),t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let r=this.resolveCommand(),o=["mcp","add",e.name];if(e.env)for(let[t,r]of Object.entries(e.env))o.push("--env",`${t}=${r}`);o.push("--",e.command,...e.args);try{return await this.runCli(r,["mcp","remove",e.name],t.cwd).catch(()=>{}),await this.runCli(r,o,t.cwd),{ok:!0,method:"cli",detail:`${r} ${o.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${r} ${o.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let r=this.resolveCommand(),o=["mcp","remove",e];try{return await this.runCli(r,o,t.cwd),{ok:!0,method:"cli",detail:`${r} ${o.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${r} ${o.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let r=this.resolveCommand();try{return await this.runCli(r,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,t){let r=i.join(this.getConfigDir(),"skills",e);try{if(!o.existsSync(t))return{ok:!1,method:"symlink",detail:r,error:`Source skill dir does not exist: ${t}`};o.mkdirSync(i.dirname(r),{recursive:!0});let e=await o.promises.lstat(r).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,n.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:r,error:`Refusing to overwrite non-symlink at ${r}`};else try{let e=await o.promises.readlink(r);if(i.resolve(e)===i.resolve(t))return{ok:!0,method:"symlink",detail:`${r} → ${t} (already)`};await o.promises.unlink(r)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:r,error:`Refusing to overwrite non-symlink at ${r}`}}let s=(0,n.isWindows)()?"junction":"dir";return await o.promises.symlink(t,r,s),{ok:!0,method:"symlink",detail:`${r} → ${t}`}}catch(e){return{ok:!1,method:"symlink",detail:r,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let t=i.join(this.getConfigDir(),"skills",e);try{let e=await o.promises.lstat(t).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${t} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:t,error:`Refusing to remove non-symlink at ${t}`};return await o.promises.unlink(t),{ok:!0,method:"symlink",detail:t}}catch(e){return{ok:!1,method:"symlink",detail:t,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,t){let r=i.join(this.getConfigDir(),"skills",e);try{if(!(await o.promises.lstat(r)).isSymbolicLink())return!1;if(!t)return!0;let e=await o.promises.readlink(r),s=i.isAbsolute(e)?e:i.resolve(i.dirname(r),e);return i.resolve(s)===i.resolve(t)}catch{return!1}}async runCli(t,r,o,s=1e4){let{execFile:i}=await e.A(482848),{promisify:n}=await e.A(268548),a=n(i),{stdout:l}=await a(t,r,{cwd:o,timeout:s});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:r}=await e.A(534777),{resolveSpawnTarget:o}=await e.A(200628),s=r(t),i=await o(this.resolveCommand(),["--version"]),{stdout:n}=await s(i.command,i.args,{timeout:5e3});return n.trim()||null}catch{return null}}async getModels(){return l}getConfigDir(){return i.join(s.homedir(),".codex")}getSettingsPath(){return i.join(this.getConfigDir(),"config.toml")}getSessionsDir(){return i.join(this.getConfigDir(),"sessions")}getApiKeyInfo(){return{envVar:"OPENAI_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["exec",e]}}resolveCommand(){return process.env.CODEX_CLI_PATH?process.env.CODEX_CLI_PATH:(0,n.resolveCommandPathSync)("codex")}getHooksPath(){return i.join(this.getConfigDir(),"hooks.json")}readHooks(){try{return JSON.parse(o.readFileSync(this.getHooksPath(),"utf-8")).hooks??{}}catch{return{}}}writeHooks(e){let t=this.getConfigDir();o.existsSync(t)||o.mkdirSync(t,{recursive:!0}),o.writeFileSync(this.getHooksPath(),JSON.stringify({hooks:e},null,2),"utf-8")}ensureHooksFeatureEnabled(){let e=this.getSettingsPath(),t="";try{t=o.readFileSync(e,"utf-8")}catch{}if(/codex_hooks\s*=\s*true/.test(t))return;/\[features\]/.test(t)?t=t.replace(/\[features\]/,"[features]\ncodex_hooks = true"):t+="\n[features]\ncodex_hooks = true\n";let r=this.getConfigDir();o.existsSync(r)||o.mkdirSync(r,{recursive:!0}),o.writeFileSync(e,t,"utf-8")}getHookArray(e,t){let r=e[t];return Array.isArray(r)?r:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}},models:{cli:["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],api:[]}}),c.__providerRegistry=d}let d=c.__providerRegistry;e.s(["providerRegistry",0,d],279711)},173215,e=>{"use strict";var t=e.i(902157),r=e.i(660526),o=e.i(750227),s=e.i(279711),i=e.i(192520),n=e.i(53674);let a="tower";function l(){let e=(0,i.getTowerDir)(),t=o.join((0,r.homedir)(),".tower");if(o.resolve(e)===o.resolve(t))return"tower";let s=o.basename(e),n=s.match(/^\.?tower-(.+)$/);return n?`tower-${c(n[1])}`:`tower-${c(s)}`}function c(e){return e.replace(/[^a-z0-9_-]/gi,"-").toLowerCase().slice(0,32)}function d(){let e=(0,n.getPackageRoot)().replace(/\\/g,"/"),r={DATABASE_URL:process.env.DATABASE_URL||`file:${(0,i.getTowerDbPath)().replace(/\\/g,"/")}`,TOWER_DATA_DIR:(0,i.getTowerDir)()},o=`${e}/dist/mcp-server.cjs`,s=l();return(0,t.existsSync)(o)?{name:s,command:"node",args:[o],env:r}:{name:s,command:`${e}/node_modules/.bin/tsx`,args:[`${e}/src/mcp/index.ts`],env:r}}async function m(e,i){let l=s.providerRegistry.get(e),c=l?.cli?.adapter;if(!c||!await c.isAvailable())return{provider:e,available:!1,ok:!1};let m="claude"===e?function(e={}){let s=e.homeDir??r.homedir(),i=e.repoRoot??process.cwd(),n=[];return n.push(function(e){let r=o.join(e,".claude","settings.json");if(!t.existsSync(r))return{removed:!1,path:r};try{let e=t.readFileSync(r,"utf-8"),o=JSON.parse(e),s=o.mcpServers;if("object"!=typeof s||null===s||Array.isArray(s)||!("tower"in s))return{removed:!1,path:r};let i=s.tower;return delete s.tower,0===Object.keys(s).length?delete o.mcpServers:o.mcpServers=s,t.writeFileSync(r,JSON.stringify(o,null,2)+"\n","utf-8"),{removed:!0,path:r,removedEntry:i,reason:"wrong-file"}}catch(e){return{removed:!1,path:r,error:e instanceof Error?e.message:String(e)}}}(s)),n.push(function(e,r,s){if(!t.existsSync(e))return{removed:!1,path:e};try{let i=t.readFileSync(e,"utf-8"),n=JSON.parse(i),a=n.mcpServers;if("object"!=typeof a||null===a||Array.isArray(a))return{removed:!1,path:e};let l=a.tower;if(!l)return{removed:!1,path:e};let c=function(e,r){let s,i=e.args;if(!Array.isArray(i))return"foreign-repo";for(let e of i)if("string"==typeof e&&o.isAbsolute(e)){s=e;break}return s?t.existsSync(s)?o.resolve(s).startsWith(o.resolve(r)+o.sep)?"current-repo":"foreign-repo":"missing-path":"foreign-repo"}(l,s);if("current-repo"===c)return{removed:!1,path:e,reason:"alive-current-repo"};return delete a.tower,0===Object.keys(a).length?delete n.mcpServers:n.mcpServers=a,t.writeFileSync(e,JSON.stringify(n,null,2)+"\n","utf-8"),{removed:!0,path:e,removedEntry:l,reason:`${r}:${c}`}}catch(t){return{removed:!1,path:e,error:t instanceof Error?t.message:String(t)}}}(o.join(s,".mcp.json"),"home-mcp-json",i)),{steps:n,removedAny:n.some(e=>e.removed)}}():void 0,u=d(),h=await c.installMcp(u,{scope:"user"}),p=await c.installHooks(i),k=await c.installSkill(a,o.join((0,n.getPackageRoot)(),"skills",a));return{provider:e,available:!0,migration:m,mcp:h,hooks:p,skill:k,ok:h.ok&&p.ok&&k.ok}}e.s(["buildTowerMcpConfig",0,d,"getTowerMcpName",0,l,"installAllForProvider",0,m],173215)}];
2
2
 
3
3
  //# sourceMappingURL=src_lib_ai_0xx6y51._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[136902,599603,e=>{"use strict";class t{providers=new Map;register(e){this.providers.set(e.name,e)}get(e){return this.providers.get(e)}getAll(){return Array.from(this.providers.values())}getCliAdapter(e){return this.providers.get(e)?.cli?.adapter??null}getQueryAdapter(e,t){let o=this.providers.get(e);return o?"api"===t?o.api?.adapter??null:o.cliQuery?.adapter??null:null}getAllowedCommands(){let e=[];for(let t of this.providers.values())t.cli?.command&&e.push(t.cli.command);return e}async getAvailableProviders(){let e=[];for(let t of this.providers.values()){let o=!!t.cli&&await t.cli.adapter.isAvailable(),s=o&&t.cli?await t.cli.adapter.getVersion():null,r=!!t.api&&!!process.env[t.api.keyEnvVar],i=!!t.api&&r;e.push({name:t.name,displayName:t.displayName,cli:{available:o,version:s},api:{available:i,keyConfigured:r}})}return e}}var o=e.i(902157),s=e.i(660526),r=e.i(750227),i=e.i(603484);function n(){return process.env.TOWER_PACKAGE_ROOT||process.cwd()}e.s(["getPackageRoot",0,n],599603);let a=["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"],l=["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],c=globalThis;if(!c.__providerRegistry){let m=new t;m.register({name:"claude",displayName:"Claude Code",agentFieldValue:"CLAUDE_CODE",cli:{command:"claude",adapter:new class t{buildSpawnArgs(e){let t=["--dangerously-skip-permissions"];e.extraArgs?.length&&t.push(...e.extraArgs),e.resumeSessionId?t.push("--resume",e.resumeSessionId):e.continueLatest?t.push("--continue"):e.prompt&&t.push(e.prompt);let o={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:o}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readSettings(),t=e.hooks??{},o=n().replace(/\\/g,"/"),s=r.join(o,"scripts","session-start-hook.js").replace(/\\/g,"/"),i=r.join(o,"scripts","post-tool-hook.js").replace(/\\/g,"/"),a=r.join(o,"scripts","stop-hook.js").replace(/\\/g,"/"),l=!1;return l=this.upsertHook(t,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${s}"`,timeout:5,type:"command"}]})||l,l=this.upsertHook(t,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${i}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||l,(l=this.upsertHook(t,"Stop","stop-hook.js",{hooks:[{command:`node "${a}"`,timeout:5,type:"command"}]})||l)&&(e.hooks=t,this.writeSettings(e)),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readSettings(),t=e.hooks??{},o=n().replace(/\\/g,"/"),s=!1;for(let[e,i]of[["SessionStart","session-start-hook.js"],["PostToolUse","post-tool-hook.js"],["Stop","stop-hook.js"]]){let n=this.getHookArray(t,e),a=n.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(i)));if(a<0)continue;let l=r.join(o,"scripts",i).replace(/\\/g,"/"),c=`node "${l}"`,m=n[a]?.hooks?.[0];m&&m.command!==c&&(m.command=c,t[e]=n,s=!0)}s&&(e.hooks=t,this.writeSettings(e))}catch{}}upsertHook(e,t,o,s){let r=this.getHookArray(e,t),i=s?.hooks?.[0]?.command,n=r.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(o)));if(n>=0){if(r[n]?.hooks?.[0]?.command===i)return!1;r.splice(n,1)}return r.push(s),e[t]=r,!0}async uninstallHooks(){try{let e=this.readSettings(),t=e.hooks??{},o=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let e of["SessionStart","PostToolUse","Stop"]){let s=this.getHookArray(t,e);t[e]=s.filter(e=>!e.hooks?.some(e=>o.some(t=>e.command?.includes(t))))}return e.hooks=t,this.writeSettings(e),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readSettings().hooks??{},t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let o=t.scope??"user",s={command:e.command,args:e.args};e.env&&Object.keys(e.env).length>0&&(s.env=e.env);let r=this.resolveCommand(),i=["mcp","add-json","-s",o,e.name,JSON.stringify(s)];try{return await this.runCli(r,["mcp","remove","-s",o,e.name],t.cwd).catch(()=>{}),await this.runCli(r,i,t.cwd),{ok:!0,method:"cli",detail:`${r} ${i.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${r} ${i.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let o=t.scope??"user",s=this.resolveCommand(),r=["mcp","remove","-s",o,e];try{return await this.runCli(s,r,t.cwd),{ok:!0,method:"cli",detail:`${s} ${r.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${s} ${r.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let o=this.resolveCommand();try{return await this.runCli(o,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,t){let s=r.join(this.getConfigDir(),"skills",e);try{if(!o.existsSync(t))return{ok:!1,method:"symlink",detail:s,error:`Source skill dir does not exist: ${t}`};o.mkdirSync(r.dirname(s),{recursive:!0});let e=await o.promises.lstat(s).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,i.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`};else try{let e=await o.promises.readlink(s);if(r.resolve(e)===r.resolve(t))return{ok:!0,method:"symlink",detail:`${s} → ${t} (already)`};await o.promises.unlink(s)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`}}let n=(0,i.isWindows)()?"junction":"dir";return await o.promises.symlink(t,s,n),{ok:!0,method:"symlink",detail:`${s} → ${t}`}}catch(e){return{ok:!1,method:"symlink",detail:s,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let t=r.join(this.getConfigDir(),"skills",e);try{let e=await o.promises.lstat(t).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${t} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:t,error:`Refusing to remove non-symlink at ${t}`};return await o.promises.unlink(t),{ok:!0,method:"symlink",detail:t}}catch(e){return{ok:!1,method:"symlink",detail:t,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,t){let s=r.join(this.getConfigDir(),"skills",e);try{if(!(await o.promises.lstat(s)).isSymbolicLink())return!1;if(!t)return!0;let e=await o.promises.readlink(s),i=r.isAbsolute(e)?e:r.resolve(r.dirname(s),e);return r.resolve(i)===r.resolve(t)}catch{return!1}}async runCli(t,o,s,r=1e4){let{execFile:i}=await e.A(482848),{promisify:n}=await e.A(268548),a=n(i),{stdout:l}=await a(t,o,{cwd:s,timeout:r});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:o}=await e.A(534777),{resolveSpawnTarget:s}=await e.A(998127),r=o(t),i=await s(this.resolveCommand(),["--version"]),{stdout:n}=await r(i.command,i.args,{timeout:5e3});return n.trim()||null}catch{return null}}async getModels(){return a}getConfigDir(){return r.join(s.homedir(),".claude")}getSettingsPath(){return r.join(this.getConfigDir(),"settings.json")}getSessionsDir(){return r.join(this.getConfigDir(),"projects")}getApiKeyInfo(){return{envVar:"ANTHROPIC_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["--print",e,"--output-format","stream-json","--verbose"]}}resolveCommand(){if(process.env.CLAUDE_CODE_PATH)return process.env.CLAUDE_CODE_PATH;if((0,i.isWindows)()){let e=(0,i.resolveCommandPathSync)("claude-code");if("claude-code"!==e)return e}return(0,i.resolveCommandPathSync)("claude")}readSettings(){try{return JSON.parse(o.readFileSync(this.getSettingsPath(),"utf-8"))}catch{return{}}}writeSettings(e){let t=this.getConfigDir();o.existsSync(t)||o.mkdirSync(t,{recursive:!0}),o.writeFileSync(this.getSettingsPath(),JSON.stringify(e,null,2),"utf-8")}getHookArray(e,t){let o=e[t];return Array.isArray(o)?o:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}},models:{cli:["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"],api:[]}}),m.register({name:"codex",displayName:"Codex CLI",agentFieldValue:"CODEX_CLI",cli:{command:"codex",adapter:new class t{buildSpawnArgs(e){let t=[];e.resumeSessionId?t.push("resume",e.resumeSessionId):e.continueLatest?t.push("resume","--last"):(t.push("--full-auto"),e.extraArgs?.length&&t.push(...e.extraArgs),e.prompt&&t.push(e.prompt));let o={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:o}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readHooks(),t=n().replace(/\\/g,"/"),o=r.join(t,"scripts","session-start-hook.js").replace(/\\/g,"/"),s=r.join(t,"scripts","post-tool-hook.js").replace(/\\/g,"/"),i=r.join(t,"scripts","stop-hook.js").replace(/\\/g,"/"),a=!1;return a=this.upsertHook(e,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${o}"`,timeout:5,type:"command"}]})||a,a=this.upsertHook(e,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${s}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||a,(a=this.upsertHook(e,"Stop","stop-hook.js",{hooks:[{command:`node "${i}"`,timeout:5,type:"command"}]})||a)&&(this.writeHooks(e),this.ensureHooksFeatureEnabled()),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readHooks(),t=n().replace(/\\/g,"/"),o=!1;for(let[s,i]of[["SessionStart","session-start-hook.js"],["PostToolUse","post-tool-hook.js"],["Stop","stop-hook.js"]]){let n=this.getHookArray(e,s),a=n.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(i)));if(a<0)continue;let l=r.join(t,"scripts",i).replace(/\\/g,"/"),c=`node "${l}"`,m=n[a]?.hooks?.[0];m&&m.command!==c&&(m.command=c,e[s]=n,o=!0)}o&&(this.writeHooks(e),this.ensureHooksFeatureEnabled())}catch{}}upsertHook(e,t,o,s){let r=this.getHookArray(e,t),i=s?.hooks?.[0]?.command,n=r.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(o)));if(n>=0){if(r[n]?.hooks?.[0]?.command===i)return!1;r.splice(n,1)}return r.push(s),e[t]=r,!0}async uninstallHooks(){try{let e=this.readHooks(),t=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let o of["SessionStart","PostToolUse","Stop"]){let s=this.getHookArray(e,o);e[o]=s.filter(e=>!e.hooks?.some(e=>t.some(t=>e.command?.includes(t))))}return this.writeHooks(e),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readHooks(),t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let o=this.resolveCommand(),s=["mcp","add",e.name];if(e.env)for(let[t,o]of Object.entries(e.env))s.push("--env",`${t}=${o}`);s.push("--",e.command,...e.args);try{return await this.runCli(o,["mcp","remove",e.name],t.cwd).catch(()=>{}),await this.runCli(o,s,t.cwd),{ok:!0,method:"cli",detail:`${o} ${s.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${o} ${s.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let o=this.resolveCommand(),s=["mcp","remove",e];try{return await this.runCli(o,s,t.cwd),{ok:!0,method:"cli",detail:`${o} ${s.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${o} ${s.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let o=this.resolveCommand();try{return await this.runCli(o,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,t){let s=r.join(this.getConfigDir(),"skills",e);try{if(!o.existsSync(t))return{ok:!1,method:"symlink",detail:s,error:`Source skill dir does not exist: ${t}`};o.mkdirSync(r.dirname(s),{recursive:!0});let e=await o.promises.lstat(s).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,i.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`};else try{let e=await o.promises.readlink(s);if(r.resolve(e)===r.resolve(t))return{ok:!0,method:"symlink",detail:`${s} → ${t} (already)`};await o.promises.unlink(s)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`}}let n=(0,i.isWindows)()?"junction":"dir";return await o.promises.symlink(t,s,n),{ok:!0,method:"symlink",detail:`${s} → ${t}`}}catch(e){return{ok:!1,method:"symlink",detail:s,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let t=r.join(this.getConfigDir(),"skills",e);try{let e=await o.promises.lstat(t).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${t} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:t,error:`Refusing to remove non-symlink at ${t}`};return await o.promises.unlink(t),{ok:!0,method:"symlink",detail:t}}catch(e){return{ok:!1,method:"symlink",detail:t,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,t){let s=r.join(this.getConfigDir(),"skills",e);try{if(!(await o.promises.lstat(s)).isSymbolicLink())return!1;if(!t)return!0;let e=await o.promises.readlink(s),i=r.isAbsolute(e)?e:r.resolve(r.dirname(s),e);return r.resolve(i)===r.resolve(t)}catch{return!1}}async runCli(t,o,s,r=1e4){let{execFile:i}=await e.A(482848),{promisify:n}=await e.A(268548),a=n(i),{stdout:l}=await a(t,o,{cwd:s,timeout:r});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:o}=await e.A(534777),{resolveSpawnTarget:s}=await e.A(998127),r=o(t),i=await s(this.resolveCommand(),["--version"]),{stdout:n}=await r(i.command,i.args,{timeout:5e3});return n.trim()||null}catch{return null}}async getModels(){return l}getConfigDir(){return r.join(s.homedir(),".codex")}getSettingsPath(){return r.join(this.getConfigDir(),"config.toml")}getSessionsDir(){return r.join(this.getConfigDir(),"sessions")}getApiKeyInfo(){return{envVar:"OPENAI_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["exec",e]}}resolveCommand(){return process.env.CODEX_CLI_PATH?process.env.CODEX_CLI_PATH:(0,i.resolveCommandPathSync)("codex")}getHooksPath(){return r.join(this.getConfigDir(),"hooks.json")}readHooks(){try{return JSON.parse(o.readFileSync(this.getHooksPath(),"utf-8")).hooks??{}}catch{return{}}}writeHooks(e){let t=this.getConfigDir();o.existsSync(t)||o.mkdirSync(t,{recursive:!0}),o.writeFileSync(this.getHooksPath(),JSON.stringify({hooks:e},null,2),"utf-8")}ensureHooksFeatureEnabled(){let e=this.getSettingsPath(),t="";try{t=o.readFileSync(e,"utf-8")}catch{}if(/codex_hooks\s*=\s*true/.test(t))return;/\[features\]/.test(t)?t=t.replace(/\[features\]/,"[features]\ncodex_hooks = true"):t+="\n[features]\ncodex_hooks = true\n";let s=this.getConfigDir();o.existsSync(s)||o.mkdirSync(s,{recursive:!0}),o.writeFileSync(e,t,"utf-8")}getHookArray(e,t){let o=e[t];return Array.isArray(o)?o:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}},models:{cli:["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],api:[]}}),c.__providerRegistry=m}let m=c.__providerRegistry;e.s(["providerRegistry",0,m],136902)}];
1
+ module.exports=[136902,599603,e=>{"use strict";class t{providers=new Map;register(e){this.providers.set(e.name,e)}get(e){return this.providers.get(e)}getAll(){return Array.from(this.providers.values())}getCliAdapter(e){return this.providers.get(e)?.cli?.adapter??null}getQueryAdapter(e,t){let o=this.providers.get(e);return o?"api"===t?o.api?.adapter??null:o.cliQuery?.adapter??null:null}getAllowedCommands(){let e=[];for(let t of this.providers.values())t.cli?.command&&e.push(t.cli.command);return e}async getAvailableProviders(){let e=[];for(let t of this.providers.values()){let o=!!t.cli&&await t.cli.adapter.isAvailable(),s=o&&t.cli?await t.cli.adapter.getVersion():null,r=!!t.api&&!!process.env[t.api.keyEnvVar],i=!!t.api&&r;e.push({name:t.name,displayName:t.displayName,cli:{available:o,version:s},api:{available:i,keyConfigured:r}})}return e}}var o=e.i(902157),s=e.i(660526),r=e.i(750227),i=e.i(603484);function n(){return process.env.TOWER_PACKAGE_ROOT||process.cwd()}e.s(["getPackageRoot",0,n],599603);let a=["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"],l=["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],c=globalThis;if(!c.__providerRegistry){let m=new t;m.register({name:"claude",displayName:"Claude Code",agentFieldValue:"CLAUDE_CODE",cli:{command:"claude",adapter:new class t{buildSpawnArgs(e){let t=["--dangerously-skip-permissions"];e.extraArgs?.length&&t.push(...e.extraArgs),e.resumeSessionId?t.push("--resume",e.resumeSessionId):e.continueLatest?t.push("--continue"):e.prompt&&t.push(e.prompt);let o={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:o}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readSettings(),t=e.hooks??{},o=n().replace(/\\/g,"/"),s=r.join(o,"scripts","tower-session-start-hook.js").replace(/\\/g,"/"),i=r.join(o,"scripts","tower-post-tool-hook.js").replace(/\\/g,"/"),a=r.join(o,"scripts","tower-stop-hook.js").replace(/\\/g,"/"),l=!1;return l=this.upsertHook(t,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${s}"`,timeout:5,type:"command"}]})||l,l=this.upsertHook(t,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${i}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||l,(l=this.upsertHook(t,"Stop","stop-hook.js",{hooks:[{command:`node "${a}"`,timeout:5,type:"command"}]})||l)&&(e.hooks=t,this.writeSettings(e)),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readSettings(),t=e.hooks??{},o=n().replace(/\\/g,"/"),s=!1;for(let[e,i,n]of[["SessionStart","session-start-hook.js","tower-session-start-hook.js"],["PostToolUse","post-tool-hook.js","tower-post-tool-hook.js"],["Stop","stop-hook.js","tower-stop-hook.js"]]){let a=this.getHookArray(t,e),l=a.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(i)));if(l<0)continue;let c=r.join(o,"scripts",n).replace(/\\/g,"/"),m=`node "${c}"`,d=a[l]?.hooks?.[0];d&&d.command!==m&&(d.command=m,t[e]=a,s=!0)}s&&(e.hooks=t,this.writeSettings(e))}catch{}}upsertHook(e,t,o,s){let r=this.getHookArray(e,t),i=s?.hooks?.[0]?.command,n=r.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(o)));if(n>=0){if(r[n]?.hooks?.[0]?.command===i)return!1;r.splice(n,1)}return r.push(s),e[t]=r,!0}async uninstallHooks(){try{let e=this.readSettings(),t=e.hooks??{},o=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let e of["SessionStart","PostToolUse","Stop"]){let s=this.getHookArray(t,e);t[e]=s.filter(e=>!e.hooks?.some(e=>o.some(t=>e.command?.includes(t))))}return e.hooks=t,this.writeSettings(e),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(e){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readSettings().hooks??{},t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let o=t.scope??"user",s={command:e.command,args:e.args};e.env&&Object.keys(e.env).length>0&&(s.env=e.env);let r=this.resolveCommand(),i=["mcp","add-json","-s",o,e.name,JSON.stringify(s)];try{return await this.runCli(r,["mcp","remove","-s",o,e.name],t.cwd).catch(()=>{}),await this.runCli(r,i,t.cwd),{ok:!0,method:"cli",detail:`${r} ${i.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${r} ${i.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let o=t.scope??"user",s=this.resolveCommand(),r=["mcp","remove","-s",o,e];try{return await this.runCli(s,r,t.cwd),{ok:!0,method:"cli",detail:`${s} ${r.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${s} ${r.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let o=this.resolveCommand();try{return await this.runCli(o,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,t){let s=r.join(this.getConfigDir(),"skills",e);try{if(!o.existsSync(t))return{ok:!1,method:"symlink",detail:s,error:`Source skill dir does not exist: ${t}`};o.mkdirSync(r.dirname(s),{recursive:!0});let e=await o.promises.lstat(s).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,i.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`};else try{let e=await o.promises.readlink(s);if(r.resolve(e)===r.resolve(t))return{ok:!0,method:"symlink",detail:`${s} → ${t} (already)`};await o.promises.unlink(s)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`}}let n=(0,i.isWindows)()?"junction":"dir";return await o.promises.symlink(t,s,n),{ok:!0,method:"symlink",detail:`${s} → ${t}`}}catch(e){return{ok:!1,method:"symlink",detail:s,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let t=r.join(this.getConfigDir(),"skills",e);try{let e=await o.promises.lstat(t).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${t} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:t,error:`Refusing to remove non-symlink at ${t}`};return await o.promises.unlink(t),{ok:!0,method:"symlink",detail:t}}catch(e){return{ok:!1,method:"symlink",detail:t,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,t){let s=r.join(this.getConfigDir(),"skills",e);try{if(!(await o.promises.lstat(s)).isSymbolicLink())return!1;if(!t)return!0;let e=await o.promises.readlink(s),i=r.isAbsolute(e)?e:r.resolve(r.dirname(s),e);return r.resolve(i)===r.resolve(t)}catch{return!1}}async runCli(t,o,s,r=1e4){let{execFile:i}=await e.A(482848),{promisify:n}=await e.A(268548),a=n(i),{stdout:l}=await a(t,o,{cwd:s,timeout:r});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:o}=await e.A(534777),{resolveSpawnTarget:s}=await e.A(998127),r=o(t),i=await s(this.resolveCommand(),["--version"]),{stdout:n}=await r(i.command,i.args,{timeout:5e3});return n.trim()||null}catch{return null}}async getModels(){return a}getConfigDir(){return r.join(s.homedir(),".claude")}getSettingsPath(){return r.join(this.getConfigDir(),"settings.json")}getSessionsDir(){return r.join(this.getConfigDir(),"projects")}getApiKeyInfo(){return{envVar:"ANTHROPIC_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["--print",e,"--output-format","stream-json","--verbose"]}}resolveCommand(){if(process.env.CLAUDE_CODE_PATH)return process.env.CLAUDE_CODE_PATH;if((0,i.isWindows)()){let e=(0,i.resolveCommandPathSync)("claude-code");if("claude-code"!==e)return e}return(0,i.resolveCommandPathSync)("claude")}readSettings(){try{return JSON.parse(o.readFileSync(this.getSettingsPath(),"utf-8"))}catch{return{}}}writeSettings(e){let t=this.getConfigDir();o.existsSync(t)||o.mkdirSync(t,{recursive:!0}),o.writeFileSync(this.getSettingsPath(),JSON.stringify(e,null,2),"utf-8")}getHookArray(e,t){let o=e[t];return Array.isArray(o)?o:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}},models:{cli:["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"],api:[]}}),m.register({name:"codex",displayName:"Codex CLI",agentFieldValue:"CODEX_CLI",cli:{command:"codex",adapter:new class t{buildSpawnArgs(e){let t=[];e.resumeSessionId?t.push("resume",e.resumeSessionId):e.continueLatest?t.push("resume","--last"):(t.push("--full-auto"),e.extraArgs?.length&&t.push(...e.extraArgs),e.prompt&&t.push(e.prompt));let o={...e.envOverrides??{}};return{command:this.resolveCommand(),args:t,env:o}}buildEnvOverrides(e){let t={TOWER_TASK_ID:e.taskId,TOWER_TASK_TITLE:e.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:e.apiUrl};return e.callbackUrl&&(t.CALLBACK_URL=e.callbackUrl),t}async installHooks(e){try{let e=this.readHooks(),t=n().replace(/\\/g,"/"),o=r.join(t,"scripts","tower-session-start-hook.js").replace(/\\/g,"/"),s=r.join(t,"scripts","tower-post-tool-hook.js").replace(/\\/g,"/"),i=r.join(t,"scripts","tower-stop-hook.js").replace(/\\/g,"/"),a=!1;return a=this.upsertHook(e,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${o}"`,timeout:5,type:"command"}]})||a,a=this.upsertHook(e,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${s}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||a,(a=this.upsertHook(e,"Stop","stop-hook.js",{hooks:[{command:`node "${i}"`,timeout:5,type:"command"}]})||a)&&(this.writeHooks(e),this.ensureHooksFeatureEnabled()),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async repairHookPaths(){try{let e=this.readHooks(),t=n().replace(/\\/g,"/"),o=!1;for(let[s,i,n]of[["SessionStart","session-start-hook.js","tower-session-start-hook.js"],["PostToolUse","post-tool-hook.js","tower-post-tool-hook.js"],["Stop","stop-hook.js","tower-stop-hook.js"]]){let a=this.getHookArray(e,s),l=a.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(i)));if(l<0)continue;let c=r.join(t,"scripts",n).replace(/\\/g,"/"),m=`node "${c}"`,d=a[l]?.hooks?.[0];d&&d.command!==m&&(d.command=m,e[s]=a,o=!0)}o&&(this.writeHooks(e),this.ensureHooksFeatureEnabled())}catch{}}upsertHook(e,t,o,s){let r=this.getHookArray(e,t),i=s?.hooks?.[0]?.command,n=r.findIndex(e=>e?.hooks?.some?.(e=>e.command?.includes(o)));if(n>=0){if(r[n]?.hooks?.[0]?.command===i)return!1;r.splice(n,1)}return r.push(s),e[t]=r,!0}async uninstallHooks(){try{let e=this.readHooks(),t=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let o of["SessionStart","PostToolUse","Stop"]){let s=this.getHookArray(e,o);e[o]=s.filter(e=>!e.hooks?.some(e=>t.some(t=>e.command?.includes(t))))}return this.writeHooks(e),{ok:!0,method:"file",detail:this.getHooksPath()}}catch(e){return{ok:!1,method:"file",detail:this.getHooksPath(),error:e instanceof Error?e.message:String(e)}}}async isHooksInstalled(){let e=this.readHooks(),t=this.getHookArray(e,"PostToolUse");return this.hasHook(t,"post-tool-hook.js")}async installMcp(e,t={}){let o=this.resolveCommand(),s=["mcp","add",e.name];if(e.env)for(let[t,o]of Object.entries(e.env))s.push("--env",`${t}=${o}`);s.push("--",e.command,...e.args);try{return await this.runCli(o,["mcp","remove",e.name],t.cwd).catch(()=>{}),await this.runCli(o,s,t.cwd),{ok:!0,method:"cli",detail:`${o} ${s.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${o} ${s.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async uninstallMcp(e,t={}){let o=this.resolveCommand(),s=["mcp","remove",e];try{return await this.runCli(o,s,t.cwd),{ok:!0,method:"cli",detail:`${o} ${s.join(" ")}`}}catch(e){return{ok:!1,method:"cli",detail:`${o} ${s.join(" ")}`,error:e instanceof Error?e.message:String(e)}}}async isMcpInstalled(e,t={}){let o=this.resolveCommand();try{return await this.runCli(o,["mcp","get",e],t.cwd,5e3),!0}catch{return!1}}async installSkill(e,t){let s=r.join(this.getConfigDir(),"skills",e);try{if(!o.existsSync(t))return{ok:!1,method:"symlink",detail:s,error:`Source skill dir does not exist: ${t}`};o.mkdirSync(r.dirname(s),{recursive:!0});let e=await o.promises.lstat(s).catch(()=>null);if(e)if(!(e.isSymbolicLink()||(0,i.isWindows)()&&e.isDirectory()))return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`};else try{let e=await o.promises.readlink(s);if(r.resolve(e)===r.resolve(t))return{ok:!0,method:"symlink",detail:`${s} → ${t} (already)`};await o.promises.unlink(s)}catch{if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:s,error:`Refusing to overwrite non-symlink at ${s}`}}let n=(0,i.isWindows)()?"junction":"dir";return await o.promises.symlink(t,s,n),{ok:!0,method:"symlink",detail:`${s} → ${t}`}}catch(e){return{ok:!1,method:"symlink",detail:s,error:e instanceof Error?e.message:String(e)}}}async uninstallSkill(e){let t=r.join(this.getConfigDir(),"skills",e);try{let e=await o.promises.lstat(t).catch(()=>null);if(!e)return{ok:!0,method:"symlink",detail:`${t} (already absent)`};if(!e.isSymbolicLink())return{ok:!1,method:"symlink",detail:t,error:`Refusing to remove non-symlink at ${t}`};return await o.promises.unlink(t),{ok:!0,method:"symlink",detail:t}}catch(e){return{ok:!1,method:"symlink",detail:t,error:e instanceof Error?e.message:String(e)}}}async isSkillInstalled(e,t){let s=r.join(this.getConfigDir(),"skills",e);try{if(!(await o.promises.lstat(s)).isSymbolicLink())return!1;if(!t)return!0;let e=await o.promises.readlink(s),i=r.isAbsolute(e)?e:r.resolve(r.dirname(s),e);return r.resolve(i)===r.resolve(t)}catch{return!1}}async runCli(t,o,s,r=1e4){let{execFile:i}=await e.A(482848),{promisify:n}=await e.A(268548),a=n(i),{stdout:l}=await a(t,o,{cwd:s,timeout:r});return l}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:t}=await e.A(144264),{promisify:o}=await e.A(534777),{resolveSpawnTarget:s}=await e.A(998127),r=o(t),i=await s(this.resolveCommand(),["--version"]),{stdout:n}=await r(i.command,i.args,{timeout:5e3});return n.trim()||null}catch{return null}}async getModels(){return l}getConfigDir(){return r.join(s.homedir(),".codex")}getSettingsPath(){return r.join(this.getConfigDir(),"config.toml")}getSessionsDir(){return r.join(this.getConfigDir(),"sessions")}getApiKeyInfo(){return{envVar:"OPENAI_API_KEY",required:!1}}buildHelloProbeArgs(e){return{command:this.resolveCommand(),args:["exec",e]}}resolveCommand(){return process.env.CODEX_CLI_PATH?process.env.CODEX_CLI_PATH:(0,i.resolveCommandPathSync)("codex")}getHooksPath(){return r.join(this.getConfigDir(),"hooks.json")}readHooks(){try{return JSON.parse(o.readFileSync(this.getHooksPath(),"utf-8")).hooks??{}}catch{return{}}}writeHooks(e){let t=this.getConfigDir();o.existsSync(t)||o.mkdirSync(t,{recursive:!0}),o.writeFileSync(this.getHooksPath(),JSON.stringify({hooks:e},null,2),"utf-8")}ensureHooksFeatureEnabled(){let e=this.getSettingsPath(),t="";try{t=o.readFileSync(e,"utf-8")}catch{}if(/codex_hooks\s*=\s*true/.test(t))return;/\[features\]/.test(t)?t=t.replace(/\[features\]/,"[features]\ncodex_hooks = true"):t+="\n[features]\ncodex_hooks = true\n";let s=this.getConfigDir();o.existsSync(s)||o.mkdirSync(s,{recursive:!0}),o.writeFileSync(e,t,"utf-8")}getHookArray(e,t){let o=e[t];return Array.isArray(o)?o:[]}hasHook(e,t){return e.some(e=>e.hooks?.some(e=>e.command?.includes(t)))}}},models:{cli:["o4-mini","o3","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","codex-mini-latest"],api:[]}}),c.__providerRegistry=m}let m=c.__providerRegistry;e.s(["providerRegistry",0,m],136902)}];
2
2
 
3
3
  //# sourceMappingURL=src_lib_ai_providers_index_ts_0.y.3vp._.js.map