@celljs/ta 4.6.1 → 4.8.0

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 (534) hide show
  1. package/README.en.md +112 -0
  2. package/README.md +15 -2
  3. package/dist/cli.mjs +168 -110
  4. package/dist/pi/CHANGELOG.md +36 -0
  5. package/dist/pi/package.json +1 -1
  6. package/dist/pi/packages/ta-agents/README.en.md +68 -0
  7. package/dist/pi/packages/ta-agents/README.md +68 -0
  8. package/dist/pi/packages/ta-agents/extension/index.mjs +1746 -0
  9. package/dist/pi/packages/ta-agents/fixtures/fake-acp-agent.mjs +183 -0
  10. package/dist/pi/packages/ta-agents/lib/acp-agent.d.ts +52 -0
  11. package/dist/pi/packages/ta-agents/lib/acp-agent.d.ts.map +1 -0
  12. package/dist/pi/packages/ta-agents/lib/acp-agent.js +218 -0
  13. package/dist/pi/packages/ta-agents/lib/acp-agent.js.map +1 -0
  14. package/dist/pi/packages/ta-agents/lib/acp-protocol.d.ts +153 -0
  15. package/dist/pi/packages/ta-agents/lib/acp-protocol.d.ts.map +1 -0
  16. package/dist/pi/packages/ta-agents/lib/acp-protocol.js +45 -0
  17. package/dist/pi/packages/ta-agents/lib/acp-protocol.js.map +1 -0
  18. package/dist/pi/packages/ta-agents/lib/agent-bindings.d.ts +45 -0
  19. package/dist/pi/packages/ta-agents/lib/agent-bindings.d.ts.map +1 -0
  20. package/dist/pi/packages/ta-agents/lib/agent-bindings.js +135 -0
  21. package/dist/pi/packages/ta-agents/lib/agent-bindings.js.map +1 -0
  22. package/dist/pi/packages/ta-agents/lib/agent-catalog.d.ts +50 -0
  23. package/dist/pi/packages/ta-agents/lib/agent-catalog.d.ts.map +1 -0
  24. package/dist/pi/packages/ta-agents/lib/agent-catalog.js +143 -0
  25. package/dist/pi/packages/ta-agents/lib/agent-catalog.js.map +1 -0
  26. package/dist/pi/packages/ta-agents/lib/agent-prompt.d.ts +18 -0
  27. package/dist/pi/packages/ta-agents/lib/agent-prompt.d.ts.map +1 -0
  28. package/dist/pi/packages/ta-agents/lib/agent-prompt.js +86 -0
  29. package/dist/pi/packages/ta-agents/lib/agent-prompt.js.map +1 -0
  30. package/dist/pi/packages/ta-agents/lib/agent-session.d.ts +71 -0
  31. package/dist/pi/packages/ta-agents/lib/agent-session.d.ts.map +1 -0
  32. package/dist/pi/packages/ta-agents/lib/agent-session.js +215 -0
  33. package/dist/pi/packages/ta-agents/lib/agent-session.js.map +1 -0
  34. package/dist/pi/packages/ta-agents/lib/agent-streamer.d.ts +41 -0
  35. package/dist/pi/packages/ta-agents/lib/agent-streamer.d.ts.map +1 -0
  36. package/dist/pi/packages/ta-agents/lib/agent-streamer.js +163 -0
  37. package/dist/pi/packages/ta-agents/lib/agent-streamer.js.map +1 -0
  38. package/dist/pi/packages/ta-agents/lib/agent-tool.d.ts +22 -0
  39. package/dist/pi/packages/ta-agents/lib/agent-tool.d.ts.map +1 -0
  40. package/dist/pi/packages/ta-agents/lib/agent-tool.js +88 -0
  41. package/dist/pi/packages/ta-agents/lib/agent-tool.js.map +1 -0
  42. package/dist/pi/packages/ta-agents/lib/agent-turn.d.ts +115 -0
  43. package/dist/pi/packages/ta-agents/lib/agent-turn.d.ts.map +1 -0
  44. package/dist/pi/packages/ta-agents/lib/agent-turn.js +343 -0
  45. package/dist/pi/packages/ta-agents/lib/agent-turn.js.map +1 -0
  46. package/dist/pi/packages/ta-agents/lib/extension.d.ts +26 -0
  47. package/dist/pi/packages/ta-agents/lib/extension.d.ts.map +1 -0
  48. package/dist/pi/packages/ta-agents/lib/extension.js +247 -0
  49. package/dist/pi/packages/ta-agents/lib/extension.js.map +1 -0
  50. package/dist/pi/packages/ta-agents/lib/json-rpc.d.ts +41 -0
  51. package/dist/pi/packages/ta-agents/lib/json-rpc.d.ts.map +1 -0
  52. package/dist/pi/packages/ta-agents/lib/json-rpc.js +145 -0
  53. package/dist/pi/packages/ta-agents/lib/json-rpc.js.map +1 -0
  54. package/dist/pi/packages/ta-agents/lib/message-stream.d.ts +31 -0
  55. package/dist/pi/packages/ta-agents/lib/message-stream.d.ts.map +1 -0
  56. package/dist/pi/packages/ta-agents/lib/message-stream.js +134 -0
  57. package/dist/pi/packages/ta-agents/lib/message-stream.js.map +1 -0
  58. package/dist/pi/packages/ta-agents/lib/pi-types.d.ts +20 -0
  59. package/dist/pi/packages/ta-agents/lib/pi-types.d.ts.map +1 -0
  60. package/dist/pi/packages/ta-agents/lib/pi-types.js +3 -0
  61. package/dist/pi/packages/ta-agents/lib/pi-types.js.map +1 -0
  62. package/dist/pi/packages/ta-agents/lib/texts.d.ts +36 -0
  63. package/dist/pi/packages/ta-agents/lib/texts.d.ts.map +1 -0
  64. package/dist/pi/packages/ta-agents/lib/texts.js +43 -0
  65. package/dist/pi/packages/ta-agents/lib/texts.js.map +1 -0
  66. package/dist/pi/packages/ta-agents/package.json +53 -0
  67. package/dist/pi/packages/ta-changes/README.en.md +21 -0
  68. package/dist/pi/packages/ta-changes/README.md +21 -0
  69. package/dist/pi/packages/ta-changes/extension/index.mjs +296 -0
  70. package/dist/pi/packages/ta-changes/host/index.mjs +309 -0
  71. package/dist/pi/packages/ta-changes/lib/blob-store.d.ts +16 -0
  72. package/dist/pi/packages/ta-changes/lib/blob-store.d.ts.map +1 -0
  73. package/dist/pi/packages/ta-changes/lib/blob-store.js +69 -0
  74. package/dist/pi/packages/ta-changes/lib/blob-store.js.map +1 -0
  75. package/dist/pi/packages/ta-changes/lib/card.d.ts +12 -0
  76. package/dist/pi/packages/ta-changes/lib/card.d.ts.map +1 -0
  77. package/dist/pi/packages/ta-changes/lib/card.js +149 -0
  78. package/dist/pi/packages/ta-changes/lib/card.js.map +1 -0
  79. package/dist/pi/packages/ta-changes/lib/changes-protocol.d.ts +76 -0
  80. package/dist/pi/packages/ta-changes/lib/changes-protocol.d.ts.map +1 -0
  81. package/dist/pi/packages/ta-changes/lib/changes-protocol.js +20 -0
  82. package/dist/pi/packages/ta-changes/lib/changes-protocol.js.map +1 -0
  83. package/dist/pi/packages/ta-changes/lib/changes-service.d.ts +20 -0
  84. package/dist/pi/packages/ta-changes/lib/changes-service.d.ts.map +1 -0
  85. package/dist/pi/packages/ta-changes/lib/changes-service.js +70 -0
  86. package/dist/pi/packages/ta-changes/lib/changes-service.js.map +1 -0
  87. package/dist/pi/packages/ta-changes/lib/changes-util.d.ts +21 -0
  88. package/dist/pi/packages/ta-changes/lib/changes-util.d.ts.map +1 -0
  89. package/dist/pi/packages/ta-changes/lib/changes-util.js +44 -0
  90. package/dist/pi/packages/ta-changes/lib/changes-util.js.map +1 -0
  91. package/dist/pi/packages/ta-changes/lib/diff-tab.d.ts +4 -0
  92. package/dist/pi/packages/ta-changes/lib/diff-tab.d.ts.map +1 -0
  93. package/dist/pi/packages/ta-changes/lib/diff-tab.js +45 -0
  94. package/dist/pi/packages/ta-changes/lib/diff-tab.js.map +1 -0
  95. package/dist/pi/packages/ta-changes/lib/extension.d.ts +21 -0
  96. package/dist/pi/packages/ta-changes/lib/extension.d.ts.map +1 -0
  97. package/dist/pi/packages/ta-changes/lib/extension.js +106 -0
  98. package/dist/pi/packages/ta-changes/lib/extension.js.map +1 -0
  99. package/dist/pi/packages/ta-changes/lib/host.d.ts +7 -0
  100. package/dist/pi/packages/ta-changes/lib/host.d.ts.map +1 -0
  101. package/dist/pi/packages/ta-changes/lib/host.js +16 -0
  102. package/dist/pi/packages/ta-changes/lib/host.js.map +1 -0
  103. package/dist/pi/packages/ta-changes/lib/i18n.d.ts +30 -0
  104. package/dist/pi/packages/ta-changes/lib/i18n.d.ts.map +1 -0
  105. package/dist/pi/packages/ta-changes/lib/i18n.js +61 -0
  106. package/dist/pi/packages/ta-changes/lib/i18n.js.map +1 -0
  107. package/dist/pi/packages/ta-changes/lib/index.d.ts +8 -0
  108. package/dist/pi/packages/ta-changes/lib/index.d.ts.map +1 -0
  109. package/dist/pi/packages/ta-changes/lib/index.js +28 -0
  110. package/dist/pi/packages/ta-changes/lib/index.js.map +1 -0
  111. package/dist/pi/packages/ta-changes/lib/line-diff.d.ts +11 -0
  112. package/dist/pi/packages/ta-changes/lib/line-diff.d.ts.map +1 -0
  113. package/dist/pi/packages/ta-changes/lib/line-diff.js +69 -0
  114. package/dist/pi/packages/ta-changes/lib/line-diff.js.map +1 -0
  115. package/dist/pi/packages/ta-changes/lib/page.d.ts +29 -0
  116. package/dist/pi/packages/ta-changes/lib/page.d.ts.map +1 -0
  117. package/dist/pi/packages/ta-changes/lib/page.js +106 -0
  118. package/dist/pi/packages/ta-changes/lib/page.js.map +1 -0
  119. package/dist/pi/packages/ta-changes/lib/react.d.ts +8 -0
  120. package/dist/pi/packages/ta-changes/lib/react.d.ts.map +1 -0
  121. package/dist/pi/packages/ta-changes/lib/react.js +8 -0
  122. package/dist/pi/packages/ta-changes/lib/react.js.map +1 -0
  123. package/dist/pi/packages/ta-changes/lib/recorder.d.ts +25 -0
  124. package/dist/pi/packages/ta-changes/lib/recorder.d.ts.map +1 -0
  125. package/dist/pi/packages/ta-changes/lib/recorder.js +117 -0
  126. package/dist/pi/packages/ta-changes/lib/recorder.js.map +1 -0
  127. package/dist/pi/packages/ta-changes/lib/style.d.ts +4 -0
  128. package/dist/pi/packages/ta-changes/lib/style.d.ts.map +1 -0
  129. package/dist/pi/packages/ta-changes/lib/style.js +44 -0
  130. package/dist/pi/packages/ta-changes/lib/style.js.map +1 -0
  131. package/dist/pi/packages/ta-changes/package.json +46 -0
  132. package/dist/pi/packages/ta-changes/web/index.js +460 -0
  133. package/dist/pi/packages/ta-channels/README.en.md +48 -0
  134. package/dist/pi/packages/ta-channels/README.md +1 -1
  135. package/dist/pi/packages/ta-channels/extension/index.mjs +8 -4
  136. package/dist/pi/packages/ta-channels/host/index.mjs +22 -3
  137. package/dist/pi/packages/ta-channels/lib/channels-model.d.ts +4 -1
  138. package/dist/pi/packages/ta-channels/lib/channels-model.d.ts.map +1 -1
  139. package/dist/pi/packages/ta-channels/lib/channels-model.js.map +1 -1
  140. package/dist/pi/packages/ta-channels/lib/channels-util.d.ts +2 -0
  141. package/dist/pi/packages/ta-channels/lib/channels-util.d.ts.map +1 -1
  142. package/dist/pi/packages/ta-channels/lib/channels-util.js +6 -1
  143. package/dist/pi/packages/ta-channels/lib/channels-util.js.map +1 -1
  144. package/dist/pi/packages/ta-channels/lib/channels.js +1 -1
  145. package/dist/pi/packages/ta-channels/lib/channels.js.map +1 -1
  146. package/dist/pi/packages/ta-channels/lib/extension.d.ts +2 -2
  147. package/dist/pi/packages/ta-channels/lib/extension.d.ts.map +1 -1
  148. package/dist/pi/packages/ta-channels/lib/extension.js +2 -2
  149. package/dist/pi/packages/ta-channels/lib/extension.js.map +1 -1
  150. package/dist/pi/packages/ta-channels/lib/sidebar.d.ts.map +1 -1
  151. package/dist/pi/packages/ta-channels/lib/sidebar.js +4 -2
  152. package/dist/pi/packages/ta-channels/lib/sidebar.js.map +1 -1
  153. package/dist/pi/packages/ta-channels/lib/style.d.ts +1 -1
  154. package/dist/pi/packages/ta-channels/lib/style.d.ts.map +1 -1
  155. package/dist/pi/packages/ta-channels/lib/style.js +1 -0
  156. package/dist/pi/packages/ta-channels/lib/style.js.map +1 -1
  157. package/dist/pi/packages/ta-channels/lib/team-tools.js +1 -1
  158. package/dist/pi/packages/ta-channels/lib/team-tools.js.map +1 -1
  159. package/dist/pi/packages/ta-channels/lib/team.d.ts +7 -1
  160. package/dist/pi/packages/ta-channels/lib/team.d.ts.map +1 -1
  161. package/dist/pi/packages/ta-channels/lib/team.js +25 -2
  162. package/dist/pi/packages/ta-channels/lib/team.js.map +1 -1
  163. package/dist/pi/packages/ta-channels/lib/views.d.ts +3 -1
  164. package/dist/pi/packages/ta-channels/lib/views.d.ts.map +1 -1
  165. package/dist/pi/packages/ta-channels/lib/views.js +12 -1
  166. package/dist/pi/packages/ta-channels/lib/views.js.map +1 -1
  167. package/dist/pi/packages/ta-channels/package.json +1 -1
  168. package/dist/pi/packages/ta-channels/web/index.js +23 -5
  169. package/dist/pi/packages/ta-computer-use/README.en.md +37 -0
  170. package/dist/pi/packages/ta-computer-use/README.md +37 -0
  171. package/dist/pi/packages/ta-computer-use/extension/index.mjs +551 -0
  172. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.d.ts +72 -0
  173. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.d.ts.map +1 -0
  174. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.js +149 -0
  175. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.js.map +1 -0
  176. package/dist/pi/packages/ta-computer-use/lib/cua-driver-daemon.d.ts +78 -0
  177. package/dist/pi/packages/ta-computer-use/lib/cua-driver-daemon.d.ts.map +1 -0
  178. package/dist/pi/packages/ta-computer-use/lib/cua-driver-daemon.js +250 -0
  179. package/dist/pi/packages/ta-computer-use/lib/cua-driver-daemon.js.map +1 -0
  180. package/dist/pi/packages/ta-computer-use/lib/cua-driver.d.ts +56 -0
  181. package/dist/pi/packages/ta-computer-use/lib/cua-driver.d.ts.map +1 -0
  182. package/dist/pi/packages/ta-computer-use/lib/cua-driver.js +112 -0
  183. package/dist/pi/packages/ta-computer-use/lib/cua-driver.js.map +1 -0
  184. package/dist/pi/packages/ta-computer-use/lib/extension.d.ts +39 -0
  185. package/dist/pi/packages/ta-computer-use/lib/extension.d.ts.map +1 -0
  186. package/dist/pi/packages/ta-computer-use/lib/extension.js +174 -0
  187. package/dist/pi/packages/ta-computer-use/lib/extension.js.map +1 -0
  188. package/dist/pi/packages/ta-computer-use/lib/pi-types.d.ts +3 -0
  189. package/dist/pi/packages/ta-computer-use/lib/pi-types.d.ts.map +1 -0
  190. package/dist/pi/packages/ta-computer-use/lib/pi-types.js +3 -0
  191. package/dist/pi/packages/ta-computer-use/lib/pi-types.js.map +1 -0
  192. package/dist/pi/packages/ta-computer-use/package.json +51 -0
  193. package/dist/pi/packages/ta-cron/README.en.md +48 -0
  194. package/dist/pi/packages/ta-cron/README.md +48 -0
  195. package/dist/pi/packages/ta-cron/extension/index.mjs +856 -0
  196. package/dist/pi/packages/ta-cron/host/index.mjs +877 -0
  197. package/dist/pi/packages/ta-cron/lib/commands.d.ts +61 -0
  198. package/dist/pi/packages/ta-cron/lib/commands.d.ts.map +1 -0
  199. package/dist/pi/packages/ta-cron/lib/commands.js +250 -0
  200. package/dist/pi/packages/ta-cron/lib/commands.js.map +1 -0
  201. package/dist/pi/packages/ta-cron/lib/cron-expression.d.ts +39 -0
  202. package/dist/pi/packages/ta-cron/lib/cron-expression.d.ts.map +1 -0
  203. package/dist/pi/packages/ta-cron/lib/cron-expression.js +146 -0
  204. package/dist/pi/packages/ta-cron/lib/cron-expression.js.map +1 -0
  205. package/dist/pi/packages/ta-cron/lib/cron-protocol.d.ts +160 -0
  206. package/dist/pi/packages/ta-cron/lib/cron-protocol.d.ts.map +1 -0
  207. package/dist/pi/packages/ta-cron/lib/cron-protocol.js +38 -0
  208. package/dist/pi/packages/ta-cron/lib/cron-protocol.js.map +1 -0
  209. package/dist/pi/packages/ta-cron/lib/editor.d.ts +17 -0
  210. package/dist/pi/packages/ta-cron/lib/editor.d.ts.map +1 -0
  211. package/dist/pi/packages/ta-cron/lib/editor.js +145 -0
  212. package/dist/pi/packages/ta-cron/lib/editor.js.map +1 -0
  213. package/dist/pi/packages/ta-cron/lib/extension.d.ts +27 -0
  214. package/dist/pi/packages/ta-cron/lib/extension.d.ts.map +1 -0
  215. package/dist/pi/packages/ta-cron/lib/extension.js +142 -0
  216. package/dist/pi/packages/ta-cron/lib/extension.js.map +1 -0
  217. package/dist/pi/packages/ta-cron/lib/form-util.d.ts +39 -0
  218. package/dist/pi/packages/ta-cron/lib/form-util.d.ts.map +1 -0
  219. package/dist/pi/packages/ta-cron/lib/form-util.js +121 -0
  220. package/dist/pi/packages/ta-cron/lib/form-util.js.map +1 -0
  221. package/dist/pi/packages/ta-cron/lib/host.d.ts +7 -0
  222. package/dist/pi/packages/ta-cron/lib/host.d.ts.map +1 -0
  223. package/dist/pi/packages/ta-cron/lib/host.js +14 -0
  224. package/dist/pi/packages/ta-cron/lib/host.js.map +1 -0
  225. package/dist/pi/packages/ta-cron/lib/i18n.d.ts +90 -0
  226. package/dist/pi/packages/ta-cron/lib/i18n.d.ts.map +1 -0
  227. package/dist/pi/packages/ta-cron/lib/i18n.js +177 -0
  228. package/dist/pi/packages/ta-cron/lib/i18n.js.map +1 -0
  229. package/dist/pi/packages/ta-cron/lib/index.d.ts +8 -0
  230. package/dist/pi/packages/ta-cron/lib/index.d.ts.map +1 -0
  231. package/dist/pi/packages/ta-cron/lib/index.js +37 -0
  232. package/dist/pi/packages/ta-cron/lib/index.js.map +1 -0
  233. package/dist/pi/packages/ta-cron/lib/model-picker.d.ts +33 -0
  234. package/dist/pi/packages/ta-cron/lib/model-picker.d.ts.map +1 -0
  235. package/dist/pi/packages/ta-cron/lib/model-picker.js +178 -0
  236. package/dist/pi/packages/ta-cron/lib/model-picker.js.map +1 -0
  237. package/dist/pi/packages/ta-cron/lib/notifier.d.ts +6 -0
  238. package/dist/pi/packages/ta-cron/lib/notifier.d.ts.map +1 -0
  239. package/dist/pi/packages/ta-cron/lib/notifier.js +50 -0
  240. package/dist/pi/packages/ta-cron/lib/notifier.js.map +1 -0
  241. package/dist/pi/packages/ta-cron/lib/page.d.ts +39 -0
  242. package/dist/pi/packages/ta-cron/lib/page.d.ts.map +1 -0
  243. package/dist/pi/packages/ta-cron/lib/page.js +113 -0
  244. package/dist/pi/packages/ta-cron/lib/page.js.map +1 -0
  245. package/dist/pi/packages/ta-cron/lib/react.d.ts +8 -0
  246. package/dist/pi/packages/ta-cron/lib/react.d.ts.map +1 -0
  247. package/dist/pi/packages/ta-cron/lib/react.js +8 -0
  248. package/dist/pi/packages/ta-cron/lib/react.js.map +1 -0
  249. package/dist/pi/packages/ta-cron/lib/reply.d.ts +6 -0
  250. package/dist/pi/packages/ta-cron/lib/reply.d.ts.map +1 -0
  251. package/dist/pi/packages/ta-cron/lib/reply.js +53 -0
  252. package/dist/pi/packages/ta-cron/lib/reply.js.map +1 -0
  253. package/dist/pi/packages/ta-cron/lib/schedule-util.d.ts +25 -0
  254. package/dist/pi/packages/ta-cron/lib/schedule-util.d.ts.map +1 -0
  255. package/dist/pi/packages/ta-cron/lib/schedule-util.js +223 -0
  256. package/dist/pi/packages/ta-cron/lib/schedule-util.js.map +1 -0
  257. package/dist/pi/packages/ta-cron/lib/scheduler.d.ts +76 -0
  258. package/dist/pi/packages/ta-cron/lib/scheduler.d.ts.map +1 -0
  259. package/dist/pi/packages/ta-cron/lib/scheduler.js +319 -0
  260. package/dist/pi/packages/ta-cron/lib/scheduler.js.map +1 -0
  261. package/dist/pi/packages/ta-cron/lib/server-texts.d.ts +7 -0
  262. package/dist/pi/packages/ta-cron/lib/server-texts.d.ts.map +1 -0
  263. package/dist/pi/packages/ta-cron/lib/server-texts.js +24 -0
  264. package/dist/pi/packages/ta-cron/lib/server-texts.js.map +1 -0
  265. package/dist/pi/packages/ta-cron/lib/style.d.ts +4 -0
  266. package/dist/pi/packages/ta-cron/lib/style.d.ts.map +1 -0
  267. package/dist/pi/packages/ta-cron/lib/style.js +137 -0
  268. package/dist/pi/packages/ta-cron/lib/style.js.map +1 -0
  269. package/dist/pi/packages/ta-cron/lib/task-store.d.ts +25 -0
  270. package/dist/pi/packages/ta-cron/lib/task-store.d.ts.map +1 -0
  271. package/dist/pi/packages/ta-cron/lib/task-store.js +60 -0
  272. package/dist/pi/packages/ta-cron/lib/task-store.js.map +1 -0
  273. package/dist/pi/packages/ta-cron/lib/task-util.d.ts +18 -0
  274. package/dist/pi/packages/ta-cron/lib/task-util.d.ts.map +1 -0
  275. package/dist/pi/packages/ta-cron/lib/task-util.js +167 -0
  276. package/dist/pi/packages/ta-cron/lib/task-util.js.map +1 -0
  277. package/dist/pi/packages/ta-cron/lib/tasks-view.d.ts +6 -0
  278. package/dist/pi/packages/ta-cron/lib/tasks-view.d.ts.map +1 -0
  279. package/dist/pi/packages/ta-cron/lib/tasks-view.js +189 -0
  280. package/dist/pi/packages/ta-cron/lib/tasks-view.js.map +1 -0
  281. package/dist/pi/packages/ta-cron/lib/tool.d.ts +85 -0
  282. package/dist/pi/packages/ta-cron/lib/tool.d.ts.map +1 -0
  283. package/dist/pi/packages/ta-cron/lib/tool.js +127 -0
  284. package/dist/pi/packages/ta-cron/lib/tool.js.map +1 -0
  285. package/dist/pi/packages/ta-cron/package.json +46 -0
  286. package/dist/pi/packages/ta-cron/web/index.js +1985 -0
  287. package/dist/pi/packages/ta-extensions/README.en.md +27 -0
  288. package/dist/pi/packages/ta-extensions/README.md +10 -3
  289. package/dist/pi/packages/ta-extensions/host/index.mjs +331 -1
  290. package/dist/pi/packages/ta-extensions/lib/actions.d.ts +5 -1
  291. package/dist/pi/packages/ta-extensions/lib/actions.d.ts.map +1 -1
  292. package/dist/pi/packages/ta-extensions/lib/actions.js +20 -1
  293. package/dist/pi/packages/ta-extensions/lib/actions.js.map +1 -1
  294. package/dist/pi/packages/ta-extensions/lib/context.d.ts +20 -0
  295. package/dist/pi/packages/ta-extensions/lib/context.d.ts.map +1 -0
  296. package/dist/pi/packages/ta-extensions/lib/context.js +8 -0
  297. package/dist/pi/packages/ta-extensions/lib/context.js.map +1 -0
  298. package/dist/pi/packages/ta-extensions/lib/host.d.ts +8 -2
  299. package/dist/pi/packages/ta-extensions/lib/host.d.ts.map +1 -1
  300. package/dist/pi/packages/ta-extensions/lib/host.js +11 -2
  301. package/dist/pi/packages/ta-extensions/lib/host.js.map +1 -1
  302. package/dist/pi/packages/ta-extensions/lib/i18n.d.ts +32 -0
  303. package/dist/pi/packages/ta-extensions/lib/i18n.d.ts.map +1 -1
  304. package/dist/pi/packages/ta-extensions/lib/i18n.js +78 -2
  305. package/dist/pi/packages/ta-extensions/lib/i18n.js.map +1 -1
  306. package/dist/pi/packages/ta-extensions/lib/index.d.ts +2 -1
  307. package/dist/pi/packages/ta-extensions/lib/index.d.ts.map +1 -1
  308. package/dist/pi/packages/ta-extensions/lib/index.js +25 -21
  309. package/dist/pi/packages/ta-extensions/lib/index.js.map +1 -1
  310. package/dist/pi/packages/ta-extensions/lib/market-detail.d.ts +12 -0
  311. package/dist/pi/packages/ta-extensions/lib/market-detail.d.ts.map +1 -0
  312. package/dist/pi/packages/ta-extensions/lib/market-detail.js +95 -0
  313. package/dist/pi/packages/ta-extensions/lib/market-detail.js.map +1 -0
  314. package/dist/pi/packages/ta-extensions/lib/market-parts.d.ts +33 -0
  315. package/dist/pi/packages/ta-extensions/lib/market-parts.d.ts.map +1 -0
  316. package/dist/pi/packages/ta-extensions/lib/market-parts.js +56 -0
  317. package/dist/pi/packages/ta-extensions/lib/market-parts.js.map +1 -0
  318. package/dist/pi/packages/ta-extensions/lib/market-store.d.ts +41 -0
  319. package/dist/pi/packages/ta-extensions/lib/market-store.d.ts.map +1 -0
  320. package/dist/pi/packages/ta-extensions/lib/market-store.js +99 -0
  321. package/dist/pi/packages/ta-extensions/lib/market-store.js.map +1 -0
  322. package/dist/pi/packages/ta-extensions/lib/market-style.d.ts +3 -0
  323. package/dist/pi/packages/ta-extensions/lib/market-style.d.ts.map +1 -0
  324. package/dist/pi/packages/ta-extensions/lib/market-style.js +98 -0
  325. package/dist/pi/packages/ta-extensions/lib/market-style.js.map +1 -0
  326. package/dist/pi/packages/ta-extensions/lib/market-util.d.ts +74 -0
  327. package/dist/pi/packages/ta-extensions/lib/market-util.d.ts.map +1 -0
  328. package/dist/pi/packages/ta-extensions/lib/market-util.js +193 -0
  329. package/dist/pi/packages/ta-extensions/lib/market-util.js.map +1 -0
  330. package/dist/pi/packages/ta-extensions/lib/market-view.d.ts +9 -0
  331. package/dist/pi/packages/ta-extensions/lib/market-view.d.ts.map +1 -0
  332. package/dist/pi/packages/ta-extensions/lib/market-view.js +144 -0
  333. package/dist/pi/packages/ta-extensions/lib/market-view.js.map +1 -0
  334. package/dist/pi/packages/ta-extensions/lib/market.d.ts +88 -0
  335. package/dist/pi/packages/ta-extensions/lib/market.d.ts.map +1 -0
  336. package/dist/pi/packages/ta-extensions/lib/market.js +198 -0
  337. package/dist/pi/packages/ta-extensions/lib/market.js.map +1 -0
  338. package/dist/pi/packages/ta-extensions/lib/page.d.ts +3 -16
  339. package/dist/pi/packages/ta-extensions/lib/page.d.ts.map +1 -1
  340. package/dist/pi/packages/ta-extensions/lib/page.js +87 -58
  341. package/dist/pi/packages/ta-extensions/lib/page.js.map +1 -1
  342. package/dist/pi/packages/ta-extensions/lib/signal.d.ts +12 -0
  343. package/dist/pi/packages/ta-extensions/lib/signal.d.ts.map +1 -0
  344. package/dist/pi/packages/ta-extensions/lib/signal.js +32 -0
  345. package/dist/pi/packages/ta-extensions/lib/signal.js.map +1 -0
  346. package/dist/pi/packages/ta-extensions/lib/style.d.ts +1 -1
  347. package/dist/pi/packages/ta-extensions/lib/style.d.ts.map +1 -1
  348. package/dist/pi/packages/ta-extensions/lib/style.js +3 -2
  349. package/dist/pi/packages/ta-extensions/lib/style.js.map +1 -1
  350. package/dist/pi/packages/ta-extensions/package.json +1 -1
  351. package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +3 -2
  352. package/dist/pi/packages/ta-extensions/web/index.js +937 -54
  353. package/dist/pi/packages/ta-workspace/README.md +5 -5
  354. package/dist/pi/packages/ta-workspace/README.zh-cn.md +29 -0
  355. package/dist/pi/packages/ta-workspace/lib/browser-agent.d.ts +36 -0
  356. package/dist/pi/packages/ta-workspace/lib/browser-agent.d.ts.map +1 -0
  357. package/dist/pi/packages/ta-workspace/lib/browser-agent.js +396 -0
  358. package/dist/pi/packages/ta-workspace/lib/browser-agent.js.map +1 -0
  359. package/dist/pi/packages/ta-workspace/lib/browser-common.d.ts +48 -0
  360. package/dist/pi/packages/ta-workspace/lib/browser-common.d.ts.map +1 -0
  361. package/dist/pi/packages/ta-workspace/lib/browser-common.js +180 -0
  362. package/dist/pi/packages/ta-workspace/lib/browser-common.js.map +1 -0
  363. package/dist/pi/packages/ta-workspace/lib/browser-import.d.ts +5 -0
  364. package/dist/pi/packages/ta-workspace/lib/browser-import.d.ts.map +1 -0
  365. package/dist/pi/packages/ta-workspace/lib/browser-import.js +97 -0
  366. package/dist/pi/packages/ta-workspace/lib/browser-import.js.map +1 -0
  367. package/dist/pi/packages/ta-workspace/lib/browser-webview.d.ts +7 -0
  368. package/dist/pi/packages/ta-workspace/lib/browser-webview.d.ts.map +1 -0
  369. package/dist/pi/packages/ta-workspace/lib/browser-webview.js +202 -0
  370. package/dist/pi/packages/ta-workspace/lib/browser-webview.js.map +1 -0
  371. package/dist/pi/packages/ta-workspace/lib/browser.d.ts +1 -7
  372. package/dist/pi/packages/ta-workspace/lib/browser.d.ts.map +1 -1
  373. package/dist/pi/packages/ta-workspace/lib/browser.js +14 -130
  374. package/dist/pi/packages/ta-workspace/lib/browser.js.map +1 -1
  375. package/dist/pi/packages/ta-workspace/lib/explorer.d.ts.map +1 -1
  376. package/dist/pi/packages/ta-workspace/lib/explorer.js +214 -3
  377. package/dist/pi/packages/ta-workspace/lib/explorer.js.map +1 -1
  378. package/dist/pi/packages/ta-workspace/lib/i18n.d.ts +37 -0
  379. package/dist/pi/packages/ta-workspace/lib/i18n.d.ts.map +1 -1
  380. package/dist/pi/packages/ta-workspace/lib/i18n.js +76 -2
  381. package/dist/pi/packages/ta-workspace/lib/i18n.js.map +1 -1
  382. package/dist/pi/packages/ta-workspace/lib/index.d.ts.map +1 -1
  383. package/dist/pi/packages/ta-workspace/lib/index.js +7 -1
  384. package/dist/pi/packages/ta-workspace/lib/index.js.map +1 -1
  385. package/dist/pi/packages/ta-workspace/lib/style.d.ts +1 -1
  386. package/dist/pi/packages/ta-workspace/lib/style.d.ts.map +1 -1
  387. package/dist/pi/packages/ta-workspace/lib/style.js +35 -6
  388. package/dist/pi/packages/ta-workspace/lib/style.js.map +1 -1
  389. package/dist/pi/packages/ta-workspace/lib/terminal.d.ts +2 -2
  390. package/dist/pi/packages/ta-workspace/lib/terminal.d.ts.map +1 -1
  391. package/dist/pi/packages/ta-workspace/lib/terminal.js +50 -104
  392. package/dist/pi/packages/ta-workspace/lib/terminal.js.map +1 -1
  393. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.d.ts +52 -0
  394. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.d.ts.map +1 -0
  395. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.js +207 -0
  396. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.js.map +1 -0
  397. package/dist/pi/packages/ta-workspace/lib/util/upload.d.ts +34 -0
  398. package/dist/pi/packages/ta-workspace/lib/util/upload.d.ts.map +1 -0
  399. package/dist/pi/packages/ta-workspace/lib/util/upload.js +109 -0
  400. package/dist/pi/packages/ta-workspace/lib/util/upload.js.map +1 -0
  401. package/dist/pi/packages/ta-workspace/lib/util/workspace.d.ts +20 -0
  402. package/dist/pi/packages/ta-workspace/lib/util/workspace.d.ts.map +1 -1
  403. package/dist/pi/packages/ta-workspace/lib/util/workspace.js +67 -0
  404. package/dist/pi/packages/ta-workspace/lib/util/workspace.js.map +1 -1
  405. package/dist/pi/packages/ta-workspace/lib/util/zip.d.ts +20 -0
  406. package/dist/pi/packages/ta-workspace/lib/util/zip.d.ts.map +1 -0
  407. package/dist/pi/packages/ta-workspace/lib/util/zip.js +128 -0
  408. package/dist/pi/packages/ta-workspace/lib/util/zip.js.map +1 -0
  409. package/dist/pi/packages/ta-workspace/lib/workspace-client.d.ts +12 -1
  410. package/dist/pi/packages/ta-workspace/lib/workspace-client.d.ts.map +1 -1
  411. package/dist/pi/packages/ta-workspace/lib/workspace-client.js +101 -0
  412. package/dist/pi/packages/ta-workspace/lib/workspace-client.js.map +1 -1
  413. package/dist/pi/packages/ta-workspace/package.json +1 -1
  414. package/dist/pi/packages/ta-workspace/web/index.js +1955 -637
  415. package/dist/public/assets/{abnfDiagram-S7VZAUFO-3_0FZVeo.js → abnfDiagram-S7VZAUFO-CNqfsCwx.js} +1 -1
  416. package/dist/public/assets/{architecture-WOLXFQ4H-BX-N-_gd.js → architecture-WOLXFQ4H-_WaGq-Qk.js} +1 -1
  417. package/dist/public/assets/{architectureDiagram-YGSQEFNW-Daeu1xjI.js → architectureDiagram-YGSQEFNW-Bn63Lctu.js} +1 -1
  418. package/dist/public/assets/{blockDiagram-APKKGZFW-DjJS8902.js → blockDiagram-APKKGZFW-BGaAecnk.js} +1 -1
  419. package/dist/public/assets/{browser-DZ1aJcgd.js → browser-DKagIN4Y.js} +1 -1
  420. package/dist/public/assets/{c4Diagram-KJ2TOQU5-mKfHFqh9.js → c4Diagram-KJ2TOQU5-CK9Z_9Zp.js} +1 -1
  421. package/dist/public/assets/{chunk-6MUBBAK2-Cnx7dsB1.js → chunk-6MUBBAK2-H3j3MGva.js} +1 -1
  422. package/dist/public/assets/{chunk-AXFCVDMN-g4Y7Pg2t.js → chunk-AXFCVDMN-Beljdjs9.js} +1 -1
  423. package/dist/public/assets/{chunk-BG4553SI-QNE6A_Vg.js → chunk-BG4553SI-TYEV5wLO.js} +1 -1
  424. package/dist/public/assets/{chunk-DQASFODM-DPHr08r0.js → chunk-DQASFODM-gmWJrizf.js} +1 -1
  425. package/dist/public/assets/{chunk-HFQBQIA3-CenkxHlV.js → chunk-HFQBQIA3-BTa7yKXI.js} +1 -1
  426. package/dist/public/assets/{chunk-KQLB2F66-C3Z8V8R_.js → chunk-KQLB2F66-BlwMm4R0.js} +1 -1
  427. package/dist/public/assets/{chunk-KS47KZWR-BbUyxMWY.js → chunk-KS47KZWR-CKTXjzwD.js} +1 -1
  428. package/dist/public/assets/{chunk-LEVMRMFU-CKECy4cp.js → chunk-LEVMRMFU-Bn9Xkefl.js} +1 -1
  429. package/dist/public/assets/{chunk-M57EVK23-DuZd8RGI.js → chunk-M57EVK23-B_QLqohG.js} +1 -1
  430. package/dist/public/assets/{chunk-OY52VR5R-DatO2fu-.js → chunk-OY52VR5R-BflzJHPz.js} +1 -1
  431. package/dist/public/assets/{chunk-QB3YPZ4I-11782Ox2.js → chunk-QB3YPZ4I-BXucfaFg.js} +1 -1
  432. package/dist/public/assets/{chunk-R3KSYZAL-CCTi2rHV.js → chunk-R3KSYZAL-CGwkwxm9.js} +1 -1
  433. package/dist/public/assets/{chunk-STOXU5M4-DU6EHCIH.js → chunk-STOXU5M4-DQGOPuM5.js} +1 -1
  434. package/dist/public/assets/{chunk-TU62E6Q5-BtgGljqq.js → chunk-TU62E6Q5-BCrs6AYI.js} +1 -1
  435. package/dist/public/assets/{chunk-X4PVCEUW-Dd_Qy0Gx.js → chunk-X4PVCEUW-MTv7nXJX.js} +1 -1
  436. package/dist/public/assets/{chunk-XXDRQBXY-DjOrWHxV.js → chunk-XXDRQBXY-fPaX8VIb.js} +1 -1
  437. package/dist/public/assets/{classDiagram-v2-L25IHNXF-KfN1--CA.js → classDiagram-v2-L25IHNXF-tm4uT08q.js} +1 -1
  438. package/dist/public/assets/{cose-bilkent-JH36ORCC-BuWVQ5UC.js → cose-bilkent-JH36ORCC-Dkk3pDZj.js} +1 -1
  439. package/dist/public/assets/cynefin-EF2NZ3EQ-D_QV_BJg.js +1 -0
  440. package/dist/public/assets/{cynefinDiagram-L36ESFBY-BKljxAVP.js → cynefinDiagram-L36ESFBY-BcoArW00.js} +1 -1
  441. package/dist/public/assets/{d3-selection-CtCbiJ-r.js → d3-selection-BzUITLov.js} +1 -1
  442. package/dist/public/assets/{dagre-SPEB5RXH-nD3f86OL.js → dagre-SPEB5RXH-oiU-wJxw.js} +1 -1
  443. package/dist/public/assets/{diagram-3B7GL73J-wSVpHF4f.js → diagram-3B7GL73J-BwlCOIW4.js} +1 -1
  444. package/dist/public/assets/{diagram-DNEMPZML-BOkeaSpr.js → diagram-DNEMPZML-CZGQiFrl.js} +1 -1
  445. package/dist/public/assets/{diagram-L3MUGCDN-CRCErdiz.js → diagram-L3MUGCDN-BJGDa24C.js} +1 -1
  446. package/dist/public/assets/{diagram-LA4NIPWU-y5kaOsii.js → diagram-LA4NIPWU-DdwHRhnP.js} +1 -1
  447. package/dist/public/assets/{diagram-MHCOC4E2-D7l7ybij.js → diagram-MHCOC4E2-IjreLUB9.js} +1 -1
  448. package/dist/public/assets/{diagram-XPFHEONP-kHzV_Ibv.js → diagram-XPFHEONP-CvaG0Zzq.js} +1 -1
  449. package/dist/public/assets/{dist-B-aKVhGg.js → dist-Cm4zqoMA.js} +1 -1
  450. package/dist/public/assets/{ebnfDiagram-UZSYDL2S-BX_-WdHG.js → ebnfDiagram-UZSYDL2S-C-FOI67M.js} +1 -1
  451. package/dist/public/assets/{editor.api-Dwz0wCaW.js → editor.api-hteKufWf.js} +1 -1
  452. package/dist/public/assets/{elk-XV6XMXQE-YaOVo5bZ.js → elk-XV6XMXQE-C_ClfkLy.js} +1 -1
  453. package/dist/public/assets/{erDiagram-EYBAPDEH-BXQPjKDV.js → erDiagram-EYBAPDEH-DSr0aRYm.js} +1 -1
  454. package/dist/public/assets/{eventmodeling-K75KTNOO-SiGVyftr.js → eventmodeling-K75KTNOO-COU_atV6.js} +1 -1
  455. package/dist/public/assets/flowDiagram-MALGAFMO-QGLBPpjQ.js +1 -0
  456. package/dist/public/assets/{freemarker2-DmbpSxx5.js → freemarker2-CBJnhymu.js} +1 -1
  457. package/dist/public/assets/{ganttDiagram-23REXITY-B_i7AN7O.js → ganttDiagram-23REXITY-BAcXXNjI.js} +1 -1
  458. package/dist/public/assets/gitGraph-VSP46ZUC-ByODkoVe.js +1 -0
  459. package/dist/public/assets/{gitGraphDiagram-STJD7YCW-BMA1YavS.js → gitGraphDiagram-STJD7YCW-Bk9sns6k.js} +1 -1
  460. package/dist/public/assets/{handlebars-BVNKBeJT.js → handlebars-CiqYW1im.js} +1 -1
  461. package/dist/public/assets/{html-BHaxuuAl.js → html-kafkm1Z0.js} +1 -1
  462. package/dist/public/assets/{index-DtU34jhH.js → index-DPLd0-lb.js} +2 -2
  463. package/dist/public/assets/info-OHQRW6UA-BMphWS2h.js +1 -0
  464. package/dist/public/assets/{infoDiagram-KBXO4MBG-BkNpfsDm.js → infoDiagram-KBXO4MBG-2hRQLVWa.js} +1 -1
  465. package/dist/public/assets/{ishikawaDiagram-M35NCXHK-xTM6C-Kn.js → ishikawaDiagram-M35NCXHK-hrOnhWJs.js} +1 -1
  466. package/dist/public/assets/{javascript-C5dXKvxq.js → javascript-Dt5MiA9w.js} +1 -1
  467. package/dist/public/assets/{journeyDiagram-OPLOXDXO-C6iaT7vL.js → journeyDiagram-OPLOXDXO-d8HJd04q.js} +1 -1
  468. package/dist/public/assets/{jsonMode-Ia_aRv-z.js → jsonMode-DBICoo6P.js} +1 -1
  469. package/dist/public/assets/{kanban-definition-BZKZHSQY-MobAdBhz.js → kanban-definition-BZKZHSQY-DOUuZDiv.js} +1 -1
  470. package/dist/public/assets/{liquid-CIbIBxiN.js → liquid-BGYhBP2h.js} +1 -1
  471. package/dist/public/assets/{mdx-BqruHcEe.js → mdx-Ct_gzcP3.js} +1 -1
  472. package/dist/public/assets/{mermaid-parser.core-kBQmxOUn.js → mermaid-parser.core-2yhxYNxq.js} +3 -3
  473. package/dist/public/assets/{mermaid.core-BFkQwIYu.js → mermaid.core-sx7teU8z.js} +4 -4
  474. package/dist/public/assets/{mindmap-definition-I2QAS2VK-DxpTmvUG.js → mindmap-definition-I2QAS2VK-DIc9LejH.js} +1 -1
  475. package/dist/public/assets/module-BX2fJibj.js +1124 -0
  476. package/dist/public/assets/module-N1D-AOa6.js +1 -0
  477. package/dist/public/assets/{monaco-BRwac88s.js → monaco-DJecWyyV.js} +3 -3
  478. package/dist/public/assets/packet-JDAUHWVQ-Ca8klABu.js +1 -0
  479. package/dist/public/assets/{pegDiagram-FD4XPPHP-B3bIVo4u.js → pegDiagram-FD4XPPHP-BfiT6-Vx.js} +1 -1
  480. package/dist/public/assets/pie-XZMESJXO-B-SN2eCI.js +1 -0
  481. package/dist/public/assets/{pieDiagram-J4AKIIQI-CgnbwU0I.js → pieDiagram-J4AKIIQI-DJ0sF_Eg.js} +1 -1
  482. package/dist/public/assets/{python-Cwjb3hEe.js → python-BrnocsK9.js} +1 -1
  483. package/dist/public/assets/{quadrantDiagram-XTYBLID2-DWx4wRau.js → quadrantDiagram-XTYBLID2-C3iF5PG6.js} +1 -1
  484. package/dist/public/assets/radar-ABXABTNO-DzDnNRnq.js +1 -0
  485. package/dist/public/assets/railroad-I3PHUGI6-7QAv0_1N.js +1 -0
  486. package/dist/public/assets/{railroad-abnf-LNEFI6M7-CyjF4cc_.js → railroad-abnf-LNEFI6M7-BI4N-mtq.js} +1 -1
  487. package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-D2ypsr5c.js → railroad-ebnf-DWYD2UWJ-Ck2MUlyV.js} +1 -1
  488. package/dist/public/assets/{railroad-peg-JR7BVNR7-Cy6Mde1c.js → railroad-peg-JR7BVNR7-Cuc9S0f4.js} +1 -1
  489. package/dist/public/assets/{railroadDiagram-MRQ6NCDL-B6ya_k_l.js → railroadDiagram-MRQ6NCDL-Cw24sb_5.js} +1 -1
  490. package/dist/public/assets/{razor-D_ClW9Lh.js → razor-BDHTAmlI.js} +1 -1
  491. package/dist/public/assets/{requirementDiagram-Y7LWUY3S-Brg8B8VS.js → requirementDiagram-Y7LWUY3S-QQUXFr1R.js} +1 -1
  492. package/dist/public/assets/{sankeyDiagram-WGJFYUXA-DbzPDfky.js → sankeyDiagram-WGJFYUXA-mSlfAHND.js} +1 -1
  493. package/dist/public/assets/{sequenceDiagram-5NDRBG5M-BuN84drT.js → sequenceDiagram-5NDRBG5M-3t8hVott.js} +1 -1
  494. package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-C_CTpHMj.js → stateDiagram-v2-FJ4FJNEA-9EW807AL.js} +1 -1
  495. package/dist/public/assets/{swimlanes-UMQ2AFYF-BvD4v9jw.js → swimlanes-UMQ2AFYF-EbMBX_e0.js} +1 -1
  496. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-CIFqDFf2.js +8 -0
  497. package/dist/public/assets/{timeline-definition-SEUHKTQE-VE2xWGk8.js → timeline-definition-SEUHKTQE-D14kjjsp.js} +1 -1
  498. package/dist/public/assets/treeView-D4JQ5SDB-cznq7PJK.js +1 -0
  499. package/dist/public/assets/treemap-SAJKECNS-CBYUiQGU.js +1 -0
  500. package/dist/public/assets/{typescript-upeNz2VW.js → typescript-BEEbbq69.js} +1 -1
  501. package/dist/public/assets/{usecaseDiagram-AFA6YXN4-ZtyyvKye.js → usecaseDiagram-AFA6YXN4-DKemtzU9.js} +1 -1
  502. package/dist/public/assets/{vennDiagram-NNMJR3RB-BTEvzrNd.js → vennDiagram-NNMJR3RB-DOBq9oeY.js} +1 -1
  503. package/dist/public/assets/wardley-7MLQ67FV-DV8bp8Ml.js +1 -0
  504. package/dist/public/assets/{wardleyDiagram-S7YFUSEH-CF8wIUhx.js → wardleyDiagram-S7YFUSEH-DquSJ4y-.js} +1 -1
  505. package/dist/public/assets/{xml-Cki0HxGb.js → xml-DvTQKQ_W.js} +1 -1
  506. package/dist/public/assets/xterm-BrP-ENHg.css +1 -0
  507. package/dist/public/assets/xterm-wtHqjrNn.js +85 -0
  508. package/dist/public/assets/{xychartDiagram-GGNKY7IX-DcDpoJ4n.js → xychartDiagram-GGNKY7IX-ClE_9jz4.js} +1 -1
  509. package/dist/public/assets/{yaml-YIY66l1U.js → yaml-ffiFfPtJ.js} +1 -1
  510. package/dist/public/index.html +21 -3
  511. package/dist/serve/index.mjs +6892 -5061
  512. package/package.json +22 -18
  513. package/dist/pi/packages/ta-workspace/lib/util/ansi.d.ts +0 -72
  514. package/dist/pi/packages/ta-workspace/lib/util/ansi.d.ts.map +0 -1
  515. package/dist/pi/packages/ta-workspace/lib/util/ansi.js +0 -434
  516. package/dist/pi/packages/ta-workspace/lib/util/ansi.js.map +0 -1
  517. package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts +0 -14
  518. package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts.map +0 -1
  519. package/dist/pi/packages/ta-workspace/lib/util/keys.js +0 -52
  520. package/dist/pi/packages/ta-workspace/lib/util/keys.js.map +0 -1
  521. package/dist/public/assets/cynefin-EF2NZ3EQ-D_GZWaFs.js +0 -1
  522. package/dist/public/assets/flowDiagram-MALGAFMO-BHpEyQnS.js +0 -1
  523. package/dist/public/assets/gitGraph-VSP46ZUC-CSv9x0vY.js +0 -1
  524. package/dist/public/assets/info-OHQRW6UA-Bx2U6fFU.js +0 -1
  525. package/dist/public/assets/module-C1y_4M09.js +0 -1061
  526. package/dist/public/assets/module-DYWqfyIP.js +0 -1
  527. package/dist/public/assets/packet-JDAUHWVQ-Dy7GyfNz.js +0 -1
  528. package/dist/public/assets/pie-XZMESJXO-B4D2CjUH.js +0 -1
  529. package/dist/public/assets/radar-ABXABTNO-Dtf3tObc.js +0 -1
  530. package/dist/public/assets/railroad-I3PHUGI6-DKGa9xBx.js +0 -1
  531. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-CMvLg13v.js +0 -8
  532. package/dist/public/assets/treeView-D4JQ5SDB-ETecwv1j.js +0 -1
  533. package/dist/public/assets/treemap-SAJKECNS-er6ceAYK.js +0 -1
  534. package/dist/public/assets/wardley-7MLQ67FV-CzrxsjBc.js +0 -1
