shadow-claw 1.34.5 → 1.35.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 (193) hide show
  1. package/.well-known/mcp/server-card.json +1 -1
  2. package/.well-known/mcp.json +1 -1
  3. package/README.md +5 -1
  4. package/dist/cli/chunk-BCLxzLO92.js +5 -0
  5. package/dist/cli/chunk-BHNCi3ui2.js +1 -0
  6. package/dist/cli/chunk-BMPhLSn8.js +1 -0
  7. package/dist/cli/chunk-BMW6QB5-2.js +27 -0
  8. package/dist/cli/chunk-BQCWtrzh.js +1 -0
  9. package/dist/cli/chunk-BQCWtrzh2.js +1 -0
  10. package/dist/cli/chunk-BdJUjMuz.js +1 -0
  11. package/dist/cli/chunk-C47WdxKx2.js +1 -0
  12. package/dist/cli/{chunk-D9dku_3t.js → chunk-CAqvQuGr.js} +1 -1
  13. package/dist/cli/{chunk-DoVxObGa2.js → chunk-CHzhUS1N2.js} +1 -1
  14. package/dist/cli/chunk-CUMlq7Jw2.js +263 -0
  15. package/dist/cli/chunk-CXi9LU9e2.js +110 -0
  16. package/dist/cli/chunk-ChefnX-r.js +110 -0
  17. package/dist/cli/{chunk-zvi71-77.js → chunk-D3JxbzjI2.js} +15 -15
  18. package/dist/cli/chunk-D7VYMl092.js +1 -0
  19. package/dist/cli/chunk-DNIduiJ82.js +91 -0
  20. package/dist/cli/{chunk-C4UfzPK4.js → chunk-DTbrldk_.js} +1 -1
  21. package/dist/cli/chunk-DZ8YBXax.js +969 -0
  22. package/dist/cli/chunk-DduRvw8B2.js +1 -0
  23. package/dist/cli/chunk-DnYxGjdu2.js +1 -0
  24. package/dist/cli/chunk-Ea7nXmgb2.js +1 -0
  25. package/dist/cli/{chunk-BRiGkTIi.js → chunk-EohNY8vW.js} +1 -1
  26. package/dist/cli/chunk-LIIpZlwP2.js +1 -0
  27. package/dist/cli/chunk-LIJZHJml2.js +1 -0
  28. package/dist/cli/chunk-MHBh2BgF2.js +91 -0
  29. package/dist/cli/{chunk-BQ7lHA7c.js → chunk-SKgLGyTY.js} +1 -1
  30. package/dist/cli/chunk-kcJSXcbq2.js +1 -0
  31. package/dist/cli/cli.js +12 -11
  32. package/dist/headless-agent.js +191 -187
  33. package/dist/lib/components/index.js +21 -21
  34. package/dist/lib/components/settings/shadow-claw-channel-config.js +1 -1
  35. package/dist/lib/components/settings/shadow-claw-control-plane.js +1 -1
  36. package/dist/lib/components/settings/shadow-claw-git.js +1 -1
  37. package/dist/lib/components/settings/shadow-claw-llm.js +1 -1
  38. package/dist/lib/components/settings/shadow-claw-networking.js +1 -1
  39. package/dist/lib/components/settings/shadow-claw-notifications.js +1 -1
  40. package/dist/lib/components/settings/shadow-claw-peerjs.js +1 -1
  41. package/dist/lib/components/settings/shadow-claw-storage.js +1 -1
  42. package/dist/lib/components/settings/shadow-claw-task-server.js +1 -1
  43. package/dist/lib/components/settings/shadow-claw-webvm.js +1 -1
  44. package/dist/lib/components/shadow-claw-channel-config.js +1 -1
  45. package/dist/lib/components/shadow-claw-channels.js +1 -1
  46. package/dist/lib/components/shadow-claw-chat.js +1 -1
  47. package/dist/lib/components/shadow-claw-control-plane.js +1 -1
  48. package/dist/lib/components/shadow-claw-conversations.js +1 -1
  49. package/dist/lib/components/shadow-claw-file-viewer.js +1 -1
  50. package/dist/lib/components/shadow-claw-files.js +1 -1
  51. package/dist/lib/components/shadow-claw-git.js +1 -1
  52. package/dist/lib/components/shadow-claw-llm.js +1 -1
  53. package/dist/lib/components/shadow-claw-networking.js +1 -1
  54. package/dist/lib/components/shadow-claw-notifications.js +1 -1
  55. package/dist/lib/components/shadow-claw-pages.js +1 -1
  56. package/dist/lib/components/shadow-claw-peerjs.js +1 -1
  57. package/dist/lib/components/shadow-claw-settings.js +1 -1
  58. package/dist/lib/components/shadow-claw-storage.js +1 -1
  59. package/dist/lib/components/shadow-claw-task-server.js +1 -1
  60. package/dist/lib/components/shadow-claw-tasks.js +1 -1
  61. package/dist/lib/components/shadow-claw-terminal.js +1 -1
  62. package/dist/lib/components/shadow-claw-tools.js +1 -1
  63. package/dist/lib/components/shadow-claw-webvm.js +1 -1
  64. package/dist/lib/components/shadow-claw.js +1 -1
  65. package/dist/lib/{configurePeerJs-DSRcNp3v.js → configurePeerJs-CdPzmpyI.js} +2 -2
  66. package/dist/lib/{configurePeerJs-DSRcNp3v.js.map → configurePeerJs-CdPzmpyI.js.map} +1 -1
  67. package/dist/lib/index.js +21 -21
  68. package/dist/lib/{initControlPlane-CWfE_Oan.js → initControlPlane-BLymRW34.js} +7 -7
  69. package/dist/lib/{initControlPlane-CWfE_Oan.js.map → initControlPlane-BLymRW34.js.map} +1 -1
  70. package/dist/lib/{orchestrator-BEUug1TW.js → orchestrator-DZkhJj7f.js} +13 -2
  71. package/dist/lib/{orchestrator-BEUug1TW.js.map → orchestrator-DZkhJj7f.js.map} +1 -1
  72. package/dist/lib/{orchestrator-CGUzfGbE.js → orchestrator-ZsQTRknI.js} +5 -5
  73. package/dist/lib/{orchestrator-CGUzfGbE.js.map → orchestrator-ZsQTRknI.js.map} +1 -1
  74. package/dist/lib/{peerjs-BSD88rT3.js → peerjs-CJYfnR5V.js} +3 -3
  75. package/dist/lib/{peerjs-BSD88rT3.js.map → peerjs-CJYfnR5V.js.map} +1 -1
  76. package/dist/lib/{push-client-CC3qifgc.js → push-client-C9hIPqLZ.js} +2 -2
  77. package/dist/lib/{push-client-CC3qifgc.js.map → push-client-C9hIPqLZ.js.map} +1 -1
  78. package/dist/lib/{shadow-claw-BWS-UVnE.js → shadow-claw-8qL2-QoK.js} +4 -4
  79. package/dist/lib/{shadow-claw-BWS-UVnE.js.map → shadow-claw-8qL2-QoK.js.map} +1 -1
  80. package/dist/lib/{shadow-claw-channel-config-DwMn3nFJ.js → shadow-claw-channel-config-CvnbqGBy.js} +3 -3
  81. package/dist/lib/{shadow-claw-channel-config-DwMn3nFJ.js.map → shadow-claw-channel-config-CvnbqGBy.js.map} +1 -1
  82. package/dist/lib/{shadow-claw-channels-BdE4cUlx.js → shadow-claw-channels-CkCvjWn1.js} +2 -2
  83. package/dist/lib/{shadow-claw-channels-BdE4cUlx.js.map → shadow-claw-channels-CkCvjWn1.js.map} +1 -1
  84. package/dist/lib/{shadow-claw-chat-DqaMoE9C.js → shadow-claw-chat-B1YEHKN3.js} +3 -3
  85. package/dist/lib/{shadow-claw-chat-DqaMoE9C.js.map → shadow-claw-chat-B1YEHKN3.js.map} +1 -1
  86. package/dist/lib/{shadow-claw-control-plane-D3DUDO29.js → shadow-claw-control-plane-jjo789IE.js} +6 -6
  87. package/dist/lib/{shadow-claw-control-plane-D3DUDO29.js.map → shadow-claw-control-plane-jjo789IE.js.map} +1 -1
  88. package/dist/lib/{shadow-claw-conversations-XT-OXogj.js → shadow-claw-conversations-MMT7wYH3.js} +2 -2
  89. package/dist/lib/{shadow-claw-conversations-XT-OXogj.js.map → shadow-claw-conversations-MMT7wYH3.js.map} +1 -1
  90. package/dist/lib/{shadow-claw-file-viewer-DJqxyd97.js → shadow-claw-file-viewer-qSkD1RQK.js} +2 -2
  91. package/dist/lib/{shadow-claw-file-viewer-DJqxyd97.js.map → shadow-claw-file-viewer-qSkD1RQK.js.map} +1 -1
  92. package/dist/lib/{shadow-claw-files-CUEJlA1o.js → shadow-claw-files-Cg8ycQ_N.js} +2 -2
  93. package/dist/lib/{shadow-claw-files-CUEJlA1o.js.map → shadow-claw-files-Cg8ycQ_N.js.map} +1 -1
  94. package/dist/lib/{shadow-claw-git-D_iVcb86.js → shadow-claw-git-gaClz-ZC.js} +3 -3
  95. package/dist/lib/{shadow-claw-git-D_iVcb86.js.map → shadow-claw-git-gaClz-ZC.js.map} +1 -1
  96. package/dist/lib/{shadow-claw-llm-C2msAsyU.js → shadow-claw-llm-DyOz0qzT.js} +2 -2
  97. package/dist/lib/{shadow-claw-llm-C2msAsyU.js.map → shadow-claw-llm-DyOz0qzT.js.map} +1 -1
  98. package/dist/lib/{shadow-claw-networking-D2NvodC-.js → shadow-claw-networking-B2xx0UUR.js} +2 -2
  99. package/dist/lib/{shadow-claw-networking-D2NvodC-.js.map → shadow-claw-networking-B2xx0UUR.js.map} +1 -1
  100. package/dist/lib/{shadow-claw-notifications-BcvVn_vu.js → shadow-claw-notifications-BjKfZy0k.js} +2 -2
  101. package/dist/lib/{shadow-claw-notifications-BcvVn_vu.js.map → shadow-claw-notifications-BjKfZy0k.js.map} +1 -1
  102. package/dist/lib/{shadow-claw-pages-CTMXRhEX.js → shadow-claw-pages-CJ2tsMtL.js} +2 -2
  103. package/dist/lib/{shadow-claw-pages-CTMXRhEX.js.map → shadow-claw-pages-CJ2tsMtL.js.map} +1 -1
  104. package/dist/lib/{shadow-claw-peerjs-C2YvypqM.js → shadow-claw-peerjs-CazCkXQ1.js} +3 -3
  105. package/dist/lib/{shadow-claw-peerjs-C2YvypqM.js.map → shadow-claw-peerjs-CazCkXQ1.js.map} +1 -1
  106. package/dist/lib/{shadow-claw-settings-B0hiDwEt.js → shadow-claw-settings-qro6pO9I.js} +2 -2
  107. package/dist/lib/{shadow-claw-settings-B0hiDwEt.js.map → shadow-claw-settings-qro6pO9I.js.map} +1 -1
  108. package/dist/lib/{shadow-claw-storage-Dt4yg4Q4.js → shadow-claw-storage-ewDdvCGa.js} +2 -2
  109. package/dist/lib/{shadow-claw-storage-Dt4yg4Q4.js.map → shadow-claw-storage-ewDdvCGa.js.map} +1 -1
  110. package/dist/lib/{shadow-claw-task-server-B2gbZaz4.js → shadow-claw-task-server-DpqQcNIs.js} +2 -2
  111. package/dist/lib/{shadow-claw-task-server-B2gbZaz4.js.map → shadow-claw-task-server-DpqQcNIs.js.map} +1 -1
  112. package/dist/lib/{shadow-claw-tasks-Bxq-niuM.js → shadow-claw-tasks-B2fMF4qE.js} +2 -2
  113. package/dist/lib/{shadow-claw-tasks-Bxq-niuM.js.map → shadow-claw-tasks-B2fMF4qE.js.map} +1 -1
  114. package/dist/lib/{shadow-claw-terminal-BfbW3xtg.js → shadow-claw-terminal-B25kQJC3.js} +2 -2
  115. package/dist/lib/{shadow-claw-terminal-BfbW3xtg.js.map → shadow-claw-terminal-B25kQJC3.js.map} +1 -1
  116. package/dist/lib/{shadow-claw-tools-BNSAaK0Y.js → shadow-claw-tools-B0y8JzoA.js} +10 -3
  117. package/dist/lib/{shadow-claw-tools-BNSAaK0Y.js.map → shadow-claw-tools-B0y8JzoA.js.map} +1 -1
  118. package/dist/lib/{shadow-claw-webvm-Dc2KmEXq.js → shadow-claw-webvm-CoCedIza.js} +2 -2
  119. package/dist/lib/{shadow-claw-webvm-Dc2KmEXq.js.map → shadow-claw-webvm-CoCedIza.js.map} +1 -1
  120. package/dist/lib/{syncWebMcpRegistration-BIL83P0Q.js → syncWebMcpRegistration-JKLALq4e.js} +2 -2
  121. package/dist/lib/{syncWebMcpRegistration-BIL83P0Q.js.map → syncWebMcpRegistration-JKLALq4e.js.map} +1 -1
  122. package/dist/lib/worker/utils/sandboxedEval.d.ts +8 -0
  123. package/dist/public/.well-known/mcp/server-card.json +1 -1
  124. package/dist/public/.well-known/mcp.json +1 -1
  125. package/dist/public/AGENTS.md +1 -1
  126. package/dist/public/README.md +5 -1
  127. package/dist/public/agent.worker.js +1 -1
  128. package/dist/public/components/shadow-claw-tools/shadow-claw-tools.html +1 -1
  129. package/dist/public/{configurePeerJs-B925t9C7.js → configurePeerJs-BrHeJGw1.js} +1 -1
  130. package/dist/public/docs/decisions/headless-cli-agent-participant.md +1 -1
  131. package/dist/public/docs/example/article/index.html +1 -1
  132. package/dist/public/docs/publishing/index.html +1 -1
  133. package/dist/public/docs/skill-creator/index.html +1 -1
  134. package/dist/public/docs/subsystems/cli.md +33 -23
  135. package/dist/public/docs/subsystems/skills.md +17 -0
  136. package/dist/public/docs/subsystems/tools.md +1 -1
  137. package/dist/public/e2e/README.md +2 -2
  138. package/dist/public/{e2e-bridge-CE1xleGn.js → e2e-bridge-D_lyH__p.js} +1 -1
  139. package/dist/public/{executeTool-DtTrsZHV.js → executeTool-b6DnRhcv.js} +2 -1
  140. package/dist/public/{file-viewer-LEEStSq-.js → file-viewer-CKrQoxZi.js} +1 -1
  141. package/dist/public/index.html +1 -1
  142. package/dist/public/index.js +1 -1
  143. package/dist/public/{initControlPlane-e2JgxXEb.js → initControlPlane-Dn-XFuxg.js} +1 -1
  144. package/dist/public/llms.txt +2 -0
  145. package/dist/public/main/index.html +1 -1
  146. package/dist/public/main/memory/index.html +1 -1
  147. package/dist/public/{orchestrator-Baif6kmu.js → orchestrator-0BnBtxHO.js} +3 -2
  148. package/dist/public/{orchestrator-TndREZPL.js → orchestrator-C3GKZriH.js} +1 -1
  149. package/dist/public/{peerjs-DE6WF3h2.js → peerjs-CgfLEp2N.js} +1 -1
  150. package/dist/public/{push-client-B_IkTpNm.js → push-client-D6DLiY1s.js} +1 -1
  151. package/dist/public/service-worker.js +1 -1
  152. package/dist/public/{shadow-claw-channels-BCGz36Zl.js → shadow-claw-channels-DSijinZ9.js} +1 -1
  153. package/dist/public/{shadow-claw-chat-H9U9jbqD.js → shadow-claw-chat-BeHlAjnA.js} +1 -1
  154. package/dist/public/{shadow-claw-control-plane-CeKh64s2.js → shadow-claw-control-plane-BfF_AZSg.js} +2 -2
  155. package/dist/public/{shadow-claw-conversations-C26t1HXN.js → shadow-claw-conversations-Bb_2bVLJ.js} +1 -1
  156. package/dist/public/{shadow-claw-DBeXILmk.js → shadow-claw-f71DlRdV.js} +2 -2
  157. package/dist/public/{shadow-claw-file-viewer-DWUoTjkr.js → shadow-claw-file-viewer-B67000Mm.js} +1 -1
  158. package/dist/public/{shadow-claw-files-BQ8DSX-z.js → shadow-claw-files-DeZZYt01.js} +1 -1
  159. package/dist/public/{shadow-claw-git-CIXyISw-.js → shadow-claw-git-Ccy25LuW.js} +2 -2
  160. package/dist/public/{shadow-claw-llm-D_GpOSZE.js → shadow-claw-llm-XjYcTlXT.js} +1 -1
  161. package/dist/public/{shadow-claw-networking-BYp5K3B7.js → shadow-claw-networking-efXQtydQ.js} +1 -1
  162. package/dist/public/{shadow-claw-notifications-ZiXmPweY.js → shadow-claw-notifications-Cq2ZSeJa.js} +1 -1
  163. package/dist/public/{shadow-claw-pages-BHXwf3BD.js → shadow-claw-pages-BVFNSSb1.js} +1 -1
  164. package/dist/public/{shadow-claw-settings-BfvDvt9c.js → shadow-claw-settings-B3sHxPh9.js} +2 -2
  165. package/dist/public/{shadow-claw-storage-Bvn85DII.js → shadow-claw-storage-DNdlzCgC.js} +1 -1
  166. package/dist/public/{shadow-claw-task-server-DZL_d8FC.js → shadow-claw-task-server-BJq0rpju.js} +1 -1
  167. package/dist/public/{shadow-claw-tasks-Cy8jzd8q.js → shadow-claw-tasks-CkF1uMeZ.js} +1 -1
  168. package/dist/public/{shadow-claw-terminal-BgEXr82T.js → shadow-claw-terminal-CnHhcpA-.js} +1 -1
  169. package/dist/public/{shadow-claw-tools-BjnssRSi.js → shadow-claw-tools-iw0fljud.js} +8 -1
  170. package/dist/public/{shadow-claw-webvm-tZ1VDoVA.js → shadow-claw-webvm-Bliu4V__.js} +1 -1
  171. package/dist/public/{syncWebMcpRegistration-CLMvJ4kV.js → syncWebMcpRegistration-D91usEMu.js} +1 -1
  172. package/package.json +1 -1
  173. package/src/cli/cli.ts +26 -2
  174. package/src/cli/commands/agent.test.ts +421 -0
  175. package/src/cli/commands/agent.ts +270 -20
  176. package/src/components/shadow-claw-tools/shadow-claw-tools.html +7 -0
  177. package/src/worker/headless-agent.ts +14 -0
  178. package/src/worker/headless-types.ts +39 -0
  179. package/src/worker/utils/native-eval-executor.test.ts +36 -0
  180. package/src/worker/utils/native-eval-executor.ts +58 -0
  181. package/src/worker/utils/sandboxedEval.ts +36 -0
  182. package/dist/cli/chunk-1BmpU7jO2.js +0 -1
  183. package/dist/cli/chunk-54Euq8Ji2.js +0 -1
  184. package/dist/cli/chunk-BTitwCgT2.js +0 -88
  185. package/dist/cli/chunk-Bjh76Dai.js +0 -1081
  186. package/dist/cli/chunk-C2HeZQ6K.js +0 -1
  187. package/dist/cli/chunk-CxdpafWg.js +0 -1
  188. package/dist/cli/chunk-DEy72ZNV2.js +0 -88
  189. package/dist/cli/chunk-Da1BZyqf.js +0 -1
  190. package/dist/cli/chunk-FHsJD-Sf2.js +0 -27
  191. package/dist/cli/chunk-aWgoVB7x2.js +0 -1
  192. package/dist/cli/chunk-hOceZVB92.js +0 -371
  193. package/dist/cli/chunk-pwNc6VtC2.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./config-D4lVqMs8.js";import{t}from"./dist-B9m1QM9v.js";import{tn as n}from"./orchestrator-Baif6kmu.js";import{t as r}from"./getGroupDir-CLz5c8cg.js";import{f as i,p as a}from"./tools-BCttQkSs.js";async function o(e,t,n){let i=await r(e,t),{dirs:o,filename:s}=a(n),c=i;for(let e of o)c=await c.getDirectoryHandle(e);return await(await c.getFileHandle(s)).getFile()}const s=new class{_file;constructor(){this._file=new t.State(null)}closeFile(){this._file.set(null)}get file(){return this._file.get()}getFile(){return this.file}getPreviewBinaryMimeType(e){return{"3gp":`video/3gpp`,"7z":`application/x-7z-compressed`,aac:`audio/aac`,apng:`image/apng`,avi:`video/x-msvideo`,avif:`image/avif`,bin:`application/octet-stream`,bmp:`image/bmp`,db:`application/vnd.sqlite3`,dll:`application/octet-stream`,dmg:`application/octet-stream`,dylib:`application/octet-stream`,exe:`application/vnd.microsoft.portable-executable`,flac:`audio/flac`,flv:`video/x-flv`,gif:`image/gif`,gz:`application/gzip`,heic:`image/heic`,heif:`image/heif`,ico:`image/x-icon`,iso:`application/octet-stream`,jpeg:`image/jpeg`,jpg:`image/jpeg`,m4a:`audio/mp4`,m4v:`video/mp4`,mkv:`video/x-matroska`,mov:`video/mp4`,mp3:`audio/mpeg`,mp4:`video/mp4`,oga:`audio/ogg`,ogg:`audio/ogg`,ogv:`video/ogg`,png:`image/png`,rar:`application/vnd.rar`,so:`application/octet-stream`,sqlite:`application/vnd.sqlite3`,sqlite3:`application/vnd.sqlite3`,tar:`application/x-tar`,tif:`image/tiff`,tiff:`image/tiff`,wasm:`application/wasm`,wav:`audio/wav`,weba:`audio/webm`,webm:`video/webm`,webp:`image/webp`,wmv:`video/x-ms-wmv`,zip:`application/zip`}[e.toLowerCase().split(`.`).pop()||``]||``}async openFile(t,r,a=e){try{let e=r.split(`/`).pop()||r,s=/\.pdf$/i.test(e),c=this.getPreviewBinaryMimeType(e);if(s){let i=await n(t,a,r);this._file.set({name:e,path:r,groupId:a,content:``,kind:`pdf`,binaryContent:i,mimeType:`application/pdf`});return}if(c){let n=await o(t,a,r);this._file.set({name:e,path:r,groupId:a,content:``,kind:`binary`,binaryContent:null,nativeFile:n,mimeType:c});return}let l=await i(t,a,r);this._file.set({name:e,path:r,groupId:a,content:l,kind:`text`,binaryContent:null,mimeType:`text/plain`})}catch(e){throw console.error(`Failed to open file:`,r,e),e}}};export{s as t};
