@bastani/atomic 0.10.4-alpha.2 → 0.10.5-alpha.1

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 (614) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/dist/_shared/chunk-CDOYTDYM.js +4 -0
  3. package/dist/_shared/chunk-CDOYTDYM.js.map +1 -0
  4. package/dist/_shared/compile-cache-warmup-host-RU5L7I7A.js +1 -1
  5. package/dist/_shared/dist-KOELCESV.js +48 -3
  6. package/dist/_shared/fork-row-index-UAUAQRD5.js +47 -2
  7. package/dist/_shared/http-YFAPTIZD.js +16 -4
  8. package/dist/_shared/http-YFAPTIZD.js.map +1 -1
  9. package/dist/_shared/lib-4PES5P4V.js +59 -14
  10. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +1706 -258
  11. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
  12. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +317 -64
  13. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
  14. package/dist/_shared/{mode-shared-HP7GUA7J.js → mode-shared-2QJSCUM6.js} +432 -81
  15. package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -0
  16. package/dist/_shared/p0-cli-BB45ZQY6.js +3482 -0
  17. package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -0
  18. package/dist/_shared/p0-cli-GUFK7TPN.js +2 -2838
  19. package/dist/_shared/p0-cli-GUFK7TPN.js.map +1 -1
  20. package/dist/_shared/{p1a-prewarm-YK3KDTLN.js → p1a-prewarm-UQY3X2UK.js} +270 -73
  21. package/dist/_shared/p1a-prewarm-UQY3X2UK.js.map +1 -0
  22. package/dist/_shared/{p1b-elig-PXQA2FYP.js → p1b-elig-ENCUPKKJ.js} +190 -121
  23. package/dist/_shared/p1b-elig-ENCUPKKJ.js.map +1 -0
  24. package/dist/_shared/p2-common-YLSYXMDQ.js +1 -3
  25. package/dist/_shared/p2-common-YLSYXMDQ.js.map +1 -1
  26. package/dist/_shared/p2-shell-TJBYQMCJ.js +1 -1
  27. package/dist/_shared/p2-shell-main-B2WIALFD.js +500 -127
  28. package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
  29. package/dist/_shared/runtime-O4KCSG4C.js +4 -4
  30. package/dist/_shared/sdk-WQIOHVKO.js +56 -11
  31. package/dist/_shared/session-data-AHTU7IS6.js +48 -3
  32. package/dist/_shared/session-manager-list-2BLEEZVG.js +2 -2
  33. package/dist/_shared/settings-startup-65YEWRV2.js.map +1 -1
  34. package/dist/_shared/sql-session-store-5FD3WBMZ.js +57 -12
  35. package/dist/_shared/{startup-0-0-X4NF3GKM.js → startup-0-0-TYUFUOJZ.js} +528 -321
  36. package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +1 -0
  37. package/dist/_shared/{startup-0-1-7QTG6VJZ.js → startup-0-1-D4LGGINF.js} +284 -81
  38. package/dist/_shared/startup-0-1-D4LGGINF.js.map +1 -0
  39. package/dist/_shared/{startup-0-2-KFDYPDJK.js → startup-0-2-SZGQIWHI.js} +483 -154
  40. package/dist/_shared/startup-0-2-SZGQIWHI.js.map +1 -0
  41. package/dist/_shared/startup-0-3-T4DVFYWX.js +340 -110
  42. package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
  43. package/dist/_shared/startup-0-4-HN5EB4K7.js +261 -59
  44. package/dist/_shared/startup-0-4-HN5EB4K7.js.map +1 -1
  45. package/dist/_shared/startup-0-5-OHJNE6JH.js +421 -148
  46. package/dist/_shared/startup-0-5-OHJNE6JH.js.map +1 -1
  47. package/dist/_shared/startup-10-0-TDQNBDDL.js +62 -11
  48. package/dist/_shared/startup-10-0-TDQNBDDL.js.map +1 -1
  49. package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
  50. package/dist/_shared/startup-14-0-MLX36RBG.js +12 -11
  51. package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
  52. package/dist/_shared/startup-15-0-YUKGAC63.js +53 -158
  53. package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
  54. package/dist/_shared/startup-15-1-4S7FLMNG.js +231 -46
  55. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  56. package/dist/_shared/startup-8-0-34CBHPZH.js +115 -35
  57. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  58. package/dist/_shared/{startup-8-1-KQJBDKRU.js → startup-8-1-SJW2GMAM.js} +203 -62
  59. package/dist/_shared/startup-8-1-SJW2GMAM.js.map +1 -0
  60. package/dist/_shared/storage-command-7MGXLJGZ.js +55 -10
  61. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +47 -2
  62. package/dist/_shared/tree-outline-MUEPK5B7.js +48 -3
  63. package/dist/builtin/intercom/CHANGELOG.md +59 -0
  64. package/dist/builtin/intercom/README.md +0 -1
  65. package/dist/builtin/intercom/broker/broker-instance.ts +13 -57
  66. package/dist/builtin/intercom/broker/broker-process.ts +30 -10
  67. package/dist/builtin/intercom/broker/broker-routing.ts +12 -2
  68. package/dist/builtin/intercom/broker/broker.bundle.mjs +2557 -498
  69. package/dist/builtin/intercom/broker/broker.ts +164 -55
  70. package/dist/builtin/intercom/broker/client.ts +36 -16
  71. package/dist/builtin/intercom/broker/control.ts +83 -20
  72. package/dist/builtin/intercom/broker/durable-ended-queue.ts +65 -19
  73. package/dist/builtin/intercom/broker/host-command-environment.ts +7 -2
  74. package/dist/builtin/intercom/broker/multinode-router.ts +1675 -387
  75. package/dist/builtin/intercom/broker/multinode-state-store.ts +10 -0
  76. package/dist/builtin/intercom/broker/paths.ts +68 -6
  77. package/dist/builtin/intercom/broker/pending-send-registry.ts +5 -0
  78. package/dist/builtin/intercom/broker/registration-bounds.ts +38 -0
  79. package/dist/builtin/intercom/broker/retiring-broker-check.ts +178 -0
  80. package/dist/builtin/intercom/broker/return-paths.ts +268 -7
  81. package/dist/builtin/intercom/broker/send-handler.ts +253 -28
  82. package/dist/builtin/intercom/broker/send-order-gate.ts +410 -0
  83. package/dist/builtin/intercom/broker/spawn.ts +950 -202
  84. package/dist/builtin/intercom/broker/sql-lease-store.ts +37 -0
  85. package/dist/builtin/intercom/broker/sql-outbox-store.ts +7 -0
  86. package/dist/builtin/intercom/broker/windows-cwd.ts +546 -0
  87. package/dist/builtin/intercom/index.bundle.mjs +3506 -2328
  88. package/dist/builtin/intercom/package.json +1 -1
  89. package/dist/builtin/intercom/retry-policy.ts +4 -0
  90. package/dist/builtin/intercom/types.ts +2 -0
  91. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  92. package/dist/builtin/mcp/package.json +1 -1
  93. package/dist/builtin/subagents/CHANGELOG.md +46 -0
  94. package/dist/builtin/subagents/package.json +1 -1
  95. package/dist/builtin/subagents/src/extension/index.bundle.mjs +336 -86
  96. package/dist/builtin/web-access/CHANGELOG.md +12 -0
  97. package/dist/builtin/web-access/index.bundle.mjs +23 -38
  98. package/dist/builtin/web-access/package.json +1 -1
  99. package/dist/bun/cli.js +1 -1
  100. package/dist/bun/cli.js.map +1 -1
  101. package/dist/bun/internal-intercom-broker.js +119 -4
  102. package/dist/bun/internal-intercom-broker.js.map +1 -1
  103. package/dist/bun/register-theme-validator.js +6 -0
  104. package/dist/bun/register-theme-validator.js.map +1 -0
  105. package/dist/cli/args.js +2 -2
  106. package/dist/cli/auth-cli.code.js +1102 -0
  107. package/dist/cli/auth-cli.code.js.map +1 -0
  108. package/dist/cli/auth-cli.impl.js +36 -0
  109. package/dist/cli/auth-cli.impl.js.map +1 -0
  110. package/dist/cli/auth-cli.js +30 -1096
  111. package/dist/cli/auth-cli.js.map +1 -1
  112. package/dist/cli/blueprint-command.code.js +906 -0
  113. package/dist/cli/blueprint-command.code.js.map +1 -0
  114. package/dist/cli/blueprint-command.impl.js +36 -0
  115. package/dist/cli/blueprint-command.impl.js.map +1 -0
  116. package/dist/cli/blueprint-command.js +30 -900
  117. package/dist/cli/blueprint-command.js.map +1 -1
  118. package/dist/cli/intercom-command.code.js +153 -0
  119. package/dist/cli/intercom-command.code.js.map +1 -0
  120. package/dist/cli/intercom-command.impl.js +36 -0
  121. package/dist/cli/intercom-command.impl.js.map +1 -0
  122. package/dist/cli/intercom-command.js +33 -105
  123. package/dist/cli/intercom-command.js.map +1 -1
  124. package/dist/cli/list-models.code.js +60 -0
  125. package/dist/cli/list-models.code.js.map +1 -0
  126. package/dist/cli/list-models.impl.js +36 -0
  127. package/dist/cli/list-models.impl.js.map +1 -0
  128. package/dist/cli/list-models.js +33 -57
  129. package/dist/cli/list-models.js.map +1 -1
  130. package/dist/cli/session-picker.code.js +55 -0
  131. package/dist/cli/session-picker.code.js.map +1 -0
  132. package/dist/cli/session-picker.impl.js +36 -0
  133. package/dist/cli/session-picker.impl.js.map +1 -0
  134. package/dist/cli/session-picker.js +33 -52
  135. package/dist/cli/session-picker.js.map +1 -1
  136. package/dist/cli/startup-ui.code.js +5 -0
  137. package/dist/cli/startup-ui.code.js.map +1 -0
  138. package/dist/cli/startup-ui.impl.js +36 -0
  139. package/dist/cli/startup-ui.impl.js.map +1 -0
  140. package/dist/cli/startup-ui.js +35 -4
  141. package/dist/cli/storage-command.code.js +3 -0
  142. package/dist/cli/storage-command.code.js.map +1 -0
  143. package/dist/cli/storage-command.impl.js +36 -0
  144. package/dist/cli/storage-command.impl.js.map +1 -0
  145. package/dist/cli/storage-command.js +35 -2
  146. package/dist/cli/storage-search-session.code.js +189 -0
  147. package/dist/cli/storage-search-session.code.js.map +1 -0
  148. package/dist/cli/storage-search-session.impl.js +36 -0
  149. package/dist/cli/storage-search-session.impl.js.map +1 -0
  150. package/dist/cli/storage-search-session.js +33 -186
  151. package/dist/cli/storage-search-session.js.map +1 -1
  152. package/dist/cli/team-command.code.js +217 -0
  153. package/dist/cli/team-command.code.js.map +1 -0
  154. package/dist/cli/team-command.impl.js +36 -0
  155. package/dist/cli/team-command.impl.js.map +1 -0
  156. package/dist/cli/team-command.js +32 -213
  157. package/dist/cli/team-command.js.map +1 -1
  158. package/dist/cli.js +60 -11
  159. package/dist/cli.js.map +1 -1
  160. package/dist/config.js +1 -1
  161. package/dist/core/agent-session-methods.d.ts +4 -3
  162. package/dist/core/agent-session-methods.js.map +1 -1
  163. package/dist/core/agent-session-types.d.ts +5 -0
  164. package/dist/core/compaction/compaction.d.ts +6 -0
  165. package/dist/core/compaction/model-resolver.d.ts +1 -1
  166. package/dist/core/debug.code.js +3 -0
  167. package/dist/core/debug.code.js.map +1 -0
  168. package/dist/core/debug.impl.js +36 -0
  169. package/dist/core/debug.impl.js.map +1 -0
  170. package/dist/core/debug.js +35 -2
  171. package/dist/core/default-model-api-prewarm.d.ts +5 -0
  172. package/dist/core/export-html/card-projection.code.js +257 -0
  173. package/dist/core/export-html/card-projection.code.js.map +1 -0
  174. package/dist/core/export-html/card-projection.impl.js +36 -0
  175. package/dist/core/export-html/card-projection.impl.js.map +1 -0
  176. package/dist/core/export-html/card-projection.js +34 -255
  177. package/dist/core/export-html/card-projection.js.map +1 -1
  178. package/dist/core/export-html/index.code.js +655 -0
  179. package/dist/core/export-html/index.code.js.map +1 -0
  180. package/dist/core/export-html/index.impl.js +36 -0
  181. package/dist/core/export-html/index.impl.js.map +1 -0
  182. package/dist/core/export-html/index.js +30 -604
  183. package/dist/core/export-html/index.js.map +1 -1
  184. package/dist/core/export-html/json-spans.code.js +3 -0
  185. package/dist/core/export-html/json-spans.code.js.map +1 -0
  186. package/dist/core/export-html/json-spans.impl.js +36 -0
  187. package/dist/core/export-html/json-spans.impl.js.map +1 -0
  188. package/dist/core/export-html/json-spans.js +35 -2
  189. package/dist/core/export-html/oversized-render-inputs.code.js +125 -0
  190. package/dist/core/export-html/oversized-render-inputs.code.js.map +1 -0
  191. package/dist/core/export-html/oversized-render-inputs.impl.js +36 -0
  192. package/dist/core/export-html/oversized-render-inputs.impl.js.map +1 -0
  193. package/dist/core/export-html/oversized-render-inputs.js +31 -120
  194. package/dist/core/export-html/oversized-render-inputs.js.map +1 -1
  195. package/dist/core/export-html/tool-renderer.code.js +350 -0
  196. package/dist/core/export-html/tool-renderer.code.js.map +1 -0
  197. package/dist/core/export-html/tool-renderer.impl.js +36 -0
  198. package/dist/core/export-html/tool-renderer.impl.js.map +1 -0
  199. package/dist/core/export-html/tool-renderer.js +33 -347
  200. package/dist/core/export-html/tool-renderer.js.map +1 -1
  201. package/dist/core/extensions/jiti-loader.code.js +3 -0
  202. package/dist/core/extensions/jiti-loader.code.js.map +1 -0
  203. package/dist/core/extensions/jiti-loader.impl.js +36 -0
  204. package/dist/core/extensions/jiti-loader.impl.js.map +1 -0
  205. package/dist/core/extensions/jiti-loader.js +35 -2
  206. package/dist/core/extensions/jiti-static-loader.code.js +3 -0
  207. package/dist/core/extensions/jiti-static-loader.code.js.map +1 -0
  208. package/dist/core/extensions/jiti-static-loader.impl.js +36 -0
  209. package/dist/core/extensions/jiti-static-loader.impl.js.map +1 -0
  210. package/dist/core/extensions/jiti-static-loader.js +35 -2
  211. package/dist/core/extensions/loader-host-modules.code.js +3 -0
  212. package/dist/core/extensions/loader-host-modules.code.js.map +1 -0
  213. package/dist/core/extensions/loader-host-modules.impl.js +36 -0
  214. package/dist/core/extensions/loader-host-modules.impl.js.map +1 -0
  215. package/dist/core/extensions/loader-host-modules.js +35 -2
  216. package/dist/core/extensions/loader-virtual-modules.d.ts +1 -6
  217. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  218. package/dist/core/extensions/runner-context.js +3 -3
  219. package/dist/core/extensions/session-events.d.ts +4 -0
  220. package/dist/core/extensions/session-events.js.map +1 -1
  221. package/dist/core/intercom-broker-control-host.code.js +5 -0
  222. package/dist/core/intercom-broker-control-host.code.js.map +1 -0
  223. package/dist/core/intercom-broker-control-host.impl.js +36 -0
  224. package/dist/core/intercom-broker-control-host.impl.js.map +1 -0
  225. package/dist/core/intercom-broker-control-host.js +35 -4
  226. package/dist/core/intercom-broker-control.code.js +63 -0
  227. package/dist/core/intercom-broker-control.code.js.map +1 -0
  228. package/dist/core/intercom-broker-control.d.ts +21 -0
  229. package/dist/core/intercom-broker-control.impl.js +36 -0
  230. package/dist/core/intercom-broker-control.impl.js.map +1 -0
  231. package/dist/core/intercom-broker-control.js +35 -17
  232. package/dist/core/intercom-broker-control.js.map +1 -1
  233. package/dist/core/package-manager-storage-adapters.code.js +3 -0
  234. package/dist/core/package-manager-storage-adapters.code.js.map +1 -0
  235. package/dist/core/package-manager-storage-adapters.impl.js +36 -0
  236. package/dist/core/package-manager-storage-adapters.impl.js.map +1 -0
  237. package/dist/core/package-manager-storage-adapters.js +35 -2
  238. package/dist/core/process-start-token.d.ts +8 -2
  239. package/dist/core/process-tree-containment.d.ts +27 -0
  240. package/dist/core/queued-message-delivery.d.ts +5 -2
  241. package/dist/core/resume/blueprint/process.d.ts +3 -1
  242. package/dist/core/sdk.code.js +9 -0
  243. package/dist/core/sdk.code.js.map +1 -0
  244. package/dist/core/sdk.impl.js +36 -0
  245. package/dist/core/sdk.impl.js.map +1 -0
  246. package/dist/core/sdk.js +35 -8
  247. package/dist/core/session-manager-core.d.ts +15 -5
  248. package/dist/core/session-manager-core.js +195 -38
  249. package/dist/core/session-manager-core.js.map +1 -1
  250. package/dist/core/session-manager-list.code.js +3 -0
  251. package/dist/core/session-manager-list.code.js.map +1 -0
  252. package/dist/core/session-manager-list.impl.js +36 -0
  253. package/dist/core/session-manager-list.impl.js.map +1 -0
  254. package/dist/core/session-manager-list.js +35 -2
  255. package/dist/core/session-manager-types.d.ts +20 -0
  256. package/dist/core/session-manager.code.js +8 -0
  257. package/dist/core/session-manager.code.js.map +1 -0
  258. package/dist/core/session-manager.d.ts +1 -1
  259. package/dist/core/session-manager.impl.js +36 -0
  260. package/dist/core/session-manager.impl.js.map +1 -0
  261. package/dist/core/session-manager.js +35 -7
  262. package/dist/core/session-storage.code.js +3 -0
  263. package/dist/core/session-storage.code.js.map +1 -0
  264. package/dist/core/session-storage.impl.js +36 -0
  265. package/dist/core/session-storage.impl.js.map +1 -0
  266. package/dist/core/session-storage.js +35 -2
  267. package/dist/core/storage/file-identity.d.ts +3 -0
  268. package/dist/core/storage/file-identity.js +296 -86
  269. package/dist/core/storage/file-identity.js.map +1 -1
  270. package/dist/core/storage/index.d.ts +1 -1
  271. package/dist/core/storage/index.js +52 -7
  272. package/dist/core/storage/index.js.map +1 -1
  273. package/dist/core/storage/node-sqlite-thread.js +47 -2
  274. package/dist/core/storage/node-sqlite.js +49 -4
  275. package/dist/core/storage/node-sqlite.js.map +1 -1
  276. package/dist/core/storage/offline-snapshot-file.code.js +37 -0
  277. package/dist/core/storage/offline-snapshot-file.code.js.map +1 -0
  278. package/dist/core/storage/offline-snapshot-file.impl.js +36 -0
  279. package/dist/core/storage/offline-snapshot-file.impl.js.map +1 -0
  280. package/dist/core/storage/offline-snapshot-file.js +33 -34
  281. package/dist/core/storage/offline-snapshot-file.js.map +1 -1
  282. package/dist/core/storage/provider.js +52 -7
  283. package/dist/core/storage/selection.js +49 -4
  284. package/dist/core/storage/session/branch-fork-source.code.js +146 -0
  285. package/dist/core/storage/session/branch-fork-source.code.js.map +1 -0
  286. package/dist/core/storage/session/branch-fork-source.impl.js +36 -0
  287. package/dist/core/storage/session/branch-fork-source.impl.js.map +1 -0
  288. package/dist/core/storage/session/branch-fork-source.js +32 -97
  289. package/dist/core/storage/session/branch-fork-source.js.map +1 -1
  290. package/dist/core/storage/session/card-view.code.js +60 -0
  291. package/dist/core/storage/session/card-view.code.js.map +1 -0
  292. package/dist/core/storage/session/card-view.impl.js +36 -0
  293. package/dist/core/storage/session/card-view.impl.js.map +1 -0
  294. package/dist/core/storage/session/card-view.js +34 -58
  295. package/dist/core/storage/session/card-view.js.map +1 -1
  296. package/dist/core/storage/session/child-reader.code.js +139 -0
  297. package/dist/core/storage/session/child-reader.code.js.map +1 -0
  298. package/dist/core/storage/session/child-reader.d.ts +1 -0
  299. package/dist/core/storage/session/child-reader.impl.js +36 -0
  300. package/dist/core/storage/session/child-reader.impl.js.map +1 -0
  301. package/dist/core/storage/session/child-reader.js +33 -91
  302. package/dist/core/storage/session/child-reader.js.map +1 -1
  303. package/dist/core/storage/session/chunked-resume-projection.code.js +3 -0
  304. package/dist/core/storage/session/chunked-resume-projection.code.js.map +1 -0
  305. package/dist/core/storage/session/chunked-resume-projection.impl.js +36 -0
  306. package/dist/core/storage/session/chunked-resume-projection.impl.js.map +1 -0
  307. package/dist/core/storage/session/chunked-resume-projection.js +35 -2
  308. package/dist/core/storage/session/expanded-child-details.code.js +684 -0
  309. package/dist/core/storage/session/expanded-child-details.code.js.map +1 -0
  310. package/dist/core/storage/session/expanded-child-details.impl.js +36 -0
  311. package/dist/core/storage/session/expanded-child-details.impl.js.map +1 -0
  312. package/dist/core/storage/session/expanded-child-details.js +31 -634
  313. package/dist/core/storage/session/expanded-child-details.js.map +1 -1
  314. package/dist/core/storage/session/fork-row-bytes.code.js +3 -0
  315. package/dist/core/storage/session/fork-row-bytes.code.js.map +1 -0
  316. package/dist/core/storage/session/fork-row-bytes.impl.js +36 -0
  317. package/dist/core/storage/session/fork-row-bytes.impl.js.map +1 -0
  318. package/dist/core/storage/session/fork-row-bytes.js +35 -2
  319. package/dist/core/storage/session/fork-row-index.code.js +3 -0
  320. package/dist/core/storage/session/fork-row-index.code.js.map +1 -0
  321. package/dist/core/storage/session/fork-row-index.impl.js +36 -0
  322. package/dist/core/storage/session/fork-row-index.impl.js.map +1 -0
  323. package/dist/core/storage/session/fork-row-index.js +35 -2
  324. package/dist/core/storage/session/fork-staging.code.js +580 -0
  325. package/dist/core/storage/session/fork-staging.code.js.map +1 -0
  326. package/dist/core/storage/session/fork-staging.impl.js +36 -0
  327. package/dist/core/storage/session/fork-staging.impl.js.map +1 -0
  328. package/dist/core/storage/session/fork-staging.js +30 -574
  329. package/dist/core/storage/session/fork-staging.js.map +1 -1
  330. package/dist/core/storage/session/fork-window.code.js +522 -0
  331. package/dist/core/storage/session/fork-window.code.js.map +1 -0
  332. package/dist/core/storage/session/fork-window.impl.js +36 -0
  333. package/dist/core/storage/session/fork-window.impl.js.map +1 -0
  334. package/dist/core/storage/session/fork-window.js +30 -471
  335. package/dist/core/storage/session/fork-window.js.map +1 -1
  336. package/dist/core/storage/session/history-pages.code.js +3 -0
  337. package/dist/core/storage/session/history-pages.code.js.map +1 -0
  338. package/dist/core/storage/session/history-pages.impl.js +36 -0
  339. package/dist/core/storage/session/history-pages.impl.js.map +1 -0
  340. package/dist/core/storage/session/history-pages.js +35 -2
  341. package/dist/core/storage/session/jsonl-entry-projection.code.js +3 -0
  342. package/dist/core/storage/session/jsonl-entry-projection.code.js.map +1 -0
  343. package/dist/core/storage/session/jsonl-entry-projection.impl.js +36 -0
  344. package/dist/core/storage/session/jsonl-entry-projection.impl.js.map +1 -0
  345. package/dist/core/storage/session/jsonl-entry-projection.js +35 -2
  346. package/dist/core/storage/session/jsonl-session-store.code.js +3 -0
  347. package/dist/core/storage/session/jsonl-session-store.code.js.map +1 -0
  348. package/dist/core/storage/session/jsonl-session-store.impl.js +36 -0
  349. package/dist/core/storage/session/jsonl-session-store.impl.js.map +1 -0
  350. package/dist/core/storage/session/jsonl-session-store.js +35 -2
  351. package/dist/core/storage/session/memory-session-store.code.js +3 -0
  352. package/dist/core/storage/session/memory-session-store.code.js.map +1 -0
  353. package/dist/core/storage/session/memory-session-store.impl.js +36 -0
  354. package/dist/core/storage/session/memory-session-store.impl.js.map +1 -0
  355. package/dist/core/storage/session/memory-session-store.js +35 -2
  356. package/dist/core/storage/session/pinned-branch-resume.code.js +117 -0
  357. package/dist/core/storage/session/pinned-branch-resume.code.js.map +1 -0
  358. package/dist/core/storage/session/pinned-branch-resume.impl.js +36 -0
  359. package/dist/core/storage/session/pinned-branch-resume.impl.js.map +1 -0
  360. package/dist/core/storage/session/pinned-branch-resume.js +33 -69
  361. package/dist/core/storage/session/pinned-branch-resume.js.map +1 -1
  362. package/dist/core/storage/session/released-history-files.code.js +465 -0
  363. package/dist/core/storage/session/released-history-files.code.js.map +1 -0
  364. package/dist/core/storage/session/released-history-files.impl.js +36 -0
  365. package/dist/core/storage/session/released-history-files.impl.js.map +1 -0
  366. package/dist/core/storage/session/released-history-files.js +32 -461
  367. package/dist/core/storage/session/released-history-files.js.map +1 -1
  368. package/dist/core/storage/session/resident-fork-rows.code.js +57 -0
  369. package/dist/core/storage/session/resident-fork-rows.code.js.map +1 -0
  370. package/dist/core/storage/session/resident-fork-rows.impl.js +36 -0
  371. package/dist/core/storage/session/resident-fork-rows.impl.js.map +1 -0
  372. package/dist/core/storage/session/resident-fork-rows.js +32 -53
  373. package/dist/core/storage/session/resident-fork-rows.js.map +1 -1
  374. package/dist/core/storage/session/session-resume.code.js +3 -0
  375. package/dist/core/storage/session/session-resume.code.js.map +1 -0
  376. package/dist/core/storage/session/session-resume.impl.js +36 -0
  377. package/dist/core/storage/session/session-resume.impl.js.map +1 -0
  378. package/dist/core/storage/session/session-resume.js +35 -2
  379. package/dist/core/storage/session/snapshot-cut.code.js +3 -0
  380. package/dist/core/storage/session/snapshot-cut.code.js.map +1 -0
  381. package/dist/core/storage/session/snapshot-cut.impl.js +36 -0
  382. package/dist/core/storage/session/snapshot-cut.impl.js.map +1 -0
  383. package/dist/core/storage/session/snapshot-cut.js +35 -2
  384. package/dist/core/storage/session/snapshot-history.code.js +107 -0
  385. package/dist/core/storage/session/snapshot-history.code.js.map +1 -0
  386. package/dist/core/storage/session/snapshot-history.impl.js +36 -0
  387. package/dist/core/storage/session/snapshot-history.impl.js.map +1 -0
  388. package/dist/core/storage/session/snapshot-history.js +34 -60
  389. package/dist/core/storage/session/snapshot-history.js.map +1 -1
  390. package/dist/core/storage/session/sql-session-store.code.js +3 -0
  391. package/dist/core/storage/session/sql-session-store.code.js.map +1 -0
  392. package/dist/core/storage/session/sql-session-store.impl.js +36 -0
  393. package/dist/core/storage/session/sql-session-store.impl.js.map +1 -0
  394. package/dist/core/storage/session/sql-session-store.js +35 -2
  395. package/dist/core/storage/session/tree-outline.code.js +3 -0
  396. package/dist/core/storage/session/tree-outline.code.js.map +1 -0
  397. package/dist/core/storage/session/tree-outline.impl.js +36 -0
  398. package/dist/core/storage/session/tree-outline.impl.js.map +1 -0
  399. package/dist/core/storage/session/tree-outline.js +35 -2
  400. package/dist/core/storage/session/tree-presentation.code.js +342 -0
  401. package/dist/core/storage/session/tree-presentation.code.js.map +1 -0
  402. package/dist/core/storage/session/tree-presentation.impl.js +36 -0
  403. package/dist/core/storage/session/tree-presentation.impl.js.map +1 -0
  404. package/dist/core/storage/session/tree-presentation.js +31 -337
  405. package/dist/core/storage/session/tree-presentation.js.map +1 -1
  406. package/dist/core/storage/session/types.d.ts +26 -0
  407. package/dist/core/storage/storage-status.code.js +3 -0
  408. package/dist/core/storage/storage-status.code.js.map +1 -0
  409. package/dist/core/storage/storage-status.impl.js +36 -0
  410. package/dist/core/storage/storage-status.impl.js.map +1 -0
  411. package/dist/core/storage/storage-status.js +35 -2
  412. package/dist/core/storage/team.code.js +3 -0
  413. package/dist/core/storage/team.code.js.map +1 -0
  414. package/dist/core/storage/team.impl.js +36 -0
  415. package/dist/core/storage/team.impl.js.map +1 -0
  416. package/dist/core/storage/team.js +35 -2
  417. package/dist/core/structured-output/index.code.js +3 -0
  418. package/dist/core/structured-output/index.code.js.map +1 -0
  419. package/dist/core/structured-output/index.impl.js +36 -0
  420. package/dist/core/structured-output/index.impl.js.map +1 -0
  421. package/dist/core/structured-output/index.js +35 -2
  422. package/dist/core/tasks/command-output.d.ts +4 -1
  423. package/dist/core/tasks/supervisor.d.ts +2 -0
  424. package/dist/core/tasks/task-completion-entry.code.js +254 -0
  425. package/dist/core/tasks/task-completion-entry.code.js.map +1 -0
  426. package/dist/core/tasks/task-completion-entry.impl.js +36 -0
  427. package/dist/core/tasks/task-completion-entry.impl.js.map +1 -0
  428. package/dist/core/tasks/task-completion-entry.js +33 -251
  429. package/dist/core/tasks/task-completion-entry.js.map +1 -1
  430. package/dist/core/tasks/task-file-history.code.js +424 -0
  431. package/dist/core/tasks/task-file-history.code.js.map +1 -0
  432. package/dist/core/tasks/task-file-history.impl.js +36 -0
  433. package/dist/core/tasks/task-file-history.impl.js.map +1 -0
  434. package/dist/core/tasks/task-file-history.js +32 -375
  435. package/dist/core/tasks/task-file-history.js.map +1 -1
  436. package/dist/core/tasks/task-reference-archive.code.js +514 -0
  437. package/dist/core/tasks/task-reference-archive.code.js.map +1 -0
  438. package/dist/core/tasks/task-reference-archive.js +34 -467
  439. package/dist/core/tasks/task-reference-archive.js.map +1 -1
  440. package/dist/core/tasks/task-reference-identity.code.js +164 -0
  441. package/dist/core/tasks/task-reference-identity.code.js.map +1 -0
  442. package/dist/core/tasks/task-reference-identity.js +32 -160
  443. package/dist/core/tasks/task-reference-identity.js.map +1 -1
  444. package/dist/core/tasks/task-reference-stream.code.js +3 -0
  445. package/dist/core/tasks/task-reference-stream.code.js.map +1 -0
  446. package/dist/core/tasks/task-reference-stream.impl.js +36 -0
  447. package/dist/core/tasks/task-reference-stream.impl.js.map +1 -0
  448. package/dist/core/tasks/task-reference-stream.js +35 -2
  449. package/dist/core/tasks/task-unsaved-answer.code.js +3 -0
  450. package/dist/core/tasks/task-unsaved-answer.code.js.map +1 -0
  451. package/dist/core/tasks/task-unsaved-answer.impl.js +36 -0
  452. package/dist/core/tasks/task-unsaved-answer.impl.js.map +1 -0
  453. package/dist/core/tasks/task-unsaved-answer.js +35 -2
  454. package/dist/core/tasks/task-view-source.code.js +3 -0
  455. package/dist/core/tasks/task-view-source.code.js.map +1 -0
  456. package/dist/core/tasks/task-view-source.d.ts +9 -0
  457. package/dist/core/tasks/task-view-source.impl.js +36 -0
  458. package/dist/core/tasks/task-view-source.impl.js.map +1 -0
  459. package/dist/core/tasks/task-view-source.js +35 -2
  460. package/dist/core/tools/read-url.code.js +1530 -0
  461. package/dist/core/tools/read-url.code.js.map +1 -0
  462. package/dist/core/tools/read-url.impl.js +36 -0
  463. package/dist/core/tools/read-url.impl.js.map +1 -0
  464. package/dist/core/tools/read-url.js +30 -1524
  465. package/dist/core/tools/read-url.js.map +1 -1
  466. package/dist/core/worktree-snapshot/blob-store.js +50 -5
  467. package/dist/core/worktree-snapshot/errors.code.js +6 -0
  468. package/dist/core/worktree-snapshot/errors.code.js.map +1 -0
  469. package/dist/core/worktree-snapshot/errors.impl.js +36 -0
  470. package/dist/core/worktree-snapshot/errors.impl.js.map +1 -0
  471. package/dist/core/worktree-snapshot/errors.js +35 -5
  472. package/dist/core/worktree-snapshot/session-index-reset.code.js +136 -0
  473. package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -0
  474. package/dist/core/worktree-snapshot/session-index-reset.impl.js +36 -0
  475. package/dist/core/worktree-snapshot/session-index-reset.impl.js.map +1 -0
  476. package/dist/core/worktree-snapshot/session-index-reset.js +34 -134
  477. package/dist/core/worktree-snapshot/session-index-reset.js.map +1 -1
  478. package/dist/extensions/codemode/execute.code.js +618 -0
  479. package/dist/extensions/codemode/execute.code.js.map +1 -0
  480. package/dist/extensions/codemode/execute.impl.js +36 -0
  481. package/dist/extensions/codemode/execute.impl.js.map +1 -0
  482. package/dist/extensions/codemode/execute.js +30 -612
  483. package/dist/extensions/codemode/execute.js.map +1 -1
  484. package/dist/extensions/codemode/renderer.code.js +110 -0
  485. package/dist/extensions/codemode/renderer.code.js.map +1 -0
  486. package/dist/extensions/codemode/renderer.impl.js +36 -0
  487. package/dist/extensions/codemode/renderer.impl.js.map +1 -0
  488. package/dist/extensions/codemode/renderer.js +33 -107
  489. package/dist/extensions/codemode/renderer.js.map +1 -1
  490. package/dist/extensions/mcp/cli.code.js +565 -0
  491. package/dist/extensions/mcp/cli.code.js.map +1 -0
  492. package/dist/extensions/mcp/cli.impl.js +36 -0
  493. package/dist/extensions/mcp/cli.impl.js.map +1 -0
  494. package/dist/extensions/mcp/cli.js +32 -561
  495. package/dist/extensions/mcp/cli.js.map +1 -1
  496. package/dist/extensions/mcp/cli.lazy.code.js +52 -0
  497. package/dist/extensions/mcp/cli.lazy.code.js.map +1 -0
  498. package/dist/extensions/mcp/cli.lazy.impl.js +36 -0
  499. package/dist/extensions/mcp/cli.lazy.impl.js.map +1 -0
  500. package/dist/extensions/mcp/cli.lazy.js +36 -7
  501. package/dist/extensions/mcp/cli.lazy.js.map +1 -1
  502. package/dist/extensions/mcp/client/transports/stdio.d.ts +2 -0
  503. package/dist/extensions/mcp/runtime.code.js +5 -0
  504. package/dist/extensions/mcp/runtime.code.js.map +1 -0
  505. package/dist/extensions/mcp/runtime.impl.js +36 -0
  506. package/dist/extensions/mcp/runtime.impl.js.map +1 -0
  507. package/dist/extensions/mcp/runtime.js +35 -4
  508. package/dist/index.d.ts +1 -1
  509. package/dist/index.js +8 -8
  510. package/dist/main-first-time-setup.code.js +12 -0
  511. package/dist/main-first-time-setup.code.js.map +1 -0
  512. package/dist/main-first-time-setup.impl.js +36 -0
  513. package/dist/main-first-time-setup.impl.js.map +1 -0
  514. package/dist/main-first-time-setup.js +35 -11
  515. package/dist/main-first-time-setup.js.map +1 -1
  516. package/dist/main.d.ts +1 -1
  517. package/dist/main.js +2 -2
  518. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +6 -1
  519. package/dist/modes/interactive/agent-view/contracts.d.ts +4 -0
  520. package/dist/modes/interactive/chat-reader-records.d.ts +1 -1
  521. package/dist/modes/interactive/components/stored-tree-view.code.js +338 -0
  522. package/dist/modes/interactive/components/stored-tree-view.code.js.map +1 -0
  523. package/dist/modes/interactive/components/stored-tree-view.impl.js +36 -0
  524. package/dist/modes/interactive/components/stored-tree-view.impl.js.map +1 -0
  525. package/dist/modes/interactive/components/stored-tree-view.js +33 -290
  526. package/dist/modes/interactive/components/stored-tree-view.js.map +1 -1
  527. package/dist/modes/interactive/components/task-selection-state.d.ts +8 -3
  528. package/dist/modes/interactive/components/task-transcript-page.d.ts +1 -0
  529. package/dist/modes/interactive/components/user-message-selector-archive.code.js +191 -0
  530. package/dist/modes/interactive/components/user-message-selector-archive.code.js.map +1 -0
  531. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +36 -0
  532. package/dist/modes/interactive/components/user-message-selector-archive.impl.js.map +1 -0
  533. package/dist/modes/interactive/components/user-message-selector-archive.js +34 -189
  534. package/dist/modes/interactive/components/user-message-selector-archive.js.map +1 -1
  535. package/dist/modes/interactive/interactive-mode-base.d.ts +6 -0
  536. package/dist/modes/interactive/interactive-mode-deps.js +4 -0
  537. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -0
  538. package/dist/modes/interactive/interactive-mode.js +1 -1
  539. package/dist/modes/interactive/interactive-queueing.d.ts +4 -0
  540. package/dist/modes/interactive/interactive-render-chat.d.ts +22 -0
  541. package/dist/modes/interactive/interactive-startup.d.ts +2 -0
  542. package/dist/modes/interactive/program-status-reporter.d.ts +2 -1
  543. package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
  544. package/dist/modes/interactive/steering-queue-controller.d.ts +4 -0
  545. package/dist/modes/interactive/theme/theme-schema-factory.d.ts +26 -0
  546. package/dist/modes/interactive/theme/theme-schema.d.ts +4 -5
  547. package/dist/modes/interactive-engine/engine-prewarm.d.ts +30 -5
  548. package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
  549. package/dist/modes/interactive-engine/isolated-runtime.d.ts +7 -0
  550. package/dist/modes/interactive-engine/protocol.d.ts +32 -1
  551. package/dist/modes/rpc/agent-view-rpc-types.d.ts +12 -1
  552. package/dist/modes/rpc/agent-view-rpc-types.js.map +1 -1
  553. package/dist/modes/rpc/rpc-client-api.d.ts +3 -1
  554. package/dist/modes/rpc/rpc-types.d.ts +12 -0
  555. package/dist/package-manager-cli.code.js +1140 -0
  556. package/dist/package-manager-cli.code.js.map +1 -0
  557. package/dist/package-manager-cli.impl.js +36 -0
  558. package/dist/package-manager-cli.impl.js.map +1 -0
  559. package/dist/package-manager-cli.js +36 -1067
  560. package/dist/package-manager-cli.js.map +1 -1
  561. package/dist/rpc-entry.js +2 -2
  562. package/dist/startup-files.json +1 -1
  563. package/dist/startup-stages/10.js +1 -1
  564. package/dist/startup-stages/11.js +1 -1
  565. package/dist/startup-stages/12.js +1 -1
  566. package/dist/startup-stages/13.js +1 -0
  567. package/dist/startup-stages/2.js +1 -7
  568. package/dist/startup-stages/3.js +6 -2
  569. package/dist/startup-stages/4.js +2 -1
  570. package/dist/startup-stages/5.js +1 -7
  571. package/dist/startup-stages/6.js +7 -10
  572. package/dist/startup-stages/7.js +10 -3
  573. package/dist/startup-stages/8.js +3 -6
  574. package/dist/startup-stages/9.js +6 -1
  575. package/dist/startup-stages/stages.json +1 -1
  576. package/dist/utils/canonical-path.js +2 -0
  577. package/dist/utils/canonical-path.js.map +1 -1
  578. package/dist/utils/child-process.d.ts +41 -1
  579. package/dist/utils/compile-cache-warmup-host.js +63 -18
  580. package/dist/utils/compile-cache-warmup-host.js.map +1 -1
  581. package/dist/utils/credential-redaction.d.ts +50 -1
  582. package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
  583. package/dist/utils/interactive-engine-env.d.ts +2 -0
  584. package/dist/utils/memoize-async.d.ts +32 -0
  585. package/dist/utils/memoize-async.js +91 -0
  586. package/dist/utils/memoize-async.js.map +1 -0
  587. package/dist/utils/photon.js +19 -29
  588. package/dist/utils/photon.js.map +1 -1
  589. package/dist/utils/shell.d.ts +7 -4
  590. package/dist/utils/startup-database-spare.code.js +108 -0
  591. package/dist/utils/startup-database-spare.code.js.map +1 -0
  592. package/dist/utils/startup-database-spare.impl.js +36 -0
  593. package/dist/utils/startup-database-spare.impl.js.map +1 -0
  594. package/dist/utils/startup-database-spare.js +33 -105
  595. package/dist/utils/startup-database-spare.js.map +1 -1
  596. package/dist/utils/tools-manager.code.js +3 -0
  597. package/dist/utils/tools-manager.code.js.map +1 -0
  598. package/dist/utils/tools-manager.impl.js +36 -0
  599. package/dist/utils/tools-manager.impl.js.map +1 -0
  600. package/dist/utils/tools-manager.js +35 -2
  601. package/dist/utils/windows-cwd.js +585 -0
  602. package/dist/utils/windows-cwd.js.map +1 -0
  603. package/docs/extensions.md +1 -1
  604. package/docs/getting-started/installation.md +2 -0
  605. package/docs/intercom/operations.md +1 -0
  606. package/docs/reference/cli.md +2 -2
  607. package/package.json +24 -24
  608. package/dist/_shared/mode-shared-HP7GUA7J.js.map +0 -1
  609. package/dist/_shared/p1a-prewarm-YK3KDTLN.js.map +0 -1
  610. package/dist/_shared/p1b-elig-PXQA2FYP.js.map +0 -1
  611. package/dist/_shared/startup-0-0-X4NF3GKM.js.map +0 -1
  612. package/dist/_shared/startup-0-1-7QTG6VJZ.js.map +0 -1
  613. package/dist/_shared/startup-0-2-KFDYPDJK.js.map +0 -1
  614. package/dist/_shared/startup-8-1-KQJBDKRU.js.map +0 -1
