@celljs/ta 4.7.0 → 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 (421) hide show
  1. package/README.en.md +5 -1
  2. package/README.md +4 -0
  3. package/dist/cli.mjs +20 -7
  4. package/dist/pi/CHANGELOG.md +24 -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/lib/views.d.ts.map +1 -1
  134. package/dist/pi/packages/ta-channels/lib/views.js +6 -1
  135. package/dist/pi/packages/ta-channels/lib/views.js.map +1 -1
  136. package/dist/pi/packages/ta-channels/package.json +1 -1
  137. package/dist/pi/packages/ta-channels/web/index.js +5 -1
  138. package/dist/pi/packages/ta-computer-use/extension/index.mjs +4 -2
  139. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.d.ts +2 -1
  140. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.d.ts.map +1 -1
  141. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.js +9 -3
  142. package/dist/pi/packages/ta-computer-use/lib/cua-driver-access.js.map +1 -1
  143. package/dist/pi/packages/ta-computer-use/package.json +1 -1
  144. package/dist/pi/packages/ta-cron/README.en.md +48 -0
  145. package/dist/pi/packages/ta-cron/README.md +48 -0
  146. package/dist/pi/packages/ta-cron/extension/index.mjs +856 -0
  147. package/dist/pi/packages/ta-cron/host/index.mjs +877 -0
  148. package/dist/pi/packages/ta-cron/lib/commands.d.ts +61 -0
  149. package/dist/pi/packages/ta-cron/lib/commands.d.ts.map +1 -0
  150. package/dist/pi/packages/ta-cron/lib/commands.js +250 -0
  151. package/dist/pi/packages/ta-cron/lib/commands.js.map +1 -0
  152. package/dist/pi/packages/ta-cron/lib/cron-expression.d.ts +39 -0
  153. package/dist/pi/packages/ta-cron/lib/cron-expression.d.ts.map +1 -0
  154. package/dist/pi/packages/ta-cron/lib/cron-expression.js +146 -0
  155. package/dist/pi/packages/ta-cron/lib/cron-expression.js.map +1 -0
  156. package/dist/pi/packages/ta-cron/lib/cron-protocol.d.ts +160 -0
  157. package/dist/pi/packages/ta-cron/lib/cron-protocol.d.ts.map +1 -0
  158. package/dist/pi/packages/ta-cron/lib/cron-protocol.js +38 -0
  159. package/dist/pi/packages/ta-cron/lib/cron-protocol.js.map +1 -0
  160. package/dist/pi/packages/ta-cron/lib/editor.d.ts +17 -0
  161. package/dist/pi/packages/ta-cron/lib/editor.d.ts.map +1 -0
  162. package/dist/pi/packages/ta-cron/lib/editor.js +145 -0
  163. package/dist/pi/packages/ta-cron/lib/editor.js.map +1 -0
  164. package/dist/pi/packages/ta-cron/lib/extension.d.ts +27 -0
  165. package/dist/pi/packages/ta-cron/lib/extension.d.ts.map +1 -0
  166. package/dist/pi/packages/ta-cron/lib/extension.js +142 -0
  167. package/dist/pi/packages/ta-cron/lib/extension.js.map +1 -0
  168. package/dist/pi/packages/ta-cron/lib/form-util.d.ts +39 -0
  169. package/dist/pi/packages/ta-cron/lib/form-util.d.ts.map +1 -0
  170. package/dist/pi/packages/ta-cron/lib/form-util.js +121 -0
  171. package/dist/pi/packages/ta-cron/lib/form-util.js.map +1 -0
  172. package/dist/pi/packages/ta-cron/lib/host.d.ts +7 -0
  173. package/dist/pi/packages/ta-cron/lib/host.d.ts.map +1 -0
  174. package/dist/pi/packages/ta-cron/lib/host.js +14 -0
  175. package/dist/pi/packages/ta-cron/lib/host.js.map +1 -0
  176. package/dist/pi/packages/ta-cron/lib/i18n.d.ts +90 -0
  177. package/dist/pi/packages/ta-cron/lib/i18n.d.ts.map +1 -0
  178. package/dist/pi/packages/ta-cron/lib/i18n.js +177 -0
  179. package/dist/pi/packages/ta-cron/lib/i18n.js.map +1 -0
  180. package/dist/pi/packages/ta-cron/lib/index.d.ts +8 -0
  181. package/dist/pi/packages/ta-cron/lib/index.d.ts.map +1 -0
  182. package/dist/pi/packages/ta-cron/lib/index.js +37 -0
  183. package/dist/pi/packages/ta-cron/lib/index.js.map +1 -0
  184. package/dist/pi/packages/ta-cron/lib/model-picker.d.ts +33 -0
  185. package/dist/pi/packages/ta-cron/lib/model-picker.d.ts.map +1 -0
  186. package/dist/pi/packages/ta-cron/lib/model-picker.js +178 -0
  187. package/dist/pi/packages/ta-cron/lib/model-picker.js.map +1 -0
  188. package/dist/pi/packages/ta-cron/lib/notifier.d.ts +6 -0
  189. package/dist/pi/packages/ta-cron/lib/notifier.d.ts.map +1 -0
  190. package/dist/pi/packages/ta-cron/lib/notifier.js +50 -0
  191. package/dist/pi/packages/ta-cron/lib/notifier.js.map +1 -0
  192. package/dist/pi/packages/ta-cron/lib/page.d.ts +39 -0
  193. package/dist/pi/packages/ta-cron/lib/page.d.ts.map +1 -0
  194. package/dist/pi/packages/ta-cron/lib/page.js +113 -0
  195. package/dist/pi/packages/ta-cron/lib/page.js.map +1 -0
  196. package/dist/pi/packages/ta-cron/lib/react.d.ts +8 -0
  197. package/dist/pi/packages/ta-cron/lib/react.d.ts.map +1 -0
  198. package/dist/pi/packages/ta-cron/lib/react.js +8 -0
  199. package/dist/pi/packages/ta-cron/lib/react.js.map +1 -0
  200. package/dist/pi/packages/ta-cron/lib/reply.d.ts +6 -0
  201. package/dist/pi/packages/ta-cron/lib/reply.d.ts.map +1 -0
  202. package/dist/pi/packages/ta-cron/lib/reply.js +53 -0
  203. package/dist/pi/packages/ta-cron/lib/reply.js.map +1 -0
  204. package/dist/pi/packages/ta-cron/lib/schedule-util.d.ts +25 -0
  205. package/dist/pi/packages/ta-cron/lib/schedule-util.d.ts.map +1 -0
  206. package/dist/pi/packages/ta-cron/lib/schedule-util.js +223 -0
  207. package/dist/pi/packages/ta-cron/lib/schedule-util.js.map +1 -0
  208. package/dist/pi/packages/ta-cron/lib/scheduler.d.ts +76 -0
  209. package/dist/pi/packages/ta-cron/lib/scheduler.d.ts.map +1 -0
  210. package/dist/pi/packages/ta-cron/lib/scheduler.js +319 -0
  211. package/dist/pi/packages/ta-cron/lib/scheduler.js.map +1 -0
  212. package/dist/pi/packages/ta-cron/lib/server-texts.d.ts +7 -0
  213. package/dist/pi/packages/ta-cron/lib/server-texts.d.ts.map +1 -0
  214. package/dist/pi/packages/ta-cron/lib/server-texts.js +24 -0
  215. package/dist/pi/packages/ta-cron/lib/server-texts.js.map +1 -0
  216. package/dist/pi/packages/ta-cron/lib/style.d.ts +4 -0
  217. package/dist/pi/packages/ta-cron/lib/style.d.ts.map +1 -0
  218. package/dist/pi/packages/ta-cron/lib/style.js +137 -0
  219. package/dist/pi/packages/ta-cron/lib/style.js.map +1 -0
  220. package/dist/pi/packages/ta-cron/lib/task-store.d.ts +25 -0
  221. package/dist/pi/packages/ta-cron/lib/task-store.d.ts.map +1 -0
  222. package/dist/pi/packages/ta-cron/lib/task-store.js +60 -0
  223. package/dist/pi/packages/ta-cron/lib/task-store.js.map +1 -0
  224. package/dist/pi/packages/ta-cron/lib/task-util.d.ts +18 -0
  225. package/dist/pi/packages/ta-cron/lib/task-util.d.ts.map +1 -0
  226. package/dist/pi/packages/ta-cron/lib/task-util.js +167 -0
  227. package/dist/pi/packages/ta-cron/lib/task-util.js.map +1 -0
  228. package/dist/pi/packages/ta-cron/lib/tasks-view.d.ts +6 -0
  229. package/dist/pi/packages/ta-cron/lib/tasks-view.d.ts.map +1 -0
  230. package/dist/pi/packages/ta-cron/lib/tasks-view.js +189 -0
  231. package/dist/pi/packages/ta-cron/lib/tasks-view.js.map +1 -0
  232. package/dist/pi/packages/ta-cron/lib/tool.d.ts +85 -0
  233. package/dist/pi/packages/ta-cron/lib/tool.d.ts.map +1 -0
  234. package/dist/pi/packages/ta-cron/lib/tool.js +127 -0
  235. package/dist/pi/packages/ta-cron/lib/tool.js.map +1 -0
  236. package/dist/pi/packages/ta-cron/package.json +46 -0
  237. package/dist/pi/packages/ta-cron/web/index.js +1985 -0
  238. package/dist/pi/packages/ta-extensions/package.json +1 -1
  239. package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +3 -2
  240. package/dist/pi/packages/ta-workspace/README.md +5 -5
  241. package/dist/pi/packages/ta-workspace/README.zh-cn.md +6 -6
  242. package/dist/pi/packages/ta-workspace/lib/browser-agent.d.ts +36 -0
  243. package/dist/pi/packages/ta-workspace/lib/browser-agent.d.ts.map +1 -0
  244. package/dist/pi/packages/ta-workspace/lib/browser-agent.js +396 -0
  245. package/dist/pi/packages/ta-workspace/lib/browser-agent.js.map +1 -0
  246. package/dist/pi/packages/ta-workspace/lib/browser-common.d.ts +48 -0
  247. package/dist/pi/packages/ta-workspace/lib/browser-common.d.ts.map +1 -0
  248. package/dist/pi/packages/ta-workspace/lib/browser-common.js +180 -0
  249. package/dist/pi/packages/ta-workspace/lib/browser-common.js.map +1 -0
  250. package/dist/pi/packages/ta-workspace/lib/browser-import.d.ts +5 -0
  251. package/dist/pi/packages/ta-workspace/lib/browser-import.d.ts.map +1 -0
  252. package/dist/pi/packages/ta-workspace/lib/browser-import.js +97 -0
  253. package/dist/pi/packages/ta-workspace/lib/browser-import.js.map +1 -0
  254. package/dist/pi/packages/ta-workspace/lib/browser-webview.d.ts +7 -0
  255. package/dist/pi/packages/ta-workspace/lib/browser-webview.d.ts.map +1 -0
  256. package/dist/pi/packages/ta-workspace/lib/browser-webview.js +202 -0
  257. package/dist/pi/packages/ta-workspace/lib/browser-webview.js.map +1 -0
  258. package/dist/pi/packages/ta-workspace/lib/browser.d.ts +1 -7
  259. package/dist/pi/packages/ta-workspace/lib/browser.d.ts.map +1 -1
  260. package/dist/pi/packages/ta-workspace/lib/browser.js +14 -154
  261. package/dist/pi/packages/ta-workspace/lib/browser.js.map +1 -1
  262. package/dist/pi/packages/ta-workspace/lib/explorer.d.ts.map +1 -1
  263. package/dist/pi/packages/ta-workspace/lib/explorer.js +214 -3
  264. package/dist/pi/packages/ta-workspace/lib/explorer.js.map +1 -1
  265. package/dist/pi/packages/ta-workspace/lib/i18n.d.ts +37 -0
  266. package/dist/pi/packages/ta-workspace/lib/i18n.d.ts.map +1 -1
  267. package/dist/pi/packages/ta-workspace/lib/i18n.js +76 -2
  268. package/dist/pi/packages/ta-workspace/lib/i18n.js.map +1 -1
  269. package/dist/pi/packages/ta-workspace/lib/index.d.ts.map +1 -1
  270. package/dist/pi/packages/ta-workspace/lib/index.js +7 -1
  271. package/dist/pi/packages/ta-workspace/lib/index.js.map +1 -1
  272. package/dist/pi/packages/ta-workspace/lib/style.d.ts +1 -1
  273. package/dist/pi/packages/ta-workspace/lib/style.d.ts.map +1 -1
  274. package/dist/pi/packages/ta-workspace/lib/style.js +35 -6
  275. package/dist/pi/packages/ta-workspace/lib/style.js.map +1 -1
  276. package/dist/pi/packages/ta-workspace/lib/terminal.d.ts +2 -2
  277. package/dist/pi/packages/ta-workspace/lib/terminal.d.ts.map +1 -1
  278. package/dist/pi/packages/ta-workspace/lib/terminal.js +50 -104
  279. package/dist/pi/packages/ta-workspace/lib/terminal.js.map +1 -1
  280. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.d.ts +52 -0
  281. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.d.ts.map +1 -0
  282. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.js +207 -0
  283. package/dist/pi/packages/ta-workspace/lib/util/browser-snapshot.js.map +1 -0
  284. package/dist/pi/packages/ta-workspace/lib/util/upload.d.ts +34 -0
  285. package/dist/pi/packages/ta-workspace/lib/util/upload.d.ts.map +1 -0
  286. package/dist/pi/packages/ta-workspace/lib/util/upload.js +109 -0
  287. package/dist/pi/packages/ta-workspace/lib/util/upload.js.map +1 -0
  288. package/dist/pi/packages/ta-workspace/lib/util/workspace.d.ts +16 -0
  289. package/dist/pi/packages/ta-workspace/lib/util/workspace.d.ts.map +1 -1
  290. package/dist/pi/packages/ta-workspace/lib/util/workspace.js +43 -0
  291. package/dist/pi/packages/ta-workspace/lib/util/workspace.js.map +1 -1
  292. package/dist/pi/packages/ta-workspace/lib/util/zip.d.ts +20 -0
  293. package/dist/pi/packages/ta-workspace/lib/util/zip.d.ts.map +1 -0
  294. package/dist/pi/packages/ta-workspace/lib/util/zip.js +128 -0
  295. package/dist/pi/packages/ta-workspace/lib/util/zip.js.map +1 -0
  296. package/dist/pi/packages/ta-workspace/lib/workspace-client.d.ts +12 -1
  297. package/dist/pi/packages/ta-workspace/lib/workspace-client.d.ts.map +1 -1
  298. package/dist/pi/packages/ta-workspace/lib/workspace-client.js +101 -0
  299. package/dist/pi/packages/ta-workspace/lib/workspace-client.js.map +1 -1
  300. package/dist/pi/packages/ta-workspace/package.json +1 -1
  301. package/dist/pi/packages/ta-workspace/web/index.js +1911 -634
  302. package/dist/public/assets/{abnfDiagram-S7VZAUFO-D1ZeYB9c.js → abnfDiagram-S7VZAUFO-CNqfsCwx.js} +1 -1
  303. package/dist/public/assets/{architecture-WOLXFQ4H-RV_x_iFj.js → architecture-WOLXFQ4H-_WaGq-Qk.js} +1 -1
  304. package/dist/public/assets/{architectureDiagram-YGSQEFNW-BGOmzcpZ.js → architectureDiagram-YGSQEFNW-Bn63Lctu.js} +1 -1
  305. package/dist/public/assets/{blockDiagram-APKKGZFW-BkoflIym.js → blockDiagram-APKKGZFW-BGaAecnk.js} +1 -1
  306. package/dist/public/assets/{browser-Cl9_lr0X.js → browser-DKagIN4Y.js} +1 -1
  307. package/dist/public/assets/{c4Diagram-KJ2TOQU5-CfrQTIEs.js → c4Diagram-KJ2TOQU5-CK9Z_9Zp.js} +1 -1
  308. package/dist/public/assets/{chunk-6MUBBAK2-C-VxnXsG.js → chunk-6MUBBAK2-H3j3MGva.js} +1 -1
  309. package/dist/public/assets/{chunk-AXFCVDMN-aqbxPiaN.js → chunk-AXFCVDMN-Beljdjs9.js} +1 -1
  310. package/dist/public/assets/{chunk-BG4553SI-DDgvFLBP.js → chunk-BG4553SI-TYEV5wLO.js} +1 -1
  311. package/dist/public/assets/{chunk-DQASFODM-CItpjfW5.js → chunk-DQASFODM-gmWJrizf.js} +1 -1
  312. package/dist/public/assets/{chunk-HFQBQIA3-BATYGV1I.js → chunk-HFQBQIA3-BTa7yKXI.js} +1 -1
  313. package/dist/public/assets/{chunk-KQLB2F66-BVAqVjgq.js → chunk-KQLB2F66-BlwMm4R0.js} +1 -1
  314. package/dist/public/assets/{chunk-KS47KZWR-Bk0_a-eE.js → chunk-KS47KZWR-CKTXjzwD.js} +1 -1
  315. package/dist/public/assets/{chunk-LEVMRMFU-DsFG_U8r.js → chunk-LEVMRMFU-Bn9Xkefl.js} +1 -1
  316. package/dist/public/assets/{chunk-M57EVK23-BgeE81Y7.js → chunk-M57EVK23-B_QLqohG.js} +1 -1
  317. package/dist/public/assets/{chunk-OY52VR5R-2Rp6C2LJ.js → chunk-OY52VR5R-BflzJHPz.js} +1 -1
  318. package/dist/public/assets/{chunk-QB3YPZ4I-BhcIp-Bl.js → chunk-QB3YPZ4I-BXucfaFg.js} +1 -1
  319. package/dist/public/assets/{chunk-R3KSYZAL-i9n2AYPG.js → chunk-R3KSYZAL-CGwkwxm9.js} +1 -1
  320. package/dist/public/assets/{chunk-STOXU5M4-DOSqSu65.js → chunk-STOXU5M4-DQGOPuM5.js} +1 -1
  321. package/dist/public/assets/{chunk-TU62E6Q5-BDA8bjy3.js → chunk-TU62E6Q5-BCrs6AYI.js} +1 -1
  322. package/dist/public/assets/{chunk-X4PVCEUW-Cs-r9l_d.js → chunk-X4PVCEUW-MTv7nXJX.js} +1 -1
  323. package/dist/public/assets/{chunk-XXDRQBXY-DEcanQFC.js → chunk-XXDRQBXY-fPaX8VIb.js} +1 -1
  324. package/dist/public/assets/{classDiagram-v2-L25IHNXF-BS8XxKRR.js → classDiagram-v2-L25IHNXF-tm4uT08q.js} +1 -1
  325. package/dist/public/assets/{cose-bilkent-JH36ORCC--RPleOJ8.js → cose-bilkent-JH36ORCC-Dkk3pDZj.js} +1 -1
  326. package/dist/public/assets/cynefin-EF2NZ3EQ-D_QV_BJg.js +1 -0
  327. package/dist/public/assets/{cynefinDiagram-L36ESFBY-DZHM2oEU.js → cynefinDiagram-L36ESFBY-BcoArW00.js} +1 -1
  328. package/dist/public/assets/{d3-selection-D2iIEb1P.js → d3-selection-BzUITLov.js} +1 -1
  329. package/dist/public/assets/{dagre-SPEB5RXH-h_G5ukMB.js → dagre-SPEB5RXH-oiU-wJxw.js} +1 -1
  330. package/dist/public/assets/{diagram-3B7GL73J-BnThWj9P.js → diagram-3B7GL73J-BwlCOIW4.js} +1 -1
  331. package/dist/public/assets/{diagram-DNEMPZML-DHCMo8sZ.js → diagram-DNEMPZML-CZGQiFrl.js} +1 -1
  332. package/dist/public/assets/{diagram-L3MUGCDN-DxJZnIKT.js → diagram-L3MUGCDN-BJGDa24C.js} +1 -1
  333. package/dist/public/assets/{diagram-LA4NIPWU-Cn0SGxqL.js → diagram-LA4NIPWU-DdwHRhnP.js} +1 -1
  334. package/dist/public/assets/{diagram-MHCOC4E2-BafBOkBk.js → diagram-MHCOC4E2-IjreLUB9.js} +1 -1
  335. package/dist/public/assets/{diagram-XPFHEONP-D7UnEMcU.js → diagram-XPFHEONP-CvaG0Zzq.js} +1 -1
  336. package/dist/public/assets/{dist-CN9JBoER.js → dist-Cm4zqoMA.js} +1 -1
  337. package/dist/public/assets/{ebnfDiagram-UZSYDL2S-Us1rkKwp.js → ebnfDiagram-UZSYDL2S-C-FOI67M.js} +1 -1
  338. package/dist/public/assets/{editor.api-S_CuXudU.js → editor.api-hteKufWf.js} +1 -1
  339. package/dist/public/assets/{elk-XV6XMXQE-Czvqrn49.js → elk-XV6XMXQE-C_ClfkLy.js} +1 -1
  340. package/dist/public/assets/{erDiagram-EYBAPDEH-C0g3K15f.js → erDiagram-EYBAPDEH-DSr0aRYm.js} +1 -1
  341. package/dist/public/assets/{eventmodeling-K75KTNOO-DIcU7mQ5.js → eventmodeling-K75KTNOO-COU_atV6.js} +1 -1
  342. package/dist/public/assets/flowDiagram-MALGAFMO-QGLBPpjQ.js +1 -0
  343. package/dist/public/assets/{freemarker2-CkAEBjHO.js → freemarker2-CBJnhymu.js} +1 -1
  344. package/dist/public/assets/{ganttDiagram-23REXITY-CIkKvihz.js → ganttDiagram-23REXITY-BAcXXNjI.js} +1 -1
  345. package/dist/public/assets/gitGraph-VSP46ZUC-ByODkoVe.js +1 -0
  346. package/dist/public/assets/{gitGraphDiagram-STJD7YCW-BxM3589j.js → gitGraphDiagram-STJD7YCW-Bk9sns6k.js} +1 -1
  347. package/dist/public/assets/{handlebars-CPBNiVZ2.js → handlebars-CiqYW1im.js} +1 -1
  348. package/dist/public/assets/{html-CJBVALoy.js → html-kafkm1Z0.js} +1 -1
  349. package/dist/public/assets/{index-CBMmE3BQ.js → index-DPLd0-lb.js} +2 -2
  350. package/dist/public/assets/info-OHQRW6UA-BMphWS2h.js +1 -0
  351. package/dist/public/assets/{infoDiagram-KBXO4MBG-BIcStK_t.js → infoDiagram-KBXO4MBG-2hRQLVWa.js} +1 -1
  352. package/dist/public/assets/{ishikawaDiagram-M35NCXHK-CpV2hKA6.js → ishikawaDiagram-M35NCXHK-hrOnhWJs.js} +1 -1
  353. package/dist/public/assets/{javascript-dv6GQsa3.js → javascript-Dt5MiA9w.js} +1 -1
  354. package/dist/public/assets/{journeyDiagram-OPLOXDXO-B_vnmdId.js → journeyDiagram-OPLOXDXO-d8HJd04q.js} +1 -1
  355. package/dist/public/assets/{jsonMode-DG_orhvz.js → jsonMode-DBICoo6P.js} +1 -1
  356. package/dist/public/assets/{kanban-definition-BZKZHSQY-q5uWw99H.js → kanban-definition-BZKZHSQY-DOUuZDiv.js} +1 -1
  357. package/dist/public/assets/{liquid-CD-LM2Kh.js → liquid-BGYhBP2h.js} +1 -1
  358. package/dist/public/assets/{mdx-C9mfI8up.js → mdx-Ct_gzcP3.js} +1 -1
  359. package/dist/public/assets/{mermaid-parser.core-DNe1duhT.js → mermaid-parser.core-2yhxYNxq.js} +3 -3
  360. package/dist/public/assets/{mermaid.core-B1AcqJgl.js → mermaid.core-sx7teU8z.js} +4 -4
  361. package/dist/public/assets/{mindmap-definition-I2QAS2VK-CwYG3Fl3.js → mindmap-definition-I2QAS2VK-DIc9LejH.js} +1 -1
  362. package/dist/public/assets/module-BX2fJibj.js +1124 -0
  363. package/dist/public/assets/module-N1D-AOa6.js +1 -0
  364. package/dist/public/assets/{monaco-C0ktZo3r.js → monaco-DJecWyyV.js} +3 -3
  365. package/dist/public/assets/packet-JDAUHWVQ-Ca8klABu.js +1 -0
  366. package/dist/public/assets/{pegDiagram-FD4XPPHP-DxtA4QDS.js → pegDiagram-FD4XPPHP-BfiT6-Vx.js} +1 -1
  367. package/dist/public/assets/pie-XZMESJXO-B-SN2eCI.js +1 -0
  368. package/dist/public/assets/{pieDiagram-J4AKIIQI-CfcIi0Vn.js → pieDiagram-J4AKIIQI-DJ0sF_Eg.js} +1 -1
  369. package/dist/public/assets/{python-DCA1j2QE.js → python-BrnocsK9.js} +1 -1
  370. package/dist/public/assets/{quadrantDiagram-XTYBLID2-BxkJdurF.js → quadrantDiagram-XTYBLID2-C3iF5PG6.js} +1 -1
  371. package/dist/public/assets/radar-ABXABTNO-DzDnNRnq.js +1 -0
  372. package/dist/public/assets/railroad-I3PHUGI6-7QAv0_1N.js +1 -0
  373. package/dist/public/assets/{railroad-abnf-LNEFI6M7--H3g5ywg.js → railroad-abnf-LNEFI6M7-BI4N-mtq.js} +1 -1
  374. package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-C2LAUFu6.js → railroad-ebnf-DWYD2UWJ-Ck2MUlyV.js} +1 -1
  375. package/dist/public/assets/{railroad-peg-JR7BVNR7-Kq_ZXQMl.js → railroad-peg-JR7BVNR7-Cuc9S0f4.js} +1 -1
  376. package/dist/public/assets/{railroadDiagram-MRQ6NCDL-i4xIvHJV.js → railroadDiagram-MRQ6NCDL-Cw24sb_5.js} +1 -1
  377. package/dist/public/assets/{razor-CEeNaFx5.js → razor-BDHTAmlI.js} +1 -1
  378. package/dist/public/assets/{requirementDiagram-Y7LWUY3S-CYNXjuJm.js → requirementDiagram-Y7LWUY3S-QQUXFr1R.js} +1 -1
  379. package/dist/public/assets/{sankeyDiagram-WGJFYUXA-CRQiHcW6.js → sankeyDiagram-WGJFYUXA-mSlfAHND.js} +1 -1
  380. package/dist/public/assets/{sequenceDiagram-5NDRBG5M-BSDVFsi2.js → sequenceDiagram-5NDRBG5M-3t8hVott.js} +1 -1
  381. package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-uyUAaysl.js → stateDiagram-v2-FJ4FJNEA-9EW807AL.js} +1 -1
  382. package/dist/public/assets/{swimlanes-UMQ2AFYF-DdEjQumY.js → swimlanes-UMQ2AFYF-EbMBX_e0.js} +1 -1
  383. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-CIFqDFf2.js +8 -0
  384. package/dist/public/assets/{timeline-definition-SEUHKTQE-DZl-TXXh.js → timeline-definition-SEUHKTQE-D14kjjsp.js} +1 -1
  385. package/dist/public/assets/treeView-D4JQ5SDB-cznq7PJK.js +1 -0
  386. package/dist/public/assets/treemap-SAJKECNS-CBYUiQGU.js +1 -0
  387. package/dist/public/assets/{typescript-DrF8YGbQ.js → typescript-BEEbbq69.js} +1 -1
  388. package/dist/public/assets/{usecaseDiagram-AFA6YXN4-DkG3gLrp.js → usecaseDiagram-AFA6YXN4-DKemtzU9.js} +1 -1
  389. package/dist/public/assets/{vennDiagram-NNMJR3RB-B_lj8x7-.js → vennDiagram-NNMJR3RB-DOBq9oeY.js} +1 -1
  390. package/dist/public/assets/wardley-7MLQ67FV-DV8bp8Ml.js +1 -0
  391. package/dist/public/assets/{wardleyDiagram-S7YFUSEH-B1VFrC5a.js → wardleyDiagram-S7YFUSEH-DquSJ4y-.js} +1 -1
  392. package/dist/public/assets/{xml-DfL-Brke.js → xml-DvTQKQ_W.js} +1 -1
  393. package/dist/public/assets/xterm-BrP-ENHg.css +1 -0
  394. package/dist/public/assets/xterm-wtHqjrNn.js +85 -0
  395. package/dist/public/assets/{xychartDiagram-GGNKY7IX-CM2CpXu9.js → xychartDiagram-GGNKY7IX-ClE_9jz4.js} +1 -1
  396. package/dist/public/assets/{yaml-CpmxRjjF.js → yaml-ffiFfPtJ.js} +1 -1
  397. package/dist/public/index.html +1 -1
  398. package/dist/serve/index.mjs +6624 -6388
  399. package/package.json +22 -19
  400. package/dist/pi/packages/ta-workspace/lib/util/ansi.d.ts +0 -72
  401. package/dist/pi/packages/ta-workspace/lib/util/ansi.d.ts.map +0 -1
  402. package/dist/pi/packages/ta-workspace/lib/util/ansi.js +0 -434
  403. package/dist/pi/packages/ta-workspace/lib/util/ansi.js.map +0 -1
  404. package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts +0 -14
  405. package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts.map +0 -1
  406. package/dist/pi/packages/ta-workspace/lib/util/keys.js +0 -52
  407. package/dist/pi/packages/ta-workspace/lib/util/keys.js.map +0 -1
  408. package/dist/public/assets/cynefin-EF2NZ3EQ-CXQC7Jwi.js +0 -1
  409. package/dist/public/assets/flowDiagram-MALGAFMO-D5Z_jzJ0.js +0 -1
  410. package/dist/public/assets/gitGraph-VSP46ZUC-CvdLb7m6.js +0 -1
  411. package/dist/public/assets/info-OHQRW6UA-BLs8wjUC.js +0 -1
  412. package/dist/public/assets/module-BLLqRvli.js +0 -1099
  413. package/dist/public/assets/module-BZPCnGxA.js +0 -1
  414. package/dist/public/assets/packet-JDAUHWVQ-jwWITUaQ.js +0 -1
  415. package/dist/public/assets/pie-XZMESJXO-CeTVZZgy.js +0 -1
  416. package/dist/public/assets/radar-ABXABTNO-BGI8J8LU.js +0 -1
  417. package/dist/public/assets/railroad-I3PHUGI6-CFkpx3Pr.js +0 -1
  418. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-BJsun6CT.js +0 -8
  419. package/dist/public/assets/treeView-D4JQ5SDB-CL1mG6td.js +0 -1
  420. package/dist/public/assets/treemap-SAJKECNS-Bk3Z1uEC.js +0 -1
  421. package/dist/public/assets/wardley-7MLQ67FV-1E8i3qpD.js +0 -1