1
+ import{o as e}from"./config-D4lVqMs8.js";import{t}from"./dist-B9m1QM9v.js";import{tn as n}from"./orchestrator-0BnBtxHO.js";import{t as r}from"./getGroupDir-CLz5c8cg.js";import{f as i,p as a}from"./tools-BCttQkSs.js";async function o(e,t,n){let i=await r(e,t),{dirs:o,filename:s}=a(n),c=i;for(let e of o)c=await c.getDirectoryHandle(e);return await(await c.getFileHandle(s)).getFile()}const s=new class{_file;constructor(){this._file=new t.State(null)}closeFile(){this._file.set(null)}get file(){return this._file.get()}getFile(){return this.file}getPreviewBinaryMimeType(e){return{"3gp":`video/3gpp`,"7z":`application/x-7z-compressed`,aac:`audio/aac`,apng:`image/apng`,avi:`video/x-msvideo`,avif:`image/avif`,bin:`application/octet-stream`,bmp:`image/bmp`,db:`application/vnd.sqlite3`,dll:`application/octet-stream`,dmg:`application/octet-stream`,dylib:`application/octet-stream`,exe:`application/vnd.microsoft.portable-executable`,flac:`audio/flac`,flv:`video/x-flv`,gif:`image/gif`,gz:`application/gzip`,heic:`image/heic`,heif:`image/heif`,ico:`image/x-icon`,iso:`application/octet-stream`,jpeg:`image/jpeg`,jpg:`image/jpeg`,m4a:`audio/mp4`,m4v:`video/mp4`,mkv:`video/x-matroska`,mov:`video/mp4`,mp3:`audio/mpeg`,mp4:`video/mp4`,oga:`audio/ogg`,ogg:`audio/ogg`,ogv:`video/ogg`,png:`image/png`,rar:`application/vnd.rar`,so:`application/octet-stream`,sqlite:`application/vnd.sqlite3`,sqlite3:`application/vnd.sqlite3`,tar:`application/x-tar`,tif:`image/tiff`,tiff:`image/tiff`,wasm:`application/wasm`,wav:`audio/wav`,weba:`audio/webm`,webm:`video/webm`,webp:`image/webp`,wmv:`video/x-ms-wmv`,zip:`application/zip`}[e.toLowerCase().split(`.`).pop()||``]||``}async openFile(t,r,a=e){try{let e=r.split(`/`).pop()||r,s=/\.pdf$/i.test(e),c=this.getPreviewBinaryMimeType(e);if(s){let i=await n(t,a,r);this._file.set({name:e,path:r,groupId:a,content:``,kind:`pdf`,binaryContent:i,mimeType:`application/pdf`});return}if(c){let n=await o(t,a,r);this._file.set({name:e,path:r,groupId:a,content:``,kind:`binary`,binaryContent:null,nativeFile:n,mimeType:c});return}let l=await i(t,a,r);this._file.set({name:e,path:r,groupId:a,content:l,kind:`text`,binaryContent:null,mimeType:`text/plain`})}catch(e){throw console.error(`Failed to open file:`,r,e),e}}};export{s as t};
@@ -1,4 +1,4 @@
1
- <!doctype html><html lang="en"><head><title>ShadowClaw</title><meta charset="utf-8"><meta name="revision" content="25a61e273c78a4e8d94f73bf714f6584f3c4be4c" /><meta name="version" content="1.34.5" /><meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"><meta name="description" content="ShadowClaw - Browser-native AI agent." /><link rel="canonical" href="https://xt-ml.github.io/shadow-claw/"><meta property="og:title" content="ShadowClaw"><meta property="og:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta property="og:type" content="website"><meta property="og:url" content="https://xt-ml.github.io/shadow-claw/"><meta property="og:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="ShadowClaw"><meta name="twitter:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta name="twitter:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"SoftwareApplication","@id":"https://xt-ml.github.io/shadow-claw/#software","name":"ShadowClaw","description":"Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution.","url":"https://xt-ml.github.io/shadow-claw/","applicationCategory":"DeveloperApplication","operatingSystem":"Web, Browser, Desktop","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"author":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"},"codeRepository":"https://github.com/xt-ml/shadow-claw","license":"https://github.com/xt-ml/shadow-claw/blob/main/LICENSE"},{"@type":"WebSite","@id":"https://xt-ml.github.io/shadow-claw/#website","url":"https://xt-ml.github.io/shadow-claw/","name":"ShadowClaw","description":"Official website and live deployment of ShadowClaw browser-native AI assistant.","publisher":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"}},{"@type":"Organization","@id":"https://xt-ml.github.io/shadow-claw/#organization","name":"xt-ml","url":"https://github.com/xt-ml","sameAs":["https://github.com/xt-ml"]}]}</script><meta name="theme-color" content="#fff" /><meta http-equiv="origin-trial" content="A88uTgESYWcVgREKVReKB6jom41uP8TzW6ei3jNdidf+Xl6ONqKRjKNBphsxhrZmdkakLK3oXDgkGq53rtZYSAMAAAB2eyJvcmlnaW4iOiJodHRwczovL3h0LW1sLmdpdGh1Yi5pbzo0NDMiLCJmZWF0dXJlIjoiV2ViTUNQIiwiZXhwaXJ5IjoxNzk0ODczNjAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><base href="/shadow-claw/" /><script id="shadow-claw-site-config" type="application/json">{"$schema":"https:\u002f\u002fjson-schema.org\u002fdraft\u002f2020-12\u002fschema","site":{"title":"ShadowClaw","description":"ShadowClaw - Browser-native AI agent.","themeColor":"#fff"},"branding":{"faviconPath":"assets\u002ficons\u002ffavicon.ico","appleTouchIconPath":"assets\u002ficons\u002f180.png","notFoundPath":"404.html"},"pwa":{"manifestPath":"manifest.json","themeColor":"#000000"},"sitemapPath":"sitemap.xml","assets":["assets"],"sidebar":{"pagesHidden":false,"chatHidden":false,"tasksHidden":false,"filesHidden":false,"defaultPage":"pages"},"settings":{"defaultToolsProfile":"__builtin_default"},"agent":{"defaultProvider":"transformers_js_local","defaultModel":"onnx-community\u002fgemma-3-1b-it-ONNX-GQA"},"customElements":{"allowedElements":["block-garden","block-garden-option","block-garden-select"],"allowedDomains":["kherrick.github.io","cdn.jsdelivr.net"],"scripts":[{"src":"https:\u002f\u002fkherrick.github.io\u002fblock-garden-knowledge-hub\u002f.agents\u002fscripts\u002fmain\u002fblock-garden-adapter.js","hasInit":true},"https:\u002f\u002fkherrick.github.io\u002fblock-garden\u002fblock-garden-bundle-min.mjs"]},"security":{"connectSrc":["'self'","blob:","data:","https:\u002f\u002fkherrick.github.io","https:\u002f\u002fcdn.jsdelivr.net"]}}</script>
1
+ <!doctype html><html lang="en"><head><title>ShadowClaw</title><meta charset="utf-8"><meta name="revision" content="72143ec88485970231da8c06ecf74089dd580224" /><meta name="version" content="1.35.0" /><meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"><meta name="description" content="ShadowClaw - Browser-native AI agent." /><link rel="canonical" href="https://xt-ml.github.io/shadow-claw/"><meta property="og:title" content="ShadowClaw"><meta property="og:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta property="og:type" content="website"><meta property="og:url" content="https://xt-ml.github.io/shadow-claw/"><meta property="og:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="ShadowClaw"><meta name="twitter:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta name="twitter:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"SoftwareApplication","@id":"https://xt-ml.github.io/shadow-claw/#software","name":"ShadowClaw","description":"Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution.","url":"https://xt-ml.github.io/shadow-claw/","applicationCategory":"DeveloperApplication","operatingSystem":"Web, Browser, Desktop","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"author":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"},"codeRepository":"https://github.com/xt-ml/shadow-claw","license":"https://github.com/xt-ml/shadow-claw/blob/main/LICENSE"},{"@type":"WebSite","@id":"https://xt-ml.github.io/shadow-claw/#website","url":"https://xt-ml.github.io/shadow-claw/","name":"ShadowClaw","description":"Official website and live deployment of ShadowClaw browser-native AI assistant.","publisher":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"}},{"@type":"Organization","@id":"https://xt-ml.github.io/shadow-claw/#organization","name":"xt-ml","url":"https://github.com/xt-ml","sameAs":["https://github.com/xt-ml"]}]}</script><meta name="theme-color" content="#fff" /><meta http-equiv="origin-trial" content="A88uTgESYWcVgREKVReKB6jom41uP8TzW6ei3jNdidf+Xl6ONqKRjKNBphsxhrZmdkakLK3oXDgkGq53rtZYSAMAAAB2eyJvcmlnaW4iOiJodHRwczovL3h0LW1sLmdpdGh1Yi5pbzo0NDMiLCJmZWF0dXJlIjoiV2ViTUNQIiwiZXhwaXJ5IjoxNzk0ODczNjAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><base href="/shadow-claw/" /><script id="shadow-claw-site-config" type="application/json">{"$schema":"https:\u002f\u002fjson-schema.org\u002fdraft\u002f2020-12\u002fschema","site":{"title":"ShadowClaw","description":"ShadowClaw - Browser-native AI agent.","themeColor":"#fff"},"branding":{"faviconPath":"assets\u002ficons\u002ffavicon.ico","appleTouchIconPath":"assets\u002ficons\u002f180.png","notFoundPath":"404.html"},"pwa":{"manifestPath":"manifest.json","themeColor":"#000000"},"sitemapPath":"sitemap.xml","assets":["assets"],"sidebar":{"pagesHidden":false,"chatHidden":false,"tasksHidden":false,"filesHidden":false,"defaultPage":"pages"},"settings":{"defaultToolsProfile":"__builtin_default"},"agent":{"defaultProvider":"transformers_js_local","defaultModel":"onnx-community\u002fgemma-3-1b-it-ONNX-GQA"},"customElements":{"allowedElements":["block-garden","block-garden-option","block-garden-select"],"allowedDomains":["kherrick.github.io","cdn.jsdelivr.net"],"scripts":[{"src":"https:\u002f\u002fkherrick.github.io\u002fblock-garden-knowledge-hub\u002f.agents\u002fscripts\u002fmain\u002fblock-garden-adapter.js","hasInit":true},"https:\u002f\u002fkherrick.github.io\u002fblock-garden\u002fblock-garden-bundle-min.mjs"]},"security":{"connectSrc":["'self'","blob:","data:","https:\u002f\u002fkherrick.github.io","https:\u002f\u002fcdn.jsdelivr.net"]}}</script>
2
2
  <script>var ShadowClawThemeInit=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);function n(){if(globalThis.trustedTypes)return;let e=new Map;globalThis.trustedTypes={createPolicy:(t,n)=>{if(e.has(t))throw TypeError(`Policy with name "${t}" already exists.`);let r={createHTML:n.createHTML?e=>n.createHTML(e):void 0,createScriptURL:n.createScriptURL?e=>n.createScriptURL(e):void 0,createScript:n.createScript?e=>n.createScript(e):void 0};return e.set(t,r),r},getPolicy:t=>e.get(t)??null,isHTML:e=>typeof e==`string`||e instanceof Object&&`toString`in e,isScriptURL:e=>typeof e==`string`||e instanceof Object&&`toString`in e,isScript:e=>typeof e==`string`||e instanceof Object&&`toString`in e}}let r=`__shadowClawDefaultTrustedTypesPolicyState`,i=`default`,a=`shadowclaw-sandbox`;function o(){let e=globalThis;return e[r]||(e[r]={initialized:!1,policy:null}),e[r]}function s(){let e=o();if(e.initialized)return;let t=Reflect.get(globalThis,`trustedTypes`);if(!(!t||typeof t.createPolicy!=`function`)){e.initialized=!0;try{if(typeof t.getPolicy==`function`){let n=t.getPolicy(i);if(n){e.policy=n;return}}let n=!1;if(typeof t.getPolicyNames==`function`){let e=t.getPolicyNames();Array.isArray(e)&&e.includes(i)&&(n=!0)}if(n){if(typeof t.getPolicy==`function`){let n=t.getPolicy(a);if(n){e.policy=n;return}}e.policy=t.createPolicy(a,{createHTML:e=>e,createScriptURL:e=>e});return}e.policy=t.createPolicy(i,{createHTML:e=>e,createScriptURL:e=>e})}catch{typeof t.getPolicy==`function`&&(e.policy=t.getPolicy(i)??t.getPolicy(a)??null)}}}new class{loading=!1;models=new Map;getModelInfo(e){if(!e||typeof e!=`string`)return null;let t=e.toLowerCase().trim(),n=this.models.get(t);if(n)return n;if(t.includes(`/`)){let e=t.split(`/`).pop();if(e&&this.models.has(e))return this.models.get(e)}else for(let[e,n]of this.models.entries())if(e.endsWith(`/${t}`))return n;if(t.includes(`:`)){let e=t.split(`:`)[0],n=this.getModelInfo(e);if(n)return n}return null}registerModelInfo(e,t){this.models.set(e.toLowerCase(),t)}clear(){this.models.clear()}async fetchModelInfo(e,t,n){if(e.modelsUrl){this.loading=!0;try{let r=new Headers;if(r.set(`Content-Type`,`application/json`),e.headers)for(let[t,n]of Object.entries(e.headers))r.set(t,n);if(n)for(let[e,t]of Object.entries(n))r.set(e,t);if(t&&e.apiKeyHeader){let n=e.apiKeyHeaderFormat;r.set(e.apiKeyHeader,n?n.replace(`{key}`,t):t)}let i=await fetch(e.modelsUrl,{headers:r});if(!i.ok)throw Error(`HTTP ${i.status} ${i.statusText}`);let a=await i.json(),o=Array.isArray(a.data)?a.data:Array.isArray(a.models)?a.models:[];for(let e of o){if(!e.id)continue;let t=e.context_length??e.context_window??0,n=e.max_completion_tokens||e.per_request_limits?.completion_tokens||e.top_provider?.max_completion_tokens||null,r=typeof e.supports_tools==`boolean`?e.supports_tools:typeof e.supportsTools==`boolean`?e.supportsTools:void 0,i=this.extractModalities(e,`input`),a=this.extractModalities(e,`output`),o=this.modalitiesInclude(i,`image`,`vision`),s=this.modalitiesInclude(i,`audio`,`voice`,`hearing`),c=this.modalitiesInclude(i,`video`),l=e.id===`openrouter/free`||this.supportedParametersInclude(e,`image`,`vision`,`audio`,`tool`,`structured`),u=this.extractReasoning(e),d=typeof e.supports_prompt_caching==`boolean`?e.supports_prompt_caching:typeof e.supportsPromptCaching==`boolean`?e.supportsPromptCaching:this.supportedParametersInclude(e,`cache_control`,`prompt_caching`)?!0:void 0;!t&&Array.isArray(e.providers)&&e.providers.length>0&&(t=e.providers[0]?.context_length||0),this.registerModelInfo(e.id,{contextWindow:t,maxOutput:n,...r!==void 0&&{supportsTools:r},...i.length>0&&{inputModalities:i},...a.length>0&&{outputModalities:a},...o!==void 0&&{supportsImageInput:o},...s!==void 0&&{supportsAudioInput:s},...c!==void 0&&{supportsVideoInput:c},...u&&{reasoning:u},...l&&{routesByRequestFeatures:l},...d!==void 0&&{supportsPromptCaching:d}})}o.length>0&&console.log(`[ModelRegistry] Registered ${o.length} models for provider "${e.id}"`)}catch(t){console.error(`[ModelRegistry] Error fetching models for ${e.id}:`,t)}finally{this.loading=!1}}}extractModalities(e,t){let n=t===`input`?e.input_modalities||e.inputModalities:e.output_modalities||e.outputModalities,r=e.architecture||{},i=t===`input`?r.input_modalities||r.inputModalities:r.output_modalities||r.outputModalities,a=typeof r.modality==`string`?r.modality:``,o=this.parseArchitectureModality(a,t),s=[...this.normalizeStringArray(n),...this.normalizeStringArray(i),...o];return Array.from(new Set(s))}extractReasoning(e){let t=e?.reasoning;if(!t||typeof t!=`object`)return;let n=this.normalizeStringArray(t.supported_efforts),r=typeof t.default_effort==`string`?t.default_effort.toLowerCase():void 0,i=typeof t.default_enabled==`boolean`?t.default_enabled:void 0,a=typeof t.supports_max_tokens==`boolean`?t.supports_max_tokens:void 0,o=typeof t.mandatory==`boolean`?t.mandatory:void 0;if(!(n.length===0&&r===void 0&&i===void 0&&a===void 0&&o===void 0))return{...n.length>0&&{supportedEfforts:n},...r!==void 0&&{defaultEffort:r},...i!==void 0&&{defaultEnabled:i},...a!==void 0&&{supportsMaxTokens:a},...o!==void 0&&{mandatory:o}}}modalitiesInclude(e,...t){if(e.length!==0)return t.some(t=>e.some(e=>e.includes(t)))}normalizeStringArray(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.toLowerCase()):[]}parseArchitectureModality(e,t){if(!e)return[];let[n=``,r=``]=e.toLowerCase().split(`->`).map(e=>e.trim());return(t===`input`?n:r).split(/[+,/\s]+/).map(e=>e.trim()).filter(Boolean)}supportedParametersInclude(e,...t){let n=this.normalizeStringArray(e.supported_parameters||e.supportedParameters);return t.some(e=>n.some(t=>t.includes(e)))}};function c(e){return e.replace(/^\/+|\/+$/g,``)}function l(e){let t=c(e);return t.endsWith(`/index.html`)?t=t.slice(0,-11):t.endsWith(`index.html`)&&(t=t.slice(0,-10)),c(t)}function u(e){let t=c(e),n=t.split(`/`).filter(Boolean);if(n.length===0)return null;let r=n[0].toLowerCase();if(r===`pages`){if(n.length>=3){let e=n[1];return{page:`pages`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e,path:n.slice(2).join(`/`)}}return{page:`pages`,groupId:`br:main`,path:n.slice(1).join(`/`)}}if(r===`files`){let e=n[1]||`main`;return{page:`files`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e,path:n.slice(2).join(`/`)||void 0}}if(r===`chat`){let e=n[1]||`main`;return{page:`chat`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e}}if(r===`tasks`){let e=n[1]||`main`;return{page:`tasks`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e}}return r===`main`?{page:`pages`,groupId:`br:main`,path:n.slice(1).join(`/`)}:{page:`pages`,groupId:`br:main`,path:t}}function d(){if(typeof document<`u`){let e=document.getElementById(`shadow-claw-static-routing`);if(e&&e.textContent)try{let t=JSON.parse(e.textContent);if(t&&typeof t==`object`&&t.routes)return t}catch(e){console.warn(`Failed to parse embedded static routing manifest:`,e)}}return null}function f(e,t){let n=t||d();if(!n||!n.routes)return null;let r=l(e);if(!r)return null;for(let[e,t]of Object.entries(n.routes))if(!(!t||!t.prettyPath)&&l(t.prettyPath)===r)return u(e);return null}let p=null,ee=new Set([`chat`,`files`,`tasks`,`pages`,`settings`,`tools`,`channels`]);function m(){p=null}typeof globalThis<`u`&&(globalThis.__applyBasePathCacheReset=m);function h(){let e=typeof window<`u`?window:typeof self<`u`?self:globalThis;if(e&&e.__SHADOWCLAW_DEPLOY_ID__){let t=String(e.__SHADOWCLAW_DEPLOY_ID__).trim();if(t)return t.replace(/[^a-zA-Z0-9_-]/g,`-`)}let t=globalThis.process;if(t&&t.env&&t.env.SHADOWCLAW_DEPLOY_ID){let e=String(t.env.SHADOWCLAW_DEPLOY_ID).trim();if(e)return e.replace(/[^a-zA-Z0-9_-]/g,`-`)}let n=te();return!n||n===`/`?``:n.replace(/^\/+|\/+$/g,``).replace(/[^a-zA-Z0-9_-]/g,`-`)}function te(){if(p!==null)return p;if((typeof window>`u`||globalThis.WorkerGlobalScope!==void 0&&typeof self<`u`&&self instanceof globalThis.WorkerGlobalScope)&&typeof self<`u`&&self.location){let e=(self.location.pathname||`/`).split(`/`).filter(Boolean);if(e.length<=1)return p=`/`,p;let t=e[0].toLowerCase(),n=t===`service-worker.js`||t===`sw.js`||t===`manifest.json`||t===`sitemap.xml`||t===`favicon.ico`||t===`index.html`||t===`service-worker`||t===`assets`||t===`dist`||t===`public`;if(n&&e.length===2)return p=`/`,p;if(!n)return p=`/`+e[0]+`/`,p}let e=typeof window<`u`&&window.location?window.location:typeof self<`u`&&self.location?self.location:null;if(!e)return`/`;if(typeof document<`u`&&typeof document.querySelector==`function`){let t=document.querySelector(`base[href]`);if(t){let n=t.getAttribute(`href`);if(n)try{let t=new URL(n,e.origin).pathname;return t.endsWith(`/`)||(t+=`/`),p=t,p}catch{}}}let t=e.pathname||`/`;if(t===`/`)return p=`/`,p;let n=t.split(`/`).filter(Boolean),r=n.findIndex(e=>ee.has(e.toLowerCase()));return r>=0?r===0?(p=`/`,p):(p=`/`+n.slice(0,r).join(`/`)+`/`,p):f(t)?(p=`/`,p):n.length===1&&!t.includes(`.`)?(p=`/`+n[0]+`/`,p):(p=`/`,p)}function ne(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|\\s)@${t}\\b`,`i`)}ne(`ShadowClaw`);function g(){let e=h();return e?`shadowclaw-${e}`:`shadowclaw`}g();let _={github:{providerId:`github`,name:`GitHub`,aliases:[`github`,`api.github.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`token `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://github.com/login/oauth/authorize`,tokenUrl:`https://github.com/login/oauth/access_token`,defaultScopes:[`repo`,`read:user`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},gitlab:{providerId:`gitlab`,name:`GitLab`,aliases:[`gitlab`,`gitlab.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`PRIVATE-TOKEN`,headerPrefix:``},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},tokenAuthByServiceType:{git_remote:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}}},oauth:{authorizeUrl:`https://gitlab.com/oauth/authorize`,tokenUrl:`https://gitlab.com/oauth/token`,defaultScopes:[`read_api`,`read_user`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},figma:{providerId:`figma`,name:`Figma`,aliases:[`figma`,`api.figma.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`X-Figma-Token`,headerPrefix:``},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://www.figma.com/oauth`,tokenUrl:`https://api.figma.com/v1/oauth/token`,refreshUrl:`https://api.figma.com/v1/oauth/refresh`,defaultScopes:[],usePkce:!0,clientAuthMethod:`basic_header`,scopeSeparator:`space`}},notion:{providerId:`notion`,name:`Notion`,aliases:[`notion`,`api.notion.com`,`notion.so`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://api.notion.com/v1/oauth/authorize`,tokenUrl:`https://api.notion.com/v1/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`basic_header`,scopeSeparator:`space`}},microsoft_graph:{providerId:`microsoft_graph`,name:`Microsoft Graph`,aliases:[`microsoft`,`graph.microsoft.com`,`microsoft_graph`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://login.microsoftonline.com/common/oauth2/v2.0/authorize`,tokenUrl:`https://login.microsoftonline.com/common/oauth2/v2.0/token`,defaultScopes:[`openid`,`profile`,`offline_access`,`User.Read`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},yahoo_mail:{providerId:`yahoo_mail`,name:`Yahoo Mail`,aliases:[`yahoo`,`yahoo_mail`,`mail.yahoo.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://api.login.yahoo.com/oauth2/request_auth`,tokenUrl:`https://api.login.yahoo.com/oauth2/get_token`,defaultScopes:[`mail-r`,`mail-w`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},google:{providerId:`google`,name:`Google`,aliases:[`google`,`googleapis.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://accounts.google.com/o/oauth2/v2/auth`,tokenUrl:`https://oauth2.googleapis.com/token`,defaultScopes:[`openid`,`profile`,`email`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},atlassian:{providerId:`atlassian`,name:`Atlassian`,aliases:[`atlassian`,`api.atlassian.com`],modes:[`oauth`,`token`,`basic`],defaultMode:`basic`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`,`basic_userpass`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `},basic:{headerName:`Authorization`,headerPrefix:`Basic `}},oauth:{authorizeUrl:`https://auth.atlassian.com/authorize`,tokenUrl:`https://auth.atlassian.com/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},slack:{providerId:`slack`,name:`Slack`,aliases:[`slack`,`slack.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://slack.com/oauth/v2/authorize`,tokenUrl:`https://slack.com/api/oauth.v2.access`,defaultScopes:[],usePkce:!1,clientAuthMethod:`request_body`,scopeSeparator:`comma`}},linear:{providerId:`linear`,name:`Linear`,aliases:[`linear`,`api.linear.app`,`linear.app`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://linear.app/oauth/authorize`,tokenUrl:`https://api.linear.app/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},azure_devops:{providerId:`azure_devops`,name:`Azure DevOps`,aliases:[`azure_devops`,`dev.azure.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`,`basic_userpass`,`ssh_key`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},tokenAuthByServiceType:{git_remote:{token:{headerName:`Authorization`,headerPrefix:`Basic `},oauth:{headerName:`Authorization`,headerPrefix:`Basic `}}},oauth:{authorizeUrl:`https://app.vssps.visualstudio.com/oauth2/authorize`,tokenUrl:`https://app.vssps.visualstudio.com/oauth2/token`,defaultScopes:[`vso.code`,`vso.profile`,`offline_access`],usePkce:!1,clientAuthMethod:`request_body`,scopeSeparator:`space`}},custom_mcp:{providerId:`custom_mcp`,name:`Custom MCP`,aliases:[`custom_mcp`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`mcp_remote`,`webmcp_local`],authTypes:[`none`,`token`,`oauth`,`custom_header`,`ssh_key`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://example.com/oauth/authorize`,tokenUrl:`https://example.com/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}}};Object.fromEntries(Object.values(_).filter(e=>!!e.oauth).map(e=>{let t=e.oauth;return[e.providerId,{id:e.providerId,name:e.name,authorizeUrl:t.authorizeUrl,tokenUrl:t.tokenUrl,redirectUri:t.redirectUri,defaultScopes:t.defaultScopes,usePkce:t.usePkce,clientAuthMethod:t.clientAuthMethod,scopeSeparator:t.scopeSeparator}]})),Object.fromEntries(Object.values(_).map(e=>[e.providerId,{providerId:e.providerId,modes:e.modes,defaultMode:e.defaultMode}])),new Promise(e=>{});
3
3
  /*! @license DOMPurify 3.4.13 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.13/LICENSE */
