@ashx-j/lunr-dev 0.2.19-dev.10.1 → 0.2.25-dev.13.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 (690) hide show
  1. package/CHANGELOG.md +60 -2
  2. package/README.md +2 -2
  3. package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
  4. package/dist/builtin-extensions/ashxj-tui.js +2 -2
  5. package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
  6. package/dist/builtin-extensions/index.d.ts.map +1 -1
  7. package/dist/builtin-extensions/index.js +1 -2
  8. package/dist/builtin-extensions/index.js.map +1 -1
  9. package/dist/builtin-extensions/lunr-browser.d.ts +9 -0
  10. package/dist/builtin-extensions/lunr-browser.d.ts.map +1 -0
  11. package/dist/builtin-extensions/lunr-browser.js +169 -0
  12. package/dist/builtin-extensions/lunr-browser.js.map +1 -0
  13. package/dist/builtin-extensions/lunr-computer-use.d.ts.map +1 -1
  14. package/dist/builtin-extensions/lunr-computer-use.js +15 -14
  15. package/dist/builtin-extensions/lunr-computer-use.js.map +1 -1
  16. package/dist/builtin-extensions/lunr-plan-tools.d.ts +7 -7
  17. package/dist/builtin-extensions/lunr-plan-tools.d.ts.map +1 -1
  18. package/dist/builtin-extensions/lunr-plan-tools.js +12 -12
  19. package/dist/builtin-extensions/lunr-plan-tools.js.map +1 -1
  20. package/dist/builtin-extensions/lunr-todos.d.ts +6 -5
  21. package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
  22. package/dist/builtin-extensions/lunr-todos.js +24 -7
  23. package/dist/builtin-extensions/lunr-todos.js.map +1 -1
  24. package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts +6 -4
  25. package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts.map +1 -1
  26. package/dist/builtin-extensions/pi-intercom/broker/spawn.js +114 -61
  27. package/dist/builtin-extensions/pi-intercom/broker/spawn.js.map +1 -1
  28. package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
  29. package/dist/builtin-extensions/pi-intercom/index.js +365 -351
  30. package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
  31. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -1
  32. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js +1 -0
  33. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -1
  34. package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
  35. package/dist/builtin-extensions/pi-mcp-adapter/index.js +1 -1
  36. package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
  37. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts +1 -1
  38. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts.map +1 -1
  39. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js +5 -1
  40. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js.map +1 -1
  41. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts.map +1 -1
  42. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js +2 -2
  43. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js.map +1 -1
  44. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +9 -7
  45. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  46. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +143 -59
  47. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  48. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts +18 -8
  49. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
  50. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +39 -14
  51. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
  52. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +5 -3
  53. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
  54. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +32 -17
  55. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
  56. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.d.ts +17 -0
  57. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.d.ts.map +1 -0
  58. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.js +45 -0
  59. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.js.map +1 -0
  60. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts +2 -0
  61. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts.map +1 -1
  62. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js +10 -14
  63. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js.map +1 -1
  64. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +12 -2
  65. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
  66. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +401 -58
  67. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
  68. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts +1 -0
  69. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts.map +1 -1
  70. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js +1 -1
  71. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js.map +1 -1
  72. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts +29 -0
  73. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts.map +1 -0
  74. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js +184 -0
  75. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js.map +1 -0
  76. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts +91 -0
  77. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts.map +1 -0
  78. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js +542 -0
  79. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js.map +1 -0
  80. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +13 -1
  81. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
  82. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +42 -12
  83. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
  84. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts.map +1 -1
  85. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js +3 -2
  86. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js.map +1 -1
  87. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts +2 -1
  88. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts.map +1 -1
  89. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js +35 -8
  90. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js.map +1 -1
  91. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts +1 -0
  92. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts.map +1 -1
  93. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js +2 -1
  94. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js.map +1 -1
  95. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +7 -3
  96. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
  97. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +26 -4
  98. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
  99. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts +1 -0
  100. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -1
  101. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +55 -38
  102. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js.map +1 -1
  103. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +100 -0
  104. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
  105. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +47 -32
  106. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
  107. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +6 -6
  108. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
  109. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +75 -5
  110. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
  111. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts +15 -2
  112. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts.map +1 -1
  113. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js +14 -4
  114. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js.map +1 -1
  115. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
  116. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +43 -4
  117. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
  118. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts +1 -0
  119. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
  120. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +26 -9
  121. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
  122. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
  123. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +4 -3
  124. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
  125. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +0 -1
  126. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  127. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +94 -25
  128. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  129. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts +2 -0
  130. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts.map +1 -1
  131. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js +75 -18
  132. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js.map +1 -1
  133. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts +1 -1
  134. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts.map +1 -1
  135. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js +1 -1
  136. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js.map +1 -1
  137. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts +1 -1
  138. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts.map +1 -1
  139. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js +1 -1
  140. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js.map +1 -1
  141. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +13 -1
  142. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
  143. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +67 -11
  144. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
  145. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +1 -0
  146. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
  147. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -1
  148. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +5 -0
  149. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
  150. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +25 -15
  151. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
  152. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts +1 -0
  153. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts.map +1 -1
  154. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js +3 -0
  155. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js.map +1 -1
  156. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
  157. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +17 -5
  158. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
  159. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts +2 -2
  160. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts.map +1 -1
  161. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js +5 -10
  162. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js.map +1 -1
  163. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.d.ts +2 -0
  164. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.d.ts.map +1 -0
  165. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.js +3 -0
  166. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.js.map +1 -0
  167. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts +3 -0
  168. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -1
  169. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +70 -13
  170. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -1
  171. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts +12 -1
  172. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts.map +1 -1
  173. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js +21 -2
  174. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js.map +1 -1
  175. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +23 -4
  176. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
  177. package/dist/builtin-extensions/pi-subagents/src/shared/types.js +1 -1
  178. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
  179. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.d.ts.map +1 -1
  180. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.js.map +1 -1
  181. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts +7 -0
  182. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
  183. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +11 -7
  184. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
  185. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +6 -0
  186. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
  187. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +46 -29
  188. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
  189. package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts +18 -0
  190. package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts.map +1 -0
  191. package/dist/builtin-extensions/pi-subagents/src/tui/communication.js +48 -0
  192. package/dist/builtin-extensions/pi-subagents/src/tui/communication.js.map +1 -0
  193. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +46 -4
  194. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
  195. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +407 -450
  196. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
  197. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts.map +1 -1
  198. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js +1 -1
  199. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js.map +1 -1
  200. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts +2 -13
  201. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts.map +1 -1
  202. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js +5 -91
  203. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js.map +1 -1
  204. package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
  205. package/dist/builtin-extensions/pi-web-access/index.js +11 -7
  206. package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
  207. package/dist/cli/args.d.ts.map +1 -1
  208. package/dist/cli/args.js +2 -1
  209. package/dist/cli/args.js.map +1 -1
  210. package/dist/cli/install-cli.d.ts.map +1 -1
  211. package/dist/cli/install-cli.js +15 -45
  212. package/dist/cli/install-cli.js.map +1 -1
  213. package/dist/core/agent-session-runtime.d.ts +9 -0
  214. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  215. package/dist/core/agent-session-runtime.js +126 -29
  216. package/dist/core/agent-session-runtime.js.map +1 -1
  217. package/dist/core/agent-session.d.ts +23 -1
  218. package/dist/core/agent-session.d.ts.map +1 -1
  219. package/dist/core/agent-session.js +255 -109
  220. package/dist/core/agent-session.js.map +1 -1
  221. package/dist/core/browser/network.d.ts +9 -0
  222. package/dist/core/browser/network.d.ts.map +1 -0
  223. package/dist/core/browser/network.js +146 -0
  224. package/dist/core/browser/network.js.map +1 -0
  225. package/dist/core/browser/runtime.d.ts +24 -0
  226. package/dist/core/browser/runtime.d.ts.map +1 -0
  227. package/dist/core/browser/runtime.js +289 -0
  228. package/dist/core/browser/runtime.js.map +1 -0
  229. package/dist/core/browser/schema.d.ts +16 -0
  230. package/dist/core/browser/schema.d.ts.map +1 -0
  231. package/dist/core/browser/schema.js +36 -0
  232. package/dist/core/browser/schema.js.map +1 -0
  233. package/dist/core/browser/settings.d.ts +8 -0
  234. package/dist/core/browser/settings.d.ts.map +1 -0
  235. package/dist/core/browser/settings.js +30 -0
  236. package/dist/core/browser/settings.js.map +1 -0
  237. package/dist/core/browser/setup.d.ts +2 -0
  238. package/dist/core/browser/setup.d.ts.map +1 -0
  239. package/dist/core/browser/setup.js +16 -0
  240. package/dist/core/browser/setup.js.map +1 -0
  241. package/dist/core/catalog-cache-scope.d.ts.map +1 -1
  242. package/dist/core/catalog-cache-scope.js +3 -1
  243. package/dist/core/catalog-cache-scope.js.map +1 -1
  244. package/dist/core/computer-use/image.d.ts +27 -0
  245. package/dist/core/computer-use/image.d.ts.map +1 -0
  246. package/dist/core/computer-use/image.js +72 -0
  247. package/dist/core/computer-use/image.js.map +1 -0
  248. package/dist/core/computer-use/policy.d.ts.map +1 -1
  249. package/dist/core/computer-use/policy.js +2 -6
  250. package/dist/core/computer-use/policy.js.map +1 -1
  251. package/dist/core/computer-use/schemas.d.ts +14 -10
  252. package/dist/core/computer-use/schemas.d.ts.map +1 -1
  253. package/dist/core/computer-use/schemas.js +27 -35
  254. package/dist/core/computer-use/schemas.js.map +1 -1
  255. package/dist/core/computer-use/workflow.d.ts +16 -8
  256. package/dist/core/computer-use/workflow.d.ts.map +1 -1
  257. package/dist/core/computer-use/workflow.js +337 -260
  258. package/dist/core/computer-use/workflow.js.map +1 -1
  259. package/dist/core/customize.d.ts +2 -0
  260. package/dist/core/customize.d.ts.map +1 -1
  261. package/dist/core/customize.js +17 -13
  262. package/dist/core/customize.js.map +1 -1
  263. package/dist/core/export-html/index.d.ts.map +1 -1
  264. package/dist/core/export-html/index.js +1 -1
  265. package/dist/core/export-html/index.js.map +1 -1
  266. package/dist/core/extensions/loader.d.ts.map +1 -1
  267. package/dist/core/extensions/loader.js +4 -0
  268. package/dist/core/extensions/loader.js.map +1 -1
  269. package/dist/core/extensions/runner.d.ts +1 -0
  270. package/dist/core/extensions/runner.d.ts.map +1 -1
  271. package/dist/core/extensions/runner.js +1 -1
  272. package/dist/core/extensions/runner.js.map +1 -1
  273. package/dist/core/extensions/types.d.ts +1 -1
  274. package/dist/core/extensions/types.d.ts.map +1 -1
  275. package/dist/core/extensions/types.js.map +1 -1
  276. package/dist/core/install-features.d.ts.map +1 -1
  277. package/dist/core/install-features.js +10 -8
  278. package/dist/core/install-features.js.map +1 -1
  279. package/dist/core/memory-cap.d.ts.map +1 -1
  280. package/dist/core/memory-cap.js +5 -3
  281. package/dist/core/memory-cap.js.map +1 -1
  282. package/dist/core/model-runtime.d.ts.map +1 -1
  283. package/dist/core/model-runtime.js +3 -2
  284. package/dist/core/model-runtime.js.map +1 -1
  285. package/dist/core/model-tiers.d.ts.map +1 -1
  286. package/dist/core/model-tiers.js +9 -6
  287. package/dist/core/model-tiers.js.map +1 -1
  288. package/dist/core/permissions.d.ts +17 -23
  289. package/dist/core/permissions.d.ts.map +1 -1
  290. package/dist/core/permissions.js +79 -146
  291. package/dist/core/permissions.js.map +1 -1
  292. package/dist/core/plan-mode.d.ts +10 -12
  293. package/dist/core/plan-mode.d.ts.map +1 -1
  294. package/dist/core/plan-mode.js +20 -24
  295. package/dist/core/plan-mode.js.map +1 -1
  296. package/dist/core/process-registry.d.ts.map +1 -1
  297. package/dist/core/process-registry.js +6 -4
  298. package/dist/core/process-registry.js.map +1 -1
  299. package/dist/core/runtime-bridges.d.ts.map +1 -1
  300. package/dist/core/runtime-bridges.js +2 -2
  301. package/dist/core/runtime-bridges.js.map +1 -1
  302. package/dist/core/runtime-scope.d.ts +11 -0
  303. package/dist/core/runtime-scope.d.ts.map +1 -0
  304. package/dist/core/runtime-scope.js +3 -0
  305. package/dist/core/runtime-scope.js.map +1 -0
  306. package/dist/core/sdk.d.ts.map +1 -1
  307. package/dist/core/sdk.js +26 -6
  308. package/dist/core/sdk.js.map +1 -1
  309. package/dist/core/session-handoff.d.ts +35 -0
  310. package/dist/core/session-handoff.d.ts.map +1 -0
  311. package/dist/core/session-handoff.js +214 -0
  312. package/dist/core/session-handoff.js.map +1 -0
  313. package/dist/core/session-manager.d.ts +20 -0
  314. package/dist/core/session-manager.d.ts.map +1 -1
  315. package/dist/core/session-manager.js +191 -22
  316. package/dist/core/session-manager.js.map +1 -1
  317. package/dist/core/session-ownership.d.ts +28 -0
  318. package/dist/core/session-ownership.d.ts.map +1 -0
  319. package/dist/core/session-ownership.js +138 -0
  320. package/dist/core/session-ownership.js.map +1 -0
  321. package/dist/core/session-retention.d.ts.map +1 -1
  322. package/dist/core/session-retention.js +11 -2
  323. package/dist/core/session-retention.js.map +1 -1
  324. package/dist/core/settings-manager.d.ts +24 -1
  325. package/dist/core/settings-manager.d.ts.map +1 -1
  326. package/dist/core/settings-manager.js +78 -1
  327. package/dist/core/settings-manager.js.map +1 -1
  328. package/dist/core/slash-commands.d.ts.map +1 -1
  329. package/dist/core/slash-commands.js +6 -4
  330. package/dist/core/slash-commands.js.map +1 -1
  331. package/dist/core/subagent-cancellation.d.ts +21 -0
  332. package/dist/core/subagent-cancellation.d.ts.map +1 -0
  333. package/dist/core/subagent-cancellation.js +53 -0
  334. package/dist/core/subagent-cancellation.js.map +1 -0
  335. package/dist/core/subagent-permission-inherit.d.ts +6 -10
  336. package/dist/core/subagent-permission-inherit.d.ts.map +1 -1
  337. package/dist/core/subagent-permission-inherit.js +14 -14
  338. package/dist/core/subagent-permission-inherit.js.map +1 -1
  339. package/dist/core/subagent-spinner-setting.d.ts +6 -0
  340. package/dist/core/subagent-spinner-setting.d.ts.map +1 -0
  341. package/dist/core/subagent-spinner-setting.js +12 -0
  342. package/dist/core/subagent-spinner-setting.js.map +1 -0
  343. package/dist/core/subagent-spinner.d.ts +4 -0
  344. package/dist/core/subagent-spinner.d.ts.map +1 -0
  345. package/dist/core/subagent-spinner.js +6 -0
  346. package/dist/core/subagent-spinner.js.map +1 -0
  347. package/dist/core/subagent-wait-interruption.d.ts +11 -0
  348. package/dist/core/subagent-wait-interruption.d.ts.map +1 -0
  349. package/dist/core/subagent-wait-interruption.js +19 -0
  350. package/dist/core/subagent-wait-interruption.js.map +1 -0
  351. package/dist/core/system-prompt.d.ts +2 -0
  352. package/dist/core/system-prompt.d.ts.map +1 -1
  353. package/dist/core/system-prompt.js +14 -4
  354. package/dist/core/system-prompt.js.map +1 -1
  355. package/dist/core/todo-settings.d.ts +5 -0
  356. package/dist/core/todo-settings.d.ts.map +1 -0
  357. package/dist/core/todo-settings.js +7 -0
  358. package/dist/core/todo-settings.js.map +1 -0
  359. package/dist/core/tools/bash.d.ts.map +1 -1
  360. package/dist/core/tools/bash.js +4 -4
  361. package/dist/core/tools/bash.js.map +1 -1
  362. package/dist/core/tools/edit.d.ts.map +1 -1
  363. package/dist/core/tools/edit.js +5 -3
  364. package/dist/core/tools/edit.js.map +1 -1
  365. package/dist/core/tools/find.d.ts.map +1 -1
  366. package/dist/core/tools/find.js +4 -4
  367. package/dist/core/tools/find.js.map +1 -1
  368. package/dist/core/tools/grep.d.ts.map +1 -1
  369. package/dist/core/tools/grep.js +4 -4
  370. package/dist/core/tools/grep.js.map +1 -1
  371. package/dist/core/tools/ls.d.ts.map +1 -1
  372. package/dist/core/tools/ls.js +4 -4
  373. package/dist/core/tools/ls.js.map +1 -1
  374. package/dist/core/tools/read.d.ts.map +1 -1
  375. package/dist/core/tools/read.js +4 -4
  376. package/dist/core/tools/read.js.map +1 -1
  377. package/dist/core/tools/render-utils.d.ts +14 -5
  378. package/dist/core/tools/render-utils.d.ts.map +1 -1
  379. package/dist/core/tools/render-utils.js +34 -7
  380. package/dist/core/tools/render-utils.js.map +1 -1
  381. package/dist/core/tools/write.d.ts.map +1 -1
  382. package/dist/core/tools/write.js +4 -4
  383. package/dist/core/tools/write.js.map +1 -1
  384. package/dist/core/usage-service.d.ts.map +1 -1
  385. package/dist/core/usage-service.js +5 -3
  386. package/dist/core/usage-service.js.map +1 -1
  387. package/dist/gateway/adapters/discord.d.ts +12 -1
  388. package/dist/gateway/adapters/discord.d.ts.map +1 -1
  389. package/dist/gateway/adapters/discord.js +114 -24
  390. package/dist/gateway/adapters/discord.js.map +1 -1
  391. package/dist/gateway/adapters/telegram.d.ts +4 -2
  392. package/dist/gateway/adapters/telegram.d.ts.map +1 -1
  393. package/dist/gateway/adapters/telegram.js +41 -11
  394. package/dist/gateway/adapters/telegram.js.map +1 -1
  395. package/dist/gateway/agent-bridge.d.ts +18 -4
  396. package/dist/gateway/agent-bridge.d.ts.map +1 -1
  397. package/dist/gateway/agent-bridge.js +305 -73
  398. package/dist/gateway/agent-bridge.js.map +1 -1
  399. package/dist/gateway/approval.d.ts +3 -6
  400. package/dist/gateway/approval.d.ts.map +1 -1
  401. package/dist/gateway/approval.js +62 -24
  402. package/dist/gateway/approval.js.map +1 -1
  403. package/dist/gateway/authz.d.ts +2 -0
  404. package/dist/gateway/authz.d.ts.map +1 -1
  405. package/dist/gateway/authz.js +13 -0
  406. package/dist/gateway/authz.js.map +1 -1
  407. package/dist/gateway/buttons.d.ts +3 -1
  408. package/dist/gateway/buttons.d.ts.map +1 -1
  409. package/dist/gateway/buttons.js +45 -20
  410. package/dist/gateway/buttons.js.map +1 -1
  411. package/dist/gateway/command.d.ts.map +1 -1
  412. package/dist/gateway/command.js +49 -4
  413. package/dist/gateway/command.js.map +1 -1
  414. package/dist/gateway/commands.d.ts +2 -0
  415. package/dist/gateway/commands.d.ts.map +1 -1
  416. package/dist/gateway/commands.js +52 -16
  417. package/dist/gateway/commands.js.map +1 -1
  418. package/dist/gateway/config.d.ts +6 -0
  419. package/dist/gateway/config.d.ts.map +1 -1
  420. package/dist/gateway/config.js +7 -0
  421. package/dist/gateway/config.js.map +1 -1
  422. package/dist/gateway/conversations.d.ts +14 -0
  423. package/dist/gateway/conversations.d.ts.map +1 -0
  424. package/dist/gateway/conversations.js +30 -0
  425. package/dist/gateway/conversations.js.map +1 -0
  426. package/dist/gateway/cron.d.ts +1 -1
  427. package/dist/gateway/cron.d.ts.map +1 -1
  428. package/dist/gateway/cron.js +2 -2
  429. package/dist/gateway/cron.js.map +1 -1
  430. package/dist/gateway/download.d.ts +2 -0
  431. package/dist/gateway/download.d.ts.map +1 -0
  432. package/dist/gateway/download.js +36 -0
  433. package/dist/gateway/download.js.map +1 -0
  434. package/dist/gateway/index.d.ts.map +1 -1
  435. package/dist/gateway/index.js +106 -47
  436. package/dist/gateway/index.js.map +1 -1
  437. package/dist/gateway/mobile-commands.d.ts +24 -0
  438. package/dist/gateway/mobile-commands.d.ts.map +1 -0
  439. package/dist/gateway/mobile-commands.js +423 -0
  440. package/dist/gateway/mobile-commands.js.map +1 -0
  441. package/dist/gateway/presenter.d.ts +27 -0
  442. package/dist/gateway/presenter.d.ts.map +1 -0
  443. package/dist/gateway/presenter.js +308 -0
  444. package/dist/gateway/presenter.js.map +1 -0
  445. package/dist/gateway/router.d.ts +6 -5
  446. package/dist/gateway/router.d.ts.map +1 -1
  447. package/dist/gateway/router.js +126 -43
  448. package/dist/gateway/router.js.map +1 -1
  449. package/dist/gateway/service.d.ts +46 -0
  450. package/dist/gateway/service.d.ts.map +1 -0
  451. package/dist/gateway/service.js +404 -0
  452. package/dist/gateway/service.js.map +1 -0
  453. package/dist/gateway/setup.d.ts +9 -0
  454. package/dist/gateway/setup.d.ts.map +1 -0
  455. package/dist/gateway/setup.js +202 -0
  456. package/dist/gateway/setup.js.map +1 -0
  457. package/dist/gateway/stream.d.ts +6 -5
  458. package/dist/gateway/stream.d.ts.map +1 -1
  459. package/dist/gateway/stream.js +24 -11
  460. package/dist/gateway/stream.js.map +1 -1
  461. package/dist/gateway/types.d.ts +4 -2
  462. package/dist/gateway/types.d.ts.map +1 -1
  463. package/dist/gateway/types.js.map +1 -1
  464. package/dist/index.d.ts +2 -0
  465. package/dist/index.d.ts.map +1 -1
  466. package/dist/index.js +2 -0
  467. package/dist/index.js.map +1 -1
  468. package/dist/main.d.ts.map +1 -1
  469. package/dist/main.js +3 -3
  470. package/dist/main.js.map +1 -1
  471. package/dist/modes/interactive/components/assistant-message.d.ts +19 -2
  472. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  473. package/dist/modes/interactive/components/assistant-message.js +90 -35
  474. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  475. package/dist/modes/interactive/components/copyable-text.d.ts +27 -0
  476. package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -0
  477. package/dist/modes/interactive/components/copyable-text.js +156 -0
  478. package/dist/modes/interactive/components/copyable-text.js.map +1 -0
  479. package/dist/modes/interactive/components/custom-entry.d.ts +1 -0
  480. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  481. package/dist/modes/interactive/components/custom-entry.js +8 -0
  482. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  483. package/dist/modes/interactive/components/custom-message.d.ts +1 -0
  484. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  485. package/dist/modes/interactive/components/custom-message.js +8 -0
  486. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  487. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  488. package/dist/modes/interactive/components/session-selector.js +16 -0
  489. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  490. package/dist/modes/interactive/components/settings-selector.d.ts +16 -1
  491. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  492. package/dist/modes/interactive/components/settings-selector.js +147 -4
  493. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  494. package/dist/modes/interactive/components/thinking-tail.d.ts +9 -2
  495. package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -1
  496. package/dist/modes/interactive/components/thinking-tail.js +43 -1
  497. package/dist/modes/interactive/components/thinking-tail.js.map +1 -1
  498. package/dist/modes/interactive/components/tool-execution.d.ts +5 -3
  499. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  500. package/dist/modes/interactive/components/tool-execution.js +55 -44
  501. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  502. package/dist/modes/interactive/extension-widget-order.d.ts +8 -0
  503. package/dist/modes/interactive/extension-widget-order.d.ts.map +1 -0
  504. package/dist/modes/interactive/extension-widget-order.js +37 -0
  505. package/dist/modes/interactive/extension-widget-order.js.map +1 -0
  506. package/dist/modes/interactive/interactive-mode.d.ts +11 -2
  507. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  508. package/dist/modes/interactive/interactive-mode.js +386 -155
  509. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  510. package/dist/modes/interactive/theme/theme.d.ts +1 -0
  511. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  512. package/dist/modes/interactive/theme/theme.js +23 -0
  513. package/dist/modes/interactive/theme/theme.js.map +1 -1
  514. package/dist/node-runtime/agent-session-services-MQUPZSIN.js +51 -0
  515. package/dist/node-runtime/{builtin-extensions-7STLFW3A.js → builtin-extensions-4GNDR6U3.js} +8 -6
  516. package/dist/node-runtime/{chunk-LTXUQJI4.js → chunk-24C5IAJ4.js} +1 -6
  517. package/dist/node-runtime/chunk-2BLXLDJR.js +144 -0
  518. package/dist/node-runtime/{chunk-RQ5DNUNG.js → chunk-2CMV4L24.js} +21 -124
  519. package/dist/node-runtime/{chunk-OTT6JMPU.js → chunk-2MI5OPMN.js} +17 -370
  520. package/dist/node-runtime/{chunk-W3CVH5RX.js → chunk-2TKODGBZ.js} +11 -6
  521. package/dist/node-runtime/{chunk-K72NVGUB.js → chunk-33SIKK3Y.js} +38 -164
  522. package/dist/node-runtime/{chunk-GZQHMEWL.js → chunk-3DKIWPKN.js} +19 -4
  523. package/dist/node-runtime/{chunk-5OLJGVCB.js → chunk-3ONQTOMR.js} +2 -2
  524. package/dist/node-runtime/{chunk-3GHXVUAK.js → chunk-3VEY2IYY.js} +1 -1
  525. package/dist/node-runtime/chunk-4ER2ZV4Z.js +537 -0
  526. package/dist/node-runtime/chunk-4EULYYR4.js +62 -0
  527. package/dist/node-runtime/{chunk-BKAZ6BKX.js → chunk-4SBQAI4T.js} +31 -31
  528. package/dist/node-runtime/{chunk-W7S2REEG.js → chunk-53ARRUHA.js} +785 -285
  529. package/dist/node-runtime/{chunk-ZSEZY3II.js → chunk-5Q4A37RB.js} +10 -4
  530. package/dist/node-runtime/{chunk-SWSN6HAB.js → chunk-5UZOPGE3.js} +1 -1
  531. package/dist/node-runtime/{chunk-LCACDWHJ.js → chunk-5Z5PCXGY.js} +263 -222
  532. package/dist/node-runtime/chunk-5ZH3ZFIZ.js +308 -0
  533. package/dist/node-runtime/chunk-7JIYPIQU.js +356 -0
  534. package/dist/node-runtime/{chunk-ZRDIMBEQ.js → chunk-AJ6R5VTV.js} +66 -91
  535. package/dist/node-runtime/chunk-ATIF3RX5.js +352 -0
  536. package/dist/node-runtime/chunk-BBUVIEZB.js +51 -0
  537. package/dist/node-runtime/chunk-CCCN2UCX.js +14 -0
  538. package/dist/node-runtime/chunk-CJS4KQFI.js +3412 -0
  539. package/dist/node-runtime/chunk-DO6PALE2.js +205 -0
  540. package/dist/node-runtime/{chunk-MUMMMTW4.js → chunk-DRJI7ZSC.js} +572 -401
  541. package/dist/node-runtime/{chunk-6SPPH4FY.js → chunk-E75WFZ33.js} +4 -4
  542. package/dist/node-runtime/{chunk-MJQDX3BA.js → chunk-EBB4BJW4.js} +3 -3
  543. package/dist/node-runtime/{chunk-5NWQCSKR.js → chunk-EOEAQIJV.js} +70 -3
  544. package/dist/node-runtime/chunk-EOPL2HMM.js +117 -0
  545. package/dist/node-runtime/chunk-H4K3JDRB.js +47 -0
  546. package/dist/node-runtime/{chunk-HRS4HMDX.js → chunk-HT2XEJNP.js} +19 -3
  547. package/dist/node-runtime/chunk-IMLCWLPI.js +9 -0
  548. package/dist/node-runtime/{chunk-FLYMHKCS.js → chunk-JJWZB7S3.js} +60 -48
  549. package/dist/node-runtime/chunk-KFFOQR4G.js +672 -0
  550. package/dist/node-runtime/chunk-L5LZUGT7.js +40 -0
  551. package/dist/node-runtime/chunk-LV6CEFW2.js +97 -0
  552. package/dist/node-runtime/{chunk-EHMBW7FA.js → chunk-LWYIVUGV.js} +5 -4
  553. package/dist/node-runtime/{chunk-T5GM5BFH.js → chunk-MFV2LOOX.js} +186 -2194
  554. package/dist/node-runtime/{chunk-5SQDLSZJ.js → chunk-MNRO3UCV.js} +2 -2
  555. package/dist/node-runtime/{chunk-JHYKXIMM.js → chunk-MPKSOJBT.js} +1 -1
  556. package/dist/node-runtime/{chunk-C4O2RSQQ.js → chunk-N4TUWAGA.js} +1 -1
  557. package/dist/node-runtime/{chunk-4SJWFTUP.js → chunk-NAY6UUQZ.js} +1 -1
  558. package/dist/node-runtime/chunk-NKH2QBKF.js +773 -0
  559. package/dist/node-runtime/chunk-O2AT4MEU.js +124 -0
  560. package/dist/node-runtime/chunk-OAR4TYZE.js +146 -0
  561. package/dist/node-runtime/{chunk-DDGMHUOW.js → chunk-OGJN3OZV.js} +2 -1
  562. package/dist/node-runtime/{chunk-MX3GJNXJ.js → chunk-PLGA743X.js} +23 -0
  563. package/dist/node-runtime/chunk-Q3FEOEDA.js +1364 -0
  564. package/dist/node-runtime/chunk-QFADHUQV.js +74 -0
  565. package/dist/node-runtime/chunk-RBZQU6TJ.js +27 -0
  566. package/dist/node-runtime/{chunk-MGSB2C3M.js → chunk-RVOQBXTA.js} +10 -6
  567. package/dist/node-runtime/{chunk-ISQDQIZN.js → chunk-RW4PYFNE.js} +14 -94
  568. package/dist/node-runtime/chunk-TP7K7YWS.js +2830 -0
  569. package/dist/node-runtime/{chunk-TAP7QTUT.js → chunk-TVLBDVTR.js} +46 -436
  570. package/dist/node-runtime/chunk-UAEOTO52.js +119 -0
  571. package/dist/node-runtime/{chunk-MGWCVY6Y.js → chunk-UDKX3PFN.js} +3 -3
  572. package/dist/node-runtime/{chunk-AY6CAJSL.js → chunk-UJOCPOMX.js} +6 -3
  573. package/dist/node-runtime/{chunk-J7QGQD45.js → chunk-UQUCFAJ3.js} +1 -1
  574. package/dist/node-runtime/chunk-US544NN6.js +13 -0
  575. package/dist/node-runtime/{chunk-7AFOFSDY.js → chunk-V3HK3FE7.js} +1 -1
  576. package/dist/node-runtime/{chunk-6UB6NKA3.js → chunk-VIVYOI7C.js} +130 -27
  577. package/dist/node-runtime/{chunk-5Q45AVQG.js → chunk-XHIRAZ26.js} +1 -1
  578. package/dist/node-runtime/chunk-YPHAIRZT.js +10 -0
  579. package/dist/node-runtime/{chunk-3RCWXWAY.js → chunk-YRUY57IN.js} +1 -1
  580. package/dist/node-runtime/cli-runtime.js +2 -2
  581. package/dist/node-runtime/command-PYBNGLPP.js +45 -0
  582. package/dist/node-runtime/{commands-LGR5VT5X.js → commands-EMBQQVVT.js} +13 -13
  583. package/dist/node-runtime/commands-Y2OUC2T7.js +37 -0
  584. package/dist/node-runtime/config-7DYMNJUO.js +20 -0
  585. package/dist/node-runtime/{customize-XEXL2DGQ.js → customize-VFJV3U6A.js} +2 -1
  586. package/dist/node-runtime/{direct-tool-executor-TDJS7TBD.js → direct-tool-executor-4D7UXYU4.js} +10 -10
  587. package/dist/node-runtime/{export-html-E4DT6ZJQ.js → export-html-ETFOKW3M.js} +4 -3
  588. package/dist/node-runtime/{extension-input-RV5N6APL.js → extension-input-7QODTFAS.js} +4 -4
  589. package/dist/node-runtime/{extension-selector-CPD5LWDD.js → extension-selector-T65JEDJ5.js} +4 -4
  590. package/dist/node-runtime/{extract-IUCVZCWC.js → extract-EQJE7FZZ.js} +2 -2
  591. package/dist/node-runtime/gateway-QENRQA5X.js +1476 -0
  592. package/dist/node-runtime/{gemini-search-NCIDF7NE.js → gemini-search-35OCRFLN.js} +1 -1
  593. package/dist/node-runtime/{gemini-url-context-OKIN7AIP.js → gemini-url-context-UQY3PHHW.js} +2 -2
  594. package/dist/node-runtime/index.js +120 -77
  595. package/dist/node-runtime/{init-EKE277AG.js → init-P5AUV77I.js} +5 -5
  596. package/dist/node-runtime/{install-cli-TH7IJJQQ.js → install-cli-KHAXYBOO.js} +21 -82
  597. package/dist/node-runtime/interactive-mode-IN77GQGX.js +74 -0
  598. package/dist/node-runtime/{interactive-view-N6F4KUIT.js → interactive-view-OMWDFGUQ.js} +10 -10
  599. package/dist/node-runtime/lunr-browser-VVPRWC3F.js +174 -0
  600. package/dist/node-runtime/lunr-computer-use-IAUNXSXH.js +138 -0
  601. package/dist/node-runtime/{lunr-cron-KKBOGAEF.js → lunr-cron-P6ZJGVEF.js} +22 -8
  602. package/dist/node-runtime/main.js +50 -35
  603. package/dist/node-runtime/{mcp-auth-flow-YL6RWPYG.js → mcp-auth-flow-QVLFVLEO.js} +2 -2
  604. package/dist/node-runtime/{memory-cap-3S4XRLNP.js → memory-cap-EL3KL4JJ.js} +2 -1
  605. package/dist/node-runtime/mobile-commands-WKFSFACZ.js +33 -0
  606. package/dist/node-runtime/model-runtime-YXGJS5OJ.js +16 -0
  607. package/dist/node-runtime/{model-tiers-NJLHUEGK.js → model-tiers-OU3U5CZG.js} +2 -1
  608. package/dist/node-runtime/{package-manager-cli-C4EJOO5Q.js → package-manager-cli-J337RKTI.js} +28 -19
  609. package/dist/node-runtime/{pi-intercom-EEMBGQID.js → pi-intercom-QM53RLTS.js} +114 -88
  610. package/dist/node-runtime/{pi-mcp-adapter-DPTJGAAL.js → pi-mcp-adapter-3PHF4KZ4.js} +9 -8
  611. package/dist/node-runtime/{pi-subagents-VKCLYIBY.js → pi-subagents-RCHPB6UK.js} +1476 -646
  612. package/dist/node-runtime/{pi-web-access-BV6DSZOP.js → pi-web-access-PNG35XW7.js} +11 -11
  613. package/dist/node-runtime/process-registry-PVJ44F7H.js +31 -0
  614. package/dist/node-runtime/{proxy-modes-R64LU6WZ.js → proxy-modes-5FAPSZEZ.js} +14 -14
  615. package/dist/node-runtime/rpc-entry.js +50 -35
  616. package/dist/node-runtime/{rpc-mode-SJNSOA4G.js → rpc-mode-SH7VB4RH.js} +2 -2
  617. package/dist/node-runtime/runtime-4VA6JKNF.js +373 -0
  618. package/dist/node-runtime/runtime-bridges-3CQHWVVY.js +21 -0
  619. package/dist/node-runtime/service-HGGU3STY.js +36 -0
  620. package/dist/node-runtime/session-handoff-IAFIK7QP.js +33 -0
  621. package/dist/node-runtime/{session-manager-QEMZBMTM.js → session-manager-TCEFDKBL.js} +2 -1
  622. package/dist/node-runtime/{session-selector-URVJLOTK.js → session-selector-HG5J4BDZ.js} +5 -4
  623. package/dist/node-runtime/{settings-manager-K6IPIQTI.js → settings-manager-HIBIUNBK.js} +13 -5
  624. package/dist/node-runtime/setup-JBKOLJ6F.js +18 -0
  625. package/dist/node-runtime/setup-YU5LKRL3.js +215 -0
  626. package/dist/node-runtime/{subagent-executor-EFLTO32A.js → subagent-executor-2BH76MMS.js} +242 -314
  627. package/dist/node-runtime/theme-WTJWZSGD.js +68 -0
  628. package/dist/node-runtime/trust-manager-6ZQANSBX.js +17 -0
  629. package/dist/node-runtime/{update-cli-I6OVDRPL.js → update-cli-TVTPVUNM.js} +7 -3
  630. package/dist/node-runtime/usage-service-LFB2SWYV.js +37 -0
  631. package/dist/node-runtime/{video-extract-ETA5RA7U.js → video-extract-OOZHR7SU.js} +2 -2
  632. package/dist/node-runtime/workflow-TVJNKKQP.js +509 -0
  633. package/dist/node-runtime/{youtube-extract-SRVGNN26.js → youtube-extract-FNPAUNHU.js} +6 -6
  634. package/dist/startup/interactive-view.d.ts.map +1 -1
  635. package/dist/startup/interactive-view.js +5 -1
  636. package/dist/startup/interactive-view.js.map +1 -1
  637. package/dist/utils/image-resize-core.d.ts +2 -0
  638. package/dist/utils/image-resize-core.d.ts.map +1 -1
  639. package/dist/utils/image-resize-core.js +10 -0
  640. package/dist/utils/image-resize-core.js.map +1 -1
  641. package/docs/browser.md +86 -0
  642. package/docs/computer-use.md +319 -268
  643. package/docs/extensions.md +2 -0
  644. package/docs/features.md +129 -30
  645. package/docs/index.md +1 -1
  646. package/docs/interactive-startup.md +2 -1
  647. package/docs/keybindings.md +4 -2
  648. package/docs/providers.md +6 -2
  649. package/docs/quickstart.md +2 -2
  650. package/docs/sessions.md +10 -0
  651. package/docs/settings.md +6 -3
  652. package/docs/tui.md +2 -0
  653. package/docs/usage.md +20 -4
  654. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  655. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  656. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  657. package/examples/extensions/gondolin/package-lock.json +2 -2
  658. package/examples/extensions/gondolin/package.json +1 -1
  659. package/examples/extensions/plan-mode/README.md +1 -1
  660. package/examples/extensions/sandbox/package-lock.json +2 -2
  661. package/examples/extensions/sandbox/package.json +1 -1
  662. package/examples/extensions/with-deps/package-lock.json +2 -2
  663. package/examples/extensions/with-deps/package.json +1 -1
  664. package/install-lock/package-lock.json +39 -25
  665. package/install-lock/package.json +2 -2
  666. package/npm-shrinkwrap.json +36 -22
  667. package/package.json +10 -7
  668. package/scripts/install-browser.mjs +20 -0
  669. package/dist/builtin-extensions/lunr-settings-tools.d.ts +0 -4
  670. package/dist/builtin-extensions/lunr-settings-tools.d.ts.map +0 -1
  671. package/dist/builtin-extensions/lunr-settings-tools.js +0 -120
  672. package/dist/builtin-extensions/lunr-settings-tools.js.map +0 -1
  673. package/dist/core/settings-tools-bridge.d.ts +0 -35
  674. package/dist/core/settings-tools-bridge.d.ts.map +0 -1
  675. package/dist/core/settings-tools-bridge.js +0 -56
  676. package/dist/core/settings-tools-bridge.js.map +0 -1
  677. package/dist/node-runtime/agent-session-services-RSGP5GDN.js +0 -39
  678. package/dist/node-runtime/chunk-EH2LJQPM.js +0 -64
  679. package/dist/node-runtime/chunk-HQCKFM2O.js +0 -56
  680. package/dist/node-runtime/chunk-JT6YCS5B.js +0 -5648
  681. package/dist/node-runtime/command-6UXQ6XZN.js +0 -13
  682. package/dist/node-runtime/gateway-3OLC4GQN.js +0 -2139
  683. package/dist/node-runtime/image-resize-6ZPBFMWW.js +0 -11
  684. package/dist/node-runtime/interactive-mode-S5M26CQ7.js +0 -59
  685. package/dist/node-runtime/lunr-computer-use-4X3KUNF4.js +0 -206
  686. package/dist/node-runtime/runtime-bridges-UJ5WJJLN.js +0 -14
  687. package/dist/node-runtime/workflow-SA34S4VX.js +0 -325
  688. package/dist/node-runtime/{chunk-U6C7VTR5.js → chunk-7IQGBKBJ.js} +3 -3
  689. package/dist/node-runtime/{mcp-panel-IIGMXQGP.js → mcp-panel-KTTFXJZ4.js} +3 -3
  690. package/dist/node-runtime/{src-GPFAU3N6.js → src-IVPNZ2BX.js} +6 -6