@@ -1,2838 +1,2 @@
1
- import { __commonJSMin, __exportAll, __require, __toESM } from "./rolldown-runtime-BGM3D5V3.js";
2
- import nodeModule, { createRequire } from "node:module";
3
- import { mkdtemp, readFile, rename, rm, writeFile } from "node:fs/promises";
4
- import { accessSync, constants, existsSync, readFileSync, realpathSync } from "fs";
5
- import { basename, dirname, join, resolve, sep, win32 } from "path";
6
- import { availableParallelism, constants as constants$1, homedir, setPriority, tmpdir, totalmem, uptime } from "node:os";
7
- import { basename as basename$1, dirname as dirname$1, isAbsolute as isAbsolute$1, join as join$1, parse, posix, relative as relative$1, resolve as resolve$1, sep as sep$1, win32 as win32$1 } from "node:path";
8
- import { fileURLToPath, pathToFileURL } from "node:url";
9
- import { spawn, spawnSync } from "node:child_process";
10
- import { findHelperExecutable, findHelperExecutableAsync, helperLaunch, helperLaunchAsync, missingHelperOptions } from "@bastani/atomic-tui/dist/helper-programs/index.js";
11
- import { canonicalizePath as canonicalizePath$1, canonicalizePathAsync as canonicalizePathAsync$1, createSessionCwdMatcher, createSessionCwdMatcherAsync as createSessionCwdMatcherAsync$1 } from "../utils/canonical-path.js";
12
- import { homedir as homedir$1 } from "os";
13
- import { pathExists } from "../utils/path-exists.js";
14
- import { appendFileSync, existsSync as existsSync$1, mkdirSync as mkdirSync$1, readFileSync as readFileSync$1, rmSync as rmSync$1 } from "node:fs";
15
- import { Worker } from "node:worker_threads";
16
- import { EVAL_WORKER_BUILTIN, evalWorkerExecArgv } from "../utils/worker-threads.js";
17
- import { cachedDataVersionTag, getHeapStatistics, setFlagsFromString } from "node:v8";
18
- import { nodeOptionsFromEnvironment, splitNodeOptions, startupNodeOptions } from "@bastani/atomic-codemode/node-options";
19
- // dist/core/builtin-install-layout.js
20
- const BUILTIN_PACKAGE_DIR_NAMES = [
21
- "subagents",
22
- "mcp",
23
- "web-access",
24
- "intercom"
25
- ];
26
- /** Source-checkout extension entries. Discovery still loads these in a git tree. */
27
- const SOURCE_EXTENSION_ENTRIES = {
28
- subagents: "src/extension/index.ts",
29
- mcp: "index.ts",
30
- "web-access": "index.ts",
31
- intercom: "index.ts"
32
- };
33
- /** Installed/npm extension entries after copy-builtin-packages prebundles them. */
34
- const INSTALLED_EXTENSION_ENTRIES = {
35
- subagents: "src/extension/index.bundle.mjs",
36
- mcp: "index.bundle.mjs",
37
- "web-access": "index.bundle.mjs",
38
- intercom: "index.bundle.mjs"
39
- };
40
- function requiredEntriesForBuiltin(dirName) {
41
- return [INSTALLED_EXTENSION_ENTRIES[dirName], SOURCE_EXTENSION_ENTRIES[dirName]];
42
- }
43
- // dist/utils/text.js
44
- /** Split a leading UTF-8 byte order mark from decoded text. */
45
- function splitBom(content) {
46
- return content.startsWith("") ? {
47
- bom: "",
48
- text: content.slice(1)
49
- } : {
50
- bom: "",
51
- text: content
52
- };
53
- }
54
- /** Remove a leading UTF-8 byte order mark from decoded text. */
55
- function stripBom(content) {
56
- return splitBom(content).text;
57
- }
58
- // dist/config-package-identity.js
59
- const COMPANION_BUILTIN_PACKAGE_NAMES = BUILTIN_PACKAGE_DIR_NAMES.map((dirName) => `@bastani/${dirName}`);
60
- function isCompanionBuiltinPackageName(name) {
61
- return name !== void 0 && COMPANION_BUILTIN_PACKAGE_NAMES.includes(name);
62
- }
63
- function packageJsonDefinesAppIdentity(pkg) {
64
- if (pkg.name === "@bastani/atomic" || pkg.name === "@mariozechner/pi") return true;
65
- return pkg.atomicConfig !== void 0 || pkg.piConfig !== void 0;
66
- }
67
- /**
68
- * Walk from a bundled or compiled module directory to the Atomic app package.
69
- *
70
- * Prebundled companion extensions live under `dist/builtin/<name>/` with their
71
- * own `package.json`. The first package.json from those bundles is
72
- * a companion such as `@bastani/subagents`, which must not become APP_NAME.
73
- */
74
- function resolvePackageDirFrom(startDir) {
75
- let dir = startDir;
76
- let firstPackageDir;
77
- while (dir !== dirname(dir)) {
78
- const packageJsonPath = join(dir, "package.json");
79
- if (existsSync(packageJsonPath)) {
80
- firstPackageDir ??= dir;
81
- if (shouldUsePackageDir(readPackageIdentity(packageJsonPath))) return dir;
82
- }
83
- dir = dirname(dir);
84
- }
85
- return firstPackageDir ?? startDir;
86
- }
87
- function shouldUsePackageDir(pkg) {
88
- if (packageJsonDefinesAppIdentity(pkg)) return true;
89
- return !isCompanionBuiltinPackageName(pkg.name);
90
- }
91
- function isJsonValue(value) {
92
- if (value === null || typeof value === "boolean" || typeof value === "string") return true;
93
- if (typeof value === "number") return Number.isFinite(value);
94
- if (Array.isArray(value)) return value.every(isJsonValue);
95
- if (typeof value !== "object" || Object.getPrototypeOf(value) !== Object.prototype) return false;
96
- return Object.values(value).every(isJsonValue);
97
- }
98
- function isJsonObject(value) {
99
- return value !== null && typeof value === "object" && !Array.isArray(value);
100
- }
101
- function readPackageIdentity(packageJsonPath) {
102
- try {
103
- const parsed = JSON.parse(stripBom(readFileSync(packageJsonPath, "utf-8")));
104
- if (!isJsonValue(parsed) || !isJsonObject(parsed)) return {};
105
- const name = parsed.name;
106
- const atomicConfig = parsed.atomicConfig;
107
- const piConfig = parsed.piConfig;
108
- return {
109
- ...typeof name === "string" ? { name } : {},
110
- ...atomicConfig !== void 0 && isJsonObject(atomicConfig) ? { atomicConfig } : {},
111
- ...piConfig !== void 0 && isJsonObject(piConfig) ? { piConfig } : {}
112
- };
113
- } catch {}
114
- return {};
115
- }
116
- // ../../node_modules/isexe/windows.js
117
- var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
118
- module.exports = isexe;
119
- isexe.sync = sync;
120
- var fs = __require("fs");
121
- function checkPathExt(path, options) {
122
- var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
123
- if (!pathext) return true;
124
- pathext = pathext.split(";");
125
- if (pathext.indexOf("") !== -1) return true;
126
- for (var i = 0; i < pathext.length; i++) {
127
- var p = pathext[i].toLowerCase();
128
- if (p && path.substr(-p.length).toLowerCase() === p) return true;
129
- }
130
- return false;
131
- }
132
- function checkStat(stat, path, options) {
133
- if (!stat.isSymbolicLink() && !stat.isFile()) return false;
134
- return checkPathExt(path, options);
135
- }
136
- function isexe(path, options, cb) {
137
- fs.stat(path, function(er, stat) {
138
- cb(er, er ? false : checkStat(stat, path, options));
139
- });
140
- }
141
- function sync(path, options) {
142
- return checkStat(fs.statSync(path), path, options);
143
- }
144
- }));
145
- // ../../node_modules/isexe/mode.js
146
- var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
147
- module.exports = isexe;
148
- isexe.sync = sync;
149
- var fs = __require("fs");
150
- function isexe(path, options, cb) {
151
- fs.stat(path, function(er, stat) {
152
- cb(er, er ? false : checkStat(stat, options));
153
- });
154
- }
155
- function sync(path, options) {
156
- return checkStat(fs.statSync(path), options);
157
- }
158
- function checkStat(stat, options) {
159
- return stat.isFile() && checkMode(stat, options);
160
- }
161
- function checkMode(stat, options) {
162
- var mod = stat.mode;
163
- var uid = stat.uid;
164
- var gid = stat.gid;
165
- var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
166
- var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
167
- var u = parseInt("100", 8);
168
- var g = parseInt("010", 8);
169
- var o = parseInt("001", 8);
170
- var ug = u | g;
171
- return mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
172
- }
173
- }));
174
- // ../../node_modules/isexe/index.js
175
- var require_isexe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
176
- __require("fs");
177
- var core;
178
- if (process.platform === "win32" || global.TESTING_WINDOWS) core = require_windows();
179
- else core = require_mode();
180
- module.exports = isexe;
181
- isexe.sync = sync;
182
- function isexe(path, options, cb) {
183
- if (typeof options === "function") {
184
- cb = options;
185
- options = {};
186
- }
187
- if (!cb) {
188
- if (typeof Promise !== "function") throw new TypeError("callback not provided");
189
- return new Promise(function(resolve, reject) {
190
- isexe(path, options || {}, function(er, is) {
191
- if (er) reject(er);
192
- else resolve(is);
193
- });
194
- });
195
- }
196
- core(path, options || {}, function(er, is) {
197
- if (er) {
198
- if (er.code === "EACCES" || options && options.ignoreErrors) {
199
- er = null;
200
- is = false;
201
- }
202
- }
203
- cb(er, is);
204
- });
205
- }
206
- function sync(path, options) {
207
- try {
208
- return core.sync(path, options || {});
209
- } catch (er) {
210
- if (options && options.ignoreErrors || er.code === "EACCES") return false;
211
- else throw er;
212
- }
213
- }
214
- }));
215
- // ../../node_modules/which/which.js
216
- var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
217
- const isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
218
- const path = __require("path");
219
- const COLON = isWindows ? ";" : ":";
220
- const isexe = require_isexe();
221
- const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
222
- const getPathInfo = (cmd, opt) => {
223
- const colon = opt.colon || COLON;
224
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH ||
225
- /* istanbul ignore next: very unusual */ "").split(colon)];
226
- const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
227
- const pathExt = isWindows ? pathExtExe.split(colon) : [""];
228
- if (isWindows) {
229
- if (cmd.indexOf(".") !== -1 && pathExt[0] !== "") pathExt.unshift("");
230
- }
231
- return {
232
- pathEnv,
233
- pathExt,
234
- pathExtExe
235
- };
236
- };
237
- const which = (cmd, opt, cb) => {
238
- if (typeof opt === "function") {
239
- cb = opt;
240
- opt = {};
241
- }
242
- if (!opt) opt = {};
243
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
244
- const found = [];
245
- const step = (i) => new Promise((resolve, reject) => {
246
- if (i === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
247
- const ppRaw = pathEnv[i];
248
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
249
- const pCmd = path.join(pathPart, cmd);
250
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
251
- resolve(subStep(p, i, 0));
252
- });
253
- const subStep = (p, i, ii) => new Promise((resolve, reject) => {
254
- if (ii === pathExt.length) return resolve(step(i + 1));
255
- const ext = pathExt[ii];
256
- isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
257
- if (!er && is) {
258
- if (opt.all) found.push(p + ext);
259
- else return resolve(p + ext);
260
- }
261
- return resolve(subStep(p, i, ii + 1));
262
- });
263
- });
264
- return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
265
- };
266
- const whichSync = (cmd, opt) => {
267
- opt = opt || {};
268
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
269
- const found = [];
270
- for (let i = 0; i < pathEnv.length; i++) {
271
- const ppRaw = pathEnv[i];
272
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
273
- const pCmd = path.join(pathPart, cmd);
274
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
275
- for (let j = 0; j < pathExt.length; j++) {
276
- const cur = p + pathExt[j];
277
- try {
278
- if (isexe.sync(cur, { pathExt: pathExtExe })) {
279
- if (opt.all) found.push(cur);
280
- else return cur;
281
- }
282
- } catch (ex) {}
283
- }
284
- }
285
- if (opt.all && found.length) return found;
286
- if (opt.nothrow) return null;
287
- throw getNotFoundError(cmd);
288
- };
289
- module.exports = which;
290
- which.sync = whichSync;
291
- }));
292
- // ../../node_modules/path-key/index.js
293
- var require_path_key = /* @__PURE__ */ __commonJSMin(((exports, module) => {
294
- const pathKey = (options = {}) => {
295
- const environment = options.env || process.env;
296
- if ((options.platform || process.platform) !== "win32") return "PATH";
297
- return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
298
- };
299
- module.exports = pathKey;
300
- module.exports.default = pathKey;
301
- }));
302
- // ../../node_modules/cross-spawn/lib/util/resolveCommand.js
303
- var require_resolveCommand = /* @__PURE__ */ __commonJSMin(((exports, module) => {
304
- const path = __require("path");
305
- const which = require_which();
306
- const getPathKey = require_path_key();
307
- function resolveCommandAttempt(parsed, withoutPathExt) {
308
- const env = parsed.options.env || process.env;
309
- const cwd = process.cwd();
310
- const hasCustomCwd = parsed.options.cwd != null;
311
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
312
- if (shouldSwitchCwd) try {
313
- process.chdir(parsed.options.cwd);
314
- } catch (err) {}
315
- let resolved;
316
- try {
317
- resolved = which.sync(parsed.command, {
318
- path: env[getPathKey({ env })],
319
- pathExt: withoutPathExt ? path.delimiter : void 0
320
- });
321
- } catch (e) {} finally {
322
- if (shouldSwitchCwd) process.chdir(cwd);
323
- }
324
- if (resolved) resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
325
- return resolved;
326
- }
327
- function resolveCommand(parsed) {
328
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
329
- }
330
- module.exports = resolveCommand;
331
- }));
332
- // ../../node_modules/cross-spawn/lib/util/escape.js
333
- var require_escape = /* @__PURE__ */ __commonJSMin(((exports, module) => {
334
- const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
335
- function escapeCommand(arg) {
336
- arg = arg.replace(metaCharsRegExp, "^$1");
337
- return arg;
338
- }
339
- function escapeArgument(arg, doubleEscapeMetaChars) {
340
- arg = `${arg}`;
341
- arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
342
- arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
343
- arg = `"${arg}"`;
344
- arg = arg.replace(metaCharsRegExp, "^$1");
345
- if (doubleEscapeMetaChars) arg = arg.replace(metaCharsRegExp, "^$1");
346
- return arg;
347
- }
348
- module.exports.command = escapeCommand;
349
- module.exports.argument = escapeArgument;
350
- }));
351
- // ../../node_modules/shebang-regex/index.js
352
- var require_shebang_regex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
353
- module.exports = /^#!(.*)/;
354
- }));
355
- // ../../node_modules/shebang-command/index.js
356
- var require_shebang_command = /* @__PURE__ */ __commonJSMin(((exports, module) => {
357
- const shebangRegex = require_shebang_regex();
358
- module.exports = (string = "") => {
359
- const match = string.match(shebangRegex);
360
- if (!match) return null;
361
- const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
362
- const binary = path.split("/").pop();
363
- if (binary === "env") return argument;
364
- return argument ? `${binary} ${argument}` : binary;
365
- };
366
- }));
367
- // ../../node_modules/cross-spawn/lib/util/readShebang.js
368
- var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
369
- const fs = __require("fs");
370
- const shebangCommand = require_shebang_command();
371
- function readShebang(command) {
372
- const size = 150;
373
- const buffer = Buffer.alloc(size);
374
- let fd;
375
- try {
376
- fd = fs.openSync(command, "r");
377
- fs.readSync(fd, buffer, 0, size, 0);
378
- fs.closeSync(fd);
379
- } catch (e) {}
380
- return shebangCommand(buffer.toString());
381
- }
382
- module.exports = readShebang;
383
- }));
384
- // ../../node_modules/cross-spawn/lib/parse.js
385
- var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
386
- const path = __require("path");
387
- const resolveCommand = require_resolveCommand();
388
- const escape = require_escape();
389
- const readShebang = require_readShebang();
390
- const isWin = process.platform === "win32";
391
- const isExecutableRegExp = /\.(?:com|exe)$/i;
392
- const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
393
- function detectShebang(parsed) {
394
- parsed.file = resolveCommand(parsed);
395
- const shebang = parsed.file && readShebang(parsed.file);
396
- if (shebang) {
397
- parsed.args.unshift(parsed.file);
398
- parsed.command = shebang;
399
- return resolveCommand(parsed);
400
- }
401
- return parsed.file;
402
- }
403
- function parseNonShell(parsed) {
404
- if (!isWin) return parsed;
405
- const commandFile = detectShebang(parsed);
406
- const needsShell = !isExecutableRegExp.test(commandFile);
407
- if (parsed.options.forceShell || needsShell) {
408
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
409
- parsed.command = path.normalize(parsed.command);
410
- parsed.command = escape.command(parsed.command);
411
- parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
412
- parsed.args = [
413
- "/d",
414
- "/s",
415
- "/c",
416
- `"${[parsed.command].concat(parsed.args).join(" ")}"`
417
- ];
418
- parsed.command = process.env.comspec || "cmd.exe";
419
- parsed.options.windowsVerbatimArguments = true;
420
- }
421
- return parsed;
422
- }
423
- function parse(command, args, options) {
424
- if (args && !Array.isArray(args)) {
425
- options = args;
426
- args = null;
427
- }
428
- args = args ? args.slice(0) : [];
429
- options = Object.assign({}, options);
430
- const parsed = {
431
- command,
432
- args,
433
- options,
434
- file: void 0,
435
- original: {
436
- command,
437
- args
438
- }
439
- };
440
- return options.shell ? parsed : parseNonShell(parsed);
441
- }
442
- module.exports = parse;
443
- }));
444
- // ../../node_modules/cross-spawn/lib/enoent.js
445
- var require_enoent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
446
- const isWin = process.platform === "win32";
447
- function notFoundError(original, syscall) {
448
- return Object.assign(/* @__PURE__ */ new Error(`${syscall} ${original.command} ENOENT`), {
449
- code: "ENOENT",
450
- errno: "ENOENT",
451
- syscall: `${syscall} ${original.command}`,
452
- path: original.command,
453
- spawnargs: original.args
454
- });
455
- }
456
- function hookChildProcess(cp, parsed) {
457
- if (!isWin) return;
458
- const originalEmit = cp.emit;
459
- cp.emit = function(name, arg1) {
460
- if (name === "exit") {
461
- const err = verifyENOENT(arg1, parsed);
462
- if (err) return originalEmit.call(cp, "error", err);
463
- }
464
- return originalEmit.apply(cp, arguments);
465
- };
466
- }
467
- function verifyENOENT(status, parsed) {
468
- if (isWin && status === 1 && !parsed.file) return notFoundError(parsed.original, "spawn");
469
- return null;
470
- }
471
- function verifyENOENTSync(status, parsed) {
472
- if (isWin && status === 1 && !parsed.file) return notFoundError(parsed.original, "spawnSync");
473
- return null;
474
- }
475
- module.exports = {
476
- hookChildProcess,
477
- verifyENOENT,
478
- verifyENOENTSync,
479
- notFoundError
480
- };
481
- }));
482
- // ../../node_modules/cross-spawn/index.js
483
- var require_cross_spawn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
484
- const cp = __require("child_process");
485
- const parse = require_parse();
486
- const enoent = require_enoent();
487
- function spawn(command, args, options) {
488
- const parsed = parse(command, args, options);
489
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
490
- enoent.hookChildProcess(spawned, parsed);
491
- return spawned;
492
- }
493
- function spawnSync(command, args, options) {
494
- const parsed = parse(command, args, options);
495
- const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
496
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
497
- return result;
498
- }
499
- module.exports = spawn;
500
- module.exports.spawn = spawn;
501
- module.exports.sync = spawnSync;
502
- module.exports._parse = parse;
503
- module.exports._enoent = enoent;
504
- }));
505
- // dist/core/debug-errors.js
506
- var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
507
- /** The family of debug output errors. */
508
- var DebugError = class extends Error {
509
- name = "DebugError";
510
- code;
511
- /** What to do about it, without the rest of the message. */
512
- hint;
513
- retryable = false;
514
- constructor(code, message, hint, options) {
515
- super(message, options);
516
- this.code = code;
517
- this.hint = hint;
518
- }
519
- /** The facts this error carries, as JSON-safe text. */
520
- fields() {
521
- return {};
522
- }
523
- };
524
- /** A debug log file could not be written. Atomic keeps running; that debug output is lost. */
525
- var DebugLogUnwritableError = class extends DebugError {
526
- name = "DebugLogUnwritableError";
527
- retryable = false;
528
- path;
529
- constructor(path, options) {
530
- const hint = `Make ${dirname$1(path)} writable, or turn debug mode off.`;
531
- super("debug-log-unwritable", `Debug log is not writable: ${path} (debug-log-unwritable). ${hint}`, hint, options);
532
- this.path = path;
533
- }
534
- fields() {
535
- return { path: this.path };
536
- }
537
- };
538
- /** The debug setting was given something other than `true` or `false`. Nothing changed. */
539
- var DebugConfigError = class extends DebugError {
540
- name = "DebugConfigError";
541
- retryable = false;
542
- source;
543
- field = "enabled";
544
- /** The type of the value received, never the value itself. */
545
- received;
546
- constructor({ source, received }) {
547
- const hint = "Pass true or false.";
548
- super("invalid-setting", `Invalid debug setting: enabled is ${received}, not a boolean (invalid-setting). ${hint}`, hint);
549
- this.source = source;
550
- this.received = received;
551
- }
552
- fields() {
553
- return {
554
- source: this.source,
555
- field: this.field,
556
- received: this.received
557
- };
558
- }
559
- };
560
- const MAX_CAUSE_DEPTH = 8;
561
- /** `error` as JSON-safe data, its cause chain cut after eight errors. {@link rehydrateDebugError} reverses it. */
562
- function serializeDebugError(error, depth = 0) {
563
- const serialized = {
564
- name: error.name,
565
- code: error.code,
566
- message: error.message,
567
- hint: error.hint,
568
- retryable: error.retryable,
569
- fields: error.fields()
570
- };
571
- const { cause } = error;
572
- if (cause === void 0 || depth + 1 >= MAX_CAUSE_DEPTH) return serialized;
573
- if (cause instanceof DebugError) return {
574
- ...serialized,
575
- cause: serializeDebugError(cause, depth + 1)
576
- };
577
- const other = cause instanceof Error ? cause : new Error(String(cause));
578
- return {
579
- ...serialized,
580
- cause: {
581
- name: other.name,
582
- message: other.message
583
- }
584
- };
585
- }
586
- /** A {@link DebugError} whose class this process does not know; it keeps the name, code and fields it arrived with. */
587
- var ForeignDebugError = class extends DebugError {
588
- name;
589
- retryable;
590
- carried;
591
- constructor(serialized, options) {
592
- super(serialized.code, serialized.message, serialized.hint, options);
593
- this.name = serialized.name;
594
- this.retryable = serialized.retryable;
595
- this.carried = serialized.fields;
596
- }
597
- fields() {
598
- return this.carried;
599
- }
600
- };
601
- function rehydrateCause(cause) {
602
- if ("code" in cause) return rehydrateDebugError(cause);
603
- const error = new Error(cause.message);
604
- error.name = cause.name;
605
- return error;
606
- }
607
- /** The error {@link serializeDebugError} described, as the same class with the same fields. */
608
- function rehydrateDebugError(serialized) {
609
- const options = serialized.cause === void 0 ? void 0 : { cause: rehydrateCause(serialized.cause) };
610
- const { path, source, received } = serialized.fields;
611
- if (serialized.name === "DebugLogUnwritableError" && path !== void 0) return new DebugLogUnwritableError(path, options);
612
- if (serialized.name === "DebugConfigError" && (source === "rpc" || source === "sdk") && received !== void 0) return new DebugConfigError({
613
- source,
614
- received
615
- });
616
- return new ForeignDebugError(serialized, options);
617
- }
618
- const DEBUG_ERROR_NAMES = /* @__PURE__ */ new Set([
619
- "DebugError",
620
- "DebugLogUnwritableError",
621
- "DebugConfigError"
622
- ]);
623
- const DEBUG_LOG_UNWRITABLE_NAMES = /* @__PURE__ */ new Set(["DebugLogUnwritableError"]);
624
- const DEBUG_CONFIG_NAMES = /* @__PURE__ */ new Set(["DebugConfigError"]);
625
- function hasStructure(value, names, code) {
626
- if (typeof value !== "object" || value === null) return false;
627
- const fields = value;
628
- return names.has(fields.name) && typeof fields.code === "string" && (code === void 0 || fields.code === code);
629
- }
630
- /** Whether `value` is a {@link DebugError}, also one that crossed a realm or process boundary. */
631
- function isDebugError(value) {
632
- return value instanceof DebugError || hasStructure(value, DEBUG_ERROR_NAMES);
633
- }
634
- /** Whether `value` is a {@link DebugLogUnwritableError}, also one that crossed a realm or process boundary. */
635
- function isDebugLogUnwritableError(value) {
636
- return value instanceof DebugLogUnwritableError || hasStructure(value, DEBUG_LOG_UNWRITABLE_NAMES, "debug-log-unwritable");
637
- }
638
- /** Whether `value` is a {@link DebugConfigError}, also one that crossed a realm or process boundary. */
639
- function isDebugConfigError(value) {
640
- return value instanceof DebugConfigError || hasStructure(value, DEBUG_CONFIG_NAMES, "invalid-setting");
641
- }
642
- // dist/core/debug-setting.js
643
- /** Carries the `debug` setting into child processes. Atomic sets it; users set `ATOMIC_DEBUG`. */
644
- const DEBUG_SETTING_ENV = "ATOMIC_DEBUG_SETTING";
645
- let debugSetting = process.env[DEBUG_SETTING_ENV] === "1";
646
- /** Whether a parent Atomic process passed its debug setting down; only a process without one uses its saved setting. */
647
- function inheritsDebugSetting(env = process.env) {
648
- return env[DEBUG_SETTING_ENV] !== void 0;
649
- }
650
- const settingListeners = /* @__PURE__ */ new Set();
651
- /** This process's `debug` setting: its saved value, a toggle in `/settings`, or what its parent passed down. */
652
- function isDebugSettingOn() {
653
- return debugSetting;
654
- }
655
- /**
656
- * Sets this process's `debug` setting. Child processes started afterwards inherit it. Throws {@link DebugConfigError},
657
- * changing nothing, when `enabled` is not a boolean.
658
- */
659
- function setDebugSetting(enabled, source = "sdk") {
660
- if (typeof enabled !== "boolean") throw new DebugConfigError({
661
- source,
662
- received: enabled === null ? "null" : typeof enabled
663
- });
664
- if (enabled === debugSetting) return;
665
- debugSetting = enabled;
666
- for (const listener of settingListeners) listener(enabled);
667
- }
668
- /** Calls `listener` whenever this process's `debug` setting changes; returns the unsubscribe function. */
669
- function onDebugSettingChange(listener) {
670
- settingListeners.add(listener);
671
- return () => settingListeners.delete(listener);
672
- }
673
- /** Writes this process's `debug` setting into `env`, the environment of a child process about to start. */
674
- function applyDebugSettingToChildEnvironment(env) {
675
- env[DEBUG_SETTING_ENV] = debugSetting ? "1" : "0";
676
- }
677
- // dist/core/storage/host-adapters.js
678
- /**
679
- * The storage adapters of the packages an Atomic process's host loaded, as the processes it starts receive them: a JSON
680
- * object from each adapter name, `<package>` or `<package>/<name>`, to the absolute adapter module it selects.
681
- */
682
- const HOST_STORAGE_ADAPTERS_ENV = "ATOMIC_HOST_STORAGE_ADAPTERS";
683
- const HOST_ADAPTERS = Symbol.for("@bastani/atomic/storage/host-adapters");
684
- const registry = globalThis;
685
- /** The adapters this process inherited from the process that started it. */
686
- function inheritedAdapters() {
687
- const adapters = /* @__PURE__ */ new Map();
688
- const text = process.env[HOST_STORAGE_ADAPTERS_ENV];
689
- if (text === void 0 || text.length === 0) return adapters;
690
- let value;
691
- try {
692
- value = JSON.parse(text);
693
- } catch {
694
- return adapters;
695
- }
696
- if (value === null || typeof value !== "object" || Array.isArray(value)) return adapters;
697
- for (const [name, module] of Object.entries(value)) if (typeof module === "string" && isAbsolute$1(module)) adapters.set(name, module);
698
- return adapters;
699
- }
700
- function hostAdapters() {
701
- registry[HOST_ADAPTERS] ??= inheritedAdapters();
702
- return registry[HOST_ADAPTERS];
703
- }
704
- /** Makes `name` select the absolute adapter `module` in this process and the processes it starts; a registered name keeps its module. */
705
- function addHostStorageAdapter(name, module) {
706
- const adapters = hostAdapters();
707
- if (!adapters.has(name)) adapters.set(name, module);
708
- }
709
- /** The adapter module `name` selects from the packages this process's host loaded, or undefined. */
710
- function hostStorageAdapter(name) {
711
- return hostAdapters().get(name);
712
- }
713
- /** The environment that passes this process's host-loaded adapters to a process it starts; empty without any. */
714
- function hostStorageAdaptersEnvironment() {
715
- const adapters = hostAdapters();
716
- return adapters.size === 0 ? {} : { [HOST_STORAGE_ADAPTERS_ENV]: JSON.stringify(Object.fromEntries(adapters)) };
717
- }
718
- // dist/utils/agent-attribution.js
719
- const ATOMIC_AI_AGENT = "atomic";
720
- // dist/utils/child-process.js
721
- const EXIT_STDIO_IDLE_GRACE_MS = 100;
722
- const EXIT_STDIO_ACTIVE_DRAIN_HARD_CAP_MS = 5e3;
723
- const WINDOWS_EXIT_POLL_INTERVAL_MS = 50;
724
- const WINDOWS_EXIT_CODE_GRACE_MS = 1e3;
725
- function createChildProcessEnvironment(overrides, baseEnv = process.env) {
726
- const callerChose = baseEnv !== process.env && baseEnv["ATOMIC_HOST_STORAGE_ADAPTERS"] !== process.env["ATOMIC_HOST_STORAGE_ADAPTERS"];
727
- const env = {
728
- ...baseEnv,
729
- ...callerChose ? {} : hostStorageAdaptersEnvironment(),
730
- ...overrides,
731
- AI_AGENT: ATOMIC_AI_AGENT
732
- };
733
- applyDebugSettingToChildEnvironment(env);
734
- return env;
735
- }
736
- const WINDOWS_SHELL_COMMANDS = /* @__PURE__ */ new Set([
737
- "bun",
738
- "npm",
739
- "npx",
740
- "pnpm",
741
- "yarn",
742
- "yarnpkg",
743
- "corepack"
744
- ]);
745
- function shouldUseWindowsShell(command) {
746
- if (process.platform !== "win32") return false;
747
- const commandName = basename$1(command).toLowerCase();
748
- return commandName.endsWith(".cmd") || commandName.endsWith(".bat") || WINDOWS_SHELL_COMMANDS.has(commandName);
749
- }
750
- /**
751
- * How {@link spawnProcess} and {@link spawnProcessSync} start `command` from `cwd` with `env`: a bare name becomes its
752
- * absolute path in PATH's absolute directories, never the working directory. On Windows `.cmd` and `.bat` shims count,
753
- * as these functions run them through cmd.exe.
754
- */
755
- function processLaunch(command, options = {}) {
756
- return helperLaunch(command, {
757
- ...launchSearch(options),
758
- shellScripts: process.platform === "win32"
759
- });
760
- }
761
- /** {@link processLaunch} without blocking the event loop. */
762
- function processLaunchAsync(command, options = {}) {
763
- return helperLaunchAsync(command, {
764
- ...launchSearch(options),
765
- shellScripts: process.platform === "win32"
766
- });
767
- }
768
- function launchSearch(options) {
769
- return {
770
- env: options.env ? createChildProcessEnvironment(void 0, options.env) : createChildProcessEnvironment(),
771
- ...options.cwd === void 0 ? {} : { cwd: options.cwd }
772
- };
773
- }
774
- function spawnProcess(command, args, options) {
775
- if (options.shell) return spawnChild(command, args, options);
776
- return spawnLaunchedProcess(processLaunch(command, {
777
- cwd: typeof options.cwd === "string" ? options.cwd : options.cwd?.pathname,
778
- env: options.env
779
- }), args, options);
780
- }
781
- /**
782
- * A shell reads the program of a command line up to the first space: a program looked up to a path with spaces runs
783
- * through one only quoted.
784
- */
785
- function shellReadable(launch, shell) {
786
- if (!shell || launch.missing !== void 0 || !isAbsolute$1(launch.file)) return launch;
787
- return { file: process.platform === "win32" ? `"${launch.file}"` : `'${launch.file.replaceAll("'", `'\\''`)}'` };
788
- }
789
- function spawnLaunchedProcess(launch, args, options) {
790
- if (launch.missing !== void 0) return spawn(launch.file, args, {
791
- ...childEnvironment(options),
792
- ...missingHelperOptions(launch)
793
- });
794
- return spawnChild(shellReadable(launch, options.shell).file, args, options);
795
- }
796
- /** `file` with Atomic's child environment, through cross-spawn on Windows. */
797
- function spawnChild(file, args, options) {
798
- const childOptions = childEnvironment(options);
799
- return process.platform === "win32" ? (0, import_cross_spawn.default)(file, args, childOptions) : spawn(file, args, childOptions);
800
- }
801
- function childEnvironment(options) {
802
- return {
803
- ...options,
804
- env: options.env ? createChildProcessEnvironment(void 0, options.env) : createChildProcessEnvironment()
805
- };
806
- }
807
- /** The synchronous {@link spawnLaunchedProcess}. */
808
- function spawnLaunchedProcessSync(launch, args, options) {
809
- if (launch.missing !== void 0) return spawnSync(launch.file, args, {
810
- ...childEnvironment(options),
811
- ...missingHelperOptions(launch)
812
- });
813
- return spawnChildSync(shellReadable(launch, options.shell).file, args, options);
814
- }
815
- function spawnChildSync(file, args, options) {
816
- const childOptions = childEnvironment(options);
817
- return process.platform === "win32" ? import_cross_spawn.default.sync(file, args, childOptions) : spawnSync(file, args, childOptions);
818
- }
819
- function isWindowsProcessAlive(pid) {
820
- try {
821
- process.kill(pid, 0);
822
- return true;
823
- } catch (error) {
824
- return error.code !== "ESRCH";
825
- }
826
- }
827
- function mapSignalExitCode(code, signal, platform) {
828
- if (code !== null || signal === null || platform === "win32") return code;
829
- return 128 + (constants$1.signals[signal] ?? 0);
830
- }
831
- /**
832
- * Wait for a child process to terminate without hanging on inherited stdio handles.
833
- *
834
- * A short-lived child can `exit` while a detached descendant keeps its stdout/stderr
835
- * pipe open. We must not resolve and destroy the streams on a short fixed deadline
836
- * measured from `exit`, or finite post-exit output still being written past that
837
- * deadline is silently lost (earendil-works/pi#5303). Instead, after `exit` we wait
838
- * for the pipes to fall idle: the grace timer is re-armed on every chunk, so finite
839
- * post-exit writers drain while active, while a quiet inherited handle (e.g. a
840
- * Windows daemonized descendant that never lets `close` fire) releases promptly
841
- * after the grace elapses. A longer active-drain hard cap is armed once on `exit`
842
- * so an endlessly noisy descendant cannot keep the wait pending forever.
843
- */
844
- function waitForChildProcess(child, options = {}) {
845
- return new Promise((resolve, reject) => {
846
- let settled = false;
847
- let exited = false;
848
- let exitCode = null;
849
- let postExitIdleTimer;
850
- let postExitActiveDrainHardCapTimer;
851
- let stdoutEnded = child.stdout === null;
852
- let stderrEnded = child.stderr === null;
853
- let windowsExitPoll;
854
- let windowsExitCodeGraceTimer;
855
- let windowsExitCodeFallback;
856
- const platform = options.platform ?? process.platform;
857
- const processAlive = options.isWindowsProcessAlive ?? isWindowsProcessAlive;
858
- const windowsExitPollIntervalMs = options.windowsExitPollIntervalMs ?? WINDOWS_EXIT_POLL_INTERVAL_MS;
859
- const windowsExitCodeGraceMs = options.windowsExitCodeGraceMs ?? WINDOWS_EXIT_CODE_GRACE_MS;
860
- const cleanup = () => {
861
- if (windowsExitPoll) {
862
- clearInterval(windowsExitPoll);
863
- windowsExitPoll = void 0;
864
- }
865
- if (postExitIdleTimer) {
866
- clearTimeout(postExitIdleTimer);
867
- postExitIdleTimer = void 0;
868
- }
869
- if (postExitActiveDrainHardCapTimer) {
870
- clearTimeout(postExitActiveDrainHardCapTimer);
871
- postExitActiveDrainHardCapTimer = void 0;
872
- }
873
- if (windowsExitCodeGraceTimer) {
874
- clearTimeout(windowsExitCodeGraceTimer);
875
- windowsExitCodeGraceTimer = void 0;
876
- }
877
- if (windowsExitCodeFallback) {
878
- clearImmediate(windowsExitCodeFallback);
879
- windowsExitCodeFallback = void 0;
880
- }
881
- child.removeListener("error", onError);
882
- child.removeListener("exit", onExit);
883
- child.removeListener("close", onClose);
884
- child.stdout?.removeListener("end", onStdoutEnd);
885
- child.stderr?.removeListener("end", onStderrEnd);
886
- child.stdout?.removeListener("data", onData);
887
- child.stderr?.removeListener("data", onData);
888
- };
889
- const finalize = (code) => {
890
- if (settled) return;
891
- settled = true;
892
- cleanup();
893
- child.stdout?.destroy();
894
- child.stderr?.destroy();
895
- resolve(code);
896
- };
897
- const maybeFinalizeAfterExit = () => {
898
- if (!exited || settled) return;
899
- if (stdoutEnded && stderrEnded) finalize(exitCode);
900
- };
901
- const armIdleTimer = () => {
902
- if (postExitIdleTimer) clearTimeout(postExitIdleTimer);
903
- postExitIdleTimer = setTimeout(() => finalize(exitCode), EXIT_STDIO_IDLE_GRACE_MS);
904
- };
905
- const armActiveDrainHardCapTimer = () => {
906
- if (postExitActiveDrainHardCapTimer) return;
907
- postExitActiveDrainHardCapTimer = setTimeout(() => finalize(exitCode), EXIT_STDIO_ACTIVE_DRAIN_HARD_CAP_MS);
908
- };
909
- const onData = () => {
910
- if (exited && !settled) armIdleTimer();
911
- };
912
- const onStdoutEnd = () => {
913
- stdoutEnded = true;
914
- maybeFinalizeAfterExit();
915
- };
916
- const onStderrEnd = () => {
917
- stderrEnded = true;
918
- maybeFinalizeAfterExit();
919
- };
920
- const onError = (err) => {
921
- if (settled) return;
922
- settled = true;
923
- cleanup();
924
- reject(err);
925
- };
926
- const onExit = (code, signal) => {
927
- if (windowsExitCodeGraceTimer) {
928
- clearTimeout(windowsExitCodeGraceTimer);
929
- windowsExitCodeGraceTimer = void 0;
930
- }
931
- if (windowsExitCodeFallback) {
932
- clearImmediate(windowsExitCodeFallback);
933
- windowsExitCodeFallback = void 0;
934
- }
935
- exited = true;
936
- exitCode = mapSignalExitCode(code, signal, platform);
937
- maybeFinalizeAfterExit();
938
- if (!settled) {
939
- armActiveDrainHardCapTimer();
940
- armIdleTimer();
941
- }
942
- };
943
- const armWindowsExitCodeGraceTimer = () => {
944
- if (windowsExitCodeGraceTimer) return;
945
- if (windowsExitPoll) {
946
- clearInterval(windowsExitPoll);
947
- windowsExitPoll = void 0;
948
- }
949
- windowsExitCodeGraceTimer = setTimeout(() => {
950
- windowsExitCodeGraceTimer = void 0;
951
- windowsExitCodeFallback = setImmediate(() => {
952
- windowsExitCodeFallback = void 0;
953
- onExit(child.exitCode ?? 0, null);
954
- });
955
- }, windowsExitCodeGraceMs);
956
- };
957
- const pollWindowsExit = () => {
958
- if (platform !== "win32" || !child.pid || exited || settled) return;
959
- if (!processAlive(child.pid)) {
960
- if (child.exitCode !== null) onExit(child.exitCode, null);
961
- else armWindowsExitCodeGraceTimer();
962
- }
963
- };
964
- const onClose = (code, signal) => {
965
- finalize(mapSignalExitCode(code, signal, platform));
966
- };
967
- if (platform === "win32" && child.pid) windowsExitPoll = setInterval(pollWindowsExit, windowsExitPollIntervalMs);
968
- child.stdout?.once("end", onStdoutEnd);
969
- child.stderr?.once("end", onStderrEnd);
970
- child.stdout?.on("data", onData);
971
- child.stderr?.on("data", onData);
972
- child.once("error", onError);
973
- child.once("exit", onExit);
974
- child.once("close", onClose);
975
- });
976
- }
977
- // dist/utils/paths.js
978
- const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
979
- function getHomeDir() {
980
- if (process.platform === "win32") {
981
- if (process.env.USERPROFILE) return process.env.USERPROFILE;
982
- if (process.env.HOMEDRIVE && process.env.HOMEPATH) return `${process.env.HOMEDRIVE}${process.env.HOMEPATH}`;
983
- if (process.env.HOME) return process.env.HOME;
984
- return homedir();
985
- }
986
- return process.env.HOME || process.env.USERPROFILE || homedir();
987
- }
988
- /**
989
- * Returns true if the value is NOT a package source (npm:, git:, etc.)
990
- * or a remote URL protocol. Bare names, relative paths, and file: URLs
991
- * are considered local.
992
- */
993
- function isLocalPath(value) {
994
- const trimmed = value.trim();
995
- if (trimmed.startsWith("npm:") || trimmed.startsWith("git:") || trimmed.startsWith("github:") || trimmed.startsWith("http:") || trimmed.startsWith("https:") || trimmed.startsWith("ssh:") || trimmed.startsWith("builtin:")) return false;
996
- return true;
997
- }
998
- /** Convert Git Bash, MSYS, Cygwin, and WSL drive paths to a form native Windows APIs accept. */
999
- function normalizeWindowsShellPath(filePath) {
1000
- if (!filePath.startsWith("/") || filePath.startsWith("//") || filePath.includes("\\")) return filePath;
1001
- const match = filePath.match(/^\/(?:mnt\/|cygdrive\/)?([a-z])(?:\/(.*))?$/i);
1002
- if (!match) return filePath;
1003
- const suffix = match[2]?.replaceAll("/", "\\");
1004
- return `${match[1].toUpperCase()}:\\${suffix ?? ""}`;
1005
- }
1006
- function normalizePath(input, options = {}) {
1007
- let normalized = options.trim ? input.trim() : input;
1008
- if (options.normalizeUnicodeSpaces) normalized = normalized.replace(UNICODE_SPACES, " ");
1009
- if (options.stripAtPrefix && normalized.startsWith("@")) normalized = normalized.slice(1);
1010
- if (process.platform === "win32") normalized = normalizeWindowsShellPath(normalized);
1011
- if (options.expandTilde ?? true) {
1012
- const home = options.homeDir ?? getHomeDir();
1013
- if (normalized === "~") return home;
1014
- if (normalized.startsWith("~/") || process.platform === "win32" && normalized.startsWith("~\\")) return join$1(home, normalized.slice(2));
1015
- }
1016
- if (/^file:\/\//.test(normalized)) return fileURLToPath(normalized);
1017
- return normalized;
1018
- }
1019
- function resolvePath(input, baseDir = process.cwd(), options = {}) {
1020
- const normalized = normalizePath(input, options);
1021
- const normalizedBaseDir = normalizePath(baseDir);
1022
- return isAbsolute$1(normalized) ? resolve$1(normalized) : resolve$1(normalizedBaseDir, normalized);
1023
- }
1024
- function getCwdRelativePath(filePath, cwd) {
1025
- const resolvedCwd = resolvePath(cwd);
1026
- const resolvedPath = resolvePath(filePath, resolvedCwd);
1027
- const relativePath = relative$1(resolvedCwd, resolvedPath);
1028
- return relativePath === "" || relativePath !== ".." && !relativePath.startsWith(`..${sep$1}`) && !isAbsolute$1(relativePath) ? relativePath || "." : void 0;
1029
- }
1030
- function formatPathRelativeToCwdOrAbsolute(filePath, cwd) {
1031
- const absolutePath = resolvePath(filePath, cwd);
1032
- return (getCwdRelativePath(absolutePath, cwd) ?? absolutePath).split(sep$1).join("/");
1033
- }
1034
- /**
1035
- * Key for comparing filesystem paths: the resolved absolute path, case-folded on Windows because Windows
1036
- * paths are case-insensitive (`c:\Users` and `C:\Users` are the same directory). NTFS can enable
1037
- * per-directory case sensitivity, but it is rarely used outside WSL interop, so it is ignored here.
1038
- * Does not touch the filesystem; resolve symlinks first when they must compare equal. Use only for
1039
- * comparison, never for display or filesystem access.
1040
- */
1041
- function getPathComparisonKey(path) {
1042
- const pathApi = getPlatformPathApi();
1043
- const resolvedPath = pathApi.resolve(path);
1044
- return pathApi === win32$1 ? resolvedPath.toLowerCase() : resolvedPath;
1045
- }
1046
- /** `node:path` rules for the current platform, read at call time so tests can simulate Windows. */
1047
- function getPlatformPathApi() {
1048
- return process.platform === "win32" ? win32$1 : posix;
1049
- }
1050
- /** True when both paths name the same location (see `getPathComparisonKey`). */
1051
- function pathsEqual(left, right) {
1052
- return getPathComparisonKey(left) === getPathComparisonKey(right);
1053
- }
1054
- /** True when `child` is `parent` or inside it (see `getPathComparisonKey`). */
1055
- function isPathWithin(parent, child) {
1056
- const parentKey = getPathComparisonKey(parent);
1057
- const childKey = getPathComparisonKey(child);
1058
- if (childKey === parentKey) return true;
1059
- const pathSep = getPlatformPathApi().sep;
1060
- return childKey.startsWith(parentKey.endsWith(pathSep) ? parentKey : `${parentKey}${pathSep}`);
1061
- }
1062
- /** Replace a leading home directory with `~` for display. Relative paths are returned unchanged. */
1063
- function shortenHomePath(path, homeDir = homedir()) {
1064
- const pathApi = getPlatformPathApi();
1065
- if (!homeDir || !pathApi.isAbsolute(path) || !isPathWithin(homeDir, path)) return path;
1066
- const relativePath = pathApi.relative(homeDir, path);
1067
- return relativePath ? `~${pathApi.sep}${relativePath}` : "~";
1068
- }
1069
- async function markPathIgnoredByCloudSync(path) {
1070
- const attrs = process.platform === "darwin" ? ["com.dropbox.ignored", "com.apple.fileprovider.ignore#P"] : process.platform === "linux" ? ["user.com.dropbox.ignored"] : [];
1071
- for (const attr of attrs) {
1072
- const [command, args] = process.platform === "darwin" ? ["xattr", [
1073
- "-w",
1074
- attr,
1075
- "1",
1076
- path
1077
- ]] : ["setfattr", [
1078
- "-n",
1079
- attr,
1080
- "-v",
1081
- "1",
1082
- path
1083
- ]];
1084
- try {
1085
- await waitForChildProcess(spawnLaunchedProcess(await processLaunchAsync(command), args, { stdio: "ignore" }));
1086
- } catch {}
1087
- }
1088
- }
1089
- // dist/utils/split-launcher.js
1090
- /**
1091
- * Split-launcher / foreign-build `import.meta.url` handling.
1092
- *
1093
- * Atomic's release binaries use a split launcher: a tiny compiled `atomic` /
1094
- * `atomic.exe` executable sets `ATOMIC_CODING_AGENT=true` and then dynamically
1095
- * imports the bundled sidecar `app.js` (plus raw-TS built-in extensions) from
1096
- * disk next to the executable.
1097
- *
1098
- * Unlike pi's single monolithic `bun --compile` binary — where `import.meta.url`
1099
- * is always a `$bunfs://` virtual-FS URL — the split sidecar bundle carries the
1100
- * build machine's source path baked in at bundle time (e.g. a macOS
1101
- * `file:///Users/.../app.js` URL). On Windows, `fileURLToPath()` rejects that
1102
- * URL with `ERR_INVALID_FILE_URL_PATH` ("File URL path must be an absolute
1103
- * path") because `/Users/...` has no drive letter, so every site that decodes
1104
- * `import.meta.url` to a filesystem path must tolerate it.
1105
- *
1106
- * These helpers centralize that tolerance: decode normally, and only when the
1107
- * decode fails under the split launcher fall back to a path resolved relative to
1108
- * the launcher executable (where the sidecar bundle and its assets actually
1109
- * live). This mirrors pi's convention of a single detection point rather than
1110
- * scattered ad-hoc guards.
1111
- */
1112
- function isSplitLauncherRuntime() {
1113
- return process.env.ATOMIC_CODING_AGENT === "true" && /(?:^|[\\/])atomic(?:\.exe)?$/i.test(process.execPath);
1114
- }
1115
- /** Directory containing the launcher executable and its sidecar bundle/assets. */
1116
- function splitLauncherDir() {
1117
- return dirname$1(process.execPath);
1118
- }
1119
- /**
1120
- * Resolve a module's directory from its `import.meta.url`, tolerating the
1121
- * split-launcher case where the bundled URL is a foreign-OS build path.
1122
- * `execRelativeSegments` locate the equivalent directory next to the launcher.
1123
- */
1124
- function moduleDirFromMetaUrl(metaUrl, ...execRelativeSegments) {
1125
- try {
1126
- return dirname$1(fileURLToPath(metaUrl));
1127
- } catch (error) {
1128
- if (isSplitLauncherRuntime()) return join$1(splitLauncherDir(), ...execRelativeSegments);
1129
- throw error;
1130
- }
1131
- }
1132
- /**
1133
- * Resolve a module's filename from its `import.meta.url`, tolerating the
1134
- * split-launcher case. `execRelativeFile` locates the equivalent file next to
1135
- * the launcher (used as a stable resolution base, e.g. for `createRequire`).
1136
- */
1137
- function moduleFileFromMetaUrl(metaUrl, execRelativeFile) {
1138
- try {
1139
- return fileURLToPath(metaUrl);
1140
- } catch (error) {
1141
- if (isSplitLauncherRuntime()) return join$1(splitLauncherDir(), execRelativeFile);
1142
- throw error;
1143
- }
1144
- }
1145
- // dist/config-self-update.js
1146
- function normalizeSelfUpdateTarget(target) {
1147
- if (typeof target === "string") return {
1148
- packageName: target,
1149
- installSpec: target
1150
- };
1151
- return {
1152
- packageName: target.packageName,
1153
- installSpec: target.installSpec ?? target.packageName
1154
- };
1155
- }
1156
- function makeSelfUpdateCommand(installStep, uninstallStep) {
1157
- if (!uninstallStep) return installStep;
1158
- return {
1159
- ...installStep,
1160
- display: `${uninstallStep.display} && ${installStep.display}`,
1161
- steps: [uninstallStep, installStep]
1162
- };
1163
- }
1164
- function makeSelfUpdateCommandStep(command, args) {
1165
- return {
1166
- command,
1167
- args,
1168
- display: [command, ...args].map((arg) => /\s/.test(arg) ? `"${arg}"` : arg).join(" ")
1169
- };
1170
- }
1171
- function detectInstallMethodForRuntime(runtime) {
1172
- if (runtime.isBunBinary) return "bun-binary";
1173
- const resolvedPath = `${runtime.moduleDir}\0${process.execPath || ""}`.toLowerCase().replace(/\\/g, "/");
1174
- if (resolvedPath.includes("/pnpm/") || resolvedPath.includes("/.pnpm/")) return "pnpm";
1175
- if (resolvedPath.includes("/yarn/") || resolvedPath.includes("/.yarn/")) return "yarn";
1176
- if (resolvedPath.includes("/install/global/node_modules/")) return "bun";
1177
- if (resolvedPath.includes("/npm/") || resolvedPath.includes("/node_modules/")) return "npm";
1178
- return "unknown";
1179
- }
1180
- function getInferredNpmInstall(runtime) {
1181
- const packageDir = runtime.getPackageDir();
1182
- const path = process.platform === "win32" || packageDir.includes("\\") ? win32 : {
1183
- basename,
1184
- dirname
1185
- };
1186
- const parent = path.dirname(packageDir);
1187
- let root;
1188
- if (path.basename(parent).startsWith("@") && path.basename(path.dirname(parent)) === "node_modules") root = path.dirname(parent);
1189
- else if (path.basename(parent) === "node_modules") root = parent;
1190
- if (!root) return void 0;
1191
- const rootParent = path.dirname(root);
1192
- if (path.basename(rootParent) === "lib") return {
1193
- root,
1194
- prefix: path.dirname(rootParent)
1195
- };
1196
- }
1197
- function getSelfUpdateCommandForMethod(runtime, method, installedPackageName, updatePackageName = installedPackageName, npmCommand, installSpec = updatePackageName) {
1198
- switch (method) {
1199
- case "bun-binary": return;
1200
- case "pnpm": {
1201
- const match = readCommandOutput("pnpm", ["root", "-g"]) ? void 0 : /^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(runtime.getPackageDir());
1202
- const binDirArgs = match ? [`--config.global-bin-dir=${process.env.PNPM_HOME || dirname(dirname(match[1]))}`] : [];
1203
- return makeSelfUpdateCommand(makeSelfUpdateCommandStep("pnpm", [
1204
- "install",
1205
- "-g",
1206
- "--ignore-scripts",
1207
- "--config.minimumReleaseAge=0",
1208
- ...binDirArgs,
1209
- installSpec
1210
- ]), updatePackageName === installedPackageName ? void 0 : makeSelfUpdateCommandStep("pnpm", [
1211
- "remove",
1212
- "-g",
1213
- ...binDirArgs,
1214
- installedPackageName
1215
- ]));
1216
- }
1217
- case "yarn": return makeSelfUpdateCommand(makeSelfUpdateCommandStep("yarn", [
1218
- "global",
1219
- "add",
1220
- "--ignore-scripts",
1221
- installSpec
1222
- ]), updatePackageName === installedPackageName ? void 0 : makeSelfUpdateCommandStep("yarn", [
1223
- "global",
1224
- "remove",
1225
- installedPackageName
1226
- ]));
1227
- case "bun": return makeSelfUpdateCommand(makeSelfUpdateCommandStep("bun", [
1228
- "install",
1229
- "-g",
1230
- "--ignore-scripts",
1231
- "--minimum-release-age=0",
1232
- installSpec
1233
- ]), updatePackageName === installedPackageName ? void 0 : makeSelfUpdateCommandStep("bun", [
1234
- "uninstall",
1235
- "-g",
1236
- installedPackageName
1237
- ]));
1238
- case "npm": {
1239
- const [command = "npm", ...npmArgs] = npmCommand ?? [];
1240
- const inferred = npmCommand?.length ? void 0 : getInferredNpmInstall(runtime);
1241
- const prefixArgs = [...npmArgs, ...inferred ? ["--prefix", inferred.prefix] : []];
1242
- return makeSelfUpdateCommand(makeSelfUpdateCommandStep(command, [
1243
- ...prefixArgs,
1244
- "install",
1245
- "-g",
1246
- "--ignore-scripts",
1247
- "--min-release-age=0",
1248
- installSpec
1249
- ]), updatePackageName === installedPackageName ? void 0 : makeSelfUpdateCommandStep(command, [
1250
- ...prefixArgs,
1251
- "uninstall",
1252
- "-g",
1253
- installedPackageName
1254
- ]));
1255
- }
1256
- case "unknown": return;
1257
- }
1258
- }
1259
- function readCommandOutput(command, args, options = {}) {
1260
- const result = spawnLaunchedProcessSync(processLaunch(command, { env: process.env }), args, {
1261
- encoding: "utf-8",
1262
- stdio: [
1263
- "ignore",
1264
- "pipe",
1265
- "pipe"
1266
- ],
1267
- env: process.env,
1268
- shell: shouldUseWindowsShell(command)
1269
- });
1270
- if (result.status === 0) return result.stdout.trim() || void 0;
1271
- if (options.requireSuccess) {
1272
- const reason = result.error?.message || result.stderr.trim() || `exit code ${result.status ?? "unknown"}`;
1273
- throw new Error(`Failed to run ${[command, ...args].join(" ")}: ${reason}`);
1274
- }
1275
- }
1276
- function getGlobalPackageRoots(runtime, method, _packageName, npmCommand) {
1277
- switch (method) {
1278
- case "npm": {
1279
- const configured = !!npmCommand?.length;
1280
- const [command = "npm", ...npmArgs] = npmCommand ?? [];
1281
- if (configured && command === "bun") {
1282
- const bunBin = readCommandOutput(command, [
1283
- ...npmArgs,
1284
- "pm",
1285
- "bin",
1286
- "-g"
1287
- ], { requireSuccess: true });
1288
- const roots = [join(homedir$1(), ".bun", "install", "global", "node_modules")];
1289
- if (bunBin) roots.push(join(dirname(bunBin), "install", "global", "node_modules"));
1290
- return roots;
1291
- }
1292
- return [readCommandOutput(command, [
1293
- ...npmArgs,
1294
- "root",
1295
- "-g"
1296
- ], { requireSuccess: configured }), (configured ? void 0 : getInferredNpmInstall(runtime))?.root].filter((x) => !!x);
1297
- }
1298
- case "pnpm": {
1299
- const root = readCommandOutput("pnpm", ["root", "-g"]);
1300
- if (root) return [root, dirname(root)];
1301
- const match = /^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(runtime.getPackageDir());
1302
- return match ? [match[1]] : [];
1303
- }
1304
- case "yarn": {
1305
- const dir = readCommandOutput("yarn", ["global", "dir"]);
1306
- return dir ? [dir, join(dir, "node_modules")] : [];
1307
- }
1308
- case "bun": {
1309
- const bunBin = readCommandOutput("bun", [
1310
- "pm",
1311
- "bin",
1312
- "-g"
1313
- ]);
1314
- const roots = [join(homedir$1(), ".bun", "install", "global", "node_modules")];
1315
- if (bunBin) roots.push(join(dirname(bunBin), "install", "global", "node_modules"));
1316
- return roots;
1317
- }
1318
- case "bun-binary":
1319
- case "unknown": return [];
1320
- }
1321
- }
1322
- function normalizeExistingPathForComparison(path, resolveSymlinks) {
1323
- const resolvedPath = resolve(path);
1324
- if (!existsSync(resolvedPath)) return;
1325
- let normalizedPath = resolvedPath;
1326
- if (resolveSymlinks) try {
1327
- normalizedPath = realpathSync(resolvedPath);
1328
- } catch {
1329
- return;
1330
- }
1331
- if (process.platform === "win32") normalizedPath = normalizedPath.toLowerCase();
1332
- return normalizedPath;
1333
- }
1334
- function getPathComparisonCandidates(path) {
1335
- return Array.from(new Set([normalizeExistingPathForComparison(path, false), normalizeExistingPathForComparison(path, true)].filter((candidate) => !!candidate)));
1336
- }
1337
- function getEntrypointPackageDir() {
1338
- const entrypoint = process.argv[1];
1339
- if (!entrypoint) return void 0;
1340
- let dir = dirname(entrypoint);
1341
- while (dir !== dirname(dir)) {
1342
- if (existsSync(join(dir, "package.json"))) return dir;
1343
- dir = dirname(dir);
1344
- }
1345
- }
1346
- function isSelfUpdatePathWritable(runtime) {
1347
- const packageDir = runtime.getPackageDir();
1348
- try {
1349
- accessSync(packageDir, constants.W_OK);
1350
- accessSync(dirname(packageDir), constants.W_OK);
1351
- return true;
1352
- } catch {
1353
- return false;
1354
- }
1355
- }
1356
- function isManagedByGlobalPackageManager(runtime, method, packageName, npmCommand) {
1357
- const packageDirCandidates = [runtime.getPackageDir(), getEntrypointPackageDir()].filter((dir) => !!dir).flatMap((dir) => getPathComparisonCandidates(dir));
1358
- return getGlobalPackageRoots(runtime, method, packageName, npmCommand).some((root) => {
1359
- return getPathComparisonCandidates(root).some((normalizedRoot) => {
1360
- const rootPrefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;
1361
- return packageDirCandidates.some((packageDir) => packageDir.startsWith(rootPrefix));
1362
- });
1363
- });
1364
- }
1365
- function getSelfUpdateCommandForRuntime(runtime, packageName, npmCommand, updateTarget = packageName) {
1366
- const method = detectInstallMethodForRuntime(runtime);
1367
- const target = normalizeSelfUpdateTarget(updateTarget);
1368
- const command = getSelfUpdateCommandForMethod(runtime, method, packageName, target.packageName, npmCommand, target.installSpec);
1369
- if (!command || !isManagedByGlobalPackageManager(runtime, method, packageName, npmCommand) || !isSelfUpdatePathWritable(runtime)) return;
1370
- return command;
1371
- }
1372
- function getSelfUpdateUnavailableInstructionForRuntime(runtime, packageName, npmCommand, updateTarget = packageName) {
1373
- const method = detectInstallMethodForRuntime(runtime);
1374
- if (method === "bun-binary") return `Download from: https://github.com/bastani-inc/atomic/releases/latest`;
1375
- const target = normalizeSelfUpdateTarget(updateTarget);
1376
- const command = getSelfUpdateCommandForMethod(runtime, method, packageName, target.packageName, npmCommand, target.installSpec);
1377
- if (command && isManagedByGlobalPackageManager(runtime, method, packageName, npmCommand) && !isSelfUpdatePathWritable(runtime)) return `This installation is managed by a global ${method} install, but the install path is not writable. Update it yourself with: ${command.display}`;
1378
- return `Update ${target.installSpec} using the package manager, wrapper, or source checkout that provides this installation.`;
1379
- }
1380
- function getUpdateInstructionForRuntime(runtime, packageName) {
1381
- const command = getSelfUpdateCommandForMethod(runtime, detectInstallMethodForRuntime(runtime), packageName);
1382
- if (command) return `Run: ${command.display}`;
1383
- return getSelfUpdateUnavailableInstructionForRuntime(runtime, packageName);
1384
- }
1385
- // dist/config.js
1386
- const __atomicDistModuleUrl$3 = new URL("../config.js", import.meta.url).href;
1387
- const __filename = moduleFileFromMetaUrl(__atomicDistModuleUrl$3, "app.js");
1388
- const __dirname = dirname(__filename);
1389
- const bunFsMarkers = [
1390
- "$bunfs",
1391
- "~BUN",
1392
- "%7EBUN"
1393
- ];
1394
- const isBunBinary = isSplitLauncherRuntime() || [__atomicDistModuleUrl$3, process.argv[1] ?? ""].some((candidate) => bunFsMarkers.some((marker) => candidate.includes(marker)));
1395
- const isBundledBuild = process.env.ATOMIC_BUNDLED_BUILD === "1";
1396
- const isBunRuntime = !!process.versions.bun;
1397
- const modulePackageDir = isBunBinary ? void 0 : resolvePackageDirFrom(__dirname);
1398
- function selfUpdateRuntime() {
1399
- return {
1400
- isBunBinary,
1401
- isBunRuntime,
1402
- moduleDir: __dirname,
1403
- getPackageDir
1404
- };
1405
- }
1406
- function detectInstallMethod() {
1407
- return detectInstallMethodForRuntime(selfUpdateRuntime());
1408
- }
1409
- function getSelfUpdateCommand(packageName, npmCommand, updateTarget = {
1410
- packageName,
1411
- installSpec: packageName
1412
- }) {
1413
- return getSelfUpdateCommandForRuntime(selfUpdateRuntime(), packageName, npmCommand, updateTarget);
1414
- }
1415
- function getSelfUpdateUnavailableInstruction(packageName, npmCommand, updateTarget = {
1416
- packageName,
1417
- installSpec: packageName
1418
- }) {
1419
- return getSelfUpdateUnavailableInstructionForRuntime(selfUpdateRuntime(), packageName, npmCommand, updateTarget);
1420
- }
1421
- function getConfiguredSelfUpdateArgv(setting) {
1422
- const fromEnv = getEnvValue(ENV_SELF_UPDATE_COMMAND)?.trim().split(/\s+/).filter(Boolean);
1423
- if (fromEnv?.length) return fromEnv;
1424
- return setting?.length ? setting : void 0;
1425
- }
1426
- function makeConfiguredSelfUpdateCommand(argv, release) {
1427
- const values = {
1428
- packageName: release.packageName,
1429
- version: release.version,
1430
- installSpec: `${release.packageName}@${release.version}`
1431
- };
1432
- const [command = "", ...args] = argv.map((arg) => arg.replace(/\{(packageName|version|installSpec)\}/g, (_, name) => values[name]));
1433
- return makeSelfUpdateCommandStep(command, args);
1434
- }
1435
- function getUpdateInstruction(packageName) {
1436
- return getUpdateInstructionForRuntime(selfUpdateRuntime(), packageName);
1437
- }
1438
- function getPackageDir() {
1439
- const envDir = process.env.ATOMIC_PACKAGE_DIR ?? process.env.PI_PACKAGE_DIR;
1440
- if (envDir) return normalizePath(envDir);
1441
- if (isBunBinary || modulePackageDir === void 0) return dirname(process.execPath);
1442
- return modulePackageDir;
1443
- }
1444
- function getModuleAssetRoot() {
1445
- const hasPackageDirOverride = !!(process.env.ATOMIC_PACKAGE_DIR || process.env.PI_PACKAGE_DIR);
1446
- if (!isBundledBuild && !hasPackageDirOverride) return __dirname;
1447
- const packageDir = getPackageDir();
1448
- return packageAssetRoots.get(packageDir) ?? findPackageAssetRoot(packageDir);
1449
- }
1450
- async function getModuleAssetRootAsync() {
1451
- const hasPackageDirOverride = !!(process.env.ATOMIC_PACKAGE_DIR || process.env.PI_PACKAGE_DIR);
1452
- if (!isBundledBuild && !hasPackageDirOverride) return __dirname;
1453
- const packageDir = getPackageDir();
1454
- const known = packageAssetRoots.get(packageDir);
1455
- if (known !== void 0) return known;
1456
- const root = join(packageDir, await pathExists(join(packageDir, "src")) ? "src" : "dist");
1457
- packageAssetRoots.set(packageDir, root);
1458
- return root;
1459
- }
1460
- const packageAssetRoots = /* @__PURE__ */ new Map();
1461
- function findPackageAssetRoot(packageDir) {
1462
- const root = join(packageDir, existsSync(join(packageDir, "src")) ? "src" : "dist");
1463
- packageAssetRoots.set(packageDir, root);
1464
- return root;
1465
- }
1466
- if (isBundledBuild || process.env.ATOMIC_PACKAGE_DIR || process.env.PI_PACKAGE_DIR) findPackageAssetRoot(getPackageDir());
1467
- let codemodeWorkerDataUrl;
1468
- let quickJSWasmPath;
1469
- function getCodemodeWorkerUrl() {
1470
- if (codemodeWorkerDataUrl) return codemodeWorkerDataUrl;
1471
- const worker = isBunBinary ? join(getPackageDir(), "codemode-worker.js") : isBundledBuild ? join(dirname(resolve(process.argv[1])), "codemode-worker.js") : join(getModuleAssetRoot(), "codemode-worker.js");
1472
- if (!isBunBinary && !isBundledBuild && !existsSync(worker)) return void 0;
1473
- codemodeWorkerDataUrl ??= new URL(`data:text/javascript;base64,${readFileSync(worker).toString("base64")}`);
1474
- return codemodeWorkerDataUrl;
1475
- }
1476
- async function getCodemodeWorkerUrlAsync() {
1477
- if (codemodeWorkerDataUrl) return codemodeWorkerDataUrl;
1478
- const worker = isBunBinary ? join(getPackageDir(), "codemode-worker.js") : isBundledBuild ? join(dirname(resolve(process.argv[1])), "codemode-worker.js") : join(await getModuleAssetRootAsync(), "codemode-worker.js");
1479
- if (!isBunBinary && !isBundledBuild && !await pathExists(worker)) return void 0;
1480
- const content = await readFile(worker);
1481
- codemodeWorkerDataUrl ??= new URL(`data:text/javascript;base64,${content.toString("base64")}`);
1482
- return codemodeWorkerDataUrl;
1483
- }
1484
- function getQuickJSWasmPath() {
1485
- quickJSWasmPath ??= isBunBinary ? join(getPackageDir(), "quickjs.wasm") : isBundledBuild ? join(dirname(resolve(process.argv[1])), "quickjs.wasm") : createRequire(__filename).resolve("quickjs-wasi/quickjs.wasm");
1486
- return quickJSWasmPath;
1487
- }
1488
- function detectInstallChange(packageJsonPath = startupPackageJsonPath) {
1489
- if (isBunBinary || !packageJsonPath) return void 0;
1490
- let installed;
1491
- try {
1492
- installed = JSON.parse(stripBom(readFileSync(packageJsonPath, "utf-8")));
1493
- } catch (error) {
1494
- return error.code === "ENOENT" ? { kind: "removed" } : void 0;
1495
- }
1496
- return installChangeOf(installed);
1497
- }
1498
- async function detectInstallChangeAsync(packageJsonPath = startupPackageJsonPath) {
1499
- if (isBunBinary || !packageJsonPath) return void 0;
1500
- let installed;
1501
- try {
1502
- installed = JSON.parse(stripBom(await readFile(packageJsonPath, "utf-8")));
1503
- } catch (error) {
1504
- return error.code === "ENOENT" ? { kind: "removed" } : void 0;
1505
- }
1506
- return installChangeOf(installed);
1507
- }
1508
- function installChangeOf(installed) {
1509
- return installed.version && installed.version !== VERSION ? {
1510
- kind: "updated",
1511
- version: installed.version
1512
- } : void 0;
1513
- }
1514
- function getThemesDir() {
1515
- if (isBunBinary) return join(getPackageDir(), "theme");
1516
- return join(getModuleAssetRoot(), "modes", "interactive", "theme");
1517
- }
1518
- function getExportTemplateDir() {
1519
- if (isBunBinary) return join(getPackageDir(), "export-html");
1520
- return join(getModuleAssetRoot(), "core", "export-html");
1521
- }
1522
- async function getExportTemplateDirAsync() {
1523
- if (isBunBinary) return join(getPackageDir(), "export-html");
1524
- return join(await getModuleAssetRootAsync(), "core", "export-html");
1525
- }
1526
- function getPackageJsonPath() {
1527
- return join(getPackageDir(), "package.json");
1528
- }
1529
- function getReadmePath() {
1530
- return resolve(join(getPackageDir(), "README.md"));
1531
- }
1532
- function getDocsPath() {
1533
- return resolve(join(getPackageDir(), "docs"));
1534
- }
1535
- function getExamplesPath() {
1536
- return resolve(join(getPackageDir(), "examples"));
1537
- }
1538
- function getChangelogPath() {
1539
- return resolve(join(getPackageDir(), "CHANGELOG.md"));
1540
- }
1541
- function getInteractiveAssetsDir() {
1542
- if (isBunBinary) return join(getPackageDir(), "assets");
1543
- return join(getModuleAssetRoot(), "modes", "interactive", "assets");
1544
- }
1545
- function getBundledInteractiveAssetPath(name) {
1546
- return join(getInteractiveAssetsDir(), name);
1547
- }
1548
- async function getBundledInteractiveAssetPathAsync(name) {
1549
- const assetsDir = isBunBinary ? join(getPackageDir(), "assets") : join(await getModuleAssetRootAsync(), "modes", "interactive", "assets");
1550
- return join(assetsDir, name);
1551
- }
1552
- let pkg = {};
1553
- let startupPackageJsonPath;
1554
- try {
1555
- const packageJsonPath = getPackageJsonPath();
1556
- pkg = JSON.parse(stripBom(readFileSync(packageJsonPath, "utf-8")));
1557
- startupPackageJsonPath = packageJsonPath;
1558
- } catch (e) {
1559
- if (e.code !== "ENOENT") throw e;
1560
- }
1561
- function appNameFromPackageName(packageName) {
1562
- const localName = packageName?.split("/").pop()?.trim();
1563
- return localName && localName.length > 0 ? localName : void 0;
1564
- }
1565
- function readAppConfig(packageJson, appName) {
1566
- if (appName) {
1567
- const appConfig2 = packageJson[`${appName}Config`];
1568
- if (appConfig2 && typeof appConfig2 === "object" && !Array.isArray(appConfig2)) return appConfig2;
1569
- }
1570
- return packageJson.piConfig;
1571
- }
1572
- const PACKAGE_NAME = pkg.name || "@bastani/atomic";
1573
- const packageAppName = appNameFromPackageName(PACKAGE_NAME);
1574
- const appConfig = readAppConfig(pkg, packageAppName);
1575
- const APP_NAME = appConfig?.name || packageAppName || "pi";
1576
- const APP_TITLE = appConfig?.name !== void 0 || APP_NAME !== "pi" ? APP_NAME : "π";
1577
- const CONFIG_DIR_NAME = appConfig?.configDir || (APP_NAME === "pi" ? ".pi" : `.${APP_NAME}`);
1578
- const LEGACY_CONFIG_DIR_NAME = ".pi";
1579
- const CONFIG_DIR_NAMES = CONFIG_DIR_NAME === ".pi" ? [CONFIG_DIR_NAME] : [CONFIG_DIR_NAME, ".pi"];
1580
- const VERSION = pkg.version || "0.0.0";
1581
- const NATIVES_VERSION = exactRelease(pkg.dependencies?.["@bastani/atomic-natives"]);
1582
- function exactRelease(range) {
1583
- return typeof range === "string" && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(range) ? range : void 0;
1584
- }
1585
- const CHANGELOG_URL = appConfig?.changelogUrl?.trim() || void 0;
1586
- const ENV_PREFIX = APP_NAME.toUpperCase();
1587
- const LEGACY_ENV_PREFIX = "PI";
1588
- const ENV_AGENT_DIR = `${ENV_PREFIX}_CODING_AGENT_DIR`;
1589
- const ENV_SESSION_DIR = `${ENV_PREFIX}_CODING_AGENT_SESSION_DIR`;
1590
- const ENV_PACKAGE_DIR = `${ENV_PREFIX}_PACKAGE_DIR`;
1591
- const ENV_OFFLINE = `${ENV_PREFIX}_OFFLINE`;
1592
- const ENV_SKIP_VERSION_CHECK = `${ENV_PREFIX}_SKIP_VERSION_CHECK`;
1593
- const ENV_STARTUP_BENCHMARK = `${ENV_PREFIX}_STARTUP_BENCHMARK`;
1594
- const ENV_TELEMETRY = `${ENV_PREFIX}_TELEMETRY`;
1595
- const ENV_SHARE_VIEWER_URL = `${ENV_PREFIX}_SHARE_VIEWER_URL`;
1596
- const ENV_MODEL_CATALOG_URL = `${ENV_PREFIX}_MODEL_CATALOG_URL`;
1597
- const ENV_CLEAR_ON_SHRINK = `${ENV_PREFIX}_CLEAR_ON_SHRINK`;
1598
- const ENV_HARDWARE_CURSOR = `${ENV_PREFIX}_HARDWARE_CURSOR`;
1599
- const ENV_CLIPBOARD_OSC52 = `${ENV_PREFIX}_CLIPBOARD_OSC52`;
1600
- const ENV_TIMING = `${ENV_PREFIX}_TIMING`;
1601
- const ENV_HEAP_MB = `${ENV_PREFIX}_HEAP_MB`;
1602
- const ENV_CODEMODE_MAX_WORKERS = `${ENV_PREFIX}_CODEMODE_MAX_WORKERS`;
1603
- const ENV_SELF_UPDATE_COMMAND = `${ENV_PREFIX}_SELF_UPDATE_COMMAND`;
1604
- const ENV_STDIN_TIMEOUT_MS = `${ENV_PREFIX}_STDIN_TIMEOUT_MS`;
1605
- const ENV_DEBUG = `${ENV_PREFIX}_DEBUG`;
1606
- function getEnvNames(name) {
1607
- if (ENV_PREFIX === "PI" || !name.startsWith(`${ENV_PREFIX}_`)) return [name];
1608
- return [name, `PI_${name.slice(ENV_PREFIX.length + 1)}`];
1609
- }
1610
- function getEnvValue(name) {
1611
- for (const candidate of getEnvNames(name)) {
1612
- const value = process.env[candidate];
1613
- if (value !== void 0) return value;
1614
- }
1615
- }
1616
- function hasEnvValue(name) {
1617
- return getEnvValue(name) !== void 0;
1618
- }
1619
- function setEnvValue(name, value) {
1620
- process.env[name] = value;
1621
- }
1622
- function expandTildePath(path) {
1623
- return normalizePath(path);
1624
- }
1625
- const DEFAULT_SHARE_VIEWER_URL = "https://bastani.ai/session/";
1626
- const VERSION_ADOPTION_ENDPOINT = "https://atomic-version-adoption.bastani-atomic.workers.dev/v1/version-adoption";
1627
- function getShareViewerUrl(gistId) {
1628
- return `${getEnvValue(ENV_SHARE_VIEWER_URL) || DEFAULT_SHARE_VIEWER_URL}#${gistId}`;
1629
- }
1630
- function getAgentDir() {
1631
- const envDir = getEnvValue(ENV_AGENT_DIR);
1632
- if (envDir) return expandTildePath(envDir);
1633
- return join(getHomeDir(), CONFIG_DIR_NAME, "agent");
1634
- }
1635
- function getLegacyAgentDir() {
1636
- return join(getHomeDir(), ".pi", "agent");
1637
- }
1638
- function getAgentDirs() {
1639
- const primary = getAgentDir();
1640
- if (hasEnvValue(ENV_AGENT_DIR) || CONFIG_DIR_NAME === ".pi") return [primary];
1641
- const legacy = getLegacyAgentDir();
1642
- return legacy === primary ? [primary] : [primary, legacy];
1643
- }
1644
- function getUserConfigDirs() {
1645
- return CONFIG_DIR_NAMES.map((name) => join(getHomeDir(), name));
1646
- }
1647
- function getProjectConfigDirs(cwd) {
1648
- return CONFIG_DIR_NAMES.map((name) => join(cwd, name));
1649
- }
1650
- function getUserConfigPaths(...segments) {
1651
- return getUserConfigDirs().map((dir) => join(dir, ...segments));
1652
- }
1653
- function getAgentConfigPaths(...segments) {
1654
- return getAgentDirs().map((dir) => join(dir, ...segments));
1655
- }
1656
- function getProjectConfigPaths(cwd, ...segments) {
1657
- return getProjectConfigDirs(cwd).map((dir) => join(dir, ...segments));
1658
- }
1659
- function getModelsConfigPaths(cwd, agentDir = getAgentDir(), includeProject = true) {
1660
- const globalPaths = agentDir === getAgentDir() ? getAgentConfigPaths("models.json") : [join(agentDir, "models.json")];
1661
- if (!includeProject) return globalPaths;
1662
- const projectPaths = getProjectConfigPaths(cwd, "models.json");
1663
- const paths = [];
1664
- for (let index = 0; index < Math.max(projectPaths.length, globalPaths.length); index++) {
1665
- if (projectPaths[index]) paths.push(projectPaths[index]);
1666
- if (globalPaths[index]) paths.push(globalPaths[index]);
1667
- }
1668
- return [...new Set(paths)];
1669
- }
1670
- function getCustomThemesDir() {
1671
- return join(getAgentDir(), "themes");
1672
- }
1673
- function getModelsPath() {
1674
- return join(getAgentDir(), "models.json");
1675
- }
1676
- function getAuthPath() {
1677
- return join(getAgentDir(), "auth.json");
1678
- }
1679
- function getSettingsPath() {
1680
- return join(getAgentDir(), "settings.json");
1681
- }
1682
- function getToolsDir() {
1683
- return join(getAgentDir(), "tools");
1684
- }
1685
- function getBinDir() {
1686
- return join(getAgentDir(), "bin");
1687
- }
1688
- const BLUEPRINT_FILE_NAME = "blueprint.yaml";
1689
- function getGlobalBlueprintPath(agentDir = getAgentDir()) {
1690
- return join(agentDir, BLUEPRINT_FILE_NAME);
1691
- }
1692
- function getProjectBlueprintPath(dir) {
1693
- return join(dir, CONFIG_DIR_NAME, BLUEPRINT_FILE_NAME);
1694
- }
1695
- function getBlueprintActionsDir(agentDir = getAgentDir()) {
1696
- return join(agentDir, "blueprint-actions");
1697
- }
1698
- const EXTENSION_TRANSPILE_CACHE_FORMAT = "ts-source-specifiers";
1699
- function getExtensionTranspileCacheDir(agentDir = getAgentDir()) {
1700
- return join(agentDir, "cache", "transpile", `${VERSION}+${EXTENSION_TRANSPILE_CACHE_FORMAT}`);
1701
- }
1702
- function getPromptsDir() {
1703
- return join(getAgentDir(), "prompts");
1704
- }
1705
- function getSessionsDir() {
1706
- return join(getAgentDir(), "sessions");
1707
- }
1708
- function getDebugLogPath() {
1709
- return join(getAgentDir(), `${APP_NAME}-debug.log`);
1710
- }
1711
- // dist/core/diagnostic-writer.js
1712
- const QUEUED = 0;
1713
- const WRITING = 1;
1714
- const LANDED = 2;
1715
- const CLAIMED = 3;
1716
- const FAILED = 4;
1717
- const SOURCE = `
1718
- ${EVAL_WORKER_BUILTIN}
1719
- const { parentPort } = builtin("node:worker_threads");
1720
- const { appendFileSync, mkdirSync } = builtin("node:fs");
1721
- const { dirname } = builtin("node:path");
1722
- parentPort.on("message", ({ id, path, chunk, state: buffer, createDirectory }) => {
1723
- const state = new Int32Array(buffer);
1724
- if (Atomics.compareExchange(state, 0, ${QUEUED}, ${WRITING}) !== ${QUEUED}) {
1725
- while (Atomics.load(state, 0) === ${CLAIMED}) Atomics.wait(state, 0, ${CLAIMED});
1726
- return;
1727
- }
1728
- let error;
1729
- try {
1730
- if (createDirectory) mkdirSync(dirname(path), { recursive: true });
1731
- appendFileSync(path, chunk);
1732
- Atomics.store(state, 0, ${LANDED});
1733
- } catch (cause) {
1734
- error = String(cause);
1735
- Atomics.store(state, 0, ${FAILED});
1736
- }
1737
- Atomics.notify(state, 0);
1738
- parentPort.postMessage({ id, error });
1739
- });
1740
- `;
1741
- let worker;
1742
- let nextId = 0;
1743
- const outstanding = /* @__PURE__ */ new Map();
1744
- const counts = /* @__PURE__ */ new Map();
1745
- function getWorker() {
1746
- if (worker !== void 0) return worker;
1747
- const created = new Worker(SOURCE, {
1748
- eval: true,
1749
- execArgv: evalWorkerExecArgv()
1750
- });
1751
- created.on("message", ({ id, error }) => {
1752
- outstanding.get(id)?.settle(error === void 0 ? void 0 : new Error(error));
1753
- });
1754
- const fail = (error) => {
1755
- if (worker === created) worker = void 0;
1756
- for (const append of outstanding.values()) {
1757
- if (append.worker !== created) continue;
1758
- Atomics.store(append.state, 0, FAILED);
1759
- Atomics.notify(append.state, 0);
1760
- append.settle(error);
1761
- }
1762
- };
1763
- created.on("error", fail);
1764
- created.on("exit", (code) => fail(/* @__PURE__ */ new Error(`Diagnostic writer exited (${code})`)));
1765
- created.unref();
1766
- worker = created;
1767
- return created;
1768
- }
1769
- var DiagnosticWriter = class {
1770
- pending = /* @__PURE__ */ new Set();
1771
- onFailure;
1772
- createDirectory;
1773
- constructor(onFailure, createDirectory = false) {
1774
- this.onFailure = onFailure;
1775
- this.createDirectory = createDirectory;
1776
- }
1777
- append(path, chunk) {
1778
- try {
1779
- const target = getWorker();
1780
- const state = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
1781
- const id = nextId++;
1782
- let resolve;
1783
- const done = new Promise((settle) => {
1784
- resolve = settle;
1785
- });
1786
- const append = {
1787
- id,
1788
- path,
1789
- chunk,
1790
- state,
1791
- worker: target,
1792
- done,
1793
- settle: (error) => {
1794
- if (!this.pending.delete(append)) return;
1795
- outstanding.delete(id);
1796
- const remaining = (counts.get(target) ?? 1) - 1;
1797
- if (remaining === 0) {
1798
- counts.delete(target);
1799
- target.unref();
1800
- } else counts.set(target, remaining);
1801
- if (error !== void 0) this.onFailure(path, error);
1802
- resolve();
1803
- }
1804
- };
1805
- this.pending.add(append);
1806
- outstanding.set(id, append);
1807
- counts.set(target, (counts.get(target) ?? 0) + 1);
1808
- target.ref();
1809
- try {
1810
- target.postMessage({
1811
- id,
1812
- path,
1813
- chunk,
1814
- state: state.buffer,
1815
- createDirectory: this.createDirectory
1816
- });
1817
- } catch (error) {
1818
- append.settle(error instanceof Error ? error : new Error(String(error)));
1819
- }
1820
- return done;
1821
- } catch (error) {
1822
- this.onFailure(path, error instanceof Error ? error : new Error(String(error)));
1823
- return Promise.resolve();
1824
- }
1825
- }
1826
- async written() {
1827
- await Promise.all([...this.pending].map((append) => append.done));
1828
- }
1829
- flushSync() {
1830
- for (const append of this.pending) {
1831
- let error;
1832
- if (Atomics.compareExchange(append.state, 0, QUEUED, CLAIMED) === QUEUED) {
1833
- try {
1834
- if (this.createDirectory) mkdirSync$1(dirname$1(append.path), { recursive: true });
1835
- appendFileSync(append.path, append.chunk);
1836
- Atomics.store(append.state, 0, LANDED);
1837
- } catch (cause) {
1838
- error = cause instanceof Error ? cause : new Error(String(cause));
1839
- Atomics.store(append.state, 0, FAILED);
1840
- }
1841
- Atomics.notify(append.state, 0);
1842
- } else while (Atomics.load(append.state, 0) === WRITING) Atomics.wait(append.state, 0, WRITING);
1843
- if (Atomics.load(append.state, 0) === FAILED) error ??= /* @__PURE__ */ new Error("Diagnostic append failed");
1844
- append.settle(error);
1845
- }
1846
- }
1847
- };
1848
- // dist/core/lifecycle-timings.js
1849
- const STATE_KEY = Symbol.for("@bastani/atomic/lifecycle-timings");
1850
- const globalWithLifecycleState = globalThis;
1851
- function getState() {
1852
- const existing = globalWithLifecycleState[STATE_KEY];
1853
- if (existing) return existing;
1854
- const created = {
1855
- sink: void 0,
1856
- clock: process.hrtime.bigint,
1857
- recorded: /* @__PURE__ */ new Set()
1858
- };
1859
- globalWithLifecycleState[STATE_KEY] = created;
1860
- return created;
1861
- }
1862
- /** True only when an internal diagnostic adapter has installed a synchronous sink. */
1863
- function isLifecycleTimingEnabled() {
1864
- return getState().sink !== void 0;
1865
- }
1866
- /**
1867
- * Install a process-local diagnostic sink.
1868
- *
1869
- * The sink must stay synchronous and must not write to the terminal. External
1870
- * ConPTY and TCP timestamps remain authoritative; these records only attribute
1871
- * time inside the process. Installing a sink resets the one-shot labels for a
1872
- * new diagnostic run. The returned function restores the previous adapter.
1873
- */
1874
- function installLifecycleTimingSink(sink, clock = process.hrtime.bigint) {
1875
- const state = getState();
1876
- const previousSink = state.sink;
1877
- const previousClock = state.clock;
1878
- const previousRecorded = new Set(state.recorded);
1879
- state.sink = sink;
1880
- state.clock = clock;
1881
- state.recorded.clear();
1882
- return () => {
1883
- state.sink = previousSink;
1884
- state.clock = previousClock;
1885
- state.recorded.clear();
1886
- for (const label of previousRecorded) state.recorded.add(label);
1887
- };
1888
- }
1889
- /** Record the first occurrence of a lifecycle boundary when diagnostics are active. */
1890
- function markLifecycleTiming(label) {
1891
- const state = getState();
1892
- const sink = state.sink;
1893
- if (!sink || state.recorded.has(label)) return;
1894
- state.recorded.add(label);
1895
- try {
1896
- sink({
1897
- label,
1898
- atNs: state.clock(),
1899
- pid: process.pid
1900
- });
1901
- } catch {}
1902
- }
1903
- /** Variables naming the startup trace file; `PI_` is the legacy alias, as for every Atomic variable. */
1904
- const STARTUP_TRACE_ENV_NAMES = ["ATOMIC_STARTUP_TRACE", "PI_STARTUP_TRACE"];
1905
- let traceWriter;
1906
- /**
1907
- * Write the trace lines still waiting for the writer's thread, once a quit has begun. Windows ends an isolated engine
1908
- * as soon as its host has the quit acknowledgement, without running exit handlers, so a line still waiting then would
1909
- * be lost. Does nothing when no trace is installed.
1910
- */
1911
- function flushLifecycleTraceAtQuit() {
1912
- getState().flushTrace?.();
1913
- }
1914
- /**
1915
- * When `ATOMIC_STARTUP_TRACE` names a file, append this process's start and each lifecycle mark to it, one JSON line
1916
- * each. A host and the engine child it starts inherit the variable, so one file holds both timelines. Lines are
1917
- * appended off the event loop in mark order; whatever has not reached the file when the process exits is written then.
1918
- * Does nothing when the variable is unset or another diagnostic sink is already installed. Returns the function that
1919
- * uninstalls it.
1920
- */
1921
- function installLifecycleTraceFromEnv(env = process.env) {
1922
- const file = STARTUP_TRACE_ENV_NAMES.map((name) => env[name]).find((value) => value !== void 0 && value !== "");
1923
- if (!file || getState().sink) return void 0;
1924
- const writer = new DiagnosticWriter(() => {});
1925
- traceWriter = writer;
1926
- const write = (label, epochMs) => {
1927
- const line = {
1928
- label,
1929
- epochMs,
1930
- pid: process.pid,
1931
- ppid: process.ppid
1932
- };
1933
- writer.append(file, `${JSON.stringify(line)}\n`);
1934
- };
1935
- const writeRemainingAtExit = () => writer.flushSync();
1936
- process.once("exit", writeRemainingAtExit);
1937
- const state = getState();
1938
- state.flushTrace = writeRemainingAtExit;
1939
- write("process-start", performance.timeOrigin);
1940
- const uninstallSink = installLifecycleTimingSink((record) => write(record.label, performance.timeOrigin + performance.now()));
1941
- return () => {
1942
- uninstallSink();
1943
- process.removeListener("exit", writeRemainingAtExit);
1944
- if (traceWriter === writer) traceWriter = void 0;
1945
- if (state.flushTrace === writeRemainingAtExit) state.flushTrace = void 0;
1946
- };
1947
- }
1948
- // dist/modes/interactive-engine/engine-heap.js
1949
- const MIB = 1048576;
1950
- const ENGINE_HEAP_SHARE_OF_SYSTEM_MEMORY = .5;
1951
- /**
1952
- * Options that set the size of V8's heap. Node applies a percentage of memory over an old space size, and V8 an old
1953
- * space size over a total heap size, which then still sizes the young generation.
1954
- */
1955
- const HEAP_SIZE_OPTIONS = /* @__PURE__ */ new Set([
1956
- "--max-old-space-size",
1957
- "--max-old-space-size-percentage",
1958
- "--max-heap-size"
1959
- ]);
1960
- /** The young generation's size, which adds to whichever heap size applies. */
1961
- const YOUNG_GENERATION_SIZE_OPTION = "--max-semi-space-size";
1962
- /** The heap options that are V8's own: V8 also reads them with one leading dash, which Node passes on to it. */
1963
- const V8_HEAP_OPTIONS = /* @__PURE__ */ new Set([
1964
- "--max-old-space-size",
1965
- "--max-heap-size",
1966
- YOUNG_GENERATION_SIZE_OPTION
1967
- ]);
1968
- /** The heap flags on a command line (`process.execArgv`). Node and V8 match `_` as `-` in an option's name. */
1969
- function commandLineHeapFlags(execArgv) {
1970
- const last = /* @__PURE__ */ new Map();
1971
- for (let index = 0; index < execArgv.length; index++) {
1972
- const flag = execArgv[index];
1973
- if (flag === "--") break;
1974
- if (!flag.startsWith("-")) continue;
1975
- const dashes = flag.startsWith("--") ? 2 : 1;
1976
- const equals = flag.indexOf("=");
1977
- const name = `--${(equals === -1 ? flag : flag.slice(0, equals)).slice(dashes).replaceAll("_", "-")}`;
1978
- if (!HEAP_SIZE_OPTIONS.has(name) && name !== YOUNG_GENERATION_SIZE_OPTION) continue;
1979
- if (dashes === 1 && !V8_HEAP_OPTIONS.has(name)) continue;
1980
- const value = execArgv[index + 1];
1981
- const valueFollows = equals === -1 && value !== void 0 && !value.startsWith("-");
1982
- last.delete(name);
1983
- last.set(name, valueFollows ? [flag, value] : [flag]);
1984
- if (valueFollows) index++;
1985
- }
1986
- return {
1987
- setsHeapSize: [...last.keys()].some((name) => HEAP_SIZE_OPTIONS.has(name)),
1988
- flags: [...last.values()].flat()
1989
- };
1990
- }
1991
- /** Whether a command line (`process.execArgv`) sets a heap size, which a process started with it keeps. */
1992
- function commandLineSetsHeapSize(execArgv) {
1993
- return commandLineHeapFlags(execArgv).setsHeapSize;
1994
- }
1995
- /**
1996
- * Node flags that size the interactive engine's V8 heap. The engine hosts every in-process subagent, so V8's default limit (about 4 GiB) caps the whole fleet regardless of machine size. Under Node the engine
1997
- * gets half of system memory, or of its container's memory limit when that is smaller, when this exceeds the
1998
- * current limit. A heap size given to Node (`--max-old-space-size`, `--max-old-space-size-percentage` or
1999
- * `--max-heap-size`) in `NODE_OPTIONS`, which the engine inherits, or on the host's own command line wins: the engine
2000
- * gets the host's command-line heap flags, the last one for each option, so that Node sizes its heap as it sized the
2001
- * host's. `ATOMIC_HEAP_MB` sets the size in MiB or, as `0`, turns automatic sizing off. A young generation size
2002
- * (`--max-semi-space-size`) on the host's command line goes to the engine in every case. Other runtimes do not use V8
2003
- * and get no flags.
2004
- */
2005
- function engineHeapRuntimeArgs(inputs) {
2006
- if (!inputs.runsOnNode) return [];
2007
- const host = commandLineHeapFlags(inputs.execArgv);
2008
- if (host.setsHeapSize) return [...host.flags];
2009
- const youngGeneration = [...host.flags];
2010
- if (nodeOptionsFromEnvironment(inputs.nodeOptions).some((option) => HEAP_SIZE_OPTIONS.has(option.name))) return youngGeneration;
2011
- const configured = inputs.configuredHeapMb?.trim();
2012
- if (configured) {
2013
- const heapMb = Number(configured);
2014
- if (Number.isSafeInteger(heapMb) && heapMb >= 0) return heapMb === 0 ? youngGeneration : [...youngGeneration, `--max-old-space-size=${heapMb}`];
2015
- }
2016
- const constrained = inputs.constrainedMemoryBytes;
2017
- const memoryBytes = constrained !== void 0 && constrained > 0 ? Math.min(inputs.totalMemoryBytes, constrained) : inputs.totalMemoryBytes;
2018
- const targetMb = Math.floor(memoryBytes * ENGINE_HEAP_SHARE_OF_SYSTEM_MEMORY / MIB);
2019
- return targetMb > Math.floor(inputs.currentHeapLimitBytes / MIB) ? [...youngGeneration, `--max-old-space-size=${targetMb}`] : youngGeneration;
2020
- }
2021
- function engineHeapRuntimeArgsForHost(runsOnNode) {
2022
- if (!runsOnNode) return [];
2023
- return engineHeapRuntimeArgs({
2024
- runsOnNode,
2025
- totalMemoryBytes: totalmem(),
2026
- constrainedMemoryBytes: process.constrainedMemory(),
2027
- currentHeapLimitBytes: getHeapStatistics().heap_size_limit,
2028
- nodeOptions: process.env.NODE_OPTIONS,
2029
- execArgv: process.execArgv,
2030
- configuredHeapMb: getEnvValue(ENV_HEAP_MB)
2031
- });
2032
- }
2033
- // dist/utils/compile-cache.js
2034
- var compile_cache_exports = /* @__PURE__ */ __exportAll({
2035
- COMPILE_CACHE_ENGINE_MATCH_HOST_ENV: () => COMPILE_CACHE_ENGINE_MATCH_HOST_ENV,
2036
- COMPILE_CACHE_ENGINE_WARMUP_ENV: () => COMPILE_CACHE_ENGINE_WARMUP_ENV,
2037
- compileCacheBaseDir: () => compileCacheBaseDir,
2038
- compileCacheBuildId: () => compileCacheBuildId,
2039
- compileCacheDeferral: () => compileCacheDeferral,
2040
- compileCacheHelperRuntime: () => compileCacheHelperRuntime,
2041
- compileCacheStartMode: () => compileCacheStartMode,
2042
- compileCacheWarmMarker: () => compileCacheWarmMarker,
2043
- currentCompileCacheWarmMarker: () => currentCompileCacheWarmMarker,
2044
- enablePersistentCompileCache: () => enablePersistentCompileCache,
2045
- engineCompileCacheResetHeapMb: () => engineCompileCacheResetHeapMb,
2046
- flushPersistentCompileCache: () => flushPersistentCompileCache,
2047
- hostAutoSizedEngineHeap: () => hostAutoSizedEngineHeap,
2048
- isCiValue: () => isCiValue,
2049
- startsCompileCacheHelper: () => startsCompileCacheHelper
2050
- });
2051
- const __atomicDistModuleUrl$2 = new URL("../utils/compile-cache.js", import.meta.url).href;
2052
- const compileCacheApi = nodeModule;
2053
- const COMPILE_CACHE_ENGINE_WARMUP_ENV = "ATOMIC_INTERNAL_COMPILE_CACHE_WARMUP";
2054
- const COMPILE_CACHE_ENGINE_MATCH_HOST_ENV = "ATOMIC_INTERNAL_COMPILE_CACHE_MATCH_HOST";
2055
- const ENGINE_WORKER_HEAP_MB_SYMBOL = /* @__PURE__ */ Symbol.for("atomic.engine-worker-heap-mb.v1");
2056
- function compileCacheStartMode(input) {
2057
- if (input.platform !== "win32" || input.runtimeIsBun || input.unsupported) return "enable";
2058
- if (input.alreadyEnabled || input.disabled || !input.interactive || !input.helperRuntime) return "enable";
2059
- return input.warm() ? "enable" : "defer";
2060
- }
2061
- function startsCompileCacheHelper(env) {
2062
- return !isCiValue(env.CI);
2063
- }
2064
- function isCiValue(value) {
2065
- if (value === void 0) return false;
2066
- const normalized = value.trim().toLowerCase();
2067
- return normalized !== "" && normalized !== "0" && normalized !== "false";
2068
- }
2069
- const HEAP_SIZE_FLAG = /^--max[-_]old[-_]space[-_]size=\d+$/;
2070
- const HEAP_SIZE_OPTION_NAMES = /* @__PURE__ */ new Set([
2071
- "--max-old-space-size",
2072
- "--max-old-space-size-percentage",
2073
- "--max-heap-size"
2074
- ]);
2075
- const V8_HEAP_SIZE_OPTION_NAMES = /* @__PURE__ */ new Set(["--max-old-space-size", "--max-heap-size"]);
2076
- const PRELOAD_FLAGS = /* @__PURE__ */ new Set([
2077
- "-r",
2078
- "--require",
2079
- "--import",
2080
- "--loader",
2081
- "--experimental-loader"
2082
- ]);
2083
- function flagsSetHeapSize(flags) {
2084
- for (const flag of flags) {
2085
- if (flag === "--") break;
2086
- if (!flag.startsWith("-")) continue;
2087
- const dashes = flag.startsWith("--") ? 2 : 1;
2088
- const equals = flag.indexOf("=");
2089
- const name = `--${(equals === -1 ? flag : flag.slice(0, equals)).slice(dashes).replaceAll("_", "-")}`;
2090
- if (!HEAP_SIZE_OPTION_NAMES.has(name)) continue;
2091
- if (dashes === 1 && !V8_HEAP_SIZE_OPTION_NAMES.has(name)) continue;
2092
- return true;
2093
- }
2094
- return false;
2095
- }
2096
- function parseAutoHeapMb(flag) {
2097
- if (!HEAP_SIZE_FLAG.test(flag)) return void 0;
2098
- const mb = Number(flag.slice(flag.indexOf("=") + 1));
2099
- return Number.isSafeInteger(mb) && mb > 0 ? mb : void 0;
2100
- }
2101
- function hostAutoSizedEngineHeap(hostExecArgv, nodeOptions, engineRuntimeArgs) {
2102
- if (flagsSetHeapSize(hostExecArgv)) return false;
2103
- const words = splitNodeOptions(nodeOptions ?? "");
2104
- if (!words || flagsSetHeapSize(words)) return false;
2105
- return engineRuntimeArgs.filter((flag) => parseAutoHeapMb(flag) !== void 0 && !hostExecArgv.includes(flag)).length === 1;
2106
- }
2107
- function engineCompileCacheResetHeapMb(input) {
2108
- if (input.runtimeIsBun || input.unsupported || input.alreadyEnabled || input.disabled || !input.matchHostTag) return;
2109
- const words = splitNodeOptions(input.nodeOptions ?? "");
2110
- if (!words || flagsSetHeapSize(words)) return void 0;
2111
- const heapValues = input.execArgv.map(parseAutoHeapMb).filter((mb) => mb !== void 0);
2112
- return heapValues.length === 1 ? heapValues[0] : void 0;
2113
- }
2114
- function keptFlags(flags) {
2115
- const kept = [];
2116
- for (let index = 0; index < flags.length; index++) {
2117
- const flag = flags[index];
2118
- if (HEAP_SIZE_FLAG.test(flag)) {
2119
- kept.push(flag);
2120
- continue;
2121
- }
2122
- const name = flag.includes("=") ? flag.slice(0, flag.indexOf("=")) : flag;
2123
- if (!PRELOAD_FLAGS.has(name)) return void 0;
2124
- if (!flag.includes("=")) index++;
2125
- }
2126
- return kept;
2127
- }
2128
- function compileCacheHelperRuntime(execArgv, env) {
2129
- if (env.NODE_V8_COVERAGE !== void 0) return void 0;
2130
- const words = splitNodeOptions(env.NODE_OPTIONS ?? "");
2131
- if (!words) return void 0;
2132
- const command = keptFlags(execArgv);
2133
- const options = keptFlags(words);
2134
- if (!command || !options) return void 0;
2135
- return {
2136
- execArgv: command,
2137
- nodeOptions: options.join(" ")
2138
- };
2139
- }
2140
- function compileCacheBuildId(build) {
2141
- let hash = 2166136261;
2142
- for (let index = 0; index < build.length; index++) {
2143
- hash ^= build.charCodeAt(index);
2144
- hash = Math.imul(hash, 16777619) >>> 0;
2145
- }
2146
- return hash.toString(16).padStart(8, "0");
2147
- }
2148
- function compileCacheBaseDir() {
2149
- return join$1(tmpdir(), "node-compile-cache");
2150
- }
2151
- function compileCacheWarmMarker(options) {
2152
- const tag = `${options.nodeVersion}-${options.arch}-${(options.versionTag >>> 0).toString(16).padStart(8, "0")}${options.uid === void 0 ? "" : `-${options.uid}`}`;
2153
- return join$1(options.baseDir, tag, `atomic-warm-${options.buildId}`);
2154
- }
2155
- function currentCompileCacheWarmMarker(buildId) {
2156
- return compileCacheWarmMarker({
2157
- baseDir: compileCacheBaseDir(),
2158
- nodeVersion: process.version,
2159
- arch: process.arch,
2160
- versionTag: cachedDataVersionTag(),
2161
- uid: typeof process.getuid === "function" ? process.getuid() : void 0,
2162
- buildId
2163
- });
2164
- }
2165
- let deferral;
2166
- function enablePersistentCompileCache(options = {}) {
2167
- try {
2168
- const runtimeIsBun = "bun" in process.versions;
2169
- const unsupported = typeof compileCacheApi.enableCompileCache !== "function";
2170
- const alreadyEnabled = compileCacheApi.getCompileCacheDir?.() !== void 0;
2171
- const disabled = process.env.NODE_DISABLE_COMPILE_CACHE !== void 0;
2172
- const resetHeapMb = engineCompileCacheResetHeapMb({
2173
- runtimeIsBun,
2174
- unsupported,
2175
- alreadyEnabled,
2176
- disabled,
2177
- matchHostTag: options.matchHostTag === true,
2178
- execArgv: process.execArgv,
2179
- nodeOptions: process.env.NODE_OPTIONS
2180
- });
2181
- if (resetHeapMb !== void 0) try {
2182
- const beforeTag = cachedDataVersionTag();
2183
- setFlagsFromString("--max-old-space-size=0");
2184
- if (cachedDataVersionTag() === beforeTag) setFlagsFromString(`--max-old-space-size=${resetHeapMb}`);
2185
- else globalThis[ENGINE_WORKER_HEAP_MB_SYMBOL] = resetHeapMb;
2186
- } catch {}
2187
- const runtime = compileCacheHelperRuntime(process.execArgv, process.env);
2188
- const buildId = compileCacheBuildId(`${__atomicDistModuleUrl$2}\0${options.build ?? ""}`);
2189
- if (compileCacheStartMode({
2190
- platform: process.platform,
2191
- runtimeIsBun,
2192
- unsupported,
2193
- alreadyEnabled,
2194
- disabled,
2195
- interactive: options.interactive === true && options.build !== void 0,
2196
- helperRuntime: runtime !== void 0,
2197
- warm: () => existsSync$1(currentCompileCacheWarmMarker(buildId))
2198
- }) === "defer" && runtime) {
2199
- deferral = {
2200
- buildId,
2201
- runtime,
2202
- helper: startsCompileCacheHelper(process.env)
2203
- };
2204
- return;
2205
- }
2206
- compileCacheApi.enableCompileCache?.();
2207
- } catch {}
2208
- }
2209
- function compileCacheDeferral() {
2210
- return deferral;
2211
- }
2212
- function flushPersistentCompileCache() {
2213
- try {
2214
- compileCacheApi.flushCompileCache?.();
2215
- } catch {}
2216
- }
2217
- // dist/utils/compile-cache-deferral.js
2218
- /**
2219
- * This process's compile-cache deferral (see `compile-cache.ts`), for the modules that load after the process's entry.
2220
- *
2221
- * `compile-cache.ts` loads with the entry (`cli.ts`), so a process that started before an update replaced the
2222
- * installation keeps the copy it started with while it loads later modules from the update. 0.10.3's copy has neither
2223
- * a deferral nor the engine warmup variable, and a named import of either would fail to link there; read through here,
2224
- * such a process is one that never deferred its cache, which it is.
2225
- */
2226
- const deferrals = compile_cache_exports;
2227
- /** The cache this process left cold for a helper, if any. */
2228
- function processCompileCacheDeferral() {
2229
- return deferrals.compileCacheDeferral?.();
2230
- }
2231
- /** The environment an engine child gets when this process leaves its cold cache to a helper that warms the engine's too. */
2232
- function engineCompileCacheWarmupEnv() {
2233
- const name = deferrals.COMPILE_CACHE_ENGINE_WARMUP_ENV;
2234
- return name !== void 0 && processCompileCacheDeferral() ? { [name]: "1" } : {};
2235
- }
2236
- /**
2237
- * The environment an auto-sized Node engine child gets so on Node 22 it aligns its compile-cache tag with the
2238
- * untouched host (#6222). Omitted on Bun or when the host itself passed an explicit heap size.
2239
- */
2240
- function engineCompileCacheMatchHostEnv(engineRuntimeArgs) {
2241
- if ("bun" in process.versions) return {};
2242
- const name = deferrals.COMPILE_CACHE_ENGINE_MATCH_HOST_ENV;
2243
- const check = deferrals.hostAutoSizedEngineHeap;
2244
- if (name === void 0 || check === void 0) return {};
2245
- return check(process.execArgv, process.env.NODE_OPTIONS, engineRuntimeArgs) ? { [name]: "1" } : {};
2246
- }
2247
- // dist/utils/compile-cache-warmup-host.js
2248
- var compile_cache_warmup_host_exports = /* @__PURE__ */ __exportAll({
2249
- compileCacheHelperLaunch: () => compileCacheHelperLaunch,
2250
- compileCacheWarmupRuntimes: () => compileCacheWarmupRuntimes,
2251
- decodeCompileCacheWarmupPlan: () => decodeCompileCacheWarmupPlan,
2252
- encodeCompileCacheWarmupPlan: () => encodeCompileCacheWarmupPlan,
2253
- startCompileCacheHelper: () => startCompileCacheHelper,
2254
- warmCompileCache: () => warmCompileCache
2255
- });
2256
- const __atomicDistModuleUrl$1 = new URL("../utils/compile-cache-warmup-host.js", import.meta.url).href;
2257
- function encodeCompileCacheWarmupPlan(plan) {
2258
- return Buffer.from(JSON.stringify(plan), "utf8").toString("base64url");
2259
- }
2260
- function decodeCompileCacheWarmupPlan(encoded) {
2261
- if (!encoded) return {
2262
- next: [],
2263
- required: []
2264
- };
2265
- const plan = JSON.parse(Buffer.from(encoded, "base64url").toString("utf8"));
2266
- return {
2267
- next: plan.next ?? [],
2268
- required: plan.required ?? []
2269
- };
2270
- }
2271
- function compileCacheHelperLaunch(runtime, buildId, script = fileURLToPath(new URL("./compile-cache-warmup.js", __atomicDistModuleUrl$1)), env = process.env, plan = {
2272
- next: [],
2273
- required: []
2274
- }) {
2275
- const helperEnv = { ...env };
2276
- if (runtime.nodeOptions) helperEnv.NODE_OPTIONS = runtime.nodeOptions;
2277
- else delete helperEnv.NODE_OPTIONS;
2278
- return {
2279
- command: process.execPath,
2280
- args: [
2281
- ...runtime.execArgv,
2282
- "--no-addons",
2283
- script,
2284
- buildId,
2285
- encodeCompileCacheWarmupPlan(plan)
2286
- ],
2287
- cwd: parse(script).root,
2288
- env: helperEnv,
2289
- detached: true
2290
- };
2291
- }
2292
- function startCompileCacheHelper(launch) {
2293
- try {
2294
- const child = spawn(launch.command, [...launch.args], {
2295
- cwd: launch.cwd,
2296
- env: launch.env,
2297
- detached: launch.detached,
2298
- stdio: "ignore",
2299
- windowsHide: true
2300
- });
2301
- child.on("error", () => {});
2302
- child.unref();
2303
- return true;
2304
- } catch {
2305
- return false;
2306
- }
2307
- }
2308
- let warmupStarted = false;
2309
- function compileCacheWarmupRuntimes(own, engineExecArgv) {
2310
- const engine = {
2311
- execArgv: engineExecArgv,
2312
- nodeOptions: own.nodeOptions
2313
- };
2314
- if (engine.execArgv.length === own.execArgv.length && engine.execArgv.every((arg, index) => arg === own.execArgv[index])) return [own];
2315
- const heapFlag = /^--max[-_]old[-_]space[-_]size=\d+$/;
2316
- return own.execArgv.length === 0 && !heapFlag.test(own.nodeOptions) && engine.execArgv.length === 1 && heapFlag.test(engine.execArgv[0]) ? [own] : [engine, own];
2317
- }
2318
- function warmCompileCache(engineExecArgv) {
2319
- const deferral = processCompileCacheDeferral();
2320
- if (!deferral?.helper || warmupStarted) return;
2321
- warmupStarted = true;
2322
- const [first, ...next] = compileCacheWarmupRuntimes(deferral.runtime, engineExecArgv);
2323
- startCompileCacheHelper(compileCacheHelperLaunch(first, deferral.buildId, void 0, void 0, {
2324
- next,
2325
- required: []
2326
- }));
2327
- }
2328
- // dist/utils/interactive-engine-bootstrap.js
2329
- /**
2330
- * Private startup channel for the isolated interactive engine.
2331
- *
2332
- * The engine child needs four control values (engine role, host PID, guardian
2333
- * path, and optionally an API key) before its runtime exists. They used to
2334
- * travel as environment variables, which cannot be taken back: under Bun a
2335
- * child spawned without an explicit `env` inherits the runtime's launch-time
2336
- * environment map, so deleting the variables from `process.env` afterwards does
2337
- * not stop arbitrary extension or hook code from leaking them — including the
2338
- * API key — into its own subprocesses.
2339
- *
2340
- * The engine is therefore launched with an environment that never contained the
2341
- * values, and the values travel in a 0600 file whose path is passed as a private
2342
- * CLI argument. The child reads it once, freezes the snapshot, and unlinks it.
2343
- * The filename carries no secret material.
2344
- *
2345
- * Cleanup is ownership-scoped. The path is untrusted child input — anyone can
2346
- * pass the private flag — so a reader may unlink only that exact file. Only the
2347
- * writer, which holds an {@link InteractiveEngineBootstrapHandle} for the
2348
- * directory it created, may remove that directory recursively.
2349
- */
2350
- const INTERACTIVE_ENGINE_BOOTSTRAP_FLAG = "--internal-engine-bootstrap";
2351
- /**
2352
- * The only argument of an engine child an interactive host starts before it knows the engine's arguments: the child
2353
- * loads the application, then reads them from its first stdin line (see engine-prewarm.ts).
2354
- */
2355
- const INTERACTIVE_ENGINE_PREWARM_FLAG = "--internal-engine-prewarm";
2356
- /**
2357
- * After the prewarm flag: the host runs `--no-session`, so the prewarmed engine opens no session database and starts no
2358
- * thread for one. Read only at process entry; the engine's own arguments arrive later.
2359
- */
2360
- const INTERACTIVE_ENGINE_PREWARM_NO_DATABASE = `${INTERACTIVE_ENGINE_PREWARM_FLAG}-no-database`;
2361
- async function writeInteractiveEngineBootstrapAsync(record) {
2362
- const directory = await mkdtemp(join$1(tmpdir(), "atomic-engine-bootstrap-"));
2363
- const path = join$1(directory, "bootstrap.json");
2364
- const tempPath = `${path}.tmp`;
2365
- const payload = {
2366
- version: 1,
2367
- ...record
2368
- };
2369
- try {
2370
- await writeFile(tempPath, JSON.stringify(payload), {
2371
- encoding: "utf8",
2372
- mode: 384
2373
- });
2374
- await rename(tempPath, path);
2375
- } catch (error) {
2376
- await rm(tempPath, { force: true }).catch(() => {});
2377
- await rm(directory, {
2378
- recursive: true,
2379
- force: true
2380
- }).catch(() => {});
2381
- throw error;
2382
- }
2383
- return {
2384
- path,
2385
- directory
2386
- };
2387
- }
2388
- async function removeOwnedInteractiveEngineBootstrapAsync(handle) {
2389
- if (!handle) return;
2390
- await rm(handle.directory, {
2391
- recursive: true,
2392
- force: true
2393
- }).catch(() => {});
2394
- }
2395
- /**
2396
- * Split the private bootstrap argument out of an argv slice.
2397
- *
2398
- * Returns the remaining arguments so normal CLI parsing never sees the flag.
2399
- */
2400
- function takeInteractiveEngineBootstrapArg(args) {
2401
- const remaining = [];
2402
- let path;
2403
- for (let index = 0; index < args.length; index += 1) {
2404
- const value = args[index];
2405
- if (value === "--internal-engine-bootstrap" && index + 1 < args.length) {
2406
- path = args[++index];
2407
- continue;
2408
- }
2409
- if (value.startsWith(`--internal-engine-bootstrap=`)) {
2410
- path = value.slice(28);
2411
- continue;
2412
- }
2413
- remaining.push(value);
2414
- }
2415
- return {
2416
- args: remaining,
2417
- path
2418
- };
2419
- }
2420
- /** True when this argv belongs to an isolated interactive engine child. */
2421
- function hasInteractiveEngineBootstrapArg(args) {
2422
- return takeInteractiveEngineBootstrapArg(args).path !== void 0;
2423
- }
2424
- /**
2425
- * Read and consume a bootstrap record.
2426
- *
2427
- * The named file is always unlinked, including on malformed content, so a stale
2428
- * API key never outlives the handshake. The path came from argv, so nothing
2429
- * around it is touched: no parent directory, no sibling.
2430
- */
2431
- function readInteractiveEngineBootstrap(path) {
2432
- let raw;
2433
- try {
2434
- raw = readFileSync$1(path, "utf8");
2435
- } catch {
2436
- return;
2437
- } finally {
2438
- rmSync$1(path, { force: true });
2439
- }
2440
- try {
2441
- const parsed = JSON.parse(raw);
2442
- if (parsed.version !== 1) return void 0;
2443
- if (typeof parsed.hostPid !== "number" || typeof parsed.guardFile !== "string") return void 0;
2444
- const trustDecisions = readTrustDecisions(parsed.trustDecisions);
2445
- const startupExtensionCheck = readStartupExtensionCheck(parsed.startupExtensionCheck);
2446
- return {
2447
- version: parsed.version,
2448
- hostPid: parsed.hostPid,
2449
- guardFile: parsed.guardFile,
2450
- ...typeof parsed.apiKey === "string" ? { apiKey: parsed.apiKey } : {},
2451
- ...trustDecisions ? { trustDecisions } : {},
2452
- ...parsed.projectResourceWithdrawals === true ? { projectResourceWithdrawals: true } : {},
2453
- ...startupExtensionCheck ? { startupExtensionCheck } : {},
2454
- ...parsed.queuedDeliveries === true ? { queuedDeliveries: true } : {},
2455
- ...typeof parsed.startedSessionId === "string" ? { startedSessionId: parsed.startedSessionId } : {}
2456
- };
2457
- } catch {
2458
- return;
2459
- }
2460
- }
2461
- /** The host's startup extension check of a bootstrap record, or undefined when it is missing or malformed. */
2462
- function readStartupExtensionCheck(value) {
2463
- if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
2464
- const { cwd, extensionsCanDecide } = value;
2465
- return typeof cwd === "string" && typeof extensionsCanDecide === "boolean" ? {
2466
- cwd,
2467
- extensionsCanDecide
2468
- } : void 0;
2469
- }
2470
- /** The trust decisions of a bootstrap record: only true or false values by path; anything else is left out. */
2471
- function readTrustDecisions(value) {
2472
- if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
2473
- const record = value;
2474
- const decisions = {
2475
- projects: readDecisions(record.projects),
2476
- extensionSources: readDecisions(record.extensionSources)
2477
- };
2478
- return Object.keys(decisions.projects).length + Object.keys(decisions.extensionSources).length > 0 ? decisions : void 0;
2479
- }
2480
- function readDecisions(value) {
2481
- const decisions = {};
2482
- if (typeof value !== "object" || value === null || Array.isArray(value)) return decisions;
2483
- for (const [path, trusted] of Object.entries(value)) if (typeof trusted === "boolean") decisions[path] = trusted;
2484
- return decisions;
2485
- }
2486
- // dist/utils/heap-relaunch.js
2487
- const HEAP_RELAUNCHED_ENV = "ATOMIC_INTERNAL_HEAP_RELAUNCHED";
2488
- /** Mirrors `resolveAppMode`: rpc, json and print modes, including print selected by piped input or output. */
2489
- function isHeadlessInvocation(args, terminal) {
2490
- if (args.includes("--internal-engine-bootstrap") || args.includes("--help") || args.includes("-h")) return false;
2491
- return args.some((arg, index) => arg === "-p" || arg === "--print" || arg === "--mode" && ["json", "rpc"].includes(args[index + 1] ?? "")) || !terminal.stdinIsTTY || !terminal.stdoutIsTTY;
2492
- }
2493
- /**
2494
- * Heap flags a headless run on Node should be relaunched with, or none. Interactive sessions size their engine
2495
- * child instead, and a process that was already relaunched or started with an explicit heap size keeps its own.
2496
- */
2497
- function headlessHeapRelaunchArgs(args) {
2498
- const terminal = {
2499
- stdinIsTTY: process.stdin.isTTY === true,
2500
- stdoutIsTTY: process.stdout.isTTY === true
2501
- };
2502
- if (process.env[HEAP_RELAUNCHED_ENV] !== void 0) {
2503
- delete process.env[HEAP_RELAUNCHED_ENV];
2504
- return [];
2505
- }
2506
- if (!isHeadlessInvocation(args, terminal) || commandLineSetsHeapSize(process.execArgv)) return [];
2507
- if ("bun" in process.versions) return [];
2508
- return engineHeapRuntimeArgs({
2509
- runsOnNode: true,
2510
- totalMemoryBytes: totalmem(),
2511
- constrainedMemoryBytes: process.constrainedMemory(),
2512
- currentHeapLimitBytes: getHeapStatistics().heap_size_limit,
2513
- nodeOptions: process.env.NODE_OPTIONS,
2514
- execArgv: [],
2515
- configuredHeapMb: getEnvValue(ENV_HEAP_MB)
2516
- });
2517
- }
2518
- /** Runs this CLI again with the heap flags, passing through stdio, termination signals and the exit status. */
2519
- function relaunchWithHeap(heapArgs, args) {
2520
- const child = spawn(process.execPath, [
2521
- ...heapArgs,
2522
- ...process.execArgv,
2523
- process.argv[1],
2524
- ...args
2525
- ], {
2526
- stdio: "inherit",
2527
- env: {
2528
- ...process.env,
2529
- [HEAP_RELAUNCHED_ENV]: "1"
2530
- }
2531
- });
2532
- for (const signal of [
2533
- "SIGINT",
2534
- "SIGTERM",
2535
- "SIGHUP"
2536
- ]) process.on(signal, () => child.kill(signal));
2537
- child.on("error", (error) => {
2538
- process.stderr.write(`Failed to start Atomic with a larger heap: ${error.message}\n`);
2539
- process.exit(1);
2540
- });
2541
- child.on("exit", (code, signal) => {
2542
- if (signal) {
2543
- process.removeAllListeners(signal);
2544
- process.kill(process.pid, signal);
2545
- return;
2546
- }
2547
- process.exit(code ?? 1);
2548
- });
2549
- }
2550
- // dist/utils/module-require.js
2551
- /**
2552
- * createRequire anchored so bare-specifier resolution works in every runtime.
2553
- *
2554
- * In the compiled binary the bundle is CJS (bytecode), where import.meta.url
2555
- * is rewritten to the original build-machine source path; requiring through it
2556
- * would resolve node_modules against paths that do not exist on user machines.
2557
- * Anchor to the executable instead so resolution walks from the node_modules
2558
- * shipped next to the binary.
2559
- */
2560
- function createModuleRequire(moduleUrl) {
2561
- return createRequire(resolutionBaseUrl(moduleUrl));
2562
- }
2563
- /**
2564
- * A resolution base URL safe for the current runtime.
2565
- *
2566
- * In compiled binaries (monolithic bun or the Atomic split launcher) the
2567
- * bundled `import.meta.url` is the build machine's source URL — a foreign-OS
2568
- * `file://` URL that `fileURLToPath` rejects on other platforms (notably a
2569
- * macOS `file:///Users/...` URL on Windows). Any API that decodes the base
2570
- * (`createRequire`, jiti's `createJiti`) then throws `ERR_INVALID_FILE_URL_PATH`.
2571
- * Anchor to the executable instead, which is always a valid local file URL.
2572
- */
2573
- function resolutionBaseUrl(moduleUrl) {
2574
- return isBunBinary ? pathToFileURL(process.execPath).href : moduleUrl;
2575
- }
2576
- // dist/utils/inherited-hangup.js
2577
- const __atomicDistModuleUrl = new URL("../utils/inherited-hangup.js", import.meta.url).href;
2578
- let hangupIgnored = false;
2579
- function noteInheritedHangup() {
2580
- if (process.platform === "win32" || !("bun" in process.versions)) return;
2581
- try {
2582
- hangupIgnored = createModuleRequire(__atomicDistModuleUrl)("@bastani/atomic-natives").signalIgnored?.(constants$1.signals.SIGHUP) === true;
2583
- } catch {}
2584
- if (hangupIgnored) process.on("SIGHUP", () => {});
2585
- }
2586
- function startedWithHangupIgnored() {
2587
- return hangupIgnored;
2588
- }
2589
- // dist/utils/interactive-invocation.js
2590
- /** Options and arguments that start something other than the plain interactive session, which has no engine. */
2591
- const NON_INTERACTIVE_FLAGS = /* @__PURE__ */ new Set([
2592
- "-p",
2593
- "--print",
2594
- "--mode",
2595
- "-h",
2596
- "--help",
2597
- "-v",
2598
- "--version",
2599
- "--export",
2600
- "--list-models"
2601
- ]);
2602
- /**
2603
- * Whether these arguments start the plain interactive session: a terminal on both ends and arguments that are only
2604
- * options (a subcommand or a prompt argument is never one), none of which selects another mode.
2605
- */
2606
- function isPlainInteractiveSessionInvocation(args, terminal) {
2607
- if (!terminal.stdinIsTTY || !terminal.stdoutIsTTY) return false;
2608
- if (args.length > 0 && !args[0].startsWith("-")) return false;
2609
- return !args.some((arg) => NON_INTERACTIVE_FLAGS.has(arg) || arg.startsWith("--internal-"));
2610
- }
2611
- // dist/utils/startup-prefetch.js
2612
- /** Options that make Node run code of the user's in every process it starts: a preload or a module loader. */
2613
- const USER_CODE_OPTIONS = /* @__PURE__ */ new Set([
2614
- "--require",
2615
- "-r",
2616
- "--import",
2617
- "--loader",
2618
- "--experimental-loader"
2619
- ]);
2620
- /**
2621
- * Reads the startup's files with this many in flight, on the reader process's own I/O pool, never this process's: four
2622
- * per CPU, from 4 to 32, so that on a machine with few CPUs the reader leaves them to Atomic's own start.
2623
- */
2624
- function readerThreads() {
2625
- return String(Math.min(32, Math.max(4, 4 * availableParallelism())));
2626
- }
2627
- /**
2628
- * The record, in the agent directory, that a reader read this installation's startup files (or found them already in
2629
- * memory) since the machine last started: `startup-prefetch-reader.ts` writes it.
2630
- */
2631
- const STARTUP_FILES_READ_MARKER = "startup-files-read.json";
2632
- /** How far two readings of when the machine last started may differ and still name the same start. */
2633
- const BOOT_TIME_TOLERANCE_MS = 1e4;
2634
- /** When the machine last started, from how long it has been running; the system clock moving changes it. */
2635
- function machineStartTimeMs() {
2636
- return Date.now() - uptime() * 1e3;
2637
- }
2638
- /**
2639
- * Whether a marker says this installation's startup files were read since the machine last started: its version, its
2640
- * installation and that start. A missing, unreadable or other marker says no.
2641
- */
2642
- function startupFilesReadThisStart(marker, version, install, startTimeMs) {
2643
- if (marker === void 0) return false;
2644
- try {
2645
- const read = JSON.parse(marker);
2646
- return read.version === version && read.install === install && typeof read.bootTimeMs === "number" && Math.abs(read.bootTimeMs - startTimeMs) <= BOOT_TIME_TOLERANCE_MS;
2647
- } catch {
2648
- return false;
2649
- }
2650
- }
2651
- /**
2652
- * Starts a short-lived process that reads the files this interactive session is about to load, many at once
2653
- * (`startup-prefetch-reader.ts`). On a cold start an antivirus scans each file when it is first opened, and the module
2654
- * loader opens them one at a time; read ahead in parallel, they are scanned in parallel. The reader only reads, ends
2655
- * when it is done, and ends with this process if this process ends first. Once it has read them (or found them in
2656
- * memory), it records so in the agent directory, and later starts until the machine restarts start no reader for this
2657
- * installation and version. Nothing starts in the standalone binary
2658
- * (one file), without the file list the build writes, when the package directory is overridden (it then names assets,
2659
- * not this installation's code), when the user sets Node's I/O pool size, or when the process runs a preload, a module
2660
- * loader or the permission model.
2661
- */
2662
- function startStartupPrefetch(packageDir) {
2663
- if (process.platform !== "win32" || process.versions.bun !== void 0 || isBunBinary) return;
2664
- if (process.permission !== void 0 || process.env.ATOMIC_PACKAGE_DIR || process.env.PI_PACKAGE_DIR) return;
2665
- if (process.env.UV_THREADPOOL_SIZE !== void 0) return;
2666
- if (startupNodeOptions().some((option) => USER_CODE_OPTIONS.has(option.name))) return;
2667
- const listPath = join$1(packageDir, "dist", "startup-files.json");
2668
- const readerPath = join$1(packageDir, "dist", "utils", "startup-prefetch-reader.js");
2669
- if (!existsSync$1(listPath) || !existsSync$1(readerPath)) return;
2670
- const marker = join$1(getAgentDir(), STARTUP_FILES_READ_MARKER);
2671
- let markerText;
2672
- try {
2673
- markerText = readFileSync$1(marker, "utf8");
2674
- } catch {}
2675
- if (startupFilesReadThisStart(markerText, VERSION, packageDir, machineStartTimeMs())) return;
2676
- try {
2677
- const reader = spawn(process.execPath, [
2678
- readerPath,
2679
- listPath,
2680
- packageDir,
2681
- marker,
2682
- VERSION
2683
- ], {
2684
- stdio: [
2685
- "pipe",
2686
- "ignore",
2687
- "ignore"
2688
- ],
2689
- windowsHide: true,
2690
- env: {
2691
- ...process.env,
2692
- UV_THREADPOOL_SIZE: readerThreads(),
2693
- NODE_OPTIONS: ""
2694
- }
2695
- });
2696
- try {
2697
- if (reader.pid !== void 0) setPriority(reader.pid, constants$1.priority.PRIORITY_BELOW_NORMAL);
2698
- } catch {}
2699
- reader.on("error", () => {});
2700
- reader.stdin?.on("error", () => {});
2701
- reader.unref();
2702
- reader.stdin?.unref?.();
2703
- const stop = () => {
2704
- if (reader.exitCode === null && reader.signalCode === null) reader.kill();
2705
- };
2706
- process.once("exit", stop);
2707
- reader.once("close", () => process.off("exit", stop));
2708
- } catch {}
2709
- }
2710
- // dist/utils/updated-install.js
2711
- /**
2712
- * A running process keeps every module it has loaded and loads the rest on demand from the installation on disk. An
2713
- * in-place update (`npm install -g` or `bun add -g` of a new version over this one) replaces those files while the
2714
- * process runs: a newer file that names an export the copy this process loaded lacks fails to link, and a file the
2715
- * update removed is gone. Neither can succeed until the process restarts, so code loaded on demand reports them as such.
2716
- * A module of anything else, such as a user's extension, that cannot load keeps its own error: a restart would not
2717
- * change it.
2718
- */
2719
- /** A feature whose code could not load because the installation changed under this process. */
2720
- var UpdatedInstallError = class extends Error {
2721
- feature;
2722
- constructor(message, feature, cause) {
2723
- super(message, { cause });
2724
- this.name = "UpdatedInstallError";
2725
- this.feature = feature;
2726
- }
2727
- };
2728
- /** Node's and Bun's link errors: an import names an export its dependency lacks. */
2729
- const LINK_FAILURE = /does not provide an export named|Export named '[^']*' not found in module|Named export '[^']*' not found|^export '[^']*' not found in '/;
2730
- const LOAD_FAILURE_CODES = /* @__PURE__ */ new Set([
2731
- "ERR_MODULE_NOT_FOUND",
2732
- "MODULE_NOT_FOUND",
2733
- "ERR_PACKAGE_PATH_NOT_EXPORTED"
2734
- ]);
2735
- /**
2736
- * Bun, for a module file that went away after it read the file's directory: a `BuildMessage` with no code, naming the
2737
- * file it could not read.
2738
- */
2739
- const BUN_MISSING_FILE = /^ENOENT reading "(.+)"$/;
2740
- /** Atomic's own packages, by name or installed (a package manager that hoists dependencies, Bun, puts them beside it). */
2741
- const OWN_PACKAGE = /^@bastani\/atomic(?:-(?:ai|tui|agent-core|codemode|schema|telemetry|natives))?(?:\/|$)|[\\/]node_modules[\\/]@bastani[\\/]atomic(?:-(?:ai|tui|agent-core|codemode|schema|telemetry|natives))?[\\/]/;
2742
- /**
2743
- * Whether `error` is the runtime failing to load a module: one that names an export its dependency lacks (Node and Bun
2744
- * report a `SyntaxError` when they link it), or one that is not there (a removed file, package or package export).
2745
- */
2746
- function isModuleLoadFailure(error) {
2747
- if (typeof error !== "object" || error === null) return false;
2748
- const { code, message, name } = error;
2749
- if (typeof code === "string" && LOAD_FAILURE_CODES.has(code)) return true;
2750
- if (name === "BuildMessage" && typeof message === "string" && BUN_MISSING_FILE.test(message)) return true;
2751
- return error instanceof SyntaxError && typeof message === "string" && LINK_FAILURE.test(message);
2752
- }
2753
- /** The module `request` names when `importer` asks for it: a file path, or the package name of a bare request. */
2754
- function requested(request, importer) {
2755
- if (!request.startsWith(".") && !request.startsWith("/") && !request.startsWith("file:") && !isAbsolute$1(request)) return OWN_PACKAGE.test(request) || importer === void 0 ? request : importer;
2756
- if (request.startsWith("file:") || isAbsolute$1(request)) return request;
2757
- if (importer === void 0) return request;
2758
- const from = importer.startsWith("file:") ? fileURLToPath(importer) : importer;
2759
- return resolve$1(dirname$1(from), request);
2760
- }
2761
- /**
2762
- * Whose module could not load, as the error tells it: the missing file itself, the package a module asked for (or,
2763
- * for a package that is not Atomic's own, the module that asked), or the module whose import fails to link (Bun names
2764
- * the module that lacks the export instead). Undefined when the error does not say.
2765
- */
2766
- function failedLoadLocation(error) {
2767
- const message = typeof error.message === "string" ? error.message : "";
2768
- if (typeof error.url === "string") return error.url;
2769
- if (error.name === "BuildMessage") return BUN_MISSING_FILE.exec(message)?.[1];
2770
- if (typeof error.referrer === "string" && typeof error.specifier === "string") return requested(error.specifier, error.referrer);
2771
- if (Array.isArray(error.requireStack)) {
2772
- const request = /Cannot find module '([^']+)'/.exec(message)?.[1];
2773
- const importer = typeof error.requireStack[0] === "string" ? error.requireStack[0] : void 0;
2774
- return request === void 0 ? importer : requested(request, importer);
2775
- }
2776
- const exportsMap = / is not defined by "exports" in (.+?package\.json)/.exec(message)?.[1];
2777
- if (exportsMap !== void 0) return exportsMap;
2778
- const missing = /Cannot find (?:module|package) '([^']+)' imported from (.+)$/m.exec(message);
2779
- if (missing) return requested(missing[1], missing[2]);
2780
- const linking = typeof error.stack === "string" ? /^(file:\/\/\S+?):\d+$/m.exec(error.stack)?.[1] : void 0;
2781
- if (linking !== void 0) return linking;
2782
- return /not found in module '([^']+)'|^export '[^']*' not found in '([^']+)'/.exec(message)?.slice(1).find(Boolean);
2783
- }
2784
- /** Whether `location`, a path, a file URL or a package name, is part of the installation this process runs from. */
2785
- function partOfInstallation(location) {
2786
- if (OWN_PACKAGE.test(location)) return true;
2787
- let path;
2788
- try {
2789
- path = location.startsWith("file:") ? fileURLToPath(location) : location;
2790
- } catch {
2791
- return false;
2792
- }
2793
- if (!isAbsolute$1(path)) return false;
2794
- const inside = relative$1(getPackageDir(), resolve$1(path));
2795
- return inside !== "" && !inside.startsWith("..") && !isAbsolute$1(inside);
2796
- }
2797
- /** Whether `error` is a module of the installation that could not load (see {@link isModuleLoadFailure}). */
2798
- function isInstallationLoadFailure(error) {
2799
- if (!isModuleLoadFailure(error)) return false;
2800
- const location = failedLoadLocation(error);
2801
- return location !== void 0 && partOfInstallation(location);
2802
- }
2803
- /**
2804
- * What a failed on-demand load of `feature` says when `change` happened to the installation since this process
2805
- * started: that it needs a restart, then the runtime's error. Undefined when the failure is not a module of the
2806
- * installation that could not load, or the installation did not change.
2807
- */
2808
- function updatedInstallMessage(error, feature, change) {
2809
- if (change === void 0 || !isInstallationLoadFailure(error)) return void 0;
2810
- const restart = change.kind === "updated" ? `${APP_NAME} was updated to ${change.version} while this session was running; restart it to keep using ${feature}.` : `The ${APP_NAME} installation this session runs from was removed or replaced; restart it to keep using ${feature}.`;
2811
- const { message } = error;
2812
- return typeof message === "string" && message !== "" ? `${restart}\n${message}` : restart;
2813
- }
2814
- /**
2815
- * The {@link UpdatedInstallError} a failed on-demand load of `feature` becomes when it failed because an update replaced
2816
- * the installation under this process; undefined when it failed for any other reason.
2817
- */
2818
- async function updatedInstallError(error, feature) {
2819
- if (error instanceof UpdatedInstallError) return error;
2820
- if (!isInstallationLoadFailure(error)) return void 0;
2821
- const message = updatedInstallMessage(error, feature, await detectInstallChangeAsync());
2822
- return message === void 0 ? void 0 : new UpdatedInstallError(message, feature, error);
2823
- }
2824
- /**
2825
- * Run `load`, which loads code of `feature` on demand (directly or anywhere inside it). A module of the installation
2826
- * that cannot load because an update replaced the installation while this process runs rejects with an
2827
- * {@link UpdatedInstallError} naming `feature`; every other outcome is `load`'s own.
2828
- */
2829
- async function loadOnDemand(feature, load) {
2830
- try {
2831
- return await load();
2832
- } catch (error) {
2833
- throw await updatedInstallError(error, feature) ?? error;
2834
- }
2835
- }
2836
- export { APP_NAME, APP_TITLE, ATOMIC_AI_AGENT, BLUEPRINT_FILE_NAME, BUILTIN_PACKAGE_DIR_NAMES, CHANGELOG_URL, COMPILE_CACHE_ENGINE_MATCH_HOST_ENV, COMPILE_CACHE_ENGINE_WARMUP_ENV, CONFIG_DIR_NAME, CONFIG_DIR_NAMES, DebugConfigError, DebugError, DebugLogUnwritableError, DiagnosticWriter, ENV_AGENT_DIR, ENV_CLEAR_ON_SHRINK, ENV_CLIPBOARD_OSC52, ENV_CODEMODE_MAX_WORKERS, ENV_DEBUG, ENV_HARDWARE_CURSOR, ENV_HEAP_MB, ENV_MODEL_CATALOG_URL, ENV_OFFLINE, ENV_PACKAGE_DIR, ENV_SELF_UPDATE_COMMAND, ENV_SESSION_DIR, ENV_SHARE_VIEWER_URL, ENV_SKIP_VERSION_CHECK, ENV_STARTUP_BENCHMARK, ENV_STDIN_TIMEOUT_MS, ENV_TELEMETRY, ENV_TIMING, INSTALLED_EXTENSION_ENTRIES, INTERACTIVE_ENGINE_BOOTSTRAP_FLAG, INTERACTIVE_ENGINE_PREWARM_FLAG, INTERACTIVE_ENGINE_PREWARM_NO_DATABASE, LEGACY_CONFIG_DIR_NAME, LEGACY_ENV_PREFIX, NATIVES_VERSION, PACKAGE_NAME, SOURCE_EXTENSION_ENTRIES, UpdatedInstallError, VERSION, VERSION_ADOPTION_ENDPOINT, addHostStorageAdapter, canonicalizePath$1 as canonicalizePath, canonicalizePathAsync$1 as canonicalizePathAsync, compileCacheDeferral, compileCacheHelperLaunch, compileCacheWarmupRuntimes, compile_cache_warmup_host_exports, createChildProcessEnvironment, createModuleRequire, createSessionCwdMatcher, createSessionCwdMatcherAsync$1 as createSessionCwdMatcherAsync, decodeCompileCacheWarmupPlan, detectInstallChange, detectInstallChangeAsync, detectInstallMethod, enablePersistentCompileCache, encodeCompileCacheWarmupPlan, engineCompileCacheMatchHostEnv, engineCompileCacheWarmupEnv, engineHeapRuntimeArgsForHost, expandTildePath, findHelperExecutable, findHelperExecutableAsync, flushLifecycleTraceAtQuit, flushPersistentCompileCache, formatPathRelativeToCwdOrAbsolute, getAgentConfigPaths, getAgentDir, getAgentDirs, getAuthPath, getBinDir, getBlueprintActionsDir, getBundledInteractiveAssetPath, getBundledInteractiveAssetPathAsync, getChangelogPath, getCodemodeWorkerUrl, getCodemodeWorkerUrlAsync, getConfiguredSelfUpdateArgv, getCustomThemesDir, getCwdRelativePath, getDebugLogPath, getDocsPath, getEnvNames, getEnvValue, getExamplesPath, getExportTemplateDir, getExportTemplateDirAsync, getExtensionTranspileCacheDir, getGlobalBlueprintPath, getHomeDir, getInteractiveAssetsDir, getLegacyAgentDir, getModelsConfigPaths, getModelsPath, getPackageDir, getPackageJsonPath, getPathComparisonKey, getProjectBlueprintPath, getProjectConfigDirs, getProjectConfigPaths, getPromptsDir, getQuickJSWasmPath, getReadmePath, getSelfUpdateCommand, getSelfUpdateUnavailableInstruction, getSessionsDir, getSettingsPath, getShareViewerUrl, getThemesDir, getToolsDir, getUpdateInstruction, getUserConfigDirs, getUserConfigPaths, hasEnvValue, hasInteractiveEngineBootstrapArg, headlessHeapRelaunchArgs, helperLaunch, helperLaunchAsync, hostStorageAdapter, inheritsDebugSetting, installLifecycleTraceFromEnv, isBunBinary, isBunRuntime, isBundledBuild, isDebugConfigError, isDebugError, isDebugLogUnwritableError, isDebugSettingOn, isHeadlessInvocation, isLifecycleTimingEnabled, isLocalPath, isModuleLoadFailure, isPathWithin, isPlainInteractiveSessionInvocation, loadOnDemand, makeConfiguredSelfUpdateCommand, markLifecycleTiming, markPathIgnoredByCloudSync, missingHelperOptions, moduleDirFromMetaUrl, normalizePath, noteInheritedHangup, onDebugSettingChange, pathsEqual, processCompileCacheDeferral, processLaunch, processLaunchAsync, readInteractiveEngineBootstrap, rehydrateDebugError, relaunchWithHeap, removeOwnedInteractiveEngineBootstrapAsync, require_cross_spawn, requiredEntriesForBuiltin, resolutionBaseUrl, resolvePath, serializeDebugError, setDebugSetting, setEnvValue, shortenHomePath, spawnLaunchedProcess, spawnLaunchedProcessSync, spawnProcess, splitBom, startCompileCacheHelper, startStartupPrefetch, startedWithHangupIgnored, stripBom, takeInteractiveEngineBootstrapArg, updatedInstallError, waitForChildProcess, warmCompileCache, writeInteractiveEngineBootstrapAsync };
2837
-
2838
- //# sourceMappingURL=p0-cli-GUFK7TPN.js.map
1
+ export { APP_NAME, APP_TITLE, ATOMIC_AI_AGENT, BLUEPRINT_FILE_NAME, BUILTIN_PACKAGE_DIR_NAMES, CHANGELOG_URL, COMPILE_CACHE_ENGINE_MATCH_HOST_ENV, COMPILE_CACHE_ENGINE_WARMUP_ENV, CONFIG_DIR_NAME, CONFIG_DIR_NAMES, DebugConfigError, DebugError, DebugLogUnwritableError, DiagnosticWriter, ENV_AGENT_DIR, ENV_CLEAR_ON_SHRINK, ENV_CLIPBOARD_OSC52, ENV_CODEMODE_MAX_WORKERS, ENV_DEBUG, ENV_HARDWARE_CURSOR, ENV_HEAP_MB, ENV_MODEL_CATALOG_URL, ENV_OFFLINE, ENV_PACKAGE_DIR, ENV_SELF_UPDATE_COMMAND, ENV_SESSION_DIR, ENV_SHARE_VIEWER_URL, ENV_SKIP_VERSION_CHECK, ENV_STARTUP_BENCHMARK, ENV_STDIN_TIMEOUT_MS, ENV_TELEMETRY, ENV_TIMING, INSTALLED_EXTENSION_ENTRIES, INTERACTIVE_ENGINE_BOOTSTRAP_FLAG, INTERACTIVE_ENGINE_PREWARM_FLAG, INTERACTIVE_ENGINE_PREWARM_NO_DATABASE, LEGACY_CONFIG_DIR_NAME, LEGACY_ENV_PREFIX, NATIVES_VERSION, PACKAGE_NAME, SOURCE_EXTENSION_ENTRIES, UpdatedInstallError, VERSION, VERSION_ADOPTION_ENDPOINT, addHostStorageAdapter, canonicalizePath, canonicalizePathAsync, compileCacheDeferral, compileCacheHelperLaunch, compileCacheWarmupRuntimes, compile_cache_warmup_host_exports, createChildProcessEnvironment, createModuleRequire, createSessionCwdMatcher, createSessionCwdMatcherAsync, decodeCompileCacheWarmupPlan, detectInstallChange, detectInstallChangeAsync, detectInstallMethod, enablePersistentCompileCache, encodeCompileCacheWarmupPlan, engineCompileCacheMatchHostEnv, engineCompileCacheWarmupEnv, engineHeapRuntimeArgsForHost, expandTildePath, findHelperExecutable, findHelperExecutableAsync, flushLifecycleTraceAtQuit, flushPersistentCompileCache, formatPathRelativeToCwdOrAbsolute, getAgentConfigPaths, getAgentDir, getAgentDirs, getAuthPath, getBinDir, getBlueprintActionsDir, getBundledInteractiveAssetPath, getBundledInteractiveAssetPathAsync, getChangelogPath, getCodemodeWorkerUrl, getCodemodeWorkerUrlAsync, getConfiguredSelfUpdateArgv, getCustomThemesDir, getCwdRelativePath, getDebugLogPath, getDocsPath, getEnvNames, getEnvValue, getExamplesPath, getExportTemplateDir, getExportTemplateDirAsync, getExtensionTranspileCacheDir, getGlobalBlueprintPath, getHomeDir, getInteractiveAssetsDir, getLegacyAgentDir, getModelsConfigPaths, getModelsPath, getPackageDir, getPackageJsonPath, getPathComparisonKey, getProjectBlueprintPath, getProjectConfigDirs, getProjectConfigPaths, getPromptsDir, getQuickJSWasmPath, getReadmePath, getSelfUpdateCommand, getSelfUpdateUnavailableInstruction, getSessionsDir, getSettingsPath, getShareViewerUrl, getThemesDir, getToolsDir, getUpdateInstruction, getUserConfigDirs, getUserConfigPaths, hasEnvValue, hasInteractiveEngineBootstrapArg, headlessHeapRelaunchArgs, helperLaunch, helperLaunchAsync, hostStorageAdapter, inheritsDebugSetting, installLifecycleTraceFromEnv, isBunBinary, isBunRuntime, isBundledBuild, isDebugConfigError, isDebugError, isDebugLogUnwritableError, isDebugSettingOn, isHeadlessInvocation, isLifecycleTimingEnabled, isLocalPath, isModuleLoadFailure, isPathWithin, isPlainInteractiveSessionInvocation, loadOnDemand, makeConfiguredSelfUpdateCommand, markLifecycleTiming, markPathIgnoredByCloudSync, missingHelperOptions, moduleDirFromMetaUrl, normalizePath, noteInheritedHangup, onDebugSettingChange, pathsEqual, processCompileCacheDeferral, processLaunch, processLaunchAsync, readInteractiveEngineBootstrap, rehydrateDebugError, relaunchWithHeap, removeOwnedInteractiveEngineBootstrapAsync, require_cross_spawn, requiredEntriesForBuiltin, resolutionBaseUrl, resolvePath, serializeDebugError, setDebugSetting, setEnvValue, shortenHomePath, spawnLaunchedProcess, spawnLaunchedProcessSync, spawnProcess, splitBom, startCompileCacheHelper, startStartupPrefetch, startedWithHangupIgnored, stripBom, takeInteractiveEngineBootstrapArg, updatedInstallError, waitForChildProcess, warmCompileCache, writeInteractiveEngineBootstrapAsync } from "./p0-cli-BB45ZQY6.js";
2
+ //# sourceMappingURL=p0-cli-GUFK7TPN.js.map