4
4
  function v(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function y(e){if(Array.isArray(e))return e}function b(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function re(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
@@ -1 +1 @@
1
- import{a as e,o as t}from"./custom-element-security-CU1rI7Pw.js";import{t as n,wt as r}from"./orchestrator-Baif6kmu.js";import{n as i,t as a}from"./e2e-bridge-CE1xleGn.js";import{n as o,r as s,t as c}from"./constants-DiETpg52.js";async function l(e,t){if(!t){t=!0;try{console.log(`🦞 ShadowClaw initializing...`);let r=e.querySelector(`shadow-claw`)||e.body.appendChild(e.createElement(`shadow-claw`));if(console.log(`✅ ShadowClaw initialized successfully`),t=!1,i()&&(console.log(`🧪 E2E Test Bridge enabled`),a(n,r)),await n.whenReady,typeof window<`u`&&typeof r.orchestrator?.ensureAllConnections==`function`)try{await r.orchestrator.ensureAllConnections({force:!1})}catch(e){console.warn(`[App] Failed to ensure connections on initialize:`,e)}return{orchestrator:r.orchestrator,isInitializing:t}}catch(e){throw console.error(`❌ Failed to initialize ShadowClaw:`,e),e}}}async function u(){await import(`./shadow-claw-DBeXILmk.js`)}if(typeof window<`u`&&!window.__SHADOWCLAW_E2E_ENABLE__)try{Object.defineProperty(window,"fetch",{value:window.fetch,writable:!1,configurable:!1}),window.crypto&&window.crypto.subtle&&Object.defineProperty(window.crypto,"subtle",{value:window.crypto.subtle,writable:!1,configurable:!1})}catch(e){console.warn(`[ShadowClaw] Security: Failed to lock globals:`,e)}t(),e();let d=!1;async function f(){await u(),d=!!(await l(document,d))?.isInitializing}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,async()=>{try{await f()}catch(e){console.error(`Fatal error during initialization:`,e),d=!1}}):f().catch(e=>{console.error(`Fatal error during initialization:`,e),d=!1}),typeof window<`u`&&[`click`,`keydown`,`touchstart`].forEach(e=>{window.addEventListener(e,r,{once:!0})});export{c as BOOT_PENDING_ATTR,o as BOOT_PENDING_CLASS,s as HYDRATION_PENDING_ATTR};
1
+ import{a as e,o as t}from"./custom-element-security-CU1rI7Pw.js";import{t as n,wt as r}from"./orchestrator-0BnBtxHO.js";import{n as i,t as a}from"./e2e-bridge-D_lyH__p.js";import{n as o,r as s,t as c}from"./constants-DiETpg52.js";async function l(e,t){if(!t){t=!0;try{console.log(`🦞 ShadowClaw initializing...`);let r=e.querySelector(`shadow-claw`)||e.body.appendChild(e.createElement(`shadow-claw`));if(console.log(`✅ ShadowClaw initialized successfully`),t=!1,i()&&(console.log(`🧪 E2E Test Bridge enabled`),a(n,r)),await n.whenReady,typeof window<`u`&&typeof r.orchestrator?.ensureAllConnections==`function`)try{await r.orchestrator.ensureAllConnections({force:!1})}catch(e){console.warn(`[App] Failed to ensure connections on initialize:`,e)}return{orchestrator:r.orchestrator,isInitializing:t}}catch(e){throw console.error(`❌ Failed to initialize ShadowClaw:`,e),e}}}async function u(){await import(`./shadow-claw-f71DlRdV.js`)}if(typeof window<`u`&&!window.__SHADOWCLAW_E2E_ENABLE__)try{Object.defineProperty(window,"fetch",{value:window.fetch,writable:!1,configurable:!1}),window.crypto&&window.crypto.subtle&&Object.defineProperty(window.crypto,"subtle",{value:window.crypto.subtle,writable:!1,configurable:!1})}catch(e){console.warn(`[ShadowClaw] Security: Failed to lock globals:`,e)}t(),e();let d=!1;async function f(){await u(),d=!!(await l(document,d))?.isInitializing}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,async()=>{try{await f()}catch(e){console.error(`Fatal error during initialization:`,e),d=!1}}):f().catch(e=>{console.error(`Fatal error during initialization:`,e),d=!1}),typeof window<`u`&&[`click`,`keydown`,`touchstart`].forEach(e=>{window.addEventListener(e,r,{once:!0})});export{c as BOOT_PENDING_ATTR,o as BOOT_PENDING_CLASS,s as HYDRATION_PENDING_ATTR};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{r as t}from"./config-D4lVqMs8.js";import{a as n}from"./app-routes-BMQ4HFaM.js";import{r}from"./txPromise-C2iYogHX.js";import{t as i}from"./browser-nBz_r6l4.js";import{t as a}from"./ulid-BY7rQVLN.js";import{t as o}from"./getAllTasks-CKZML6au.js";var s=e(i(),1),c=class{_transport;_url;_httpUrl;_token;_clientId;_peerId;_deviceLabel;_capabilities;_version;_heartbeatIntervalMs;_reconnectDelayMs;_maxReconnectDelayMs;_handlers;_WebSocketClass;_EventSourceClass;_fetchFn;_ws=null;_es=null;_heartbeatTimer=null;_reconnectTimer=null;_currentReconnectDelay;_isDestroyed=!1;_state=`disconnected`;constructor(e){if(this._transport=e.transport||`sse`,this._clientId=e.clientId,this._peerId=e.peerId,this._deviceLabel=e.deviceLabel||`ShadowClaw Browser Client`,this._capabilities=e.capabilities||[`webmcp`,`opfs`,`push`],this._version=e.version||`1.27.1`,this._token=e.token,this._heartbeatIntervalMs=e.heartbeatIntervalMs||1e4,this._reconnectDelayMs=e.reconnectDelayMs||1e3,this._maxReconnectDelayMs=e.maxReconnectDelayMs||3e4,this._currentReconnectDelay=this._reconnectDelayMs,this._handlers=new Map,this._WebSocketClass=e.WebSocketClass||(typeof WebSocket<`u`?WebSocket:null),this._EventSourceClass=e.EventSourceClass||(typeof EventSource<`u`?EventSource:null),this._fetchFn=e.fetchFn||(typeof fetch<`u`?fetch.bind(globalThis):(()=>Promise.reject(Error(`fetch not available`)))),e.handlers)for(let[t,n]of Object.entries(e.handlers))this.registerHandler(t,n);let t=typeof location<`u`?location:null,n=t?`${t.protocol}//${t.host}`:`http://127.0.0.1:8888`,r=t?`${t.protocol===`https:`?`wss:`:`ws:`}//${t.host}`:`ws://127.0.0.1:8888`;this._url=e.url||`${r}/ws/control`,this._httpUrl=e.httpUrl||n}get transport(){return this._transport}get version(){return this._version}registerHandler(e,t){this._handlers.set(e,t)}unregisterHandler(e){this._handlers.delete(e)}getState(){return this._state}ensureConnected(e=!1){if(this._isDestroyed=!1,this._reconnectTimer&&=(clearTimeout(this._reconnectTimer),null),this._currentReconnectDelay=this._reconnectDelayMs,this._transport===`websocket`){let t=this._ws&&(this._ws.readyState===1||this._ws.readyState===this._WebSocketClass?.OPEN);(e||!t||this._state!==`connected`)&&(this._cleanupConnection(),this.connect())}else{let t=this._es&&(this._es.readyState===1||this._es.readyState===this._EventSourceClass?.OPEN);(e||!t||this._state!==`connected`)&&(this._cleanupConnection(),this.connect())}}connect(){this._isDestroyed||this._state===`connected`||this._state===`connecting`||(this._transport===`websocket`?this._connectWebSocket():this._connectSse())}_connectWebSocket(){if(!this._WebSocketClass){console.warn(`[ControlPlaneClient] WebSocket not supported in this environment`);return}this._state=`connecting`;let e=new URL(this._url,`ws://127.0.0.1:8888`);this._token&&e.searchParams.set(`token`,this._token);try{let t=new this._WebSocketClass(e.toString());this._ws=t,t.onopen=()=>{this._state=`connected`,this._currentReconnectDelay=this._reconnectDelayMs,this._sendRegister(),this._startHeartbeat()},t.onmessage=e=>{this._handleMessage(e.data)},t.onclose=()=>{this._cleanupConnection(),this._isDestroyed||this._scheduleReconnect()},t.onerror=e=>{console.warn(`[ControlPlaneClient] WebSocket error:`,e)}}catch(e){console.warn(`[ControlPlaneClient] Failed to establish WebSocket connection:`,e),this._cleanupConnection(),this._scheduleReconnect()}}_connectSse(){if(!this._EventSourceClass){(s.default===void 0||!s.default.env?.JEST_WORKER_ID)&&console.warn(`[ControlPlaneClient] EventSource not supported in this environment`);return}this._state=`connecting`;let e=new URL(`/api/control/events`,this._httpUrl);e.searchParams.set(`clientId`,this._clientId),this._token&&e.searchParams.set(`token`,this._token);try{let t=new this._EventSourceClass(e.toString());this._es=t,t.onopen=()=>{this._state=`connected`,this._currentReconnectDelay=this._reconnectDelayMs,this._sendRegister(),this._startHeartbeat()},typeof t.addEventListener==`function`&&t.addEventListener(`command:execute`,e=>{this._handleMessage(e.data)}),t.onmessage=e=>{this._handleMessage(e.data)},t.onerror=e=>{console.warn(`[ControlPlaneClient] SSE connection error:`,e),this._cleanupConnection(),this._isDestroyed||this._scheduleReconnect()}}catch(e){console.warn(`[ControlPlaneClient] Failed to establish SSE connection:`,e),this._cleanupConnection(),this._scheduleReconnect()}}disconnect(){this._isDestroyed=!0;try{this._sendUnregister()}catch{}this._cleanupConnection(),this._reconnectTimer&&=(clearTimeout(this._reconnectTimer),null)}_cleanupConnection(){if(this._state=`disconnected`,this._stopHeartbeat(),this._ws){try{this._ws.close()}catch{}this._ws=null}if(this._es){try{this._es.close()}catch{}this._es=null}}_scheduleReconnect(){this._reconnectTimer||this._isDestroyed||(this._reconnectTimer=setTimeout(()=>{this._reconnectTimer=null,this._isDestroyed||this.connect()},this._currentReconnectDelay),this._currentReconnectDelay=Math.min(this._currentReconnectDelay*1.5,this._maxReconnectDelayMs))}_startHeartbeat(){this._stopHeartbeat(),this._heartbeatTimer=setInterval(()=>{this._sendHeartbeat()},this._heartbeatIntervalMs)}_stopHeartbeat(){this._heartbeatTimer&&=(clearInterval(this._heartbeatTimer),null)}_sendRegister(){let e={clientId:this._clientId,deviceLabel:this._deviceLabel,capabilities:this._capabilities,version:this._version,transport:this._transport,peerId:this._peerId};this._sendMessage({id:a(),type:`client:register`,payload:e})}_sendHeartbeat(){let e={clientId:this._clientId,timestamp:Date.now()};this._sendMessage({id:a(),type:`client:heartbeat`,payload:e})}_sendUnregister(){if(!this._clientId)return;let e={clientId:this._clientId};this._sendMessage({id:a(),type:`client:unregister`,payload:e})}_sendMessage(e){if(this._transport===`websocket`){this._ws&&(this._ws.readyState===1||this._ws.readyState===this._WebSocketClass?.OPEN)&&this._ws.send(JSON.stringify(e));return}let t=new URL(`/api/control/messages`,this._httpUrl),n={"Content-Type":`application/json`};this._token&&(n[`x-control-token`]=this._token,n.Authorization=`Bearer ${this._token}`);let r={method:`POST`,headers:n,body:JSON.stringify(e)},i=t.hostname.toLowerCase(),a=i===`localhost`||i===`127.0.0.1`||i===`::1`||i===`[::1]`,o=/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/.test(i);a?r.targetAddressSpace=`loopback`:o&&(r.targetAddressSpace=`private`),this._fetchFn(t.toString(),r).catch(e=>{console.warn(`[ControlPlaneClient] Failed to send message via HTTP POST:`,e)})}async _handleMessage(e){if(!e||typeof e!=`string`)return;let t;try{t=JSON.parse(e)}catch{return}if(t.type===`command:execute`){let{commandId:e,action:n,args:r}=t.payload,i=this._handlers.get(n);if(!i){this._sendMessage({id:a(),type:`command:result`,replyTo:t.id,payload:{commandId:e,success:!1,error:`Unknown action: ${n}`}});return}try{let n=await i(r);this._sendMessage({id:a(),type:`command:result`,replyTo:t.id,payload:{commandId:e,success:!0,data:n}})}catch(n){this._sendMessage({id:a(),type:`command:result`,replyTo:t.id,payload:{commandId:e,success:!1,error:n.message||String(n)}})}}}};function l(){if(typeof localStorage<`u`)try{let e=localStorage.getItem(t.CONTROL_PLANE_CLIENT_ID);if(e&&e.trim())return e.trim()}catch{}let e=n(),r=e?`${e}-${a().toLowerCase()}`:`client-${a().toLowerCase()}`;if(typeof localStorage<`u`)try{localStorage.setItem(t.CONTROL_PLANE_CLIENT_ID,r)}catch{}return r}async function u(e){if(typeof localStorage<`u`)try{let e=localStorage.getItem(t.CONTROL_PLANE_ENABLED);if(e!==null)return e===`true`||e===`1`}catch{}if(e)try{let{getConfig:n}=await import(`./getConfig-4saf0Tkq.js`).then(e=>e.n),r=await n(e,t.CONTROL_PLANE_ENABLED);if(r!=null)return r===`true`||r===`1`}catch{}return!1}function d(e){if(typeof EventSource>`u`&&typeof WebSocket>`u`)return!1;let t=e||(typeof location<`u`?location:null);return!(!t||t.protocol===`file:`||typeof document<`u`&&document.querySelector(`meta[name="shadowclaw-static-only"]`))}function f(e){let n=``;if(typeof localStorage<`u`)try{n=(localStorage.getItem(t.CONTROL_PLANE_URL)||``).trim()}catch{}let r=e||(typeof location<`u`?location:null),i=r&&(r.protocol===`file:`||r.hostname&&(r.hostname.endsWith(`.github.io`)||r.hostname.endsWith(`.pages.dev`))),a=n;a||=i?`http://127.0.0.1:8888`:r&&r.host?`${r.protocol}//${r.host}`:`http://127.0.0.1:8888`,a=a.replace(/\/+$/,``);let o=a.replace(/^https?:/,e=>e===`https:`?`wss:`:`ws:`);return{httpUrl:a,wsUrl:`${o}/ws/control`}}function p(){let e=[];return typeof navigator<`u`&&(navigator.storage&&typeof navigator.storage.getDirectory==`function`&&e.push(`opfs`),`serviceWorker`in navigator&&typeof window<`u`&&`PushManager`in window&&e.push(`push`),(typeof document<`u`&&document.modelContext||navigator&&navigator.modelContext)&&e.push(`webmcp`)),typeof RTCPeerConnection<`u`&&e.push(`peerjs`),e}function m(){if(typeof navigator>`u`)return`ShadowClaw Node`;let e=navigator.userAgent,t=`Desktop`;/iPad/i.test(e)?t=`iPad`:/iPhone/i.test(e)?t=`iPhone`:/Android/i.test(e)?t=`Android`:/Macintosh/i.test(e)?t=`Mac`:/Windows/i.test(e)?t=`Windows`:/Linux/i.test(e)&&(t=`Linux`);let n=`Browser`;return/Chrome/i.test(e)&&!/Edg/i.test(e)?n=`Chrome`:/Safari/i.test(e)&&!/Chrome/i.test(e)?n=`Safari`:/Firefox/i.test(e)?n=`Firefox`:/Edg/i.test(e)&&(n=`Edge`),`${t} ${n}`}function h(){let e=``,t=``;typeof document<`u`&&(e=document.querySelector(`meta[name="version"]`)?.getAttribute(`content`)?.trim()||``,t=document.querySelector(`meta[name="revision"]`)?.getAttribute(`content`)?.trim()||``);let n=t.length>7?t.slice(0,7):t;return e&&n?`${e} (${n})`:e||n||`1.27.1`}let g=null;async function _(e,t={},n={}){let i=l(),a=m(),s=p();switch(e){case`send-message`:{if(!t.text)throw Error(`Missing text parameter`);let{orchestratorStore:e}=await import(`./orchestrator-Baif6kmu.js`).then(e=>e.n),r=n.orchestrator||e.orchestrator,i=t.groupId||e.activeGroupId||`br:main`;return r?.browserChat?.submit?(r.browserChat.submit(t.text,i),{queued:!0,groupId:i}):r?.submitMessage?(r.submitMessage(t.text,i),{queued:!0,groupId:i}):e.sendMessage?(e.sendMessage(t.text),{queued:!0,groupId:i}):{queued:!1,error:`Orchestrator not ready`}}case`list-tasks`:{let e=await o(await r());return t?.groupId&&(e=e.filter(e=>e.groupId===t.groupId)),{tasks:e}}case`read-state`:{let{orchestratorStore:e}=await import(`./orchestrator-Baif6kmu.js`).then(e=>e.n),t=n.orchestrator||e.orchestrator;return{clientId:i,deviceLabel:a,capabilities:s,version:n.version||h(),activeGroupId:n.orchestrator?.activeGroupId||e.activeGroupId||t?.activeGroupId||`br:main`,state:n.orchestrator?.state||e.state||t?.state||`idle`}}case`list-tools`:{try{let{getWebMcpTools:e}=await import(`./webmcp-CcIw3_V3.js`).then(e=>e.a),t=await e();if(t&&t.length>0)return{tools:t.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,annotations:e.annotations}))}}catch{}try{let{orchestratorStore:e}=await import(`./orchestrator-Baif6kmu.js`).then(e=>e.n),r=n.orchestrator||e.orchestrator||(typeof document<`u`?document.querySelector(`shadow-claw`)?.orchestrator:null),i=t.groupId||r?.activeGroupId||e.activeGroupId||`br:main`,a=e.groups.find(e=>e.groupId===i);if(a?.toolTags&&a.toolTags.length>0){let{TOOL_DEFINITIONS:e}=await import(`./tools-CcgG5XuA.js`).then(e=>e.n),{parseWebMcpInputSchema:t}=await import(`./webmcp-CcIw3_V3.js`).then(e=>e.a);return{tools:e.filter(e=>a.toolTags.includes(e.name)).map(e=>({name:e.name,description:e.description,inputSchema:t(e.input_schema)}))}}}catch{}let{TOOL_DEFINITIONS:e}=await import(`./tools-CcgG5XuA.js`).then(e=>e.n),{parseWebMcpInputSchema:r}=await import(`./webmcp-CcIw3_V3.js`).then(e=>e.a);return{tools:e.map(e=>({name:e.name,description:e.description,inputSchema:r(e.input_schema)}))}}case`invoke-tool`:{if(!t.toolName)throw Error(`Missing toolName parameter`);try{let{orchestratorStore:e}=await import(`./orchestrator-Baif6kmu.js`).then(e=>e.n),{toolsStore:r}=await import(`./tools-BCttQkSs.js`).then(e=>e.n),i=n.orchestrator||e.orchestrator||(typeof document<`u`?document.querySelector(`shadow-claw`)?.orchestrator:null),a=t.groupId||i?.activeGroupId||e.activeGroupId||`br:main`,o=e.groups.find(e=>e.groupId===a);if(o?.toolTags&&o.toolTags.length>0){if(!o.toolTags.includes(t.toolName))throw Error(`Tool '${t.toolName}' is not enabled in the active conversation (${a}).`)}else if(r?.allTools&&r.allTools.some(e=>e.name===t.toolName)&&r?.enabledToolNames&&r.enabledToolNames.size>0){let e=r.enabledToolNames.has(t.toolName),n=r.isDeclarativeToolEnabled(t.toolName);if(!e&&!n)throw Error(`Tool '${t.toolName}' is not enabled on this client.`)}}catch(e){if(e.message&&e.message.includes(`is not enabled`))throw e}let e=typeof document<`u`&&document.modelContext||typeof navigator<`u`&&navigator.modelContext;if(e){let n;if(typeof e.getTools==`function`)try{let r=await e.getTools();if(Array.isArray(r)&&r.length>0){if(n=r.find(e=>e.name===t.toolName),!n)throw Error(`Tool '${t.toolName}' is not enabled or registered on this client.`)}else n=Array.isArray(r)?r.find(e=>e.name===t.toolName):void 0;if(n&&typeof n.execute==`function`)return{result:await n.execute(typeof t.input==`string`?JSON.parse(t.input):t.input||{})}}catch(e){if(e.message&&e.message.includes(`is not enabled`))throw e}let{executeWebMcpTool:r}=await import(`./webmcp-CcIw3_V3.js`).then(e=>e.a);if(typeof e.executeTool==`function`){if(n)try{return{result:await r(e,n,t.input)}}catch{}try{return{result:await r(e,{name:t.toolName},t.input)}}catch{}try{return{result:await r(e,t.toolName,t.input)}}catch{}}let i=typeof t.input==`string`?t.input:JSON.stringify(t.input||{});if(typeof navigator<`u`&&navigator.modelContextTesting&&typeof navigator.modelContextTesting.executeTool==`function`)try{return{result:await navigator.modelContextTesting.executeTool(t.toolName,i)}}catch{}if(typeof e.callTool==`function`)try{return{result:await e.callTool({name:t.toolName,arguments:typeof t.input==`string`?JSON.parse(t.input):t.input||{}})}}catch{}if(typeof e.invoke==`function`)try{return{result:await e.invoke(t.toolName,typeof t.input==`string`?JSON.parse(t.input):t.input||{})}}catch{}}let{orchestratorStore:r}=await import(`./orchestrator-Baif6kmu.js`).then(e=>e.n),i=n.orchestrator||r.orchestrator||(typeof document<`u`?document.querySelector(`shadow-claw`)?.orchestrator:null),a=i?.agentWorker;if(a&&typeof a.postMessage==`function`){let e=Date.now().toString(36)+Math.random().toString(36).slice(2),n=t.toolName===`ask_user`,r=t.timeoutMs||(n?3e5:6e4);return{result:await new Promise((n,o)=>{let s=setTimeout(()=>{a.removeEventListener(`message`,c),o(Error(`Timeout waiting for tool execution`))},r),c=t=>{let r=t.data;r&&r.type===`execute-tool-result`&&r.callId===e&&(clearTimeout(s),a.removeEventListener(`message`,c),r.error?o(Error(r.error)):n(r.result))};a.addEventListener(`message`,c),a.postMessage({type:`execute-tool`,callId:e,payload:{name:t.toolName,input:typeof t.input==`string`?JSON.parse(t.input):t.input||{},groupId:t.groupId||i?.activeGroupId||`br:main`}})})}}throw Error(`Tool ${t.toolName} could not be executed (no context or worker available)`)}case`trigger-backup`:{let{orchestratorStore:e}=await import(`./orchestrator-Baif6kmu.js`).then(e=>e.n),a=t.groupId||n.orchestrator?.activeGroupId||e.activeGroupId||`br:main`,o=await r(),{getGroupDir:s}=await import(`./getGroupDir-CLz5c8cg.js`).then(e=>e.n),c=await s(o,a);async function l(e,t=``){let n=[];for await(let[r,i]of e.entries()){let e=t?`${t}/${r}`:r;if(i.kind===`directory`){let t=await l(i,e);n.push(...t)}else n.push(e)}return n}async function u(e){try{let t=e.split(`/`),n=c;for(let e=0;e<t.length-1;e++)n=await n.getDirectoryHandle(t[e]);let r=await(await(await n.getFileHandle(t[t.length-1])).getFile()).arrayBuffer();return new Uint8Array(r)}catch{return null}}let{BackupController:d}=await import(`./backup-controller-CvzDOq4T.js`);return await new d({clientId:i,token:t.token,serverBaseUrl:f().httpUrl,fileEnumerator:()=>l(c),fileReader:e=>u(e)}).initiate()}default:throw Error(`Unknown action '${e}'`)}}function v(e={}){if(g){try{g.disconnect()}catch{}g=null}let n=e.clientId&&e.clientId.trim()||l(),r=p(),i=m(),a=e.version||h(),o=null;if(typeof localStorage<`u`)try{let e=localStorage.getItem(t.CONTROL_PLANE_TRANSPORT);(e===`sse`||e===`websocket`)&&(o=e)}catch{}let s=e.transport||o||`sse`,u;if(typeof localStorage<`u`)try{u=localStorage.getItem(t.PEERJS_MY_PEER_ID)||void 0}catch{}let{httpUrl:v,wsUrl:y}=f(),b=new c({clientId:n,deviceLabel:i,capabilities:r,version:a,peerId:u,transport:s,httpUrl:v,url:y,handlers:{"send-message":t=>_(`send-message`,t,e),"list-tasks":t=>_(`list-tasks`,t,e),"read-state":t=>_(`read-state`,t,e),"invoke-tool":t=>_(`invoke-tool`,t,e),"list-tools":t=>_(`list-tools`,t,e),"trigger-backup":t=>_(`trigger-backup`,t,e)}});return e.autoConnect!==!1&&d()&&b.connect(),g=b,b}function y(){return g}function b(){if(g){try{g.disconnect()}catch{}g=null}}async function x(e={}){let n=e.db;if(!n)try{n=await r()}catch{}if(!await u(n))return b(),null;if(!d())return null;if(typeof localStorage<`u`&&n)try{let{getConfig:e}=await import(`./getConfig-4saf0Tkq.js`).then(e=>e.n),[r,i]=await Promise.all([e(n,t.CONTROL_PLANE_URL),e(n,t.CONTROL_PLANE_TRANSPORT)]);r&&localStorage.setItem(t.CONTROL_PLANE_URL,r),i&&localStorage.setItem(t.CONTROL_PLANE_TRANSPORT,i),localStorage.setItem(t.CONTROL_PLANE_ENABLED,`true`)}catch{}let i=y();return i?(i.ensureConnected(e.force),i):v(e)}export{m as detectDeviceLabel,x as ensureControlPlaneConnected,_ as executeClientControlCommand,l as getOrCreateControlPlaneClientId,u as isControlPlaneEnabled,d as shouldConnectControlPlane,b as stopControlPlaneClient};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{r as t}from"./config-D4lVqMs8.js";import{a as n}from"./app-routes-BMQ4HFaM.js";import{r}from"./txPromise-C2iYogHX.js";import{t as i}from"./browser-nBz_r6l4.js";import{t as a}from"./ulid-BY7rQVLN.js";import{t as o}from"./getAllTasks-CKZML6au.js";var s=e(i(),1),c=class{_transport;_url;_httpUrl;_token;_clientId;_peerId;_deviceLabel;_capabilities;_version;_heartbeatIntervalMs;_reconnectDelayMs;_maxReconnectDelayMs;_handlers;_WebSocketClass;_EventSourceClass;_fetchFn;_ws=null;_es=null;_heartbeatTimer=null;_reconnectTimer=null;_currentReconnectDelay;_isDestroyed=!1;_state=`disconnected`;constructor(e){if(this._transport=e.transport||`sse`,this._clientId=e.clientId,this._peerId=e.peerId,this._deviceLabel=e.deviceLabel||`ShadowClaw Browser Client`,this._capabilities=e.capabilities||[`webmcp`,`opfs`,`push`],this._version=e.version||`1.27.1`,this._token=e.token,this._heartbeatIntervalMs=e.heartbeatIntervalMs||1e4,this._reconnectDelayMs=e.reconnectDelayMs||1e3,this._maxReconnectDelayMs=e.maxReconnectDelayMs||3e4,this._currentReconnectDelay=this._reconnectDelayMs,this._handlers=new Map,this._WebSocketClass=e.WebSocketClass||(typeof WebSocket<`u`?WebSocket:null),this._EventSourceClass=e.EventSourceClass||(typeof EventSource<`u`?EventSource:null),this._fetchFn=e.fetchFn||(typeof fetch<`u`?fetch.bind(globalThis):(()=>Promise.reject(Error(`fetch not available`)))),e.handlers)for(let[t,n]of Object.entries(e.handlers))this.registerHandler(t,n);let t=typeof location<`u`?location:null,n=t?`${t.protocol}//${t.host}`:`http://127.0.0.1:8888`,r=t?`${t.protocol===`https:`?`wss:`:`ws:`}//${t.host}`:`ws://127.0.0.1:8888`;this._url=e.url||`${r}/ws/control`,this._httpUrl=e.httpUrl||n}get transport(){return this._transport}get version(){return this._version}registerHandler(e,t){this._handlers.set(e,t)}unregisterHandler(e){this._handlers.delete(e)}getState(){return this._state}ensureConnected(e=!1){if(this._isDestroyed=!1,this._reconnectTimer&&=(clearTimeout(this._reconnectTimer),null),this._currentReconnectDelay=this._reconnectDelayMs,this._transport===`websocket`){let t=this._ws&&(this._ws.readyState===1||this._ws.readyState===this._WebSocketClass?.OPEN);(e||!t||this._state!==`connected`)&&(this._cleanupConnection(),this.connect())}else{let t=this._es&&(this._es.readyState===1||this._es.readyState===this._EventSourceClass?.OPEN);(e||!t||this._state!==`connected`)&&(this._cleanupConnection(),this.connect())}}connect(){this._isDestroyed||this._state===`connected`||this._state===`connecting`||(this._transport===`websocket`?this._connectWebSocket():this._connectSse())}_connectWebSocket(){if(!this._WebSocketClass){console.warn(`[ControlPlaneClient] WebSocket not supported in this environment`);return}this._state=`connecting`;let e=new URL(this._url,`ws://127.0.0.1:8888`);this._token&&e.searchParams.set(`token`,this._token);try{let t=new this._WebSocketClass(e.toString());this._ws=t,t.onopen=()=>{this._state=`connected`,this._currentReconnectDelay=this._reconnectDelayMs,this._sendRegister(),this._startHeartbeat()},t.onmessage=e=>{this._handleMessage(e.data)},t.onclose=()=>{this._cleanupConnection(),this._isDestroyed||this._scheduleReconnect()},t.onerror=e=>{console.warn(`[ControlPlaneClient] WebSocket error:`,e)}}catch(e){console.warn(`[ControlPlaneClient] Failed to establish WebSocket connection:`,e),this._cleanupConnection(),this._scheduleReconnect()}}_connectSse(){if(!this._EventSourceClass){(s.default===void 0||!s.default.env?.JEST_WORKER_ID)&&console.warn(`[ControlPlaneClient] EventSource not supported in this environment`);return}this._state=`connecting`;let e=new URL(`/api/control/events`,this._httpUrl);e.searchParams.set(`clientId`,this._clientId),this._token&&e.searchParams.set(`token`,this._token);try{let t=new this._EventSourceClass(e.toString());this._es=t,t.onopen=()=>{this._state=`connected`,this._currentReconnectDelay=this._reconnectDelayMs,this._sendRegister(),this._startHeartbeat()},typeof t.addEventListener==`function`&&t.addEventListener(`command:execute`,e=>{this._handleMessage(e.data)}),t.onmessage=e=>{this._handleMessage(e.data)},t.onerror=e=>{console.warn(`[ControlPlaneClient] SSE connection error:`,e),this._cleanupConnection(),this._isDestroyed||this._scheduleReconnect()}}catch(e){console.warn(`[ControlPlaneClient] Failed to establish SSE connection:`,e),this._cleanupConnection(),this._scheduleReconnect()}}disconnect(){this._isDestroyed=!0;try{this._sendUnregister()}catch{}this._cleanupConnection(),this._reconnectTimer&&=(clearTimeout(this._reconnectTimer),null)}_cleanupConnection(){if(this._state=`disconnected`,this._stopHeartbeat(),this._ws){try{this._ws.close()}catch{}this._ws=null}if(this._es){try{this._es.close()}catch{}this._es=null}}_scheduleReconnect(){this._reconnectTimer||this._isDestroyed||(this._reconnectTimer=setTimeout(()=>{this._reconnectTimer=null,this._isDestroyed||this.connect()},this._currentReconnectDelay),this._currentReconnectDelay=Math.min(this._currentReconnectDelay*1.5,this._maxReconnectDelayMs))}_startHeartbeat(){this._stopHeartbeat(),this._heartbeatTimer=setInterval(()=>{this._sendHeartbeat()},this._heartbeatIntervalMs)}_stopHeartbeat(){this._heartbeatTimer&&=(clearInterval(this._heartbeatTimer),null)}_sendRegister(){let e={clientId:this._clientId,deviceLabel:this._deviceLabel,capabilities:this._capabilities,version:this._version,transport:this._transport,peerId:this._peerId};this._sendMessage({id:a(),type:`client:register`,payload:e})}_sendHeartbeat(){let e={clientId:this._clientId,timestamp:Date.now()};this._sendMessage({id:a(),type:`client:heartbeat`,payload:e})}_sendUnregister(){if(!this._clientId)return;let e={clientId:this._clientId};this._sendMessage({id:a(),type:`client:unregister`,payload:e})}_sendMessage(e){if(this._transport===`websocket`){this._ws&&(this._ws.readyState===1||this._ws.readyState===this._WebSocketClass?.OPEN)&&this._ws.send(JSON.stringify(e));return}let t=new URL(`/api/control/messages`,this._httpUrl),n={"Content-Type":`application/json`};this._token&&(n[`x-control-token`]=this._token,n.Authorization=`Bearer ${this._token}`);let r={method:`POST`,headers:n,body:JSON.stringify(e)},i=t.hostname.toLowerCase(),a=i===`localhost`||i===`127.0.0.1`||i===`::1`||i===`[::1]`,o=/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/.test(i);a?r.targetAddressSpace=`loopback`:o&&(r.targetAddressSpace=`private`),this._fetchFn(t.toString(),r).catch(e=>{console.warn(`[ControlPlaneClient] Failed to send message via HTTP POST:`,e)})}async _handleMessage(e){if(!e||typeof e!=`string`)return;let t;try{t=JSON.parse(e)}catch{return}if(t.type===`command:execute`){let{commandId:e,action:n,args:r}=t.payload,i=this._handlers.get(n);if(!i){this._sendMessage({id:a(),type:`command:result`,replyTo:t.id,payload:{commandId:e,success:!1,error:`Unknown action: ${n}`}});return}try{let n=await i(r);this._sendMessage({id:a(),type:`command:result`,replyTo:t.id,payload:{commandId:e,success:!0,data:n}})}catch(n){this._sendMessage({id:a(),type:`command:result`,replyTo:t.id,payload:{commandId:e,success:!1,error:n.message||String(n)}})}}}};function l(){if(typeof localStorage<`u`)try{let e=localStorage.getItem(t.CONTROL_PLANE_CLIENT_ID);if(e&&e.trim())return e.trim()}catch{}let e=n(),r=e?`${e}-${a().toLowerCase()}`:`client-${a().toLowerCase()}`;if(typeof localStorage<`u`)try{localStorage.setItem(t.CONTROL_PLANE_CLIENT_ID,r)}catch{}return r}async function u(e){if(typeof localStorage<`u`)try{let e=localStorage.getItem(t.CONTROL_PLANE_ENABLED);if(e!==null)return e===`true`||e===`1`}catch{}if(e)try{let{getConfig:n}=await import(`./getConfig-4saf0Tkq.js`).then(e=>e.n),r=await n(e,t.CONTROL_PLANE_ENABLED);if(r!=null)return r===`true`||r===`1`}catch{}return!1}function d(e){if(typeof EventSource>`u`&&typeof WebSocket>`u`)return!1;let t=e||(typeof location<`u`?location:null);return!(!t||t.protocol===`file:`||typeof document<`u`&&document.querySelector(`meta[name="shadowclaw-static-only"]`))}function f(e){let n=``;if(typeof localStorage<`u`)try{n=(localStorage.getItem(t.CONTROL_PLANE_URL)||``).trim()}catch{}let r=e||(typeof location<`u`?location:null),i=r&&(r.protocol===`file:`||r.hostname&&(r.hostname.endsWith(`.github.io`)||r.hostname.endsWith(`.pages.dev`))),a=n;a||=i?`http://127.0.0.1:8888`:r&&r.host?`${r.protocol}//${r.host}`:`http://127.0.0.1:8888`,a=a.replace(/\/+$/,``);let o=a.replace(/^https?:/,e=>e===`https:`?`wss:`:`ws:`);return{httpUrl:a,wsUrl:`${o}/ws/control`}}function p(){let e=[];return typeof navigator<`u`&&(navigator.storage&&typeof navigator.storage.getDirectory==`function`&&e.push(`opfs`),`serviceWorker`in navigator&&typeof window<`u`&&`PushManager`in window&&e.push(`push`),(typeof document<`u`&&document.modelContext||navigator&&navigator.modelContext)&&e.push(`webmcp`)),typeof RTCPeerConnection<`u`&&e.push(`peerjs`),e}function m(){if(typeof navigator>`u`)return`ShadowClaw Node`;let e=navigator.userAgent,t=`Desktop`;/iPad/i.test(e)?t=`iPad`:/iPhone/i.test(e)?t=`iPhone`:/Android/i.test(e)?t=`Android`:/Macintosh/i.test(e)?t=`Mac`:/Windows/i.test(e)?t=`Windows`:/Linux/i.test(e)&&(t=`Linux`);let n=`Browser`;return/Chrome/i.test(e)&&!/Edg/i.test(e)?n=`Chrome`:/Safari/i.test(e)&&!/Chrome/i.test(e)?n=`Safari`:/Firefox/i.test(e)?n=`Firefox`:/Edg/i.test(e)&&(n=`Edge`),`${t} ${n}`}function h(){let e=``,t=``;typeof document<`u`&&(e=document.querySelector(`meta[name="version"]`)?.getAttribute(`content`)?.trim()||``,t=document.querySelector(`meta[name="revision"]`)?.getAttribute(`content`)?.trim()||``);let n=t.length>7?t.slice(0,7):t;return e&&n?`${e} (${n})`:e||n||`1.27.1`}let g=null;async function _(e,t={},n={}){let i=l(),a=m(),s=p();switch(e){case`send-message`:{if(!t.text)throw Error(`Missing text parameter`);let{orchestratorStore:e}=await import(`./orchestrator-0BnBtxHO.js`).then(e=>e.n),r=n.orchestrator||e.orchestrator,i=t.groupId||e.activeGroupId||`br:main`;return r?.browserChat?.submit?(r.browserChat.submit(t.text,i),{queued:!0,groupId:i}):r?.submitMessage?(r.submitMessage(t.text,i),{queued:!0,groupId:i}):e.sendMessage?(e.sendMessage(t.text),{queued:!0,groupId:i}):{queued:!1,error:`Orchestrator not ready`}}case`list-tasks`:{let e=await o(await r());return t?.groupId&&(e=e.filter(e=>e.groupId===t.groupId)),{tasks:e}}case`read-state`:{let{orchestratorStore:e}=await import(`./orchestrator-0BnBtxHO.js`).then(e=>e.n),t=n.orchestrator||e.orchestrator;return{clientId:i,deviceLabel:a,capabilities:s,version:n.version||h(),activeGroupId:n.orchestrator?.activeGroupId||e.activeGroupId||t?.activeGroupId||`br:main`,state:n.orchestrator?.state||e.state||t?.state||`idle`}}case`list-tools`:{try{let{getWebMcpTools:e}=await import(`./webmcp-CcIw3_V3.js`).then(e=>e.a),t=await e();if(t&&t.length>0)return{tools:t.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,annotations:e.annotations}))}}catch{}try{let{orchestratorStore:e}=await import(`./orchestrator-0BnBtxHO.js`).then(e=>e.n),r=n.orchestrator||e.orchestrator||(typeof document<`u`?document.querySelector(`shadow-claw`)?.orchestrator:null),i=t.groupId||r?.activeGroupId||e.activeGroupId||`br:main`,a=e.groups.find(e=>e.groupId===i);if(a?.toolTags&&a.toolTags.length>0){let{TOOL_DEFINITIONS:e}=await import(`./tools-CcgG5XuA.js`).then(e=>e.n),{parseWebMcpInputSchema:t}=await import(`./webmcp-CcIw3_V3.js`).then(e=>e.a);return{tools:e.filter(e=>a.toolTags.includes(e.name)).map(e=>({name:e.name,description:e.description,inputSchema:t(e.input_schema)}))}}}catch{}let{TOOL_DEFINITIONS:e}=await import(`./tools-CcgG5XuA.js`).then(e=>e.n),{parseWebMcpInputSchema:r}=await import(`./webmcp-CcIw3_V3.js`).then(e=>e.a);return{tools:e.map(e=>({name:e.name,description:e.description,inputSchema:r(e.input_schema)}))}}case`invoke-tool`:{if(!t.toolName)throw Error(`Missing toolName parameter`);try{let{orchestratorStore:e}=await import(`./orchestrator-0BnBtxHO.js`).then(e=>e.n),{toolsStore:r}=await import(`./tools-BCttQkSs.js`).then(e=>e.n),i=n.orchestrator||e.orchestrator||(typeof document<`u`?document.querySelector(`shadow-claw`)?.orchestrator:null),a=t.groupId||i?.activeGroupId||e.activeGroupId||`br:main`,o=e.groups.find(e=>e.groupId===a);if(o?.toolTags&&o.toolTags.length>0){if(!o.toolTags.includes(t.toolName))throw Error(`Tool '${t.toolName}' is not enabled in the active conversation (${a}).`)}else if(r?.allTools&&r.allTools.some(e=>e.name===t.toolName)&&r?.enabledToolNames&&r.enabledToolNames.size>0){let e=r.enabledToolNames.has(t.toolName),n=r.isDeclarativeToolEnabled(t.toolName);if(!e&&!n)throw Error(`Tool '${t.toolName}' is not enabled on this client.`)}}catch(e){if(e.message&&e.message.includes(`is not enabled`))throw e}let e=typeof document<`u`&&document.modelContext||typeof navigator<`u`&&navigator.modelContext;if(e){let n;if(typeof e.getTools==`function`)try{let r=await e.getTools();if(Array.isArray(r)&&r.length>0){if(n=r.find(e=>e.name===t.toolName),!n)throw Error(`Tool '${t.toolName}' is not enabled or registered on this client.`)}else n=Array.isArray(r)?r.find(e=>e.name===t.toolName):void 0;if(n&&typeof n.execute==`function`)return{result:await n.execute(typeof t.input==`string`?JSON.parse(t.input):t.input||{})}}catch(e){if(e.message&&e.message.includes(`is not enabled`))throw e}let{executeWebMcpTool:r}=await import(`./webmcp-CcIw3_V3.js`).then(e=>e.a);if(typeof e.executeTool==`function`){if(n)try{return{result:await r(e,n,t.input)}}catch{}try{return{result:await r(e,{name:t.toolName},t.input)}}catch{}try{return{result:await r(e,t.toolName,t.input)}}catch{}}let i=typeof t.input==`string`?t.input:JSON.stringify(t.input||{});if(typeof navigator<`u`&&navigator.modelContextTesting&&typeof navigator.modelContextTesting.executeTool==`function`)try{return{result:await navigator.modelContextTesting.executeTool(t.toolName,i)}}catch{}if(typeof e.callTool==`function`)try{return{result:await e.callTool({name:t.toolName,arguments:typeof t.input==`string`?JSON.parse(t.input):t.input||{}})}}catch{}if(typeof e.invoke==`function`)try{return{result:await e.invoke(t.toolName,typeof t.input==`string`?JSON.parse(t.input):t.input||{})}}catch{}}let{orchestratorStore:r}=await import(`./orchestrator-0BnBtxHO.js`).then(e=>e.n),i=n.orchestrator||r.orchestrator||(typeof document<`u`?document.querySelector(`shadow-claw`)?.orchestrator:null),a=i?.agentWorker;if(a&&typeof a.postMessage==`function`){let e=Date.now().toString(36)+Math.random().toString(36).slice(2),n=t.toolName===`ask_user`,r=t.timeoutMs||(n?3e5:6e4);return{result:await new Promise((n,o)=>{let s=setTimeout(()=>{a.removeEventListener(`message`,c),o(Error(`Timeout waiting for tool execution`))},r),c=t=>{let r=t.data;r&&r.type===`execute-tool-result`&&r.callId===e&&(clearTimeout(s),a.removeEventListener(`message`,c),r.error?o(Error(r.error)):n(r.result))};a.addEventListener(`message`,c),a.postMessage({type:`execute-tool`,callId:e,payload:{name:t.toolName,input:typeof t.input==`string`?JSON.parse(t.input):t.input||{},groupId:t.groupId||i?.activeGroupId||`br:main`}})})}}throw Error(`Tool ${t.toolName} could not be executed (no context or worker available)`)}case`trigger-backup`:{let{orchestratorStore:e}=await import(`./orchestrator-0BnBtxHO.js`).then(e=>e.n),a=t.groupId||n.orchestrator?.activeGroupId||e.activeGroupId||`br:main`,o=await r(),{getGroupDir:s}=await import(`./getGroupDir-CLz5c8cg.js`).then(e=>e.n),c=await s(o,a);async function l(e,t=``){let n=[];for await(let[r,i]of e.entries()){let e=t?`${t}/${r}`:r;if(i.kind===`directory`){let t=await l(i,e);n.push(...t)}else n.push(e)}return n}async function u(e){try{let t=e.split(`/`),n=c;for(let e=0;e<t.length-1;e++)n=await n.getDirectoryHandle(t[e]);let r=await(await(await n.getFileHandle(t[t.length-1])).getFile()).arrayBuffer();return new Uint8Array(r)}catch{return null}}let{BackupController:d}=await import(`./backup-controller-CvzDOq4T.js`);return await new d({clientId:i,token:t.token,serverBaseUrl:f().httpUrl,fileEnumerator:()=>l(c),fileReader:e=>u(e)}).initiate()}default:throw Error(`Unknown action '${e}'`)}}function v(e={}){if(g){try{g.disconnect()}catch{}g=null}let n=e.clientId&&e.clientId.trim()||l(),r=p(),i=m(),a=e.version||h(),o=null;if(typeof localStorage<`u`)try{let e=localStorage.getItem(t.CONTROL_PLANE_TRANSPORT);(e===`sse`||e===`websocket`)&&(o=e)}catch{}let s=e.transport||o||`sse`,u;if(typeof localStorage<`u`)try{u=localStorage.getItem(t.PEERJS_MY_PEER_ID)||void 0}catch{}let{httpUrl:v,wsUrl:y}=f(),b=new c({clientId:n,deviceLabel:i,capabilities:r,version:a,peerId:u,transport:s,httpUrl:v,url:y,handlers:{"send-message":t=>_(`send-message`,t,e),"list-tasks":t=>_(`list-tasks`,t,e),"read-state":t=>_(`read-state`,t,e),"invoke-tool":t=>_(`invoke-tool`,t,e),"list-tools":t=>_(`list-tools`,t,e),"trigger-backup":t=>_(`trigger-backup`,t,e)}});return e.autoConnect!==!1&&d()&&b.connect(),g=b,b}function y(){return g}function b(){if(g){try{g.disconnect()}catch{}g=null}}async function x(e={}){let n=e.db;if(!n)try{n=await r()}catch{}if(!await u(n))return b(),null;if(!d())return null;if(typeof localStorage<`u`&&n)try{let{getConfig:e}=await import(`./getConfig-4saf0Tkq.js`).then(e=>e.n),[r,i]=await Promise.all([e(n,t.CONTROL_PLANE_URL),e(n,t.CONTROL_PLANE_TRANSPORT)]);r&&localStorage.setItem(t.CONTROL_PLANE_URL,r),i&&localStorage.setItem(t.CONTROL_PLANE_TRANSPORT,i),localStorage.setItem(t.CONTROL_PLANE_ENABLED,`true`)}catch{}let i=y();return i?(i.ensureConnected(e.force),i):v(e)}export{m as detectDeviceLabel,x as ensureControlPlaneConnected,_ as executeClientControlCommand,l as getOrCreateControlPlaneClientId,u as isControlPlaneEnabled,d as shouldConnectControlPlane,b as stopControlPlaneClient};
@@ -14,6 +14,7 @@ Run instantly without cloning the repo:
14
14
  - `npx shadow-claw agent tools` — Inspect available tools and execution environments.