@@ -344,6 +344,22 @@ var ZH = {
344
344
  copied: "已复制",
345
345
  findInFolder: "在文件夹中查找…",
346
346
  revealInExplorer: "在资源管理器中显示",
347
+ revealInFinder: "在 Finder 中显示",
348
+ revealInFileExplorer: "在文件资源管理器中显示",
349
+ openContainingFolder: "打开所在的文件夹",
350
+ revealFailed: "无法在文件管理器中显示:{message}",
351
+ uploadFiles: "上传文件…",
352
+ uploadFolder: "上传文件夹…",
353
+ download: "下载",
354
+ uploading: "正在上传 {name}",
355
+ uploaded: "已上传 {count} 个文件",
356
+ uploadFailed: "上传失败:{message}",
357
+ replaceTitle: "已存在 {names},要替换吗?",
358
+ replaceMessage: "同名的文件会被上传的文件覆盖。",
359
+ packing: "正在打包 {name}",
360
+ downloadFailed: "下载失败:{message}",
361
+ moveExists: "目标文件夹中已有“{name}”。",
362
+ moveFailed: "移动失败:{message}",
347
363
  nameEmpty: "必须提供文件或文件夹名称。",
348
364
  nameSlash: "文件或文件夹名称不能以斜杠开头。",
349
365
  nameInvalid: "名称 {name} 不能用作文件或文件夹名称,请换一个。",
@@ -464,7 +480,28 @@ var ZH = {
464
480
  browserHint: "输入网址或搜索,也可以打开本机的开发服务器。",
465
481
  home: "起始页",
466
482
  removeRecent: "从最近访问中移除",
467
- frameHint: "有的网站不允许被嵌入,页面空白时请在新窗口打开。",
483
+ frameHint: "有的网站不允许被嵌入,页面空白时请在新窗口打开;Ta 桌面版没有这个限制。",
484
+ stop: "停止",
485
+ openBrowser: "在默认浏览器中打开",
486
+ loadFailed: "无法打开这个网页",
487
+ pageCrashed: "这个网页崩溃了",
488
+ retry: "重试",
489
+ agentDriving: "Ta 正在操作",
490
+ importSignIns: "导入浏览器的登录状态",
491
+ importTitle: "导入登录状态",
492
+ importHint: "把所选浏览器的 Cookie 复制到这里,你和 Agent 都能直接使用已登录的网站。不导入密码和浏览记录。",
493
+ importFrom: "从哪个浏览器导入",
494
+ noProfiles: "没有找到 Chrome、Edge、Brave、Arc、Vivaldi 或 Chromium 的个人资料。",
495
+ importNow: "导入…",
496
+ importing: "导入中…",
497
+ imported: "已导入 {count} 个 Cookie",
498
+ importSkipped: "{count} 个无法读取,已跳过。",
499
+ importAppBound: "{count} 个受 Chrome 应用绑定加密保护,只能在网站上重新登录。",
500
+ clearBrowserData: "清除内置浏览器数据",
501
+ clearBrowserDataDetail: "删除内置浏览器的全部 Cookie、网站存储和缓存,网站都需要重新登录。",
502
+ clear: "清除",
503
+ cleared: "已清除内置浏览器数据",
504
+ done: "完成",
468
505
  binary: "二进制文件,不显示内容({size})。",
469
506
  truncated: "文件较大,只显示前 1 MB,不能编辑。",
470
507
  line: "第 {line} 行",
@@ -493,6 +530,22 @@ var EN = {
493
530
  copied: "Copied",
494
531
  findInFolder: "Find in Folder…",
495
532
  revealInExplorer: "Reveal in Explorer",
533
+ revealInFinder: "Reveal in Finder",
534
+ revealInFileExplorer: "Reveal in File Explorer",
535
+ openContainingFolder: "Open Containing Folder",
536
+ revealFailed: "Could not show it in the file manager: {message}",
537
+ uploadFiles: "Upload Files…",
538
+ uploadFolder: "Upload Folder…",
539
+ download: "Download",
540
+ uploading: "Uploading {name}",
541
+ uploaded: "Uploaded {count} file(s)",
542
+ uploadFailed: "Could not upload: {message}",
543
+ replaceTitle: "{names} already exists. Replace it?",
544
+ replaceMessage: "Files of the same name are overwritten by the uploaded ones.",
545
+ packing: "Packing {name}",
546
+ downloadFailed: "Could not download: {message}",
547
+ moveExists: "{name} already exists in the folder.",
548
+ moveFailed: "Could not move: {message}",
496
549
  nameEmpty: "A file or folder name must be provided.",
497
550
  nameSlash: "A file or folder name cannot start with a slash.",
498
551
  nameInvalid: "The name {name} is not valid as a file or folder name. Please choose a different name.",
@@ -613,7 +666,28 @@ var EN = {
613
666
  browserHint: "Enter an address or search, or open a dev server on this machine.",
614
667
  home: "Start page",
615
668
  removeRecent: "Remove from recent",
616
- frameHint: "Some sites refuse to be embedded; if the page stays blank, open it in a new window.",
669
+ frameHint: "Some sites refuse to be embedded; if the page stays blank, open it in a new window. Ta Desktop has no such limit.",
670
+ stop: "Stop",
671
+ openBrowser: "Open in the default browser",
672
+ loadFailed: "This page did not open",
673
+ pageCrashed: "This page crashed",
674
+ retry: "Retry",
675
+ agentDriving: "Ta is working here",
676
+ importSignIns: "Import sign-ins from your browser",
677
+ importTitle: "Import sign-ins",
678
+ importHint: "Copies the cookies of the browser you pick here, so you and the agent use the sites you are signed in to. Passwords and history are not imported.",
679
+ importFrom: "Import from",
680
+ noProfiles: "No profile of Chrome, Edge, Brave, Arc, Vivaldi or Chromium was found.",
681
+ importNow: "Import…",
682
+ importing: "Importing…",
683
+ imported: "{count} cookies imported",
684
+ importSkipped: "{count} could not be read and were skipped.",
685
+ importAppBound: "{count} are under Chrome's app-bound encryption: sign in again on those sites.",
686
+ clearBrowserData: "Clear browser data",
687
+ clearBrowserDataDetail: "Deletes every cookie, site storage and the cache of the browser of Ta: every site needs a sign-in again.",
688
+ clear: "Clear",
689
+ cleared: "Browser data cleared",
690
+ done: "Done",
617
691
  binary: "A binary file; its content is not shown ({size}).",
618
692
  truncated: "A large file: only the first 1 MB is shown, read-only.",
619
693
  line: "Line {line}",
@@ -931,6 +1005,27 @@ var WorkspaceUtil;
931
1005
  return !folder || path === folder || path.startsWith(`${folder}/`);
932
1006
  }
933
1007
  WorkspaceUtil.within = within;
1008
+ function movable(paths2, folder) {
1009
+ const unique = [...new Set(paths2)].filter((path) => path && !within(folder, path) && dirname(path) !== folder);
1010
+ return unique.filter((path) => !unique.some((other) => other !== path && within(path, other)));
1011
+ }
1012
+ WorkspaceUtil.movable = movable;
1013
+ function movedTo(path, moved, folder) {
1014
+ const from = moved.find((source) => within(path, source));
1015
+ return from === undefined ? undefined : join(folder, basename(from)) + path.slice(from.length);
1016
+ }
1017
+ WorkspaceUtil.movedTo = movedTo;
1018
+ function shellQuote(path, windows = false) {
1019
+ if (/^[\w@%+=:,./-]+$/.test(path)) {
1020
+ return path;
1021
+ }
1022
+ return windows ? `"${path.replace(/"/g, '""')}"` : `'${path.replace(/'/g, "'\\''")}'`;
1023
+ }
1024
+ WorkspaceUtil.shellQuote = shellQuote;
1025
+ function fileManagerLabel(platform) {
1026
+ return platform === "darwin" ? "revealInFinder" : platform === "win32" ? "revealInFileExplorer" : "openContainingFolder";
1027
+ }
1028
+ WorkspaceUtil.fileManagerLabel = fileManagerLabel;
934
1029
  function groupMatches(matches) {
935
1030
  const files = new Map;
936
1031
  for (const match of matches) {
@@ -1024,6 +1119,16 @@ var WorkspaceUtil;
1024
1119
  return parsed.toString();
1025
1120
  }
1026
1121
  WorkspaceUtil.withPort = withPort;
1122
+ function unforward(url, asked, shown) {
1123
+ try {
1124
+ const from = new URL(shown ?? asked).origin;
1125
+ const to = new URL(asked).origin;
1126
+ return from !== to && url.startsWith(`${from}/`) ? `${to}${url.slice(from.length)}` : url;
1127
+ } catch {
1128
+ return url;
1129
+ }
1130
+ }
1131
+ WorkspaceUtil.unforward = unforward;
1027
1132
  function toUrl(input) {
1028
1133
  const text = input.trim();
1029
1134
  if (!text) {
@@ -1057,7 +1162,7 @@ var WorkspaceUtil;
1057
1162
  WorkspaceUtil.size = size;
1058
1163
  })(WorkspaceUtil ||= {});
1059
1164
 
1060
- // web-src/browser.tsx
1165
+ // web-src/browser-common.tsx
1061
1166
  var RECENT_KEY = "recent";
1062
1167
  var MAX_RECENT = 12;
1063
1168
  var Recent;
@@ -1117,7 +1222,37 @@ function parts(url) {
1117
1222
  return { host: url, rest: "" };
1118
1223
  }
1119
1224
  }
1120
- function AddressBar({ value, loading, onOpen }) {
1225
+ function AddressIcon({ value, loading, favicon }) {
1226
+ const [broken, setBroken] = React.useState();
1227
+ if (loading) {
1228
+ return /* @__PURE__ */ React.createElement("span", {
1229
+ className: "taw-spin"
1230
+ }, /* @__PURE__ */ React.createElement(Glyph, {
1231
+ name: "LoaderCircle",
1232
+ size: 14
1233
+ }));
1234
+ }
1235
+ if (favicon && broken !== favicon) {
1236
+ return /* @__PURE__ */ React.createElement("img", {
1237
+ className: "taw-address-favicon",
1238
+ src: favicon,
1239
+ alt: "",
1240
+ referrerPolicy: "no-referrer",
1241
+ onError: () => setBroken(favicon)
1242
+ });
1243
+ }
1244
+ return /* @__PURE__ */ React.createElement(Glyph, {
1245
+ name: value ? "Globe" : "Search",
1246
+ size: 14
1247
+ });
1248
+ }
1249
+ function AddressBar({
1250
+ value,
1251
+ title,
1252
+ loading,
1253
+ favicon,
1254
+ onOpen
1255
+ }) {
1121
1256
  const [text, setText] = React.useState(value);
1122
1257
  React.useEffect(() => setText(value), [value]);
1123
1258
  return /* @__PURE__ */ React.createElement("form", {
@@ -1132,18 +1267,15 @@ function AddressBar({ value, loading, onOpen }) {
1132
1267
  }
1133
1268
  }, /* @__PURE__ */ React.createElement("span", {
1134
1269
  className: "taw-address-icon"
1135
- }, loading ? /* @__PURE__ */ React.createElement("span", {
1136
- className: "taw-spin"
1137
- }, /* @__PURE__ */ React.createElement(Glyph, {
1138
- name: "LoaderCircle",
1139
- size: 14
1140
- })) : /* @__PURE__ */ React.createElement(Glyph, {
1141
- name: value ? "Globe" : "Search",
1142
- size: 14
1270
+ }, /* @__PURE__ */ React.createElement(AddressIcon, {
1271
+ value,
1272
+ loading,
1273
+ favicon
1143
1274
  })), /* @__PURE__ */ React.createElement("input", {
1144
1275
  value: text,
1145
1276
  placeholder: t("address"),
1146
1277
  "aria-label": t("address"),
1278
+ title: title || undefined,
1147
1279
  spellCheck: false,
1148
1280
  autoComplete: "off",
1149
1281
  onFocus: (event) => event.target.select(),
@@ -1164,7 +1296,50 @@ function AddressBar({ value, loading, onOpen }) {
1164
1296
  size: 14
1165
1297
  })) : undefined);
1166
1298
  }
1167
- function Home({ onOpen }) {
1299
+ function BrowserBar(props) {
1300
+ const { url, loading, onStop } = props;
1301
+ return /* @__PURE__ */ React.createElement("header", {
1302
+ className: "taw-browser-bar"
1303
+ }, /* @__PURE__ */ React.createElement(Action, {
1304
+ icon: "ArrowLeft",
1305
+ label: t("back"),
1306
+ disabled: !props.canGoBack,
1307
+ onClick: props.onBack
1308
+ }), /* @__PURE__ */ React.createElement(Action, {
1309
+ icon: "ArrowRight",
1310
+ label: t("forward"),
1311
+ disabled: !props.canGoForward,
1312
+ onClick: props.onForward
1313
+ }), loading && onStop ? /* @__PURE__ */ React.createElement(Action, {
1314
+ icon: "X",
1315
+ label: t("stop"),
1316
+ onClick: onStop
1317
+ }) : /* @__PURE__ */ React.createElement(Action, {
1318
+ icon: "RefreshCw",
1319
+ label: t("refresh"),
1320
+ disabled: !url,
1321
+ onClick: props.onReload
1322
+ }), /* @__PURE__ */ React.createElement(AddressBar, {
1323
+ value: url,
1324
+ title: props.title,
1325
+ loading,
1326
+ favicon: props.favicon,
1327
+ onOpen: props.onOpen
1328
+ }), props.badge, /* @__PURE__ */ React.createElement(Action, {
1329
+ icon: "House",
1330
+ label: t("home"),
1331
+ disabled: !url,
1332
+ onClick: props.onHome
1333
+ }), /* @__PURE__ */ React.createElement(Action, {
1334
+ icon: "ExternalLink",
1335
+ label: props.outsideLabel,
1336
+ disabled: !props.onOpenOutside,
1337
+ onClick: () => props.onOpenOutside?.()
1338
+ }), loading ? /* @__PURE__ */ React.createElement("span", {
1339
+ className: "taw-browser-loading"
1340
+ }) : undefined);
1341
+ }
1342
+ function Home({ onOpen, foot, extra }) {
1168
1343
  const recent = React.useSyncExternalStore(Recent.subscribe, Recent.all);
1169
1344
  return /* @__PURE__ */ React.createElement("div", {
1170
1345
  className: `taw-browser-home ${recent.length === 0 ? "taw-browser-blank" : ""}`
@@ -1186,7 +1361,7 @@ function Home({ onOpen }) {
1186
1361
  key: address,
1187
1362
  className: "taw-browser-chip",
1188
1363
  onClick: () => onOpen(`http://${address}`)
1189
- }, address))) : undefined), recent.length > 0 ? /* @__PURE__ */ React.createElement("section", {
1364
+ }, address))) : undefined, extra), recent.length > 0 ? /* @__PURE__ */ React.createElement("section", {
1190
1365
  className: "taw-browser-recent"
1191
1366
  }, /* @__PURE__ */ React.createElement("h3", {
1192
1367
  className: "taw-browser-heading"
@@ -1216,9 +1391,9 @@ function Home({ onOpen }) {
1216
1391
  name: "X",
1217
1392
  size: 13
1218
1393
  })));
1219
- })) : undefined, /* @__PURE__ */ React.createElement("p", {
1394
+ })) : undefined, foot ? /* @__PURE__ */ React.createElement("p", {
1220
1395
  className: "taw-browser-foot"
1221
- }, t("frameHint")));
1396
+ }, foot) : undefined);
1222
1397
  }