@@ -0,0 +1,1746 @@
1
+ // src/extension.ts
2
+ import { readFileSync as readFileSync2 } from "node:fs";
3
+ import { homedir as homedir3 } from "node:os";
4
+ import { join as join3, resolve } from "node:path";
5
+
6
+ // src/acp-protocol.ts
7
+ var Acp;
8
+ ((Acp) => {
9
+ Acp.PROTOCOL_VERSION = 1;
10
+ Acp.AUTH_REQUIRED = -32000;
11
+ function text(block) {
12
+ if (!block) {
13
+ return "";
14
+ }
15
+ switch (block.type) {
16
+ case "text":
17
+ return block.text ?? "";
18
+ case "resource":
19
+ return block.resource?.text ?? block.resource?.uri ?? "";
20
+ case "resource_link":
21
+ return block.uri ?? block.name ?? "";
22
+ default:
23
+ return `[${block.type}]`;
24
+ }
25
+ }
26
+ Acp.text = text;
27
+ function values(option) {
28
+ return (option?.options ?? []).flatMap((item) => ("options" in item) && Array.isArray(item.options) ? item.options : [item]);
29
+ }
30
+ Acp.values = values;
31
+ function optionOf(options, category) {
32
+ return options?.find((option) => option.category === category) ?? options?.find((option) => option.id === category);
33
+ }
34
+ Acp.optionOf = optionOf;
35
+ })(Acp ||= {});
36
+
37
+ // src/agent-bindings.ts
38
+ import { realpathSync } from "node:fs";
39
+ import { homedir } from "node:os";
40
+ import { join, sep } from "node:path";
41
+
42
+ // src/acp-agent.ts
43
+ import { spawn } from "node:child_process";
44
+
45
+ // src/agent-turn.ts
46
+ var OUTPUT_CHARS = 8000;
47
+ var WRITING_KINDS = new Set(["edit", "delete", "move"]);
48
+ var PATH_KEYS = ["file_path", "path", "filePath", "notebook_path", "destination"];
49
+ function str(value) {
50
+ return typeof value === "string" && value.trim() ? value : undefined;
51
+ }
52
+ function num(value) {
53
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
54
+ }
55
+
56
+ class AgentTurn {
57
+ unsolicited;
58
+ command;
59
+ onWrite;
60
+ tools = new Map;
61
+ usage = {};
62
+ ended = false;
63
+ produced = false;
64
+ items = [];
65
+ listeners = new Set;
66
+ written = new Set;
67
+ constructor(unsolicited = false, command, onWrite) {
68
+ this.unsolicited = unsolicited;
69
+ this.command = command;
70
+ this.onWrite = onWrite;
71
+ }
72
+ update(update) {
73
+ if (this.ended) {
74
+ return;
75
+ }
76
+ switch (update.sessionUpdate) {
77
+ case "agent_message_chunk":
78
+ this.pushText("text", Acp.text(update.content));
79
+ break;
80
+ case "agent_thought_chunk":
81
+ this.pushText("thinking", Acp.text(update.content));
82
+ break;
83
+ case "tool_call":
84
+ case "tool_call_update":
85
+ this.tool(update);
86
+ break;
87
+ case "plan":
88
+ this.pushText("thinking", AgentTurn.plan(update.entries));
89
+ break;
90
+ case "usage_update":
91
+ this.measure(update);
92
+ break;
93
+ }
94
+ }
95
+ end(reason) {
96
+ this.finish({ type: "end", reason });
97
+ }
98
+ fail(message, code) {
99
+ this.finish({ type: "error", message, code });
100
+ }
101
+ async next(signal) {
102
+ while (!this.items.length) {
103
+ if (signal?.aborted) {
104
+ return;
105
+ }
106
+ await this.changed(signal);
107
+ }
108
+ return this.items.shift();
109
+ }
110
+ async whenEnded(timeoutMs) {
111
+ const until = Date.now() + timeoutMs;
112
+ while (!this.ended && Date.now() < until) {
113
+ await this.changed(undefined, until - Date.now());
114
+ }
115
+ }
116
+ peek() {
117
+ return this.items[0];
118
+ }
119
+ shift() {
120
+ return this.items.shift();
121
+ }
122
+ async settle(id, quietMs, signal) {
123
+ for (;; ) {
124
+ const run = this.tools.get(id);
125
+ if (!run || run.complete || this.ended || signal?.aborted || this.items.some((item) => item.type !== "tool")) {
126
+ return;
127
+ }
128
+ const left = run.updatedAt + quietMs - Date.now();
129
+ if (left <= 0) {
130
+ return;
131
+ }
132
+ await this.changed(signal, left);
133
+ }
134
+ }
135
+ async waitTool(id, signal) {
136
+ for (;; ) {
137
+ const run = this.tools.get(id);
138
+ if (!run || run.done || this.ended || signal?.aborted) {
139
+ return run;
140
+ }
141
+ await this.changed(signal);
142
+ }
143
+ }
144
+ pushText(type, text) {
145
+ if (!text) {
146
+ return;
147
+ }
148
+ this.produced = true;
149
+ const last = this.items[this.items.length - 1];
150
+ if (last?.type === type) {
151
+ last.text += text;
152
+ } else {
153
+ this.items.push({ type, text });
154
+ }
155
+ this.notify();
156
+ }
157
+ tool(update) {
158
+ let run = this.tools.get(update.toolCallId);
159
+ if (!run) {
160
+ run = {
161
+ id: update.toolCallId,
162
+ title: "",
163
+ kind: "other",
164
+ input: {},
165
+ locations: [],
166
+ status: "pending",
167
+ output: "",
168
+ done: false,
169
+ complete: false,
170
+ terminal: "",
171
+ updatedAt: Date.now()
172
+ };
173
+ this.tools.set(run.id, run);
174
+ this.items.push({ type: "tool", id: run.id });
175
+ this.produced = true;
176
+ }
177
+ run.title = str(update.title) ?? run.title;
178
+ run.kind = update.kind ?? run.kind;
179
+ run.name = AgentTurn.toolName(update._meta) ?? str(update.name) ?? run.name;
180
+ run.terminal += AgentTurn.terminalOutput(update._meta);
181
+ if (update.rawInput && typeof update.rawInput === "object" && Object.keys(update.rawInput).length) {
182
+ run.input = update.rawInput;
183
+ }
184
+ if (update.locations?.length) {
185
+ run.locations = update.locations.map((location) => location.path);
186
+ }
187
+ if (update.status) {
188
+ run.status = update.status;
189
+ }
190
+ run.complete ||= AgentTurn.argumentsComplete(update._meta) || Object.keys(run.input).length > 0 && update.status === "pending";
191
+ if (run.status === "completed" || run.status === "failed") {
192
+ run.done = true;
193
+ run.complete = true;
194
+ run.output = AgentTurn.contentText(update.content ?? []) || run.terminal || AgentTurn.raw(update.rawOutput);
195
+ run.output = AgentTurn.clip(run.output);
196
+ }
197
+ run.updatedAt = Date.now();
198
+ this.tellWrites(run, update.content ?? []);
199
+ this.notify();
200
+ }
201
+ tellWrites(run, content) {
202
+ if (!this.onWrite) {
203
+ return;
204
+ }
205
+ const tell = (path, before) => {
206
+ const key = `${run.id}\x00${path}`;
207
+ if (!this.written.has(key)) {
208
+ this.written.add(key);
209
+ this.onWrite?.(path, before);
210
+ }
211
+ };
212
+ for (const item of content) {
213
+ if (item.type === "diff" && str(item.path)) {
214
+ tell(item.path, item.oldText ?? null);
215
+ }
216
+ }
217
+ if (WRITING_KINDS.has(run.kind)) {
218
+ for (const path of [...run.locations, ...PATH_KEYS.map((key) => str(run.input[key]))]) {
219
+ if (path) {
220
+ tell(path);
221
+ }
222
+ }
223
+ }
224
+ }
225
+ measure(update) {
226
+ this.usage.used = num(update.used) ?? this.usage.used;
227
+ this.usage.size = num(update.size) ?? this.usage.size;
228
+ const tokens = update._meta?.usage;
229
+ if (tokens && typeof tokens === "object") {
230
+ this.usage.input = num(tokens.prompt_tokens) ?? num(tokens.input_tokens) ?? this.usage.input;
231
+ this.usage.output = num(tokens.completion_tokens) ?? num(tokens.output_tokens) ?? this.usage.output;
232
+ const details = tokens.prompt_tokens_details;
233
+ this.usage.cacheRead = num(tokens.prompt_cache_hit_tokens) || num(details?.cached_tokens) || num(tokens.cached_tokens) || num(tokens.cache_read_input_tokens) || this.usage.cacheRead;
234
+ }
235
+ }
236
+ finish(item) {
237
+ if (this.ended) {
238
+ return;
239
+ }
240
+ this.ended = true;
241
+ this.items.push(item);
242
+ this.notify();
243
+ }
244
+ notify() {
245
+ for (const listener of [...this.listeners]) {
246
+ listener();
247
+ }
248
+ }
249
+ changed(signal, timeoutMs) {
250
+ return new Promise((resolve) => {
251
+ const done = () => {
252
+ this.listeners.delete(done);
253
+ signal?.removeEventListener("abort", done);
254
+ if (timer) {
255
+ clearTimeout(timer);
256
+ }
257
+ resolve();
258
+ };
259
+ const timer = timeoutMs !== undefined ? setTimeout(done, timeoutMs) : undefined;
260
+ this.listeners.add(done);
261
+ signal?.addEventListener("abort", done, { once: true });
262
+ });
263
+ }
264
+ static plan(entries) {
265
+ const mark = { completed: "x", in_progress: "~", pending: " " };
266
+ return `${entries.map((entry) => `- [${mark[entry.status] ?? " "}] ${entry.content}`).join(`
267
+ `)}
268
+ `;
269
+ }
270
+ static output(update) {
271
+ return AgentTurn.clip(AgentTurn.contentText(update.content ?? []) || AgentTurn.raw(update.rawOutput));
272
+ }
273
+ static clip(text) {
274
+ return text.length > OUTPUT_CHARS ? `${text.slice(0, OUTPUT_CHARS)}
275
+ …` : text;
276
+ }
277
+ static terminalOutput(meta) {
278
+ let text = "";
279
+ for (const [key, value] of Object.entries(meta ?? {})) {
280
+ const data = value?.data;
281
+ if (/terminal_output/.test(key) && typeof data === "string") {
282
+ text += data;
283
+ }
284
+ }
285
+ return text;
286
+ }
287
+ static contentText(content) {
288
+ return content.map((item) => {
289
+ if (item.type === "content") {
290
+ return Acp.text(item.content);
291
+ }
292
+ if (item.type === "diff") {
293
+ return `${item.path}
294
+ ${AgentTurn.diff(item.oldText ?? "", item.newText)}`;
295
+ }
296
+ return "";
297
+ }).filter(Boolean).join(`
298
+ `);
299
+ }
300
+ static raw(value) {
301
+ if (value === undefined || value === null) {
302
+ return "";
303
+ }
304
+ if (typeof value === "string") {
305
+ return value;
306
+ }
307
+ const text = value.text;
308
+ if (typeof text === "string") {
309
+ return text;
310
+ }
311
+ try {
312
+ return JSON.stringify(value, undefined, 2);
313
+ } catch {
314
+ return String(value);
315
+ }
316
+ }
317
+ static diff(before, after) {
318
+ const old = before ? before.split(`
319
+ `) : [];
320
+ const lines = after.split(`
321
+ `);
322
+ let start = 0;
323
+ while (start < old.length && start < lines.length && old[start] === lines[start]) {
324
+ start++;
325
+ }
326
+ let end = 0;
327
+ while (end < old.length - start && end < lines.length - start && old[old.length - 1 - end] === lines[lines.length - 1 - end]) {
328
+ end++;
329
+ }
330
+ return [...old.slice(start, old.length - end).map((line) => `- ${line}`), ...lines.slice(start, lines.length - end).map((line) => `+ ${line}`)].join(`
331
+ `);
332
+ }
333
+ static argumentsComplete(meta) {
334
+ return Object.entries(meta ?? {}).some(([key, value]) => /toolArgumentsComplete$/.test(key) && value === true);
335
+ }
336
+ static toolName(meta) {
337
+ for (const [key, value] of Object.entries(meta ?? {})) {
338
+ if (/toolName$/i.test(key) && typeof value === "string") {
339
+ return value;
340
+ }
341
+ if (value && typeof value === "object" && typeof value.toolName === "string") {
342
+ return value.toolName;
343
+ }
344
+ }
345
+ return;
346
+ }
347
+ }
348
+
349
+ // src/agent-session.ts
350
+ var UNSOLICITED_QUIET_MS = 3000;
351
+ var ABANDON_WAIT_MS = 5000;
352
+ var ANSWER_WAIT_MS = 15000;
353
+
354
+ class AgentSession {
355
+ host;
356
+ id;
357
+ turn;
358
+ options = [];
359
+ models;
360
+ title;
361
+ callbacks = { permission: async (request) => AgentSession.allow(request), activity: () => {
362
+ return;
363
+ } };
364
+ queued = [];
365
+ quietTimer;
366
+ abandoned;
367
+ answer;
368
+ working = false;
369
+ requests = new Set;
370
+ earlier = new Set;
371
+ constructor(host, id, setup) {
372
+ this.host = host;
373
+ this.id = id;
374
+ this.apply(setup);
375
+ }
376
+ apply(setup) {
377
+ if (setup.configOptions) {
378
+ this.options = setup.configOptions;
379
+ }
380
+ if (setup.models) {
381
+ this.models = setup.models;
382
+ }
383
+ }
384
+ update(update) {
385
+ const meta = update._meta;
386
+ const ids = AgentSession.requestIds(meta);
387
+ for (const id of ids) {
388
+ this.requests.add(id);
389
+ }
390
+ switch (update.sessionUpdate) {
391
+ case "config_option_update":
392
+ this.options = update.configOptions ?? this.options;
393
+ return;
394
+ case "session_info_update": {
395
+ const title = update.title;
396
+ if (typeof title === "string" && title.trim() && title.trim() !== this.title) {
397
+ this.title = title.trim();
398
+ this.callbacks.title?.(this.title);
399
+ }
400
+ const phase = AgentSession.phase(meta);
401
+ const stale = ids.some((id) => this.earlier.has(id));
402
+ if (phase && !stale && this.turn && !this.turn.unsolicited) {
403
+ if (phase !== "idle") {
404
+ this.working = true;
405
+ } else if (this.working) {
406
+ this.working = false;
407
+ this.turn.end("end_turn");
408
+ }
409
+ }
410
+ if (meta && Object.keys(meta).some((key) => /unsolicitedTurn$/.test(key)) && !this.turn) {
411
+ this.startUnsolicited(false);
412
+ }
413
+ return;
414
+ }
415
+ case "session_end":
416
+ if (this.turn?.unsolicited) {
417
+ this.turn.end("end_turn");
418
+ }
419
+ return;
420
+ case "agent_message_chunk":
421
+ case "agent_thought_chunk":
422
+ case "tool_call":
423
+ case "tool_call_update":
424
+ case "plan":
425
+ if (!this.turn) {
426
+ this.startUnsolicited(true);
427
+ }
428
+ break;
429
+ }
430
+ this.turn?.update(update);
431
+ if (this.turn?.unsolicited && this.quietTimer) {
432
+ this.quiet(this.turn);
433
+ }
434
+ }
435
+ prompt(prompt) {
436
+ const first = prompt.find((block) => block.type === "text")?.text?.trim() ?? "";
437
+ const turn = new AgentTurn(false, /^\/[\w:.-]+/.exec(first)?.[0], (path, before) => this.callbacks.write?.(path, before));
438
+ this.turn = turn;
439
+ this.working = false;
440
+ this.earlier = new Set(this.requests);
441
+ const answer = this.host.request("session/prompt", { sessionId: this.id, prompt }).then((response) => turn.end(response?.stopReason ?? "end_turn"), (error) => turn.fail(error.message, error.code));
442
+ this.answer = answer;
443
+ return turn;
444
+ }
445
+ queue(prompt) {
446
+ this.queued.push(prompt);
447
+ }
448
+ takeQueued() {
449
+ if (!this.queued.length) {
450
+ return;
451
+ }
452
+ return this.queued.splice(0).flat();
453
+ }
454
+ abandon(turn) {
455
+ this.cancel();
456
+ this.finished(turn);
457
+ this.abandoned = turn;
458
+ }
459
+ async idle() {
460
+ const turn = this.abandoned;
461
+ this.abandoned = undefined;
462
+ await turn?.whenEnded(ABANDON_WAIT_MS);
463
+ const answer = this.answer;
464
+ if (answer) {
465
+ let timer;
466
+ await Promise.race([answer, new Promise((resolve) => timer = setTimeout(resolve, ANSWER_WAIT_MS))]);
467
+ clearTimeout(timer);
468
+ }
469
+ }
470
+ finished(turn) {
471
+ if (this.turn === turn) {
472
+ this.turn = undefined;
473
+ clearTimeout(this.quietTimer);
474
+ this.quietTimer = undefined;
475
+ }
476
+ }
477
+ cancel() {
478
+ this.host.notify("session/cancel", { sessionId: this.id });
479
+ if (this.turn?.unsolicited) {
480
+ this.turn.end("cancelled");
481
+ }
482
+ }
483
+ async select(category, value, signal) {
484
+ if (value === undefined) {
485
+ return;
486
+ }
487
+ const option = Acp.optionOf(this.options, category);
488
+ if (option) {
489
+ if (option.currentValue === value || !Acp.values(option).some((candidate) => candidate.value === value)) {
490
+ return;
491
+ }
492
+ const result = await this.host.request("session/set_config_option", { sessionId: this.id, configId: option.id, value }, signal);
493
+ this.apply(result ?? {});
494
+ option.currentValue = value;
495
+ } else if (category === "model" && this.models && this.models.currentModelId !== value) {
496
+ if (this.models.availableModels.some((model) => model.modelId === value)) {
497
+ await this.host.request("session/set_model", { sessionId: this.id, modelId: value }, signal);
498
+ this.models.currentModelId = value;
499
+ }
500
+ }
501
+ }
502
+ startUnsolicited(quiet) {
503
+ const turn = new AgentTurn(true, undefined, (path, before) => this.callbacks.write?.(path, before));
504
+ this.turn = turn;
505
+ if (quiet) {
506
+ this.quiet(turn);
507
+ }
508
+ this.callbacks.activity(this);
509
+ }
510
+ quiet(turn) {
511
+ clearTimeout(this.quietTimer);
512
+ this.quietTimer = setTimeout(() => turn.end("end_turn"), UNSOLICITED_QUIET_MS);
513
+ this.quietTimer.unref?.();
514
+ }
515
+ static requestIds(meta) {
516
+ return Object.entries(meta ?? {}).filter(([key, value]) => /requestId$/i.test(key) && typeof value === "string" && value).map(([, value]) => value);
517
+ }
518
+ static phase(meta) {
519
+ for (const [key, value] of Object.entries(meta ?? {})) {
520
+ const phase = value?.phase;
521
+ if (/agentPhase$/.test(key) && typeof phase === "string") {
522
+ return phase;
523
+ }
524
+ }
525
+ return;
526
+ }
527
+ static allow(request) {
528
+ const option = request.options.find((candidate) => candidate.kind === "allow_once") ?? request.options.find((candidate) => candidate.kind === "allow_always") ?? request.options[0];
529
+ return option ? { outcome: "selected", optionId: option.optionId } : { outcome: "cancelled" };
530
+ }
531
+ }
532
+
533
+ // src/json-rpc.ts
534
+ class JsonRpcError extends Error {
535
+ code;
536
+ data;
537
+ constructor(code, message, data) {
538
+ super(message);
539
+ this.code = code;
540
+ this.data = data;
541
+ this.name = "JsonRpcError";
542
+ }
543
+ }
544
+
545
+ class JsonRpcConnection {
546
+ output;
547
+ onRequest = async (method) => {
548
+ throw new JsonRpcError(-32601, `Method not found: ${method}`);
549
+ };
550
+ onNotification = () => {
551
+ return;
552
+ };
553
+ onClose = () => {
554
+ return;
555
+ };
556
+ nextId = 0;
557
+ pending = new Map;
558
+ buffer = "";
559
+ closed;
560
+ constructor(output, input) {
561
+ this.output = output;
562
+ input.setEncoding("utf8");
563
+ input.on("data", (chunk) => this.receive(chunk));
564
+ input.on("end", () => this.close(new Error("The agent closed its output")));
565
+ output.on("error", (error) => this.close(error));
566
+ }
567
+ get pendingCount() {
568
+ return this.pending.size;
569
+ }
570
+ get isClosed() {
571
+ return this.closed !== undefined;
572
+ }
573
+ request(method, params, signal) {
574
+ if (this.closed) {
575
+ return Promise.reject(this.closed);
576
+ }
577
+ const id = ++this.nextId;
578
+ return new Promise((resolve, reject) => {
579
+ const abort = () => {
580
+ this.pending.delete(id);
581
+ reject(signal?.reason instanceof Error ? signal.reason : new Error("Aborted"));
582
+ };
583
+ if (signal?.aborted) {
584
+ abort();
585
+ return;
586
+ }
587
+ signal?.addEventListener("abort", abort, { once: true });
588
+ this.pending.set(id, {
589
+ resolve: (value) => {
590
+ signal?.removeEventListener("abort", abort);
591
+ resolve(value);
592
+ },
593
+ reject: (error) => {
594
+ signal?.removeEventListener("abort", abort);
595
+ reject(error);
596
+ }
597
+ });
598
+ this.send({ jsonrpc: "2.0", id, method, params });
599
+ });
600
+ }
601
+ notify(method, params) {
602
+ if (!this.closed) {
603
+ this.send({ jsonrpc: "2.0", method, params });
604
+ }
605
+ }
606
+ close(error) {
607
+ if (this.closed) {
608
+ return;
609
+ }
610
+ this.closed = error;
611
+ for (const pending of this.pending.values()) {
612
+ pending.reject(error);
613
+ }
614
+ this.pending.clear();
615
+ this.onClose(error);
616
+ }
617
+ send(message) {
618
+ this.output.write(`${JSON.stringify(message)}
619
+ `);
620
+ }
621
+ receive(chunk) {
622
+ this.buffer += chunk;
623
+ let end = this.buffer.indexOf(`
624
+ `);
625
+ while (end >= 0) {
626
+ const line = this.buffer.slice(0, end).trim();
627
+ this.buffer = this.buffer.slice(end + 1);
628
+ if (line) {
629
+ this.dispatch(line);
630
+ }
631
+ end = this.buffer.indexOf(`
632
+ `);
633
+ }
634
+ }
635
+ dispatch(line) {
636
+ let message;
637
+ try {
638
+ message = JSON.parse(line);
639
+ } catch {
640
+ return;
641
+ }
642
+ if (!message || typeof message !== "object") {
643
+ return;
644
+ }
645
+ if (message.method === undefined) {
646
+ const pending = typeof message.id === "number" ? this.pending.get(message.id) : undefined;
647
+ if (pending) {
648
+ this.pending.delete(message.id);
649
+ if (message.error) {
650
+ pending.reject(new JsonRpcError(message.error.code, message.error.message, message.error.data));
651
+ } else {
652
+ pending.resolve(message.result);
653
+ }
654
+ }
655
+ } else if (message.id === undefined || message.id === null) {
656
+ this.onNotification(message.method, message.params);
657
+ } else {
658
+ this.answer(message.id, message.method, message.params);
659
+ }
660
+ }
661
+ async answer(id, method, params) {
662
+ try {
663
+ const result = await this.onRequest(method, params);
664
+ this.send({ jsonrpc: "2.0", id, result: result ?? null });
665
+ } catch (error) {
666
+ const code = error instanceof JsonRpcError ? error.code : -32603;
667
+ this.send({ jsonrpc: "2.0", id, error: { code, message: error instanceof Error ? error.message : String(error) } });
668
+ }
669
+ }
670
+ }
671
+
672
+ // src/texts.ts
673
+ var TEXTS = {
674
+ remote: {
675
+ en: (agent) => `${agent} works in directories of this computer; it cannot work in a remote directory yet.`,
676
+ zh: (agent) => `${agent} 只能在这台电脑上的目录里工作,暂不支持远程目录。`
677
+ },
678
+ signIn: {
679
+ en: (agent, command) => `${agent} is not signed in. Run \`${command}\` in a terminal to sign in, then try again.`,
680
+ zh: (agent, command) => `${agent} 还没有登录。请在终端里运行 \`${command}\` 登录后再试。`
681
+ },
682
+ notFound: {
683
+ en: (agent, command) => `${agent}: \`${command}\` was not found. Install it, or set its command in \`agents\` of settings.json.`,
684
+ zh: (agent, command) => `${agent}:找不到命令 \`${command}\`。请先安装,或在 settings.json 的 \`agents\` 里指定它的命令。`
685
+ },
686
+ exited: {
687
+ en: (agent, code, last) => `${agent} exited (${code})${last ? `: ${last}` : ""}`,
688
+ zh: (agent, code, last) => `${agent} 已退出(${code})${last ? `:${last}` : ""}`
689
+ },
690
+ commandDone: {
691
+ en: (agent, command) => `${agent} ran \`${command}\` and said nothing back; it may only show in ${agent}'s own interface.`,
692
+ zh: (agent, command) => `${agent} 已执行 \`${command}\`,没有返回内容(这个命令可能只在 ${agent} 自己的界面里有显示)。`
693
+ },
694
+ unfinished: {
695
+ en: (agent) => `${agent} ended its turn before this call finished.`,
696
+ zh: (agent) => `${agent} 在这次调用完成前结束了这一轮。`
697
+ }
698
+ };
699
+ function language(env = process.env) {
700
+ const locale = env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG || Intl.DateTimeFormat().resolvedOptions().locale;
701
+ return /^zh/i.test(locale) ? "zh" : "en";
702
+ }
703
+ function text(key, ...args) {
704
+ return TEXTS[key][language()](...args);
705
+ }
706
+
707
+ // src/acp-agent.ts
708
+ var STDERR_CHARS = 2000;
709
+ function agentEnv(extra) {
710
+ const env = {};
711
+ for (const [key, value] of Object.entries(process.env)) {
712
+ if (!key.startsWith("PI_") && key !== "ELECTRON_RUN_AS_NODE" && key !== "AI_AGENT") {
713
+ env[key] = value;
714
+ }
715
+ }
716
+ return { ...env, ...extra };
717
+ }
718
+
719
+ class AcpAgent {
720
+ name;
721
+ program;
722
+ idleMs;
723
+ sessions = new Map;
724
+ initialized;
725
+ child;
726
+ connection;
727
+ starting;
728
+ stderr = "";
729
+ idleTimer;
730
+ constructor(name, program, idleMs = 10 * 60000) {
731
+ this.name = name;
732
+ this.program = program;
733
+ this.idleMs = idleMs;
734
+ }
735
+ get running() {
736
+ return !!this.connection && !this.connection.isClosed;
737
+ }
738
+ start() {
739
+ if (this.starting && this.running) {
740
+ return this.starting;
741
+ }
742
+ this.starting = this.launch();
743
+ this.starting.catch(() => this.starting = undefined);
744
+ return this.starting;
745
+ }
746
+ async newSession(cwd, signal) {
747
+ await this.start();
748
+ const setup = await this.request("session/new", { cwd, mcpServers: [] }, signal);
749
+ if (!setup?.sessionId) {
750
+ throw new Error(`${this.name} did not open a session`);
751
+ }
752
+ return this.add(setup.sessionId, setup);
753
+ }
754
+ async loadSession(id, cwd, signal) {
755
+ const known = this.sessions.get(id);
756
+ if (known) {
757
+ return known;
758
+ }
759
+ const init = await this.start();
760
+ if (!init.agentCapabilities?.loadSession) {
761
+ return;
762
+ }
763
+ try {
764
+ const setup = await this.request("session/load", { sessionId: id, cwd, mcpServers: [] }, signal);
765
+ return this.add(id, setup ?? {});
766
+ } catch (error) {
767
+ if (error instanceof JsonRpcError && error.code !== Acp.AUTH_REQUIRED) {
768
+ return;
769
+ }
770
+ throw error;
771
+ }
772
+ }
773
+ request(method, params, signal) {
774
+ this.touch();
775
+ if (!this.connection || this.connection.isClosed) {
776
+ return Promise.reject(new Error(`${this.name} is not running`));
777
+ }
778
+ const connection = this.connection;
779
+ this.reference(true);
780
+ return connection.request(method, params, signal).catch((error) => {
781
+ throw this.explain(error);
782
+ }).finally(() => this.reference(connection.pendingCount > 0));
783
+ }
784
+ notify(method, params) {
785
+ this.connection?.notify(method, params);
786
+ }
787
+ stop() {
788
+ clearTimeout(this.idleTimer);
789
+ const child = this.child;
790
+ this.child = undefined;
791
+ this.connection?.close(new Error(`${this.name} stopped`));
792
+ this.connection = undefined;
793
+ this.starting = undefined;
794
+ if (child && child.exitCode === null) {
795
+ child.stdin?.end();
796
+ child.kill();
797
+ }
798
+ }
799
+ reference(on) {
800
+ const child = this.child;
801
+ for (const handle of [child, child?.stdin, child?.stdout, child?.stderr]) {
802
+ if (on) {
803
+ handle?.ref?.();
804
+ } else {
805
+ handle?.unref?.();
806
+ }
807
+ }
808
+ }
809
+ touch() {
810
+ clearTimeout(this.idleTimer);
811
+ this.idleTimer = setTimeout(() => {
812
+ if ([...this.sessions.values()].some((session) => session.turn)) {
813
+ this.touch();
814
+ } else {
815
+ this.stop();
816
+ }
817
+ }, this.idleMs);
818
+ this.idleTimer.unref?.();
819
+ }
820
+ add(id, setup) {
821
+ const session = new AgentSession(this, id, setup);
822
+ this.sessions.set(id, session);
823
+ return session;
824
+ }
825
+ async launch() {
826
+ this.stop();
827
+ this.stderr = "";
828
+ const child = spawn(this.program.command, this.program.args, {
829
+ cwd: this.program.cwd,
830
+ env: agentEnv(this.program.env),
831
+ stdio: ["pipe", "pipe", "pipe"],
832
+ shell: process.platform === "win32",
833
+ windowsHide: true
834
+ });
835
+ this.child = child;
836
+ const { stdin, stdout } = child;
837
+ if (!stdin || !stdout) {
838
+ throw new Error(`${this.name} has no standard input or output`);
839
+ }
840
+ const connection = new JsonRpcConnection(stdin, stdout);
841
+ this.connection = connection;
842
+ child.stderr?.setEncoding("utf8");
843
+ child.stderr?.on("data", (chunk) => this.stderr = (this.stderr + chunk).slice(-STDERR_CHARS));
844
+ child.on("error", (error) => connection.close(error.code === "ENOENT" ? new Error(text("notFound", this.name, this.program.command)) : error));
845
+ child.on("exit", (code) => connection.close(new Error(text("exited", this.name, String(code ?? "signal"), this.lastError()))));
846
+ connection.onNotification = (method, params) => this.notified(method, params);
847
+ connection.onRequest = (method, params) => this.requested(method, params);
848
+ connection.onClose = (error) => {
849
+ for (const session of this.sessions.values()) {
850
+ session.turn?.fail(error.message);
851
+ }
852
+ this.sessions.clear();
853
+ };
854
+ this.reference(true);
855
+ const init = await connection.request("initialize", {
856
+ protocolVersion: Acp.PROTOCOL_VERSION,
857
+ clientCapabilities: {
858
+ fs: { readTextFile: false, writeTextFile: false },
859
+ terminal: false,
860
+ ...this.program.clientMeta ? { _meta: this.program.clientMeta } : {}
861
+ },
862
+ clientInfo: { name: "ta", version: "1" }
863
+ }).finally(() => this.reference(false));
864
+ this.initialized = init;
865
+ return init;
866
+ }
867
+ notified(method, params) {
868
+ this.touch();
869
+ if (method !== "session/update") {
870
+ return;
871
+ }
872
+ const { sessionId, update } = params ?? {};
873
+ if (sessionId && update) {
874
+ this.sessions.get(sessionId)?.update(update);
875
+ }
876
+ }
877
+ async requested(method, params) {
878
+ if (method === "session/request_permission") {
879
+ const request = params;
880
+ const session = this.sessions.get(request.sessionId);
881
+ const outcome = session ? await session.callbacks.permission(request) : AgentSession.allow(request);
882
+ return { outcome };
883
+ }
884
+ throw new JsonRpcError(-32601, `Method not found: ${method}`);
885
+ }
886
+ explain(error) {
887
+ if (error instanceof JsonRpcError && error.code === Acp.AUTH_REQUIRED) {
888
+ return Object.assign(new Error(`${this.name} is not signed in`), { code: error.code });
889
+ }
890
+ return error instanceof Error ? error : new Error(String(error));
891
+ }
892
+ lastError() {
893
+ const lines = this.stderr.trim().split(`
894
+ `).filter(Boolean);
895
+ return lines[lines.length - 1] ?? "";
896
+ }
897
+ }
898
+
899
+ // src/agent-bindings.ts
900
+ var BINDING_ENTRY = "ta-agents.session";
901
+ var POOL = Symbol.for("ta-agents.pool");
902
+ var AgentPool;
903
+ ((AgentPool) => {
904
+ function of(config, cwd) {
905
+ const global = globalThis;
906
+ const pool = global[POOL] ?? create();
907
+ global[POOL] = pool;
908
+ const key = JSON.stringify([config.command, config.args, config.env ?? {}, config.clientMeta ?? {}, cwd]);
909
+ let agent = pool.get(key);
910
+ if (!agent) {
911
+ agent = new AcpAgent(config.name, { command: config.command, args: config.args, env: config.env, clientMeta: config.clientMeta, cwd });
912
+ pool.set(key, agent);
913
+ }
914
+ return agent;
915
+ }
916
+ AgentPool.of = of;
917
+ function create() {
918
+ const pool = new Map;
919
+ process.once("exit", () => {
920
+ for (const agent of pool.values()) {
921
+ agent.stop();
922
+ }
923
+ });
924
+ return pool;
925
+ }
926
+ })(AgentPool ||= {});
927
+
928
+ class AgentBindings {
929
+ save;
930
+ prepare;
931
+ agentOf;
932
+ cwd = process.cwd();
933
+ ids = new Map;
934
+ opened = new Map;
935
+ constructor(save, prepare, agentOf = AgentPool.of) {
936
+ this.save = save;
937
+ this.prepare = prepare;
938
+ this.agentOf = agentOf;
939
+ }
940
+ restore(entries, fork) {
941
+ this.ids.clear();
942
+ this.opened.clear();
943
+ if (fork) {
944
+ return;
945
+ }
946
+ for (const entry of entries) {
947
+ const { type, customType, data } = entry ?? {};
948
+ if (type === "custom" && customType === BINDING_ENTRY && typeof data?.agent === "string" && typeof data.session === "string") {
949
+ this.ids.set(data.agent, data.session);
950
+ }
951
+ }
952
+ }
953
+ forget() {
954
+ this.ids.clear();
955
+ this.opened.clear();
956
+ }
957
+ sessionId(agent) {
958
+ return this.ids.get(agent);
959
+ }
960
+ open(config, signal) {
961
+ const agent = this.agentOf(config, this.cwd);
962
+ let opened = this.opened.get(config.id);
963
+ if (opened) {
964
+ opened = opened.then((value) => agent.running && agent.sessions.get(value.session.id) === value.session ? { ...value, fresh: false } : this.connect(config, agent, signal));
965
+ } else {
966
+ opened = this.connect(config, agent, signal);
967
+ }
968
+ opened.catch(() => this.opened.delete(config.id));
969
+ this.opened.set(config.id, opened);
970
+ return opened;
971
+ }
972
+ close() {
973
+ this.opened.clear();
974
+ }
975
+ async connect(config, agent, signal) {
976
+ if (AgentBindings.isRemote(this.cwd)) {
977
+ throw new Error(text("remote", config.name));
978
+ }
979
+ const known = this.ids.get(config.id);
980
+ let session = known ? await agent.loadSession(known, this.cwd, signal) : undefined;
981
+ const fresh = !session;
982
+ if (!session) {
983
+ session = await agent.newSession(this.cwd, signal);
984
+ for (const [option, value] of Object.entries(config.options ?? {})) {
985
+ await session.select(option, value, signal).catch(() => {
986
+ return;
987
+ });
988
+ }
989
+ this.ids.set(config.id, session.id);
990
+ this.save({ agent: config.id, session: session.id });
991
+ }
992
+ this.prepare(config, session);
993
+ return { session, fresh, images: !!agent.initialized?.agentCapabilities?.promptCapabilities?.image, dirs: AgentBindings.dirs(this.cwd) };
994
+ }
995
+ static dirs(cwd) {
996
+ try {
997
+ const real = realpathSync(cwd);
998
+ return real === cwd ? [cwd] : [cwd, real];
999
+ } catch {
1000
+ return [cwd];
1001
+ }
1002
+ }
1003
+ static isRemote(cwd) {
1004
+ const agentDir = process.env.TA_CODING_AGENT_DIR ?? join(homedir(), ".ta", "agent");
1005
+ return cwd.startsWith(join(agentDir, "remote") + sep);
1006
+ }
1007
+ }
1008
+
1009
+ // src/agent-catalog.ts
1010
+ import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
1011
+ import { homedir as homedir2 } from "node:os";
1012
+ import { delimiter, dirname, join as join2 } from "node:path";
1013
+ var PRESETS = [
1014
+ {
1015
+ id: "codebuddy-code",
1016
+ name: "CodeBuddy Code",
1017
+ command: "cbc",
1018
+ args: ["--acp"],
1019
+ programs: ["cbc", "codebuddy"],
1020
+ login: "cbc",
1021
+ env: { CODEBUDDY_CODE_MODE_ENABLED: "1" },
1022
+ clientMeta: { "codebuddy.ai": { mainAgentSupport: true, toolModeSupport: true } },
1023
+ options: { mode: "fullAccess" }
1024
+ },
1025
+ {
1026
+ id: "claude-code",
1027
+ name: "Claude Code",
1028
+ command: "npx",
1029
+ args: ["-y", "@agentclientprotocol/claude-agent-acp@0.106.0"],
1030
+ programs: ["claude"],
1031
+ login: "claude"
1032
+ },
1033
+ { id: "codex", name: "Codex", command: "npx", args: ["-y", "@agentclientprotocol/codex-acp@2.6.0"], programs: ["codex"], login: "codex login" }
1034
+ ];
1035
+ var AgentCatalog;
1036
+ ((AgentCatalog) => {
1037
+ AgentCatalog.DEFAULT_MODEL = "default";
1038
+ function agents(settings, find = Programs.find) {
1039
+ const configured = settings && typeof settings === "object" ? settings : {};
1040
+ const result = [];
1041
+ for (const preset of PRESETS) {
1042
+ const setting = configured[preset.id];
1043
+ if (setting === false) {
1044
+ continue;
1045
+ }
1046
+ const found = preset.programs.find((program) => find(program));
1047
+ if (!found && !setting) {
1048
+ continue;
1049
+ }
1050
+ const { programs, ...config } = preset;
1051
+ const command = programs.includes(config.command) && found ? found : config.command;
1052
+ const own = setting || {};
1053
+ result.push({
1054
+ ...config,
1055
+ command,
1056
+ ...own,
1057
+ id: preset.id,
1058
+ env: config.env || own.env ? { ...config.env, ...own.env } : undefined,
1059
+ options: config.options || own.options ? { ...config.options, ...own.options } : undefined
1060
+ });
1061
+ }
1062
+ for (const [id, setting] of Object.entries(configured)) {
1063
+ if (setting && typeof setting === "object" && !PRESETS.some((preset) => preset.id === id) && typeof setting.command === "string") {
1064
+ result.push({ name: id, args: [], ...setting, id, command: setting.command });
1065
+ }
1066
+ }
1067
+ return result;
1068
+ }
1069
+ AgentCatalog.agents = agents;
1070
+ })(AgentCatalog ||= {});
1071
+ var Programs;
1072
+ ((Programs) => {
1073
+ function find(program) {
1074
+ const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
1075
+ for (const dir of (process.env.PATH ?? "").split(delimiter)) {
1076
+ for (const extension of extensions) {
1077
+ if (dir && isFile(join2(dir, program + extension))) {
1078
+ return program;
1079
+ }
1080
+ }
1081
+ }
1082
+ return;
1083
+ }
1084
+ Programs.find = find;
1085
+ function isFile(path) {
1086
+ try {
1087
+ return statSync(path).isFile();
1088
+ } catch {
1089
+ return false;
1090
+ }
1091
+ }
1092
+ })(Programs ||= {});
1093
+
1094
+ class ModelCache {
1095
+ file;
1096
+ entries;
1097
+ constructor(file = ModelCache.defaultFile()) {
1098
+ this.file = file;
1099
+ }
1100
+ get(id) {
1101
+ return this.read()[id];
1102
+ }
1103
+ set(id, models) {
1104
+ const entries = this.read();
1105
+ if (JSON.stringify(entries[id]) === JSON.stringify(models)) {
1106
+ return false;
1107
+ }
1108
+ entries[id] = models;
1109
+ try {
1110
+ mkdirSync(dirname(this.file), { recursive: true });
1111
+ const temp = `${this.file}.${process.pid}.tmp`;
1112
+ writeFileSync(temp, JSON.stringify(entries, undefined, 2));
1113
+ renameSync(temp, this.file);
1114
+ } catch {}
1115
+ return true;
1116
+ }
1117
+ read() {
1118
+ if (!this.entries) {
1119
+ try {
1120
+ this.entries = existsSync(this.file) ? JSON.parse(readFileSync(this.file, "utf8")) : {};
1121
+ } catch {
1122
+ this.entries = {};
1123
+ }
1124
+ }
1125
+ return this.entries ?? {};
1126
+ }
1127
+ static defaultFile() {
1128
+ return join2(process.env.XDG_CACHE_HOME || join2(homedir2(), ".cache"), "ta-agents", "models.json");
1129
+ }
1130
+ }
1131
+
1132
+ // src/agent-prompt.ts
1133
+ var ACTIVITY_TEXT = "[The agent continued on its own]";
1134
+ var TRANSCRIPT_CHARS = 30000;
1135
+ var AgentPrompt;
1136
+ ((AgentPrompt) => {
1137
+ function pending(messages) {
1138
+ const result = [];
1139
+ for (let index = messages.length - 1;index >= 0; index--) {
1140
+ const message = messages[index];
1141
+ if (message.role === "system") {
1142
+ continue;
1143
+ }
1144
+ if (message.role !== "user") {
1145
+ break;
1146
+ }
1147
+ if (text2(message) !== ACTIVITY_TEXT) {
1148
+ result.unshift(message);
1149
+ }
1150
+ }
1151
+ return result;
1152
+ }
1153
+ AgentPrompt.pending = pending;
1154
+ function blocks(messages, images) {
1155
+ const result = [];
1156
+ for (const message of messages) {
1157
+ if (message.role !== "user") {
1158
+ continue;
1159
+ }
1160
+ if (typeof message.content === "string") {
1161
+ result.push({ type: "text", text: message.content });
1162
+ continue;
1163
+ }
1164
+ for (const part of message.content) {
1165
+ if (part.type === "text") {
1166
+ result.push({ type: "text", text: part.text });
1167
+ } else if (images) {
1168
+ result.push({ type: "image", data: part.data, mimeType: part.mimeType });
1169
+ } else {
1170
+ result.push({ type: "text", text: "[An image the agent cannot take was left out]" });
1171
+ }
1172
+ }
1173
+ }
1174
+ return result;
1175
+ }
1176
+ AgentPrompt.blocks = blocks;
1177
+ function transcript(messages, pendingCount) {
1178
+ const earlier = messages.filter((message) => (message.role === "user" || message.role === "assistant") && text2(message) !== ACTIVITY_TEXT);
1179
+ const lines = [];
1180
+ for (const message of earlier.slice(0, Math.max(0, earlier.length - pendingCount))) {
1181
+ const content = text2(message).trim();
1182
+ if (content) {
1183
+ lines.push(`${message.role === "user" ? "User" : "Assistant"}: ${content}`);
1184
+ }
1185
+ }
1186
+ if (!lines.length) {
1187
+ return;
1188
+ }
1189
+ const body = lines.join(`
1190
+
1191
+ `);
1192
+ const kept = body.length > TRANSCRIPT_CHARS ? `…${body.slice(-TRANSCRIPT_CHARS)}` : body;
1193
+ return `<earlier_conversation>
1194
+ The user talked with another assistant before you joined; this is what was said:
1195
+
1196
+ ${kept}
1197
+ </earlier_conversation>`;
1198
+ }
1199
+ AgentPrompt.transcript = transcript;
1200
+ function text2(message) {
1201
+ if (message.role === "user" || message.role === "system") {
1202
+ return typeof message.content === "string" ? message.content : message.content.map((part) => part.type === "text" ? part.text : "").join("");
1203
+ }
1204
+ if (message.role === "assistant") {
1205
+ return message.content.map((part) => part.type === "text" ? part.text : "").join("");
1206
+ }
1207
+ return "";
1208
+ }
1209
+ AgentPrompt.text = text2;
1210
+ })(AgentPrompt ||= {});
1211
+
1212
+ // src/agent-tool.ts
1213
+ function relative(path, dirs) {
1214
+ const dir = dirs.find((candidate) => path.startsWith(`${candidate}/`) || path.startsWith(`${candidate}\\`));
1215
+ return dir ? path.slice(dir.length + 1) : path;
1216
+ }
1217
+ function str2(value) {
1218
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
1219
+ }
1220
+ var AgentTool;
1221
+ ((AgentTool) => {
1222
+ AgentTool.NAME = "agent_tool";
1223
+ function args(run, cwd = []) {
1224
+ const input = run.input;
1225
+ const title = run.title || run.name || run.kind;
1226
+ let target;
1227
+ switch (run.kind) {
1228
+ case "execute":
1229
+ target = str2(input.command) ?? title.replace(/^`|`$/g, "");
1230
+ break;
1231
+ case "read":
1232
+ case "edit":
1233
+ case "delete":
1234
+ case "move":
1235
+ target = run.locations[0] ?? str2(input.file_path) ?? str2(input.path) ?? str2(input.filePath);
1236
+ break;
1237
+ case "search":
1238
+ target = str2(input.pattern) ?? str2(input.query);
1239
+ break;
1240
+ case "fetch":
1241
+ target = str2(input.url) ?? str2(input.query);
1242
+ break;
1243
+ }
1244
+ target ??= str2(input.description);
1245
+ return { title, kind: run.kind, target: relative(target ?? title, cwd), ...run.name ? { tool: run.name } : {} };
1246
+ }
1247
+ AgentTool.args = args;
1248
+ function definition(calls) {
1249
+ return {
1250
+ name: AgentTool.NAME,
1251
+ label: "Agent tool",
1252
+ description: "A tool call another coding agent made with its own tools. Only that agent calls it.",
1253
+ parameters: {
1254
+ type: "object",
1255
+ properties: {
1256
+ title: { type: "string" },
1257
+ kind: { type: "string" },
1258
+ target: { type: "string" },
1259
+ tool: { type: "string" }
1260
+ }
1261
+ },
1262
+ exposure: "direct",
1263
+ defaultActive: false,
1264
+ annotations: { readOnlyHint: true },
1265
+ async execute(toolCallId, _params, signal) {
1266
+ const call = calls.get(toolCallId);
1267
+ if (!call) {
1268
+ return { content: [{ type: "text", text: "This call ran in an earlier run of the agent." }], details: {} };
1269
+ }
1270
+ const run = await call.turn.waitTool(toolCallId, signal);
1271
+ if (signal?.aborted) {
1272
+ call.session.abandon(call.turn);
1273
+ calls.delete(toolCallId);
1274
+ throw new Error("Cancelled");
1275
+ }
1276
+ calls.delete(toolCallId);
1277
+ const details = { agent: call.agent, kind: run?.kind, title: run?.title, status: run?.status, locations: run?.locations };
1278
+ if (!run?.done) {
1279
+ return { content: [{ type: "text", text: text("unfinished", call.agent) }], details, isError: true };
1280
+ }
1281
+ return { content: [{ type: "text", text: run.output || "(no output)" }], details, isError: run.status === "failed" };
1282
+ }
1283
+ };
1284
+ }
1285
+ AgentTool.definition = definition;
1286
+ })(AgentTool ||= {});
1287
+
1288
+ // src/message-stream.ts
1289
+ class MessageStream {
1290
+ queue = [];
1291
+ waiting;
1292
+ done = false;
1293
+ resolveResult;
1294
+ final = new Promise((resolve) => this.resolveResult = resolve);
1295
+ push(event) {
1296
+ if (this.done) {
1297
+ return;
1298
+ }
1299
+ if (event.type === "done" || event.type === "error") {
1300
+ this.done = true;
1301
+ this.resolveResult(event.type === "done" ? event.message : event.error);
1302
+ }
1303
+ this.queue.push(event);
1304
+ this.waiting?.();
1305
+ }
1306
+ result() {
1307
+ return this.final;
1308
+ }
1309
+ async* [Symbol.asyncIterator]() {
1310
+ for (;; ) {
1311
+ const event = this.queue.shift();
1312
+ if (event) {
1313
+ yield event;
1314
+ if (event.type === "done" || event.type === "error") {
1315
+ return;
1316
+ }
1317
+ } else {
1318
+ await new Promise((resolve) => this.waiting = resolve);
1319
+ this.waiting = undefined;
1320
+ }
1321
+ }
1322
+ }
1323
+ }
1324
+ function emptyUsage() {
1325
+ return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } };
1326
+ }
1327
+
1328
+ class MessageBuilder {
1329
+ stream;
1330
+ message;
1331
+ open;
1332
+ ended = false;
1333
+ started = Date.now();
1334
+ constructor(stream, model) {
1335
+ this.stream = stream;
1336
+ this.message = {
1337
+ role: "assistant",
1338
+ content: [],
1339
+ api: model.api,
1340
+ provider: model.provider,
1341
+ model: model.id,
1342
+ usage: emptyUsage(),
1343
+ stopReason: "stop",
1344
+ timestamp: this.started
1345
+ };
1346
+ this.stream.push({ type: "start", partial: this.message });
1347
+ }
1348
+ append(type, delta) {
1349
+ if (!delta) {
1350
+ return;
1351
+ }
1352
+ if (this.open?.type !== type) {
1353
+ this.close();
1354
+ const index2 = this.message.content.length;
1355
+ this.message.content.push(type === "text" ? { type: "text", text: "" } : { type: "thinking", thinking: "" });
1356
+ this.open = { type, index: index2 };
1357
+ this.stream.push({ type: type === "text" ? "text_start" : "thinking_start", contentIndex: index2, partial: this.message });
1358
+ }
1359
+ const index = this.open.index;
1360
+ const block = this.message.content[index];
1361
+ if (block.type === "text") {
1362
+ block.text += delta;
1363
+ this.stream.push({ type: "text_delta", contentIndex: index, delta, partial: this.message });
1364
+ } else if (block.type === "thinking") {
1365
+ block.thinking += delta;
1366
+ this.stream.push({ type: "thinking_delta", contentIndex: index, delta, partial: this.message });
1367
+ }
1368
+ }
1369
+ toolCall(call) {
1370
+ this.close();
1371
+ const index = this.message.content.length;
1372
+ this.message.content.push(call);
1373
+ this.stream.push({ type: "toolcall_start", contentIndex: index, partial: this.message });
1374
+ this.stream.push({ type: "toolcall_delta", contentIndex: index, delta: JSON.stringify(call.arguments), partial: this.message });
1375
+ this.stream.push({ type: "toolcall_end", contentIndex: index, toolCall: call, partial: this.message });
1376
+ }
1377
+ done(reason, usage) {
1378
+ if (this.ended) {
1379
+ return;
1380
+ }
1381
+ this.close();
1382
+ this.ended = true;
1383
+ this.message.stopReason = reason;
1384
+ this.message.usage = usage ?? this.message.usage;
1385
+ this.message.durationMs = Date.now() - this.started;
1386
+ this.stream.push({ type: "done", reason, message: this.message });
1387
+ }
1388
+ error(reason, message) {
1389
+ if (this.ended) {
1390
+ return;
1391
+ }
1392
+ this.close();
1393
+ this.ended = true;
1394
+ this.message.stopReason = reason;
1395
+ this.message.errorMessage = message;
1396
+ this.message.durationMs = Date.now() - this.started;
1397
+ this.stream.push({ type: "error", reason, error: this.message });
1398
+ }
1399
+ close() {
1400
+ if (!this.open) {
1401
+ return;
1402
+ }
1403
+ const { type, index } = this.open;
1404
+ const block = this.message.content[index];
1405
+ this.open = undefined;
1406
+ if (type === "text" && block.type === "text") {
1407
+ this.stream.push({ type: "text_end", contentIndex: index, content: block.text, partial: this.message });
1408
+ } else if (block.type === "thinking") {
1409
+ this.stream.push({ type: "thinking_end", contentIndex: index, content: block.thinking, partial: this.message });
1410
+ }
1411
+ }
1412
+ }
1413
+
1414
+ // src/agent-streamer.ts
1415
+ var SETTLE_MS = 1500;
1416
+ var THINKING = {
1417
+ minimal: ["minimal", "low"],
1418
+ low: ["low"],
1419
+ medium: ["medium"],
1420
+ high: ["high"],
1421
+ xhigh: ["xhigh", "max", "high"]
1422
+ };
1423
+
1424
+ class AgentStreamer {
1425
+ host;
1426
+ constructor(host) {
1427
+ this.host = host;
1428
+ }
1429
+ stream(config, model, context, options) {
1430
+ const stream = new MessageStream;
1431
+ const builder = new MessageBuilder(stream, model);
1432
+ this.run(config, model, context, options, builder).catch((error) => builder.error("error", AgentStreamer.describe(config, error)));
1433
+ return stream;
1434
+ }
1435
+ async run(config, model, context, options, builder) {
1436
+ const signal = options?.signal;
1437
+ const { session, fresh, images, dirs } = await this.host.open(config, signal);
1438
+ const pending = AgentPrompt.pending(context.messages);
1439
+ let turn = session.turn;
1440
+ if (turn) {
1441
+ if (pending.length) {
1442
+ session.queue(AgentPrompt.blocks(pending, images));
1443
+ }
1444
+ } else {
1445
+ let prompt = pending.length ? AgentPrompt.blocks(pending, images) : session.takeQueued();
1446
+ if (!prompt?.length) {
1447
+ builder.done("stop");
1448
+ return;
1449
+ }
1450
+ const earlier = fresh ? AgentPrompt.transcript(context.messages, pending.length) : undefined;
1451
+ if (earlier) {
1452
+ prompt = [{ type: "text", text: earlier }, ...prompt];
1453
+ }
1454
+ await session.idle();
1455
+ await this.configure(session, model, options, signal);
1456
+ turn = session.prompt(prompt);
1457
+ }
1458
+ for (;; ) {
1459
+ const item = await turn.next(signal);
1460
+ if (!item) {
1461
+ session.abandon(turn);
1462
+ builder.error("aborted", "Aborted");
1463
+ return;
1464
+ }
1465
+ switch (item.type) {
1466
+ case "text":
1467
+ case "thinking":
1468
+ builder.append(item.type, item.text);
1469
+ break;
1470
+ case "tool":
1471
+ await this.tools(config, session, turn, item.id, builder, dirs, signal);
1472
+ return;
1473
+ case "end": {
1474
+ session.finished(turn);
1475
+ this.host.ended(config, session);
1476
+ const queued = session.takeQueued();
1477
+ if (queued) {
1478
+ turn = session.prompt(queued);
1479
+ break;
1480
+ }
1481
+ if (item.reason === "cancelled" && signal?.aborted) {
1482
+ builder.error("aborted", "Aborted");
1483
+ } else {
1484
+ if (turn.command && !turn.produced) {
1485
+ builder.append("text", text("commandDone", config.name, turn.command));
1486
+ }
1487
+ builder.done("stop", AgentStreamer.usage(turn));
1488
+ }
1489
+ return;
1490
+ }
1491
+ case "error":
1492
+ session.finished(turn);
1493
+ builder.error("error", AgentStreamer.describe(config, item));
1494
+ return;
1495
+ }
1496
+ }
1497
+ }
1498
+ async tools(config, session, turn, first, builder, dirs, signal) {
1499
+ const ids = [first];
1500
+ while (turn.peek()?.type === "tool") {
1501
+ ids.push(turn.shift().id);
1502
+ }
1503
+ for (const id of ids) {
1504
+ await turn.settle(id, SETTLE_MS, signal);
1505
+ }
1506
+ if (signal?.aborted) {
1507
+ session.abandon(turn);
1508
+ builder.error("aborted", "Aborted");
1509
+ return;
1510
+ }
1511
+ for (const id of ids) {
1512
+ const run = turn.tools.get(id);
1513
+ if (run) {
1514
+ this.host.calls.set(id, { agent: config.name, session, turn });
1515
+ builder.toolCall({ type: "toolCall", id, name: AgentTool.NAME, arguments: AgentTool.args(run, dirs) });
1516
+ }
1517
+ }
1518
+ builder.done("toolUse");
1519
+ }
1520
+ async configure(session, model, options, signal) {
1521
+ try {
1522
+ if (model.id !== AgentCatalog.DEFAULT_MODEL) {
1523
+ await session.select("model", model.id, signal);
1524
+ }
1525
+ const level = options?.reasoning;
1526
+ if (level && model.reasoning) {
1527
+ const offered = Acp.values(Acp.optionOf(session.options, "thought_level")).map((value) => value.value);
1528
+ await session.select("thought_level", (THINKING[level] ?? [level]).find((value) => offered.includes(value)), signal);
1529
+ }
1530
+ } catch {}
1531
+ }
1532
+ static usage(turn) {
1533
+ const usage = emptyUsage();
1534
+ const { input, output, cacheRead, used } = turn.usage;
1535
+ usage.cacheRead = cacheRead ?? 0;
1536
+ usage.input = input !== undefined ? Math.max(0, input - usage.cacheRead) : used ?? 0;
1537
+ usage.output = output ?? 0;
1538
+ usage.totalTokens = usage.input + usage.output + usage.cacheRead;
1539
+ return usage;
1540
+ }
1541
+ static describe(config, error) {
1542
+ const { message, code } = error ?? {};
1543
+ if (code === Acp.AUTH_REQUIRED) {
1544
+ return text("signIn", config.name, config.login ?? config.command);
1545
+ }
1546
+ return message || String(error);
1547
+ }
1548
+ }
1549
+
1550
+ // src/extension.ts
1551
+ var TA_FILE_WRITE_EVENT = "ta:file-write";
1552
+ var ACTIVITY_ENTRY = "ta-agents.activity";
1553
+ var CONTEXT_WINDOW = 200000;
1554
+ var MAX_TOKENS = 32000;
1555
+ var INSTANCES = Symbol.for("ta-agents.instances");
1556
+ var Sessions;
1557
+ ((Sessions) => {
1558
+ function all() {
1559
+ const global = globalThis;
1560
+ const map = global[INSTANCES] ?? new Map;
1561
+ global[INSTANCES] = map;
1562
+ return map;
1563
+ }
1564
+ function set(id, instance) {
1565
+ all().set(id, instance);
1566
+ }
1567
+ Sessions.set = set;
1568
+ function remove(id, instance) {
1569
+ if (all().get(id) === instance) {
1570
+ all().delete(id);
1571
+ }
1572
+ }
1573
+ Sessions.remove = remove;
1574
+ function get(id) {
1575
+ return id ? all().get(id) : undefined;
1576
+ }
1577
+ Sessions.get = get;
1578
+ })(Sessions ||= {});
1579
+ function activate(pi, options = {}) {
1580
+ const find = options.find ?? Programs.find;
1581
+ const userAgents = options.userAgents ?? (() => {
1582
+ return;
1583
+ });
1584
+ const cache = options.cache ?? new ModelCache;
1585
+ const calls = new Map;
1586
+ let configs = [];
1587
+ let context;
1588
+ const ours = (model) => configs.find((config) => config.id === model?.provider);
1589
+ const providerModels = (config) => {
1590
+ const known = cache.get(config.id);
1591
+ const listed = [
1592
+ { id: AgentCatalog.DEFAULT_MODEL, name: config.name },
1593
+ ...(known?.models ?? []).filter((model) => model.id !== AgentCatalog.DEFAULT_MODEL).map((model) => ({ id: model.id, name: model.name }))
1594
+ ];
1595
+ return listed.map((model) => ({
1596
+ ...model,
1597
+ reasoning: known?.reasoning ?? false,
1598
+ input: ["text", "image"],
1599
+ cost: { ...emptyUsage().cost },
1600
+ contextWindow: known?.contextWindow ?? CONTEXT_WINDOW,
1601
+ maxTokens: MAX_TOKENS
1602
+ }));
1603
+ };
1604
+ const register = (config) => pi.registerProvider(config.id, {
1605
+ name: config.name,
1606
+ baseUrl: `acp://${config.id}`,
1607
+ apiKey: "acp",
1608
+ api: `acp-${config.id}`,
1609
+ streamSimple: (model, transcript, streamOptions) => {
1610
+ const owner = Sessions.get(streamOptions?.sessionId) ?? self;
1611
+ const own = owner.configs().find((candidate) => candidate.id === config.id) ?? config;
1612
+ return owner.streamer.stream(own, model, transcript, streamOptions);
1613
+ },
1614
+ models: providerModels(config)
1615
+ });
1616
+ const offer = (next) => {
1617
+ for (const config of configs) {
1618
+ if (!next.some((candidate) => candidate.id === config.id)) {
1619
+ pi.unregisterProvider(config.id);
1620
+ }
1621
+ }
1622
+ configs = next;
1623
+ configs.forEach(register);
1624
+ };
1625
+ const learn = (config, session, contextWindow) => {
1626
+ const option = Acp.optionOf(session.options, "model");
1627
+ const models = option ? Acp.values(option).map((value) => ({ id: value.value, name: value.name })) : (session.models?.availableModels ?? []).map((model) => ({ id: model.modelId, name: model.name }));
1628
+ const known = cache.get(config.id);
1629
+ const next = {
1630
+ models,
1631
+ reasoning: !!Acp.optionOf(session.options, "thought_level"),
1632
+ contextWindow: contextWindow ?? known?.contextWindow
1633
+ };
1634
+ if (cache.set(config.id, next)) {
1635
+ register(config);
1636
+ }
1637
+ };
1638
+ const toggleTool = (model) => {
1639
+ const active = pi.getActiveTools();
1640
+ const has = active.includes(AgentTool.NAME);
1641
+ if (ours(model) && !has) {
1642
+ pi.setActiveTools([...active, AgentTool.NAME]);
1643
+ } else if (!ours(model) && has) {
1644
+ pi.setActiveTools(active.filter((name) => name !== AgentTool.NAME));
1645
+ }
1646
+ };
1647
+ const bindings = new AgentBindings((binding) => pi.appendEntry(BINDING_ENTRY, binding), (config, session) => {
1648
+ session.callbacks = {
1649
+ permission: async (request) => {
1650
+ const ui = context?.hasUI ? context.ui : undefined;
1651
+ if (config.permissions !== "ask" || !ui) {
1652
+ return AgentSession.allow(request);
1653
+ }
1654
+ const chosen = await ui.select(`${config.name}: ${request.toolCall.title ?? "permission"}`, request.options.map((option2) => option2.name));
1655
+ const option = request.options.find((candidate) => candidate.name === chosen);
1656
+ return option ? { outcome: "selected", optionId: option.optionId } : { outcome: "cancelled" };
1657
+ },
1658
+ title: (title) => {
1659
+ if (!pi.getSessionName()) {
1660
+ pi.setSessionName(title);
1661
+ }
1662
+ },
1663
+ activity: () => {
1664
+ if (context?.model?.provider === config.id) {
1665
+ pi.sendMessage({ customType: ACTIVITY_ENTRY, content: ACTIVITY_TEXT, display: false }, { triggerTurn: true });
1666
+ }
1667
+ },
1668
+ write: (path, before) => {
1669
+ const file = { path: resolve(context?.cwd ?? bindings.cwd, path), ...before !== undefined ? { before } : {} };
1670
+ pi.events.emit(TA_FILE_WRITE_EVENT, file);
1671
+ }
1672
+ };
1673
+ learn(config, session);
1674
+ }, options.agentOf);
1675
+ const streamer = new AgentStreamer({
1676
+ open: (config, signal) => bindings.open(config, signal),
1677
+ calls,
1678
+ ended: (config, session) => {
1679
+ if (session.title && !pi.getSessionName()) {
1680
+ pi.setSessionName(session.title);
1681
+ }
1682
+ const size = session.turn?.usage.size;
1683
+ if (size) {
1684
+ learn(config, session, size);
1685
+ }
1686
+ }
1687
+ });
1688
+ const self = { configs: () => configs, streamer };
1689
+ let sessionId;
1690
+ pi.registerTool(AgentTool.definition(calls));
1691
+ offer(AgentCatalog.agents(userAgents(), find));
1692
+ pi.on("session_start", (event, ctx) => {
1693
+ context = ctx;
1694
+ if (sessionId) {
1695
+ Sessions.remove(sessionId, self);
1696
+ }
1697
+ sessionId = ctx.sessionManager.getSessionId();
1698
+ Sessions.set(sessionId, self);
1699
+ bindings.cwd = ctx.cwd;
1700
+ bindings.restore(ctx.sessionManager.getBranch(), event.reason === "fork");
1701
+ const settings = pi.getSettings().agents;
1702
+ offer(AgentCatalog.agents(settings, find));
1703
+ toggleTool(ctx.model);
1704
+ });
1705
+ pi.on("model_select", (event) => toggleTool(event.model));
1706
+ pi.on("session_tree", () => bindings.forget());
1707
+ pi.on("session_before_compact", (event, ctx) => {
1708
+ if (!ours(ctx.model)) {
1709
+ return;
1710
+ }
1711
+ if (event.reason === "manual") {
1712
+ setTimeout(() => pi.sendUserMessage("/compact"), 0);
1713
+ }
1714
+ return { cancel: true };
1715
+ });
1716
+ pi.on("session_shutdown", () => {
1717
+ bindings.close();
1718
+ context = undefined;
1719
+ if (sessionId) {
1720
+ Sessions.remove(sessionId, self);
1721
+ }
1722
+ });
1723
+ }
1724
+ function agentDir(env = process.env) {
1725
+ let config = {};
1726
+ try {
1727
+ config = JSON.parse(readFileSync2(join3(env.PI_PACKAGE_DIR ?? "", "package.json"), "utf8")).piConfig ?? {};
1728
+ } catch {}
1729
+ const name = config.name || "pi";
1730
+ return env[`${name.toUpperCase()}_CODING_AGENT_DIR`] || join3(homedir3(), config.configDir || ".pi", "agent");
1731
+ }
1732
+ function readUserAgents(agentDir2) {
1733
+ try {
1734
+ return JSON.parse(readFileSync2(join3(agentDir2, "settings.json"), "utf8")).agents;
1735
+ } catch {
1736
+ return;
1737
+ }
1738
+ }
1739
+ function extension_default(pi) {
1740
+ activate(pi, { userAgents: () => readUserAgents(agentDir()) });
1741
+ }
1742
+ export {
1743
+ extension_default as default,
1744
+ agentDir,
1745
+ activate
1746
+ };