15
15
  - `npx shadow-claw agent tool <name> [jsonArgs]` — Execute any tool directly from the terminal without model invocation.
16
16
  - `npx shadow-claw agent skills` — List and inspect declarative skills from `.agents/skills/`.
17
+ - `npx shadow-claw agent import <url> [options]` — Discover and import remote RFC v0.2.0 skills, declarative tools, and companion scripts directly into the agent workspace.
17
18
  - `npx shadow-claw agent init <dir>` — Scaffold a headless agent workspace with interactive model selection and prewarming.
18
19
  - `npx shadow-claw init <dir>` — Scaffold a custom template or knowledge hub.
19
20
  - `npx shadow-claw server` — Run headless 24/7 backend services (task scheduler, MCP, REST API).
@@ -28,6 +29,7 @@ ShadowClaw is best suited for:
28
29
  - **Dual-runtime flexibility (browser UI + server CLI):** Seamlessly transition between an interactive web/Electron GUI (with visual A2UI components, chat, files, and tasks) and an autonomous headless agent running directly in terminal pipelines, CI/CD, or automated servers.
29
30
  - **Client-side orchestration of the agentic loop:** When you want the entire agent decision loop—state machine, prompt assembly, dynamic context windowing, and tool dispatch—to execute client-side off the main thread in a browser Web Worker or Electron.
30
31
  - **Host-native server CLI agent (`shadow-claw agent`):** Running autonomous agents directly in Node.js on bare-metal or container servers with host OS shell execution (`child_process`), direct filesystem handles (`NodeFsDirectoryHandle`), SQLite conversation storage, and out-of-the-box in-process Transformers.js ONNX execution (`onnx-community/gemma-3-1b-it-ONNX-GQA`), Llamafile binaries, or OpenRouter (`openrouter/free`).
32
+ - **Remote skill & declarative tool discovery:** Importing decentralized skills and tools from RFC v0.2.0 endpoints directly into browser OPFS or host CLI workspaces via `shadow-claw agent import` without writing custom glue code.
31
33
  - **Direct tool & skill inspection:** Executing agent tools (`shadow-claw agent tool <name> '{"arg":"val"}'`) and declarative skill toolchains directly from scripts or shell pipelines without invoking model inference.
32
34
  - **Zero-install instant launch & CLI driving:** Starting immediately with `npx shadow-claw dev --open`, scaffolding custom templates with `npx shadow-claw init`, or driving connected browser sessions, tasks, and backups through the `shadow-claw` CLI.
33
35
  - **Ultra-safe sandboxed execution:** Running real code, bash, and system operations inside isolated client-side environments—including an in-browser WebVM (v86 Alpine Linux running in WASM inside a Web Worker), `just-bash` POSIX emulation, and sandboxed OPFS/IndexedDB storage.
@@ -1,4 +1,4 @@
1
- <!doctype html><html lang="en"><head><title>ShadowClaw</title><meta charset="utf-8"><meta name="revision" content="25a61e273c78a4e8d94f73bf714f6584f3c4be4c" /><meta name="version" content="1.34.5" /><meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"><meta name="description" content="ShadowClaw - Browser-native AI agent." /><link rel="canonical" href="https://xt-ml.github.io/shadow-claw/"><meta property="og:title" content="ShadowClaw"><meta property="og:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta property="og:type" content="website"><meta property="og:url" content="https://xt-ml.github.io/shadow-claw/"><meta property="og:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="ShadowClaw"><meta name="twitter:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta name="twitter:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"SoftwareApplication","@id":"https://xt-ml.github.io/shadow-claw/#software","name":"ShadowClaw","description":"Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution.","url":"https://xt-ml.github.io/shadow-claw/","applicationCategory":"DeveloperApplication","operatingSystem":"Web, Browser, Desktop","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"author":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"},"codeRepository":"https://github.com/xt-ml/shadow-claw","license":"https://github.com/xt-ml/shadow-claw/blob/main/LICENSE"},{"@type":"WebSite","@id":"https://xt-ml.github.io/shadow-claw/#website","url":"https://xt-ml.github.io/shadow-claw/","name":"ShadowClaw","description":"Official website and live deployment of ShadowClaw browser-native AI assistant.","publisher":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"}},{"@type":"Organization","@id":"https://xt-ml.github.io/shadow-claw/#organization","name":"xt-ml","url":"https://github.com/xt-ml","sameAs":["https://github.com/xt-ml"]}]}</script><meta name="theme-color" content="#fff" /><meta http-equiv="origin-trial" content="A88uTgESYWcVgREKVReKB6jom41uP8TzW6ei3jNdidf+Xl6ONqKRjKNBphsxhrZmdkakLK3oXDgkGq53rtZYSAMAAAB2eyJvcmlnaW4iOiJodHRwczovL3h0LW1sLmdpdGh1Yi5pbzo0NDMiLCJmZWF0dXJlIjoiV2ViTUNQIiwiZXhwaXJ5IjoxNzk0ODczNjAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><base href="/shadow-claw/" /><script id="shadow-claw-site-config" type="application/json">{"$schema":"https:\u002f\u002fjson-schema.org\u002fdraft\u002f2020-12\u002fschema","site":{"title":"ShadowClaw","description":"ShadowClaw - Browser-native AI agent.","themeColor":"#fff"},"branding":{"faviconPath":"assets\u002ficons\u002ffavicon.ico","appleTouchIconPath":"assets\u002ficons\u002f180.png","notFoundPath":"404.html"},"pwa":{"manifestPath":"manifest.json","themeColor":"#000000"},"sitemapPath":"sitemap.xml","assets":["assets"],"sidebar":{"pagesHidden":false,"chatHidden":false,"tasksHidden":false,"filesHidden":false,"defaultPage":"pages"},"settings":{"defaultToolsProfile":"__builtin_default"},"agent":{"defaultProvider":"transformers_js_local","defaultModel":"onnx-community\u002fgemma-3-1b-it-ONNX-GQA"},"customElements":{"allowedElements":["block-garden","block-garden-option","block-garden-select"],"allowedDomains":["kherrick.github.io","cdn.jsdelivr.net"],"scripts":[{"src":"https:\u002f\u002fkherrick.github.io\u002fblock-garden-knowledge-hub\u002f.agents\u002fscripts\u002fmain\u002fblock-garden-adapter.js","hasInit":true},"https:\u002f\u002fkherrick.github.io\u002fblock-garden\u002fblock-garden-bundle-min.mjs"]},"security":{"connectSrc":["'self'","blob:","data:","https:\u002f\u002fkherrick.github.io","https:\u002f\u002fcdn.jsdelivr.net"]}}</script>
1
+ <!doctype html><html lang="en"><head><title>ShadowClaw</title><meta charset="utf-8"><meta name="revision" content="72143ec88485970231da8c06ecf74089dd580224" /><meta name="version" content="1.35.0" /><meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"><meta name="description" content="ShadowClaw - Browser-native AI agent." /><link rel="canonical" href="https://xt-ml.github.io/shadow-claw/"><meta property="og:title" content="ShadowClaw"><meta property="og:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta property="og:type" content="website"><meta property="og:url" content="https://xt-ml.github.io/shadow-claw/"><meta property="og:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="ShadowClaw"><meta name="twitter:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta name="twitter:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"SoftwareApplication","@id":"https://xt-ml.github.io/shadow-claw/#software","name":"ShadowClaw","description":"Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution.","url":"https://xt-ml.github.io/shadow-claw/","applicationCategory":"DeveloperApplication","operatingSystem":"Web, Browser, Desktop","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"author":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"},"codeRepository":"https://github.com/xt-ml/shadow-claw","license":"https://github.com/xt-ml/shadow-claw/blob/main/LICENSE"},{"@type":"WebSite","@id":"https://xt-ml.github.io/shadow-claw/#website","url":"https://xt-ml.github.io/shadow-claw/","name":"ShadowClaw","description":"Official website and live deployment of ShadowClaw browser-native AI assistant.","publisher":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"}},{"@type":"Organization","@id":"https://xt-ml.github.io/shadow-claw/#organization","name":"xt-ml","url":"https://github.com/xt-ml","sameAs":["https://github.com/xt-ml"]}]}</script><meta name="theme-color" content="#fff" /><meta http-equiv="origin-trial" content="A88uTgESYWcVgREKVReKB6jom41uP8TzW6ei3jNdidf+Xl6ONqKRjKNBphsxhrZmdkakLK3oXDgkGq53rtZYSAMAAAB2eyJvcmlnaW4iOiJodHRwczovL3h0LW1sLmdpdGh1Yi5pbzo0NDMiLCJmZWF0dXJlIjoiV2ViTUNQIiwiZXhwaXJ5IjoxNzk0ODczNjAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><base href="/shadow-claw/" /><script id="shadow-claw-site-config" type="application/json">{"$schema":"https:\u002f\u002fjson-schema.org\u002fdraft\u002f2020-12\u002fschema","site":{"title":"ShadowClaw","description":"ShadowClaw - Browser-native AI agent.","themeColor":"#fff"},"branding":{"faviconPath":"assets\u002ficons\u002ffavicon.ico","appleTouchIconPath":"assets\u002ficons\u002f180.png","notFoundPath":"404.html"},"pwa":{"manifestPath":"manifest.json","themeColor":"#000000"},"sitemapPath":"sitemap.xml","assets":["assets"],"sidebar":{"pagesHidden":false,"chatHidden":false,"tasksHidden":false,"filesHidden":false,"defaultPage":"pages"},"settings":{"defaultToolsProfile":"__builtin_default"},"agent":{"defaultProvider":"transformers_js_local","defaultModel":"onnx-community\u002fgemma-3-1b-it-ONNX-GQA"},"customElements":{"allowedElements":["block-garden","block-garden-option","block-garden-select"],"allowedDomains":["kherrick.github.io","cdn.jsdelivr.net"],"scripts":[{"src":"https:\u002f\u002fkherrick.github.io\u002fblock-garden-knowledge-hub\u002f.agents\u002fscripts\u002fmain\u002fblock-garden-adapter.js","hasInit":true},"https:\u002f\u002fkherrick.github.io\u002fblock-garden\u002fblock-garden-bundle-min.mjs"]},"security":{"connectSrc":["'self'","blob:","data:","https:\u002f\u002fkherrick.github.io","https:\u002f\u002fcdn.jsdelivr.net"]}}</script>
2
2
  <script>var ShadowClawThemeInit=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);function n(){if(globalThis.trustedTypes)return;let e=new Map;globalThis.trustedTypes={createPolicy:(t,n)=>{if(e.has(t))throw TypeError(`Policy with name "${t}" already exists.`);let r={createHTML:n.createHTML?e=>n.createHTML(e):void 0,createScriptURL:n.createScriptURL?e=>n.createScriptURL(e):void 0,createScript:n.createScript?e=>n.createScript(e):void 0};return e.set(t,r),r},getPolicy:t=>e.get(t)??null,isHTML:e=>typeof e==`string`||e instanceof Object&&`toString`in e,isScriptURL:e=>typeof e==`string`||e instanceof Object&&`toString`in e,isScript:e=>typeof e==`string`||e instanceof Object&&`toString`in e}}let r=`__shadowClawDefaultTrustedTypesPolicyState`,i=`default`,a=`shadowclaw-sandbox`;function o(){let e=globalThis;return e[r]||(e[r]={initialized:!1,policy:null}),e[r]}function s(){let e=o();if(e.initialized)return;let t=Reflect.get(globalThis,`trustedTypes`);if(!(!t||typeof t.createPolicy!=`function`)){e.initialized=!0;try{if(typeof t.getPolicy==`function`){let n=t.getPolicy(i);if(n){e.policy=n;return}}let n=!1;if(typeof t.getPolicyNames==`function`){let e=t.getPolicyNames();Array.isArray(e)&&e.includes(i)&&(n=!0)}if(n){if(typeof t.getPolicy==`function`){let n=t.getPolicy(a);if(n){e.policy=n;return}}e.policy=t.createPolicy(a,{createHTML:e=>e,createScriptURL:e=>e});return}e.policy=t.createPolicy(i,{createHTML:e=>e,createScriptURL:e=>e})}catch{typeof t.getPolicy==`function`&&(e.policy=t.getPolicy(i)??t.getPolicy(a)??null)}}}new class{loading=!1;models=new Map;getModelInfo(e){if(!e||typeof e!=`string`)return null;let t=e.toLowerCase().trim(),n=this.models.get(t);if(n)return n;if(t.includes(`/`)){let e=t.split(`/`).pop();if(e&&this.models.has(e))return this.models.get(e)}else for(let[e,n]of this.models.entries())if(e.endsWith(`/${t}`))return n;if(t.includes(`:`)){let e=t.split(`:`)[0],n=this.getModelInfo(e);if(n)return n}return null}registerModelInfo(e,t){this.models.set(e.toLowerCase(),t)}clear(){this.models.clear()}async fetchModelInfo(e,t,n){if(e.modelsUrl){this.loading=!0;try{let r=new Headers;if(r.set(`Content-Type`,`application/json`),e.headers)for(let[t,n]of Object.entries(e.headers))r.set(t,n);if(n)for(let[e,t]of Object.entries(n))r.set(e,t);if(t&&e.apiKeyHeader){let n=e.apiKeyHeaderFormat;r.set(e.apiKeyHeader,n?n.replace(`{key}`,t):t)}let i=await fetch(e.modelsUrl,{headers:r});if(!i.ok)throw Error(`HTTP ${i.status} ${i.statusText}`);let a=await i.json(),o=Array.isArray(a.data)?a.data:Array.isArray(a.models)?a.models:[];for(let e of o){if(!e.id)continue;let t=e.context_length??e.context_window??0,n=e.max_completion_tokens||e.per_request_limits?.completion_tokens||e.top_provider?.max_completion_tokens||null,r=typeof e.supports_tools==`boolean`?e.supports_tools:typeof e.supportsTools==`boolean`?e.supportsTools:void 0,i=this.extractModalities(e,`input`),a=this.extractModalities(e,`output`),o=this.modalitiesInclude(i,`image`,`vision`),s=this.modalitiesInclude(i,`audio`,`voice`,`hearing`),c=this.modalitiesInclude(i,`video`),l=e.id===`openrouter/free`||this.supportedParametersInclude(e,`image`,`vision`,`audio`,`tool`,`structured`),u=this.extractReasoning(e),d=typeof e.supports_prompt_caching==`boolean`?e.supports_prompt_caching:typeof e.supportsPromptCaching==`boolean`?e.supportsPromptCaching:this.supportedParametersInclude(e,`cache_control`,`prompt_caching`)?!0:void 0;!t&&Array.isArray(e.providers)&&e.providers.length>0&&(t=e.providers[0]?.context_length||0),this.registerModelInfo(e.id,{contextWindow:t,maxOutput:n,...r!==void 0&&{supportsTools:r},...i.length>0&&{inputModalities:i},...a.length>0&&{outputModalities:a},...o!==void 0&&{supportsImageInput:o},...s!==void 0&&{supportsAudioInput:s},...c!==void 0&&{supportsVideoInput:c},...u&&{reasoning:u},...l&&{routesByRequestFeatures:l},...d!==void 0&&{supportsPromptCaching:d}})}o.length>0&&console.log(`[ModelRegistry] Registered ${o.length} models for provider "${e.id}"`)}catch(t){console.error(`[ModelRegistry] Error fetching models for ${e.id}:`,t)}finally{this.loading=!1}}}extractModalities(e,t){let n=t===`input`?e.input_modalities||e.inputModalities:e.output_modalities||e.outputModalities,r=e.architecture||{},i=t===`input`?r.input_modalities||r.inputModalities:r.output_modalities||r.outputModalities,a=typeof r.modality==`string`?r.modality:``,o=this.parseArchitectureModality(a,t),s=[...this.normalizeStringArray(n),...this.normalizeStringArray(i),...o];return Array.from(new Set(s))}extractReasoning(e){let t=e?.reasoning;if(!t||typeof t!=`object`)return;let n=this.normalizeStringArray(t.supported_efforts),r=typeof t.default_effort==`string`?t.default_effort.toLowerCase():void 0,i=typeof t.default_enabled==`boolean`?t.default_enabled:void 0,a=typeof t.supports_max_tokens==`boolean`?t.supports_max_tokens:void 0,o=typeof t.mandatory==`boolean`?t.mandatory:void 0;if(!(n.length===0&&r===void 0&&i===void 0&&a===void 0&&o===void 0))return{...n.length>0&&{supportedEfforts:n},...r!==void 0&&{defaultEffort:r},...i!==void 0&&{defaultEnabled:i},...a!==void 0&&{supportsMaxTokens:a},...o!==void 0&&{mandatory:o}}}modalitiesInclude(e,...t){if(e.length!==0)return t.some(t=>e.some(e=>e.includes(t)))}normalizeStringArray(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.toLowerCase()):[]}parseArchitectureModality(e,t){if(!e)return[];let[n=``,r=``]=e.toLowerCase().split(`->`).map(e=>e.trim());return(t===`input`?n:r).split(/[+,/\s]+/).map(e=>e.trim()).filter(Boolean)}supportedParametersInclude(e,...t){let n=this.normalizeStringArray(e.supported_parameters||e.supportedParameters);return t.some(e=>n.some(t=>t.includes(e)))}};function c(e){return e.replace(/^\/+|\/+$/g,``)}function l(e){let t=c(e);return t.endsWith(`/index.html`)?t=t.slice(0,-11):t.endsWith(`index.html`)&&(t=t.slice(0,-10)),c(t)}function u(e){let t=c(e),n=t.split(`/`).filter(Boolean);if(n.length===0)return null;let r=n[0].toLowerCase();if(r===`pages`){if(n.length>=3){let e=n[1];return{page:`pages`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e,path:n.slice(2).join(`/`)}}return{page:`pages`,groupId:`br:main`,path:n.slice(1).join(`/`)}}if(r===`files`){let e=n[1]||`main`;return{page:`files`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e,path:n.slice(2).join(`/`)||void 0}}if(r===`chat`){let e=n[1]||`main`;return{page:`chat`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e}}if(r===`tasks`){let e=n[1]||`main`;return{page:`tasks`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e}}return r===`main`?{page:`pages`,groupId:`br:main`,path:n.slice(1).join(`/`)}:{page:`pages`,groupId:`br:main`,path:t}}function d(){if(typeof document<`u`){let e=document.getElementById(`shadow-claw-static-routing`);if(e&&e.textContent)try{let t=JSON.parse(e.textContent);if(t&&typeof t==`object`&&t.routes)return t}catch(e){console.warn(`Failed to parse embedded static routing manifest:`,e)}}return null}function f(e,t){let n=t||d();if(!n||!n.routes)return null;let r=l(e);if(!r)return null;for(let[e,t]of Object.entries(n.routes))if(!(!t||!t.prettyPath)&&l(t.prettyPath)===r)return u(e);return null}let p=null,ee=new Set([`chat`,`files`,`tasks`,`pages`,`settings`,`tools`,`channels`]);function m(){p=null}typeof globalThis<`u`&&(globalThis.__applyBasePathCacheReset=m);function h(){let e=typeof window<`u`?window:typeof self<`u`?self:globalThis;if(e&&e.__SHADOWCLAW_DEPLOY_ID__){let t=String(e.__SHADOWCLAW_DEPLOY_ID__).trim();if(t)return t.replace(/[^a-zA-Z0-9_-]/g,`-`)}let t=globalThis.process;if(t&&t.env&&t.env.SHADOWCLAW_DEPLOY_ID){let e=String(t.env.SHADOWCLAW_DEPLOY_ID).trim();if(e)return e.replace(/[^a-zA-Z0-9_-]/g,`-`)}let n=te();return!n||n===`/`?``:n.replace(/^\/+|\/+$/g,``).replace(/[^a-zA-Z0-9_-]/g,`-`)}function te(){if(p!==null)return p;if((typeof window>`u`||globalThis.WorkerGlobalScope!==void 0&&typeof self<`u`&&self instanceof globalThis.WorkerGlobalScope)&&typeof self<`u`&&self.location){let e=(self.location.pathname||`/`).split(`/`).filter(Boolean);if(e.length<=1)return p=`/`,p;let t=e[0].toLowerCase(),n=t===`service-worker.js`||t===`sw.js`||t===`manifest.json`||t===`sitemap.xml`||t===`favicon.ico`||t===`index.html`||t===`service-worker`||t===`assets`||t===`dist`||t===`public`;if(n&&e.length===2)return p=`/`,p;if(!n)return p=`/`+e[0]+`/`,p}let e=typeof window<`u`&&window.location?window.location:typeof self<`u`&&self.location?self.location:null;if(!e)return`/`;if(typeof document<`u`&&typeof document.querySelector==`function`){let t=document.querySelector(`base[href]`);if(t){let n=t.getAttribute(`href`);if(n)try{let t=new URL(n,e.origin).pathname;return t.endsWith(`/`)||(t+=`/`),p=t,p}catch{}}}let t=e.pathname||`/`;if(t===`/`)return p=`/`,p;let n=t.split(`/`).filter(Boolean),r=n.findIndex(e=>ee.has(e.toLowerCase()));return r>=0?r===0?(p=`/`,p):(p=`/`+n.slice(0,r).join(`/`)+`/`,p):f(t)?(p=`/`,p):n.length===1&&!t.includes(`.`)?(p=`/`+n[0]+`/`,p):(p=`/`,p)}function ne(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|\\s)@${t}\\b`,`i`)}ne(`ShadowClaw`);function g(){let e=h();return e?`shadowclaw-${e}`:`shadowclaw`}g();let _={github:{providerId:`github`,name:`GitHub`,aliases:[`github`,`api.github.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`token `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://github.com/login/oauth/authorize`,tokenUrl:`https://github.com/login/oauth/access_token`,defaultScopes:[`repo`,`read:user`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},gitlab:{providerId:`gitlab`,name:`GitLab`,aliases:[`gitlab`,`gitlab.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`PRIVATE-TOKEN`,headerPrefix:``},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},tokenAuthByServiceType:{git_remote:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}}},oauth:{authorizeUrl:`https://gitlab.com/oauth/authorize`,tokenUrl:`https://gitlab.com/oauth/token`,defaultScopes:[`read_api`,`read_user`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},figma:{providerId:`figma`,name:`Figma`,aliases:[`figma`,`api.figma.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`X-Figma-Token`,headerPrefix:``},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://www.figma.com/oauth`,tokenUrl:`https://api.figma.com/v1/oauth/token`,refreshUrl:`https://api.figma.com/v1/oauth/refresh`,defaultScopes:[],usePkce:!0,clientAuthMethod:`basic_header`,scopeSeparator:`space`}},notion:{providerId:`notion`,name:`Notion`,aliases:[`notion`,`api.notion.com`,`notion.so`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://api.notion.com/v1/oauth/authorize`,tokenUrl:`https://api.notion.com/v1/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`basic_header`,scopeSeparator:`space`}},microsoft_graph:{providerId:`microsoft_graph`,name:`Microsoft Graph`,aliases:[`microsoft`,`graph.microsoft.com`,`microsoft_graph`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://login.microsoftonline.com/common/oauth2/v2.0/authorize`,tokenUrl:`https://login.microsoftonline.com/common/oauth2/v2.0/token`,defaultScopes:[`openid`,`profile`,`offline_access`,`User.Read`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},yahoo_mail:{providerId:`yahoo_mail`,name:`Yahoo Mail`,aliases:[`yahoo`,`yahoo_mail`,`mail.yahoo.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://api.login.yahoo.com/oauth2/request_auth`,tokenUrl:`https://api.login.yahoo.com/oauth2/get_token`,defaultScopes:[`mail-r`,`mail-w`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},google:{providerId:`google`,name:`Google`,aliases:[`google`,`googleapis.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://accounts.google.com/o/oauth2/v2/auth`,tokenUrl:`https://oauth2.googleapis.com/token`,defaultScopes:[`openid`,`profile`,`email`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},atlassian:{providerId:`atlassian`,name:`Atlassian`,aliases:[`atlassian`,`api.atlassian.com`],modes:[`oauth`,`token`,`basic`],defaultMode:`basic`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`,`basic_userpass`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `},basic:{headerName:`Authorization`,headerPrefix:`Basic `}},oauth:{authorizeUrl:`https://auth.atlassian.com/authorize`,tokenUrl:`https://auth.atlassian.com/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},slack:{providerId:`slack`,name:`Slack`,aliases:[`slack`,`slack.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://slack.com/oauth/v2/authorize`,tokenUrl:`https://slack.com/api/oauth.v2.access`,defaultScopes:[],usePkce:!1,clientAuthMethod:`request_body`,scopeSeparator:`comma`}},linear:{providerId:`linear`,name:`Linear`,aliases:[`linear`,`api.linear.app`,`linear.app`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://linear.app/oauth/authorize`,tokenUrl:`https://api.linear.app/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},azure_devops:{providerId:`azure_devops`,name:`Azure DevOps`,aliases:[`azure_devops`,`dev.azure.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`,`basic_userpass`,`ssh_key`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},tokenAuthByServiceType:{git_remote:{token:{headerName:`Authorization`,headerPrefix:`Basic `},oauth:{headerName:`Authorization`,headerPrefix:`Basic `}}},oauth:{authorizeUrl:`https://app.vssps.visualstudio.com/oauth2/authorize`,tokenUrl:`https://app.vssps.visualstudio.com/oauth2/token`,defaultScopes:[`vso.code`,`vso.profile`,`offline_access`],usePkce:!1,clientAuthMethod:`request_body`,scopeSeparator:`space`}},custom_mcp:{providerId:`custom_mcp`,name:`Custom MCP`,aliases:[`custom_mcp`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`mcp_remote`,`webmcp_local`],authTypes:[`none`,`token`,`oauth`,`custom_header`,`ssh_key`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://example.com/oauth/authorize`,tokenUrl:`https://example.com/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}}};Object.fromEntries(Object.values(_).filter(e=>!!e.oauth).map(e=>{let t=e.oauth;return[e.providerId,{id:e.providerId,name:e.name,authorizeUrl:t.authorizeUrl,tokenUrl:t.tokenUrl,redirectUri:t.redirectUri,defaultScopes:t.defaultScopes,usePkce:t.usePkce,clientAuthMethod:t.clientAuthMethod,scopeSeparator:t.scopeSeparator}]})),Object.fromEntries(Object.values(_).map(e=>[e.providerId,{providerId:e.providerId,modes:e.modes,defaultMode:e.defaultMode}])),new Promise(e=>{});