1223
1398
  var ShowPage = new Channel;
1224
1399
  function useForwarded(url, cwd) {
@@ -1240,7 +1415,909 @@ function useForwarded(url, cwd) {
1240
1415
  }
1241
1416
  return forwarded?.url === url ? forwarded.to : undefined;
1242
1417
  }
1243
- function BrowserView() {
1418
+ function openOutside(url) {
1419
+ window.open(url, "_blank", "noopener,noreferrer");
1420
+ }
1421
+
1422
+ // web-src/util/browser-snapshot.ts
1423
+ var ACTIONABLE = new Set([
1424
+ "button",
1425
+ "checkbox",
1426
+ "combobox",
1427
+ "link",
1428
+ "listbox",
1429
+ "menuitem",
1430
+ "menuitemcheckbox",
1431
+ "menuitemradio",
1432
+ "option",
1433
+ "radio",
1434
+ "searchbox",
1435
+ "slider",
1436
+ "spinbutton",
1437
+ "switch",
1438
+ "tab",
1439
+ "textbox",
1440
+ "treeitem"
1441
+ ]);
1442
+ var SKIPPED = new Set(["none", "presentation", "InlineTextBox", "LineBreak"]);
1443
+ var TRANSPARENT = new Set([
1444
+ "generic",
1445
+ "group",
1446
+ "paragraph",
1447
+ "Section",
1448
+ "LayoutTable",
1449
+ "LayoutTableRow",
1450
+ "LayoutTableCell",
1451
+ "LabelText",
1452
+ "RootWebArea",
1453
+ "WebArea"
1454
+ ]);
1455
+ var STATES = ["focused", "checked", "selected", "pressed", "disabled", "required", "readonly", "invalid"];
1456
+ var MAX_NAME = 120;
1457
+ var MODIFIERS = { alt: 1, option: 1, control: 2, ctrl: 2, meta: 4, cmd: 4, command: 4, shift: 8 };
1458
+ var NAMED = {
1459
+ Enter: [13, "\r"],
1460
+ Tab: [9],
1461
+ Escape: [27],
1462
+ Backspace: [8],
1463
+ Delete: [46],
1464
+ ArrowUp: [38],
1465
+ ArrowDown: [40],
1466
+ ArrowLeft: [37],
1467
+ ArrowRight: [39],
1468
+ Home: [36],
1469
+ End: [35],
1470
+ PageUp: [33],
1471
+ PageDown: [34],
1472
+ Space: [32, " "]
1473
+ };
1474
+ var BrowserSnapshot;
1475
+ ((BrowserSnapshot) => {
1476
+ function text(value, max = MAX_NAME) {
1477
+ const line = String(value ?? "").replace(/\s+/g, " ").trim();
1478
+ return line.length > max ? `${line.slice(0, max - 1)}…` : line;
1479
+ }
1480
+ function property(node, name) {
1481
+ return node.properties?.find((item) => item.name === name)?.value?.value;
1482
+ }
1483
+ function render(nodes, maxLines = 800) {
1484
+ const byId = new Map(nodes.map((node) => [node.nodeId, node]));
1485
+ const lines = [];
1486
+ let more = 0;
1487
+ const add = (line) => {
1488
+ if (lines.length < maxLines) {
1489
+ lines.push(line);
1490
+ } else {
1491
+ more++;
1492
+ }
1493
+ };
1494
+ const visit = (node, depth, parentName, inActionable = false) => {
1495
+ const role = String(node.role?.value ?? "");
1496
+ const name = text(node.name?.value);
1497
+ const children = (node.childIds ?? []).map((id) => byId.get(id)).filter((child) => child !== undefined);
1498
+ const pass = (nextDepth, nextName, nextInActionable = inActionable) => {
1499
+ for (const child of children) {
1500
+ visit(child, nextDepth, nextName, nextInActionable);
1501
+ }
1502
+ };
1503
+ if (node.ignored || SKIPPED.has(role)) {
1504
+ pass(depth, parentName);
1505
+ return;
1506
+ }
1507
+ if (role === "StaticText") {
1508
+ if (name && !parentName.includes(name)) {
1509
+ add(`${" ".repeat(depth)}${JSON.stringify(name)}`);
1510
+ }
1511
+ return;
1512
+ }
1513
+ const actionable = (ACTIONABLE.has(role) || property(node, "editable") !== undefined && !inActionable) && node.backendDOMNodeId !== undefined;
1514
+ if (!actionable && TRANSPARENT.has(role) && !name) {
1515
+ pass(depth, parentName);
1516
+ return;
1517
+ }
1518
+ let line = `${" ".repeat(depth)}${actionable ? `[${node.backendDOMNodeId}] ` : ""}${role}${name ? ` ${JSON.stringify(name)}` : ""}`;
1519
+ const level = property(node, "level");
1520
+ if (level !== undefined) {
1521
+ line += ` level=${level}`;
1522
+ }
1523
+ const states = STATES.filter((state) => {
1524
+ const value2 = property(node, state);
1525
+ return value2 === true || value2 === "true" || value2 === "mixed";
1526
+ }).map((state) => property(node, state) === "mixed" ? `${state}=mixed` : state);
1527
+ const expanded = property(node, "expanded");
1528
+ if (expanded !== undefined) {
1529
+ states.push(expanded ? "expanded" : "collapsed");
1530
+ }
1531
+ if (states.length > 0) {
1532
+ line += ` (${states.join(", ")})`;
1533
+ }
1534
+ const value = text(node.value?.value);
1535
+ if (value && value !== name) {
1536
+ line += ` value=${JSON.stringify(value)}`;
1537
+ }
1538
+ const description = text(node.description?.value, 80);
1539
+ if (description && description !== name) {
1540
+ line += ` description=${JSON.stringify(description)}`;
1541
+ }
1542
+ add(line);
1543
+ pass(depth + 1, name, inActionable || actionable);
1544
+ };
1545
+ for (const root of nodes.filter((node) => !node.parentId || !byId.has(node.parentId))) {
1546
+ visit(root, 0, "");
1547
+ }
1548
+ if (more > 0) {
1549
+ lines.push(`… ${more} more lines: scroll, or evaluate to read a part of the page.`);
1550
+ }
1551
+ return lines.length > 0 ? lines.join(`
1552
+ `) : "(the page shows nothing to read yet)";
1553
+ }
1554
+ BrowserSnapshot.render = render;
1555
+ function center(quad) {
1556
+ const xs = [quad[0], quad[2], quad[4], quad[6]];
1557
+ const ys = [quad[1], quad[3], quad[5], quad[7]];
1558
+ return { x: (Math.min(...xs) + Math.max(...xs)) / 2, y: (Math.min(...ys) + Math.max(...ys)) / 2 };
1559
+ }
1560
+ BrowserSnapshot.center = center;
1561
+ function key(input) {
1562
+ const parts2 = input.split("+");
1563
+ const name = input.endsWith("++") || input === "+" ? "+" : parts2.pop();
1564
+ if (!name) {
1565
+ return;
1566
+ }
1567
+ let modifiers = 0;
1568
+ for (const part of input === "+" ? [] : parts2.filter(Boolean)) {
1569
+ const bit = MODIFIERS[part.toLowerCase()];
1570
+ if (bit === undefined) {
1571
+ return;
1572
+ }
1573
+ modifiers |= bit;
1574
+ }
1575
+ const shortcut = (modifiers & (2 | 4)) !== 0;
1576
+ const named = Object.keys(NAMED).find((candidate) => candidate.toLowerCase() === name.toLowerCase());
1577
+ if (named) {
1578
+ const [code, typed] = NAMED[named];
1579
+ return {
1580
+ key: named === "Space" ? " " : named,
1581
+ code: named,
1582
+ windowsVirtualKeyCode: code,
1583
+ modifiers,
1584
+ ...typed && !shortcut ? { text: typed } : {}
1585
+ };
1586
+ }
1587
+ const fn = /^F([1-9]|1[0-2])$/i.exec(name);
1588
+ if (fn) {
1589
+ return { key: `F${fn[1]}`, code: `F${fn[1]}`, windowsVirtualKeyCode: 111 + Number(fn[1]), modifiers };
1590
+ }
1591
+ if ([...name].length !== 1) {
1592
+ return;
1593
+ }
1594
+ const shifted = (modifiers & 8) !== 0;
1595
+ const letter = /^[a-z]$/i.test(name);
1596
+ const digit = /^[0-9]$/.test(name);
1597
+ const key2 = letter ? shifted ? name.toUpperCase() : name.toLowerCase() : name;
1598
+ return {
1599
+ key: key2,
1600
+ code: letter ? `Key${name.toUpperCase()}` : digit ? `Digit${name}` : "",
1601
+ windowsVirtualKeyCode: letter ? name.toUpperCase().charCodeAt(0) : digit ? name.charCodeAt(0) : 0,
1602
+ modifiers,
1603
+ ...shortcut ? {} : { text: key2 }
1604
+ };
1605
+ }
1606
+ BrowserSnapshot.key = key;
1607
+ })(BrowserSnapshot ||= {});
1608
+
1609
+ // web-src/browser-agent.ts
1610
+ var ACTIONS = ["navigate", "back", "forward", "reload", "snapshot", "click", "type", "press", "scroll", "screenshot", "evaluate", "wait", "cdp"];
1611
+ var MAX_OUTPUT = 20000;
1612
+ var TYPE_INTO = `function (text) {
1613
+ this.focus();
1614
+ if (typeof this.select === 'function') {
1615
+ this.select();
1616
+ } else {
1617
+ const range = document.createRange();
1618
+ range.selectNodeContents(this);
1619
+ getSelection().removeAllRanges();
1620
+ getSelection().addRange(range);
1621
+ }
1622
+ const typed = text ? document.execCommand('insertText', false, text) : document.execCommand('delete');
1623
+ if (!typed && 'value' in this) {
1624
+ const setter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this), 'value')?.set;
1625
+ setter ? setter.call(this, text) : (this.value = text);
1626
+ this.dispatchEvent(new Event('input', { bubbles: true }));
1627
+ this.dispatchEvent(new Event('change', { bubbles: true }));
1628
+ }
1629
+ }`;
1630
+ var MAX_WAIT_MS = 30000;
1631
+ var KEY_FOCUS_MS = 50;
1632
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1633
+ async function until(ready, ms) {
1634
+ const end = Date.now() + ms;
1635
+ for (;; ) {
1636
+ const value = ready();
1637
+ if (value !== undefined || Date.now() >= end) {
1638
+ return value;
1639
+ }
1640
+ await sleep(50);
1641
+ }
1642
+ }
1643
+ function clip(text) {
1644
+ return text.length > MAX_OUTPUT ? `${text.slice(0, MAX_OUTPUT)}
1645
+ … cut at ${MAX_OUTPUT} characters` : text;
1646
+ }
1647
+ var AgentBrowser;
1648
+ ((AgentBrowser) => {
1649
+ let handle;
1650
+ let snapshot;
1651
+ function attach(next) {
1652
+ handle = next;
1653
+ return () => {
1654
+ if (handle === next) {
1655
+ handle = undefined;
1656
+ }
1657
+ };
1658
+ }
1659
+ AgentBrowser.attach = attach;
1660
+ AgentBrowser.TOOL = {
1661
+ name: "browser",
1662
+ description: [
1663
+ "Works the browser in Ta's workbench, on the user's machine: the user sees it, and it keeps the user's sign-ins to sites.",
1664
+ "Actions:",
1665
+ "- navigate {url}: open a page (http or https); back, forward, reload",
1666
+ "- snapshot: the page as an accessibility tree, one element a line; what one acts on starts with its ref in brackets, [12]",
1667
+ "- click {ref} or {x, y}: click it; x and y are CSS pixels of the screenshot",
1668
+ "- type {ref, text, submit?}: replace the text of a field with text; submit presses Enter after",
1669
+ '- press {key}: a key or a shortcut: "Enter", "Escape", "Tab", "ArrowDown", "a", "Control+A", "Meta+Shift+Z"',
1670
+ '- scroll {direction: "down" | "up", amount?}: by amount pixels, a screen by default; or {ref}: until it is shown',
1671
+ "- screenshot: what is shown, as a data URL of a JPEG (in codemode, give it to image() to look at it)",
1672
+ "- evaluate {expression}: run JavaScript in the page; the JSON of its value, awaited",
1673
+ "- wait {text?, ms?}: until the page shows text, or for ms milliseconds; at most 30000",
1674
+ "- cdp {method, params?}: a command of the Chrome DevTools Protocol to the page (Accessibility, CSS, DOM, DOMSnapshot, Emulation, Input, Log, Overlay, Page, Runtime)",
1675
+ "After an action it says the title and address of the page; refs change when the page does, so take a snapshot again before acting on a new page."
1676
+ ].join(`
1677
+ `),
1678
+ parameters: {
1679
+ type: "object",
1680
+ properties: {
1681
+ action: { type: "string", enum: [...ACTIONS] },
1682
+ url: { type: "string" },
1683
+ ref: { type: "integer", description: "The number in brackets in the last snapshot." },
1684
+ x: { type: "number" },
1685
+ y: { type: "number" },
1686
+ text: { type: "string" },
1687
+ submit: { type: "boolean" },
1688
+ key: { type: "string" },
1689
+ direction: { type: "string", enum: ["down", "up"] },
1690
+ amount: { type: "number" },
1691
+ expression: { type: "string" },
1692
+ ms: { type: "number" },
1693
+ method: { type: "string" },
1694
+ params: { type: "object" }
1695
+ },
1696
+ required: ["action"]
1697
+ },
1698
+ execute: (_toolCallId, params) => run(params)
1699
+ };
1700
+ async function run(params) {
1701
+ const action = params.action;
1702
+ if (!ACTIONS.includes(action)) {
1703
+ throw new Error(`Unknown action ${JSON.stringify(params.action)}: use one of ${ACTIONS.join(", ")}.`);
1704
+ }
1705
+ const browser = await open();
1706
+ browser.drive();
1707
+ if (action === "navigate") {
1708
+ const url = WorkspaceUtil.toUrl(String(params.url ?? ""));
1709
+ if (!url || !/^https?:\/\//i.test(url)) {
1710
+ throw new Error("navigate opens pages of the web: give an http or https url.");
1711
+ }
1712
+ const before = browser.view()?.getURL();
1713
+ browser.go(url);
1714
+ await settle(browser, before);
1715
+ return status(page(browser));
1716
+ }
1717
+ if (action === "wait" && !params.text) {
1718
+ await sleep(Math.min(MAX_WAIT_MS, Number(params.ms) > 0 ? Number(params.ms) : 1000));
1719
+ const shown = browser.view();
1720
+ return shown ? status(shown) : "No page is open.";
1721
+ }
1722
+ const view = page(browser);
1723
+ const send = (method, args = {}) => command(view, method, args);
1724
+ switch (action) {
1725
+ case "back":
1726
+ case "forward":
1727
+ case "reload": {
1728
+ const before = view.getURL();
1729
+ if (action === "back" && !view.canGoBack()) {
1730
+ throw new Error("There is no page to go back to.");
1731
+ }
1732
+ if (action === "forward" && !view.canGoForward()) {
1733
+ throw new Error("There is no page to go forward to.");
1734
+ }
1735
+ if (action === "back") {
1736
+ view.goBack();
1737
+ } else if (action === "forward") {
1738
+ view.goForward();
1739
+ } else {
1740
+ view.reload();
1741
+ }
1742
+ await settle(browser, action === "reload" ? undefined : before);
1743
+ return status(view);
1744
+ }
1745
+ case "snapshot": {
1746
+ const document2 = await documentOf(send);
1747
+ await send("Accessibility.enable");
1748
+ let text = "";
1749
+ for (let attempt = 0;attempt < 10; attempt++) {
1750
+ const { nodes } = await send("Accessibility.getFullAXTree");
1751
+ text = BrowserSnapshot.render(nodes);
1752
+ if (text.includes(`
1753
+ `) || !(await evaluate(send, "Boolean(document.body && document.body.childElementCount)").catch(() => "false")).includes("true")) {
1754
+ break;
1755
+ }
1756
+ await sleep(200);
1757
+ }
1758
+ snapshot = { document: document2, refs: new Set([...text.matchAll(/^\s*\[(\d+)\]/gm)].map((match) => Number(match[1]))) };
1759
+ return clip(`${status(view)}
1760
+
1761
+ ${text}`);
1762
+ }
1763
+ case "click": {
1764
+ const point = params.ref === undefined ? { x: Number(params.x), y: Number(params.y) } : await locate(send, await ref(send, params.ref));
1765
+ if (!Number.isFinite(point.x) || !Number.isFinite(point.y)) {
1766
+ throw new Error("click needs a ref, or x and y.");
1767
+ }
1768
+ const before = view.getURL();
1769
+ const focused = document.activeElement;
1770
+ await send("Input.dispatchMouseEvent", { type: "mouseMoved", ...point });
1771
+ await send("Input.dispatchMouseEvent", { type: "mousePressed", button: "left", clickCount: 1, ...point });
1772
+ await send("Input.dispatchMouseEvent", { type: "mouseReleased", button: "left", clickCount: 1, ...point });
1773
+ if (focused instanceof HTMLElement && focused !== view && document.activeElement === view) {
1774
+ focused.focus({ preventScroll: true });
1775
+ }
1776
+ await settle(browser, before, 300);
1777
+ return status(view);
1778
+ }
1779
+ case "type": {
1780
+ const backendNodeId = await ref(send, params.ref);
1781
+ await send("DOM.focus", { backendNodeId }).catch((error) => stale(error, backendNodeId));
1782
+ const { object } = await send("DOM.resolveNode", { backendNodeId });
1783
+ await send("Runtime.callFunctionOn", {
1784
+ objectId: object.objectId,
1785
+ functionDeclaration: TYPE_INTO,
1786
+ arguments: [{ value: String(params.text ?? "") }],
1787
+ userGesture: true
1788
+ });
1789
+ const before = view.getURL();
1790
+ if (params.submit === true) {
1791
+ await press(view, send, "Enter");
1792
+ }
1793
+ await settle(browser, before, 300);
1794
+ return status(view);
1795
+ }
1796
+ case "press": {
1797
+ const before = view.getURL();
1798
+ await press(view, send, String(params.key ?? ""));
1799
+ await settle(browser, before, 300);
1800
+ return status(view);
1801
+ }
1802
+ case "scroll": {
1803
+ if (params.ref !== undefined) {
1804
+ const backendNodeId = await ref(send, params.ref);
1805
+ await send("DOM.scrollIntoViewIfNeeded", { backendNodeId }).catch((error) => stale(error, backendNodeId));
1806
+ } else {
1807
+ const { cssLayoutViewport: viewport } = await send("Page.getLayoutMetrics");
1808
+ const amount = Number(params.amount) > 0 ? Number(params.amount) : Math.round(viewport.clientHeight * 0.8);
1809
+ await send("Input.dispatchMouseEvent", {
1810
+ type: "mouseWheel",
1811
+ x: viewport.clientWidth / 2,
1812
+ y: viewport.clientHeight / 2,
1813
+ deltaX: 0,
1814
+ deltaY: params.direction === "up" ? -amount : amount
1815
+ });
1816
+ await sleep(250);
1817
+ }
1818
+ const where = await evaluate(send, "[Math.round(scrollY), document.documentElement.scrollHeight, innerHeight]");
1819
+ const [top, height, shown] = JSON.parse(where);
1820
+ return `${status(view)}
1821
+ Scrolled to ${top} of ${height} pixels, ${shown} shown.`;
1822
+ }
1823
+ case "screenshot": {
1824
+ const { cssVisualViewport: viewport } = await send("Page.getLayoutMetrics");
1825
+ const ratio = Number(await evaluate(send, "devicePixelRatio")) || 1;
1826
+ const { data } = await send("Page.captureScreenshot", {
1827
+ format: "jpeg",
1828
+ quality: 70,
1829
+ clip: { x: viewport.pageX, y: viewport.pageY, width: viewport.clientWidth, height: viewport.clientHeight, scale: 1 / ratio }
1830
+ });
1831
+ return `data:image/jpeg;base64,${data}`;
1832
+ }
1833
+ case "evaluate":
1834
+ return clip(await evaluate(send, String(params.expression ?? "")));
1835
+ case "wait": {
1836
+ const ms = Math.min(MAX_WAIT_MS, Number(params.ms) > 0 ? Number(params.ms) : 1e4);
1837
+ const probe = `Boolean(document.body && document.body.innerText.includes(${JSON.stringify(params.text)}))`;
1838
+ const end = Date.now() + ms;
1839
+ while (Date.now() < end) {
1840
+ if (await evaluate(send, probe).catch(() => "false") === "true") {
1841
+ return status(view);
1842
+ }
1843
+ await sleep(250);
1844
+ }
1845
+ throw new Error(`The page did not show ${JSON.stringify(params.text)} in ${ms} ms.`);
1846
+ }
1847
+ case "cdp": {
1848
+ const method = String(params.method ?? "");
1849
+ const args = params.params && typeof params.params === "object" ? params.params : {};
1850
+ return clip(JSON.stringify(await send(method, args) ?? null));
1851
+ }
1852
+ }
1853
+ throw new Error(`Unknown action ${action}.`);
1854
+ }
1855
+ async function open() {
1856
+ if (!pi.ui.debugWebview) {
1857
+ throw new Error("The browser of Ta can be worked in Ta Desktop only.");
1858
+ }
1859
+ if (!handle?.shown()) {
1860
+ pi.ui.showView(`${PACKAGE}/browser`);
1861
+ }
1862
+ const opened = await until(() => handle, 5000);
1863
+ if (!opened) {
1864
+ throw new Error("The browser did not open.");
1865
+ }
1866
+ return opened;
1867
+ }
1868
+ function page(browser) {
1869
+ const view = browser.view();
1870
+ if (!view) {
1871
+ throw new Error("No page is open: navigate to one first.");
1872
+ }
1873
+ return view;
1874
+ }
1875
+ async function command(view, method, args) {
1876
+ const debug = pi.ui.debugWebview;
1877
+ if (!debug) {
1878
+ throw new Error("The browser of Ta can be worked in Ta Desktop only.");
1879
+ }
1880
+ return debug(view.getWebContentsId(), method, args);
1881
+ }
1882
+ async function settle(browser, before, grace = 150) {
1883
+ await sleep(grace);
1884
+ const view = await until(() => browser.view(), 15000);
1885
+ if (!view) {
1886
+ return;
1887
+ }
1888
+ const end = Date.now() + 15000;
1889
+ while (view.isLoading() && Date.now() < end) {
1890
+ await sleep(100);
1891
+ }
1892
+ if (before !== undefined && view.getURL() === before) {
1893
+ return;
1894
+ }
1895
+ while (Date.now() < end) {
1896
+ const state = await command(view, "Runtime.evaluate", { expression: "document.readyState", returnByValue: true }).catch(() => {
1897
+ return;
1898
+ });
1899
+ if (state?.result?.value !== "loading") {
1900
+ return;
1901
+ }
1902
+ await sleep(100);
1903
+ }
1904
+ }
1905
+ function status(view) {
1906
+ const title = view.getTitle();
1907
+ const url = view.getURL();
1908
+ return title && title !== url ? `Page: ${title} — ${url}` : `Page: ${url}`;
1909
+ }
1910
+ async function documentOf(send) {
1911
+ const { frameTree } = await send("Page.getFrameTree");
1912
+ return frameTree.frame.loaderId;
1913
+ }
1914
+ async function ref(send, value) {
1915
+ const id = Number(value);
1916
+ if (!Number.isInteger(id) || id <= 0) {
1917
+ throw new Error("ref is the number in brackets of an element in the last snapshot.");
1918
+ }
1919
+ if (!snapshot || snapshot.document !== await documentOf(send)) {
1920
+ throw new Error("The page changed since the last snapshot: take a snapshot, then use its refs.");
1921
+ }
1922
+ if (!snapshot.refs.has(id)) {
1923
+ throw new Error(`[${id}] is not a ref of the last snapshot.`);
1924
+ }
1925
+ return id;
1926
+ }
1927
+ function stale(error, id) {
1928
+ const message = error instanceof Error ? error.message : String(error);
1929
+ throw new Error(/node/i.test(message) ? `The element [${id}] is not on the page any more: take a snapshot again.` : message);
1930
+ }
1931
+ async function locate(send, backendNodeId) {
1932
+ await send("DOM.scrollIntoViewIfNeeded", { backendNodeId }).catch((error) => stale(error, backendNodeId));
1933
+ const { quads } = await send("DOM.getContentQuads", { backendNodeId }).catch((error) => stale(error, backendNodeId));
1934
+ if (!quads?.length) {
1935
+ throw new Error(`The element [${backendNodeId}] is not shown: scroll to it, or take a snapshot again.`);
1936
+ }
1937
+ return BrowserSnapshot.center(quads[0]);
1938
+ }
1939
+ async function press(view, send, name) {
1940
+ const key = BrowserSnapshot.key(name);
1941
+ if (!key) {
1942
+ throw new Error(`${JSON.stringify(name)} is not a key: use names such as Enter, Tab, Escape, ArrowDown, a, Control+A.`);
1943
+ }
1944
+ const { text, ...event } = key;
1945
+ const focused = document.activeElement;
1946
+ if (focused !== view) {
1947
+ view.focus();
1948
+ await sleep(KEY_FOCUS_MS);
1949
+ }
1950
+ try {
1951
+ await send("Input.dispatchKeyEvent", { type: text ? "keyDown" : "rawKeyDown", ...event, ...text ? { text, unmodifiedText: text } : {} });
1952
+ await send("Input.dispatchKeyEvent", { type: "keyUp", ...event });
1953
+ } finally {
1954
+ if (focused instanceof HTMLElement && focused !== view) {
1955
+ await sleep(KEY_FOCUS_MS);
1956
+ focused.focus({ preventScroll: true });
1957
+ }
1958
+ }
1959
+ }
1960
+ async function evaluate(send, expression) {
1961
+ const { result, exceptionDetails } = await send("Runtime.evaluate", { expression, returnByValue: true, awaitPromise: true, userGesture: true });
1962
+ if (exceptionDetails) {
1963
+ throw new Error(exceptionDetails.exception?.description ?? exceptionDetails.text ?? "The expression threw.");
1964
+ }
1965
+ if (result?.type === "undefined") {
1966
+ return "undefined";
1967
+ }
1968
+ return result && "value" in result ? JSON.stringify(result.value) ?? String(result.value) : result?.description ?? "undefined";
1969
+ }
1970
+ })(AgentBrowser ||= {});
1971
+
1972
+ // web-src/browser-import.tsx
1973
+ function ImportDialog({ data, onClose, onChanged }) {
1974
+ const [profiles, setProfiles] = React.useState();
1975
+ const [chosen, setChosen] = React.useState();
1976
+ const [step, setStep] = React.useState({ kind: "pick" });
1977
+ const [error, setError] = React.useState();
1978
+ React.useEffect(() => {
1979
+ data.profiles().then((list) => {
1980
+ setProfiles(list);
1981
+ setChosen(list[0]?.id);
1982
+ }, (failure) => setError(Host.message(failure)));
1983
+ }, [data]);
1984
+ const run = async (action) => {
1985
+ setError(undefined);
1986
+ setStep({ kind: "working" });
1987
+ try {
1988
+ setStep(await action() ?? { kind: "pick" });
1989
+ } catch (failure) {
1990
+ setError(Host.message(failure));
1991
+ setStep({ kind: "pick" });
1992
+ }
1993
+ };
1994
+ const take = () => run(async () => {
1995
+ const report = chosen ? await data.import(chosen) : undefined;
1996
+ if (report) {
1997
+ onChanged();
1998
+ }
1999
+ return report && { kind: "done", report };
2000
+ });
2001
+ const clear = async () => {
2002
+ if (await pi.ui.confirm(t("clearBrowserData"), t("clearBrowserDataDetail"), { confirmLabel: t("clear"), danger: true })) {
2003
+ await run(async () => {
2004
+ await data.clear();
2005
+ onChanged();
2006
+ return { kind: "cleared" };
2007
+ });
2008
+ }
2009
+ };
2010
+ const working = step.kind === "working";
2011
+ let body;
2012
+ if (step.kind === "done" || step.kind === "cleared") {
2013
+ const report = step.kind === "done" ? step.report : undefined;
2014
+ body = /* @__PURE__ */ React.createElement("div", {
2015
+ className: "taw-import-result"
2016
+ }, /* @__PURE__ */ React.createElement("span", {
2017
+ className: "taw-browser-mark"
2018
+ }, /* @__PURE__ */ React.createElement(Glyph, {
2019
+ name: "Check",
2020
+ size: 22
2021
+ })), /* @__PURE__ */ React.createElement("p", {
2022
+ className: "taw-browser-title"
2023
+ }, report ? t("imported", { count: report.imported }) : t("cleared")), report && report.skipped > 0 ? /* @__PURE__ */ React.createElement("p", {
2024
+ className: "taw-browser-sub"
2025
+ }, t("importSkipped", { count: report.skipped })) : undefined, report && report.appBound > 0 ? /* @__PURE__ */ React.createElement("p", {
2026
+ className: "taw-browser-sub"
2027
+ }, t("importAppBound", { count: report.appBound })) : undefined, /* @__PURE__ */ React.createElement("div", {
2028
+ className: "taw-import-actions"
2029
+ }, /* @__PURE__ */ React.createElement("button", {
2030
+ type: "button",
2031
+ className: "taw-button taw-primary",
2032
+ onClick: onClose
2033
+ }, t("done"))));
2034
+ } else {
2035
+ body = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", {
2036
+ className: "taw-import-hint"
2037
+ }, t("importHint")), profiles === undefined && !error ? /* @__PURE__ */ React.createElement("p", {
2038
+ className: "taw-import-hint"
2039
+ }, t("loading")) : undefined, profiles?.length === 0 ? /* @__PURE__ */ React.createElement("p", {
2040
+ className: "taw-import-hint"
2041
+ }, t("noProfiles")) : undefined, profiles && profiles.length > 0 ? /* @__PURE__ */ React.createElement("div", {
2042
+ className: "taw-import-profiles",
2043
+ role: "radiogroup",
2044
+ "aria-label": t("importFrom")
2045
+ }, profiles.map((profile) => /* @__PURE__ */ React.createElement("label", {
2046
+ key: profile.id,
2047
+ className: `taw-import-profile ${chosen === profile.id ? "taw-on" : ""}`
2048
+ }, /* @__PURE__ */ React.createElement("input", {
2049
+ type: "radio",
2050
+ name: "taw-import-profile",
2051
+ checked: chosen === profile.id,
2052
+ onChange: () => setChosen(profile.id)
2053
+ }), /* @__PURE__ */ React.createElement("span", {
2054
+ className: "taw-browser-letter"
2055
+ }, profile.browser.replace(/^(Google|Microsoft) /, "").charAt(0)), /* @__PURE__ */ React.createElement("span", {
2056
+ className: "taw-import-browser"
2057
+ }, profile.browser), /* @__PURE__ */ React.createElement("span", {
2058
+ className: "taw-import-name"
2059
+ }, profile.name)))) : undefined, error ? /* @__PURE__ */ React.createElement("p", {
2060
+ className: "taw-import-error"
2061
+ }, error) : undefined, /* @__PURE__ */ React.createElement("div", {
2062
+ className: "taw-import-actions"
2063
+ }, /* @__PURE__ */ React.createElement("button", {
2064
+ type: "button",
2065
+ className: "taw-link",
2066
+ disabled: working,
2067
+ onClick: () => void clear()
2068
+ }, t("clearBrowserData")), /* @__PURE__ */ React.createElement("button", {
2069
+ type: "button",
2070
+ className: "taw-button taw-primary",
2071
+ disabled: working || !chosen,
2072
+ onClick: () => void take()
2073
+ }, working ? t("importing") : t("importNow"))));
2074
+ }
2075
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
2076
+ title: t("importTitle"),
2077
+ onClose
2078
+ }, /* @__PURE__ */ React.createElement("div", {
2079
+ className: "taw-import"
2080
+ }, body));
2081
+ }
2082
+ function ImportSignIns({ onChanged }) {
2083
+ const data = pi.ui.desktop?.browserData;
2084
+ const [open, setOpen] = React.useState(false);
2085
+ if (!data) {
2086
+ return null;
2087
+ }
2088
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("button", {
2089
+ type: "button",
2090
+ className: "taw-browser-import",
2091
+ onClick: () => setOpen(true)
2092
+ }, /* @__PURE__ */ React.createElement(Glyph, {
2093
+ name: "Download",
2094
+ size: 13
2095
+ }), t("importSignIns")), open ? /* @__PURE__ */ React.createElement(ImportDialog, {
2096
+ data,
2097
+ onClose: () => setOpen(false),
2098
+ onChanged
2099
+ }) : undefined);
2100
+ }
2101
+
2102
+ // web-src/browser-webview.tsx
2103
+ var ERR_ABORTED = -3;
2104
+ var NO_PAGE = { url: "", title: "", loading: false, canGoBack: false, canGoForward: false };
2105
+ function usePage(view, mounted, onFailure) {
2106
+ const [page, setPage] = React.useState(NO_PAGE);
2107
+ const ready = React.useRef(false);
2108
+ const failed = React.useRef(onFailure);
2109
+ failed.current = onFailure;
2110
+ React.useEffect(() => {
2111
+ const element = view.current;
2112
+ if (!element) {
2113
+ return;
2114
+ }
2115
+ const update = (next) => setPage((previous) => ({
2116
+ ...previous,
2117
+ ...next,
2118
+ ...ready.current ? { canGoBack: element.canGoBack(), canGoForward: element.canGoForward() } : {}
2119
+ }));
2120
+ const listeners = [
2121
+ [
2122
+ "dom-ready",
2123
+ () => {
2124
+ ready.current = true;
2125
+ update({});
2126
+ }
2127
+ ],
2128
+ [
2129
+ "did-start-loading",
2130
+ () => {
2131
+ failed.current(undefined);
2132
+ update({ loading: true });
2133
+ }
2134
+ ],
2135
+ ["did-stop-loading", () => update({ loading: false })],
2136
+ ["did-navigate", (event) => update({ url: event.url, favicon: undefined })],
2137
+ ["did-navigate-in-page", (event) => event.isMainFrame && update({ url: event.url })],
2138
+ ["page-title-updated", (event) => update({ title: event.title })],
2139
+ ["page-favicon-updated", (event) => update({ favicon: event.favicons.find((icon) => /^(https?:|data:image\/)/i.test(icon)) })],
2140
+ [
2141
+ "did-fail-load",
2142
+ (event) => {
2143
+ if (event.isMainFrame && event.errorCode !== ERR_ABORTED) {
2144
+ failed.current({ url: event.validatedURL, reason: event.errorDescription || String(event.errorCode) });
2145
+ update({ url: event.validatedURL, title: "", favicon: undefined, loading: false });
2146
+ }
2147
+ }
2148
+ ],
2149
+ [
2150
+ "render-process-gone",
2151
+ () => {
2152
+ failed.current({ crashed: true });
2153
+ update({ loading: false });
2154
+ }
2155
+ ]
2156
+ ];
2157
+ for (const [name, listener] of listeners) {
2158
+ element.addEventListener(name, listener);
2159
+ }
2160
+ return () => {
2161
+ ready.current = false;
2162
+ for (const [name, listener] of listeners) {
2163
+ element.removeEventListener(name, listener);
2164
+ }
2165
+ };
2166
+ }, [mounted]);
2167
+ const expect = React.useCallback((url) => setPage((previous) => ({ ...previous, url, title: "", favicon: undefined })), []);
2168
+ return { page, ready, expect };
2169
+ }
2170
+ function FailurePanel({ failure, onRetry, onOutside }) {
2171
+ const crashed = "crashed" in failure;
2172
+ return /* @__PURE__ */ React.createElement("div", {
2173
+ className: "taw-browser-failure",
2174
+ role: "alert"
2175
+ }, /* @__PURE__ */ React.createElement("span", {
2176
+ className: "taw-browser-mark"
2177
+ }, /* @__PURE__ */ React.createElement(Glyph, {
2178
+ name: "CircleAlert",
2179
+ size: 22
2180
+ })), /* @__PURE__ */ React.createElement("p", {
2181
+ className: "taw-browser-title"
2182
+ }, t(crashed ? "pageCrashed" : "loadFailed")), crashed ? undefined : /* @__PURE__ */ React.createElement("p", {
2183
+ className: "taw-browser-sub"
2184
+ }, failure.reason), /* @__PURE__ */ React.createElement("div", {
2185
+ className: "taw-browser-chips"
2186
+ }, /* @__PURE__ */ React.createElement("button", {
2187
+ type: "button",
2188
+ className: "taw-browser-chip",
2189
+ onClick: onRetry
2190
+ }, t("retry")), onOutside ? /* @__PURE__ */ React.createElement("button", {
2191
+ type: "button",
2192
+ className: "taw-browser-chip",
2193
+ onClick: onOutside
2194
+ }, t("openBrowser")) : undefined));
2195
+ }
2196
+ var DRIVEN_MS = 4000;
2197
+ function useAgent(go, view, ready, hasPage, show, stage) {
2198
+ const [driven, setDriven] = React.useState(false);
2199
+ const latest = React.useRef({ go, hasPage, show });
2200
+ latest.current = { go, hasPage, show };
2201
+ React.useEffect(() => {
2202
+ let timer;
2203
+ const detach = AgentBrowser.attach({
2204
+ go: (url) => latest.current.go(url),
2205
+ view: () => latest.current.hasPage && ready.current ? view.current ?? undefined : undefined,
2206
+ shown: () => (stage.current?.getClientRects().length ?? 0) > 0,
2207
+ drive: () => {
2208
+ if (latest.current.hasPage) {
2209
+ latest.current.show();
2210
+ }
2211
+ setDriven(true);
2212
+ clearTimeout(timer);
2213
+ timer = setTimeout(() => setDriven(false), DRIVEN_MS);
2214
+ }
2215
+ });
2216
+ return () => {
2217
+ clearTimeout(timer);
2218
+ detach();
2219
+ };
2220
+ }, []);
2221
+ return driven;
2222
+ }
2223
+ function WebviewBrowser() {
2224
+ const cwd = pi.ui.useCwd();
2225
+ const [request, setRequest] = React.useState({ url: "", id: 0 });
2226
+ const [home, setHome] = React.useState(true);
2227
+ const [src, setSrc] = React.useState();
2228
+ const [failure, setFailure] = React.useState();
2229
+ const view = React.useRef(null);
2230
+ const stage = React.useRef(null);
2231
+ const { page, ready, expect } = usePage(view, Boolean(src), setFailure);
2232
+ const shown = useForwarded(request.url, cwd);
2233
+ React.useEffect(() => {
2234
+ if (!request.url || !shown) {
2235
+ return;
2236
+ }
2237
+ setFailure(undefined);
2238
+ expect(shown);
2239
+ if (view.current && ready.current) {
2240
+ view.current.loadURL(shown).catch(() => {
2241
+ return;
2242
+ });
2243
+ } else {
2244
+ setSrc(shown);
2245
+ }
2246
+ }, [shown, request.id]);
2247
+ const go = (url) => {
2248
+ if (!url) {
2249
+ setHome(true);
2250
+ return;
2251
+ }
2252
+ Recent.add(url);
2253
+ setHome(false);
2254
+ setRequest((previous) => ({ url, id: previous.id + 1 }));
2255
+ };
2256
+ ShowPage.useReceive(go);
2257
+ const driven = useAgent(go, view, ready, Boolean(src), () => setHome(false), stage);
2258
+ const call = (run) => {
2259
+ if (view.current && ready.current) {
2260
+ run(view.current);
2261
+ }
2262
+ };
2263
+ const retry = () => {
2264
+ if (failure && "url" in failure && failure.url) {
2265
+ setFailure(undefined);
2266
+ call((element) => element.loadURL(failure.url).catch(() => {
2267
+ return;
2268
+ }));
2269
+ } else {
2270
+ call((element) => element.reload());
2271
+ }
2272
+ };
2273
+ const address = home ? "" : WorkspaceUtil.unforward(page.url || request.url, request.url, shown);
2274
+ const current = page.url || shown;
2275
+ return /* @__PURE__ */ React.createElement("div", {
2276
+ className: "taw-browser"
2277
+ }, /* @__PURE__ */ React.createElement(BrowserBar, {
2278
+ url: address,
2279
+ title: home ? undefined : page.title,
2280
+ favicon: home ? undefined : page.favicon,
2281
+ loading: !home && page.loading,
2282
+ canGoBack: home ? Boolean(src) : page.canGoBack,
2283
+ canGoForward: !home && page.canGoForward,
2284
+ onBack: () => home ? setHome(false) : call((element) => element.goBack()),
2285
+ onForward: () => call((element) => element.goForward()),
2286
+ onReload: retry,
2287
+ onStop: () => call((element) => element.stop()),
2288
+ onOpen: go,
2289
+ onHome: () => setHome(true),
2290
+ onOpenOutside: !home && current ? () => openOutside(current) : undefined,
2291
+ outsideLabel: t("openBrowser"),
2292
+ badge: driven ? /* @__PURE__ */ React.createElement("span", {
2293
+ className: "taw-browser-driven",
2294
+ role: "status"
2295
+ }, /* @__PURE__ */ React.createElement("span", {
2296
+ className: "taw-browser-driven-dot"
2297
+ }), t("agentDriving")) : undefined
2298
+ }), /* @__PURE__ */ React.createElement("div", {
2299
+ className: "taw-browser-stage",
2300
+ ref: stage
2301
+ }, src ? React.createElement("webview", {
2302
+ ref: view,
2303
+ src,
2304
+ className: "taw-webview",
2305
+ allowpopups: "true",
2306
+ style: { display: home ? "none" : "flex" }
2307
+ }) : undefined, home ? /* @__PURE__ */ React.createElement(Home, {
2308
+ onOpen: go,
2309
+ extra: /* @__PURE__ */ React.createElement(ImportSignIns, {
2310
+ onChanged: () => call((element) => element.reload())
2311
+ })
2312
+ }) : undefined, !home && failure ? /* @__PURE__ */ React.createElement(FailurePanel, {
2313
+ failure,
2314
+ onRetry: retry,
2315
+ onOutside: "url" in failure ? () => openOutside(failure.url) : undefined
2316
+ }) : undefined));
2317
+ }
2318
+
2319
+ // web-src/browser.tsx
2320
+ function FrameBrowser() {
1244
2321
  const [history, setHistory] = React.useState({ list: [""], index: 0, reloads: 0 });
1245
2322
  const [loading, setLoading] = React.useState(false);
1246
2323
  const url = history.list[history.index];
@@ -1266,40 +2343,19 @@ function BrowserView() {
1266
2343
  };
1267
2344
  return /* @__PURE__ */ React.createElement("div", {
1268
2345
  className: "taw-browser"
1269
- }, /* @__PURE__ */ React.createElement("header", {
1270
- className: "taw-browser-bar"
1271
- }, /* @__PURE__ */ React.createElement(Action, {
1272
- icon: "ArrowLeft",
1273
- label: t("back"),
1274
- disabled: history.index === 0,
1275
- onClick: () => step(-1)
1276
- }), /* @__PURE__ */ React.createElement(Action, {
1277
- icon: "ArrowRight",
1278
- label: t("forward"),
1279
- disabled: history.index === history.list.length - 1,
1280
- onClick: () => step(1)
1281
- }), /* @__PURE__ */ React.createElement(Action, {
1282
- icon: "RefreshCw",
1283
- label: t("refresh"),
1284
- disabled: !url,
1285
- onClick: reload
1286
- }), /* @__PURE__ */ React.createElement(AddressBar, {
1287
- value: url,
2346
+ }, /* @__PURE__ */ React.createElement(BrowserBar, {
2347
+ url,
1288
2348
  loading,
1289
- onOpen: go
1290
- }), /* @__PURE__ */ React.createElement(Action, {
1291
- icon: "House",
1292
- label: t("home"),
1293
- disabled: !url,
1294
- onClick: () => go("")
1295
- }), /* @__PURE__ */ React.createElement(Action, {
1296
- icon: "ExternalLink",
1297
- label: t("openExternal"),
1298
- disabled: !shown,
1299
- onClick: () => shown && window.open(shown, "_blank", "noopener,noreferrer")
1300
- }), loading ? /* @__PURE__ */ React.createElement("span", {
1301
- className: "taw-browser-loading"
1302
- }) : undefined), url ? shown && /* @__PURE__ */ React.createElement("iframe", {
2349
+ canGoBack: history.index > 0,
2350
+ canGoForward: history.index < history.list.length - 1,
2351
+ onBack: () => step(-1),
2352
+ onForward: () => step(1),
2353
+ onReload: reload,
2354
+ onOpen: go,
2355
+ onHome: () => go(""),
2356
+ onOpenOutside: shown ? () => openOutside(shown) : undefined,
2357
+ outsideLabel: t("openExternal")
2358
+ }), url ? shown && /* @__PURE__ */ React.createElement("iframe", {
1303
2359
  key: `${history.index}:${history.reloads}`,
1304
2360
  className: "taw-frame",
1305
2361
  title: shown === url ? url : `${url} → ${shown}`,
@@ -1308,9 +2364,13 @@ function BrowserView() {
1308
2364
  sandbox: WorkspaceUtil.frameSandbox(shown, location.origin),
1309
2365
  onLoad: () => setLoading(false)
1310
2366
  }) : /* @__PURE__ */ React.createElement(Home, {
1311
- onOpen: go
2367
+ onOpen: go,
2368
+ foot: t("frameHint")
1312
2369
  }));
1313
2370
  }
2371
+ function BrowserView() {
2372
+ return pi.ui.supportsWebview ? /* @__PURE__ */ React.createElement(WebviewBrowser, null) : /* @__PURE__ */ React.createElement(FrameBrowser, null);
2373
+ }
1314
2374
 
1315
2375
  // web-src/util/seti.ts
1316
2376
  var SETI_ICONS = [
@@ -4362,6 +5422,182 @@ function MediaPreview({ kind, url, size, onInfo }) {
4362
5422
  }
4363
5423
  }
4364
5424
 
5425
+ // ../ta-protocol/esm/common/auth-protocol.js
5426
+ var TaAuthServer = Symbol("TaAuthServer");
5427
+ // ../ta-protocol/esm/common/location.js
5428
+ var TaLocation;
5429
+ (function(TaLocation2) {
5430
+ TaLocation2.SSH = "ssh://";
5431
+ const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
5432
+ function isRemote(location2) {
5433
+ return location2.startsWith(TaLocation2.SSH);
5434
+ }
5435
+ TaLocation2.isRemote = isRemote;
5436
+ function parse(location2) {
5437
+ if (!isRemote(location2)) {
5438
+ return;
5439
+ }
5440
+ const rest = location2.slice(TaLocation2.SSH.length);
5441
+ const slash = rest.indexOf("/");
5442
+ const host2 = slash < 0 ? rest : rest.slice(0, slash);
5443
+ const path2 = slash < 0 ? "" : normalize(rest.slice(slash));
5444
+ if (!isHost(host2)) {
5445
+ throw new Error(`${JSON.stringify(location2)} names no host: write ssh://<host>/<path>, the host as ssh takes it.`);
5446
+ }
5447
+ return { host: host2, path: path2 };
5448
+ }
5449
+ TaLocation2.parse = parse;
5450
+ function isHost(host2) {
5451
+ return HOST.test(host2);
5452
+ }
5453
+ TaLocation2.isHost = isHost;
5454
+ const FLAGS = /^-[46AaCfGgKkMNnqsTtVvXxYy]+$/;
5455
+ function readHost(input) {
5456
+ const words = input.trim().split(/\s+/).filter(Boolean);
5457
+ if (words[0] === "ssh") {
5458
+ words.shift();
5459
+ }
5460
+ let destination;
5461
+ let port;
5462
+ let user;
5463
+ const options2 = [];
5464
+ for (let i = 0;i < words.length; i++) {
5465
+ const word = words[i];
5466
+ const glued = /^-([pl])(.+)$/.exec(word);
5467
+ if (word === "-p" || word === "-l" || glued) {
5468
+ const value = glued ? glued[2] : words[++i];
5469
+ if (value === undefined) {
5470
+ return { error: "invalid" };
5471
+ }
5472
+ if ((glued ? glued[1] : word[1]) === "p") {
5473
+ port = value;
5474
+ } else {
5475
+ user = value;
5476
+ }
5477
+ } else if (word === "-o" || word.startsWith("-o")) {
5478
+ const value = word === "-o" ? words[++i] : word.slice(2);
5479
+ const option = /^(port|user)\s*=?\s*(.+)$/i.exec(value !== null && value !== undefined ? value : "");
5480
+ if (!option) {
5481
+ options2.push(`-o ${value !== null && value !== undefined ? value : ""}`.trim());
5482
+ } else if (option[1].toLowerCase() === "port") {
5483
+ port = option[2];
5484
+ } else {
5485
+ user = option[2];
5486
+ }
5487
+ } else if (FLAGS.test(word)) {} else if (word.startsWith("-")) {
5488
+ options2.push(/^-[bBcDeEFiIJLmOQRSwW]$/.test(word) && words[i + 1] !== undefined ? `${word} ${words[++i]}` : word);
5489
+ } else if (destination === undefined) {
5490
+ destination = word;
5491
+ } else {
5492
+ return { error: "invalid" };
5493
+ }
5494
+ }
5495
+ if (options2.length > 0) {
5496
+ return { error: "options", options: options2 };
5497
+ }
5498
+ if (!destination) {
5499
+ return { error: "empty" };
5500
+ }
5501
+ let host2 = destination.replace(/^ssh:\/\//, "").replace(/\/.*$/, "");
5502
+ if (user && !host2.includes("@")) {
5503
+ host2 = `${user}@${host2}`;
5504
+ }
5505
+ if (port) {
5506
+ if (!/^\d{1,5}$/.test(port) || /:\d+$/.test(host2)) {
5507
+ return { error: "invalid" };
5508
+ }
5509
+ host2 = port === "22" ? host2 : `${host2}:${port}`;
5510
+ }
5511
+ return isHost(host2) ? { host: host2 } : { error: "invalid" };
5512
+ }
5513
+ TaLocation2.readHost = readHost;
5514
+ function ssh(host2, path2 = "") {
5515
+ return `${TaLocation2.SSH}${host2}${path2 ? normalize(path2) : ""}`;
5516
+ }
5517
+ TaLocation2.ssh = ssh;
5518
+ function host(location2) {
5519
+ var _a;
5520
+ return isRemote(location2) ? (_a = parse(location2)) === null || _a === undefined ? undefined : _a.host : undefined;
5521
+ }
5522
+ TaLocation2.host = host;
5523
+ function path(location2) {
5524
+ var _a;
5525
+ var _b;
5526
+ return (_b = (_a = parse(location2)) === null || _a === undefined ? undefined : _a.path) !== null && _b !== undefined ? _b : location2;
5527
+ }
5528
+ TaLocation2.path = path;
5529
+ function parent(location2) {
5530
+ const remote = parse(location2);
5531
+ if (remote) {
5532
+ const above = remote.path ? parentPath(remote.path) : undefined;
5533
+ return above === undefined ? undefined : ssh(remote.host, above);
5534
+ }
5535
+ return parentPath(location2);
5536
+ }
5537
+ TaLocation2.parent = parent;
5538
+ function child(location2, name) {
5539
+ const remote = parse(location2);
5540
+ if (remote) {
5541
+ return ssh(remote.host, childPath(remote.path || "/", name));
5542
+ }
5543
+ return childPath(location2, name);
5544
+ }
5545
+ TaLocation2.child = child;
5546
+ function basename(location2) {
5547
+ const remote = parse(location2);
5548
+ const path2 = (remote ? remote.path : location2).replace(/[\\/]+$/, "");
5549
+ const name = path2.slice(Math.max(path2.lastIndexOf("/"), path2.lastIndexOf("\\")) + 1);
5550
+ return name || (remote === null || remote === undefined ? undefined : remote.host) || location2;
5551
+ }
5552
+ TaLocation2.basename = basename;
5553
+ function parentPath(path2) {
5554
+ const trimmed = path2.replace(/[\\/]+$/, "");
5555
+ const at = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
5556
+ if (at < 0) {
5557
+ return;
5558
+ }
5559
+ const head = trimmed.slice(0, at);
5560
+ return head === "" || /^[A-Za-z]:$/.test(head) ? head + trimmed[at] : head;
5561
+ }
5562
+ function childPath(path2, name) {
5563
+ const separator = path2.includes("/") || !path2.includes("\\") ? "/" : "\\";
5564
+ return path2.endsWith(separator) ? path2 + name : path2 + separator + name;
5565
+ }
5566
+ function normalize(path2) {
5567
+ const squeezed = `/${path2}`.replace(/\/+/g, "/");
5568
+ return squeezed.length > 1 ? squeezed.replace(/\/$/, "") : squeezed;
5569
+ }
5570
+ })(TaLocation || (TaLocation = {}));
5571
+ // ../ta-protocol/esm/common/package-protocol.js
5572
+ var TaPackageServer = Symbol("TaPackageServer");
5573
+ // ../ta-protocol/esm/common/relay-protocol.js
5574
+ var TaRelayServer = Symbol("TaRelayServer");
5575
+ // ../ta-protocol/esm/common/remote-protocol.js
5576
+ var TaRemoteServer = Symbol("TaRemoteServer");
5577
+ // ../ta-protocol/esm/common/settings-protocol.js
5578
+ var TaSettingsServer = Symbol("TaSettingsServer");
5579
+ // ../ta-protocol/esm/common/ta-protocol.js
5580
+ var TaServer = Symbol("TaServer");
5581
+ var TaClient = Symbol("TaClient");
5582
+ var TaMessageContext;
5583
+ (function(TaMessageContext2) {
5584
+ const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
5585
+ function wrap(context, message) {
5586
+ return `<context>
5587
+ ${context}
5588
+ </context>
5589
+ ${message}`;
5590
+ }
5591
+ TaMessageContext2.wrap = wrap;
5592
+ function strip(message) {
5593
+ return message.replace(BLOCK, "");
5594
+ }
5595
+ TaMessageContext2.strip = strip;
5596
+ })(TaMessageContext || (TaMessageContext = {}));
5597
+ // ../ta-protocol/esm/common/workspace-protocol.js
5598
+ var TaWorkspaceServer = Symbol("TaWorkspaceServer");
5599
+ var TaTerminalServer = Symbol("TaTerminalServer");
5600
+ var TA_UPLOAD_PART_BYTES = 4 * 1024 * 1024;
4365
5601
  // web-src/util/search.ts
4366
5602
  var PREVIEW_CHARS = 200;
4367
5603
  var SKIPPED_DIRECTORIES = [".git", "node_modules"];
@@ -4548,33 +5784,246 @@ var SearchUtil;
4548
5784
  if (!found?.[0]) {
4549
5785
  return { text, count: 0 };
4550
5786
  }
4551
- const offset = start + found.index;
4552
- return { text: text.slice(0, offset) + expand(found[0], found.slice(1)) + text.slice(offset + found[0].length), count: 1 };
4553
- }
4554
- SearchUtil.replace = replace;
4555
- function groupsOf(rest) {
4556
- return rest.slice(0, rest.findIndex((value) => typeof value === "number"));
5787
+ const offset = start + found.index;
5788
+ return { text: text.slice(0, offset) + expand(found[0], found.slice(1)) + text.slice(offset + found[0].length), count: 1 };
5789
+ }
5790
+ SearchUtil.replace = replace;
5791
+ function groupsOf(rest) {
5792
+ return rest.slice(0, rest.findIndex((value) => typeof value === "number"));
5793
+ }
5794
+ function substitute(replacement, match, groups) {
5795
+ return replacement.replace(/\$(\$|&|\d{1,2})/g, (all, name) => {
5796
+ if (name === "$") {
5797
+ return "$";
5798
+ }
5799
+ if (name === "&") {
5800
+ return match;
5801
+ }
5802
+ const index = Number(name);
5803
+ return index >= 1 && index <= groups.length ? groups[index - 1] ?? "" : all;
5804
+ });
5805
+ }
5806
+ SearchUtil.substitute = substitute;
5807
+ })(SearchUtil ||= {});
5808
+
5809
+ // web-src/util/upload.ts
5810
+ var UploadUtil;
5811
+ ((UploadUtil) => {
5812
+ function segments(path) {
5813
+ const parts3 = path.split(/[\\/]+/).filter((part) => part && part !== ".");
5814
+ if (!parts3.length || parts3.some((part) => part === ".." || part.includes("\x00"))) {
5815
+ throw new Error(`Not a path to upload to: ${path}`);
5816
+ }
5817
+ return parts3;
5818
+ }
5819
+ UploadUtil.segments = segments;
5820
+ function fromFiles(files) {
5821
+ return { files: Array.from(files, (file) => ({ path: file.webkitRelativePath || file.name, file })), folders: [] };
5822
+ }
5823
+ UploadUtil.fromFiles = fromFiles;
5824
+ async function fromDrop(dataTransfer) {
5825
+ const entries = Array.from(dataTransfer.items ?? []).filter((item) => item.kind === "file").map((item) => item.webkitGetAsEntry?.());
5826
+ if (!entries.length || entries.some((entry) => !entry)) {
5827
+ return fromFiles(Array.from(dataTransfer.files ?? []));
5828
+ }
5829
+ const batch = { files: [], folders: [] };
5830
+ for (const entry of entries) {
5831
+ await collect(entry, "", batch);
5832
+ }
5833
+ return batch;
5834
+ }
5835
+ UploadUtil.fromDrop = fromDrop;
5836
+ async function collect(entry, folder, batch) {
5837
+ const path = folder ? `${folder}/${entry.name}` : entry.name;
5838
+ if (entry.isFile && entry.file) {
5839
+ const read = entry.file.bind(entry);
5840
+ batch.files.push({ path, file: await new Promise((resolve, reject) => read(resolve, reject)) });
5841
+ } else if (entry.isDirectory && entry.createReader) {
5842
+ batch.folders.push(path);
5843
+ const reader = entry.createReader();
5844
+ for (;; ) {
5845
+ const children = await new Promise((resolve, reject) => reader.readEntries(resolve, reject));
5846
+ if (!children.length) {
5847
+ break;
5848
+ }
5849
+ for (const child of children) {
5850
+ await collect(child, path, batch);
5851
+ }
5852
+ }
5853
+ }
5854
+ }
5855
+ function topNames(batch) {
5856
+ const names = new Set;
5857
+ for (const path of [...batch.files.map((file) => file.path), ...batch.folders]) {
5858
+ names.add(segments(path)[0]);
5859
+ }
5860
+ return [...names];
5861
+ }
5862
+ UploadUtil.topNames = topNames;
5863
+ function emptyFolders(batch) {
5864
+ const filled = new Set;
5865
+ for (const { path } of batch.files) {
5866
+ const parts3 = segments(path);
5867
+ for (let i = 1;i < parts3.length; i++) {
5868
+ filled.add(parts3.slice(0, i).join("/"));
5869
+ }
5870
+ }
5871
+ const folders = batch.folders.map((folder) => segments(folder).join("/"));
5872
+ return [...new Set(folders)].filter((folder) => !filled.has(folder) && !folders.some((other) => other.startsWith(`${folder}/`)));
5873
+ }
5874
+ UploadUtil.emptyFolders = emptyFolders;
5875
+ function totalBytes(batch) {
5876
+ return batch.files.reduce((sum, { file }) => sum + file.size, 0);
5877
+ }
5878
+ UploadUtil.totalBytes = totalBytes;
5879
+ function parts2(size, partBytes) {
5880
+ if (size === 0) {
5881
+ return [[0, 0]];
5882
+ }
5883
+ const out = [];
5884
+ for (let start = 0;start < size; start += partBytes) {
5885
+ out.push([start, Math.min(size, start + partBytes)]);
5886
+ }
5887
+ return out;
5888
+ }
5889
+ UploadUtil.parts = parts2;
5890
+ function toBase64(bytes) {
5891
+ let binary = "";
5892
+ for (let i = 0;i < bytes.length; i += 32768) {
5893
+ binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
5894
+ }
5895
+ return btoa(binary);
5896
+ }
5897
+ UploadUtil.toBase64 = toBase64;
5898
+ })(UploadUtil ||= {});
5899
+
5900
+ // web-src/util/zip.ts
5901
+ var CRC_TABLE = (() => {
5902
+ const table = new Uint32Array(256);
5903
+ for (let n = 0;n < 256; n++) {
5904
+ let c = n;
5905
+ for (let k = 0;k < 8; k++) {
5906
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
5907
+ }
5908
+ table[n] = c >>> 0;
5909
+ }
5910
+ return table;
5911
+ })();
5912
+ var ZIP_MAX_BYTES = 4294967295;
5913
+ var ZIP_MAX_ENTRIES = 65535;
5914
+ var ZipUtil;
5915
+ ((ZipUtil) => {
5916
+ function crc32(data) {
5917
+ let crc = 4294967295;
5918
+ for (let i = 0;i < data.length; i++) {
5919
+ crc = CRC_TABLE[(crc ^ data[i]) & 255] ^ crc >>> 8;
5920
+ }
5921
+ return (crc ^ 4294967295) >>> 0;
5922
+ }
5923
+ ZipUtil.crc32 = crc32;
5924
+ function dosTime(date) {
5925
+ const year = Math.max(1980, date.getFullYear());
5926
+ return [
5927
+ date.getHours() << 11 | date.getMinutes() << 5 | Math.floor(date.getSeconds() / 2),
5928
+ year - 1980 << 9 | date.getMonth() + 1 << 5 | date.getDate()
5929
+ ];
5930
+ }
5931
+ async function create(entries, deflate) {
5932
+ if (entries.length > ZIP_MAX_ENTRIES) {
5933
+ throw new Error(`An archive holds at most ${ZIP_MAX_ENTRIES} files.`);
5934
+ }
5935
+ const encoder = new TextEncoder;
5936
+ const locals = [];
5937
+ const centrals = [];
5938
+ let offset = 0;
5939
+ for (const entry of entries) {
5940
+ const name = encoder.encode(entry.path.replace(/^\/+/, ""));
5941
+ const crc = crc32(entry.data);
5942
+ const deflated = deflate && entry.data.length > 0 ? await deflate(entry.data) : undefined;
5943
+ const compressed = deflated && deflated.length < entry.data.length ? deflated : entry.data;
5944
+ const method = compressed === entry.data ? 0 : 8;
5945
+ const [time, date] = dosTime(entry.modified ?? new Date);
5946
+ if (offset + 30 + name.length + compressed.length > ZIP_MAX_BYTES) {
5947
+ throw new Error("An archive holds at most 4 GB.");
5948
+ }
5949
+ const header = (signature, central) => {
5950
+ const view = new DataView(new ArrayBuffer(central ? 46 : 30));
5951
+ let at2 = 0;
5952
+ const u16 = (value) => {
5953
+ view.setUint16(at2, value, true);
5954
+ at2 += 2;
5955
+ };
5956
+ const u32 = (value) => {
5957
+ view.setUint32(at2, value >>> 0, true);
5958
+ at2 += 4;
5959
+ };
5960
+ u32(signature);
5961
+ if (central) {
5962
+ u16(20);
5963
+ }
5964
+ u16(20);
5965
+ u16(2048);
5966
+ u16(method);
5967
+ u16(time);
5968
+ u16(date);
5969
+ u32(crc);
5970
+ u32(compressed.length);
5971
+ u32(entry.data.length);
5972
+ u16(name.length);
5973
+ u16(0);
5974
+ if (central) {
5975
+ u16(0);
5976
+ u16(0);
5977
+ u16(0);
5978
+ u32(0);
5979
+ u32(offset);
5980
+ }
5981
+ return new Uint8Array(view.buffer);
5982
+ };
5983
+ const local = header(67324752, false);
5984
+ locals.push(local, name, compressed);
5985
+ centrals.push(header(33639248, true), name);
5986
+ offset += local.length + name.length + compressed.length;
5987
+ }
5988
+ const centralSize = centrals.reduce((sum, part) => sum + part.length, 0);
5989
+ const end = new DataView(new ArrayBuffer(22));
5990
+ end.setUint32(0, 101010256, true);
5991
+ end.setUint16(8, entries.length, true);
5992
+ end.setUint16(10, entries.length, true);
5993
+ end.setUint32(12, centralSize, true);
5994
+ end.setUint32(16, offset, true);
5995
+ const parts2 = [...locals, ...centrals, new Uint8Array(end.buffer)];
5996
+ const out = new Uint8Array(parts2.reduce((sum, part) => sum + part.length, 0));
5997
+ let at = 0;
5998
+ for (const part of parts2) {
5999
+ out.set(part, at);
6000
+ at += part.length;
6001
+ }
6002
+ return out;
4557
6003
  }
4558
- function substitute(replacement, match, groups) {
4559
- return replacement.replace(/\$(\$|&|\d{1,2})/g, (all, name) => {
4560
- if (name === "$") {
4561
- return "$";
4562
- }
4563
- if (name === "&") {
4564
- return match;
4565
- }
4566
- const index = Number(name);
4567
- return index >= 1 && index <= groups.length ? groups[index - 1] ?? "" : all;
4568
- });
6004
+ ZipUtil.create = create;
6005
+ function browserDeflate() {
6006
+ const Stream = globalThis.CompressionStream;
6007
+ if (!Stream) {
6008
+ return;
6009
+ }
6010
+ return async (data) => {
6011
+ const stream = new Stream("deflate-raw");
6012
+ const writer = stream.writable.getWriter();
6013
+ writer.write(data).then(() => writer.close());
6014
+ return new Uint8Array(await new Response(stream.readable).arrayBuffer());
6015
+ };
4569
6016
  }
4570
- SearchUtil.substitute = substitute;
4571
- })(SearchUtil ||= {});
6017
+ ZipUtil.browserDeflate = browserDeflate;
6018
+ })(ZipUtil ||= {});
4572
6019
 