@@ -0,0 +1,1364 @@
1
+ import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
2
+ import {
3
+ DefaultPackageManager,
4
+ require_ignore
5
+ } from "./chunk-MFV2LOOX.js";
6
+ import {
7
+ parseFrontmatter
8
+ } from "./chunk-QFWG2RVL.js";
9
+ import {
10
+ SettingsManager
11
+ } from "./chunk-EOEAQIJV.js";
12
+ import {
13
+ getGlobalInstructionsPath,
14
+ loadSelectedUserInstructions
15
+ } from "./chunk-M3LZLQW2.js";
16
+ import {
17
+ measureStartup,
18
+ resetTimings
19
+ } from "./chunk-PVCDKGR6.js";
20
+ import {
21
+ loadThemeFromPath
22
+ } from "./chunk-PLGA743X.js";
23
+ import {
24
+ CONFIG_DIR_NAME,
25
+ canonicalizePath,
26
+ getAgentDir,
27
+ isBunBinary,
28
+ isLocalPath,
29
+ isNodeBundle,
30
+ resolvePath,
31
+ waitForChildProcess
32
+ } from "./chunk-PCIGF2XK.js";
33
+ import {
34
+ __toESM
35
+ } from "./chunk-BRJX2PRC.js";
36
+
37
+ // packages/coding-agent/dist/core/event-bus.js
38
+ import { EventEmitter } from "node:events";
39
+ function createEventBus() {
40
+ let emitter = new EventEmitter();
41
+ return {
42
+ emit: (channel, data) => {
43
+ emitter.emit(channel, data);
44
+ },
45
+ on: (channel, handler) => {
46
+ let safeHandler = async (data) => {
47
+ try {
48
+ await handler(data);
49
+ } catch (err) {
50
+ console.error(`Event handler error (${channel}):`, err);
51
+ }
52
+ };
53
+ return emitter.on(channel, safeHandler), () => emitter.off(channel, safeHandler);
54
+ },
55
+ clear: () => {
56
+ emitter.removeAllListeners();
57
+ }
58
+ };
59
+ }
60
+
61
+ // packages/coding-agent/dist/core/source-info.js
62
+ function createSourceInfo(path2, metadata) {
63
+ return {
64
+ path: path2,
65
+ source: metadata.source,
66
+ scope: metadata.scope,
67
+ origin: metadata.origin,
68
+ baseDir: metadata.baseDir
69
+ };
70
+ }
71
+ function createSyntheticSourceInfo(path2, options) {
72
+ return {
73
+ path: path2,
74
+ source: options.source,
75
+ scope: options.scope ?? "temporary",
76
+ origin: options.origin ?? "top-level",
77
+ baseDir: options.baseDir
78
+ };
79
+ }
80
+
81
+ // packages/coding-agent/dist/core/extensions/loader.js
82
+ import * as fs from "node:fs";
83
+ import { createRequire } from "node:module";
84
+ import * as path from "node:path";
85
+ import { fileURLToPath } from "node:url";
86
+
87
+ // packages/coding-agent/dist/core/exec.js
88
+ import { spawn } from "node:child_process";
89
+ async function execCommand(command, args, cwd, options) {
90
+ return new Promise((resolve5) => {
91
+ let proc = spawn(command, args, {
92
+ cwd,
93
+ shell: !1,
94
+ stdio: ["ignore", "pipe", "pipe"]
95
+ }), stdout = "", stderr = "", killed = !1, timeoutId, killProcess = () => {
96
+ killed || (killed = !0, proc.kill("SIGTERM"), setTimeout(() => {
97
+ proc.killed || proc.kill("SIGKILL");
98
+ }, 5e3));
99
+ };
100
+ options?.signal && (options.signal.aborted ? killProcess() : options.signal.addEventListener("abort", killProcess, { once: !0 })), options?.timeout && options.timeout > 0 && (timeoutId = setTimeout(() => {
101
+ killProcess();
102
+ }, options.timeout)), proc.stdout?.on("data", (data) => {
103
+ stdout += data.toString();
104
+ }), proc.stderr?.on("data", (data) => {
105
+ stderr += data.toString();
106
+ }), waitForChildProcess(proc).then((code) => {
107
+ timeoutId && clearTimeout(timeoutId), options?.signal && options.signal.removeEventListener("abort", killProcess), resolve5({ stdout, stderr, code: code ?? 0, killed });
108
+ }).catch((_err) => {
109
+ timeoutId && clearTimeout(timeoutId), options?.signal && options.signal.removeEventListener("abort", killProcess), resolve5({ stdout, stderr, code: 1, killed });
110
+ });
111
+ });
112
+ }
113
+
114
+ // packages/coding-agent/dist/core/extensions/loader.js
115
+ var bunExtensionHost, createJitiFn;
116
+ var require2 = createRequire(new URL("../core/extensions/loader.js", import.meta.url).href), _aliases = null;
117
+ function getAliases() {
118
+ if (_aliases)
119
+ return _aliases;
120
+ let __dirname = path.dirname(fileURLToPath(new URL("../core/extensions/loader.js", import.meta.url).href)), packageIndex = path.resolve(__dirname, "../..", isNodeBundle ? "node-runtime/index.js" : "index.js"), typeboxEntry = require2.resolve("typebox"), typeboxCompileEntry = require2.resolve("typebox/compile"), typeboxValueEntry = require2.resolve("typebox/value"), packagesRoot = path.resolve(__dirname, "../../../../"), resolveWorkspaceOrImport = (workspaceRelativePath, specifier) => {
121
+ let workspacePath = path.join(packagesRoot, workspaceRelativePath);
122
+ return fs.existsSync(workspacePath) ? workspacePath : fileURLToPath(import.meta.resolve(specifier));
123
+ }, piCodingAgentEntry = packageIndex, piAgentCoreEntry = resolveWorkspaceOrImport("agent/dist/index.js", "@ashx-j/lunr-agent"), piTuiEntry = resolveWorkspaceOrImport("tui/dist/index.js", "@ashx-j/lunr-tui"), piAiCompatEntry = resolveWorkspaceOrImport("ai/dist/compat.js", "@ashx-j/lunr-ai/compat"), piAiOauthEntry = resolveWorkspaceOrImport("ai/dist/oauth.js", "@ashx-j/lunr-ai/oauth"), piAiCatalogDirectory = path.dirname(resolveWorkspaceOrImport("ai/dist/catalog/codex.js", "@ashx-j/lunr-ai/catalog/codex")), piAiProvidersEntry = resolveWorkspaceOrImport("ai/dist/providers/all.js", "@ashx-j/lunr-ai/providers/all");
124
+ return _aliases = {
125
+ "@ashx-j/lunr-dev": piCodingAgentEntry,
126
+ "@ashx-j/lunr-agent": piAgentCoreEntry,
127
+ "@ashx-j/lunr-tui": piTuiEntry,
128
+ "@ashx-j/lunr-ai/providers/all": piAiProvidersEntry,
129
+ "@ashx-j/lunr-ai/catalog": piAiCatalogDirectory,
130
+ "@ashx-j/lunr-ai/compat": piAiCompatEntry,
131
+ "@ashx-j/lunr-ai/oauth": piAiOauthEntry,
132
+ "@ashx-j/lunr-ai": piAiCompatEntry,
133
+ "@ashx-j/lunr": piCodingAgentEntry,
134
+ "@ashx-j/lunr-agent": piAgentCoreEntry,
135
+ "@ashx-j/lunr-tui": piTuiEntry,
136
+ "@ashx-j/lunr-ai/providers/all": piAiProvidersEntry,
137
+ "@ashx-j/lunr-ai/catalog": piAiCatalogDirectory,
138
+ "@ashx-j/lunr-ai/compat": piAiCompatEntry,
139
+ "@ashx-j/lunr-ai/oauth": piAiOauthEntry,
140
+ "@ashx-j/lunr-ai": piAiCompatEntry,
141
+ "@mariozechner/pi-coding-agent": piCodingAgentEntry,
142
+ "@mariozechner/pi-agent-core": piAgentCoreEntry,
143
+ "@mariozechner/pi-tui": piTuiEntry,
144
+ "@mariozechner/pi-ai/providers/all": piAiProvidersEntry,
145
+ "@mariozechner/pi-ai/catalog": piAiCatalogDirectory,
146
+ "@mariozechner/pi-ai/compat": piAiCompatEntry,
147
+ "@mariozechner/pi-ai/oauth": piAiOauthEntry,
148
+ "@mariozechner/pi-ai": piAiCompatEntry,
149
+ typebox: typeboxEntry,
150
+ "typebox/compile": typeboxCompileEntry,
151
+ "typebox/value": typeboxValueEntry,
152
+ "@sinclair/typebox": typeboxEntry,
153
+ "@sinclair/typebox/compile": typeboxCompileEntry,
154
+ "@sinclair/typebox/value": typeboxValueEntry
155
+ }, _aliases;
156
+ }
157
+ var extensionCacheCwd, extensionCacheGeneration = 0, extensionCache = /* @__PURE__ */ new Map();
158
+ function clearExtensionCache() {
159
+ extensionCache.clear(), extensionCacheCwd = void 0, extensionCacheGeneration++;
160
+ }
161
+ function useExtensionCacheCwd(cwd) {
162
+ let resolvedCwd = resolvePath(cwd);
163
+ return extensionCacheCwd !== void 0 && extensionCacheCwd !== resolvedCwd && clearExtensionCache(), extensionCacheCwd = resolvedCwd, { cwd: resolvedCwd, generation: extensionCacheGeneration };
164
+ }
165
+ function createExtensionRuntime() {
166
+ let notInitialized = () => {
167
+ throw new Error("Extension runtime not initialized. Action methods cannot be called during extension loading.");
168
+ }, state = {}, runtime = {
169
+ sendMessage: notInitialized,
170
+ sendUserMessage: notInitialized,
171
+ appendEntry: notInitialized,
172
+ setSessionName: notInitialized,
173
+ getSessionName: notInitialized,
174
+ setLabel: notInitialized,
175
+ getActiveTools: notInitialized,
176
+ getAllTools: notInitialized,
177
+ setActiveTools: notInitialized,
178
+ // registerTool() is valid during extension load; refresh is only needed post-bind.
179
+ refreshTools: () => {
180
+ },
181
+ getCommands: notInitialized,
182
+ setModel: () => Promise.reject(new Error("Extension runtime not initialized")),
183
+ getThinkingLevel: notInitialized,
184
+ setThinkingLevel: notInitialized,
185
+ flagValues: /* @__PURE__ */ new Map(),
186
+ pendingProviderRegistrations: [],
187
+ assertActive: () => {
188
+ if (state.staleMessage)
189
+ throw new Error(state.staleMessage);
190
+ },
191
+ invalidate: (message) => {
192
+ state.staleMessage ??= message ?? "This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload().";
193
+ },
194
+ // Pre-bind: queue registrations so bindCore() can flush them once the
195
+ // model registry is available. bindCore() replaces both with direct calls.
196
+ registerProvider: (name, config, extensionPath = "<unknown>") => {
197
+ runtime.pendingProviderRegistrations.push({ name, config, extensionPath });
198
+ },
199
+ unregisterProvider: (name) => {
200
+ runtime.pendingProviderRegistrations = runtime.pendingProviderRegistrations.filter((r) => r.name !== name);
201
+ }
202
+ };
203
+ return runtime;
204
+ }
205
+ function createExtensionAPI(extension, runtime, cwd, eventBus) {
206
+ return {
207
+ // Registration methods - write to extension
208
+ on(event, handler) {
209
+ runtime.assertActive();
210
+ let list = extension.handlers.get(event) ?? [];
211
+ list.push(handler), extension.handlers.set(event, list);
212
+ },
213
+ registerTool(tool) {
214
+ runtime.assertActive(), extension.tools.set(tool.name, {
215
+ definition: tool,
216
+ sourceInfo: extension.sourceInfo
217
+ }), runtime.refreshTools();
218
+ },
219
+ registerCommand(name, options) {
220
+ runtime.assertActive(), extension.commands.set(name, {
221
+ name,
222
+ sourceInfo: extension.sourceInfo,
223
+ ...options
224
+ });
225
+ },
226
+ registerShortcut(shortcut, options) {
227
+ runtime.assertActive(), extension.shortcuts.set(shortcut, { shortcut, extensionPath: extension.path, ...options });
228
+ },
229
+ registerFlag(name, options) {
230
+ runtime.assertActive(), extension.flags.set(name, { name, extensionPath: extension.path, ...options }), options.default !== void 0 && !runtime.flagValues.has(name) && runtime.flagValues.set(name, options.default);
231
+ },
232
+ registerMessageRenderer(customType, renderer) {
233
+ runtime.assertActive(), extension.messageRenderers.set(customType, renderer);
234
+ },
235
+ registerEntryRenderer(customType, renderer) {
236
+ runtime.assertActive(), extension.entryRenderers ??= /* @__PURE__ */ new Map(), extension.entryRenderers.set(customType, renderer);
237
+ },
238
+ // Flag access - checks extension registered it, reads from runtime
239
+ getFlag(name) {
240
+ if (runtime.assertActive(), !!extension.flags.has(name))
241
+ return runtime.flagValues.get(name);
242
+ },
243
+ // Action methods - delegate to shared runtime
244
+ sendMessage(message, options) {
245
+ runtime.assertActive(), runtime.sendMessage(message, options);
246
+ },
247
+ sendUserMessage(content, options) {
248
+ runtime.assertActive(), runtime.sendUserMessage(content, options);
249
+ },
250
+ appendEntry(customType, data) {
251
+ runtime.assertActive(), runtime.appendEntry(customType, data);
252
+ },
253
+ setSessionName(name) {
254
+ runtime.assertActive(), runtime.setSessionName(name);
255
+ },
256
+ getSessionName() {
257
+ return runtime.assertActive(), runtime.getSessionName();
258
+ },
259
+ setLabel(entryId, label) {
260
+ runtime.assertActive(), runtime.setLabel(entryId, label);
261
+ },
262
+ exec(command, args, options) {
263
+ return runtime.assertActive(), execCommand(command, args, options?.cwd ?? cwd, options);
264
+ },
265
+ getActiveTools() {
266
+ return runtime.assertActive(), runtime.getActiveTools();
267
+ },
268
+ getAllTools() {
269
+ return runtime.assertActive(), runtime.getAllTools();
270
+ },
271
+ setActiveTools(toolNames) {
272
+ runtime.assertActive(), runtime.setActiveTools(toolNames);
273
+ },
274
+ getCommands() {
275
+ return runtime.assertActive(), runtime.getCommands();
276
+ },
277
+ setModel(model) {
278
+ return runtime.assertActive(), runtime.setModel(model);
279
+ },
280
+ getThinkingLevel() {
281
+ return runtime.assertActive(), runtime.getThinkingLevel();
282
+ },
283
+ setThinkingLevel(level) {
284
+ runtime.assertActive(), runtime.setThinkingLevel(level);
285
+ },
286
+ registerProvider(name, config) {
287
+ runtime.assertActive(), runtime.registerProvider(name, config, extension.path);
288
+ },
289
+ unregisterProvider(name) {
290
+ runtime.assertActive(), runtime.unregisterProvider(name, extension.path);
291
+ },
292
+ events: eventBus
293
+ };
294
+ }
295
+ function isCurrentCacheToken(cacheToken) {
296
+ return cacheToken !== void 0 && extensionCacheCwd === cacheToken.cwd && extensionCacheGeneration === cacheToken.generation;
297
+ }
298
+ async function ensureExtensionHost() {
299
+ if (createJitiFn)
300
+ return createJitiFn;
301
+ if (isBunBinary && bunExtensionHost)
302
+ return bunExtensionHost.createJiti;
303
+ let { createJiti } = await import("jiti/static");
304
+ return createJitiFn = createJiti, createJiti;
305
+ }
306
+ async function loadExtensionModule(extensionPath, cacheToken) {
307
+ if (isCurrentCacheToken(cacheToken)) {
308
+ let cachedFactory = extensionCache.get(extensionPath);
309
+ if (cachedFactory)
310
+ return cachedFactory;
311
+ }
312
+ let factory = await (await ensureExtensionHost())(new URL("../core/extensions/loader.js", import.meta.url).href, {
313
+ moduleCache: !1,
314
+ // In Bun binary: use virtualModules for bundled packages (no filesystem resolution)
315
+ // Also disable tryNative so jiti handles ALL imports (not just the entry point)
316
+ // In Node.js/dev: use aliases to resolve to node_modules paths
317
+ ...isBunBinary ? { virtualModules: bunExtensionHost?.virtualModules, tryNative: !1 } : { alias: getAliases() }
318
+ }).import(extensionPath, { default: !0 });
319
+ if (typeof factory == "function")
320
+ return isCurrentCacheToken(cacheToken) && extensionCache.set(extensionPath, factory), factory;
321
+ }
322
+ function createExtension(extensionPath, resolvedPath) {
323
+ let source = extensionPath.startsWith("<") && extensionPath.endsWith(">") ? extensionPath.slice(1, -1).split(":")[0] || "temporary" : "local", baseDir = extensionPath.startsWith("<") ? void 0 : path.dirname(resolvedPath);
324
+ return {
325
+ path: extensionPath,
326
+ resolvedPath,
327
+ sourceInfo: createSyntheticSourceInfo(extensionPath, { source, baseDir }),
328
+ handlers: /* @__PURE__ */ new Map(),
329
+ tools: /* @__PURE__ */ new Map(),
330
+ messageRenderers: /* @__PURE__ */ new Map(),
331
+ entryRenderers: /* @__PURE__ */ new Map(),
332
+ commands: /* @__PURE__ */ new Map(),
333
+ flags: /* @__PURE__ */ new Map(),
334
+ shortcuts: /* @__PURE__ */ new Map()
335
+ };
336
+ }
337
+ async function loadExtension(extensionPath, cwd, eventBus, runtime, cacheToken) {
338
+ let resolvedPath = resolvePath(extensionPath, cwd, { normalizeUnicodeSpaces: !0 });
339
+ try {
340
+ let factory = await measureStartup(`${extensionPath} module import`, () => loadExtensionModule(resolvedPath, cacheToken));
341
+ if (!factory)
342
+ return { extension: null, error: `Extension does not export a valid factory function: ${extensionPath}` };
343
+ let extension = createExtension(extensionPath, resolvedPath), api = createExtensionAPI(extension, runtime, cwd, eventBus);
344
+ return await measureStartup(`${extensionPath} factory`, () => factory(api)), { extension, error: null };
345
+ } catch (err) {
346
+ return { extension: null, error: `Failed to load extension: ${err instanceof Error ? err.message : String(err)}` };
347
+ }
348
+ }
349
+ async function loadExtensionFromFactory(factory, cwd, eventBus, runtime, extensionPath = "<inline>") {
350
+ let extension = createExtension(extensionPath, extensionPath), resolvedCwd = resolvePath(cwd), api = createExtensionAPI(extension, runtime, resolvedCwd, eventBus);
351
+ return await measureStartup(`${extensionPath} factory`, () => factory(api)), extension;
352
+ }
353
+ async function loadExtensionsInternal(paths, cwd, eventBus, runtime, useCache = !1) {
354
+ let extensions = [], errors = [], cacheToken = useCache ? useExtensionCacheCwd(cwd) : void 0, resolvedCwd = cacheToken?.cwd ?? resolvePath(cwd), resolvedEventBus = eventBus ?? createEventBus(), resolvedRuntime = runtime ?? createExtensionRuntime();
355
+ for (let extPath of paths) {
356
+ let { extension, error } = await loadExtension(extPath, resolvedCwd, resolvedEventBus, resolvedRuntime, cacheToken);
357
+ if (error) {
358
+ errors.push({ path: extPath, error });
359
+ continue;
360
+ }
361
+ extension && extensions.push(extension);
362
+ }
363
+ return {
364
+ extensions,
365
+ errors,
366
+ runtime: resolvedRuntime
367
+ };
368
+ }
369
+ async function loadExtensions(paths, cwd, eventBus, runtime) {
370
+ return loadExtensionsInternal(paths, cwd, eventBus, runtime);
371
+ }
372
+ async function loadExtensionsCached(paths, cwd, eventBus, runtime) {
373
+ return loadExtensionsInternal(paths, cwd, eventBus, runtime, !0);
374
+ }
375
+ function readPiManifest(packageJsonPath) {
376
+ try {
377
+ let content = fs.readFileSync(packageJsonPath, "utf-8"), pkg = JSON.parse(content);
378
+ return pkg.pi && typeof pkg.pi == "object" ? pkg.pi : null;
379
+ } catch {
380
+ return null;
381
+ }
382
+ }
383
+ function isExtensionFile(name) {
384
+ return name.endsWith(".ts") || name.endsWith(".js");
385
+ }
386
+ function resolveExtensionEntries(dir) {
387
+ let packageJsonPath = path.join(dir, "package.json");
388
+ if (fs.existsSync(packageJsonPath)) {
389
+ let manifest = readPiManifest(packageJsonPath);
390
+ if (manifest?.extensions?.length) {
391
+ let entries = [];
392
+ for (let extPath of manifest.extensions) {
393
+ let resolvedExtPath = path.resolve(dir, extPath);
394
+ fs.existsSync(resolvedExtPath) && entries.push(resolvedExtPath);
395
+ }
396
+ if (entries.length > 0)
397
+ return entries;
398
+ }
399
+ }
400
+ let indexTs = path.join(dir, "index.ts"), indexJs = path.join(dir, "index.js");
401
+ return fs.existsSync(indexTs) ? [indexTs] : fs.existsSync(indexJs) ? [indexJs] : null;
402
+ }
403
+ function discoverExtensionsInDir(dir) {
404
+ if (!fs.existsSync(dir))
405
+ return [];
406
+ let discovered = [];
407
+ try {
408
+ let entries = fs.readdirSync(dir, { withFileTypes: !0 });
409
+ for (let entry of entries) {
410
+ let entryPath = path.join(dir, entry.name);
411
+ if ((entry.isFile() || entry.isSymbolicLink()) && isExtensionFile(entry.name)) {
412
+ discovered.push(entryPath);
413
+ continue;
414
+ }
415
+ if (entry.isDirectory() || entry.isSymbolicLink()) {
416
+ let entries2 = resolveExtensionEntries(entryPath);
417
+ entries2 && discovered.push(...entries2);
418
+ }
419
+ }
420
+ } catch {
421
+ return [];
422
+ }
423
+ return discovered;
424
+ }
425
+ async function discoverAndLoadExtensions(configuredPaths, cwd, agentDir = getAgentDir(), eventBus) {
426
+ let resolvedCwd = resolvePath(cwd), resolvedAgentDir = resolvePath(agentDir), allPaths = [], seen = /* @__PURE__ */ new Set(), addPaths = (paths) => {
427
+ for (let p of paths) {
428
+ let resolved = path.resolve(p);
429
+ seen.has(resolved) || (seen.add(resolved), allPaths.push(p));
430
+ }
431
+ }, localExtDir = path.join(resolvedCwd, CONFIG_DIR_NAME, "extensions");
432
+ addPaths(discoverExtensionsInDir(localExtDir));
433
+ let globalExtDir = path.join(resolvedAgentDir, "extensions");
434
+ addPaths(discoverExtensionsInDir(globalExtDir));
435
+ for (let p of configuredPaths) {
436
+ let resolved = resolvePath(p, resolvedCwd, { normalizeUnicodeSpaces: !0 });
437
+ if (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {
438
+ let entries = resolveExtensionEntries(resolved);
439
+ if (entries) {
440
+ addPaths(entries);
441
+ continue;
442
+ }
443
+ addPaths(discoverExtensionsInDir(resolved));
444
+ continue;
445
+ }
446
+ addPaths([resolved]);
447
+ }
448
+ return loadExtensions(allPaths, resolvedCwd, eventBus);
449
+ }
450
+
451
+ // packages/coding-agent/dist/core/skills.js
452
+ var import_ignore = __toESM(require_ignore(), 1);
453
+ import { existsSync as existsSync2, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
454
+ import { basename, dirname as dirname2, join as join2, relative, resolve as resolve2, sep } from "path";
455
+ var MAX_NAME_LENGTH = 64, MAX_DESCRIPTION_LENGTH = 1024, IGNORE_FILE_NAMES = [".gitignore", ".ignore", ".fdignore"];
456
+ function toPosixPath(p) {
457
+ return p.split(sep).join("/");
458
+ }
459
+ function prefixIgnorePattern(line, prefix) {
460
+ let trimmed = line.trim();
461
+ if (!trimmed || trimmed.startsWith("#") && !trimmed.startsWith("\\#"))
462
+ return null;
463
+ let pattern = line, negated = !1;
464
+ pattern.startsWith("!") ? (negated = !0, pattern = pattern.slice(1)) : pattern.startsWith("\\!") && (pattern = pattern.slice(1)), pattern.startsWith("/") && (pattern = pattern.slice(1));
465
+ let prefixed = prefix ? `${prefix}${pattern}` : pattern;
466
+ return negated ? `!${prefixed}` : prefixed;
467
+ }
468
+ function addIgnoreRules(ig, dir, rootDir) {
469
+ let relativeDir = relative(rootDir, dir), prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : "";
470
+ for (let filename of IGNORE_FILE_NAMES) {
471
+ let ignorePath = join2(dir, filename);
472
+ if (existsSync2(ignorePath))
473
+ try {
474
+ let patterns = readFileSync2(ignorePath, "utf-8").split(/\r?\n/).map((line) => prefixIgnorePattern(line, prefix)).filter((line) => !!line);
475
+ patterns.length > 0 && ig.add(patterns);
476
+ } catch {
477
+ }
478
+ }
479
+ }
480
+ function validateName(name) {
481
+ let errors = [];
482
+ return name.length > MAX_NAME_LENGTH && errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`), /^[a-z0-9-]+$/.test(name) || errors.push("name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)"), (name.startsWith("-") || name.endsWith("-")) && errors.push("name must not start or end with a hyphen"), name.includes("--") && errors.push("name must not contain consecutive hyphens"), errors;
483
+ }
484
+ function validateDescription(description) {
485
+ let errors = [];
486
+ return !description || description.trim() === "" ? errors.push("description is required") : description.length > MAX_DESCRIPTION_LENGTH && errors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`), errors;
487
+ }
488
+ function createSkillSourceInfo(filePath, baseDir, source) {
489
+ switch (source) {
490
+ case "user":
491
+ return createSyntheticSourceInfo(filePath, {
492
+ source: "local",
493
+ scope: "user",
494
+ baseDir
495
+ });
496
+ case "project":
497
+ return createSyntheticSourceInfo(filePath, {
498
+ source: "local",
499
+ scope: "project",
500
+ baseDir
501
+ });
502
+ case "path":
503
+ return createSyntheticSourceInfo(filePath, {
504
+ source: "local",
505
+ baseDir
506
+ });
507
+ default:
508
+ return createSyntheticSourceInfo(filePath, { source, baseDir });
509
+ }
510
+ }
511
+ function loadSkillsFromDir(options) {
512
+ let { dir, source } = options;
513
+ return loadSkillsFromDirInternal(dir, source, !0);
514
+ }
515
+ function loadSkillsFromDirInternal(dir, source, includeRootFiles, ignoreMatcher, rootDir) {
516
+ let skills = [], diagnostics = [];
517
+ if (!existsSync2(dir))
518
+ return { skills, diagnostics };
519
+ let root = rootDir ?? dir, ig = ignoreMatcher ?? (0, import_ignore.default)();
520
+ addIgnoreRules(ig, dir, root);
521
+ try {
522
+ let entries = readdirSync2(dir, { withFileTypes: !0 });
523
+ for (let entry of entries) {
524
+ if (entry.name !== "SKILL.md")
525
+ continue;
526
+ let fullPath = join2(dir, entry.name), isFile = entry.isFile();
527
+ if (entry.isSymbolicLink())
528
+ try {
529
+ isFile = statSync2(fullPath).isFile();
530
+ } catch {
531
+ continue;
532
+ }
533
+ let relPath = toPosixPath(relative(root, fullPath));
534
+ if (!isFile || ig.ignores(relPath))
535
+ continue;
536
+ let result = loadSkillFromFile(fullPath, source);
537
+ return result.skill && skills.push(result.skill), diagnostics.push(...result.diagnostics), { skills, diagnostics };
538
+ }
539
+ for (let entry of entries) {
540
+ if (entry.name.startsWith(".") || entry.name === "node_modules")
541
+ continue;
542
+ let fullPath = join2(dir, entry.name), isDirectory = entry.isDirectory(), isFile = entry.isFile();
543
+ if (entry.isSymbolicLink())
544
+ try {
545
+ let stats = statSync2(fullPath);
546
+ isDirectory = stats.isDirectory(), isFile = stats.isFile();
547
+ } catch {
548
+ continue;
549
+ }
550
+ let relPath = toPosixPath(relative(root, fullPath)), ignorePath = isDirectory ? `${relPath}/` : relPath;
551
+ if (ig.ignores(ignorePath))
552
+ continue;
553
+ if (isDirectory) {
554
+ let subResult = loadSkillsFromDirInternal(fullPath, source, !1, ig, root);
555
+ skills.push(...subResult.skills), diagnostics.push(...subResult.diagnostics);
556
+ continue;
557
+ }
558
+ if (!isFile || !includeRootFiles || !entry.name.endsWith(".md"))
559
+ continue;
560
+ let result = loadSkillFromFile(fullPath, source);
561
+ result.skill && skills.push(result.skill), diagnostics.push(...result.diagnostics);
562
+ }
563
+ } catch {
564
+ }
565
+ return { skills, diagnostics };
566
+ }
567
+ function loadSkillFromFile(filePath, source) {
568
+ let diagnostics = [];
569
+ try {
570
+ let rawContent = readFileSync2(filePath, "utf-8"), { frontmatter } = parseFrontmatter(rawContent), skillDir = dirname2(filePath), parentDirName = basename(skillDir), descErrors = validateDescription(frontmatter.description);
571
+ for (let error of descErrors)
572
+ diagnostics.push({ type: "warning", message: error, path: filePath });
573
+ let name = frontmatter.name || parentDirName, nameErrors = validateName(name);
574
+ for (let error of nameErrors)
575
+ diagnostics.push({ type: "warning", message: error, path: filePath });
576
+ return !frontmatter.description || frontmatter.description.trim() === "" ? { skill: null, diagnostics } : {
577
+ skill: {
578
+ name,
579
+ description: frontmatter.description,
580
+ filePath,
581
+ baseDir: skillDir,
582
+ sourceInfo: createSkillSourceInfo(filePath, skillDir, source),
583
+ disableModelInvocation: frontmatter["disable-model-invocation"] === !0
584
+ },
585
+ diagnostics
586
+ };
587
+ } catch (error) {
588
+ let message = error instanceof Error ? error.message : "failed to parse skill file";
589
+ return diagnostics.push({ type: "warning", message, path: filePath }), { skill: null, diagnostics };
590
+ }
591
+ }
592
+ function formatSkillsForPrompt(skills) {
593
+ let visibleSkills = skills.filter((s) => !s.disableModelInvocation);
594
+ if (visibleSkills.length === 0)
595
+ return "";
596
+ let lines = [
597
+ `
598
+
599
+ The following skills provide specialized instructions for specific tasks.`,
600
+ "Use the read tool to load a skill's file when the task matches its description.",
601
+ "When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.",
602
+ "",
603
+ "<available_skills>"
604
+ ];
605
+ for (let skill of visibleSkills)
606
+ lines.push(" <skill>"), lines.push(` <name>${escapeXml(skill.name)}</name>`), lines.push(` <description>${escapeXml(skill.description)}</description>`), lines.push(` <location>${escapeXml(skill.filePath)}</location>`), lines.push(" </skill>");
607
+ return lines.push("</available_skills>"), lines.join(`
608
+ `);
609
+ }
610
+ function escapeXml(str) {
611
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
612
+ }
613
+ function loadSkills(options) {
614
+ let { agentDir, skillPaths, includeDefaults } = options, resolvedCwd = resolvePath(options.cwd), resolvedAgentDir = resolvePath(agentDir ?? getAgentDir()), skillMap = /* @__PURE__ */ new Map(), realPathSet = /* @__PURE__ */ new Set(), allDiagnostics = [], collisionDiagnostics = [];
615
+ function addSkills(result) {
616
+ allDiagnostics.push(...result.diagnostics);
617
+ for (let skill of result.skills) {
618
+ let realPath = canonicalizePath(skill.filePath);
619
+ if (realPathSet.has(realPath))
620
+ continue;
621
+ let existing = skillMap.get(skill.name);
622
+ existing ? collisionDiagnostics.push({
623
+ type: "collision",
624
+ message: `name "${skill.name}" collision`,
625
+ path: skill.filePath,
626
+ collision: {
627
+ resourceType: "skill",
628
+ name: skill.name,
629
+ winnerPath: existing.filePath,
630
+ loserPath: skill.filePath
631
+ }
632
+ }) : (skillMap.set(skill.name, skill), realPathSet.add(realPath));
633
+ }
634
+ }
635
+ includeDefaults && (addSkills(loadSkillsFromDirInternal(join2(resolvedAgentDir, "skills"), "user", !0)), addSkills(loadSkillsFromDirInternal(resolve2(resolvedCwd, CONFIG_DIR_NAME, "skills"), "project", !0)));
636
+ let userSkillsDir = join2(resolvedAgentDir, "skills"), projectSkillsDir = resolve2(resolvedCwd, CONFIG_DIR_NAME, "skills"), isUnderPath = (target, root) => {
637
+ let normalizedRoot = resolve2(root);
638
+ if (target === normalizedRoot)
639
+ return !0;
640
+ let prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;
641
+ return target.startsWith(prefix);
642
+ }, getSource = (resolvedPath) => {
643
+ if (!includeDefaults) {
644
+ if (isUnderPath(resolvedPath, userSkillsDir))
645
+ return "user";
646
+ if (isUnderPath(resolvedPath, projectSkillsDir))
647
+ return "project";
648
+ }
649
+ return "path";
650
+ };
651
+ for (let rawPath of skillPaths) {
652
+ let resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: !0 });
653
+ if (!existsSync2(resolvedPath)) {
654
+ allDiagnostics.push({ type: "warning", message: "skill path does not exist", path: resolvedPath });
655
+ continue;
656
+ }
657
+ try {
658
+ let stats = statSync2(resolvedPath), source = getSource(resolvedPath);
659
+ if (stats.isDirectory())
660
+ addSkills(loadSkillsFromDirInternal(resolvedPath, source, !0));
661
+ else if (stats.isFile() && resolvedPath.endsWith(".md")) {
662
+ let result = loadSkillFromFile(resolvedPath, source);
663
+ result.skill ? addSkills({ skills: [result.skill], diagnostics: result.diagnostics }) : allDiagnostics.push(...result.diagnostics);
664
+ } else
665
+ allDiagnostics.push({ type: "warning", message: "skill path is not a markdown file", path: resolvedPath });
666
+ } catch (error) {
667
+ let message = error instanceof Error ? error.message : "failed to read skill path";
668
+ allDiagnostics.push({ type: "warning", message, path: resolvedPath });
669
+ }
670
+ }
671
+ return {
672
+ skills: Array.from(skillMap.values()),
673
+ diagnostics: [...allDiagnostics, ...collisionDiagnostics]
674
+ };
675
+ }
676
+
677
+ // packages/coding-agent/dist/core/resource-loader.js
678
+ import { existsSync as existsSync4, readdirSync as readdirSync4, readFileSync as readFileSync4, statSync as statSync4 } from "node:fs";
679
+ import { dirname as dirname4, join as join4, resolve as resolve4, sep as sep3 } from "node:path";
680
+ import chalk from "chalk";
681
+
682
+ // packages/coding-agent/dist/core/prompt-templates.js
683
+ import { existsSync as existsSync3, readdirSync as readdirSync3, readFileSync as readFileSync3, statSync as statSync3 } from "fs";
684
+ import { basename as basename2, dirname as dirname3, join as join3, resolve as resolve3, sep as sep2 } from "path";
685
+ function parseCommandArgs(argsString) {
686
+ let args = [], current = "", inQuote = null;
687
+ for (let i = 0; i < argsString.length; i++) {
688
+ let char = argsString[i];
689
+ inQuote ? char === inQuote ? inQuote = null : current += char : char === '"' || char === "'" ? inQuote = char : /\s/.test(char) ? current && (args.push(current), current = "") : current += char;
690
+ }
691
+ return current && args.push(current), args;
692
+ }
693
+ function substituteArgs(content, args) {
694
+ let allArgs = args.join(" ");
695
+ return content.replace(/\$\{(\d+):-([^}]*)\}|\$\{@:(\d+)(?::(\d+))?\}|\$(ARGUMENTS|@|\d+)/g, (_match, defaultNum, defaultValue, sliceStart, sliceLength, simple) => {
696
+ if (defaultNum) {
697
+ let index2 = parseInt(defaultNum, 10) - 1, value = args[index2];
698
+ return value || defaultValue;
699
+ }
700
+ if (sliceStart) {
701
+ let start = parseInt(sliceStart, 10) - 1;
702
+ if (start < 0 && (start = 0), sliceLength) {
703
+ let length = parseInt(sliceLength, 10);
704
+ return args.slice(start, start + length).join(" ");
705
+ }
706
+ return args.slice(start).join(" ");
707
+ }
708
+ if (simple === "ARGUMENTS" || simple === "@")
709
+ return allArgs;
710
+ let index = parseInt(simple, 10) - 1;
711
+ return args[index] ?? "";
712
+ });
713
+ }
714
+ function loadTemplateFromFile(filePath, sourceInfo) {
715
+ try {
716
+ let rawContent = readFileSync3(filePath, "utf-8"), { frontmatter, body } = parseFrontmatter(rawContent), name = basename2(filePath).replace(/\.md$/, ""), description = frontmatter.description || "";
717
+ if (!description) {
718
+ let firstLine = body.split(`
719
+ `).find((line) => line.trim());
720
+ firstLine && (description = firstLine.slice(0, 60), firstLine.length > 60 && (description += "..."));
721
+ }
722
+ return {
723
+ name,
724
+ description,
725
+ ...frontmatter["argument-hint"] && { argumentHint: frontmatter["argument-hint"] },
726
+ content: body,
727
+ sourceInfo,
728
+ filePath
729
+ };
730
+ } catch {
731
+ return null;
732
+ }
733
+ }
734
+ function loadTemplatesFromDir(dir, getSourceInfo) {
735
+ let templates = [];
736
+ if (!existsSync3(dir))
737
+ return templates;
738
+ try {
739
+ let entries = readdirSync3(dir, { withFileTypes: !0 });
740
+ for (let entry of entries) {
741
+ let fullPath = join3(dir, entry.name), isFile = entry.isFile();
742
+ if (entry.isSymbolicLink())
743
+ try {
744
+ isFile = statSync3(fullPath).isFile();
745
+ } catch {
746
+ continue;
747
+ }
748
+ if (isFile && entry.name.endsWith(".md")) {
749
+ let template = loadTemplateFromFile(fullPath, getSourceInfo(fullPath));
750
+ template && templates.push(template);
751
+ }
752
+ }
753
+ } catch {
754
+ return templates;
755
+ }
756
+ return templates;
757
+ }
758
+ function loadPromptTemplates(options) {
759
+ let resolvedCwd = resolvePath(options.cwd), resolvedAgentDir = resolvePath(options.agentDir), promptPaths = options.promptPaths, includeDefaults = options.includeDefaults, templates = [], globalPromptsDir = join3(resolvedAgentDir, "prompts"), projectPromptsDir = resolve3(resolvedCwd, CONFIG_DIR_NAME, "prompts"), isUnderPath = (target, root) => {
760
+ let normalizedRoot = resolve3(root);
761
+ if (target === normalizedRoot)
762
+ return !0;
763
+ let prefix = normalizedRoot.endsWith(sep2) ? normalizedRoot : `${normalizedRoot}${sep2}`;
764
+ return target.startsWith(prefix);
765
+ }, getSourceInfo = (resolvedPath) => isUnderPath(resolvedPath, globalPromptsDir) ? createSyntheticSourceInfo(resolvedPath, {
766
+ source: "local",
767
+ scope: "user",
768
+ baseDir: globalPromptsDir
769
+ }) : isUnderPath(resolvedPath, projectPromptsDir) ? createSyntheticSourceInfo(resolvedPath, {
770
+ source: "local",
771
+ scope: "project",
772
+ baseDir: projectPromptsDir
773
+ }) : createSyntheticSourceInfo(resolvedPath, {
774
+ source: "local",
775
+ baseDir: statSync3(resolvedPath).isDirectory() ? resolvedPath : dirname3(resolvedPath)
776
+ });
777
+ includeDefaults && (templates.push(...loadTemplatesFromDir(globalPromptsDir, getSourceInfo)), templates.push(...loadTemplatesFromDir(projectPromptsDir, getSourceInfo)));
778
+ for (let rawPath of promptPaths) {
779
+ let resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: !0 });
780
+ if (existsSync3(resolvedPath))
781
+ try {
782
+ let stats = statSync3(resolvedPath);
783
+ if (stats.isDirectory())
784
+ templates.push(...loadTemplatesFromDir(resolvedPath, getSourceInfo));
785
+ else if (stats.isFile() && resolvedPath.endsWith(".md")) {
786
+ let template = loadTemplateFromFile(resolvedPath, getSourceInfo(resolvedPath));
787
+ template && templates.push(template);
788
+ }
789
+ } catch {
790
+ }
791
+ }
792
+ return templates;
793
+ }
794
+ function expandPromptTemplate(text, templates) {
795
+ if (!text.startsWith("/"))
796
+ return text;
797
+ let match = text.match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);
798
+ if (!match)
799
+ return text;
800
+ let templateName = match[1], argsString = match[2] ?? "", template = templates.find((t) => t.name === templateName);
801
+ if (template) {
802
+ let args = parseCommandArgs(argsString);
803
+ return substituteArgs(template.content, args);
804
+ }
805
+ return text;
806
+ }
807
+
808
+ // packages/coding-agent/dist/core/resource-loader.js
809
+ function inlineExtensionPath(input, index) {
810
+ return `<inline:${typeof input != "function" ? input.name : index + 1}>`;
811
+ }
812
+ function resolvePromptInput(input, description) {
813
+ if (input) {
814
+ if (existsSync4(input))
815
+ try {
816
+ return readFileSync4(input, "utf-8");
817
+ } catch (error) {
818
+ return console.error(chalk.yellow(`Warning: Could not read ${description} file ${input}: ${error}`)), input;
819
+ }
820
+ return input;
821
+ }
822
+ }
823
+ function loadContextFileFromDir(dir) {
824
+ let candidates = ["AGENTS.md", "AGENTS.MD", "CLAUDE.md", "CLAUDE.MD"];
825
+ for (let filename of candidates) {
826
+ let filePath = join4(dir, filename);
827
+ if (existsSync4(filePath))
828
+ try {
829
+ return {
830
+ path: filePath,
831
+ content: readFileSync4(filePath, "utf-8")
832
+ };
833
+ } catch (error) {
834
+ console.error(chalk.yellow(`Warning: Could not read ${filePath}: ${error}`));
835
+ }
836
+ }
837
+ return null;
838
+ }
839
+ function loadProjectContextFiles(options) {
840
+ let resolvedCwd = resolvePath(options.cwd), resolvedAgentDir = resolvePath(options.agentDir), contextFiles = [], seenPaths = /* @__PURE__ */ new Set(), userContexts = options.settingsManager ? loadSelectedUserInstructions({ agentDir: resolvedAgentDir, settingsManager: options.settingsManager }) : [getGlobalInstructionsPath(resolvedAgentDir)].map((path2) => loadContextFileFromDir(dirname4(path2))).filter((file) => file !== null);
841
+ for (let userContext of userContexts)
842
+ contextFiles.push(userContext), seenPaths.add(userContext.path);
843
+ let ancestorContextFiles = [], currentDir = resolvedCwd;
844
+ for (; ; ) {
845
+ let contextFile = loadContextFileFromDir(currentDir);
846
+ contextFile && !seenPaths.has(contextFile.path) && (ancestorContextFiles.unshift(contextFile), seenPaths.add(contextFile.path));
847
+ let parentDir = dirname4(currentDir);
848
+ if (parentDir === currentDir)
849
+ break;
850
+ currentDir = parentDir;
851
+ }
852
+ return contextFiles.push(...ancestorContextFiles), contextFiles;
853
+ }
854
+ var DefaultResourceLoader = class {
855
+ cwd;
856
+ agentDir;
857
+ settingsManager;
858
+ eventBus;
859
+ packageManager;
860
+ additionalExtensionPaths;
861
+ additionalSkillPaths;
862
+ additionalPromptTemplatePaths;
863
+ additionalThemePaths;
864
+ extensionFactories;
865
+ noExtensions;
866
+ noSkills;
867
+ noPromptTemplates;
868
+ noThemes;
869
+ noContextFiles;
870
+ systemPromptSource;
871
+ appendSystemPromptSource;
872
+ extensionsOverride;
873
+ skillsOverride;
874
+ promptsOverride;
875
+ themesOverride;
876
+ agentsFilesOverride;
877
+ systemPromptOverride;
878
+ appendSystemPromptOverride;
879
+ extensionsResult;
880
+ skills;
881
+ skillDiagnostics;
882
+ prompts;
883
+ promptDiagnostics;
884
+ themes;
885
+ themeDiagnostics;
886
+ agentsFiles;
887
+ systemPrompt;
888
+ appendSystemPrompt;
889
+ lastSkillPaths;
890
+ extensionSkillSourceInfos;
891
+ extensionPromptSourceInfos;
892
+ extensionThemeSourceInfos;
893
+ lastPromptPaths;
894
+ lastThemePaths;
895
+ loaded;
896
+ constructor(options) {
897
+ this.cwd = resolvePath(options.cwd), this.agentDir = resolvePath(options.agentDir), this.settingsManager = options.settingsManager ?? SettingsManager.create(this.cwd, this.agentDir), this.eventBus = options.eventBus ?? createEventBus(), this.packageManager = new DefaultPackageManager({
898
+ cwd: this.cwd,
899
+ agentDir: this.agentDir,
900
+ settingsManager: this.settingsManager
901
+ }), this.additionalExtensionPaths = options.additionalExtensionPaths ?? [], this.additionalSkillPaths = options.additionalSkillPaths ?? [], this.additionalPromptTemplatePaths = options.additionalPromptTemplatePaths ?? [], this.additionalThemePaths = options.additionalThemePaths ?? [], this.extensionFactories = options.extensionFactories ?? [], this.noExtensions = options.noExtensions ?? !1, this.noSkills = options.noSkills ?? !1, this.noPromptTemplates = options.noPromptTemplates ?? !1, this.noThemes = options.noThemes ?? !1, this.noContextFiles = options.noContextFiles ?? !1, this.systemPromptSource = options.systemPrompt, this.appendSystemPromptSource = options.appendSystemPrompt, this.extensionsOverride = options.extensionsOverride, this.skillsOverride = options.skillsOverride, this.promptsOverride = options.promptsOverride, this.themesOverride = options.themesOverride, this.agentsFilesOverride = options.agentsFilesOverride, this.systemPromptOverride = options.systemPromptOverride, this.appendSystemPromptOverride = options.appendSystemPromptOverride, this.extensionsResult = { extensions: [], errors: [], runtime: createExtensionRuntime() }, this.skills = [], this.skillDiagnostics = [], this.prompts = [], this.promptDiagnostics = [], this.themes = [], this.themeDiagnostics = [], this.agentsFiles = [], this.appendSystemPrompt = [], this.lastSkillPaths = [], this.extensionSkillSourceInfos = /* @__PURE__ */ new Map(), this.extensionPromptSourceInfos = /* @__PURE__ */ new Map(), this.extensionThemeSourceInfos = /* @__PURE__ */ new Map(), this.lastPromptPaths = [], this.lastThemePaths = [], this.loaded = !1;
902
+ }
903
+ getExtensions() {
904
+ return this.extensionsResult;
905
+ }
906
+ getSkills() {
907
+ return { skills: this.skills, diagnostics: this.skillDiagnostics };
908
+ }
909
+ getPrompts() {
910
+ return { prompts: this.prompts, diagnostics: this.promptDiagnostics };
911
+ }
912
+ getThemes() {
913
+ return { themes: this.themes, diagnostics: this.themeDiagnostics };
914
+ }
915
+ getAgentsFiles() {
916
+ return { agentsFiles: this.agentsFiles };
917
+ }
918
+ contextFilesEnabled() {
919
+ return !this.noContextFiles;
920
+ }
921
+ getSystemPrompt() {
922
+ return this.systemPrompt;
923
+ }
924
+ getAppendSystemPrompt() {
925
+ return this.appendSystemPrompt;
926
+ }
927
+ async attachInlineExtensions(factories) {
928
+ let loaded = new Set(this.extensionsResult.extensions.map((extension) => extension.path)), pending = factories.filter((factory, index) => {
929
+ let path2 = inlineExtensionPath(factory, this.extensionFactories.length + index);
930
+ return !loaded.has(path2);
931
+ });
932
+ if (pending.length === 0)
933
+ return { extensions: [], errors: [], runtime: this.extensionsResult.runtime };
934
+ let attached = await this.loadExtensionFactories(this.extensionsResult.runtime, pending);
935
+ return this.extensionFactories.push(...pending), this.extensionsResult.extensions.push(...attached.extensions), this.extensionsResult.errors.push(...attached.errors), this.addExtensionConflictDiagnostics(this.extensionsResult), {
936
+ extensions: attached.extensions,
937
+ errors: attached.errors,
938
+ runtime: this.extensionsResult.runtime
939
+ };
940
+ }
941
+ extendResources(paths) {
942
+ let skillPaths = this.normalizeExtensionPaths(paths.skillPaths ?? []), promptPaths = this.normalizeExtensionPaths(paths.promptPaths ?? []), themePaths = this.normalizeExtensionPaths(paths.themePaths ?? []);
943
+ for (let entry of skillPaths)
944
+ this.extensionSkillSourceInfos.set(entry.path, createSourceInfo(entry.path, entry.metadata));
945
+ for (let entry of promptPaths)
946
+ this.extensionPromptSourceInfos.set(entry.path, createSourceInfo(entry.path, entry.metadata));
947
+ for (let entry of themePaths)
948
+ this.extensionThemeSourceInfos.set(entry.path, createSourceInfo(entry.path, entry.metadata));
949
+ skillPaths.length > 0 && (this.lastSkillPaths = this.mergePaths(this.lastSkillPaths, skillPaths.map((entry) => entry.path)), this.updateSkillsFromPaths(this.lastSkillPaths)), promptPaths.length > 0 && (this.lastPromptPaths = this.mergePaths(this.lastPromptPaths, promptPaths.map((entry) => entry.path)), this.updatePromptsFromPaths(this.lastPromptPaths)), themePaths.length > 0 && (this.lastThemePaths = this.mergePaths(this.lastThemePaths, themePaths.map((entry) => entry.path)), this.updateThemesFromPaths(this.lastThemePaths));
950
+ }
951
+ resolveOnMissing(skipMissingPackageInstall) {
952
+ if (skipMissingPackageInstall)
953
+ return async () => "skip";
954
+ }
955
+ async loadProjectTrustExtensions(options) {
956
+ return this.settingsManager.setProjectTrusted(!1), await this.settingsManager.reload(), this.loadCurrentExtensionSet({
957
+ includeInlineFactories: !0,
958
+ skipMissingPackageInstall: options?.skipMissingPackageInstall
959
+ });
960
+ }
961
+ async reload(options) {
962
+ resetTimings("extensions"), this.loaded && clearExtensionCache();
963
+ let preTrustExtensions;
964
+ if (options?.resolveProjectTrust) {
965
+ preTrustExtensions = await this.loadProjectTrustExtensions(options);
966
+ let projectTrusted = await options.resolveProjectTrust({ extensionsResult: preTrustExtensions });
967
+ this.settingsManager.setProjectTrusted(projectTrusted);
968
+ }
969
+ await this.settingsManager.reload();
970
+ let resolvedPaths = await this.packageManager.resolve(this.resolveOnMissing(options?.skipMissingPackageInstall)), cliExtensionPaths = await this.packageManager.resolveExtensionSources(this.additionalExtensionPaths, {
971
+ temporary: !0
972
+ }), metadataByPath = /* @__PURE__ */ new Map();
973
+ this.extensionSkillSourceInfos = /* @__PURE__ */ new Map(), this.extensionPromptSourceInfos = /* @__PURE__ */ new Map(), this.extensionThemeSourceInfos = /* @__PURE__ */ new Map();
974
+ let getEnabledResources = (resources) => {
975
+ for (let r of resources)
976
+ metadataByPath.has(r.path) || metadataByPath.set(r.path, r.metadata);
977
+ return resources.filter((r) => r.enabled);
978
+ }, getEnabledPaths = (resources) => getEnabledResources(resources).map((r) => r.path), enabledExtensions = getEnabledPaths(resolvedPaths.extensions), enabledSkillResources = getEnabledResources(resolvedPaths.skills), enabledPrompts = getEnabledPaths(resolvedPaths.prompts), enabledThemes = getEnabledPaths(resolvedPaths.themes), enabledSkills = enabledSkillResources.map((resource) => this.mapSkillPath(resource, metadataByPath));
979
+ for (let r of cliExtensionPaths.extensions)
980
+ metadataByPath.has(r.path) || metadataByPath.set(r.path, { source: "cli", scope: "temporary", origin: "top-level" });
981
+ for (let r of cliExtensionPaths.skills)
982
+ metadataByPath.has(r.path) || metadataByPath.set(r.path, { source: "cli", scope: "temporary", origin: "top-level" });
983
+ let cliEnabledExtensions = getEnabledPaths(cliExtensionPaths.extensions), cliEnabledSkills = getEnabledPaths(cliExtensionPaths.skills), cliEnabledPrompts = getEnabledPaths(cliExtensionPaths.prompts), cliEnabledThemes = getEnabledPaths(cliExtensionPaths.themes), extensionPaths = this.noExtensions ? cliEnabledExtensions : this.mergePaths(cliEnabledExtensions, enabledExtensions), extensionsResult = await this.loadFinalExtensionSet(extensionPaths, preTrustExtensions);
984
+ for (let p of this.additionalExtensionPaths)
985
+ if (isLocalPath(p)) {
986
+ let resolved = this.resolveResourcePath(p);
987
+ existsSync4(resolved) || extensionsResult.errors.push({ path: resolved, error: `Extension path does not exist: ${resolved}` });
988
+ }
989
+ this.extensionsResult = this.extensionsOverride ? this.extensionsOverride(extensionsResult) : extensionsResult, this.applyExtensionSourceInfo(this.extensionsResult.extensions, metadataByPath);
990
+ let skillPaths = this.noSkills ? this.mergePaths(cliEnabledSkills, this.additionalSkillPaths) : this.mergePaths([...cliEnabledSkills, ...enabledSkills], this.additionalSkillPaths);
991
+ this.lastSkillPaths = skillPaths, this.updateSkillsFromPaths(skillPaths, metadataByPath);
992
+ for (let p of this.additionalSkillPaths)
993
+ if (isLocalPath(p)) {
994
+ let resolved = this.resolveResourcePath(p);
995
+ !existsSync4(resolved) && !this.skillDiagnostics.some((d) => d.path === resolved) && this.skillDiagnostics.push({ type: "error", message: "Skill path does not exist", path: resolved });
996
+ }
997
+ let promptPaths = this.noPromptTemplates ? this.mergePaths(cliEnabledPrompts, this.additionalPromptTemplatePaths) : this.mergePaths([...cliEnabledPrompts, ...enabledPrompts], this.additionalPromptTemplatePaths);
998
+ this.lastPromptPaths = promptPaths, this.updatePromptsFromPaths(promptPaths, metadataByPath);
999
+ for (let p of this.additionalPromptTemplatePaths)
1000
+ if (isLocalPath(p)) {
1001
+ let resolved = this.resolveResourcePath(p);
1002
+ !existsSync4(resolved) && !this.promptDiagnostics.some((d) => d.path === resolved) && this.promptDiagnostics.push({
1003
+ type: "error",
1004
+ message: "Prompt template path does not exist",
1005
+ path: resolved
1006
+ });
1007
+ }
1008
+ let themePaths = this.noThemes ? this.mergePaths(cliEnabledThemes, this.additionalThemePaths) : this.mergePaths([...cliEnabledThemes, ...enabledThemes], this.additionalThemePaths);
1009
+ this.lastThemePaths = themePaths, this.updateThemesFromPaths(themePaths, metadataByPath);
1010
+ for (let p of this.additionalThemePaths) {
1011
+ let resolved = this.resolveResourcePath(p);
1012
+ !existsSync4(resolved) && !this.themeDiagnostics.some((d) => d.path === resolved) && this.themeDiagnostics.push({ type: "error", message: "Theme path does not exist", path: resolved });
1013
+ }
1014
+ let agentsFiles = {
1015
+ agentsFiles: this.noContextFiles ? [] : loadProjectContextFiles({
1016
+ cwd: this.cwd,
1017
+ agentDir: this.agentDir,
1018
+ settingsManager: this.settingsManager
1019
+ })
1020
+ }, resolvedAgentsFiles = this.agentsFilesOverride ? this.agentsFilesOverride(agentsFiles) : agentsFiles;
1021
+ this.agentsFiles = resolvedAgentsFiles.agentsFiles;
1022
+ let baseSystemPrompt = resolvePromptInput(this.systemPromptSource ?? this.discoverSystemPromptFile(), "system prompt");
1023
+ this.systemPrompt = this.systemPromptOverride ? this.systemPromptOverride(baseSystemPrompt) : baseSystemPrompt;
1024
+ let baseAppend = (this.appendSystemPromptSource ?? (this.discoverAppendSystemPromptFile() ? [this.discoverAppendSystemPromptFile()] : [])).map((s) => resolvePromptInput(s, "append system prompt")).filter((s) => s !== void 0);
1025
+ this.appendSystemPrompt = this.appendSystemPromptOverride ? this.appendSystemPromptOverride(baseAppend) : baseAppend, this.loaded = !0;
1026
+ }
1027
+ async loadCurrentExtensionSet(options) {
1028
+ let resolvedPaths = await this.packageManager.resolve(this.resolveOnMissing(options.skipMissingPackageInstall)), cliExtensionPaths = await this.packageManager.resolveExtensionSources(this.additionalExtensionPaths, {
1029
+ temporary: !0
1030
+ }), enabledExtensions = resolvedPaths.extensions.filter((r) => r.enabled).map((r) => r.path), cliEnabledExtensions = cliExtensionPaths.extensions.filter((r) => r.enabled).map((r) => r.path), extensionPaths = this.noExtensions ? cliEnabledExtensions : this.mergePaths(cliEnabledExtensions, enabledExtensions), extensionsResult = await loadExtensionsCached(extensionPaths, this.cwd, this.eventBus);
1031
+ if (!options.includeInlineFactories)
1032
+ return extensionsResult;
1033
+ let inlineExtensions = await this.loadExtensionFactories(extensionsResult.runtime);
1034
+ return extensionsResult.extensions.push(...inlineExtensions.extensions), extensionsResult.errors.push(...inlineExtensions.errors), extensionsResult;
1035
+ }
1036
+ resolveExtensionLoadPath(path2) {
1037
+ return resolvePath(path2, this.cwd, { normalizeUnicodeSpaces: !0 });
1038
+ }
1039
+ async loadFinalExtensionSet(extensionPaths, preTrustExtensions) {
1040
+ if (!preTrustExtensions) {
1041
+ let extensionsResult2 = await loadExtensionsCached(extensionPaths, this.cwd, this.eventBus), inlineExtensions2 = await this.loadExtensionFactories(extensionsResult2.runtime);
1042
+ return extensionsResult2.extensions.push(...inlineExtensions2.extensions), extensionsResult2.errors.push(...inlineExtensions2.errors), this.addExtensionConflictDiagnostics(extensionsResult2), extensionsResult2;
1043
+ }
1044
+ let preloadedByPath = new Map(preTrustExtensions.extensions.filter((extension) => !extension.path.startsWith("<inline:")).map((extension) => [extension.resolvedPath, extension])), failedPreloadPaths = new Set(preTrustExtensions.errors.map((error) => this.resolveExtensionLoadPath(error.path))), remainingPaths = extensionPaths.filter((path2) => {
1045
+ let resolvedPath = this.resolveExtensionLoadPath(path2);
1046
+ return !preloadedByPath.has(resolvedPath) && !failedPreloadPaths.has(resolvedPath);
1047
+ }), remainingExtensions = await loadExtensionsCached(remainingPaths, this.cwd, this.eventBus, preTrustExtensions.runtime), loadedByPath = new Map(preloadedByPath);
1048
+ for (let extension of remainingExtensions.extensions)
1049
+ loadedByPath.set(extension.resolvedPath, extension);
1050
+ let inlineExtensions = preTrustExtensions.extensions.filter((extension) => extension.path.startsWith("<inline:")), orderedExtensions = extensionPaths.map((path2) => loadedByPath.get(this.resolveExtensionLoadPath(path2))).filter((extension) => extension !== void 0);
1051
+ orderedExtensions.push(...inlineExtensions);
1052
+ let extensionsResult = {
1053
+ extensions: orderedExtensions,
1054
+ errors: [...preTrustExtensions.errors, ...remainingExtensions.errors],
1055
+ runtime: preTrustExtensions.runtime
1056
+ };
1057
+ return this.addExtensionConflictDiagnostics(extensionsResult), extensionsResult;
1058
+ }
1059
+ addExtensionConflictDiagnostics(extensionsResult) {
1060
+ let conflicts = this.detectExtensionConflicts(extensionsResult.extensions);
1061
+ for (let conflict of conflicts)
1062
+ extensionsResult.errors.push({ path: conflict.path, error: conflict.message });
1063
+ }
1064
+ mapSkillPath(resource, metadataByPath) {
1065
+ if (resource.metadata.source !== "auto" && resource.metadata.origin !== "package")
1066
+ return resource.path;
1067
+ try {
1068
+ if (!statSync4(resource.path).isDirectory())
1069
+ return resource.path;
1070
+ } catch {
1071
+ return resource.path;
1072
+ }
1073
+ let skillFile = join4(resource.path, "SKILL.md");
1074
+ return existsSync4(skillFile) ? (metadataByPath.has(skillFile) || metadataByPath.set(skillFile, resource.metadata), skillFile) : resource.path;
1075
+ }
1076
+ normalizeExtensionPaths(entries) {
1077
+ return entries.map((entry) => {
1078
+ let metadata = entry.metadata.baseDir ? { ...entry.metadata, baseDir: this.resolveResourcePath(entry.metadata.baseDir) } : entry.metadata;
1079
+ return {
1080
+ path: this.resolveResourcePath(entry.path),
1081
+ metadata
1082
+ };
1083
+ });
1084
+ }
1085
+ updateSkillsFromPaths(skillPaths, metadataByPath) {
1086
+ let skillsResult;
1087
+ this.noSkills && skillPaths.length === 0 ? skillsResult = { skills: [], diagnostics: [] } : skillsResult = loadSkills({
1088
+ cwd: this.cwd,
1089
+ agentDir: this.agentDir,
1090
+ skillPaths,
1091
+ includeDefaults: !1
1092
+ });
1093
+ let resolvedSkills = this.skillsOverride ? this.skillsOverride(skillsResult) : skillsResult;
1094
+ this.skills = resolvedSkills.skills.map((skill) => ({
1095
+ ...skill,
1096
+ sourceInfo: this.findSourceInfoForPath(skill.filePath, this.extensionSkillSourceInfos, metadataByPath) ?? skill.sourceInfo ?? this.getDefaultSourceInfoForPath(skill.filePath)
1097
+ })), this.skillDiagnostics = resolvedSkills.diagnostics;
1098
+ }
1099
+ updatePromptsFromPaths(promptPaths, metadataByPath) {
1100
+ let promptsResult;
1101
+ if (this.noPromptTemplates && promptPaths.length === 0)
1102
+ promptsResult = { prompts: [], diagnostics: [] };
1103
+ else {
1104
+ let allPrompts = loadPromptTemplates({
1105
+ cwd: this.cwd,
1106
+ agentDir: this.agentDir,
1107
+ promptPaths,
1108
+ includeDefaults: !1
1109
+ });
1110
+ promptsResult = this.dedupePrompts(allPrompts);
1111
+ }
1112
+ let resolvedPrompts = this.promptsOverride ? this.promptsOverride(promptsResult) : promptsResult;
1113
+ this.prompts = resolvedPrompts.prompts.map((prompt) => ({
1114
+ ...prompt,
1115
+ sourceInfo: this.findSourceInfoForPath(prompt.filePath, this.extensionPromptSourceInfos, metadataByPath) ?? prompt.sourceInfo ?? this.getDefaultSourceInfoForPath(prompt.filePath)
1116
+ })), this.promptDiagnostics = resolvedPrompts.diagnostics;
1117
+ }
1118
+ updateThemesFromPaths(themePaths, metadataByPath) {
1119
+ let themesResult;
1120
+ if (this.noThemes && themePaths.length === 0)
1121
+ themesResult = { themes: [], diagnostics: [] };
1122
+ else {
1123
+ let loaded = this.loadThemes(themePaths, !1), deduped = this.dedupeThemes(loaded.themes);
1124
+ themesResult = { themes: deduped.themes, diagnostics: [...loaded.diagnostics, ...deduped.diagnostics] };
1125
+ }
1126
+ let resolvedThemes = this.themesOverride ? this.themesOverride(themesResult) : themesResult;
1127
+ this.themes = resolvedThemes.themes.map((theme) => {
1128
+ let sourcePath = theme.sourcePath;
1129
+ return theme.sourceInfo = sourcePath ? this.findSourceInfoForPath(sourcePath, this.extensionThemeSourceInfos, metadataByPath) ?? theme.sourceInfo ?? this.getDefaultSourceInfoForPath(sourcePath) : theme.sourceInfo, theme;
1130
+ }), this.themeDiagnostics = resolvedThemes.diagnostics;
1131
+ }
1132
+ applyExtensionSourceInfo(extensions, metadataByPath) {
1133
+ for (let extension of extensions) {
1134
+ extension.sourceInfo = this.findSourceInfoForPath(extension.path, void 0, metadataByPath) ?? this.getDefaultSourceInfoForPath(extension.path);
1135
+ for (let command of extension.commands.values())
1136
+ command.sourceInfo = extension.sourceInfo;
1137
+ for (let tool of extension.tools.values())
1138
+ tool.sourceInfo = extension.sourceInfo;
1139
+ }
1140
+ }
1141
+ findSourceInfoForPath(resourcePath, extraSourceInfos, metadataByPath) {
1142
+ if (!resourcePath)
1143
+ return;
1144
+ if (resourcePath.startsWith("<"))
1145
+ return this.getDefaultSourceInfoForPath(resourcePath);
1146
+ let normalizedResourcePath = resolve4(resourcePath);
1147
+ if (extraSourceInfos)
1148
+ for (let [sourcePath, sourceInfo] of extraSourceInfos.entries()) {
1149
+ let normalizedSourcePath = resolve4(sourcePath);
1150
+ if (normalizedResourcePath === normalizedSourcePath || normalizedResourcePath.startsWith(`${normalizedSourcePath}${sep3}`))
1151
+ return { ...sourceInfo, path: resourcePath };
1152
+ }
1153
+ if (metadataByPath) {
1154
+ let exact = metadataByPath.get(normalizedResourcePath) ?? metadataByPath.get(resourcePath);
1155
+ if (exact)
1156
+ return createSourceInfo(resourcePath, exact);
1157
+ for (let [sourcePath, metadata] of metadataByPath.entries()) {
1158
+ let normalizedSourcePath = resolve4(sourcePath);
1159
+ if (normalizedResourcePath === normalizedSourcePath || normalizedResourcePath.startsWith(`${normalizedSourcePath}${sep3}`))
1160
+ return createSourceInfo(resourcePath, metadata);
1161
+ }
1162
+ }
1163
+ }
1164
+ getDefaultSourceInfoForPath(filePath) {
1165
+ if (filePath.startsWith("<") && filePath.endsWith(">"))
1166
+ return {
1167
+ path: filePath,
1168
+ source: filePath.slice(1, -1).split(":")[0] || "temporary",
1169
+ scope: "temporary",
1170
+ origin: "top-level"
1171
+ };
1172
+ let normalizedPath = resolve4(filePath), agentRoots = [
1173
+ join4(this.agentDir, "skills"),
1174
+ join4(this.agentDir, "prompts"),
1175
+ join4(this.agentDir, "themes"),
1176
+ join4(this.agentDir, "extensions")
1177
+ ], projectRoots = [
1178
+ join4(this.cwd, CONFIG_DIR_NAME, "skills"),
1179
+ join4(this.cwd, CONFIG_DIR_NAME, "prompts"),
1180
+ join4(this.cwd, CONFIG_DIR_NAME, "themes"),
1181
+ join4(this.cwd, CONFIG_DIR_NAME, "extensions")
1182
+ ];
1183
+ for (let root of agentRoots)
1184
+ if (this.isUnderPath(normalizedPath, root))
1185
+ return { path: filePath, source: "local", scope: "user", origin: "top-level", baseDir: root };
1186
+ for (let root of projectRoots)
1187
+ if (this.isUnderPath(normalizedPath, root))
1188
+ return { path: filePath, source: "local", scope: "project", origin: "top-level", baseDir: root };
1189
+ return {
1190
+ path: filePath,
1191
+ source: "local",
1192
+ scope: "temporary",
1193
+ origin: "top-level",
1194
+ baseDir: statSync4(normalizedPath).isDirectory() ? normalizedPath : resolve4(normalizedPath, "..")
1195
+ };
1196
+ }
1197
+ mergePaths(primary, additional) {
1198
+ let merged = [], seen = /* @__PURE__ */ new Set();
1199
+ for (let p of [...primary, ...additional]) {
1200
+ let resolved = this.resolveResourcePath(p), canonicalPath = canonicalizePath(resolved);
1201
+ seen.has(canonicalPath) || (seen.add(canonicalPath), merged.push(resolved));
1202
+ }
1203
+ return merged;
1204
+ }
1205
+ resolveResourcePath(p) {
1206
+ return resolvePath(p, this.cwd, { trim: !0 });
1207
+ }
1208
+ loadThemes(paths, includeDefaults = !0) {
1209
+ let themes = [], diagnostics = [];
1210
+ if (includeDefaults) {
1211
+ let defaultDirs = [join4(this.agentDir, "themes"), join4(this.cwd, CONFIG_DIR_NAME, "themes")];
1212
+ for (let dir of defaultDirs)
1213
+ this.loadThemesFromDir(dir, themes, diagnostics);
1214
+ }
1215
+ for (let p of paths) {
1216
+ let resolved = this.resolveResourcePath(p);
1217
+ if (!existsSync4(resolved)) {
1218
+ diagnostics.push({ type: "warning", message: "theme path does not exist", path: resolved });
1219
+ continue;
1220
+ }
1221
+ try {
1222
+ let stats = statSync4(resolved);
1223
+ stats.isDirectory() ? this.loadThemesFromDir(resolved, themes, diagnostics) : stats.isFile() && resolved.endsWith(".json") ? this.loadThemeFromFile(resolved, themes, diagnostics) : diagnostics.push({ type: "warning", message: "theme path is not a json file", path: resolved });
1224
+ } catch (error) {
1225
+ let message = error instanceof Error ? error.message : "failed to read theme path";
1226
+ diagnostics.push({ type: "warning", message, path: resolved });
1227
+ }
1228
+ }
1229
+ return { themes, diagnostics };
1230
+ }
1231
+ loadThemesFromDir(dir, themes, diagnostics) {
1232
+ if (existsSync4(dir))
1233
+ try {
1234
+ let entries = readdirSync4(dir, { withFileTypes: !0 });
1235
+ for (let entry of entries) {
1236
+ let isFile = entry.isFile();
1237
+ if (entry.isSymbolicLink())
1238
+ try {
1239
+ isFile = statSync4(join4(dir, entry.name)).isFile();
1240
+ } catch {
1241
+ continue;
1242
+ }
1243
+ isFile && entry.name.endsWith(".json") && this.loadThemeFromFile(join4(dir, entry.name), themes, diagnostics);
1244
+ }
1245
+ } catch (error) {
1246
+ let message = error instanceof Error ? error.message : "failed to read theme directory";
1247
+ diagnostics.push({ type: "warning", message, path: dir });
1248
+ }
1249
+ }
1250
+ loadThemeFromFile(filePath, themes, diagnostics) {
1251
+ try {
1252
+ themes.push(loadThemeFromPath(filePath));
1253
+ } catch (error) {
1254
+ let message = error instanceof Error ? error.message : "failed to load theme";
1255
+ diagnostics.push({ type: "warning", message, path: filePath });
1256
+ }
1257
+ }
1258
+ async loadExtensionFactories(runtime, factories = this.extensionFactories) {
1259
+ let extensions = [], errors = [];
1260
+ for (let [index, input] of factories.entries()) {
1261
+ let factory = typeof input != "function" ? input.factory : input, extensionPath = inlineExtensionPath(input, index);
1262
+ try {
1263
+ let extension = await loadExtensionFromFactory(factory, this.cwd, this.eventBus, runtime, extensionPath);
1264
+ extensions.push(extension);
1265
+ } catch (error) {
1266
+ let message = error instanceof Error ? error.message : "failed to load extension";
1267
+ errors.push({ path: extensionPath, error: message });
1268
+ }
1269
+ }
1270
+ return { extensions, errors };
1271
+ }
1272
+ dedupePrompts(prompts) {
1273
+ let seen = /* @__PURE__ */ new Map(), diagnostics = [];
1274
+ for (let prompt of prompts) {
1275
+ let existing = seen.get(prompt.name);
1276
+ existing ? diagnostics.push({
1277
+ type: "collision",
1278
+ message: `name "/${prompt.name}" collision`,
1279
+ path: prompt.filePath,
1280
+ collision: {
1281
+ resourceType: "prompt",
1282
+ name: prompt.name,
1283
+ winnerPath: existing.filePath,
1284
+ loserPath: prompt.filePath
1285
+ }
1286
+ }) : seen.set(prompt.name, prompt);
1287
+ }
1288
+ return { prompts: Array.from(seen.values()), diagnostics };
1289
+ }
1290
+ dedupeThemes(themes) {
1291
+ let seen = /* @__PURE__ */ new Map(), diagnostics = [];
1292
+ for (let t of themes) {
1293
+ let name = t.name ?? "unnamed", existing = seen.get(name);
1294
+ existing ? diagnostics.push({
1295
+ type: "collision",
1296
+ message: `name "${name}" collision`,
1297
+ path: t.sourcePath,
1298
+ collision: {
1299
+ resourceType: "theme",
1300
+ name,
1301
+ winnerPath: existing.sourcePath ?? "<builtin>",
1302
+ loserPath: t.sourcePath ?? "<builtin>"
1303
+ }
1304
+ }) : seen.set(name, t);
1305
+ }
1306
+ return { themes: Array.from(seen.values()), diagnostics };
1307
+ }
1308
+ discoverSystemPromptFile() {
1309
+ let projectPath = join4(this.cwd, CONFIG_DIR_NAME, "SYSTEM.md");
1310
+ if (this.settingsManager.isProjectTrusted() && existsSync4(projectPath))
1311
+ return projectPath;
1312
+ let globalPath = join4(this.agentDir, "SYSTEM.md");
1313
+ if (existsSync4(globalPath))
1314
+ return globalPath;
1315
+ }
1316
+ discoverAppendSystemPromptFile() {
1317
+ let projectPath = join4(this.cwd, CONFIG_DIR_NAME, "APPEND_SYSTEM.md");
1318
+ if (this.settingsManager.isProjectTrusted() && existsSync4(projectPath))
1319
+ return projectPath;
1320
+ let globalPath = join4(this.agentDir, "APPEND_SYSTEM.md");
1321
+ if (existsSync4(globalPath))
1322
+ return globalPath;
1323
+ }
1324
+ isUnderPath(target, root) {
1325
+ let normalizedRoot = resolve4(root);
1326
+ if (target === normalizedRoot)
1327
+ return !0;
1328
+ let prefix = normalizedRoot.endsWith(sep3) ? normalizedRoot : `${normalizedRoot}${sep3}`;
1329
+ return target.startsWith(prefix);
1330
+ }
1331
+ detectExtensionConflicts(extensions) {
1332
+ let conflicts = [], toolOwners = /* @__PURE__ */ new Map(), flagOwners = /* @__PURE__ */ new Map();
1333
+ for (let ext of extensions) {
1334
+ for (let toolName of ext.tools.keys()) {
1335
+ let existingOwner = toolOwners.get(toolName);
1336
+ existingOwner && existingOwner !== ext.path ? conflicts.push({
1337
+ path: ext.path,
1338
+ message: `Tool "${toolName}" conflicts with ${existingOwner}`
1339
+ }) : toolOwners.set(toolName, ext.path);
1340
+ }
1341
+ for (let flagName of ext.flags.keys()) {
1342
+ let existingOwner = flagOwners.get(flagName);
1343
+ existingOwner && existingOwner !== ext.path ? conflicts.push({
1344
+ path: ext.path,
1345
+ message: `Flag "--${flagName}" conflicts with ${existingOwner}`
1346
+ }) : flagOwners.set(flagName, ext.path);
1347
+ }
1348
+ }
1349
+ return conflicts;
1350
+ }
1351
+ };
1352
+
1353
+ export {
1354
+ createEventBus,
1355
+ createSyntheticSourceInfo,
1356
+ createExtensionRuntime,
1357
+ discoverAndLoadExtensions,
1358
+ expandPromptTemplate,
1359
+ loadSkillsFromDir,
1360
+ formatSkillsForPrompt,
1361
+ loadSkills,
1362
+ loadProjectContextFiles,
1363
+ DefaultResourceLoader
1364
+ };