3
3
  /*! @license DOMPurify 3.4.13 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.13/LICENSE */
4
4
  function v(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function y(e){if(Array.isArray(e))return e}function b(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function re(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
@@ -1,4 +1,4 @@
1
- <!doctype html><html lang="en"><head><title>ShadowClaw</title><meta charset="utf-8"><meta name="revision" content="25a61e273c78a4e8d94f73bf714f6584f3c4be4c" /><meta name="version" content="1.34.5" /><meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"><meta name="description" content="ShadowClaw - Browser-native AI agent." /><link rel="canonical" href="https://xt-ml.github.io/shadow-claw/"><meta property="og:title" content="ShadowClaw"><meta property="og:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta property="og:type" content="website"><meta property="og:url" content="https://xt-ml.github.io/shadow-claw/"><meta property="og:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="ShadowClaw"><meta name="twitter:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta name="twitter:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"SoftwareApplication","@id":"https://xt-ml.github.io/shadow-claw/#software","name":"ShadowClaw","description":"Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution.","url":"https://xt-ml.github.io/shadow-claw/","applicationCategory":"DeveloperApplication","operatingSystem":"Web, Browser, Desktop","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"author":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"},"codeRepository":"https://github.com/xt-ml/shadow-claw","license":"https://github.com/xt-ml/shadow-claw/blob/main/LICENSE"},{"@type":"WebSite","@id":"https://xt-ml.github.io/shadow-claw/#website","url":"https://xt-ml.github.io/shadow-claw/","name":"ShadowClaw","description":"Official website and live deployment of ShadowClaw browser-native AI assistant.","publisher":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"}},{"@type":"Organization","@id":"https://xt-ml.github.io/shadow-claw/#organization","name":"xt-ml","url":"https://github.com/xt-ml","sameAs":["https://github.com/xt-ml"]}]}</script><meta name="theme-color" content="#fff" /><meta http-equiv="origin-trial" content="A88uTgESYWcVgREKVReKB6jom41uP8TzW6ei3jNdidf+Xl6ONqKRjKNBphsxhrZmdkakLK3oXDgkGq53rtZYSAMAAAB2eyJvcmlnaW4iOiJodHRwczovL3h0LW1sLmdpdGh1Yi5pbzo0NDMiLCJmZWF0dXJlIjoiV2ViTUNQIiwiZXhwaXJ5IjoxNzk0ODczNjAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><base href="/shadow-claw/" /><script id="shadow-claw-site-config" type="application/json">{"$schema":"https:\u002f\u002fjson-schema.org\u002fdraft\u002f2020-12\u002fschema","site":{"title":"ShadowClaw","description":"ShadowClaw - Browser-native AI agent.","themeColor":"#fff"},"branding":{"faviconPath":"assets\u002ficons\u002ffavicon.ico","appleTouchIconPath":"assets\u002ficons\u002f180.png","notFoundPath":"404.html"},"pwa":{"manifestPath":"manifest.json","themeColor":"#000000"},"sitemapPath":"sitemap.xml","assets":["assets"],"sidebar":{"pagesHidden":false,"chatHidden":false,"tasksHidden":false,"filesHidden":false,"defaultPage":"pages"},"settings":{"defaultToolsProfile":"__builtin_default"},"agent":{"defaultProvider":"transformers_js_local","defaultModel":"onnx-community\u002fgemma-3-1b-it-ONNX-GQA"},"customElements":{"allowedElements":["block-garden","block-garden-option","block-garden-select"],"allowedDomains":["kherrick.github.io","cdn.jsdelivr.net"],"scripts":[{"src":"https:\u002f\u002fkherrick.github.io\u002fblock-garden-knowledge-hub\u002f.agents\u002fscripts\u002fmain\u002fblock-garden-adapter.js","hasInit":true},"https:\u002f\u002fkherrick.github.io\u002fblock-garden\u002fblock-garden-bundle-min.mjs"]},"security":{"connectSrc":["'self'","blob:","data:","https:\u002f\u002fkherrick.github.io","https:\u002f\u002fcdn.jsdelivr.net"]}}</script>
1
+ <!doctype html><html lang="en"><head><title>ShadowClaw</title><meta charset="utf-8"><meta name="revision" content="72143ec88485970231da8c06ecf74089dd580224" /><meta name="version" content="1.35.0" /><meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"><meta name="description" content="ShadowClaw - Browser-native AI agent." /><link rel="canonical" href="https://xt-ml.github.io/shadow-claw/"><meta property="og:title" content="ShadowClaw"><meta property="og:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta property="og:type" content="website"><meta property="og:url" content="https://xt-ml.github.io/shadow-claw/"><meta property="og:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="ShadowClaw"><meta name="twitter:description" content="Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution."><meta name="twitter:image" content="https://xt-ml.github.io/shadow-claw/assets/icons/512.png"><script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"SoftwareApplication","@id":"https://xt-ml.github.io/shadow-claw/#software","name":"ShadowClaw","description":"Browser-native personal AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution.","url":"https://xt-ml.github.io/shadow-claw/","applicationCategory":"DeveloperApplication","operatingSystem":"Web, Browser, Desktop","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"author":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"},"codeRepository":"https://github.com/xt-ml/shadow-claw","license":"https://github.com/xt-ml/shadow-claw/blob/main/LICENSE"},{"@type":"WebSite","@id":"https://xt-ml.github.io/shadow-claw/#website","url":"https://xt-ml.github.io/shadow-claw/","name":"ShadowClaw","description":"Official website and live deployment of ShadowClaw browser-native AI assistant.","publisher":{"@type":"Organization","name":"xt-ml","url":"https://github.com/xt-ml"}},{"@type":"Organization","@id":"https://xt-ml.github.io/shadow-claw/#organization","name":"xt-ml","url":"https://github.com/xt-ml","sameAs":["https://github.com/xt-ml"]}]}</script><meta name="theme-color" content="#fff" /><meta http-equiv="origin-trial" content="A88uTgESYWcVgREKVReKB6jom41uP8TzW6ei3jNdidf+Xl6ONqKRjKNBphsxhrZmdkakLK3oXDgkGq53rtZYSAMAAAB2eyJvcmlnaW4iOiJodHRwczovL3h0LW1sLmdpdGh1Yi5pbzo0NDMiLCJmZWF0dXJlIjoiV2ViTUNQIiwiZXhwaXJ5IjoxNzk0ODczNjAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><base href="/shadow-claw/" /><script id="shadow-claw-site-config" type="application/json">{"$schema":"https:\u002f\u002fjson-schema.org\u002fdraft\u002f2020-12\u002fschema","site":{"title":"ShadowClaw","description":"ShadowClaw - Browser-native AI agent.","themeColor":"#fff"},"branding":{"faviconPath":"assets\u002ficons\u002ffavicon.ico","appleTouchIconPath":"assets\u002ficons\u002f180.png","notFoundPath":"404.html"},"pwa":{"manifestPath":"manifest.json","themeColor":"#000000"},"sitemapPath":"sitemap.xml","assets":["assets"],"sidebar":{"pagesHidden":false,"chatHidden":false,"tasksHidden":false,"filesHidden":false,"defaultPage":"pages"},"settings":{"defaultToolsProfile":"__builtin_default"},"agent":{"defaultProvider":"transformers_js_local","defaultModel":"onnx-community\u002fgemma-3-1b-it-ONNX-GQA"},"customElements":{"allowedElements":["block-garden","block-garden-option","block-garden-select"],"allowedDomains":["kherrick.github.io","cdn.jsdelivr.net"],"scripts":[{"src":"https:\u002f\u002fkherrick.github.io\u002fblock-garden-knowledge-hub\u002f.agents\u002fscripts\u002fmain\u002fblock-garden-adapter.js","hasInit":true},"https:\u002f\u002fkherrick.github.io\u002fblock-garden\u002fblock-garden-bundle-min.mjs"]},"security":{"connectSrc":["'self'","blob:","data:","https:\u002f\u002fkherrick.github.io","https:\u002f\u002fcdn.jsdelivr.net"]}}</script>
2
2
  <script>var ShadowClawThemeInit=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);function n(){if(globalThis.trustedTypes)return;let e=new Map;globalThis.trustedTypes={createPolicy:(t,n)=>{if(e.has(t))throw TypeError(`Policy with name "${t}" already exists.`);let r={createHTML:n.createHTML?e=>n.createHTML(e):void 0,createScriptURL:n.createScriptURL?e=>n.createScriptURL(e):void 0,createScript:n.createScript?e=>n.createScript(e):void 0};return e.set(t,r),r},getPolicy:t=>e.get(t)??null,isHTML:e=>typeof e==`string`||e instanceof Object&&`toString`in e,isScriptURL:e=>typeof e==`string`||e instanceof Object&&`toString`in e,isScript:e=>typeof e==`string`||e instanceof Object&&`toString`in e}}let r=`__shadowClawDefaultTrustedTypesPolicyState`,i=`default`,a=`shadowclaw-sandbox`;function o(){let e=globalThis;return e[r]||(e[r]={initialized:!1,policy:null}),e[r]}function s(){let e=o();if(e.initialized)return;let t=Reflect.get(globalThis,`trustedTypes`);if(!(!t||typeof t.createPolicy!=`function`)){e.initialized=!0;try{if(typeof t.getPolicy==`function`){let n=t.getPolicy(i);if(n){e.policy=n;return}}let n=!1;if(typeof t.getPolicyNames==`function`){let e=t.getPolicyNames();Array.isArray(e)&&e.includes(i)&&(n=!0)}if(n){if(typeof t.getPolicy==`function`){let n=t.getPolicy(a);if(n){e.policy=n;return}}e.policy=t.createPolicy(a,{createHTML:e=>e,createScriptURL:e=>e});return}e.policy=t.createPolicy(i,{createHTML:e=>e,createScriptURL:e=>e})}catch{typeof t.getPolicy==`function`&&(e.policy=t.getPolicy(i)??t.getPolicy(a)??null)}}}new class{loading=!1;models=new Map;getModelInfo(e){if(!e||typeof e!=`string`)return null;let t=e.toLowerCase().trim(),n=this.models.get(t);if(n)return n;if(t.includes(`/`)){let e=t.split(`/`).pop();if(e&&this.models.has(e))return this.models.get(e)}else for(let[e,n]of this.models.entries())if(e.endsWith(`/${t}`))return n;if(t.includes(`:`)){let e=t.split(`:`)[0],n=this.getModelInfo(e);if(n)return n}return null}registerModelInfo(e,t){this.models.set(e.toLowerCase(),t)}clear(){this.models.clear()}async fetchModelInfo(e,t,n){if(e.modelsUrl){this.loading=!0;try{let r=new Headers;if(r.set(`Content-Type`,`application/json`),e.headers)for(let[t,n]of Object.entries(e.headers))r.set(t,n);if(n)for(let[e,t]of Object.entries(n))r.set(e,t);if(t&&e.apiKeyHeader){let n=e.apiKeyHeaderFormat;r.set(e.apiKeyHeader,n?n.replace(`{key}`,t):t)}let i=await fetch(e.modelsUrl,{headers:r});if(!i.ok)throw Error(`HTTP ${i.status} ${i.statusText}`);let a=await i.json(),o=Array.isArray(a.data)?a.data:Array.isArray(a.models)?a.models:[];for(let e of o){if(!e.id)continue;let t=e.context_length??e.context_window??0,n=e.max_completion_tokens||e.per_request_limits?.completion_tokens||e.top_provider?.max_completion_tokens||null,r=typeof e.supports_tools==`boolean`?e.supports_tools:typeof e.supportsTools==`boolean`?e.supportsTools:void 0,i=this.extractModalities(e,`input`),a=this.extractModalities(e,`output`),o=this.modalitiesInclude(i,`image`,`vision`),s=this.modalitiesInclude(i,`audio`,`voice`,`hearing`),c=this.modalitiesInclude(i,`video`),l=e.id===`openrouter/free`||this.supportedParametersInclude(e,`image`,`vision`,`audio`,`tool`,`structured`),u=this.extractReasoning(e),d=typeof e.supports_prompt_caching==`boolean`?e.supports_prompt_caching:typeof e.supportsPromptCaching==`boolean`?e.supportsPromptCaching:this.supportedParametersInclude(e,`cache_control`,`prompt_caching`)?!0:void 0;!t&&Array.isArray(e.providers)&&e.providers.length>0&&(t=e.providers[0]?.context_length||0),this.registerModelInfo(e.id,{contextWindow:t,maxOutput:n,...r!==void 0&&{supportsTools:r},...i.length>0&&{inputModalities:i},...a.length>0&&{outputModalities:a},...o!==void 0&&{supportsImageInput:o},...s!==void 0&&{supportsAudioInput:s},...c!==void 0&&{supportsVideoInput:c},...u&&{reasoning:u},...l&&{routesByRequestFeatures:l},...d!==void 0&&{supportsPromptCaching:d}})}o.length>0&&console.log(`[ModelRegistry] Registered ${o.length} models for provider "${e.id}"`)}catch(t){console.error(`[ModelRegistry] Error fetching models for ${e.id}:`,t)}finally{this.loading=!1}}}extractModalities(e,t){let n=t===`input`?e.input_modalities||e.inputModalities:e.output_modalities||e.outputModalities,r=e.architecture||{},i=t===`input`?r.input_modalities||r.inputModalities:r.output_modalities||r.outputModalities,a=typeof r.modality==`string`?r.modality:``,o=this.parseArchitectureModality(a,t),s=[...this.normalizeStringArray(n),...this.normalizeStringArray(i),...o];return Array.from(new Set(s))}extractReasoning(e){let t=e?.reasoning;if(!t||typeof t!=`object`)return;let n=this.normalizeStringArray(t.supported_efforts),r=typeof t.default_effort==`string`?t.default_effort.toLowerCase():void 0,i=typeof t.default_enabled==`boolean`?t.default_enabled:void 0,a=typeof t.supports_max_tokens==`boolean`?t.supports_max_tokens:void 0,o=typeof t.mandatory==`boolean`?t.mandatory:void 0;if(!(n.length===0&&r===void 0&&i===void 0&&a===void 0&&o===void 0))return{...n.length>0&&{supportedEfforts:n},...r!==void 0&&{defaultEffort:r},...i!==void 0&&{defaultEnabled:i},...a!==void 0&&{supportsMaxTokens:a},...o!==void 0&&{mandatory:o}}}modalitiesInclude(e,...t){if(e.length!==0)return t.some(t=>e.some(e=>e.includes(t)))}normalizeStringArray(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.toLowerCase()):[]}parseArchitectureModality(e,t){if(!e)return[];let[n=``,r=``]=e.toLowerCase().split(`->`).map(e=>e.trim());return(t===`input`?n:r).split(/[+,/\s]+/).map(e=>e.trim()).filter(Boolean)}supportedParametersInclude(e,...t){let n=this.normalizeStringArray(e.supported_parameters||e.supportedParameters);return t.some(e=>n.some(t=>t.includes(e)))}};function c(e){return e.replace(/^\/+|\/+$/g,``)}function l(e){let t=c(e);return t.endsWith(`/index.html`)?t=t.slice(0,-11):t.endsWith(`index.html`)&&(t=t.slice(0,-10)),c(t)}function u(e){let t=c(e),n=t.split(`/`).filter(Boolean);if(n.length===0)return null;let r=n[0].toLowerCase();if(r===`pages`){if(n.length>=3){let e=n[1];return{page:`pages`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e,path:n.slice(2).join(`/`)}}return{page:`pages`,groupId:`br:main`,path:n.slice(1).join(`/`)}}if(r===`files`){let e=n[1]||`main`;return{page:`files`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e,path:n.slice(2).join(`/`)||void 0}}if(r===`chat`){let e=n[1]||`main`;return{page:`chat`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e}}if(r===`tasks`){let e=n[1]||`main`;return{page:`tasks`,groupId:e===`main`?`br:main`:e.startsWith(`br-`)?`br:${e.slice(3)}`:e}}return r===`main`?{page:`pages`,groupId:`br:main`,path:n.slice(1).join(`/`)}:{page:`pages`,groupId:`br:main`,path:t}}function d(){if(typeof document<`u`){let e=document.getElementById(`shadow-claw-static-routing`);if(e&&e.textContent)try{let t=JSON.parse(e.textContent);if(t&&typeof t==`object`&&t.routes)return t}catch(e){console.warn(`Failed to parse embedded static routing manifest:`,e)}}return null}function f(e,t){let n=t||d();if(!n||!n.routes)return null;let r=l(e);if(!r)return null;for(let[e,t]of Object.entries(n.routes))if(!(!t||!t.prettyPath)&&l(t.prettyPath)===r)return u(e);return null}let p=null,ee=new Set([`chat`,`files`,`tasks`,`pages`,`settings`,`tools`,`channels`]);function m(){p=null}typeof globalThis<`u`&&(globalThis.__applyBasePathCacheReset=m);function h(){let e=typeof window<`u`?window:typeof self<`u`?self:globalThis;if(e&&e.__SHADOWCLAW_DEPLOY_ID__){let t=String(e.__SHADOWCLAW_DEPLOY_ID__).trim();if(t)return t.replace(/[^a-zA-Z0-9_-]/g,`-`)}let t=globalThis.process;if(t&&t.env&&t.env.SHADOWCLAW_DEPLOY_ID){let e=String(t.env.SHADOWCLAW_DEPLOY_ID).trim();if(e)return e.replace(/[^a-zA-Z0-9_-]/g,`-`)}let n=te();return!n||n===`/`?``:n.replace(/^\/+|\/+$/g,``).replace(/[^a-zA-Z0-9_-]/g,`-`)}function te(){if(p!==null)return p;if((typeof window>`u`||globalThis.WorkerGlobalScope!==void 0&&typeof self<`u`&&self instanceof globalThis.WorkerGlobalScope)&&typeof self<`u`&&self.location){let e=(self.location.pathname||`/`).split(`/`).filter(Boolean);if(e.length<=1)return p=`/`,p;let t=e[0].toLowerCase(),n=t===`service-worker.js`||t===`sw.js`||t===`manifest.json`||t===`sitemap.xml`||t===`favicon.ico`||t===`index.html`||t===`service-worker`||t===`assets`||t===`dist`||t===`public`;if(n&&e.length===2)return p=`/`,p;if(!n)return p=`/`+e[0]+`/`,p}let e=typeof window<`u`&&window.location?window.location:typeof self<`u`&&self.location?self.location:null;if(!e)return`/`;if(typeof document<`u`&&typeof document.querySelector==`function`){let t=document.querySelector(`base[href]`);if(t){let n=t.getAttribute(`href`);if(n)try{let t=new URL(n,e.origin).pathname;return t.endsWith(`/`)||(t+=`/`),p=t,p}catch{}}}let t=e.pathname||`/`;if(t===`/`)return p=`/`,p;let n=t.split(`/`).filter(Boolean),r=n.findIndex(e=>ee.has(e.toLowerCase()));return r>=0?r===0?(p=`/`,p):(p=`/`+n.slice(0,r).join(`/`)+`/`,p):f(t)?(p=`/`,p):n.length===1&&!t.includes(`.`)?(p=`/`+n[0]+`/`,p):(p=`/`,p)}function ne(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|\\s)@${t}\\b`,`i`)}ne(`ShadowClaw`);function g(){let e=h();return e?`shadowclaw-${e}`:`shadowclaw`}g();let _={github:{providerId:`github`,name:`GitHub`,aliases:[`github`,`api.github.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`token `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://github.com/login/oauth/authorize`,tokenUrl:`https://github.com/login/oauth/access_token`,defaultScopes:[`repo`,`read:user`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},gitlab:{providerId:`gitlab`,name:`GitLab`,aliases:[`gitlab`,`gitlab.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`PRIVATE-TOKEN`,headerPrefix:``},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},tokenAuthByServiceType:{git_remote:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}}},oauth:{authorizeUrl:`https://gitlab.com/oauth/authorize`,tokenUrl:`https://gitlab.com/oauth/token`,defaultScopes:[`read_api`,`read_user`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},figma:{providerId:`figma`,name:`Figma`,aliases:[`figma`,`api.figma.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`X-Figma-Token`,headerPrefix:``},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://www.figma.com/oauth`,tokenUrl:`https://api.figma.com/v1/oauth/token`,refreshUrl:`https://api.figma.com/v1/oauth/refresh`,defaultScopes:[],usePkce:!0,clientAuthMethod:`basic_header`,scopeSeparator:`space`}},notion:{providerId:`notion`,name:`Notion`,aliases:[`notion`,`api.notion.com`,`notion.so`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://api.notion.com/v1/oauth/authorize`,tokenUrl:`https://api.notion.com/v1/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`basic_header`,scopeSeparator:`space`}},microsoft_graph:{providerId:`microsoft_graph`,name:`Microsoft Graph`,aliases:[`microsoft`,`graph.microsoft.com`,`microsoft_graph`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://login.microsoftonline.com/common/oauth2/v2.0/authorize`,tokenUrl:`https://login.microsoftonline.com/common/oauth2/v2.0/token`,defaultScopes:[`openid`,`profile`,`offline_access`,`User.Read`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},yahoo_mail:{providerId:`yahoo_mail`,name:`Yahoo Mail`,aliases:[`yahoo`,`yahoo_mail`,`mail.yahoo.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://api.login.yahoo.com/oauth2/request_auth`,tokenUrl:`https://api.login.yahoo.com/oauth2/get_token`,defaultScopes:[`mail-r`,`mail-w`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},google:{providerId:`google`,name:`Google`,aliases:[`google`,`googleapis.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://accounts.google.com/o/oauth2/v2/auth`,tokenUrl:`https://oauth2.googleapis.com/token`,defaultScopes:[`openid`,`profile`,`email`],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},atlassian:{providerId:`atlassian`,name:`Atlassian`,aliases:[`atlassian`,`api.atlassian.com`],modes:[`oauth`,`token`,`basic`],defaultMode:`basic`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`,`basic_userpass`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `},basic:{headerName:`Authorization`,headerPrefix:`Basic `}},oauth:{authorizeUrl:`https://auth.atlassian.com/authorize`,tokenUrl:`https://auth.atlassian.com/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},slack:{providerId:`slack`,name:`Slack`,aliases:[`slack`,`slack.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://slack.com/oauth/v2/authorize`,tokenUrl:`https://slack.com/api/oauth.v2.access`,defaultScopes:[],usePkce:!1,clientAuthMethod:`request_body`,scopeSeparator:`comma`}},linear:{providerId:`linear`,name:`Linear`,aliases:[`linear`,`api.linear.app`,`linear.app`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`],authTypes:[`token`,`oauth`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://linear.app/oauth/authorize`,tokenUrl:`https://api.linear.app/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}},azure_devops:{providerId:`azure_devops`,name:`Azure DevOps`,aliases:[`azure_devops`,`dev.azure.com`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`http_api`,`git_remote`],authTypes:[`token`,`oauth`,`basic_userpass`,`ssh_key`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},tokenAuthByServiceType:{git_remote:{token:{headerName:`Authorization`,headerPrefix:`Basic `},oauth:{headerName:`Authorization`,headerPrefix:`Basic `}}},oauth:{authorizeUrl:`https://app.vssps.visualstudio.com/oauth2/authorize`,tokenUrl:`https://app.vssps.visualstudio.com/oauth2/token`,defaultScopes:[`vso.code`,`vso.profile`,`offline_access`],usePkce:!1,clientAuthMethod:`request_body`,scopeSeparator:`space`}},custom_mcp:{providerId:`custom_mcp`,name:`Custom MCP`,aliases:[`custom_mcp`],modes:[`oauth`,`token`],defaultMode:`oauth`,serviceTypes:[`mcp_remote`,`webmcp_local`],authTypes:[`none`,`token`,`oauth`,`custom_header`,`ssh_key`],tokenAuth:{token:{headerName:`Authorization`,headerPrefix:`Bearer `},oauth:{headerName:`Authorization`,headerPrefix:`Bearer `}},oauth:{authorizeUrl:`https://example.com/oauth/authorize`,tokenUrl:`https://example.com/oauth/token`,defaultScopes:[],usePkce:!0,clientAuthMethod:`request_body`,scopeSeparator:`space`}}};Object.fromEntries(Object.values(_).filter(e=>!!e.oauth).map(e=>{let t=e.oauth;return[e.providerId,{id:e.providerId,name:e.name,authorizeUrl:t.authorizeUrl,tokenUrl:t.tokenUrl,redirectUri:t.redirectUri,defaultScopes:t.defaultScopes,usePkce:t.usePkce,clientAuthMethod:t.clientAuthMethod,scopeSeparator:t.scopeSeparator}]})),Object.fromEntries(Object.values(_).map(e=>[e.providerId,{providerId:e.providerId,modes:e.modes,defaultMode:e.defaultMode}])),new Promise(e=>{});
3
3
  /*! @license DOMPurify 3.4.13 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.13/LICENSE */
4
4
  function v(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function y(e){if(Array.isArray(e))return e}function b(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function re(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,r as n,t as r}from"./rolldown-runtime-aKtaBQYM.js";import{C as i,F as a,I as o,O as s,P as c,R as l,m as u,n as d,o as f,r as p,u as m,y as h}from"./config-D4lVqMs8.js";import{a as g,n as _}from"./app-routes-BMQ4HFaM.js";import{n as v,r as y,t as b}from"./txPromise-C2iYogHX.js";import{t as x}from"./getConfig-4saf0Tkq.js";import{t as ee}from"./browser-nBz_r6l4.js";import{a as S,c as C,o as w,t as T}from"./custom-element-security-CU1rI7Pw.js";import{t as E}from"./dist-B9m1QM9v.js";import{E as D,_ as O,a as te,b as ne,c as re,d as ie,f as ae,g as oe,h as se,l as ce,m as le,p as ue,t as de,u as fe,w as pe,x as me,y as he}from"./executeNativeAiTask-CXBr7mSA.js";import{n as ge,r as _e,t as ve}from"./headless-BbtDA5cs.js";import{a as ye,i as be,o as xe,r as Se,s as Ce,t as we}from"./getGroupDir-CLz5c8cg.js";import{a as Te,c as Ee,d as De,f as Oe,l as ke,o as Ae,p as je,r as Me,s as Ne,t as Pe}from"./tools-BCttQkSs.js";import{t as k}from"./setConfig-DdSThoKj.js";import{t as Fe}from"./ulid-BY7rQVLN.js";import{i as Ie,r as Le,t as Re}from"./tools-CcgG5XuA.js";import"./tools-B-PzsLc2.js";import{t as ze}from"./buffer-9oRIc-5Z.js";import{n as Be,r as Ve}from"./crypto-C8c5wMzN.js";import{c as He,d as Ue,i as We,l as Ge,m as Ke,n as qe,p as Je,r as Ye,t as Xe}from"./mcp-reconnect-BK1bYBdC.js";import{a as Ze,c as Qe,d as $e,f as et,h as tt,i as nt,l as rt,m as it,n as at,o as ot,p as st,r as ct,s as lt,t as ut,u as dt,y as ft}from"./is-typed-array-CnI-JI7u.js";import{n as pt,o as mt,r as ht,t as gt}from"./constants-BR3kgTKA.js";import{a as _t,i as vt,n as yt,o as bt,r as xt,s as St,t as Ct}from"./connections-CiukjGiH.js";import{t as wt}from"./getAllTasks-CKZML6au.js";import{r as Tt}from"./push-client-B_IkTpNm.js";import{o as Et,r as Dt}from"./toast-BXgUfbyh.js";const Ot={openrouter:{label:`OpenRouter API Keys`,href:`https://openrouter.ai/keys`},huggingface:{label:`HuggingFace Access Tokens`,href:`https://huggingface.co/settings/tokens`},bedrock_proxy:{label:`AWS Bedrock Setup`,href:`https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html`},ollama:{label:`Install Ollama`,href:`https://ollama.com/download`},prompt_api:{label:`Prompt API Docs`,href:`https://developer.chrome.com/docs/ai/built-in`}},kt=new Set([`ollama`,`bedrock_proxy`,`llamafile`,`transformers_js_local`]);function At(e){return a(e)?.name||e}function jt(e,t,n){let r=(t||``).toLowerCase();return r?n&&(r.includes(`api key not configured`)||r.includes(`go to settings to add your api key`)||r.includes(`missing api key`)||r.includes(`no api key`))?`api-key-missing`:n&&(r.includes(`invalid api key`)||r.includes(`incorrect api key`)||r.includes(`authentication failed`)||r.includes(`401`)||r.includes(`403`)||r.includes(`unauthorized`)||r.includes(`forbidden`))?`api-key-invalid`:r.includes(`429`)||r.includes(`rate limit`)||r.includes(`too many requests`)?`rate-limited`:r.includes(`failed to fetch`)||r.includes(`networkerror`)||r.includes(`network error`)||r.includes(`econnrefused`)||r.includes(`connection refused`)||r.includes(`enotfound`)||r.includes(`timed out`)||r.includes(`timeout`)||r.includes(`503`)||r.includes(`502`)?`provider-unreachable`:null:null}function Mt(e,t,n){let r=At(e),i=Ot[e]?[Ot[e]]:[],a=[],o=`${r} Issue`,s=`ShadowClaw hit a ${r} provider error.`;return t===`api-key-missing`?(o=`${r} API Key Required`,s=`${r} needs an API key before requests can run.`,a.push(`Open Settings > AI > Model Provider and enter an API key as required.`),a.push(`Click Save Provider, then retry your message.`)):t===`api-key-invalid`?(o=`${r} Authentication Failed`,s=`${r} rejected the current API key.`,a.push(`Generate or copy a fresh API key for this provider.`),a.push(`Open Settings > AI > Model Provider, replace the key, click Save Provider, then retry.`)):t===`provider-unreachable`?(o=`${r} Not Reachable`,s=`ShadowClaw could not reach ${r}.`,kt.has(e)?(a.push(`Make sure the local ShadowClaw server is running (npm start) and the proxy URL in Settings is correct.`),a.push(`If this provider depends on another local runtime, verify it is running too.`)):(a.push(`Check internet connectivity and confirm the provider service is available.`),a.push(`If you are using a proxy or VPN, ensure requests to the provider are allowed.`))):t===`rate-limited`&&(o=`${r} Rate Limited`,s=`${r} is throttling requests right now.`,a.push(`Wait a moment and retry the request.`),a.push(`If this keeps happening, switch to a lower-traffic model or reduce request frequency.`)),n&&n.trim()&&a.push(`Details: ${n.trim()}`),{mode:`info`,title:o,message:s,details:a,links:i,confirmLabel:`OK`,autoCloseSeconds:30}}function Nt(e){if(typeof e.size==`number`&&e.size>0)return e.size;if(typeof e.data==`string`&&e.data.length>0){let t=e.data.endsWith(`==`)?2:+!!e.data.endsWith(`=`);return Math.max(0,Math.floor(e.data.length*3/4)-t)}return 0}function Pt(e){return e?e.startsWith(`text/`)||e===`json`||e===`xml`||e===`javascript`||e===`csv`||e===`markdown`:!1}function Ft(e){let t=Nt(e);if(t===0)return 0;switch(e.mediaType){case`image`:return 1500;case`audio`:return 1500;case`video`:return 2500;default:return Pt(e.mimeType)?Math.ceil(t/4):Math.ceil(t/16)}}function It(e){return e?Math.ceil(e.length/4):0}function Lt(e){let t=0;if(typeof e.content==`string`)t=It(e.content);else if(Array.isArray(e.content))for(let n of e.content)if(n.type===`text`&&n.text)t+=It(n.text);else if(n.type===`tool_use`)t+=It(n.name),t+=It(JSON.stringify(n.input));else if(n.type===`tool_result`){let e=n.content;t+=It(typeof e==`string`?e:JSON.stringify(e))}else n.type===`attachment`&&(t+=It(n.fileName),t+=It(n.mimeType),t+=It(n.path),t+=Ft(n));return t+4}function Rt(e,t){if(!e)return``;if(e.length<=t)return e;let n=e.slice(0,t).lastIndexOf(`
1
+ import{i as e,n as t,r as n,t as r}from"./rolldown-runtime-aKtaBQYM.js";import{C as i,F as a,I as o,O as s,P as c,R as l,m as u,n as d,o as f,r as p,u as m,y as h}from"./config-D4lVqMs8.js";import{a as g,n as _}from"./app-routes-BMQ4HFaM.js";import{n as v,r as y,t as b}from"./txPromise-C2iYogHX.js";import{t as x}from"./getConfig-4saf0Tkq.js";import{t as ee}from"./browser-nBz_r6l4.js";import{a as S,c as C,o as w,t as T}from"./custom-element-security-CU1rI7Pw.js";import{t as E}from"./dist-B9m1QM9v.js";import{E as D,_ as O,a as te,b as ne,c as re,d as ie,f as ae,g as oe,h as se,l as ce,m as le,p as ue,t as de,u as fe,w as pe,x as me,y as he}from"./executeNativeAiTask-CXBr7mSA.js";import{n as ge,r as _e,t as ve}from"./headless-BbtDA5cs.js";import{a as ye,i as be,o as xe,r as Se,s as Ce,t as we}from"./getGroupDir-CLz5c8cg.js";import{a as Te,c as Ee,d as De,f as Oe,l as ke,o as Ae,p as je,r as Me,s as Ne,t as Pe}from"./tools-BCttQkSs.js";import{t as k}from"./setConfig-DdSThoKj.js";import{t as Fe}from"./ulid-BY7rQVLN.js";import{i as Ie,r as Le,t as Re}from"./tools-CcgG5XuA.js";import"./tools-B-PzsLc2.js";import{t as ze}from"./buffer-9oRIc-5Z.js";import{n as Be,r as Ve}from"./crypto-C8c5wMzN.js";import{c as He,d as Ue,i as We,l as Ge,m as Ke,n as qe,p as Je,r as Ye,t as Xe}from"./mcp-reconnect-BK1bYBdC.js";import{a as Ze,c as Qe,d as $e,f as et,h as tt,i as nt,l as rt,m as it,n as at,o as ot,p as st,r as ct,s as lt,t as ut,u as dt,y as ft}from"./is-typed-array-CnI-JI7u.js";import{n as pt,o as mt,r as ht,t as gt}from"./constants-BR3kgTKA.js";import{a as _t,i as vt,n as yt,o as bt,r as xt,s as St,t as Ct}from"./connections-CiukjGiH.js";import{t as wt}from"./getAllTasks-CKZML6au.js";import{r as Tt}from"./push-client-D6DLiY1s.js";import{o as Et,r as Dt}from"./toast-BXgUfbyh.js";const Ot={openrouter:{label:`OpenRouter API Keys`,href:`https://openrouter.ai/keys`},huggingface:{label:`HuggingFace Access Tokens`,href:`https://huggingface.co/settings/tokens`},bedrock_proxy:{label:`AWS Bedrock Setup`,href:`https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html`},ollama:{label:`Install Ollama`,href:`https://ollama.com/download`},prompt_api:{label:`Prompt API Docs`,href:`https://developer.chrome.com/docs/ai/built-in`}},kt=new Set([`ollama`,`bedrock_proxy`,`llamafile`,`transformers_js_local`]);function At(e){return a(e)?.name||e}function jt(e,t,n){let r=(t||``).toLowerCase();return r?n&&(r.includes(`api key not configured`)||r.includes(`go to settings to add your api key`)||r.includes(`missing api key`)||r.includes(`no api key`))?`api-key-missing`:n&&(r.includes(`invalid api key`)||r.includes(`incorrect api key`)||r.includes(`authentication failed`)||r.includes(`401`)||r.includes(`403`)||r.includes(`unauthorized`)||r.includes(`forbidden`))?`api-key-invalid`:r.includes(`429`)||r.includes(`rate limit`)||r.includes(`too many requests`)?`rate-limited`:r.includes(`failed to fetch`)||r.includes(`networkerror`)||r.includes(`network error`)||r.includes(`econnrefused`)||r.includes(`connection refused`)||r.includes(`enotfound`)||r.includes(`timed out`)||r.includes(`timeout`)||r.includes(`503`)||r.includes(`502`)?`provider-unreachable`:null:null}function Mt(e,t,n){let r=At(e),i=Ot[e]?[Ot[e]]:[],a=[],o=`${r} Issue`,s=`ShadowClaw hit a ${r} provider error.`;return t===`api-key-missing`?(o=`${r} API Key Required`,s=`${r} needs an API key before requests can run.`,a.push(`Open Settings > AI > Model Provider and enter an API key as required.`),a.push(`Click Save Provider, then retry your message.`)):t===`api-key-invalid`?(o=`${r} Authentication Failed`,s=`${r} rejected the current API key.`,a.push(`Generate or copy a fresh API key for this provider.`),a.push(`Open Settings > AI > Model Provider, replace the key, click Save Provider, then retry.`)):t===`provider-unreachable`?(o=`${r} Not Reachable`,s=`ShadowClaw could not reach ${r}.`,kt.has(e)?(a.push(`Make sure the local ShadowClaw server is running (npm start) and the proxy URL in Settings is correct.`),a.push(`If this provider depends on another local runtime, verify it is running too.`)):(a.push(`Check internet connectivity and confirm the provider service is available.`),a.push(`If you are using a proxy or VPN, ensure requests to the provider are allowed.`))):t===`rate-limited`&&(o=`${r} Rate Limited`,s=`${r} is throttling requests right now.`,a.push(`Wait a moment and retry the request.`),a.push(`If this keeps happening, switch to a lower-traffic model or reduce request frequency.`)),n&&n.trim()&&a.push(`Details: ${n.trim()}`),{mode:`info`,title:o,message:s,details:a,links:i,confirmLabel:`OK`,autoCloseSeconds:30}}function Nt(e){if(typeof e.size==`number`&&e.size>0)return e.size;if(typeof e.data==`string`&&e.data.length>0){let t=e.data.endsWith(`==`)?2:+!!e.data.endsWith(`=`);return Math.max(0,Math.floor(e.data.length*3/4)-t)}return 0}function Pt(e){return e?e.startsWith(`text/`)||e===`json`||e===`xml`||e===`javascript`||e===`csv`||e===`markdown`:!1}function Ft(e){let t=Nt(e);if(t===0)return 0;switch(e.mediaType){case`image`:return 1500;case`audio`:return 1500;case`video`:return 2500;default:return Pt(e.mimeType)?Math.ceil(t/4):Math.ceil(t/16)}}function It(e){return e?Math.ceil(e.length/4):0}function Lt(e){let t=0;if(typeof e.content==`string`)t=It(e.content);else if(Array.isArray(e.content))for(let n of e.content)if(n.type===`text`&&n.text)t+=It(n.text);else if(n.type===`tool_use`)t+=It(n.name),t+=It(JSON.stringify(n.input));else if(n.type===`tool_result`){let e=n.content;t+=It(typeof e==`string`?e:JSON.stringify(e))}else n.type===`attachment`&&(t+=It(n.fileName),t+=It(n.mimeType),t+=It(n.path),t+=Ft(n));return t+4}function Rt(e,t){if(!e)return``;if(e.length<=t)return e;let n=e.slice(0,t).lastIndexOf(`
2
2
  `),r=n>t*.5?n:t;return`${e.slice(0,r)}\n[...truncated ${e.length-r} chars]`}function zt(e,t){let{contextLimit:n,systemPromptTokens:r,maxOutputTokens:i,skimTop:a=!1}=t;if(e.length===0)return{messages:[],estimatedTokens:0,truncatedCount:0,contextLimit:n,usagePercent:0};let o=Math.max(0,n-r-i),s=Math.min(25e3,Math.max(1e3,Math.floor(o*.6*4))),c=e.map(e=>Bt(e,s)),l=0,u=c.length,d=null,f=0;if(a&&c.length>0){let e=c[0];(e.role===`user`||e.role===`system`)&&(f=Lt(e),f<=o&&(d=e))}let p=o-f;for(let e=c.length-1;e>=+!!d;e--){let t=Lt(c[e]),n=c[e],r=!1;if(n.role===`user`&&Array.isArray(n.content)&&n.content.some(e=>e.type===`tool_result`)){let n=c[e-1];n&&n.role===`assistant`&&Array.isArray(n.content)&&n.content.some(e=>e.type===`tool_use`)&&(r=!0,t+=Lt(n))}if(l+t>p&&e<c.length-1)break;l+=t,r?(u=e-1,e--):u=e}let m=c.slice(u),h=u;d&&u>0&&(m=[d,...m],h=Math.max(0,u-1));let g=l+f,_=g+r,v=n>0?Math.round(_/n*100*10)/10:0;return{messages:m,estimatedTokens:g,truncatedCount:h,contextLimit:n,usagePercent:v}}function Bt(e,t){if(!Array.isArray(e.content))return e;let n=e.content.map(e=>e.type===`tool_result`&&typeof e.content==`string`?{...e,content:Rt(e.content,t)}:e);return{...e,content:n}}async function Vt(e,t,n){let r=await we(e,t),{dirs:i,filename:a}=je(n),o=r;for(let e of i)o=await o.getDirectoryHandle(e);let s=await o.getFileHandle(a);try{let e=await s.createSyncAccessHandle(),t=e.getSize(),n=new Uint8Array(t);return e.read(n,{at:0}),e.close(),n}catch{let e=await(await s.getFile()).arrayBuffer();return new Uint8Array(e)}}function Ht(e,t,n){let r=null,i,a;return typeof e==`string`?(i=e,a=t):(r=e,i=t,a=n??50),r&&v(r)?Promise.resolve().then(()=>(r.db.prepare(`SELECT * FROM messages WHERE groupId = ? ORDER BY timestamp DESC LIMIT ?`).all(i,a)??[]).reverse().map(Ut)):new Promise(async(e,t)=>{try{let n=r??await y();if(!n)return t(Error(`failed to get transaction, cannot get recent messages.`));let o=n.transaction(`messages`,`readonly`);if(!o)return t(Error(`failed to get transaction`));let s=o.objectStore(`messages`).index(`by-group-time`),c=IDBKeyRange.bound([i,0],[i,1/0]),l=s.openCursor(c,`prev`),u=[];l.onsuccess=()=>{let t=l.result;t&&u.length<a?(u.push(t.value),t.continue()):e(u.reverse())},l.onerror=()=>t(l.error)}catch(e){t(e)}})}function Ut(e){return{...e,isFromMe:!!e.isFromMe,isTrigger:!!e.isTrigger,attachments:e.attachments?JSON.parse(e.attachments):void 0,a2uiAction:e.a2uiAction?JSON.parse(e.a2uiAction):void 0,a2uiEnvelopes:e.a2uiEnvelopes?JSON.parse(e.a2uiEnvelopes):void 0}}const Wt=5*1024*1024,Gt=20*1024*1024;async function Kt(e,t){let n=await Ht(e,t),r=await y();return await Promise.all(n.map(async t=>{if(t.isFromMe)return{role:`assistant`,content:t.content};let n=`${t.sender}: ${t.content}`,i=await qt(r,e,t.attachments||[]);return i.length===0?{role:`user`,content:n}:{role:`user`,content:[{type:`text`,text:n},...i]}}))}async function qt(e,t,n){let r=[];for(let i of n){let n=i.mimeType||`application/octet-stream`,a=D(n,i.fileName),o=a===`text`?`file`:a===`document`?`document`:a,s={type:`attachment`,mediaType:o,fileName:i.fileName,mimeType:n,size:i.size,path:i.path};if(e&&o===`image`&&i.path&&(i.size||0)<=3145728)try{s.data=Jt(await Vt(e,t,i.path))}catch{}if(e&&o===`audio`&&i.path&&(i.size||0)<=Wt)try{s.data=Jt(await Vt(e,t,i.path))}catch{}if(e&&o===`document`&&i.path&&(i.size||0)<=Gt)try{s.data=Jt(await Vt(e,t,i.path))}catch{}if(e&&o===`audio`&&i.path&&(i.size||0)<=Wt)try{s.data=Jt(await Vt(e,t,i.path))}catch{}if(e&&o===`document`&&i.path&&(i.size||0)<=Gt)try{s.data=Jt(await Vt(e,t,i.path))}catch{}r.push(s)}return r}function Jt(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n){let i=e.subarray(r,r+n);t+=String.fromCharCode(...i)}return btoa(t)}const Yt=`group_metadata`;async function Xt(e){let t=await x(e,Yt);if(!t)return[];try{return JSON.parse(t)}catch{return[]}}async function Zt(e,t){await k(e,Yt,JSON.stringify(t))}async function Qt(e,t,n=`br:`,r){let i=await Xt(e),a={groupId:`${n}${r??Fe()}`,name:t,createdAt:Date.now()};return i.push(a),await Zt(e,i),a}async function $t(e,t,n){let r=await Xt(e),i=r.find(e=>e.groupId===t);i&&(i.name=n),await Zt(e,r)}async function en(e,t,n){let r=await Xt(e),i=r.find(e=>e.groupId===t);i&&(n&&n.length>0?i.toolTags=n:delete i.toolTags),await Zt(e,r)}async function tn(e,t){await Zt(e,(await Xt(e)).filter(e=>e.groupId!==t))}async function nn(e){let t=await Xt(e);if(t.length===0){let t={groupId:f,name:`Main`,createdAt:0};return await Zt(e,[t]),[t]}return t}async function rn(e,t){let n=await Xt(e),r=new Map(n.map(e=>[e.groupId,e])),i=[];for(let e of t){let t=r.get(e);t&&(i.push(t),r.delete(e))}for(let e of n)r.has(e.groupId)&&i.push(e);await Zt(e,i)}async function an(e,t){let n=await Xt(e),r=n.find(e=>e.groupId===t);if(!r)return null;let i=t.indexOf(`:`),a={groupId:`${i>=0?t.slice(0,i+1):`br:`}${Fe()}`,name:`${r.name} (copy)`,createdAt:Date.now(),pinnedMaxTokens:r.pinnedMaxTokens,providerRuntimeOverrides:r.providerRuntimeOverrides?JSON.parse(JSON.stringify(r.providerRuntimeOverrides)):void 0,subagentModelSelectionMode:r.subagentModelSelectionMode,subagentMaxTokens:r.subagentMaxTokens,subagentPinnedProvider:r.subagentPinnedProvider,subagentPinnedModel:r.subagentPinnedModel,subagentFastProvider:r.subagentFastProvider,subagentFastModel:r.subagentFastModel,subagentSmartProvider:r.subagentSmartProvider,subagentSmartModel:r.subagentSmartModel,subagentPowerfulProvider:r.subagentPowerfulProvider,subagentPowerfulModel:r.subagentPowerfulModel,toolTags:r.toolTags?[...r.toolTags]:void 0};return n.push(a),await Zt(e,n),a}async function on(e,t,n,r,i){let a=await Xt(e),o=a.find(e=>e.groupId===t);o&&(n?o.pinnedProvider=n:delete o.pinnedProvider,r?o.pinnedModel=r:delete o.pinnedModel,typeof i==`number`&&Number.isFinite(i)&&i>0?o.pinnedMaxTokens=Math.floor(i):delete o.pinnedMaxTokens),await Zt(e,a)}async function sn(e,t,n,r,i,a){let o=await Xt(e),s=o.find(e=>e.groupId===t);s&&(s.subagentModelSelectionMode=n,n===`manual`?(r?s.subagentPinnedProvider=r:delete s.subagentPinnedProvider,i?s.subagentPinnedModel=i:delete s.subagentPinnedModel):(delete s.subagentPinnedProvider,delete s.subagentPinnedModel),typeof a==`number`&&Number.isFinite(a)&&a>0?s.subagentMaxTokens=Math.floor(a):delete s.subagentMaxTokens),await Zt(e,o)}async function cn(e,t,n){let r=await Xt(e),i=r.find(e=>e.groupId===t);i&&(n&&Object.keys(n).length>0?i.providerRuntimeOverrides=JSON.parse(JSON.stringify(n)):delete i.providerRuntimeOverrides),await Zt(e,r)}function ln(e,t,n,r){return{type:`thinking-log`,payload:{groupId:e,level:t,timestamp:Date.now(),label:n,message:r||``}}}function un(e,t,n){return{type:`tool-activity`,payload:{groupId:e,tool:t,status:n}}}async function dn(e,t,n,r){let{dirs:i,filename:a}=je(n);for(let n=0;n<2;n++)try{let n=await we(e,t);for(let e of i)n=await n.getDirectoryHandle(e,{create:!0});let o=await n.getFileHandle(a,{create:!0});try{await Ne(o,r);return}catch(t){if(!((t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`)&&(await ye(e)).type===`opfs`))throw t}let s=t.replace(/:/g,`-`);await Ee([Se(),`groups`,s,...i,a],r);return}catch(e){if(n===0&&Ce(e)){xe();continue}throw e}}let fn=null;function pn(e){fn=e}const mn=new Map;function hn(e,t){mn.set(e,t)}function gn(e){mn.delete(e)}function _n(e){let t=e?.payload?.groupId;if(t&&mn.has(t)){mn.get(t).push(e);return}if(fn){fn(e);return}typeof self<`u`&&typeof self.postMessage==`function`&&self.postMessage(e)}function vn(e,t){let n=RegExp(`<${t}[^>]*>`,`i`),r=e.match(n);if(!r||r.index===void 0)return null;let i=r.index+r[0].length,a=RegExp(`</${t}>`,`i`),o=e.slice(i).match(a);return!o||o.index===void 0?null:e.slice(i,i+o.index)}function yn(e,t){let n=e;for(let e of t)n=n.replace(RegExp(`<${e}[^>]*>[\\s\\S]*?</${e}>`,`gi`),``);return n}function bn(e){let t=e;return t=t.replace(/<[^>]+>/g,` `),t=t.replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/g,`'`).replace(/&nbsp;/g,` `).replace(/&#\d+;/g,``),t=t.replace(/[ \t]+/g,` `).replace(/\n\s*\n/g,`
3
3
  `).replace(/ \n/g,`
4
4
  `).trim(),t}function xn(e){let t=vn(e,`main`)||vn(e,`article`)||e;return t=yn(t,[`script`,`style`,`noscript`,`svg`,`head`,`nav`,`footer`,`header`,`aside`]),t=t.replace(/<!--[\s\S]*?-->/g,``),bn(t)}const Sn=new Set,Cn=6e4,wn=typeof document>`u`?`worker`:`ui`,Tn=new Map,En=new Map,Dn=new Map,On=new Map,kn=new Map;let An=null,jn=!1;function Mn(){return`[WebVM:${wn}]`}async function Nn(){ir()}async function Pn(e,t=900,n=null){{let e=In();return`Error: WebVM is not available. The VM requires local assets served at /assets/ (alpine-fs.json, libv86.mjs, etc). Use the "javascript" tool for code execution, or the "fetch_url" tool for HTTP requests.`+(e.error?`\nReason: ${e.error}`:e.booting?`
@@ -1804,7 +1804,7 @@ Important: Use write_file (not bash/sed) to write resolved files. Ensure NO conf
1804
1804
  ---
1805
1805
 
1806
1806
  `)}return ZB($B(e,n),n,{parentGroupId:t,workspaceMode:r})}function tV(e,t){if(!e.schedule||typeof e.schedule!=`string`)return`Error: Missing or invalid 'schedule' (cron expression) for create_task.`;let n=e.type===`tools`?`tools`:`prompt`;if(n===`prompt`&&(!e.prompt||typeof e.prompt!=`string`))return`Error: Missing or invalid 'prompt' for create_task with type 'prompt'.`;let r={createdAt:Date.now(),enabled:!0,groupId:t,id:Fe(),lastRun:null,prompt:e.prompt?e.prompt.trim():``,schedule:e.schedule.trim(),tools:Array.isArray(e.tools)?e.tools:[],type:n};return typeof e.name==`string`&&e.name.trim()&&(r.name=e.name.trim()),_n({type:`task-created`,payload:{task:r}}),`Task created successfully.\nID: ${r.id}\nSchedule: ${r.schedule}\nType: ${r.type}`}function nV(e,t){return e.id?(_n({type:`delete-task`,payload:{id:e.id,groupId:t}}),`Task ${e.id} deleted successfully.`):`Error: Missing required task ID for deletion.`}async function rV(e,t){return(await wt(e)).filter(e=>e.groupId===t)}async function iV(e,t,n){let r=(await rV(e,n)).find(e=>e.id===t.id);return r?(r.enabled=!1,_n({type:`update-task`,payload:{task:r}}),`Task ${t.id} disabled successfully.`):`Error: Task with ID ${t.id} not found.`}async function aV(e,t,n){let r=(await rV(e,n)).find(e=>e.id===t.id);return r?(r.enabled=!0,_n({type:`update-task`,payload:{task:r}}),`Task ${t.id} enabled successfully.`):`Error: Task with ID ${t.id} not found.`}async function oV(e,t){let n=await rV(e,t);return n.length===0?`No tasks found for this group.`:(n.sort((e,t)=>{let n=e.order??0,r=t.order??0;return n===r?e.createdAt-t.createdAt:n-r}),n.map(e=>`[ID: ${e.id}] Name: ${e.name||`(none)`}, Schedule: ${e.schedule}, Type: ${e.type||`prompt`}, Enabled: ${e.enabled}`).join(`
1807
- `))}async function sV(e,t,n){let r=(await rV(e,n)).find(e=>e.id===t.id);return r?(_n({type:`run-task`,payload:{task:r}}),`Task ${t.id} triggered successfully.`):`Error: Task with ID ${t.id} not found.`}async function cV(e,t,n){let r=(await rV(e,n)).find(e=>e.id===t.id);return r?(t.schedule&&(r.schedule=t.schedule),(t.type===`prompt`||t.type===`tools`)&&(r.type=t.type),t.prompt&&(r.prompt=t.prompt),Array.isArray(t.tools)&&(r.tools=t.tools),t.enabled!==void 0&&(r.enabled=!!t.enabled),t.name!==void 0&&(r.name=typeof t.name==`string`?t.name.trim():void 0),_n({type:`update-task`,payload:{task:r}}),`Task ${t.id} updated successfully.`):`Error: Task with ID ${t.id} not found.`}async function lV(e,t){let{question:n,options:r}=e;if(!n)return`Error: question is required.`;let i=Fe();return _n({type:`ask-user`,payload:{id:i,groupId:t,question:n,options:r}}),await new Promise(e=>{globalThis.pendingAskUserResolvers=globalThis.pendingAskUserResolvers||{},globalThis.pendingAskUserResolvers[i]=e})}function uV(e){return _n({type:`clear-chat`,payload:{groupId:e}}),`Chat history cleared successfully. New session started.`}function dV(e){let t=new Date,n=e.timezone;if(n)try{return new Intl.DateTimeFormat(`en-US`,{timeZone:n,timeStyle:`long`,dateStyle:`long`}).format(t)}catch(e){return`Error: Invalid timezone ${n} - ${e.message}`}return t.toISOString()}let fV;function pV(){if(fV!==void 0)return fV;let e=Reflect.get(globalThis,`trustedTypes`);if(!e||typeof e.createPolicy!=`function`)return fV=null,fV;try{fV=e.createPolicy(`shadowclaw-sandbox`,{createScriptURL:e=>e})}catch{fV=null}return fV}const mV=[`self`,`postMessage`,`importScripts`,`close`,`onmessage`,`onmessageerror`,`onerror`,`setInterval`,`XMLHttpRequest`,`WebSocket`,`indexedDB`,`caches`,`navigator`,`location`,`eval`,`Function`];function hV(e){return e?mV:[...mV,`fetch`]}async function gV(e,t=3e4,n=!1,r){let i=_V(e,n,r),a=new Blob([i],{type:`application/javascript`}),o=URL.createObjectURL(a),s=null;try{return await new Promise(e=>{let n=setTimeout(()=>{s&&=(s.terminate(),null),e({ok:!1,error:`Execution timed out after ${t/1e3}s`})},t),r=pV(),i=r&&typeof r.createScriptURL==`function`?r.createScriptURL(o):o,a=new Worker(i);s=a,a.onmessage=t=>{clearTimeout(n),a.terminate(),s=null,e(t.data)},a.onerror=t=>{clearTimeout(n),a.terminate(),s=null,e({ok:!1,error:t.message||`Unknown worker error`})}})}finally{URL.revokeObjectURL(o),s&&s.terminate()}}function _V(e=``,t=!1,n){return`
1807
+ `))}async function sV(e,t,n){let r=(await rV(e,n)).find(e=>e.id===t.id);return r?(_n({type:`run-task`,payload:{task:r}}),`Task ${t.id} triggered successfully.`):`Error: Task with ID ${t.id} not found.`}async function cV(e,t,n){let r=(await rV(e,n)).find(e=>e.id===t.id);return r?(t.schedule&&(r.schedule=t.schedule),(t.type===`prompt`||t.type===`tools`)&&(r.type=t.type),t.prompt&&(r.prompt=t.prompt),Array.isArray(t.tools)&&(r.tools=t.tools),t.enabled!==void 0&&(r.enabled=!!t.enabled),t.name!==void 0&&(r.name=typeof t.name==`string`?t.name.trim():void 0),_n({type:`update-task`,payload:{task:r}}),`Task ${t.id} updated successfully.`):`Error: Task with ID ${t.id} not found.`}async function lV(e,t){let{question:n,options:r}=e;if(!n)return`Error: question is required.`;let i=Fe();return _n({type:`ask-user`,payload:{id:i,groupId:t,question:n,options:r}}),await new Promise(e=>{globalThis.pendingAskUserResolvers=globalThis.pendingAskUserResolvers||{},globalThis.pendingAskUserResolvers[i]=e})}function uV(e){return _n({type:`clear-chat`,payload:{groupId:e}}),`Chat history cleared successfully. New session started.`}function dV(e){let t=new Date,n=e.timezone;if(n)try{return new Intl.DateTimeFormat(`en-US`,{timeZone:n,timeStyle:`long`,dateStyle:`long`}).format(t)}catch(e){return`Error: Invalid timezone ${n} - ${e.message}`}return t.toISOString()}let fV;function pV(){if(fV!==void 0)return fV;let e=Reflect.get(globalThis,`trustedTypes`);if(!e||typeof e.createPolicy!=`function`)return fV=null,fV;try{fV=e.createPolicy(`shadowclaw-sandbox`,{createScriptURL:e=>e})}catch{fV=null}return fV}const mV=[`self`,`postMessage`,`importScripts`,`close`,`onmessage`,`onmessageerror`,`onerror`,`setInterval`,`XMLHttpRequest`,`WebSocket`,`indexedDB`,`caches`,`navigator`,`location`,`eval`,`Function`];function hV(e){return e?mV:[...mV,`fetch`]}async function gV(e,t=3e4,n=!1,r){if(typeof Worker>`u`){let i=globalThis.__headlessEvalExecutor;return typeof i==`function`?i(e,t,n,r):{ok:!1,error:`Web Workers are not supported in this environment.`}}let i=_V(e,n,r),a=new Blob([i],{type:`application/javascript`}),o=URL.createObjectURL(a),s=null;try{return await new Promise(e=>{let n=setTimeout(()=>{s&&=(s.terminate(),null),e({ok:!1,error:`Execution timed out after ${t/1e3}s`})},t),r=pV(),i=r&&typeof r.createScriptURL==`function`?r.createScriptURL(o):o,a=new Worker(i);s=a,a.onmessage=t=>{clearTimeout(n),a.terminate(),s=null,e(t.data)},a.onerror=t=>{clearTimeout(n),a.terminate(),s=null,e({ok:!1,error:t.message||`Unknown worker error`})}})}finally{URL.revokeObjectURL(o),s&&s.terminate()}}function _V(e=``,t=!1,n){return`
1808
1808
  "use strict";
1809
1809
  const blocked = ${JSON.stringify(hV(t))};
1810
1810
  const __hostPostMessage =
@@ -1909,6 +1909,7 @@ const restoreGlobals = applyGlobalShadows();
1909
1909
  const Function = undefined;
1910
1910
  ${t?``:`const fetch = undefined;`}
1911
1911
  const $PIPE_DATA = ${JSON.stringify(n??``)};
1912
+ const data = $PIPE_DATA;
1912
1913
 
1913
1914
  ${e}
1914
1915
  })();