4573
6020
  // web-src/workspace-client.ts
4574
6021
  var SEARCH_LIMIT = 2000;
4575
6022
  var SEARCH_BYTES = 8 * 1024 * 1024;
4576
6023
  var SEARCHERS = ["rg", "git", "grep"];
4577
6024
  var REMOTE_TIMEOUT_MS = 120000;
6025
+ var MAX_ARCHIVE_BYTES = 1024 * 1024 * 1024;
6026
+ var DOWNLOAD_CONCURRENCY = 4;
4578
6027
  var WorkspaceClient;
4579
6028
  ((WorkspaceClient) => {
4580
6029
  const missing = new Map;
@@ -4670,6 +6119,93 @@ var WorkspaceClient;
4670
6119
  return run(cwd, "rm", ["-rf", "--", path]);
4671
6120
  }
4672
6121
  WorkspaceClient.remove = remove;
6122
+ function move(cwd, paths, folder) {
6123
+ return run(cwd, "mv", ["-n", "--", ...paths, folder || "."]);
6124
+ }
6125
+ WorkspaceClient.move = move;
6126
+ async function upload(cwd, folder, batch, onProgress) {
6127
+ for (const empty of UploadUtil.emptyFolders(batch)) {
6128
+ await createFolder(cwd, WorkspaceUtil.join(folder, empty));
6129
+ }
6130
+ const total = UploadUtil.totalBytes(batch);
6131
+ let sent = 0;
6132
+ for (const { path, file } of batch.files) {
6133
+ const target = WorkspaceUtil.join(folder, UploadUtil.segments(path).join("/"));
6134
+ for (const [start, end] of UploadUtil.parts(file.size, TA_UPLOAD_PART_BYTES)) {
6135
+ onProgress?.(sent, total, file.name);
6136
+ const bytes = new Uint8Array(await file.slice(start, end).arrayBuffer());
6137
+ await pi.workspace.uploadFile(target, UploadUtil.toBase64(bytes), { cwd, append: start > 0 });
6138
+ sent += end - start;
6139
+ }
6140
+ }
6141
+ onProgress?.(sent, total, "");
6142
+ return batch.files.length;
6143
+ }
6144
+ WorkspaceClient.upload = upload;
6145
+ async function filesOf(cwd, folder) {
6146
+ const files = [];
6147
+ let level = [folder];
6148
+ while (level.length) {
6149
+ const listed = await Promise.all(level.map((dir) => pi.workspace.listDirectory(dir, cwd)));
6150
+ level = [];
6151
+ for (const entry of listed.flat()) {
6152
+ if (entry.kind === "directory") {
6153
+ level.push(entry.path);
6154
+ } else {
6155
+ files.push(entry);
6156
+ }
6157
+ }
6158
+ }
6159
+ return files;
6160
+ }
6161
+ WorkspaceClient.filesOf = filesOf;
6162
+ async function download(cwd, entry, onProgress) {
6163
+ if (entry.kind === "file") {
6164
+ save(await pi.workspace.fileUrl(entry.path, cwd), entry.name);
6165
+ return;
6166
+ }
6167
+ const files = await filesOf(cwd, entry.path);
6168
+ const total = files.reduce((sum, file) => sum + (file.size ?? 0), 0);
6169
+ if (total > MAX_ARCHIVE_BYTES) {
6170
+ throw new Error(`${WorkspaceUtil.size(total)} is more than a folder downloaded here may hold (${WorkspaceUtil.size(MAX_ARCHIVE_BYTES)}).`);
6171
+ }
6172
+ const base = (await pi.workspace.fileUrl(entry.path, cwd)).replace(/\/?$/, "/");
6173
+ const offset = entry.path ? entry.path.length + 1 : 0;
6174
+ const entries = new Array(files.length);
6175
+ let done = 0;
6176
+ let next = 0;
6177
+ const worker = async () => {
6178
+ while (next < files.length) {
6179
+ const index = next++;
6180
+ const file = files[index];
6181
+ const relative = file.path.slice(offset);
6182
+ onProgress?.(done, total, file.name);
6183
+ const response = await fetch(base + relative.split("/").map(encodeURIComponent).join("/"));
6184
+ if (!response.ok) {
6185
+ throw new Error(`${file.path}: HTTP ${response.status}`);
6186
+ }
6187
+ entries[index] = { path: `${entry.name}/${relative}`, data: new Uint8Array(await response.arrayBuffer()) };
6188
+ done += file.size ?? 0;
6189
+ }
6190
+ };
6191
+ await Promise.all(Array.from({ length: Math.min(DOWNLOAD_CONCURRENCY, files.length) }, worker));
6192
+ onProgress?.(total, total, "");
6193
+ const zip = await ZipUtil.create(entries, ZipUtil.browserDeflate());
6194
+ const url = URL.createObjectURL(new Blob([zip], { type: "application/zip" }));
6195
+ save(url, `${entry.name}.zip`);
6196
+ setTimeout(() => URL.revokeObjectURL(url), 60000);
6197
+ }
6198
+ WorkspaceClient.download = download;
6199
+ function save(url, name) {
6200
+ const link2 = document.createElement("a");
6201
+ link2.href = url;
6202
+ link2.download = name;
6203
+ link2.rel = "noopener";
6204
+ link2.style.display = "none";
6205
+ document.body.append(link2);
6206
+ link2.click();
6207
+ link2.remove();
6208
+ }
4673
6209
  })(WorkspaceClient ||= {});