@@ -1,4 +1,4 @@
1
- import{D as e,E as t,F as n,I as r,M as i,O as a,P as o,R as s,T as c,_ as l,g as u,j as d,l as f,o as p,r as m,s as h,t as g,v as _,w as v}from"./config-D4lVqMs8.js";import{i as y,n as b,r as x}from"./txPromise-C2iYogHX.js";import{t as S}from"./getConfig-4saf0Tkq.js";import{p as C}from"./custom-element-security-CU1rI7Pw.js";import{t as w}from"./dist-B9m1QM9v.js";import{$t as T,At as E,Bt as D,C as O,Ct as k,Dt as A,Et as ee,G as j,H as te,I as M,It as N,Jt as P,Kt as F,Lt as I,M as ne,Mt as re,N as L,Ot as R,P as ie,Qt as z,Rt as B,St as ae,Tt as oe,U as V,V as H,W as se,X as ce,Y as le,Yt as ue,Zt as U,an as de,at as fe,bt as pe,dt as me,en as he,ft as ge,gt as _e,j as ve,jt as ye,kt as be,l as xe,nn as Se,ot as Ce,qt as we,rn as Te,t as W,tn as Ee,u as De,ut as Oe,zt as ke}from"./orchestrator-Baif6kmu.js";import{C as Ae,S as je,a as G,d as Me,i as Ne,o as Pe,r as Fe,s as Ie,v as Le,w as K}from"./executeNativeAiTask-CXBr7mSA.js";import{n as Re,r as ze}from"./headless-BbtDA5cs.js";import{l as Be,r as Ve}from"./getGroupDir-CLz5c8cg.js";import{c as He,f as Ue,s as We,t as q,u as Ge}from"./tools-BCttQkSs.js";import{t as J}from"./setConfig-DdSThoKj.js";import{t as Y}from"./ulid-BY7rQVLN.js";import{t as Ke}from"./tools-CcgG5XuA.js";import{i as qe,r as Je}from"./syncWebMcpRegistration-CLMvJ4kV.js";import"./tools-B-PzsLc2.js";import{n as Ye,r as Xe}from"./crypto-C8c5wMzN.js";import{a as Ze,i as Qe,r as X,t as $e}from"./peerjs-DE6WF3h2.js";import{i as et,r as tt}from"./webmcp-CcIw3_V3.js";import{ensureControlPlaneConnected as nt}from"./initControlPlane-e2JgxXEb.js";async function rt(e){if(!(!e||e.name===`shadowclaw`)){try{if(await S(e,m.DB_MIGRATED_FROM_LEGACY)===`true`)return}catch{}try{let t=await new Promise(e=>{let t=indexedDB.open(l);t.onsuccess=()=>{let n=t.result;if(!n.objectStoreNames||n.objectStoreNames.length===0){n.close(),e(null);return}e(n)},t.onerror=()=>e(null)});if(t){let n=Array.from(t.objectStoreNames).filter(t=>e.objectStoreNames.contains(t));for(let r of n)await new Promise(n=>{try{let i=t.transaction(r,`readonly`).objectStore(r).getAll();i.onsuccess=()=>{let t=i.result||[];if(t.length>0)try{let i=e.transaction(r,`readwrite`),a=i.objectStore(r);for(let e of t)a.put(e);i.oncomplete=()=>n(),i.onerror=()=>n(),i.onabort=()=>n()}catch{n()}else n()},i.onerror=()=>n()}catch{n()}});t.close()}}catch(e){console.warn(`Legacy IndexedDB migration warning:`,e)}finally{try{await J(e,m.DB_MIGRATED_FROM_LEGACY,`true`)}catch{}}}}async function it(e,t,n){for await(let[r,i]of e.entries())if(i.kind===`directory`)await it(i,await t.getDirectoryHandle(r,{create:!0}),[...n,r]);else if(i.kind===`file`){let e=await i.getFile(),a=await t.getFileHandle(r,{create:!0});try{await We(a,e)}catch(t){if(!(t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`))throw t;await He([...n,r],e)}}}async function at(e){if(!e)return;try{if(await S(e,m.OPFS_MIGRATED_FROM_LEGACY)===`true`)return}catch{}let t=Ve();if(t!==`shadowclaw`&&!(typeof navigator>`u`||!navigator.storage||typeof navigator.storage.getDirectory!=`function`))try{let n=await navigator.storage.getDirectory(),r;try{r=await n.getDirectoryHandle(_)}catch{try{await J(e,m.OPFS_MIGRATED_FROM_LEGACY,`true`)}catch{}return}let i=await n.getDirectoryHandle(t,{create:!0});await it(r,i,[t])}catch(e){console.warn(`Legacy OPFS migration warning:`,e)}finally{try{await J(e,m.OPFS_MIGRATED_FROM_LEGACY,`true`)}catch{}}}function ot(){return new Promise(async(e,t)=>{let n,r=d(),i=indexedDB.open(r,2);i.onupgradeneeded=()=>{let e=i.result;if(!e.objectStoreNames.contains(`messages`)){let t=e.createObjectStore(`messages`,{keyPath:`id`});t.createIndex(`by-group-time`,[`groupId`,`timestamp`]),t.createIndex(`by-group`,`groupId`)}if(e.objectStoreNames.contains(`sessions`)||e.createObjectStore(`sessions`,{keyPath:`groupId`}),!e.objectStoreNames.contains(`tasks`)){let t=e.createObjectStore(`tasks`,{keyPath:`id`});t.createIndex(`by-group`,`groupId`),t.createIndex(`by-enabled`,`enabled`)}e.objectStoreNames.contains(`config`)||e.createObjectStore(`config`,{keyPath:`key`}),e.objectStoreNames.contains(`pendingShares`)||e.createObjectStore(`pendingShares`,{keyPath:`id`}).createIndex(`by-createdAt`,`createdAt`)},i.onsuccess=async()=>{n=i.result,y(n);try{await rt(n),await at(n)}catch(e){console.warn(`Error running legacy migration:`,e)}e(n)},i.onerror=()=>{t(Error(`Failed to open IndexedDB: ${i.error?.message}`))}})}var st=class{activeGroupId;displayCallback;messageCallback;type;typingCallback;constructor(){this.type=`browser`,this.messageCallback=null,this.typingCallback=null,this.displayCallback=null,this.activeGroupId=p}getActiveGroup(){return this.activeGroupId}onDisplay(e){this.displayCallback=e}onMessage(e){this.messageCallback=e}onTyping(e){this.typingCallback=e}setActiveGroup(e){this.activeGroupId=e}setTyping(e,t){this.typingCallback?.(e,t)}start(){}stop(){}submit(e,t,n=[],r,i,a){let o=t||this.activeGroupId,s={id:Y(),groupId:o,sender:`You`,content:e,timestamp:Date.now(),channel:`browser`,attachments:n,a2uiAction:r,freshContext:i,subagent:a};this.messageCallback?.(s)}async send(e,t,n){this.displayCallback?.(e,t,!0)}},ct=class{_entries;constructor(){this._entries=[]}find(e){return this.resolve(e)?.channel??null}get(e){return this._entries.find(t=>t.prefix===e)?.channel}getBadge(e){return this.resolve(e)?.badge??``}getChannelType(e){return this.resolve(e)?.channel.type??null}onMessage(e){for(let t of this._entries)t.channel.onMessage(e)}onTyping(e){for(let t of this._entries)t.channel.onTyping&&t.channel.onTyping(e)}prefixes(){return this._entries.map(e=>e.prefix)}register(e,t,n){let r=typeof n==`string`?{badge:n}:n??{};this._entries.push({prefix:e,channel:t,badge:r.badge??e.replace(/:$/,``),autoTrigger:r.autoTrigger??!1}),this._entries.sort((e,t)=>t.prefix.length-e.prefix.length)}resolve(e){for(let t of this._entries)if(e.startsWith(t.prefix))return t;return null}shouldAutoTrigger(e){return this.resolve(e)?.autoTrigger??!1}startAll(){for(let e of this._entries)e.channel.start()}stopAll(){for(let e of this._entries)e.channel.stop()}},lt=class{abortController=null;apiKey=``;apiMode=`unknown`;cursor=null;fileReader=null;messageCallback=null;reconnectDelayMs=1e3;registeredChatIds=new Set;running=!1;seenMessageIds=new Map;serverUrl=``;type=`imessage`;configure(e,t,n){this.serverUrl=ut(e),this.apiKey=t.trim(),this.registeredChatIds=new Set(n.map(e=>e.trim()).filter(Boolean)),this.cursor=null,this.apiMode=`unknown`}handleIncomingMessage(e){this.pruneSeenMessageIds();let t=String(e.chatId||e.conversationId||``).trim();if(!t||this.registeredChatIds.size>0&&!this.registeredChatIds.has(t))return;let n=`${e.text||e.body||``}`.trim();if(!n)return;let r=`${e.id||e.guid||`${t}:${e.timestamp||e.createdAt||n}`}`;if(this.seenMessageIds.has(r))return;this.seenMessageIds.set(r,Date.now());let i={id:r,groupId:`im:${t}`,sender:`${e.sender||e.handle||e.from||`iMessage`}`,content:n,timestamp:dt(e.timestamp||e.createdAt),channel:`imessage`};this.messageCallback?.(i)}handlePollResponse(e){e.nextCursor!==void 0&&e.nextCursor!==null?this.cursor=String(e.nextCursor):e.cursor!==void 0&&e.cursor!==null&&(this.cursor=String(e.cursor));let t=Array.isArray(e.messages)?e.messages:[];for(let e of t)this.handleIncomingMessage(e)}isConfigured(){return this.serverUrl.length>0}onMessage(e){this.messageCallback=e}pruneSeenMessageIds(){let e=Date.now();for(let[t,n]of this.seenMessageIds.entries())e-n>6e4&&this.seenMessageIds.delete(t)}setTyping(e,t){if(!t)return;let n=e.replace(/^im:/,``);this.requestJson(`/messages/typing`,{method:`POST`,body:JSON.stringify({chatId:n,typing:!0})}).catch(()=>{})}start(){!this.isConfigured()||this.running||(this.running=!0,this.abortController=new AbortController,this.poll())}ensureConnected(){!this.isConfigured()||!this.running||(this.reconnectDelayMs=1e3,this.abortController?.abort(),this.abortController=new AbortController,this.poll())}stop(){this.running=!1,this.abortController?.abort(),this.abortController=null}async ensureApiMode(){if(this.apiMode!==`unknown`)return this.apiMode;try{await this.requestJson(`/v1/info`,{method:`GET`}),this.apiMode=`beeper-desktop`}catch{this.apiMode=`legacy`}return this.apiMode}async poll(){for(;this.running&&this.abortController&&!this.abortController.signal.aborted;)try{let e=new URLSearchParams({timeout:`25`});this.cursor&&e.set(`cursor`,this.cursor);let t=await this.requestJson(`/messages?${e.toString()}`,{method:`GET`},u+5e3,this.abortController.signal);this.reconnectDelayMs=1e3,this.handlePollResponse(t)}catch(e){if(e instanceof Error&&e.name===`AbortError`)break;console.error(`iMessage bridge poll error:`,e),await ft(this.reconnectDelayMs),this.reconnectDelayMs=Math.min(this.reconnectDelayMs*2,3e4)}}async requestJson(e,t,n=u,r){let i=new AbortController,a=setTimeout(()=>i.abort(),n),o=()=>i.abort();r?.addEventListener(`abort`,o,{once:!0});try{let n=new Headers(t.headers);n.set(`Accept`,`application/json`),!n.has(`Content-Type`)&&t.body&&!(t.body instanceof FormData)&&n.set(`Content-Type`,`application/json`),this.apiKey&&(n.set(`Authorization`,`Bearer ${this.apiKey}`),n.set(`X-API-Key`,this.apiKey));let r=await fetch(`${this.serverUrl}${e}`,{...t,headers:n,signal:i.signal});if(!r.ok){let e=await r.text();throw Error(`iMessage bridge request failed: ${r.status} ${e}`)}return r.status===204?{messages:[]}:await r.json()}finally{clearTimeout(a),r?.removeEventListener(`abort`,o)}}async send(e,t,n){let r=e.replace(/^im:/,``),{remainingText:i,attachments:a}=pt(t);for(let t of a){if(!this.fileReader){await this.sendText(r,`[${t.alt}] (file: ${t.path})`);continue}try{let n=await this.fileReader(e,t.path);if(!n||n.size===0)throw Error(`Attachment file is empty or unavailable.`);await this.sendAttachment(r,n,t)}catch(e){console.warn(`iMessage attachment send failed for ${t.path}:`,e),await this.sendText(r,`[${t.alt}] (file: ${t.path})`)}}let o=i.trim();o&&await this.sendText(r,o)}async sendAttachment(e,t,n){if(await this.ensureApiMode()===`beeper-desktop`){await this.sendAttachmentViaBeeperDesktop(e,t,n);return}await this.sendAttachmentViaLegacyBridge(e,t,n)}async sendAttachmentViaBeeperDesktop(e,t,n){let r=n.path.split(`/`).pop()||`attachment.bin`,i=new FormData;i.append(`file`,t,r),i.append(`fileName`,r),t.type&&i.append(`mimeType`,t.type);let a=`${(await this.requestJson(`/v1/assets/upload`,{method:`POST`,body:i})).uploadID||``}`.trim();if(!a)throw Error(`Beeper asset upload failed: missing uploadID`);await this.requestJson(`/v1/chats/${encodeURIComponent(e)}/messages`,{method:`POST`,body:JSON.stringify({text:n.alt||void 0,attachment:{uploadID:a,fileName:r,mimeType:t.type||void 0}})})}async sendAttachmentViaLegacyBridge(e,t,n){let r=n.path.split(`/`).pop()||`attachment.bin`,i=new FormData;i.append(`chatId`,e),n.alt&&i.append(`text`,n.alt),i.append(`file`,t,r),await this.requestJson(`/messages/send`,{method:`POST`,body:i})}async sendText(e,t){if(await this.ensureApiMode()===`beeper-desktop`){await this.requestJson(`/v1/chats/${encodeURIComponent(e)}/messages`,{method:`POST`,body:JSON.stringify({text:t})});return}await this.requestJson(`/messages/send`,{method:`POST`,body:JSON.stringify({chatId:e,text:t})})}};function ut(e){return e.trim().replace(/\/+$/,``)}function dt(e){if(typeof e==`number`&&Number.isFinite(e))return e>0xe8d4a51000?e:e*1e3;if(typeof e==`string`){let t=Number(e);if(Number.isFinite(t))return dt(t);let n=Date.parse(e);if(Number.isFinite(n))return n}return Date.now()}function ft(e){return new Promise(t=>setTimeout(t,e))}function pt(e){let t=[],n=/!?\[([^\]]*)\]\(([^)]+)\)/g,r=null,i=e;for(;(r=n.exec(e))!==null;){let e=r[1]||``,n=mt((r[2]||``).trim());n&&(t.push({alt:e,path:n}),i=i.replace(r[0],``))}return{remainingText:i,attachments:t}}function mt(e){if(!e)return null;let t=e.trim();if(/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(t)||t.startsWith(`//`))return null;let n=t.replace(/\\/g,`/`).replace(/^\/+/,``).replace(/^\.\//,``);if(!n)return null;let r=n.split(`/`).filter(Boolean);return r.some(e=>e===`..`)?null:r.join(`/`)}var ht=class{messageCallback=null;running=!1;type=`room`;typingCallback=null;_manager=null;_peerjs=null;deliverInbound(e){this.messageCallback?.(e)}onMessage(e){this.messageCallback=e}onTyping(e){this.typingCallback=e}setManager(e){this._manager=e}setPeerJs(e){this._peerjs=e}setTyping(e,t){}start(){this.running=!0}stop(){this.running=!1}async send(e,t,n){if(!this._manager)return;let r=ke(e);if(n&&n.length>0&&this._peerjs){let t=this._manager.get(r);t&&await this._peerjs.sendAttachmentsToRoom(t,e,n)}this._manager.broadcast(r,t,n)}};const gt=1e3;var _t=class{abortController=null;fileReader=null;messageCallback=null;offset=0;pollRetryDelayMs=gt;pollSessionId=0;registeredChatIds=new Set;running=!1;token=``;type=`telegram`;useProxy=!1;buildFileUrl(e){let t=e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`);return`${this.useProxy?`/telegram/file/bot`:`https://api.telegram.org/file/bot`}${this.token}/${t}`}buildMethodUrl(t){let n=t.replace(/^\/+/,``);return`${this.useProxy?e:c}${this.token}/${n}`}configure(e,t,n=!1){this.token=e.trim(),this.registeredChatIds=new Set(t.map(e=>e.trim()).filter(Boolean)),this.useProxy=!!n}isConfigured(){return this.token.length>0}nextPollRetryDelay(){let e=this.pollRetryDelayMs;return this.pollRetryDelayMs=Math.min(this.pollRetryDelayMs*2,6e4),e}onMessage(e){this.messageCallback=e}registerChatId(e){let t=e.trim();t&&this.registeredChatIds.add(t)}resetPollBackoff(){this.pollRetryDelayMs=gt}setTyping(e,t){if(!t)return;let n=e.replace(/^tg:/,``);this.apiCall(`sendChatAction`,{chat_id:n,action:`typing`}).catch(()=>{})}start(){if(!this.token||this.running)return;this.running=!0,this.resetPollBackoff();let e=++this.pollSessionId,t=new AbortController;this.abortController=t,this.poll(e,t)}ensureConnected(){if(!this.token||!this.running)return;this.resetPollBackoff(),this.abortController?.abort();let e=++this.pollSessionId,t=new AbortController;this.abortController=t,this.poll(e,t)}stop(){this.running=!1,this.resetPollBackoff(),this.pollSessionId+=1,this.abortController?.abort(),this.abortController=null}async apiCall(e,t){let n=await fetch(this.buildMethodUrl(e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let t=await n.text();throw Error(`Telegram API ${e} failed: ${n.status} ${t}`)}return await n.json()}async extractAttachments(e){let t=[],n=Array.isArray(e.photo)?e.photo.at(-1):null;n?.file_id&&t.push({id:n.file_id,fileName:`photo-${e.message_id}.png`,mimeType:`image/png`,previewDisposition:`inline`}),e.document?.file_id&&t.push({id:e.document.file_id,fileName:e.document.file_name||`document-${e.message_id}`,mimeType:e.document.mime_type}),e.video?.file_id&&t.push({id:e.video.file_id,fileName:e.video.file_name||`video-${e.message_id}.mp4`,mimeType:e.video.mime_type||`video/mp4`}),e.audio?.file_id&&t.push({id:e.audio.file_id,fileName:e.audio.file_name||`audio-${e.message_id}.mp3`,mimeType:e.audio.mime_type||`audio/mpeg`}),e.voice?.file_id&&t.push({id:e.voice.file_id,fileName:`voice-${e.message_id}.ogg`,mimeType:e.voice.mime_type||`audio/ogg`}),e.animation?.file_id&&t.push({id:e.animation.file_id,fileName:e.animation.file_name||`animation-${e.message_id}.mp4`,mimeType:e.animation.mime_type||`video/mp4`}),e.sticker?.file_id&&t.push({id:e.sticker.file_id,fileName:`sticker-${e.message_id}.${bt(e.sticker)}`,mimeType:e.sticker.is_animated?`application/x-tgsticker`:e.sticker.is_video?`video/webm`:`image/webp`});let r=[];for(let e of t){let t=await this.fetchTelegramFileInfo(e.id);r.push({id:e.id,fileName:e.fileName,mimeType:e.mimeType,size:t.file_size,previewDisposition:e.previewDisposition,source:{kind:`remote-url`,url:this.buildFileUrl(t.file_path)}})}return r}async fetchTelegramFileInfo(e){let t=await this.apiCall(`getFile`,{file_id:e});if(!t.ok||!t.result?.file_path)throw Error(`Telegram getFile failed for attachment ${e}`);return t.result}async handleUpdate(e){let t=e.message;if(!t)return;let n=String(t.chat.id);if(t.text===`/chatid`){this.apiCall(`sendMessage`,{chat_id:n,text:`Chat ID: ${n}\nRegister this ID in ShadowClaw settings.`}).catch(console.error);return}if(t.text===`/ping`){this.apiCall(`sendMessage`,{chat_id:n,text:`Pong! ShadowClaw is running.`}).catch(console.error);return}if(!this.registeredChatIds.has(n))return;let r=await this.extractAttachments(t),i=`${t.text||t.caption||``}`.trim()||(t.photo?.length?`[Photo]`:null)||(t.voice?`[Voice message]`:null)||(t.video?`[Video]`:null)||(t.audio?`[Audio]`:null)||(t.animation?`[Animation]`:null)||(t.document?`[Document: ${t.document.file_name||`unnamed`}]`:null)||(t.sticker?`[Sticker: ${t.sticker.emoji||``}]`:null)||(t.location?`[Location: ${t.location.latitude}, ${t.location.longitude}]`:null)||(t.contact?`[Contact: ${t.contact.first_name}]`:null)||`[Unsupported message type]`,a=t.from?.first_name||t.from?.username||String(t.from?.id||`Unknown`),o={id:String(t.message_id),groupId:`tg:${n}`,sender:a,content:i,timestamp:t.date*1e3,channel:`telegram`,attachments:r};this.messageCallback?.(o)}async poll(e,t){for(;this.running&&this.pollSessionId===e&&!t.signal.aborted;)try{let e=await fetch(this.buildMethodUrl(`getUpdates?offset=${this.offset}&timeout=30`),{signal:t.signal});if(!e.ok){console.error(`Telegram poll error: HTTP ${e.status}`),await this.waitForRetry(this.nextPollRetryDelay());continue}let n=await e.json();if(!n.ok||!Array.isArray(n.result)){await this.waitForRetry(this.nextPollRetryDelay());continue}this.resetPollBackoff();for(let e of n.result)this.offset=e.update_id+1,await this.handleUpdate(e)}catch(e){if(e instanceof Error&&e.name===`AbortError`)break;console.error(`Telegram poll error:`,e),await this.waitForRetry(this.nextPollRetryDelay())}}async send(e,n,r){let i=e.replace(/^tg:/,``),{remainingText:a,attachments:o}=xt(n);for(let t of o){if(this.fileReader)try{let n=await this.fileReader(e,t.path);if(n&&n.size>0){let e=t.path.toLowerCase();e.endsWith(`.png`)||e.endsWith(`.jpg`)||e.endsWith(`.jpeg`)||e.endsWith(`.gif`)||e.endsWith(`.webp`)?await this.sendPhoto(i,n,t.alt,t.path):await this.sendDocument(i,n,t.alt,t.path);continue}}catch(e){console.warn(`TelegramChannel: failed to read file ${t.path}:`,e)}await this.apiCall(`sendMessage`,{chat_id:i,text:`[${t.alt}] (file: ${t.path})`})}let s=a.trim();if(s){let e=vt(s,t);for(let t of e)await this.apiCall(`sendMessage`,{chat_id:i,text:t})}}async sendDocument(e,t,n,r){let i=r.split(`/`).pop()||`document.file`,a=new FormData;a.append(`chat_id`,e),a.append(`document`,t,i),n&&a.append(`caption`,n);let o=await fetch(this.buildMethodUrl(`sendDocument`),{method:`POST`,body:a});if(!o.ok){let e=await o.text();throw Error(`Telegram sendDocument failed: ${o.status} ${e}`)}}async sendPhoto(e,t,n,r){let i=r.split(`/`).pop()||`image.png`,a=new FormData;a.append(`chat_id`,e),a.append(`photo`,t,i),n&&a.append(`caption`,n);let o=await fetch(this.buildMethodUrl(`sendPhoto`),{method:`POST`,body:a});if(!o.ok){let e=await o.text();throw Error(`Telegram sendPhoto failed: ${o.status} ${e}`)}}async waitForRetry(e){await yt(e)}};function vt(e,t){if(e.length<=t)return[e];let n=[],r=e;for(;r.length>0;){if(r.length<=t){n.push(r);break}let e=t,i=r.lastIndexOf(`
1
+ import{D as e,E as t,F as n,I as r,M as i,O as a,P as o,R as s,T as c,_ as l,g as u,j as d,l as f,o as p,r as m,s as h,t as g,v as _,w as v}from"./config-D4lVqMs8.js";import{i as y,n as b,r as x}from"./txPromise-C2iYogHX.js";import{t as S}from"./getConfig-4saf0Tkq.js";import{p as C}from"./custom-element-security-CU1rI7Pw.js";import{t as w}from"./dist-B9m1QM9v.js";import{$t as T,At as E,Bt as D,C as O,Ct as k,Dt as A,Et as ee,G as j,H as te,I as M,It as N,Jt as P,Kt as F,Lt as I,M as ne,Mt as re,N as L,Ot as R,P as ie,Qt as z,Rt as B,St as ae,Tt as oe,U as V,V as H,W as se,X as ce,Y as le,Yt as ue,Zt as U,an as de,at as fe,bt as pe,dt as me,en as he,ft as ge,gt as _e,j as ve,jt as ye,kt as be,l as xe,nn as Se,ot as Ce,qt as we,rn as Te,t as W,tn as Ee,u as De,ut as Oe,zt as ke}from"./orchestrator-0BnBtxHO.js";import{C as Ae,S as je,a as G,d as Me,i as Ne,o as Pe,r as Fe,s as Ie,v as Le,w as K}from"./executeNativeAiTask-CXBr7mSA.js";import{n as Re,r as ze}from"./headless-BbtDA5cs.js";import{l as Be,r as Ve}from"./getGroupDir-CLz5c8cg.js";import{c as He,f as Ue,s as We,t as q,u as Ge}from"./tools-BCttQkSs.js";import{t as J}from"./setConfig-DdSThoKj.js";import{t as Y}from"./ulid-BY7rQVLN.js";import{t as Ke}from"./tools-CcgG5XuA.js";import{i as qe,r as Je}from"./syncWebMcpRegistration-D91usEMu.js";import"./tools-B-PzsLc2.js";import{n as Ye,r as Xe}from"./crypto-C8c5wMzN.js";import{a as Ze,i as Qe,r as X,t as $e}from"./peerjs-CgfLEp2N.js";import{i as et,r as tt}from"./webmcp-CcIw3_V3.js";import{ensureControlPlaneConnected as nt}from"./initControlPlane-Dn-XFuxg.js";async function rt(e){if(!(!e||e.name===`shadowclaw`)){try{if(await S(e,m.DB_MIGRATED_FROM_LEGACY)===`true`)return}catch{}try{let t=await new Promise(e=>{let t=indexedDB.open(l);t.onsuccess=()=>{let n=t.result;if(!n.objectStoreNames||n.objectStoreNames.length===0){n.close(),e(null);return}e(n)},t.onerror=()=>e(null)});if(t){let n=Array.from(t.objectStoreNames).filter(t=>e.objectStoreNames.contains(t));for(let r of n)await new Promise(n=>{try{let i=t.transaction(r,`readonly`).objectStore(r).getAll();i.onsuccess=()=>{let t=i.result||[];if(t.length>0)try{let i=e.transaction(r,`readwrite`),a=i.objectStore(r);for(let e of t)a.put(e);i.oncomplete=()=>n(),i.onerror=()=>n(),i.onabort=()=>n()}catch{n()}else n()},i.onerror=()=>n()}catch{n()}});t.close()}}catch(e){console.warn(`Legacy IndexedDB migration warning:`,e)}finally{try{await J(e,m.DB_MIGRATED_FROM_LEGACY,`true`)}catch{}}}}async function it(e,t,n){for await(let[r,i]of e.entries())if(i.kind===`directory`)await it(i,await t.getDirectoryHandle(r,{create:!0}),[...n,r]);else if(i.kind===`file`){let e=await i.getFile(),a=await t.getFileHandle(r,{create:!0});try{await We(a,e)}catch(t){if(!(t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`))throw t;await He([...n,r],e)}}}async function at(e){if(!e)return;try{if(await S(e,m.OPFS_MIGRATED_FROM_LEGACY)===`true`)return}catch{}let t=Ve();if(t!==`shadowclaw`&&!(typeof navigator>`u`||!navigator.storage||typeof navigator.storage.getDirectory!=`function`))try{let n=await navigator.storage.getDirectory(),r;try{r=await n.getDirectoryHandle(_)}catch{try{await J(e,m.OPFS_MIGRATED_FROM_LEGACY,`true`)}catch{}return}let i=await n.getDirectoryHandle(t,{create:!0});await it(r,i,[t])}catch(e){console.warn(`Legacy OPFS migration warning:`,e)}finally{try{await J(e,m.OPFS_MIGRATED_FROM_LEGACY,`true`)}catch{}}}function ot(){return new Promise(async(e,t)=>{let n,r=d(),i=indexedDB.open(r,2);i.onupgradeneeded=()=>{let e=i.result;if(!e.objectStoreNames.contains(`messages`)){let t=e.createObjectStore(`messages`,{keyPath:`id`});t.createIndex(`by-group-time`,[`groupId`,`timestamp`]),t.createIndex(`by-group`,`groupId`)}if(e.objectStoreNames.contains(`sessions`)||e.createObjectStore(`sessions`,{keyPath:`groupId`}),!e.objectStoreNames.contains(`tasks`)){let t=e.createObjectStore(`tasks`,{keyPath:`id`});t.createIndex(`by-group`,`groupId`),t.createIndex(`by-enabled`,`enabled`)}e.objectStoreNames.contains(`config`)||e.createObjectStore(`config`,{keyPath:`key`}),e.objectStoreNames.contains(`pendingShares`)||e.createObjectStore(`pendingShares`,{keyPath:`id`}).createIndex(`by-createdAt`,`createdAt`)},i.onsuccess=async()=>{n=i.result,y(n);try{await rt(n),await at(n)}catch(e){console.warn(`Error running legacy migration:`,e)}e(n)},i.onerror=()=>{t(Error(`Failed to open IndexedDB: ${i.error?.message}`))}})}var st=class{activeGroupId;displayCallback;messageCallback;type;typingCallback;constructor(){this.type=`browser`,this.messageCallback=null,this.typingCallback=null,this.displayCallback=null,this.activeGroupId=p}getActiveGroup(){return this.activeGroupId}onDisplay(e){this.displayCallback=e}onMessage(e){this.messageCallback=e}onTyping(e){this.typingCallback=e}setActiveGroup(e){this.activeGroupId=e}setTyping(e,t){this.typingCallback?.(e,t)}start(){}stop(){}submit(e,t,n=[],r,i,a){let o=t||this.activeGroupId,s={id:Y(),groupId:o,sender:`You`,content:e,timestamp:Date.now(),channel:`browser`,attachments:n,a2uiAction:r,freshContext:i,subagent:a};this.messageCallback?.(s)}async send(e,t,n){this.displayCallback?.(e,t,!0)}},ct=class{_entries;constructor(){this._entries=[]}find(e){return this.resolve(e)?.channel??null}get(e){return this._entries.find(t=>t.prefix===e)?.channel}getBadge(e){return this.resolve(e)?.badge??``}getChannelType(e){return this.resolve(e)?.channel.type??null}onMessage(e){for(let t of this._entries)t.channel.onMessage(e)}onTyping(e){for(let t of this._entries)t.channel.onTyping&&t.channel.onTyping(e)}prefixes(){return this._entries.map(e=>e.prefix)}register(e,t,n){let r=typeof n==`string`?{badge:n}:n??{};this._entries.push({prefix:e,channel:t,badge:r.badge??e.replace(/:$/,``),autoTrigger:r.autoTrigger??!1}),this._entries.sort((e,t)=>t.prefix.length-e.prefix.length)}resolve(e){for(let t of this._entries)if(e.startsWith(t.prefix))return t;return null}shouldAutoTrigger(e){return this.resolve(e)?.autoTrigger??!1}startAll(){for(let e of this._entries)e.channel.start()}stopAll(){for(let e of this._entries)e.channel.stop()}},lt=class{abortController=null;apiKey=``;apiMode=`unknown`;cursor=null;fileReader=null;messageCallback=null;reconnectDelayMs=1e3;registeredChatIds=new Set;running=!1;seenMessageIds=new Map;serverUrl=``;type=`imessage`;configure(e,t,n){this.serverUrl=ut(e),this.apiKey=t.trim(),this.registeredChatIds=new Set(n.map(e=>e.trim()).filter(Boolean)),this.cursor=null,this.apiMode=`unknown`}handleIncomingMessage(e){this.pruneSeenMessageIds();let t=String(e.chatId||e.conversationId||``).trim();if(!t||this.registeredChatIds.size>0&&!this.registeredChatIds.has(t))return;let n=`${e.text||e.body||``}`.trim();if(!n)return;let r=`${e.id||e.guid||`${t}:${e.timestamp||e.createdAt||n}`}`;if(this.seenMessageIds.has(r))return;this.seenMessageIds.set(r,Date.now());let i={id:r,groupId:`im:${t}`,sender:`${e.sender||e.handle||e.from||`iMessage`}`,content:n,timestamp:dt(e.timestamp||e.createdAt),channel:`imessage`};this.messageCallback?.(i)}handlePollResponse(e){e.nextCursor!==void 0&&e.nextCursor!==null?this.cursor=String(e.nextCursor):e.cursor!==void 0&&e.cursor!==null&&(this.cursor=String(e.cursor));let t=Array.isArray(e.messages)?e.messages:[];for(let e of t)this.handleIncomingMessage(e)}isConfigured(){return this.serverUrl.length>0}onMessage(e){this.messageCallback=e}pruneSeenMessageIds(){let e=Date.now();for(let[t,n]of this.seenMessageIds.entries())e-n>6e4&&this.seenMessageIds.delete(t)}setTyping(e,t){if(!t)return;let n=e.replace(/^im:/,``);this.requestJson(`/messages/typing`,{method:`POST`,body:JSON.stringify({chatId:n,typing:!0})}).catch(()=>{})}start(){!this.isConfigured()||this.running||(this.running=!0,this.abortController=new AbortController,this.poll())}ensureConnected(){!this.isConfigured()||!this.running||(this.reconnectDelayMs=1e3,this.abortController?.abort(),this.abortController=new AbortController,this.poll())}stop(){this.running=!1,this.abortController?.abort(),this.abortController=null}async ensureApiMode(){if(this.apiMode!==`unknown`)return this.apiMode;try{await this.requestJson(`/v1/info`,{method:`GET`}),this.apiMode=`beeper-desktop`}catch{this.apiMode=`legacy`}return this.apiMode}async poll(){for(;this.running&&this.abortController&&!this.abortController.signal.aborted;)try{let e=new URLSearchParams({timeout:`25`});this.cursor&&e.set(`cursor`,this.cursor);let t=await this.requestJson(`/messages?${e.toString()}`,{method:`GET`},u+5e3,this.abortController.signal);this.reconnectDelayMs=1e3,this.handlePollResponse(t)}catch(e){if(e instanceof Error&&e.name===`AbortError`)break;console.error(`iMessage bridge poll error:`,e),await ft(this.reconnectDelayMs),this.reconnectDelayMs=Math.min(this.reconnectDelayMs*2,3e4)}}async requestJson(e,t,n=u,r){let i=new AbortController,a=setTimeout(()=>i.abort(),n),o=()=>i.abort();r?.addEventListener(`abort`,o,{once:!0});try{let n=new Headers(t.headers);n.set(`Accept`,`application/json`),!n.has(`Content-Type`)&&t.body&&!(t.body instanceof FormData)&&n.set(`Content-Type`,`application/json`),this.apiKey&&(n.set(`Authorization`,`Bearer ${this.apiKey}`),n.set(`X-API-Key`,this.apiKey));let r=await fetch(`${this.serverUrl}${e}`,{...t,headers:n,signal:i.signal});if(!r.ok){let e=await r.text();throw Error(`iMessage bridge request failed: ${r.status} ${e}`)}return r.status===204?{messages:[]}:await r.json()}finally{clearTimeout(a),r?.removeEventListener(`abort`,o)}}async send(e,t,n){let r=e.replace(/^im:/,``),{remainingText:i,attachments:a}=pt(t);for(let t of a){if(!this.fileReader){await this.sendText(r,`[${t.alt}] (file: ${t.path})`);continue}try{let n=await this.fileReader(e,t.path);if(!n||n.size===0)throw Error(`Attachment file is empty or unavailable.`);await this.sendAttachment(r,n,t)}catch(e){console.warn(`iMessage attachment send failed for ${t.path}:`,e),await this.sendText(r,`[${t.alt}] (file: ${t.path})`)}}let o=i.trim();o&&await this.sendText(r,o)}async sendAttachment(e,t,n){if(await this.ensureApiMode()===`beeper-desktop`){await this.sendAttachmentViaBeeperDesktop(e,t,n);return}await this.sendAttachmentViaLegacyBridge(e,t,n)}async sendAttachmentViaBeeperDesktop(e,t,n){let r=n.path.split(`/`).pop()||`attachment.bin`,i=new FormData;i.append(`file`,t,r),i.append(`fileName`,r),t.type&&i.append(`mimeType`,t.type);let a=`${(await this.requestJson(`/v1/assets/upload`,{method:`POST`,body:i})).uploadID||``}`.trim();if(!a)throw Error(`Beeper asset upload failed: missing uploadID`);await this.requestJson(`/v1/chats/${encodeURIComponent(e)}/messages`,{method:`POST`,body:JSON.stringify({text:n.alt||void 0,attachment:{uploadID:a,fileName:r,mimeType:t.type||void 0}})})}async sendAttachmentViaLegacyBridge(e,t,n){let r=n.path.split(`/`).pop()||`attachment.bin`,i=new FormData;i.append(`chatId`,e),n.alt&&i.append(`text`,n.alt),i.append(`file`,t,r),await this.requestJson(`/messages/send`,{method:`POST`,body:i})}async sendText(e,t){if(await this.ensureApiMode()===`beeper-desktop`){await this.requestJson(`/v1/chats/${encodeURIComponent(e)}/messages`,{method:`POST`,body:JSON.stringify({text:t})});return}await this.requestJson(`/messages/send`,{method:`POST`,body:JSON.stringify({chatId:e,text:t})})}};function ut(e){return e.trim().replace(/\/+$/,``)}function dt(e){if(typeof e==`number`&&Number.isFinite(e))return e>0xe8d4a51000?e:e*1e3;if(typeof e==`string`){let t=Number(e);if(Number.isFinite(t))return dt(t);let n=Date.parse(e);if(Number.isFinite(n))return n}return Date.now()}function ft(e){return new Promise(t=>setTimeout(t,e))}function pt(e){let t=[],n=/!?\[([^\]]*)\]\(([^)]+)\)/g,r=null,i=e;for(;(r=n.exec(e))!==null;){let e=r[1]||``,n=mt((r[2]||``).trim());n&&(t.push({alt:e,path:n}),i=i.replace(r[0],``))}return{remainingText:i,attachments:t}}function mt(e){if(!e)return null;let t=e.trim();if(/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(t)||t.startsWith(`//`))return null;let n=t.replace(/\\/g,`/`).replace(/^\/+/,``).replace(/^\.\//,``);if(!n)return null;let r=n.split(`/`).filter(Boolean);return r.some(e=>e===`..`)?null:r.join(`/`)}var ht=class{messageCallback=null;running=!1;type=`room`;typingCallback=null;_manager=null;_peerjs=null;deliverInbound(e){this.messageCallback?.(e)}onMessage(e){this.messageCallback=e}onTyping(e){this.typingCallback=e}setManager(e){this._manager=e}setPeerJs(e){this._peerjs=e}setTyping(e,t){}start(){this.running=!0}stop(){this.running=!1}async send(e,t,n){if(!this._manager)return;let r=ke(e);if(n&&n.length>0&&this._peerjs){let t=this._manager.get(r);t&&await this._peerjs.sendAttachmentsToRoom(t,e,n)}this._manager.broadcast(r,t,n)}};const gt=1e3;var _t=class{abortController=null;fileReader=null;messageCallback=null;offset=0;pollRetryDelayMs=gt;pollSessionId=0;registeredChatIds=new Set;running=!1;token=``;type=`telegram`;useProxy=!1;buildFileUrl(e){let t=e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`);return`${this.useProxy?`/telegram/file/bot`:`https://api.telegram.org/file/bot`}${this.token}/${t}`}buildMethodUrl(t){let n=t.replace(/^\/+/,``);return`${this.useProxy?e:c}${this.token}/${n}`}configure(e,t,n=!1){this.token=e.trim(),this.registeredChatIds=new Set(t.map(e=>e.trim()).filter(Boolean)),this.useProxy=!!n}isConfigured(){return this.token.length>0}nextPollRetryDelay(){let e=this.pollRetryDelayMs;return this.pollRetryDelayMs=Math.min(this.pollRetryDelayMs*2,6e4),e}onMessage(e){this.messageCallback=e}registerChatId(e){let t=e.trim();t&&this.registeredChatIds.add(t)}resetPollBackoff(){this.pollRetryDelayMs=gt}setTyping(e,t){if(!t)return;let n=e.replace(/^tg:/,``);this.apiCall(`sendChatAction`,{chat_id:n,action:`typing`}).catch(()=>{})}start(){if(!this.token||this.running)return;this.running=!0,this.resetPollBackoff();let e=++this.pollSessionId,t=new AbortController;this.abortController=t,this.poll(e,t)}ensureConnected(){if(!this.token||!this.running)return;this.resetPollBackoff(),this.abortController?.abort();let e=++this.pollSessionId,t=new AbortController;this.abortController=t,this.poll(e,t)}stop(){this.running=!1,this.resetPollBackoff(),this.pollSessionId+=1,this.abortController?.abort(),this.abortController=null}async apiCall(e,t){let n=await fetch(this.buildMethodUrl(e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let t=await n.text();throw Error(`Telegram API ${e} failed: ${n.status} ${t}`)}return await n.json()}async extractAttachments(e){let t=[],n=Array.isArray(e.photo)?e.photo.at(-1):null;n?.file_id&&t.push({id:n.file_id,fileName:`photo-${e.message_id}.png`,mimeType:`image/png`,previewDisposition:`inline`}),e.document?.file_id&&t.push({id:e.document.file_id,fileName:e.document.file_name||`document-${e.message_id}`,mimeType:e.document.mime_type}),e.video?.file_id&&t.push({id:e.video.file_id,fileName:e.video.file_name||`video-${e.message_id}.mp4`,mimeType:e.video.mime_type||`video/mp4`}),e.audio?.file_id&&t.push({id:e.audio.file_id,fileName:e.audio.file_name||`audio-${e.message_id}.mp3`,mimeType:e.audio.mime_type||`audio/mpeg`}),e.voice?.file_id&&t.push({id:e.voice.file_id,fileName:`voice-${e.message_id}.ogg`,mimeType:e.voice.mime_type||`audio/ogg`}),e.animation?.file_id&&t.push({id:e.animation.file_id,fileName:e.animation.file_name||`animation-${e.message_id}.mp4`,mimeType:e.animation.mime_type||`video/mp4`}),e.sticker?.file_id&&t.push({id:e.sticker.file_id,fileName:`sticker-${e.message_id}.${bt(e.sticker)}`,mimeType:e.sticker.is_animated?`application/x-tgsticker`:e.sticker.is_video?`video/webm`:`image/webp`});let r=[];for(let e of t){let t=await this.fetchTelegramFileInfo(e.id);r.push({id:e.id,fileName:e.fileName,mimeType:e.mimeType,size:t.file_size,previewDisposition:e.previewDisposition,source:{kind:`remote-url`,url:this.buildFileUrl(t.file_path)}})}return r}async fetchTelegramFileInfo(e){let t=await this.apiCall(`getFile`,{file_id:e});if(!t.ok||!t.result?.file_path)throw Error(`Telegram getFile failed for attachment ${e}`);return t.result}async handleUpdate(e){let t=e.message;if(!t)return;let n=String(t.chat.id);if(t.text===`/chatid`){this.apiCall(`sendMessage`,{chat_id:n,text:`Chat ID: ${n}\nRegister this ID in ShadowClaw settings.`}).catch(console.error);return}if(t.text===`/ping`){this.apiCall(`sendMessage`,{chat_id:n,text:`Pong! ShadowClaw is running.`}).catch(console.error);return}if(!this.registeredChatIds.has(n))return;let r=await this.extractAttachments(t),i=`${t.text||t.caption||``}`.trim()||(t.photo?.length?`[Photo]`:null)||(t.voice?`[Voice message]`:null)||(t.video?`[Video]`:null)||(t.audio?`[Audio]`:null)||(t.animation?`[Animation]`:null)||(t.document?`[Document: ${t.document.file_name||`unnamed`}]`:null)||(t.sticker?`[Sticker: ${t.sticker.emoji||``}]`:null)||(t.location?`[Location: ${t.location.latitude}, ${t.location.longitude}]`:null)||(t.contact?`[Contact: ${t.contact.first_name}]`:null)||`[Unsupported message type]`,a=t.from?.first_name||t.from?.username||String(t.from?.id||`Unknown`),o={id:String(t.message_id),groupId:`tg:${n}`,sender:a,content:i,timestamp:t.date*1e3,channel:`telegram`,attachments:r};this.messageCallback?.(o)}async poll(e,t){for(;this.running&&this.pollSessionId===e&&!t.signal.aborted;)try{let e=await fetch(this.buildMethodUrl(`getUpdates?offset=${this.offset}&timeout=30`),{signal:t.signal});if(!e.ok){console.error(`Telegram poll error: HTTP ${e.status}`),await this.waitForRetry(this.nextPollRetryDelay());continue}let n=await e.json();if(!n.ok||!Array.isArray(n.result)){await this.waitForRetry(this.nextPollRetryDelay());continue}this.resetPollBackoff();for(let e of n.result)this.offset=e.update_id+1,await this.handleUpdate(e)}catch(e){if(e instanceof Error&&e.name===`AbortError`)break;console.error(`Telegram poll error:`,e),await this.waitForRetry(this.nextPollRetryDelay())}}async send(e,n,r){let i=e.replace(/^tg:/,``),{remainingText:a,attachments:o}=xt(n);for(let t of o){if(this.fileReader)try{let n=await this.fileReader(e,t.path);if(n&&n.size>0){let e=t.path.toLowerCase();e.endsWith(`.png`)||e.endsWith(`.jpg`)||e.endsWith(`.jpeg`)||e.endsWith(`.gif`)||e.endsWith(`.webp`)?await this.sendPhoto(i,n,t.alt,t.path):await this.sendDocument(i,n,t.alt,t.path);continue}}catch(e){console.warn(`TelegramChannel: failed to read file ${t.path}:`,e)}await this.apiCall(`sendMessage`,{chat_id:i,text:`[${t.alt}] (file: ${t.path})`})}let s=a.trim();if(s){let e=vt(s,t);for(let t of e)await this.apiCall(`sendMessage`,{chat_id:i,text:t})}}async sendDocument(e,t,n,r){let i=r.split(`/`).pop()||`document.file`,a=new FormData;a.append(`chat_id`,e),a.append(`document`,t,i),n&&a.append(`caption`,n);let o=await fetch(this.buildMethodUrl(`sendDocument`),{method:`POST`,body:a});if(!o.ok){let e=await o.text();throw Error(`Telegram sendDocument failed: ${o.status} ${e}`)}}async sendPhoto(e,t,n,r){let i=r.split(`/`).pop()||`image.png`,a=new FormData;a.append(`chat_id`,e),a.append(`photo`,t,i),n&&a.append(`caption`,n);let o=await fetch(this.buildMethodUrl(`sendPhoto`),{method:`POST`,body:a});if(!o.ok){let e=await o.text();throw Error(`Telegram sendPhoto failed: ${o.status} ${e}`)}}async waitForRetry(e){await yt(e)}};function vt(e,t){if(e.length<=t)return[e];let n=[],r=e;for(;r.length>0;){if(r.length<=t){n.push(r);break}let e=t,i=r.lastIndexOf(`
2
2
  `,t);i>t*.5&&(e=i),n.push(r.slice(0,e)),r=r.slice(e)}return n}function yt(e){return new Promise(t=>setTimeout(t,e))}function bt(e){return e?.is_animated?`tgs`:e?.is_video?`webm`:`webp`}function xt(e){let t=[],n=/!?\[([^\]]*)\]\(([^)]+)\)/g,r,i=e;for(;(r=n.exec(e))!==null;){let e=r[1],n=St((r[2]||``).trim());n&&(t.push({alt:e,path:n}),i=i.replace(r[0],``))}return{remainingText:i,attachments:t}}function St(e){if(!e)return null;let t=e.trim();if(/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(t)||t.startsWith(`//`))return null;let n=t.replace(/\\/g,`/`).replace(/^\/+/,``).replace(/^\.\//,``);if(!n)return null;let r=n.split(`/`).filter(Boolean);return r.some(e=>e===`..`)?null:r.join(`/`)}function Ct(e,t){let n=JSON.stringify(e.dataModel??{},null,2),r=t?`${t}`:`The user`;return`[A2UI ACTION]\nsurfaceId: "${e.surfaceId}"\nactionId: "${e.actionId}"\n`+(t?`firedBy: "${t}"\n`:``)+`dataModel:\n${n}\n\nInstructions: ${r} triggered the "${e.actionId}" action on surface "${e.surfaceId}". The dataModel above contains the current form values. Use the appropriate tool(s) to fulfill the action based on the actionId and dataModel values. After you have a result, call render_component with action "updateDataModel" on surfaceId "${e.surfaceId}" to update the surface (e.g. set path "/result" to the output value). Do NOT respond with plain text only — always update the surface via render_component.`}var wt=class{static formatMessagesXml(e){let t=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`);return`<messages>\n${e.map(e=>`<message sender="${t(e.sender)}" time="${new Date(e.timestamp).toISOString()}">${t(e.content)}</message>`).join(`
3
3
  `)}\n</messages>`}static formatOutbound(e){return e.replace(/<internal>[\s\S]*?<\/internal>/g,``).trim()}registry;constructor(e){this.registry=e}findChannel(e){return this.registry.find(e)}setTyping(e,t){this.findChannel(e)?.setTyping(e,t)}async send(e,t,n){let r=this.findChannel(e);if(!r){console.warn(`No channel for groupId: ${e}`);return}await r.send(e,t,n)}};const Tt={"litert-community/gemma-4-E2B-it-litert-lm":`https://huggingface.co/litert-community/gemma-4-E2B-it-litert-lm/resolve/main/gemma-4-E2B-it-web.litertlm`,"litert-community/gemma-4-E4B-it-litert-lm":`https://huggingface.co/litert-community/gemma-4-E4B-it-litert-lm/resolve/main/gemma-4-E4B-it-web.litertlm`},Et=Object.keys(Tt);function Dt(){return typeof navigator<`u`&&`gpu`in navigator&&typeof WebAssembly<`u`&&`Suspending`in WebAssembly}let Ot=null,kt=null,At=null,jt=null;const Mt=Ae;async function Nt(e,t,n){return je(e,t,n,{cacheName:`shadow-claw-litertlm-models`,chunkSize:Mt})}async function Pt(e,t,n){if(kt===e&&Ot)return Ot;if(At&&jt===e)return At;jt=e,At=(async()=>{if(Ot){try{await Ot.delete?.()}catch{}Ot=null,kt=null}let r=Tt[e];if(!r)throw Error(`LiteRT-LM: Model '${e} is not supported. Supported models: ${Et.join(`, `)}`);let i=await import(`./dist-DUy1CvmT.js`).catch(()=>{throw Error(`LiteRT-LM: The @litert-lm/core package is not installed. Run: npm install @litert-lm/core`)}),a=i.Engine??i.default?.Engine;if(typeof a?.create!=`function`)throw Error(`LiteRT-LM: Could not locate Engine.create in @litert-lm/core. Ensure you have the latest version installed.`);let o=await Nt(r,t??(()=>{}),n),s=await a.create({model:o,mainExecutorSettings:{maxNumTokens:8192}});return Ot=s,kt=e,s})();try{return await At}finally{At=null,jt=null}}function Ft(e){if(!e)return null;let t=e.match(/<\|tool_call>call:([A-Za-z0-9_]+)(\{[\s\S]*?)(?:<tool_call\|>|$)/);if(!t)return null;let n=t[1],r=t[2];r=r.replace(/<\|"\|>/g,`"`);function i(e){return e.replace(/([{,]\s*)([A-Za-z_$][A-Za-z0-9_$]*)(\s*:)/g,`$1"$2"$3`)}let a={},o=[r,i(r)];for(let e of o)try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t)){a=t;break}}catch{}if(Object.keys(a).length===0){let e=r.indexOf(`{`),t=r.lastIndexOf(`}`);if(e>=0&&t>e){let n=r.slice(e,t+1);for(let e of[n,i(n)])try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t)){a=t;break}}catch{}}}return{name:n,input:a}}function It(e){let t=K(String(e||``),`litert_lm`).trim();if(!t)return null;let n=e=>{try{let t=JSON.parse(e);if(t&&typeof t==`object`&&(t.type===`tool_use`||t.type===`response`))return t.tools_calls&&!t.tool_calls&&(t.tool_calls=t.tools_calls),{...t,format:`json`}}catch{}return null},r=n(t);if(r)return r;let i=t.indexOf(`{`),a=t.lastIndexOf(`}`);if(i>=0&&a>i&&(r=n(t.slice(i,a+1)),r))return r;if(t.includes(`"tool_use"`)){let e=/"name"\s*:\s*"([^"]+)"/.exec(t);if(e){let n={},r=/"input"\s*:\s*(\{.*?\})\s*(?:]|\}|"|$)/s.exec(t);if(r)try{n=JSON.parse(r[1])}catch{}return{type:`tool_use`,format:`json`,tool_calls:[{id:`litert_${Date.now()}`,name:e[1],input:n}]}}}let o=Ft(t);return o?{type:`tool_use`,format:`model_specific`,tool_calls:[{id:`litert_${Date.now()}`,name:o.name,input:o.input}]}:null}function Lt(e,t,n){let r=[],i=e||``;if(n.length>0){let e=[``,`TOOL CALLING INSTRUCTIONS:`,`Return ONLY valid JSON (no markdown fences).`,`To call a tool: {"type":"tool_use","tool_calls":[{"name":"<tool>","input":{...}}]}`,`To reply: {"type":"response","response":"<your answer>"}`,`IMPORTANT: When you need to use a tool, output ONLY the JSON above — do NOT describe the call as text.`,``,`Available tools:`,n.map(e=>{let t=Object.keys(e.input_schema.properties||{}).join(`, `),n=e.description.split(`. `)[0];return`${e.name}(${t}): ${n}`}).join(`
4
4
  `)].join(`