4674
6210
 
4675
6211
  // web-src/editors.tsx
@@ -5499,6 +7035,10 @@ var roots = new Map;
5499
7035
  var INDENT2 = 12;
5500
7036
  var EXPANDED_KEY = "explorer.expanded";
5501
7037
  var NO_DECORATIONS = { files: new Map, folders: new Map, ignored: [] };
7038
+ var DRAG_OPEN_MS = 600;
7039
+ function acceptsDrop(dataTransfer) {
7040
+ return dataTransfer.types.includes("Files") || pi.ui.fileDrag.has(dataTransfer);
7041
+ }
5502
7042
  var RevealRequests = new Channel;
5503
7043
  var ShowDirectory = new Channel;
5504
7044
  function ExplorerView() {
@@ -5512,6 +7052,14 @@ function ExplorerView() {
5512
7052
  const [picking, setPicking] = React.useState(false);
5513
7053
  const [menu, openMenu] = useContextMenu();
5514
7054
  const list2 = React.useRef(null);
7055
+ const [dropTarget, setDropTarget] = React.useState();
7056
+ const [transfer, setTransfer] = React.useState();
7057
+ const filePicker = React.useRef(null);
7058
+ const folderPicker = React.useRef(null);
7059
+ const pickedFolder = React.useRef("");
7060
+ const dragOpen = React.useRef(undefined);
7061
+ const desktop = pi.ui.desktop;
7062
+ const showsInFileManager = !!desktop && !TaLocation.isRemote(root);
5515
7063
  const git = useLoad(() => WorkspaceClient.status(root, true).catch(() => {
5516
7064
  return;
5517
7065
  }), [root, changed]);
@@ -5684,6 +7232,141 @@ function ExplorerView() {
5684
7232
  pi.ui.notify(t("deleteFailed", { message: Host.message(error) }), "error");
5685
7233
  }
5686
7234
  };
7235
+ const reloadFolder = async (folder) => {
7236
+ await load([folder, ...[...tree.expanded].filter((dir) => dir !== folder && WorkspaceUtil.within(dir, folder))]);
7237
+ FilesChanged.notify();
7238
+ };
7239
+ const taken = (folder, names) => {
7240
+ const there = siblings(folder).map((name) => name.toLowerCase());
7241
+ return names.filter((name) => there.includes(name.toLowerCase()));
7242
+ };
7243
+ const upload = async (folder, pending) => {
7244
+ let batch;
7245
+ try {
7246
+ batch = await pending;
7247
+ } catch (error) {
7248
+ pi.ui.notify(t("uploadFailed", { message: Host.message(error) }), "error");
7249
+ return;
7250
+ }
7251
+ if (!batch.files.length && !batch.folders.length) {
7252
+ return;
7253
+ }
7254
+ const replaced = taken(folder, UploadUtil.topNames(batch));
7255
+ if (replaced.length && !await pi.ui.confirm(t("replaceTitle", { names: replaced.join(", ") }), t("replaceMessage"), { confirmLabel: t("replace") })) {
7256
+ return;
7257
+ }
7258
+ if (folder) {
7259
+ expand((previous) => WorkspaceUtil.reveal(new Set([...previous, folder]), folder));
7260
+ }
7261
+ setTransfer({ label: t("uploading", { name: "" }), done: 0, total: UploadUtil.totalBytes(batch) });
7262
+ try {
7263
+ const count = await WorkspaceClient.upload(root, folder, batch, (done, total, name) => setTransfer({ label: t("uploading", { name }), done, total }));
7264
+ pi.ui.notify(t("uploaded", { count }));
7265
+ } catch (error) {
7266
+ pi.ui.notify(t("uploadFailed", { message: Host.message(error) }), "error");
7267
+ } finally {
7268
+ setTransfer(undefined);
7269
+ await reloadFolder(folder);
7270
+ }
7271
+ };
7272
+ const pickFiles = (folder, folders) => {
7273
+ pickedFolder.current = folder;
7274
+ (folders ? folderPicker : filePicker).current?.click();
7275
+ };
7276
+ const onPicked = (event) => {
7277
+ const files = Array.from(event.target.files ?? []);
7278
+ event.target.value = "";
7279
+ if (files.length) {
7280
+ upload(pickedFolder.current, Promise.resolve(UploadUtil.fromFiles(files)));
7281
+ }
7282
+ };
7283
+ const download = async (entry) => {
7284
+ try {
7285
+ if (entry.kind === "directory") {
7286
+ setTransfer({ label: t("packing", { name: entry.name }), done: 0, total: 0 });
7287
+ }
7288
+ await WorkspaceClient.download(root, entry, (done, total) => setTransfer({ label: t("packing", { name: entry.name }), done, total }));
7289
+ } catch (error) {
7290
+ pi.ui.notify(t("downloadFailed", { message: Host.message(error) }), "error");
7291
+ } finally {
7292
+ setTransfer(undefined);
7293
+ }
7294
+ };
7295
+ const move = async (paths, folder) => {
7296
+ const moving = WorkspaceUtil.movable(paths, folder);
7297
+ if (!moving.length) {
7298
+ return;
7299
+ }
7300
+ const clash = taken(folder, moving.map(WorkspaceUtil.basename));
7301
+ if (clash.length) {
7302
+ pi.ui.notify(t("moveExists", { name: clash[0] }), "error");
7303
+ return;
7304
+ }
7305
+ const reopen = OpenFiles.list().filter((file) => file.kind === "file" && file.cwd === root && moving.some((path) => WorkspaceUtil.within(file.detail, path)));
7306
+ try {
7307
+ await WorkspaceClient.move(root, moving, folder);
7308
+ for (const path of moving) {
7309
+ closeEditorsOf(root, path);
7310
+ }
7311
+ for (const file of reopen) {
7312
+ const to = WorkspaceUtil.movedTo(file.detail, moving, folder);
7313
+ if (to) {
7314
+ openFile(root, to, undefined, { preserveFocus: true });
7315
+ }
7316
+ }
7317
+ expand((previous) => new Set([...previous].map((path) => WorkspaceUtil.movedTo(path, moving, folder) ?? path)));
7318
+ if (folder) {
7319
+ expand((previous) => WorkspaceUtil.reveal(new Set([...previous, folder]), folder));
7320
+ }
7321
+ await load([...new Set([folder, ...moving.map(WorkspaceUtil.dirname)])]);
7322
+ setSelected(WorkspaceUtil.movedTo(moving[0], moving, folder));
7323
+ FilesChanged.notify();
7324
+ } catch (error) {
7325
+ pi.ui.notify(t("moveFailed", { message: Host.message(error) }), "error");
7326
+ }
7327
+ };
7328
+ const showInFileManager = (path) => {
7329
+ desktop?.showItemInFolder(absolute(path)).catch((error) => pi.ui.notify(t("revealFailed", { message: Host.message(error) }), "error"));
7330
+ };
7331
+ const stopDragOpen = () => {
7332
+ clearTimeout(dragOpen.current?.timer);
7333
+ dragOpen.current = undefined;
7334
+ };
7335
+ const dragOver = (event, folder, entry) => {
7336
+ if (!acceptsDrop(event.dataTransfer)) {
7337
+ return;
7338
+ }
7339
+ event.preventDefault();
7340
+ event.stopPropagation();
7341
+ event.dataTransfer.dropEffect = event.dataTransfer.types.includes("Files") ? "copy" : "move";
7342
+ if (dropTarget !== folder) {
7343
+ setDropTarget(folder);
7344
+ }
7345
+ const closed = entry?.kind === "directory" && !tree.expanded.has(entry.path) ? entry : undefined;
7346
+ if (dragOpen.current?.path !== closed?.path) {
7347
+ stopDragOpen();
7348
+ if (closed) {
7349
+ dragOpen.current = { path: closed.path, timer: setTimeout(() => toggle(closed), DRAG_OPEN_MS) };
7350
+ }
7351
+ }
7352
+ };
7353
+ const drop = (event, folder) => {
7354
+ if (!acceptsDrop(event.dataTransfer)) {
7355
+ return;
7356
+ }
7357
+ event.preventDefault();
7358
+ event.stopPropagation();
7359
+ setDropTarget(undefined);
7360
+ stopDragOpen();
7361
+ if (event.dataTransfer.types.includes("Files")) {
7362
+ upload(folder, UploadUtil.fromDrop(event.dataTransfer));
7363
+ return;
7364
+ }
7365
+ const dragged = pi.ui.fileDrag.get(event.dataTransfer);
7366
+ if (dragged?.cwd === root) {
7367
+ move(dragged.paths, folder);
7368
+ }
7369
+ };
5687
7370
  const absolute = (path) => path ? `${root.replace(/\/+$/, "")}/${path}` : root;
5688
7371
  const findInFolder = (path) => {
5689
7372
  SearchRequests.send({ cwd: root, include: path ? `${path}/**` : "" });
@@ -5695,11 +7378,25 @@ function ExplorerView() {
5695
7378
  { label: t("newFile"), run: () => startCreate(false, folder) },
5696
7379
  { label: t("newFolder"), run: () => startCreate(true, folder) }
5697
7380
  ];
7381
+ const fileManager = desktop && showsInFileManager ? [{ label: t(WorkspaceUtil.fileManagerLabel(desktop.platform)), run: () => showInFileManager(entry?.path ?? "") }] : [];
7382
+ const transfers = [
7383
+ { label: t("uploadFiles"), run: () => pickFiles(folder, false) },
7384
+ { label: t("uploadFolder"), run: () => pickFiles(folder, true) },
7385
+ {
7386
+ label: t("download"),
7387
+ run: () => void download(entry ?? { path: "", name: WorkspaceUtil.basename(TaLocation.path(root)) || "workspace", kind: "directory" })
7388
+ }
7389
+ ];
5698
7390
  if (!entry) {
5699
7391
  return [
5700
7392
  ...items,
5701
7393
  "-",
7394
+ ...fileManager,
5702
7395
  { label: t("findInFolder"), run: () => findInFolder("") },
7396
+ "-",
7397
+ ...transfers,
7398
+ "-",
7399
+ { label: t("copyPath"), run: () => copyText(root, t("copied")) },
5703
7400
  { label: t("refresh"), run: () => void load(["", ...tree.expanded]) }
5704
7401
  ];
5705
7402
  }
@@ -5707,8 +7404,11 @@ function ExplorerView() {
5707
7404
  ...items,
5708
7405
  "-",
5709
7406
  ...entry.kind === "file" ? [{ label: t("open"), run: () => openFile(root, entry.path) }] : [],
7407
+ ...fileManager,
5710
7408
  ...entry.kind === "directory" ? [{ label: t("findInFolder"), run: () => findInFolder(entry.path) }] : [],
5711
7409
  "-",
7410
+ ...transfers,
7411
+ "-",
5712
7412
  { label: t("copyPath"), keys: MAC ? "⌥⌘C" : "Shift+Alt+C", run: () => copyText(absolute(entry.path), t("copied")) },
5713
7413
  { label: t("copyRelativePath"), run: () => copyText(entry.path, t("copied")) },
5714
7414
  "-",
@@ -5729,7 +7429,7 @@ function ExplorerView() {
5729
7429
  };
5730
7430
  const onKey = (event, entry, expanded) => {
5731
7431
  const row = event.currentTarget;
5732
- const move = (to) => {
7432
+ const move2 = (to) => {
5733
7433
  const path = to?.dataset.path;
5734
7434
  if (path !== undefined) {
5735
7435
  setSelected(path);
@@ -5742,22 +7442,22 @@ function ExplorerView() {
5742
7442
  if (!expanded) {
5743
7443
  toggle(entry);
5744
7444
  } else {
5745
- move(row.nextElementSibling);
7445
+ move2(row.nextElementSibling);
5746
7446
  }
5747
7447
  } else if (event.key === "ArrowLeft") {
5748
7448
  event.preventDefault();
5749
7449
  if (expanded) {
5750
7450
  toggle(entry);
5751
7451
  } else {
5752
- move(list2.current?.querySelector(`[data-path="${CSS.escape(WorkspaceUtil.dirname(entry.path))}"]`));
7452
+ move2(list2.current?.querySelector(`[data-path="${CSS.escape(WorkspaceUtil.dirname(entry.path))}"]`));
5753
7453
  }
5754
7454
  } else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
5755
7455
  event.preventDefault();
5756
- move(event.key === "ArrowDown" ? row.nextElementSibling : row.previousElementSibling);
7456
+ move2(event.key === "ArrowDown" ? row.nextElementSibling : row.previousElementSibling);
5757
7457
  } else if (event.key === "Home" || event.key === "End") {
5758
7458
  event.preventDefault();
5759
7459
  const rowsShown = all();
5760
- move(event.key === "Home" ? rowsShown[0] : rowsShown[rowsShown.length - 1]);
7460
+ move2(event.key === "Home" ? rowsShown[0] : rowsShown[rowsShown.length - 1]);
5761
7461
  } else if (event.key === "Enter" && MAC) {
5762
7462
  event.preventDefault();
5763
7463
  setEditing({ kind: "rename", path: entry.path });
@@ -5812,7 +7512,7 @@ function ExplorerView() {
5812
7512
  "aria-expanded": entry.kind === "directory" ? expanded : undefined,
5813
7513
  "aria-level": depth + 1,
5814
7514
  "aria-selected": selected === entry.path,
5815
- className: `taw-row taw-tree-row ${selected === entry.path ? "taw-selected" : ""} ${ignored ? "taw-ignored" : ""} ${letter === "D" ? "taw-deleted" : ""}`,
7515
+ className: `taw-row taw-tree-row ${selected === entry.path ? "taw-selected" : ""} ${ignored ? "taw-ignored" : ""} ${letter === "D" ? "taw-deleted" : ""} ${dropTarget && WorkspaceUtil.within(entry.path, dropTarget) ? "taw-drop" : ""}`,
5816
7516
  style: { paddingLeft: 8 + depth * INDENT2 },
5817
7517
  title: letter ? `${entry.path} • ${gitLabel(letter)}` : entry.path,
5818
7518
  onClick: () => !renaming && activate(entry, false),
@@ -5821,7 +7521,15 @@ function ExplorerView() {
5821
7521
  onContextMenu: (event) => {
5822
7522
  setSelected(entry.path);
5823
7523
  openMenu(event, menuFor(entry));
5824
- }
7524
+ },
7525
+ draggable: !renaming,
7526
+ onDragStart: (event) => {
7527
+ setSelected(entry.path);
7528
+ event.dataTransfer.effectAllowed = "copyMove";
7529
+ pi.ui.fileDrag.set(event.dataTransfer, { cwd: root, paths: [entry.path] });
7530
+ },
7531
+ onDragOver: (event) => dragOver(event, entry.kind === "directory" ? entry.path : WorkspaceUtil.dirname(entry.path), entry),
7532
+ onDrop: (event) => drop(event, entry.kind === "directory" ? entry.path : WorkspaceUtil.dirname(entry.path))
5825
7533
  }, /* @__PURE__ */ React.createElement(Guides, {
5826
7534
  depth
5827
7535
  }), /* @__PURE__ */ React.createElement("span", {
@@ -5880,15 +7588,49 @@ function ExplorerView() {
5880
7588
  onClick: () => setPicking(true)
5881
7589
  })), /* @__PURE__ */ React.createElement("div", {
5882
7590
  ref: list2,
5883
- className: "taw-list taw-tree",
7591
+ className: `taw-list taw-tree ${dropTarget === "" ? "taw-drop-root" : ""}`,
5884
7592
  role: "tree",
5885
7593
  "aria-label": t("explorer"),
5886
7594
  onContextMenu: (event) => event.target === event.currentTarget && openMenu(event, menuFor()),
5887
7595
  onClick: (event) => event.target === event.currentTarget && setSelected(undefined),
5888
- onKeyDown: (event) => event.key === "Escape" && setSelected(undefined)
7596
+ onKeyDown: (event) => event.key === "Escape" && setSelected(undefined),
7597
+ onDragOver: (event) => dragOver(event, ""),
7598
+ onDrop: (event) => drop(event, ""),
7599
+ onDragLeave: (event) => {
7600
+ if (!event.currentTarget.contains(event.relatedTarget)) {
7601
+ setDropTarget(undefined);
7602
+ stopDragOpen();
7603
+ }
7604
+ },
7605
+ onDragEnd: () => {
7606
+ setDropTarget(undefined);
7607
+ stopDragOpen();
7608
+ }
5889
7609
  }, tree.error && /* @__PURE__ */ React.createElement(Empty, {
5890
7610
  tone: "error"
5891
- }, t("failed", { message: tree.error })), !tree.error && !tree.children.has("") && /* @__PURE__ */ React.createElement(Empty, null, t("loading")), !tree.error && tree.children.get("")?.length === 0 && !creating && /* @__PURE__ */ React.createElement(Empty, null, t("empty")), shown), menu, picking && /* @__PURE__ */ React.createElement(FolderPicker, {
7611
+ }, t("failed", { message: tree.error })), !tree.error && !tree.children.has("") && /* @__PURE__ */ React.createElement(Empty, null, t("loading")), !tree.error && tree.children.get("")?.length === 0 && !creating && /* @__PURE__ */ React.createElement(Empty, null, t("empty")), shown), transfer && /* @__PURE__ */ React.createElement("div", {
7612
+ className: "taw-transfer",
7613
+ role: "status"
7614
+ }, /* @__PURE__ */ React.createElement("span", null, transfer.label), transfer.total > 0 && /* @__PURE__ */ React.createElement("span", {
7615
+ className: "taw-detail"
7616
+ }, Math.floor(transfer.done / transfer.total * 100), "%"), /* @__PURE__ */ React.createElement("span", {
7617
+ className: "taw-transfer-bar",
7618
+ style: { width: transfer.total > 0 ? `${transfer.done / transfer.total * 100}%` : "0%" }
7619
+ })), /* @__PURE__ */ React.createElement("input", {
7620
+ ref: filePicker,
7621
+ type: "file",
7622
+ multiple: true,
7623
+ hidden: true,
7624
+ onChange: onPicked
7625
+ }), /* @__PURE__ */ React.createElement("input", {
7626
+ ref: (element) => {
7627
+ folderPicker.current = element;
7628
+ element?.setAttribute("webkitdirectory", "");
7629
+ },
7630
+ type: "file",
7631
+ hidden: true,
7632
+ onChange: onPicked
7633
+ }), menu, picking && /* @__PURE__ */ React.createElement(FolderPicker, {
5892
7634
  initial: root,
5893
7635
  onClose: () => setPicking(false),
5894
7636
  onPick: (path) => {
@@ -6348,6 +8090,12 @@ var STYLE = `
6348
8090
  .taw-guides { position: absolute; inset: 0; pointer-events: none; }
6349
8091
  .taw-guide { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ta-border); opacity: 0; transition: opacity 120ms; }
6350
8092
  .taw-tree:hover .taw-guide { opacity: 1; }
8093
+ .taw-tree-row.taw-drop, .taw-tree-row.taw-drop:hover { background: color-mix(in srgb, var(--ta-border-focus) 16%, transparent); }
8094
+ .taw-tree.taw-drop-root { box-shadow: inset 0 0 0 1px var(--ta-border-focus); background: color-mix(in srgb, var(--ta-border-focus) 8%, transparent); }
8095
+ .taw-transfer { position: relative; flex: none; display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px; border-top: 1px solid var(--ta-border-muted); color: var(--ta-secondary); font-size: 12px; overflow: hidden; }
8096
+ .taw-transfer > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
8097
+ .taw-transfer .taw-detail { flex: none; }
8098
+ .taw-transfer-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--ta-border-focus); transition: width 0.2s ease; }
6351
8099
  .taw-editing { cursor: default; background: none !important; }
6352
8100
  .taw-name-input { position: relative; flex: 1; min-width: 0; display: flex; }
6353
8101
  .taw-input.taw-inline { height: 22px; padding: 0 4px; border-radius: 4px; font-size: 13px; }
@@ -6502,11 +8250,35 @@ var STYLE = `
6502
8250
  .taw-text { padding-right: 16px; }
6503
8251
  .taw-hint { flex: none; padding: 4px 12px; border-bottom: 1px solid var(--ta-border-muted); background: var(--ta-raised); color: var(--ta-secondary); font-size: 12px; }
6504
8252
  .taw-frame { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }
6505
- .taw-terminal { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 8px; background: var(--ta-code); color: var(--ta-text); cursor: text; font-family: var(--ta-mono); font-size: 12px; line-height: 18px; }
6506
- .taw-screen { margin: 0; font-family: var(--ta-mono); font-size: 12px; line-height: 18px; white-space: pre; }
6507
- .taw-screen-line { position: relative; min-height: 18px; }
6508
- .taw-cursor { position: absolute; top: 2px; width: 1ch; height: 14px; background: var(--ta-text); opacity: 0.55; pointer-events: none; }
6509
- .taw-terminal:not(:focus-within) .taw-cursor { background: none; outline: 1px solid var(--ta-muted); outline-offset: -1px; }
8253
+ .taw-browser-stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
8254
+ .taw-webview { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }
8255
+ .taw-browser-driven { display: inline-flex; align-items: center; flex: none; gap: 6px; height: 22px; margin-right: 2px; padding: 0 9px 0 8px; border-radius: 11px; background: color-mix(in srgb, var(--ta-green) 14%, transparent); color: var(--ta-green); font-size: 11.5px; white-space: nowrap; }
8256
+ .taw-browser-driven-dot { width: 6px; height: 6px; border-radius: 3px; background: currentColor; animation: taw-pulse 1.2s ease-in-out infinite; }
8257
+ @keyframes taw-pulse { 50% { opacity: 0.35; } }
8258
+ .taw-browser-import { display: inline-flex; align-items: center; gap: 6px; margin-top: 18px; padding: 0; border: 0; background: none; color: var(--ta-secondary); font: inherit; font-size: 12.5px; cursor: pointer; }
8259
+ .taw-browser-import:hover { color: var(--ta-text); text-decoration: underline; text-underline-offset: 3px; }
8260
+ .taw-import { display: flex; flex-direction: column; gap: 12px; width: min(420px, 80vw); font-size: 13px; color: var(--ta-text); }
8261
+ .taw-import-hint { margin: 0; color: var(--ta-secondary); line-height: 1.6; }
8262
+ .taw-import-error { margin: 0; color: var(--ta-red); line-height: 1.5; overflow-wrap: anywhere; }
8263
+ .taw-import-profiles { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; }
8264
+ .taw-import-profile { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
8265
+ .taw-import-profile:hover { background: var(--ta-hover); }
8266
+ .taw-import-profile.taw-on { border-color: var(--ta-border-focus); background: var(--ta-hover); }
8267
+ .taw-import-profile input { position: absolute; opacity: 0; pointer-events: none; }
8268
+ .taw-import-browser { flex: none; font-weight: 500; }
8269
+ .taw-import-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-muted); }
8270
+ .taw-import-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
8271
+ .taw-import-result { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 0 0; }
8272
+ .taw-import-result .taw-import-actions { justify-content: center; margin-top: 18px; }
8273
+ .taw-button.taw-primary { border-color: var(--ta-brand); background: var(--ta-brand); color: var(--ta-brand-text); font-weight: 500; }
8274
+ .taw-button.taw-primary:hover:not(:disabled) { background: var(--ta-brand); opacity: 0.88; }
8275
+ .taw-button:disabled { opacity: 0.45; cursor: default; }
8276
+ .taw-link { padding: 0; border: 0; background: none; color: var(--ta-muted); font: inherit; font-size: 12.5px; cursor: pointer; }
8277
+ .taw-link:hover:not(:disabled) { color: var(--ta-text); text-decoration: underline; text-underline-offset: 3px; }
8278
+ .taw-address-favicon { width: 14px; height: 14px; border-radius: 3px; object-fit: contain; }
8279
+ .taw-browser-failure { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--ta-main); text-align: center; }
8280
+ .taw-browser-failure .taw-browser-sub { max-width: 380px; overflow-wrap: anywhere; }
8281
+ .taw-terminal { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--ta-code); }
6510
8282
  @media (pointer: coarse) {
6511
8283
  .taw-row { height: 36px; }
6512
8284
  .taw-action { width: 32px; height: 32px; }
@@ -6530,7 +8302,6 @@ var STYLE = `
6530
8302
  .taw-terminal-tab > button:first-child { display: flex; align-items: center; gap: 6px; min-width: 0; height: 24px; padding: 0 2px 0 8px; border: 0; background: none; color: inherit; font: inherit; font-size: 12px; cursor: pointer; }
6531
8303
  .taw-terminal-tab > button:first-child > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
6532
8304
  .taw-terminal-tab > .taw-action { width: 20px; height: 20px; }
6533
- .taw-terminal-input { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; resize: none; }
6534
8305
  `;
6535
8306
  function injectStyle() {
6536
8307
  const element = document.createElement("style");
@@ -6541,437 +8312,10 @@ ${STYLE}`;
6541
8312
  return () => element.remove();
6542
8313
  }
6543
8314
 
6544
- // web-src/util/ansi.ts
6545
- var PLAIN = Object.freeze({});
6546
- var ESC = "\x1B";
6547
- var CSI = new RegExp(`^${ESC}\\[([0-?]*)([ -/]*)([@-~])`);
6548
- var DEFAULT_MAX_LINES = 2000;
6549
- var TAB = 8;
6550
-
6551
- class AnsiScreen {
6552
- cols;
6553
- rows;
6554
- maxLines;
6555
- lines = [[]];
6556
- row = 0;
6557
- col = 0;
6558
- style = PLAIN;
6559
- rest = "";
6560
- savedCursor;
6561
- version = 0;
6562
- constructor(cols = 80, rows = 24, maxLines = DEFAULT_MAX_LINES) {
6563
- this.cols = cols;
6564
- this.rows = rows;
6565
- this.maxLines = maxLines;
6566
- }
6567
- resize(cols, rows) {
6568
- this.cols = Math.max(1, cols);
6569
- this.rows = Math.max(1, rows);
6570
- this.version++;
6571
- }
6572
- feed(input) {
6573
- const text = this.rest + input;
6574
- this.rest = "";
6575
- let i = 0;
6576
- while (i < text.length) {
6577
- const char = text[i];
6578
- if (char === "\x1B") {
6579
- const used = this.escape(text, i);
6580
- if (used < 0) {
6581
- this.rest = text.slice(i);
6582
- break;
6583
- }
6584
- i += used;
6585
- continue;
6586
- }
6587
- i++;
6588
- if (char === "\r") {
6589
- this.col = 0;
6590
- } else if (char === `
6591
- `) {
6592
- this.lineFeed();
6593
- } else if (char === "\b") {
6594
- this.col = Math.max(0, this.col - 1);
6595
- } else if (char === "\t") {
6596
- this.col = Math.min(this.cols - 1, (Math.floor(this.col / TAB) + 1) * TAB);
6597
- } else if (char >= " " && char !== "") {
6598
- const code = char.charCodeAt(0);
6599
- if (code >= 55296 && code < 56320 && i < text.length) {
6600
- this.put(char + text[i]);
6601
- i++;
6602
- } else {
6603
- this.put(char);
6604
- }
6605
- }
6606
- }
6607
- this.version++;
6608
- }
6609
- clear() {
6610
- this.lines = [[]];
6611
- this.row = 0;
6612
- this.col = 0;
6613
- this.version++;
6614
- }
6615
- spans() {
6616
- return this.lines.map((line) => {
6617
- const spans = [];
6618
- for (const cell of line) {
6619
- const last = spans[spans.length - 1];
6620
- if (last && last.style === cell.style) {
6621
- last.text += cell.char;
6622
- } else {
6623
- spans.push({ text: cell.char, style: cell.style });
6624
- }
6625
- }
6626
- return spans;
6627
- });
6628
- }
6629
- text() {
6630
- return this.lines.map((line) => line.map((cell) => cell.char).join("").trimEnd()).join(`
6631
- `);
6632
- }
6633
- cursor() {
6634
- return { row: this.row, col: this.col };
6635
- }
6636
- put(char) {
6637
- if (this.col >= this.cols) {
6638
- this.col = 0;
6639
- this.lineFeed();
6640
- }
6641
- const line = this.lines[this.row];
6642
- while (line.length < this.col) {
6643
- line.push({ char: " ", style: PLAIN });
6644
- }
6645
- line[this.col] = { char, style: this.style };
6646
- this.col++;
6647
- }
6648
- lineFeed() {
6649
- this.row++;
6650
- if (this.row === this.lines.length) {
6651
- this.lines.push([]);
6652
- }
6653
- if (this.lines.length > this.maxLines) {
6654
- const drop = this.lines.length - this.maxLines;
6655
- this.lines.splice(0, drop);
6656
- this.row -= drop;
6657
- }
6658
- }
6659
- top() {
6660
- return Math.max(0, this.lines.length - this.rows);
6661
- }
6662
- escape(text, start) {
6663
- const kind = text[start + 1];
6664
- if (kind === undefined) {
6665
- return -1;
6666
- }
6667
- if (kind === "[") {
6668
- const found = CSI.exec(text.slice(start, start + 64));
6669
- if (!found) {
6670
- return text.length - start < 64 ? -1 : 2;
6671
- }
6672
- this.csi(found[1], found[3]);
6673
- return found[0].length;
6674
- }
6675
- if (kind === "]" || kind === "P" || kind === "_" || kind === "^") {
6676
- const bel = text.indexOf("\x07", start + 2);
6677
- const st = text.indexOf("\x1B\\", start + 2);
6678
- const end = bel < 0 ? st : st < 0 ? bel : Math.min(bel, st);
6679
- if (end < 0) {
6680
- return -1;
6681
- }
6682
- return end - start + (end === bel ? 1 : 2);
6683
- }
6684
- if (kind === "(" || kind === ")" || kind === "#") {
6685
- return text.length - start < 3 ? -1 : 3;
6686
- }
6687
- if (kind === "7") {
6688
- this.savedCursor = { row: this.row, col: this.col };
6689
- } else if (kind === "8" && this.savedCursor) {
6690
- ({ row: this.row, col: this.col } = this.savedCursor);
6691
- } else if (kind === "M") {
6692
- this.row = Math.max(this.top(), this.row - 1);
6693
- } else if (kind === "c") {
6694
- this.clear();
6695
- this.style = PLAIN;
6696
- }
6697
- return 2;
6698
- }
6699
- csi(params, final) {
6700
- if (params.startsWith("?") || params.startsWith(">") || params.startsWith("=")) {
6701
- if (/^\?(1049|47|1047)$/.test(params) && (final === "h" || final === "l")) {
6702
- this.eraseScreen(2);
6703
- }
6704
- return;
6705
- }
6706
- const values = params.split(";").map((value) => value === "" ? undefined : Number(value));
6707
- const n = values[0] ?? 1;
6708
- switch (final) {
6709
- case "m":
6710
- this.sgr(values.map((value) => value ?? 0));
6711
- break;
6712
- case "A":
6713
- this.row = Math.max(this.top(), this.row - n);
6714
- break;
6715
- case "B":
6716
- this.moveRow(this.row + n);
6717
- break;
6718
- case "C":
6719
- this.col = Math.min(this.cols - 1, this.col + n);
6720
- break;
6721
- case "D":
6722
- this.col = Math.max(0, this.col - n);
6723
- break;
6724
- case "E":
6725
- this.moveRow(this.row + n);
6726
- this.col = 0;
6727
- break;
6728
- case "F":
6729
- this.row = Math.max(this.top(), this.row - n);
6730
- this.col = 0;
6731
- break;
6732
- case "G":
6733
- this.col = Math.min(this.cols - 1, Math.max(0, n - 1));
6734
- break;
6735
- case "H":
6736
- case "f":
6737
- this.moveRow(this.top() + Math.max(0, (values[0] ?? 1) - 1));
6738
- this.col = Math.min(this.cols - 1, Math.max(0, (values[1] ?? 1) - 1));
6739
- break;
6740
- case "J":
6741
- this.eraseScreen(values[0] ?? 0);
6742
- break;
6743
- case "K":
6744
- this.eraseLine(values[0] ?? 0);
6745
- break;
6746
- case "P":
6747
- this.lines[this.row].splice(this.col, n);
6748
- break;
6749
- case "X":
6750
- for (let i = this.col;i < Math.min(this.col + n, this.lines[this.row].length); i++) {
6751
- this.lines[this.row][i] = { char: " ", style: PLAIN };
6752
- }
6753
- break;
6754
- case "@":
6755
- if (this.col < this.lines[this.row].length) {
6756
- this.lines[this.row].splice(this.col, 0, ...Array.from({ length: n }, () => ({ char: " ", style: PLAIN })));
6757
- }
6758
- break;
6759
- case "s":
6760
- this.savedCursor = { row: this.row, col: this.col };
6761
- break;
6762
- case "u":
6763
- if (this.savedCursor) {
6764
- ({ row: this.row, col: this.col } = this.savedCursor);
6765
- }
6766
- break;
6767
- }
6768
- }
6769
- moveRow(row) {
6770
- while (this.lines.length <= row) {
6771
- this.lines.push([]);
6772
- }
6773
- this.row = row;
6774
- }
6775
- eraseLine(mode) {
6776
- const line = this.lines[this.row];
6777
- if (mode === 0) {
6778
- line.length = Math.min(line.length, this.col);
6779
- } else if (mode === 1) {
6780
- for (let i = 0;i <= Math.min(this.col, line.length - 1); i++) {
6781
- line[i] = { char: " ", style: PLAIN };
6782
- }
6783
- } else {
6784
- line.length = 0;
6785
- }
6786
- }
6787
- eraseScreen(mode) {
6788
- if (mode === 0) {
6789
- this.eraseLine(0);
6790
- this.lines.length = this.row + 1;
6791
- } else if (mode === 1) {
6792
- for (let i = this.top();i < this.row; i++) {
6793
- this.lines[i] = [];
6794
- }
6795
- this.eraseLine(1);
6796
- } else {
6797
- if (mode === 3) {
6798
- this.lines = [[]];
6799
- } else {
6800
- const used = this.lines.length > 1 || this.lines[0].length > 0;
6801
- for (let i = 0;used && i < this.rows; i++) {
6802
- this.lines.push([]);
6803
- }
6804
- }
6805
- this.row = this.top();
6806
- this.col = 0;
6807
- if (this.lines.length > this.maxLines) {
6808
- const drop = this.lines.length - this.maxLines;
6809
- this.lines.splice(0, drop);
6810
- this.row -= drop;
6811
- }
6812
- }
6813
- }
6814
- sgr(values) {
6815
- const style = { ...this.style };
6816
- for (let i = 0;i < values.length; i++) {
6817
- const value = values[i];
6818
- if (value === 0) {
6819
- for (const key of Object.keys(style)) {
6820
- delete style[key];
6821
- }
6822
- } else if (value === 1) {
6823
- style.bold = true;
6824
- } else if (value === 2) {
6825
- style.dim = true;
6826
- } else if (value === 3) {
6827
- style.italic = true;
6828
- } else if (value === 4) {
6829
- style.underline = true;
6830
- } else if (value === 7) {
6831
- style.inverse = true;
6832
- } else if (value === 22) {
6833
- delete style.bold;
6834
- delete style.dim;
6835
- } else if (value === 23) {
6836
- delete style.italic;
6837
- } else if (value === 24) {
6838
- delete style.underline;
6839
- } else if (value === 27) {
6840
- delete style.inverse;
6841
- } else if (value >= 30 && value <= 37) {
6842
- style.fg = value - 30;
6843
- } else if (value >= 90 && value <= 97) {
6844
- style.fg = value - 90 + 8;
6845
- } else if (value === 39) {
6846
- delete style.fg;
6847
- } else if (value >= 40 && value <= 47) {
6848
- style.bg = value - 40;
6849
- } else if (value >= 100 && value <= 107) {
6850
- style.bg = value - 100 + 8;
6851
- } else if (value === 49) {
6852
- delete style.bg;
6853
- } else if (value === 38 || value === 48) {
6854
- const key = value === 38 ? "fg" : "bg";
6855
- if (values[i + 1] === 5 && values[i + 2] !== undefined) {
6856
- style[key] = values[i + 2];
6857
- i += 2;
6858
- } else if (values[i + 1] === 2 && values[i + 4] !== undefined) {
6859
- style[key] = `#${values.slice(i + 2, i + 5).map((part) => Math.min(255, part).toString(16).padStart(2, "0")).join("")}`;
6860
- i += 4;
6861
- }
6862
- }
6863
- }
6864
- this.style = Object.keys(style).length ? style : PLAIN;
6865
- }
6866
- }
6867
- var AnsiUtil;
6868
- ((AnsiUtil) => {
6869
- const BASIC = ["--ta-text", "--ta-red", "--ta-green", "--ta-yellow", "--ta-blue", "#c084fc", "#22d3ee", "--ta-secondary"];
6870
- const STEPS = [0, 95, 135, 175, 215, 255];
6871
- function color(value) {
6872
- if (value === undefined || typeof value === "string") {
6873
- return value;
6874
- }
6875
- if (value < 16) {
6876
- if (value % 8 === 0) {
6877
- return "var(--ta-muted)";
6878
- }
6879
- const name = value === 15 ? "--ta-text" : BASIC[value % 8];
6880
- return name.startsWith("--") ? `var(${name})` : name;
6881
- }
6882
- if (value < 232) {
6883
- const n = value - 16;
6884
- return `rgb(${STEPS[Math.floor(n / 36)]}, ${STEPS[Math.floor(n / 6) % 6]}, ${STEPS[n % 6]})`;
6885
- }
6886
- const gray = 8 + (value - 232) * 10;
6887
- return `rgb(${gray}, ${gray}, ${gray})`;
6888
- }
6889
- AnsiUtil.color = color;
6890
- function css(style) {
6891
- if (style === PLAIN || !Object.keys(style).length) {
6892
- return;
6893
- }
6894
- let fg = color(style.fg);
6895
- let bg = color(style.bg);
6896
- if (style.inverse) {
6897
- [fg, bg] = [bg ?? "var(--ta-main)", fg ?? "var(--ta-text)"];
6898
- }
6899
- const css2 = {};
6900
- if (fg) {
6901
- css2.color = fg;
6902
- }
6903
- if (bg) {
6904
- css2.background = bg;
6905
- }
6906
- if (style.bold) {
6907
- css2.fontWeight = "600";
6908
- }
6909
- if (style.dim) {
6910
- css2.opacity = "0.65";
6911
- }
6912
- if (style.italic) {
6913
- css2.fontStyle = "italic";
6914
- }
6915
- if (style.underline) {
6916
- css2.textDecoration = "underline";
6917
- }
6918
- return css2;
6919
- }
6920
- AnsiUtil.css = css;
6921
- })(AnsiUtil ||= {});
6922
-
6923
- // web-src/util/keys.ts
6924
- var KEYS = {
6925
- Enter: "\r",
6926
- Backspace: "",
6927
- Tab: "\t",
6928
- Escape: "\x1B",
6929
- ArrowUp: "\x1B[A",
6930
- ArrowDown: "\x1B[B",
6931
- ArrowRight: "\x1B[C",
6932
- ArrowLeft: "\x1B[D",
6933
- Home: "\x1B[H",
6934
- End: "\x1B[F",
6935
- Delete: "\x1B[3~",
6936
- Insert: "\x1B[2~",
6937
- PageUp: "\x1B[5~",
6938
- PageDown: "\x1B[6~"
6939
- };
6940
- var TerminalKeys;
6941
- ((TerminalKeys) => {
6942
- function sequence(event) {
6943
- if (event.metaKey) {
6944
- return;
6945
- }
6946
- if (event.key === "Tab" && event.shiftKey) {
6947
- return "\x1B[Z";
6948
- }
6949
- const special = KEYS[event.key];
6950
- if (special) {
6951
- return event.altKey ? `\x1B${special}` : special;
6952
- }
6953
- if (event.ctrlKey && event.key.length === 1) {
6954
- const code = event.key.toUpperCase().charCodeAt(0);
6955
- if (code >= 64 && code <= 95) {
6956
- return String.fromCharCode(code - 64);
6957
- }
6958
- if (event.key === " ") {
6959
- return "\x00";
6960
- }
6961
- }
6962
- return;
6963
- }
6964
- TerminalKeys.sequence = sequence;
6965
- function paste(text) {
6966
- return text.replace(/\r?\n/g, "\r");
6967
- }
6968
- TerminalKeys.paste = paste;
6969
- })(TerminalKeys ||= {});
6970
-
6971
8315
  // web-src/terminal.tsx
6972
- var LINE_HEIGHT = 18;
6973
- var SCROLLBACK = 1000;
6974
8316
  var RESIZE_MS = 120;
8317
+ var OPEN_COLS = 100;
8318
+ var OPEN_ROWS = 30;
6975
8319
  var Terminals;
6976
8320
  ((Terminals) => {
6977
8321
  const sessions = new Map;
@@ -7006,8 +8350,25 @@ var Terminals;
7006
8350
  function add(info) {
7007
8351
  let session = sessions.get(info.terminalId);
7008
8352
  if (!session) {
7009
- session = { info, screen: new AnsiScreen(80, 24, SCROLLBACK) };
7010
- sessions.set(info.terminalId, session);
8353
+ const terminal = pi.ui.createTerminal({ cols: OPEN_COLS, rows: OPEN_ROWS, cwd: info.cwd || undefined });
8354
+ const created = { info, terminal };
8355
+ const id = info.terminalId;
8356
+ terminal.onData((data) => {
8357
+ if (created.exitCode === undefined) {
8358
+ pi.terminals.writeTerminal(id, data).catch(() => {
8359
+ return;
8360
+ });
8361
+ }
8362
+ });
8363
+ let timer;
8364
+ terminal.onResize(({ cols, rows }) => {
8365
+ clearTimeout(timer);
8366
+ timer = setTimeout(() => void pi.terminals.resizeTerminal(id, cols, rows).catch(() => {
8367
+ return;
8368
+ }), RESIZE_MS);
8369
+ });
8370
+ session = created;
8371
+ sessions.set(id, session);
7011
8372
  changed();
7012
8373
  }
7013
8374
  return session;
@@ -7018,18 +8379,20 @@ var Terminals;
7018
8379
  return;
7019
8380
  }
7020
8381
  const session = sessions.get(terminalId) ?? add({ terminalId, cwd: "", shell: "", pty: true });
7021
- session.screen.feed(data);
8382
+ session.terminal.write(data);
7022
8383
  if (exitCode !== undefined && exitCode !== null) {
7023
8384
  session.exitCode = exitCode;
7024
- session.screen.feed(`\r
8385
+ session.terminal.write(`\r
7025
8386
  ${t("terminalEnded", { code: exitCode })}\r
7026
- `);
8387
+ \x1B[?25l`);
8388
+ changed();
7027
8389
  }
7028
- changed();
7029
8390
  }
7030
8391
  Terminals.receive = receive;
7031
8392
  function remove(terminalId) {
7032
- if (sessions.delete(terminalId)) {
8393
+ const session = sessions.get(terminalId);
8394
+ if (session && sessions.delete(terminalId)) {
8395
+ session.terminal.dispose();
7033
8396
  closed.add(terminalId);
7034
8397
  changed();
7035
8398
  }
@@ -7074,7 +8437,7 @@ function TerminalView() {
7074
8437
  opening.current = true;
7075
8438
  try {
7076
8439
  setError(undefined);
7077
- setShown(Terminals.add(await pi.terminals.openTerminal({ cwd, cols: 100, rows: 30 })).info.terminalId);
8440
+ setShown(Terminals.add(await pi.terminals.openTerminal({ cwd, cols: OPEN_COLS, rows: OPEN_ROWS })).info.terminalId);
7078
8441
  } catch (failure) {
7079
8442
  setError(Host.message(failure));
7080
8443
  } finally {
@@ -7151,88 +8514,23 @@ function TerminalView() {
7151
8514
  terminalId: current.info.terminalId
7152
8515
  }));
7153
8516
  }
7154
- function measure(element) {
7155
- const probe = document.createElement("span");
7156
- probe.textContent = "MMMMMMMMMM";
7157
- probe.style.visibility = "hidden";
7158
- probe.style.position = "absolute";
7159
- element.appendChild(probe);
7160
- const width = probe.getBoundingClientRect().width / 10 || 8;
7161
- probe.remove();
7162
- return { width, height: LINE_HEIGHT };
7163
- }
7164
8517
  function TerminalEditor({ terminalId }) {
7165
8518
  useTerminals();
7166
8519
  const session = Terminals.get(terminalId);
7167
8520
  const box = React.useRef(null);
7168
- const input = React.useRef(null);
7169
- const composing = React.useRef(false);
7170
- const pinned = React.useRef(true);
7171
- const write = React.useCallback((data) => void pi.terminals.writeTerminal(terminalId, data).catch(() => {
7172
- return;
7173
- }), [terminalId]);
8521
+ const terminal = session?.terminal;
7174
8522
  React.useEffect(() => {
7175
8523
  const element = box.current;
7176
- if (!element || !session) {
8524
+ if (!element || !terminal) {
7177
8525
  return;
7178
8526
  }
7179
- let timer;
7180
- let last = "";
7181
- const observer = new ResizeObserver(() => {
7182
- if (!element.clientWidth || !element.clientHeight) {
7183
- return;
7184
- }
7185
- const cell = measure(element);
7186
- const cols = Math.max(20, Math.floor((element.clientWidth - 16) / cell.width));
7187
- const rows = Math.max(5, Math.floor((element.clientHeight - 16) / cell.height));
7188
- if (`${cols}x${rows}` === last) {
7189
- return;
7190
- }
7191
- last = `${cols}x${rows}`;
7192
- session.screen.resize(cols, rows);
7193
- clearTimeout(timer);
7194
- timer = setTimeout(() => void pi.terminals.resizeTerminal(terminalId, cols, rows).catch(() => {
7195
- return;
7196
- }), RESIZE_MS);
7197
- });
7198
- observer.observe(element);
7199
- return () => {
7200
- observer.disconnect();
7201
- clearTimeout(timer);
7202
- };
7203
- }, [session, terminalId]);
7204
- React.useEffect(() => input.current?.focus({ preventScroll: true }), []);
7205
- React.useLayoutEffect(() => {
7206
- const element = box.current;
7207
- if (element && pinned.current) {
7208
- element.scrollTop = element.scrollHeight;
7209
- }
7210
- });
8527
+ const detach = terminal.attach(element);
8528
+ terminal.focus();
8529
+ return detach;
8530
+ }, [terminal]);
7211
8531
  if (!session) {
7212
8532
  return /* @__PURE__ */ React.createElement(Empty, null, t("noTerminals"));
7213
8533
  }
7214
- const lines = session.screen.spans();
7215
- const cursor = session.screen.cursor();
7216
- const ended = session.exitCode !== undefined;
7217
- const onKeyDown = (event) => {
7218
- if (composing.current || ended) {
7219
- return;
7220
- }
7221
- const sequence = TerminalKeys.sequence(event);
7222
- if (sequence !== undefined) {
7223
- event.preventDefault();
7224
- write(sequence);
7225
- }
7226
- };
7227
- const flush = () => {
7228
- const element = input.current;
7229
- if (element?.value && !composing.current) {
7230
- if (!ended) {
7231
- write(element.value);
7232
- }
7233
- element.value = "";
7234
- }
7235
- };
7236
8534
  return /* @__PURE__ */ React.createElement("div", {
7237
8535
  className: "taw-editor"
7238
8536
  }, session.info.pty === false && /* @__PURE__ */ React.createElement("div", {
@@ -7240,50 +8538,26 @@ function TerminalEditor({ terminalId }) {
7240
8538
  }, t("pipeMode")), /* @__PURE__ */ React.createElement("div", {
7241
8539
  className: "taw-terminal",
7242
8540
  ref: box,
7243
- role: "presentation",
7244
- onScroll: (event) => {
7245
- const element = event.currentTarget;
7246
- pinned.current = element.scrollHeight - element.scrollTop - element.clientHeight < LINE_HEIGHT;
7247
- },
7248
- onMouseUp: () => {
7249
- if (!window.getSelection()?.toString()) {
7250
- input.current?.focus({ preventScroll: true });
8541
+ onDragOver: (event) => {
8542
+ if (pi.ui.fileDrag.has(event.dataTransfer)) {
8543
+ event.preventDefault();
8544
+ event.dataTransfer.dropEffect = "copy";
7251
8545
  }
7252
- }
7253
- }, /* @__PURE__ */ React.createElement("pre", {
7254
- className: "taw-screen"
7255
- }, lines.map((spans, row) => /* @__PURE__ */ React.createElement("div", {
7256
- key: row,
7257
- className: "taw-screen-line"
7258
- }, spans.map((span, index) => /* @__PURE__ */ React.createElement("span", {
7259
- key: index,
7260
- style: AnsiUtil.css(span.style)
7261
- }, span.text)), row === cursor.row && !ended && /* @__PURE__ */ React.createElement("span", {
7262
- className: "taw-cursor",
7263
- style: { left: `${cursor.col}ch` }
7264
- }), `
7265
- `))), /* @__PURE__ */ React.createElement("textarea", {
7266
- ref: input,
7267
- className: "taw-terminal-input",
7268
- "aria-label": t("terminal"),
7269
- autoCapitalize: "off",
7270
- autoComplete: "off",
7271
- autoCorrect: "off",
7272
- spellCheck: false,
7273
- onKeyDown,
7274
- onInput: flush,
7275
- onCompositionStart: () => composing.current = true,
7276
- onCompositionEnd: () => {
7277
- composing.current = false;
7278
- flush();
7279
8546
  },
7280
- onPaste: (event) => {
7281
- event.preventDefault();
7282
- if (!ended) {
7283
- write(TerminalKeys.paste(event.clipboardData.getData("text")));
8547
+ onDrop: (event) => {
8548
+ const files = pi.ui.fileDrag.get(event.dataTransfer);
8549
+ if (!files || session.exitCode !== undefined) {
8550
+ return;
7284
8551
  }
8552
+ event.preventDefault();
8553
+ const windows = /(^|[\\/])(cmd|powershell|pwsh)(\.exe)?$/i.test(session.info.shell);
8554
+ const words = pi.ui.fileDrag.paths(files).map((path) => WorkspaceUtil.shellQuote(path, windows));
8555
+ pi.terminals.writeTerminal(terminalId, `${words.join(" ")} `).catch(() => {
8556
+ return;
8557
+ });
8558
+ terminal?.focus();
7285
8559
  }
7286
- })));
8560
+ }));
7287
8561
  }
7288
8562
 
7289
8563
  // web-src/index.tsx
@@ -7318,6 +8592,9 @@ function activate(pi2) {
7318
8592
  pi2.on("tool_execution_end", () => FilesChanged.notify());
7319
8593
  pi2.on("agent_end", () => FilesChanged.notify());
7320
8594
  pi2.registerOpener((link2) => openLink(pi2, link2));
8595
+ if (pi2.ui.debugWebview) {
8596
+ pi2.registerTool(AgentBrowser.TOOL);
8597
+ }
7321
8598
  const stopTerminals = pi2.onTerminalData((terminalId, data, exitCode) => Terminals.receive(terminalId, data, exitCode));
7322
8599
  OpenFiles.restore();
7323
8600
  return () => {