shadow-claw 1.59.6 → 1.60.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 (358) hide show
  1. package/.well-known/mcp/server-card.json +1 -1
  2. package/.well-known/mcp.json +1 -1
  3. package/README.md +6 -2
  4. package/dist/cli/build/build.js +1 -1
  5. package/dist/cli/chunk-3C5izdQW.js +1 -0
  6. package/dist/cli/chunk-B-75h9gX.js +1 -0
  7. package/dist/cli/{chunk-C9o6lXP3.js → chunk-B7Kn-otm.js} +1 -1
  8. package/dist/cli/{chunk-YX32FcN7.js → chunk-BBczgswQ.js} +1 -1
  9. package/dist/cli/{chunk-DcNxjqH6.js → chunk-BE-lYWcn.js} +1 -1
  10. package/dist/cli/{chunk-DJqHK-qS.js → chunk-BECr0WxI.js} +11 -11
  11. package/dist/cli/chunk-BEz1PD1_.js +1 -0
  12. package/dist/cli/chunk-BLzI1Fp2.js +1 -0
  13. package/dist/cli/{chunk-yiVdvGCJ.js → chunk-BVSC1MNQ.js} +11 -11
  14. package/dist/cli/{chunk-CX2itile.js → chunk-BdWcep6o.js} +1 -1
  15. package/dist/cli/{chunk-DLde6nuO.js → chunk-BfTpnSS4.js} +1 -1
  16. package/dist/cli/{chunk-D2_eAO83.js → chunk-BgvqTf7w.js} +1 -1
  17. package/dist/cli/chunk-BwsJfUT3.js +1 -0
  18. package/dist/cli/{chunk--PFY91kE.js → chunk-C9b4b7c_.js} +1 -1
  19. package/dist/cli/{chunk-D3y7h9Xe.js → chunk-CAw9XYFe.js} +1 -1
  20. package/dist/cli/chunk-CFCcbFs2.js +396 -0
  21. package/dist/cli/{chunk-Cnjb8Usu.js → chunk-CTarF4FC.js} +1 -1
  22. package/dist/cli/{chunk-DM4xsTry.js → chunk-Cbq5hpjb.js} +4 -4
  23. package/dist/cli/chunk-CjTjKy_v.js +310 -0
  24. package/dist/cli/chunk-Cjyu4cr_.js +36 -0
  25. package/dist/cli/{chunk-DUGZPka_.js → chunk-ClMKygjZ.js} +1 -1
  26. package/dist/cli/chunk-Cppnq1KF.js +1 -0
  27. package/dist/cli/{chunk-DvemF16v.js → chunk-D9QCNFMO.js} +1 -1
  28. package/dist/cli/chunk-DB21BMqt.js +7 -0
  29. package/dist/cli/{chunk-_Vo-o_e3.js → chunk-DHoIWvCc.js} +1 -1
  30. package/dist/cli/chunk-DZEN9T5y.js +1 -0
  31. package/dist/cli/{chunk-5rLO4DWS.js → chunk-Dl14OyYO.js} +9 -9
  32. package/dist/cli/chunk-Dl_vv0dI.js +1 -0
  33. package/dist/cli/chunk-Dpmfhlyl.js +1 -0
  34. package/dist/cli/{chunk-BrR1DOBS.js → chunk-Du7Xtucq.js} +1 -1
  35. package/dist/cli/{chunk-Bc_weULz.js → chunk-DxcDFUi_.js} +1 -1
  36. package/dist/cli/{chunk-Dt7-hzJU.js → chunk-DyyEWbV7.js} +1 -1
  37. package/dist/cli/chunk-N0x3mXU0.js +1 -0
  38. package/dist/cli/{chunk-CGoE4llV.js → chunk-V-w0Bata.js} +1 -1
  39. package/dist/cli/{chunk-C8DBACtx.js → chunk-ZxDxSSn-.js} +1 -1
  40. package/dist/cli/chunk-lPvFUkd5.js +7 -0
  41. package/dist/cli/{chunk-Ctg5L55n.js → chunk-n5s-sCdU.js} +1 -1
  42. package/dist/cli/{chunk-Dw8GndPD.js → chunk-nD9VPVMq.js} +1 -1
  43. package/dist/cli/{chunk-Cq_kQohv.js → chunk-rFuy8aS_.js} +1 -1
  44. package/dist/cli/{chunk-Bq38OubR.js → chunk-wjM6JXWa.js} +1 -1
  45. package/dist/cli/{chunk-3wTukVof.js → chunk-zcES9rut.js} +1 -1
  46. package/dist/cli/cli.js +3 -3
  47. package/dist/headless-agent.js +2 -2
  48. package/dist/lib/{app-routes-DJdIjp2V.js → app-routes-BXiRvlNl.js} +7 -25
  49. package/dist/lib/{app-routes-DJdIjp2V.js.map → app-routes-BXiRvlNl.js.map} +1 -1
  50. package/dist/lib/{attachment-capabilities-Dbb-4ZP5.js → attachment-capabilities-BjkEPip8.js} +2 -2
  51. package/dist/lib/{attachment-capabilities-Dbb-4ZP5.js.map → attachment-capabilities-BjkEPip8.js.map} +1 -1
  52. package/dist/lib/{channel-Dlru5ofR.js → channel-DB77spML.js} +3 -3
  53. package/dist/lib/{channel-Dlru5ofR.js.map → channel-DB77spML.js.map} +1 -1
  54. package/dist/lib/{chat-template-BuuLY8l7.js → chat-template-DPEKGJhB.js} +2 -2
  55. package/dist/lib/{chat-template-BuuLY8l7.js.map → chat-template-DPEKGJhB.js.map} +1 -1
  56. package/dist/lib/{compact-context-BtR55YPU.js → compact-context-Q9t9aL1e.js} +19 -19
  57. package/dist/lib/{compact-context-BtR55YPU.js.map → compact-context-Q9t9aL1e.js.map} +1 -1
  58. package/dist/lib/components/common/shadow-claw-provider-model-picker.js +1 -1
  59. package/dist/lib/components/index.js +27 -27
  60. package/dist/lib/components/settings/shadow-claw-accounts.js +1 -1
  61. package/dist/lib/components/settings/shadow-claw-channel-config.js +1 -1
  62. package/dist/lib/components/settings/shadow-claw-control-plane.js +1 -1
  63. package/dist/lib/components/settings/shadow-claw-git.js +1 -1
  64. package/dist/lib/components/settings/shadow-claw-integrations.js +1 -1
  65. package/dist/lib/components/settings/shadow-claw-llm.js +1 -1
  66. package/dist/lib/components/settings/shadow-claw-mcp-remote.js +1 -1
  67. package/dist/lib/components/settings/shadow-claw-networking.js +1 -1
  68. package/dist/lib/components/settings/shadow-claw-notifications.js +1 -1
  69. package/dist/lib/components/settings/shadow-claw-peerjs.js +1 -1
  70. package/dist/lib/components/settings/shadow-claw-storage.js +1 -1
  71. package/dist/lib/components/settings/shadow-claw-task-server.js +1 -1
  72. package/dist/lib/components/settings/shadow-claw-webvm.js +1 -1
  73. package/dist/lib/components/shadow-claw-a2ui.js +1 -1
  74. package/dist/lib/components/shadow-claw-accounts.js +1 -1
  75. package/dist/lib/components/shadow-claw-channel-config.js +1 -1
  76. package/dist/lib/components/shadow-claw-channels.js +1 -1
  77. package/dist/lib/components/shadow-claw-chat.js +1 -1
  78. package/dist/lib/components/shadow-claw-control-plane.js +1 -1
  79. package/dist/lib/components/shadow-claw-conversations.js +1 -1
  80. package/dist/lib/components/shadow-claw-file-viewer.js +1 -1
  81. package/dist/lib/components/shadow-claw-files.js +1 -1
  82. package/dist/lib/components/shadow-claw-git.js +1 -1
  83. package/dist/lib/components/shadow-claw-integrations.js +1 -1
  84. package/dist/lib/components/shadow-claw-llm.js +1 -1
  85. package/dist/lib/components/shadow-claw-mcp-remote.js +1 -1
  86. package/dist/lib/components/shadow-claw-networking.js +1 -1
  87. package/dist/lib/components/shadow-claw-notifications.js +1 -1
  88. package/dist/lib/components/shadow-claw-page-header.js +1 -1
  89. package/dist/lib/components/shadow-claw-pages.js +1 -1
  90. package/dist/lib/components/shadow-claw-peerjs.js +1 -1
  91. package/dist/lib/components/shadow-claw-provider-model-picker.js +1 -1
  92. package/dist/lib/components/shadow-claw-settings.js +1 -1
  93. package/dist/lib/components/shadow-claw-storage.js +1 -1
  94. package/dist/lib/components/shadow-claw-task-server.js +1 -1
  95. package/dist/lib/components/shadow-claw-tasks.js +1 -1
  96. package/dist/lib/components/shadow-claw-terminal.js +1 -1
  97. package/dist/lib/components/shadow-claw-tools.js +1 -1
  98. package/dist/lib/components/shadow-claw-webvm.js +1 -1
  99. package/dist/lib/components/shadow-claw.js +1 -1
  100. package/dist/lib/{config-DxNI3TlW.js → config-BrHR97zt.js} +2 -2
  101. package/dist/lib/{config-DxNI3TlW.js.map → config-BrHR97zt.js.map} +1 -1
  102. package/dist/lib/{configure-peer-js-ChDhOZU4.js → configure-peer-js-CgFiwoxY.js} +3 -3
  103. package/dist/lib/{configure-peer-js-ChDhOZU4.js.map → configure-peer-js-CgFiwoxY.js.map} +1 -1
  104. package/dist/lib/{connections-DC4NZkJE.js → connections-C1FWsBsE.js} +2 -2
  105. package/dist/lib/{connections-DC4NZkJE.js.map → connections-C1FWsBsE.js.map} +1 -1
  106. package/dist/lib/content/build-attachment-content-blocks.d.ts +2 -0
  107. package/dist/lib/{credentials-5vpz0XPk.js → credentials-CZbngHXW.js} +2 -2
  108. package/dist/lib/{credentials-5vpz0XPk.js.map → credentials-CZbngHXW.js.map} +1 -1
  109. package/dist/lib/{discover-skills-CD0sKvAI.js → discover-skills-CXyaWHKi.js} +13 -13
  110. package/dist/lib/{discover-skills-CD0sKvAI.js.map → discover-skills-CXyaWHKi.js.map} +1 -1
  111. package/dist/lib/{download-group-file-Dk3qaxhJ.js → download-group-file-D0wgg10Q.js} +2 -2
  112. package/dist/lib/{download-group-file-Dk3qaxhJ.js.map → download-group-file-D0wgg10Q.js.map} +1 -1
  113. package/dist/lib/{file-viewer-B4pRW-_G.js → file-viewer-DOfvX6yy.js} +5 -5
  114. package/dist/lib/{file-viewer-B4pRW-_G.js.map → file-viewer-DOfvX6yy.js.map} +1 -1
  115. package/dist/lib/{get-or-create-subscriber-id-HCcgDEPz.js → get-or-create-subscriber-id-wyzaML7Z.js} +2 -2
  116. package/dist/lib/{get-or-create-subscriber-id-HCcgDEPz.js.map → get-or-create-subscriber-id-wyzaML7Z.js.map} +1 -1
  117. package/dist/lib/{git-B3Q1euc5.js → git-CogDRlEz.js} +5 -5
  118. package/dist/lib/{git-B3Q1euc5.js.map → git-CogDRlEz.js.map} +1 -1
  119. package/dist/lib/{iframe-bridge-scripts-D8iuFhUk.js → iframe-bridge-scripts-Dx825LLG.js} +2 -2
  120. package/dist/lib/{iframe-bridge-scripts-D8iuFhUk.js.map → iframe-bridge-scripts-Dx825LLG.js.map} +1 -1
  121. package/dist/lib/index.js +28 -28
  122. package/dist/lib/{init-chat-split-resize-B0ODULx9.js → init-chat-split-resize-Cc0bd2z9.js} +2 -2
  123. package/dist/lib/{init-chat-split-resize-B0ODULx9.js.map → init-chat-split-resize-Cc0bd2z9.js.map} +1 -1
  124. package/dist/lib/{init-control-plane-C1FRRmjC.js → init-control-plane-CEGdzgWX.js} +15 -15
  125. package/dist/lib/{init-control-plane-C1FRRmjC.js.map → init-control-plane-CEGdzgWX.js.map} +1 -1
  126. package/dist/lib/{invoke-agent-CzN7sVh-.js → invoke-agent-cac3gCsj.js} +11 -11
  127. package/dist/lib/{invoke-agent-CzN7sVh-.js.map → invoke-agent-cac3gCsj.js.map} +1 -1
  128. package/dist/lib/{markdown-mbNo7cV3.js → markdown--6vTAPEH.js} +2 -2
  129. package/dist/lib/{markdown-mbNo7cV3.js.map → markdown--6vTAPEH.js.map} +1 -1
  130. package/dist/lib/{mcp-reconnect-3T7yWGEY.js → mcp-reconnect-BeqQvNWO.js} +3 -3
  131. package/dist/lib/{mcp-reconnect-3T7yWGEY.js.map → mcp-reconnect-BeqQvNWO.js.map} +1 -1
  132. package/dist/lib/{model-ranking-DGNSWYwN.js → model-ranking-BhsJV7vb.js} +2 -2
  133. package/dist/lib/{model-ranking-DGNSWYwN.js.map → model-ranking-BhsJV7vb.js.map} +1 -1
  134. package/dist/lib/{move-group-entry-NMTJ59M9.js → move-group-entry-D8dptMg0.js} +5 -5
  135. package/dist/lib/{move-group-entry-NMTJ59M9.js.map → move-group-entry-D8dptMg0.js.map} +1 -1
  136. package/dist/lib/{orchestrator-B8FV1V7x.js → orchestrator-BBAwy9Nm.js} +24 -24
  137. package/dist/lib/{orchestrator-B8FV1V7x.js.map → orchestrator-BBAwy9Nm.js.map} +1 -1
  138. package/dist/lib/{orchestrator-i_QJ-o22.js → orchestrator-cRBe3lhq.js} +11 -11
  139. package/dist/lib/orchestrator-cRBe3lhq.js.map +1 -0
  140. package/dist/lib/{parse-path-DPCn-HwI.js → parse-path-BOHQP_IQ.js} +3 -3
  141. package/dist/lib/{parse-path-DPCn-HwI.js.map → parse-path-BOHQP_IQ.js.map} +1 -1
  142. package/dist/lib/{peerjs-z5zeioPV.js → peerjs-BLg8aGUj.js} +8 -8
  143. package/dist/lib/{peerjs-z5zeioPV.js.map → peerjs-BLg8aGUj.js.map} +1 -1
  144. package/dist/lib/{process-peer-query-param-CJp7w7AU.js → process-peer-query-param-BnsVnxzH.js} +5 -5
  145. package/dist/lib/{process-peer-query-param-CJp7w7AU.js.map → process-peer-query-param-BnsVnxzH.js.map} +1 -1
  146. package/dist/lib/{process-pending-shared-payloads-B6_TlBFA.js → process-pending-shared-payloads-DBZfZOOa.js} +4 -4
  147. package/dist/lib/{process-pending-shared-payloads-B6_TlBFA.js.map → process-pending-shared-payloads-DBZfZOOa.js.map} +1 -1
  148. package/dist/lib/{process-room-query-param-C3FFGGn6.js → process-room-query-param-B8EYg_-r.js} +4 -4
  149. package/dist/lib/{process-room-query-param-C3FFGGn6.js.map → process-room-query-param-B8EYg_-r.js.map} +1 -1
  150. package/dist/lib/{provider-DcQZypu5.js → provider-BC9KPI14.js} +3 -3
  151. package/dist/lib/{provider-DcQZypu5.js.map → provider-BC9KPI14.js.map} +1 -1
  152. package/dist/lib/{push-client-Cx5rMs6J.js → push-client-CAm6UMvE.js} +5 -5
  153. package/dist/lib/{push-client-Cx5rMs6J.js.map → push-client-CAm6UMvE.js.map} +1 -1
  154. package/dist/lib/{read-group-file-bytes-CXOG_YyM.js → read-group-file-bytes-UQIk1eJG.js} +2 -2
  155. package/dist/lib/{read-group-file-bytes-CXOG_YyM.js.map → read-group-file-bytes-UQIk1eJG.js.map} +1 -1
  156. package/dist/lib/{rooms-CwlkYLDU.js → rooms-Dzphx3rK.js} +2 -2
  157. package/dist/lib/{rooms-CwlkYLDU.js.map → rooms-Dzphx3rK.js.map} +1 -1
  158. package/dist/lib/{shadow-claw-DoQ7fgl5.js → shadow-claw-CGl8tXtG.js} +17 -20
  159. package/dist/lib/shadow-claw-CGl8tXtG.js.map +1 -0
  160. package/dist/lib/{shadow-claw-a2ui-Br6qJMs1.js → shadow-claw-a2ui-lG0vQbW8.js} +2 -2
  161. package/dist/lib/{shadow-claw-a2ui-Br6qJMs1.js.map → shadow-claw-a2ui-lG0vQbW8.js.map} +1 -1
  162. package/dist/lib/{shadow-claw-accounts-BTDILfWw.js → shadow-claw-accounts-CkqyCxwp.js} +3 -3
  163. package/dist/lib/{shadow-claw-accounts-BTDILfWw.js.map → shadow-claw-accounts-CkqyCxwp.js.map} +1 -1
  164. package/dist/lib/{shadow-claw-channel-config-IKiL34tI.js → shadow-claw-channel-config-BNIWCdsL.js} +4 -4
  165. package/dist/lib/{shadow-claw-channel-config-IKiL34tI.js.map → shadow-claw-channel-config-BNIWCdsL.js.map} +1 -1
  166. package/dist/lib/{shadow-claw-channels-JgEzuHWK.js → shadow-claw-channels-C2QSn4Ew.js} +3 -3
  167. package/dist/lib/{shadow-claw-channels-JgEzuHWK.js.map → shadow-claw-channels-C2QSn4Ew.js.map} +1 -1
  168. package/dist/lib/{shadow-claw-chat-SGUDT31r.js → shadow-claw-chat-Wx3y9y6c.js} +15 -15
  169. package/dist/lib/{shadow-claw-chat-SGUDT31r.js.map → shadow-claw-chat-Wx3y9y6c.js.map} +1 -1
  170. package/dist/lib/{shadow-claw-control-plane-CRWFZ3vD.js → shadow-claw-control-plane-D5E4cFGu.js} +7 -7
  171. package/dist/lib/{shadow-claw-control-plane-CRWFZ3vD.js.map → shadow-claw-control-plane-D5E4cFGu.js.map} +1 -1
  172. package/dist/lib/{shadow-claw-conversations-D23GJ7qo.js → shadow-claw-conversations-BtDv7GRW.js} +7 -7
  173. package/dist/lib/{shadow-claw-conversations-D23GJ7qo.js.map → shadow-claw-conversations-BtDv7GRW.js.map} +1 -1
  174. package/dist/lib/{shadow-claw-file-viewer-C1V8WTiU.js → shadow-claw-file-viewer-CG40kwWV.js} +10 -10
  175. package/dist/lib/{shadow-claw-file-viewer-C1V8WTiU.js.map → shadow-claw-file-viewer-CG40kwWV.js.map} +1 -1
  176. package/dist/lib/{shadow-claw-files-DN7irmE1.js → shadow-claw-files-BOUULrlX.js} +11 -11
  177. package/dist/lib/{shadow-claw-files-DN7irmE1.js.map → shadow-claw-files-BOUULrlX.js.map} +1 -1
  178. package/dist/lib/{shadow-claw-git-D-1oIh65.js → shadow-claw-git-BeHV73_9.js} +6 -6
  179. package/dist/lib/{shadow-claw-git-D-1oIh65.js.map → shadow-claw-git-BeHV73_9.js.map} +1 -1
  180. package/dist/lib/{shadow-claw-integrations-CZjnm7cM.js → shadow-claw-integrations-RZZ-m-Id.js} +4 -4
  181. package/dist/lib/{shadow-claw-integrations-CZjnm7cM.js.map → shadow-claw-integrations-RZZ-m-Id.js.map} +1 -1
  182. package/dist/lib/{shadow-claw-llm-4Gefh5FN.js → shadow-claw-llm-KONyWKZM.js} +9 -9
  183. package/dist/lib/{shadow-claw-llm-4Gefh5FN.js.map → shadow-claw-llm-KONyWKZM.js.map} +1 -1
  184. package/dist/lib/{shadow-claw-mcp-remote-B9ssb3YV.js → shadow-claw-mcp-remote-BKFROurv.js} +4 -4
  185. package/dist/lib/{shadow-claw-mcp-remote-B9ssb3YV.js.map → shadow-claw-mcp-remote-BKFROurv.js.map} +1 -1
  186. package/dist/lib/{shadow-claw-networking-BN5BB4hb.js → shadow-claw-networking-Diy3JJkc.js} +2 -2
  187. package/dist/lib/{shadow-claw-networking-BN5BB4hb.js.map → shadow-claw-networking-Diy3JJkc.js.map} +1 -1
  188. package/dist/lib/{shadow-claw-notifications-71KARtkY.js → shadow-claw-notifications-C-upPa-4.js} +3 -3
  189. package/dist/lib/{shadow-claw-notifications-71KARtkY.js.map → shadow-claw-notifications-C-upPa-4.js.map} +1 -1
  190. package/dist/lib/{shadow-claw-page-header-DMGO-TSe.js → shadow-claw-page-header-C_Qr3xZM.js} +2 -2
  191. package/dist/lib/{shadow-claw-page-header-DMGO-TSe.js.map → shadow-claw-page-header-C_Qr3xZM.js.map} +1 -1
  192. package/dist/lib/{shadow-claw-pages-BiRM6qiA.js → shadow-claw-pages-CfAjUKgd.js} +11 -11
  193. package/dist/lib/{shadow-claw-pages-BiRM6qiA.js.map → shadow-claw-pages-CfAjUKgd.js.map} +1 -1
  194. package/dist/lib/{shadow-claw-peerjs-BZu7jNSe.js → shadow-claw-peerjs-t4YibS9s.js} +6 -6
  195. package/dist/lib/{shadow-claw-peerjs-BZu7jNSe.js.map → shadow-claw-peerjs-t4YibS9s.js.map} +1 -1
  196. package/dist/lib/{shadow-claw-provider-model-picker-BXYXEobD.js → shadow-claw-provider-model-picker-B-Ct4yW-.js} +2 -2
  197. package/dist/lib/{shadow-claw-provider-model-picker-BXYXEobD.js.map → shadow-claw-provider-model-picker-B-Ct4yW-.js.map} +1 -1
  198. package/dist/lib/{shadow-claw-settings-CcT5EK08.js → shadow-claw-settings-Cg5V0e9g.js} +7 -7
  199. package/dist/lib/{shadow-claw-settings-CcT5EK08.js.map → shadow-claw-settings-Cg5V0e9g.js.map} +1 -1
  200. package/dist/lib/{shadow-claw-storage-eTOpbvpi.js → shadow-claw-storage-C7tCnsSG.js} +5 -5
  201. package/dist/lib/{shadow-claw-storage-eTOpbvpi.js.map → shadow-claw-storage-C7tCnsSG.js.map} +1 -1
  202. package/dist/lib/{shadow-claw-task-server-DFImTUbw.js → shadow-claw-task-server-BObsRdf8.js} +2 -2
  203. package/dist/lib/{shadow-claw-task-server-DFImTUbw.js.map → shadow-claw-task-server-BObsRdf8.js.map} +1 -1
  204. package/dist/lib/{shadow-claw-tasks-BjaxsmUx.js → shadow-claw-tasks-B2EEqrcY.js} +9 -9
  205. package/dist/lib/{shadow-claw-tasks-BjaxsmUx.js.map → shadow-claw-tasks-B2EEqrcY.js.map} +1 -1
  206. package/dist/lib/{shadow-claw-terminal-C-4wreFe.js → shadow-claw-terminal-DSHfO2b9.js} +2 -2
  207. package/dist/lib/{shadow-claw-terminal-C-4wreFe.js.map → shadow-claw-terminal-DSHfO2b9.js.map} +1 -1
  208. package/dist/lib/{shadow-claw-tools-COdrGZJk.js → shadow-claw-tools-DwPBADua.js} +7 -7
  209. package/dist/lib/{shadow-claw-tools-COdrGZJk.js.map → shadow-claw-tools-DwPBADua.js.map} +1 -1
  210. package/dist/lib/{shadow-claw-webvm-sxqVjO0L.js → shadow-claw-webvm-CY4qGaMB.js} +3 -3
  211. package/dist/lib/{shadow-claw-webvm-sxqVjO0L.js.map → shadow-claw-webvm-CY4qGaMB.js.map} +1 -1
  212. package/dist/lib/{sync-web-mcp-registration-D4hdUwtv.js → sync-web-mcp-registration-BiOZvW-R.js} +6 -6
  213. package/dist/lib/{sync-web-mcp-registration-D4hdUwtv.js.map → sync-web-mcp-registration-BiOZvW-R.js.map} +1 -1
  214. package/dist/lib/{system-prompt-DT_KeYaL.js → system-prompt-CxJ3Nx4c.js} +9 -8
  215. package/dist/lib/system-prompt-CxJ3Nx4c.js.map +1 -0
  216. package/dist/lib/{tools-Beuyh8y1.js → tools-B8OJ4sMF.js} +4 -4
  217. package/dist/lib/{tools-Beuyh8y1.js.map → tools-B8OJ4sMF.js.map} +1 -1
  218. package/dist/lib/{transformers-DydnReu4.js → transformers-BMURofG6.js} +2 -2
  219. package/dist/lib/{transformers-DydnReu4.js.map → transformers-BMURofG6.js.map} +1 -1
  220. package/dist/lib/{trusted-types-CfwZl_rr.js → trusted-types-HwsGS5Nj.js} +19 -17
  221. package/dist/lib/{trusted-types-CfwZl_rr.js.map → trusted-types-HwsGS5Nj.js.map} +1 -1
  222. package/dist/lib/{upload-group-file-BbBzjTcN.js → upload-group-file-CJpoNjEb.js} +3 -3
  223. package/dist/lib/{upload-group-file-BbBzjTcN.js.map → upload-group-file-CJpoNjEb.js.map} +1 -1
  224. package/dist/lib/utils/index.js +1 -1
  225. package/dist/lib/utils/namespaced-storage.js +1 -1
  226. package/dist/lib/utils/runtime-assets.js +1 -1
  227. package/dist/lib/utils/utils.js +1 -1
  228. package/dist/lib/{webmcp-DCfAFiIO.js → webmcp-BoMTvgmX.js} +3 -3
  229. package/dist/lib/{webmcp-DCfAFiIO.js.map → webmcp-BoMTvgmX.js.map} +1 -1
  230. package/dist/lib/{write-group-file-bytes-Ccn-VFUU.js → write-group-file-bytes-CNT7DqOZ.js} +3 -3
  231. package/dist/lib/{write-group-file-bytes-Ccn-VFUU.js.map → write-group-file-bytes-CNT7DqOZ.js.map} +1 -1
  232. package/dist/public/.well-known/mcp/server-card.json +1 -1
  233. package/dist/public/.well-known/mcp.json +1 -1
  234. package/dist/public/AGENTS.md +3 -1
  235. package/dist/public/README.md +6 -2
  236. package/dist/public/agent.worker.js +1 -1
  237. package/dist/public/attachment-capabilities-AdwXt3--.js +1 -0
  238. package/dist/public/{channel-BylT3rJC.js → channel-DIpDQekL.js} +1 -1
  239. package/dist/public/{chat-template-DPHJy7tr.js → chat-template-CXKs8lFR.js} +1 -1
  240. package/dist/public/compact-context-BQ2ZXoAc.js +5 -0
  241. package/dist/public/{compact-context-BINQh64w.js → compact-context-dHitmPsV.js} +2 -2
  242. package/dist/public/config-C16fFWtP.js +1 -0
  243. package/dist/public/{configure-peer-js-DChhcOfe.js → configure-peer-js-DV1rqvFX.js} +1 -1
  244. package/dist/public/{connections-CHaw0VqP.js → connections-Dxwj8yK_.js} +1 -1
  245. package/dist/public/{create-model-cache-fetch-DQebkoPL.js → create-model-cache-fetch-B0mSCEk6.js} +1 -1
  246. package/dist/public/{credentials-CgVqS119.js → credentials-CJUQ5Ep2.js} +1 -1
  247. package/dist/public/{custom-element-security-kiDhPfb8.js → custom-element-security-B2daIE5r.js} +2 -2
  248. package/dist/public/{discover-skills-Cvmx5I9V.js → discover-skills-BWJB8HUA.js} +6 -6
  249. package/dist/public/docs/architecture/overview.md +1 -1
  250. package/dist/public/docs/example/article/index.html +29 -30
  251. package/dist/public/docs/example/article.html +29 -30
  252. package/dist/public/docs/publishing/index.html +29 -30
  253. package/dist/public/docs/publishing.html +29 -30
  254. package/dist/public/docs/skill-creator/index.html +29 -30
  255. package/dist/public/docs/skill-creator.html +29 -30
  256. package/dist/public/docs/subsystems/attachment-capabilities.md +14 -1
  257. package/dist/public/docs/subsystems/cli.md +95 -51
  258. package/dist/public/docs/subsystems/pages.md +5 -0
  259. package/dist/public/{download-group-file-BapoRgfU.js → download-group-file-BkMH-JKi.js} +1 -1
  260. package/dist/public/e2e/README.md +1 -1
  261. package/dist/public/{e2e-bridge-C0g8vZKr.js → e2e-bridge-lP2qqiv3.js} +1 -1
  262. package/dist/public/get-group-dir-D--BiEyk.js +1 -0
  263. package/dist/public/{get-or-create-subscriber-id-GvRZYXwA.js → get-or-create-subscriber-id-jVHnQfbr.js} +1 -1
  264. package/dist/public/{git-CaAAZfVd.js → git-DjmQ16rm.js} +2 -2
  265. package/dist/public/{iframe-bridge-scripts-BnqtKhE4.js → iframe-bridge-scripts-CO0izGjW.js} +1 -1
  266. package/dist/public/index.html +29 -30
  267. package/dist/public/index.js +1 -1
  268. package/dist/public/{init-chat-split-resize-Btonoy8u.js → init-chat-split-resize-C8AqCCiK.js} +1 -1
  269. package/dist/public/init-control-plane-Ctz7FI8M.js +1 -0
  270. package/dist/public/{invoke-agent-B3Osw6K7.js → invoke-agent-C_geruwq.js} +1 -1
  271. package/dist/public/llms.txt +1 -1
  272. package/dist/public/main/index.html +29 -30
  273. package/dist/public/main/memory/index.html +29 -30
  274. package/dist/public/main/memory.html +29 -30
  275. package/dist/public/main.html +29 -30
  276. package/dist/public/{markdown-CPbU4r1U.js → markdown-CDSb5Hrl.js} +1 -1
  277. package/dist/public/{mcp-reconnect-CzROVsXG.js → mcp-reconnect-iPZPihwX.js} +1 -1
  278. package/dist/public/{memory-storage-BkoMlxOr.js → memory-storage-2m7KZ-aP.js} +1 -1
  279. package/dist/public/{model-ranking-CK0iBo3Z.js → model-ranking-BgOSaNIy.js} +1 -1
  280. package/dist/public/{move-group-entry-CTxoq7lw.js → move-group-entry-QQ9Hkk54.js} +1 -1
  281. package/dist/public/{orchestrator-BrDjQbGf.js → orchestrator-C1kaTltu.js} +2 -2
  282. package/dist/public/orchestrator-Li1UAsv7.js +63 -0
  283. package/dist/public/{peerjs-CgF4Iz5W.js → peerjs-DbBryE-9.js} +1 -1
  284. package/dist/public/{process-peer-query-param-BL2k0Hu-.js → process-peer-query-param-DQIgr3KL.js} +1 -1
  285. package/dist/public/{process-pending-shared-payloads-C1AgGvn8.js → process-pending-shared-payloads-Ctb-TFqB.js} +1 -1
  286. package/dist/public/{process-room-query-param-DM0QCq3_.js → process-room-query-param-F-XnIVoZ.js} +1 -1
  287. package/dist/public/provider-YPZmsuHR.js +1 -0
  288. package/dist/public/{push-client-DJEOz7bi.js → push-client-DRx9Eggz.js} +1 -1
  289. package/dist/public/{rooms-C6LXIJl4.js → rooms-BurBI7is.js} +1 -1
  290. package/dist/public/service-worker/init.js +1 -1
  291. package/dist/public/service-worker.js +1 -1
  292. package/dist/public/shadow-claw-Bg9AQ5x_.js +1176 -0
  293. package/dist/public/{shadow-claw-accounts--4hd_oCz.js → shadow-claw-accounts-B3mjYI0M.js} +1 -1
  294. package/dist/public/{shadow-claw-card-IbNlZAdK.js → shadow-claw-card-tcXRS1GF.js} +1 -1
  295. package/dist/public/{shadow-claw-channels-Vq_pPGa2.js → shadow-claw-channels-BiSfLvWv.js} +1 -1
  296. package/dist/public/{shadow-claw-chat-D7_GS25e.js → shadow-claw-chat-N5jMsXZZ.js} +3 -3
  297. package/dist/public/{shadow-claw-control-plane-WTMEV8_p.js → shadow-claw-control-plane-DFVe_Xdq.js} +2 -2
  298. package/dist/public/{shadow-claw-conversations-CLQgU1IT.js → shadow-claw-conversations-wAR06_ya.js} +1 -1
  299. package/dist/public/{shadow-claw-empty-state-D4CrFGsN.js → shadow-claw-empty-state-CnPm3NVM.js} +1 -1
  300. package/dist/public/{shadow-claw-file-viewer-BhqiqLWQ.js → shadow-claw-file-viewer-sZN_FCDW.js} +4 -4
  301. package/dist/public/{shadow-claw-files-senDiG9l.js → shadow-claw-files-CnvkCbd4.js} +2 -2
  302. package/dist/public/{shadow-claw-git-DOOCqY23.js → shadow-claw-git-BBHfClGk.js} +2 -2
  303. package/dist/public/{shadow-claw-integrations-Bsvc3Agq.js → shadow-claw-integrations-DvdBqzRJ.js} +1 -1
  304. package/dist/public/{shadow-claw-llm-actYICAk.js → shadow-claw-llm-YfohG519.js} +2 -2
  305. package/dist/public/{shadow-claw-mcp-remote-BYUgrK3v.js → shadow-claw-mcp-remote-BAVbf5pi.js} +1 -1
  306. package/dist/public/{shadow-claw-networking-Dk3p5Ny_.js → shadow-claw-networking-CZ4LWPW7.js} +1 -1
  307. package/dist/public/{shadow-claw-notifications-CzPAlay8.js → shadow-claw-notifications-BHwyREkG.js} +1 -1
  308. package/dist/public/{shadow-claw-page-header-CjJpVkyL.js → shadow-claw-page-header-De6Qf6eY.js} +1 -1
  309. package/dist/public/{shadow-claw-page-header-action-button-2DH5O1TD.js → shadow-claw-page-header-action-button-FSOhTc9z.js} +1 -1
  310. package/dist/public/{shadow-claw-pages-3r5I-wI8.js → shadow-claw-pages-D_oPyDca.js} +6 -6
  311. package/dist/public/{shadow-claw-pdf-viewer-BiCEwsoY.js → shadow-claw-pdf-viewer-CrU4wqRq.js} +1 -1
  312. package/dist/public/{shadow-claw-settings-DgB9RSZN.js → shadow-claw-settings-DkUhvxVr.js} +2 -2
  313. package/dist/public/{shadow-claw-storage-JB_43nd8.js → shadow-claw-storage-D0o56Tjw.js} +1 -1
  314. package/dist/public/{shadow-claw-task-server-oi5UIxdA.js → shadow-claw-task-server-4rkroO9K.js} +1 -1
  315. package/dist/public/{shadow-claw-tasks-CnyiOt81.js → shadow-claw-tasks-BdP7lmvu.js} +3 -3
  316. package/dist/public/{shadow-claw-terminal-BC3RynHt.js → shadow-claw-terminal-DVHX7Fsu.js} +1 -1
  317. package/dist/public/{shadow-claw-toast-YjG--2Za.js → shadow-claw-toast-B9Y9tSkW.js} +1 -1
  318. package/dist/public/{shadow-claw-tools-Bbwk4vlT.js → shadow-claw-tools-BwwY53Lr.js} +1 -1
  319. package/dist/public/{shadow-claw-webvm-HZqzl2H5.js → shadow-claw-webvm-CXGdkCNM.js} +1 -1
  320. package/dist/public/{sync-web-mcp-registration-BaH2nAP0.js → sync-web-mcp-registration-DVK_IhXZ.js} +1 -1
  321. package/dist/public/{system-prompt-Dck3N8T0.js → system-prompt-BmswoQwF.js} +2 -2
  322. package/dist/public/{tools-DHA1dK2I.js → tools-D-52Zmfc.js} +1 -1
  323. package/dist/public/{transformers-C-DuTM2K.js → transformers-CQ9ss9rD.js} +1 -1
  324. package/dist/public/{upload-group-file-Cejr3zo1.js → upload-group-file-A8kB7lvO.js} +1 -1
  325. package/dist/public/{webmcp-CMRtu57-.js → webmcp-DIUZjVF5.js} +1 -1
  326. package/dist/public/{workbox-92eae37e.js → workbox-e4022e15.js} +1 -1
  327. package/dist/public/{write-group-file-CmJuVQNO.js → write-group-file-R67DjJ-q.js} +1 -1
  328. package/dist/public/{write-group-file-bytes-Cejr3zo1.js → write-group-file-bytes-A8kB7lvO.js} +1 -1
  329. package/dist/public/{zip-reader-CuQ13eLe.js → zip-reader-JHoTbATw.js} +1 -1
  330. package/dist/server.js +6 -6
  331. package/package.json +1 -1
  332. package/dist/cli/chunk-2gZFafgY.js +0 -1
  333. package/dist/cli/chunk-BFziiMKt.js +0 -7
  334. package/dist/cli/chunk-BM3llsxb.js +0 -1
  335. package/dist/cli/chunk-BUNoeMKY.js +0 -36
  336. package/dist/cli/chunk-Bj5qFsDi.js +0 -7
  337. package/dist/cli/chunk-Bj95zm-y.js +0 -1
  338. package/dist/cli/chunk-BpyP-esT.js +0 -1
  339. package/dist/cli/chunk-CX696s3_.js +0 -1
  340. package/dist/cli/chunk-DRxCrCAA.js +0 -139
  341. package/dist/cli/chunk-DjbCHa0h.js +0 -1
  342. package/dist/cli/chunk-Ds5-K-9o.js +0 -1
  343. package/dist/cli/chunk-DsQhAF31.js +0 -1
  344. package/dist/cli/chunk-VM-dECyG.js +0 -1
  345. package/dist/cli/chunk-gvNsvav0.js +0 -225
  346. package/dist/cli/chunk-heu2xRw1.js +0 -1
  347. package/dist/lib/orchestrator-i_QJ-o22.js.map +0 -1
  348. package/dist/lib/shadow-claw-DoQ7fgl5.js.map +0 -1
  349. package/dist/lib/system-prompt-DT_KeYaL.js.map +0 -1
  350. package/dist/public/app-routes-V_-URXc5.js +0 -1
  351. package/dist/public/attachment-capabilities-B6ibLwQB.js +0 -1
  352. package/dist/public/compact-context-CX4H8V57.js +0 -5
  353. package/dist/public/config-C-YdSFZB.js +0 -1
  354. package/dist/public/get-group-dir-DL44kvqW.js +0 -1
  355. package/dist/public/init-control-plane-BoJijVtf.js +0 -1
  356. package/dist/public/orchestrator-CaUpEVkQ.js +0 -63
  357. package/dist/public/provider-DNIL4-Hw.js +0 -1
  358. package/dist/public/shadow-claw-DdgeYPg5.js +0 -1176
package/dist/server.js CHANGED
@@ -3690,7 +3690,7 @@ x8e=Object.defineProperty,S8e=(e,t,n)=>t in e?x8e(e,t,{enumerable:!0,configurabl
3690
3690
  (id, groupId, enabled, schedule, prompt, tools, lastRun, createdAt, type, freshContext, subagent, name, task_order, pushNotifications)
3691
3691
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);for(let e of i)a.run(Hf(),n,+!!e.enabled,e.schedule??null,e.prompt??``,e.tools??null,e.lastRun??null,e.createdAt,e.type??null,e.freshContext?1:null,e.subagent?1:null,e.name??null,e.task_order??null,e.pushNotifications?1:null);return Promise.resolve(i.length)}return new Promise((r,i)=>{let a=e?.transaction(`tasks`,`readwrite`);if(!a)throw Error(`failed to get transaction, cannot clone tasks.`);let o=a.objectStore(`tasks`),s=o.index(`by-group`).openCursor(t),c=0;s.onsuccess=()=>{let e=s.result;if(e){let t={...e.value,id:Hf(),groupId:n};o.put(t),c++,e.continue()}else r(c)},s.onerror=()=>i(s.error)})}var G8e=R((()=>{qf(),ma()}));function K8e(e,t){return _a(e,`messages`,`readwrite`,e=>e.delete(t)).then(()=>void 0)}var q8e=R((()=>{va()}));function J8e(e,t){return t?_a(e,`tasks`,`readwrite`,e=>e.delete(t)).then(()=>void 0):Promise.reject(/* @__PURE__ */ Error(`Task ID is required for deletion.`))}var Y8e=R((()=>{va()}));function pO(e){return _a(e,`tasks`,`readonly`,e=>e.getAll()).then(e=>e.map(e=>({...e,enabled:!!e.enabled})))}var mO=R((()=>{va()}));function X8e(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`sub-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}async function hO(e){if(!e)return X8e();let t=await ba(e,V.SUBSCRIBER_ID);if(typeof t==`string`&&t.trim().length>0)return t;let n=X8e();return await BD(e,V.SUBSCRIBER_ID,n),n}var Z8e=R((()=>{Mn(),xa(),VD()}));function Q8e(e,t,n){let r=null,i,a;return typeof e==`string`?(i=e,a=t):(r=e,i=t,a=n??50),r&&fa(r)?Promise.resolve().then(()=>(r.db.prepare(`SELECT * FROM messages WHERE groupId = ? ORDER BY timestamp DESC LIMIT ?`).all(i,a)??[]).reverse().map($8e)):new Promise(async(e,t)=>{try{let n=r??await aa();if(!n)return t(/* @__PURE__ */ Error(`failed to get transaction, cannot get recent messages.`));let o=n.transaction(`messages`,`readonly`);if(!o)return t(/* @__PURE__ */ 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 $8e(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}}var e5e=R((()=>{da(),ma()}));async function gO(e){let t=await ba(e,u5e);if(!t)return[];try{return JSON.parse(t)}catch{return[]}}async function _O(e,t){await BD(e,u5e,JSON.stringify(t))}async function t5e(e,t,n=`br:`,r){let i=await gO(e),a={groupId:`${n}${r??Hf()}`,name:t,createdAt:Date.now()};return i.push(a),await _O(e,i),a}async function n5e(e,t,n){let r=await gO(e),i=r.find(e=>e.groupId===t);i&&(i.name=n),await _O(e,r)}async function r5e(e,t,n){let r=await gO(e),i=r.find(e=>e.groupId===t);i&&(n&&n.length>0?i.toolTags=n:delete i.toolTags),await _O(e,r)}async function i5e(e,t){await _O(e,(await gO(e)).filter(e=>e.groupId!==t))}async function vO(e){let t=await gO(e);if(t.length===0){let t={groupId:fn,name:`Main`,createdAt:0};return await _O(e,[t]),[t]}return t}async function a5e(e,t){let n=await gO(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 _O(e,i)}async function o5e(e,t){let n=await gO(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:`}${Hf()}`,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 _O(e,n),a}async function s5e(e,t,n,r,i){let a=await gO(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 _O(e,a)}async function c5e(e,t,n,r,i,a){let o=await gO(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 _O(e,o)}async function l5e(e,t,n){let r=await gO(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 _O(e,r)}var u5e,d5e=R((()=>{Mn(),xa(),VD(),qf(),u5e=`group_metadata`}));function yO(e,t){return _a(e,`messages`,`readwrite`,e=>e.put(t)).then(()=>void 0)}var f5e=R((()=>{va()}));function bO(e,t){let n={...t,enabled:+!!t.enabled};return _a(e,`tasks`,`readwrite`,e=>e.put(n)).then(()=>void 0)}var p5e=R((()=>{va()}));function m5e(e,t,n){let r=null,i,a;return typeof e==`string`?(i=e,a=t):(r=e,i=t,a=n),r&&fa(r)?Promise.resolve().then(()=>{r.db.prepare(`UPDATE tasks SET lastRun = ? WHERE id = ?`).run(a,i)}):new Promise(async(e,t)=>{try{let n=r??await aa();if(!n)return t(/* @__PURE__ */ Error(`failed to get transaction, cannot update task last run.`));let o=n.transaction(`tasks`,`readwrite`);if(!o)return t(/* @__PURE__ */ Error(`failed to get transaction`));let s=o.objectStore(`tasks`),c=s.get(i);c.onsuccess=()=>{let n=c.result;if(!n){e();return}n.lastRun=a;let r=s.put(n);r.onsuccess=()=>e(),r.onerror=()=>t(r.error)},c.onerror=()=>t(c.error)}catch(e){t(e)}})}var h5e=R((()=>{da(),ma()}));async function g5e(e,t,n){let r=(await pO(e)).filter(e=>e.groupId===t),i=new Map(r.map(e=>[e.id,e])),a=[],o=0;for(let t of n){let n=i.get(t);n&&(n.order=o++,await bO(e,n),a.push(n),i.delete(t))}let s=Array.from(i.values()).sort((e,t)=>{let n=e.order??0,r=t.order??0;return n===r?e.createdAt-t.createdAt:n-r});for(let t of s)t.order=o++,await bO(e,t),a.push(t);return a}var _5e=R((()=>{mO(),p5e()}));async function v5e(e,t,n,r){let i=await Lp(e,t),a=await Lp(e,n),o=r.replace(/\\/g,`/`).replace(/^\/+/,``).split(`/`).filter(Boolean),s=i,c=a;for(let e of o)s=await s.getDirectoryHandle(e),c=await c.getDirectoryHandle(e,{create:!0});let l=n.replace(/:/g,`-`),u=[yp(),`groups`,l,...o];try{await y5e(e,n,s,c,u)}catch(e){throw o.length>0&&await a.removeEntry(o[0],{recursive:!0}).catch(()=>void 0),e}}async function y5e(e,t,n,r,i){for await(let[a,o]of n.entries()){if(o.kind===`directory`){await y5e(e,t,o,await r.getDirectoryHandle(a,{create:!0}),[...i,a]);continue}let n=await o.getFile(),s=await r.getFileHandle(a,{create:!0});try{await FD(s,n)}catch(t){if(!((t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`)&&(await wp(e)).type===`opfs`))throw t;await ID([...i,a],n)}}}var b5e=R((()=>{Rp(),Ep(),LD()}));async function xO(e,t,n=`.`){for(let r=0;r<2;r++)try{let r=await Lp(e,t);if(n&&n!==`.`){let e=n.replace(/\\/g,`/`).replace(/^\/home\/user\//,`/`).replace(/^\/+/,``).split(`/`).filter(Boolean);for(let t of e){let e=await r.getDirectoryHandle(t);if(typeof r.isSameEntry==`function`&&await r.isSameEntry(e))throw Error(`Directory navigation stuck at "${r.name}" for segment "${t}" — the stored directory handle may be stale.`);r=e}}let i=[];for await(let[e,t]of r.entries())i.push(t.kind===`directory`?`${e}/`:e);return i.sort()}catch(e){if(r===0&&Cp(e)){Sp();continue}throw e}return[]}var SO=R((()=>{Rp(),Ep()}));function x5e(e){if(!e||typeof e!=`object`)return!1;let t=globalThis.FileSystemDirectoryHandle;return t!==void 0&&e instanceof t||typeof e.getDirectoryHandle==`function`&&typeof e.getFileHandle==`function`&&typeof e.requestPermission==`function`}async function S5e(e){let t=await ba(e,V.STORAGE_HANDLE);return!x5e(t)||await t.requestPermission({mode:`readwrite`})===`granted`}var C5e=R((()=>{Mn(),xa()}));function w5e(e){let t=Lt();return t?`shadowclaw:${t}:${e}`:e}function T5e(e){if(typeof localStorage>`u`)return null;let t=w5e(e);try{let n=localStorage.getItem(t);if(n!==null)return n;if(t===e)return null;let r=localStorage.getItem(e);if(r!==null)return localStorage.setItem(t,r),r}catch(e){console.warn(`Unable to read from localStorage:`,e)}return null}function E5e(e,t){if(typeof localStorage>`u`)return;let n=w5e(e);try{localStorage.setItem(n,t)}catch(e){console.warn(`Unable to write to localStorage:`,e)}}var D5e=R((()=>{Gt()}));async function O5e(e,t){let n=await Lp(e,t);for await(let[e]of n.entries())await n.removeEntry(e,{recursive:!0})}var k5e=R((()=>{Rp()}));async function CO(e,t,n){let r=await Lp(e,t),{dirs:i,filename:a}=zp(n.replace(/\/$/,``)),o=r;for(let e of i)o=await o.getDirectoryHandle(e);await o.removeEntry(a,{recursive:!0})}var A5e=R((()=>{Rp(),Bp()}));function wO(e,t){return`${e}:${t}`}async function j5e(e){let t=await ba(e,V.SUPPRESSED_PAGES_LIST);if(!t||typeof t!=`string`)return[];try{let e=JSON.parse(t);if(Array.isArray(e))return e}catch{}return[]}async function M5e(e,t,n){let r=await j5e(e),i=wO(t,n);return r.some(e=>wO(e.groupId,e.path)===i)}async function N5e(e,t,n){let r=await j5e(e),i=wO(t,n);if(!r.some(e=>wO(e.groupId,e.path)===i)){let i=[...r,{groupId:t,path:n}];await BD(e,V.SUPPRESSED_PAGES_LIST,JSON.stringify(i))}}async function P5e(e,t,n){let r=await j5e(e),i=wO(t,n),a=r.filter(e=>wO(e.groupId,e.path)!==i);a.length!==r.length&&await BD(e,V.SUPPRESSED_PAGES_LIST,JSON.stringify(a))}var F5e=R((()=>{Mn(),xa(),VD()}));function TO(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}var EO=R((()=>{}));function I5e(e){let t=e.trim().replace(/\\/g,`/`);return t===`/`||/^\/+$/.test(t)?`/`:t.replace(/^\/+/,``).replace(/\/+$/,``)}function DO(e){return e===`/`?`/`:e.replace(U5e,``)}function L5e(e){let t=e.trim().replace(/\\/g,`/`);return t===`/`||/^\/+$/.test(t)?`/`:t.replace(/^\/+/,``).replace(/\/+$/,``)}function R5e(e){return e?e.replace(/^br:/i,``).replace(/^br-/i,``).trim():`main`}function OO(e,t){let n=L5e(t);if(!n)return;e.add(n);let r=DO(n);r&&r!==n&&e.add(r)}function z5e(e,t,n){let r=/* @__PURE__ */ new Set;if(!e)return r;let i=R5e(t);if(e===`/`){if(r.add(`/`),OO(r,`index.html`),n){let e=I5e(n);e&&e!==`/`&&OO(r,`${e}/index.html`)}return OO(r,`pages/index.html`),OO(r,`pages/${i}/index.html`),OO(r,`${i}/index.html`),r}if(OO(r,e),n){let t=I5e(n);t&&t!==`/`&&OO(r,`${t}/${e}`)}if(e.startsWith(`pages/`)){let t=e.slice(6);OO(r,t),t.startsWith(`${i}/`)?OO(r,t.slice(`${i}/`.length)):OO(r,t.replace(/^[^/]+\//,``))}else OO(r,`pages/${e}`),OO(r,`pages/${i}/${e}`),OO(r,`${i}/${e}`);for(let e of Array.from(r)){let t=DO(e);if(e===`index.html`||t===`index`){r.add(`/`);break}}return r}function B5e(e,t){let n=t.toLowerCase(),r=DO(t).toLowerCase(),i=n===r?[n]:[n,r];for(let t of e){let e=t.toLowerCase(),n=DO(e);for(let t of i)if(t&&(e===t||n===t||t!==`/`&&(e.startsWith(`${t}/`)||n.startsWith(`${t}/`)||e.endsWith(`/${t}`)||n.endsWith(`/${t}`)||e.includes(`/${t}/`)||n.includes(`/${t}/`))))return!0}return!1}function V5e(e,t){for(let n of t){let t=I5e(n);if(t&&B5e(e,t))return!0}return!1}function H5e(e,t,n,r){if(!e||typeof e!=`string`)return!1;let i=L5e(e);if(!i)return!1;let a=[],o=[],s,c;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t,n=e.allowList??e.allowlist??[],r=e.denyList??e.denylist??[];a=TO(Array.from(n||[])),o=TO(Array.from(r||[])),s=e.groupId,c=e.basePathPrefix}else a=TO(Array.from(t||[])),o=TO(Array.from(n||[])),s=r?.groupId,c=r?.basePathPrefix;let l=z5e(i,s,c);return o.length>0&&V5e(l,o)?!1:a.length>0?V5e(l,a):!0}var U5e,W5e=R((()=>{EO(),U5e=/\.(md|markdown|html|xhtml|txt)$/i}));function G5e(e){if(!e)return``;let t=e.match(/^\r?\n([ \t]+)/);if(t){let n=t[1],r=RegExp(`^[ \\t]{1,${n.length}}`,`gm`);return e.replace(/^\r?\n/,``).replace(r,``).replace(/\r?\n[ \t]*$/,`
3692
3692
  `)}if(/^(?:\r?\n)+[ \t]*---/.test(e))return e.replace(/^(?:\r?\n)+/,``);if(/^[ \t]+---/.test(e)){let t=e.match(/^[ \t]+/);if(t){let n=t[0],r=RegExp(`^[ \\t]{1,${n.length}}`,`gm`);return e.replace(r,``)}}return e}var K5e=R((()=>{}));function q5e(e=fn){return e===`br:main`?V.STATIC_MAIN_SITE_SEEDED:`${V.STATIC_MAIN_SITE_SEEDED}:${e}`}async function J5e(e,t=fn){let n=await ba(e,q5e(t));return n===!0||n===`true`}async function Y5e(e,t=fn,n=!0){await BD(e,q5e(t),n)}function X5e(){let e=zt(`/${f7e}`);if(typeof window<`u`&&window.location?.origin)try{return new URL(e,window.location.origin).toString()}catch{return e}return e}function Z5e(e){let t=e.replace(/^\/+/,``),n=p7e;if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent);typeof t?.pages?.baseUrl==`string`&&(n=t.pages.baseUrl.replace(/^\/+/,``).replace(/\/+$/,``))}}catch{}let r=zt(n?`/${n}/${t}`:`/${t}`);if(typeof window<`u`&&window.location?.origin)try{return new URL(r,window.location.origin).toString()}catch{return r}return r}async function Q5e(){if(typeof fetch!=`function`)return null;try{let e=X5e(),t=await fetch(e);if(t.ok){if((t.headers?.get?.(`content-type`)||``).includes(`text/html`))return null;let e=await t.json();if(e&&Array.isArray(e.pages))return e}}catch{}return null}async function $5e(e){if(typeof fetch!=`function`)return null;try{let t=Z5e(e),n=await fetch(t);if(n.ok){let t=n.headers?.get?.(`content-type`)||``;if((e.endsWith(`.md`)||e.endsWith(`.markdown`)||e.endsWith(`.json`))&&t.includes(`text/html`))return null;let r=await n.text();return r.includes(`<shadow-claw`)||r.includes(`data-shadow-claw-dsd`)?null:r}}catch{}return null}function e7e(e){if(typeof document>`u`)return null;let t=t=>{if(!t||!(t instanceof HTMLElement))return!1;if(!e)return!0;let n=t.getAttribute(`data-initial-path`)?.trim();return!n||n===e},n=document.querySelector(e?`[data-pages-rendered][data-initial-path="${e}"]`:`[data-pages-rendered]`);if(t(n))return n;let r=document.querySelector(`shadow-claw`)?.shadowRoot,i=(r?.querySelector(`shadow-claw-pages`)?.shadowRoot)?.querySelector(e?`[data-pages-rendered][data-initial-path="${e}"]`:`[data-pages-rendered]`)||r?.querySelector(e?`[data-pages-rendered][data-initial-path="${e}"]`:`[data-pages-rendered]`);if(t(i))return i;let a=document.querySelectorAll(`template`);for(let n of Array.from(a)){let r=n.content?.querySelector(e?`[data-pages-rendered][data-initial-path="${e}"]`:`[data-pages-rendered]`);if(t(r))return r;let i=n.content?.querySelectorAll(`template`);if(i)for(let n of Array.from(i)){let r=n.content?.querySelector(e?`[data-pages-rendered][data-initial-path="${e}"]`:`[data-pages-rendered]`);if(t(r))return r}}return null}function kO(e=`index.html`){let t=e7e(e);if(!t)return null;let n=t.getAttribute(`data-initial-path`)?.trim();if(n&&n!==e)return null;let r=t.querySelector(`[data-markdown-frontmatter]`),i=null;if(r){let e=r.getAttribute(`data-frontmatter`);if(e)try{i=JSON.parse(e)}catch{}}let a=t.cloneNode(!0),o=a.querySelector(`[data-markdown-frontmatter]`);o&&o.remove();let s=a.innerHTML.trim();if(!s&&!i)return null;if(i&&Object.keys(i).length>0){let e=[`---`];for(let[t,n]of Object.entries(i))typeof n==`string`?e.push(`${t}: ${JSON.stringify(n)}`):typeof n==`number`||typeof n==`boolean`?e.push(`${t}: ${n}`):e.push(`${t}: ${JSON.stringify(n)}`);return e.push(`---`,``),`${e.join(`
3693
- `)}\n${s}`}return s}async function t7e(e={}){let t=()=>{let e=null;if(typeof document<`u`){let t=document.getElementById(`shadow-claw-static-manifest`);if(t&&t.textContent)try{let n=JSON.parse(t.textContent);n&&Array.isArray(n.pages)&&(e={...n,pages:[...n.pages]})}catch(e){console.warn(`Failed to parse embedded static main manifest:`,e)}let n=document.querySelectorAll(`script[type="text/markdown"][data-shadow-claw-page]`);if(n.length>0){e||={pages:[]};for(let t of Array.from(n)){let n=t.getAttribute(`data-shadow-claw-page`)?.trim();if(n){let r=t.textContent||``;r=G5e(r),!r.trim()&&/^memory\.(md|markdown)$/iu.test(n)&&(r=HD),!r.trim()&&(n===`index.html`||/^index\.(html?|xhtml)$/iu.test(n))&&(r=kO(n)??YD);let i=e.pages.findIndex(e=>e.displayPath===n);i>=0?e.pages[i].content=r:e.pages.push({displayPath:n,content:r})}}}let r=document.getElementById(`shadow-claw-site-config`);if(r?.textContent)try{let t=JSON.parse(r.textContent);if(Array.isArray(t?.pages?.files)){e||={pages:[]};for(let n of t.pages.files)if(typeof n==`string`&&n.trim()){let t=n.trim(),r=``;/^memory\.(md|markdown)$/iu.test(t)?r=HD:(t===`index.html`||/^index\.(html?|xhtml)$/iu.test(t))&&(r=kO(t)??YD),e.pages.some(e=>e.displayPath===t)||e.pages.push({displayPath:t,content:r})}}}catch{}let i=e7e();if(i){e||={pages:[]};let t=i.getAttribute(`data-initial-path`)?.trim()||`index.html`;if(!e.pages.some(e=>e.displayPath===t)){let n=kO(t)??YD;e.pages.push({displayPath:t,content:n})}e.pages.some(e=>/^memory\.(md|markdown)$/iu.test(e.displayPath))||e.pages.push({displayPath:`MEMORY.md`,content:HD})}}return e};if(e.preferEmbedded!==!1){let e=t();if(e)return e}if(e.fetchFallback!==!1){let e=await Q5e();if(e)return e}if(e.preferEmbedded===!1){let e=t();if(e)return e}return{pages:[{displayPath:`index.html`,content:YD},{displayPath:`MEMORY.md`,content:HD}]}}async function n7e(e,t,n=[]){for(let[r,i]of Object.entries(t))if(r===`purgePreRenderedStaticPages`&&i===!0){if(n.length>0){let t=n[0],r=n.slice(1).join(`/`);try{r?await CO(e,t,r):await O5e(e,t)}catch(e){console.warn(`Failed to purge pre-rendered static pages for ${t}/${r}:`,e)}}}else typeof i==`object`&&i&&await n7e(e,i,[...n,r])}function r7e(){if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent);if(t?.pages?.sortOrder===`desc`)return`desc`;if(t?.pages?.sortOrder===`asc`)return`asc`}}catch{}return`desc`}function i7e(){if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent)?.pages?.defaultPinnedPage;if(typeof t==`string`&&t.trim().length>0)return t.trim()}}catch{}return null}function a7e(){if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent);return{allowList:TO(t?.pages?.allowList??t?.pages?.allowlist??t?.allowList??t?.allowlist??[]),denyList:TO(t?.pages?.denyList??t?.pages?.denylist??t?.denyList??t?.denylist??[])}}}catch{}return{allowList:[],denyList:[]}}function o7e(e,t){let n=t??r7e();return[...e].sort((e,t)=>{let r=e.path,i=t.path,a=r.split(`/`).pop()||``,o=i.split(`/`).pop()||``,s=/^index\.(html?|xhtml)$/iu.test(a),c=/^index\.(html?|xhtml)$/iu.test(o);if(s&&!c)return-1;if(!s&&c)return 1;let l=/^memory\.(md|markdown)$/iu.test(a),u=/^memory\.(md|markdown)$/iu.test(o);return l&&!u?1:!l&&u?-1:n===`asc`?r.localeCompare(i,void 0,{numeric:!0,sensitivity:`base`}):i.localeCompare(r,void 0,{numeric:!0,sensitivity:`base`})})}async function s7e(e,t,n=l7e,r=u7e){let i=t??d7e;try{if(T5e(n)===i)return!0}catch{}try{if(await ba(e,r)===i){try{E5e(n,i)}catch{}return!0}await BD(e,r,i);try{E5e(n,i)}catch{}}catch{try{E5e(n,i)}catch{}}return!1}async function c7e(e,t=fn,n=[],r={}){await X6e(e,t);let i=await t7e(r),a=!1;i.preRenderedStaticPages&&(await s7e(e,i.purgeId)||(a=!0,await n7e(e,i.preRenderedStaticPages)));let o=!1;if(t===`br:main`&&i.skillsPurgeId!==void 0&&!await s7e(e,i.skillsPurgeId,`sc:skills-purge-id`,`static_main_skills_purge_id`)){o=!0;try{await CO(e,t,`.agents/skills/main`)}catch(e){if(!(e&&typeof e==`object`&&`name`in e&&e.name===`NotFoundError`))throw e}try{await CO(e,t,`.agents/tools/main`)}catch(e){if(!(e&&typeof e==`object`&&`name`in e&&e.name===`NotFoundError`))throw e}}for(let n of i.pages)if(n.content?.includes(`slug: "shadow-claw--purge-pages"`)){!a&&!await s7e(e,i.purgeId)&&(a=!0,await O5e(e,t));break}let s=t===`br:main`&&await GD(e),c=new Set(i.pages.map(e=>wO(t,e.displayPath))),l=a?n.filter(e=>e.groupId!==t||c.has(wO(e.groupId,e.path))):[...n],{allowList:u,denyList:d}=a7e(),f=0;for(let n of i.pages)if(f++,f%5==0&&await new Promise(e=>setTimeout(e,0)),!n.content?.includes(`slug: "shadow-claw--purge-pages"`)&&H5e(n.displayPath,{allowList:u,denyList:d,groupId:t})){if(/^memory\.(md|markdown)$/iu.test(n.displayPath)){if(s)continue;let r=typeof n.content==`string`&&n.content.trim().length>0&&n.content!==HD?n.content:void 0;if(r===void 0?await qD(e,t):await qD(e,t,r)){let e=wO(t,n.displayPath);l.some(t=>wO(t.groupId,t.path)===e)||l.push({groupId:t,path:n.displayPath})}}else if(!await M5e(e,t,n.displayPath))try{if(!await UD(e,t,n.displayPath)){let r=n.content;(typeof r!=`string`||!r.trim())&&(r=n.displayPath===`index.html`?kO(`index.html`)??YD:await $5e(n.displayPath)??``),await RD(e,t,n.displayPath,r)}let r=wO(t,n.displayPath);l.some(e=>wO(e.groupId,e.path)===r)||l.push({groupId:t,path:n.displayPath})}catch(e){console.warn(`Failed to seed static page file ${n.displayPath}:`,e)}}if(t===`br:main`){for(let n of i.skills||[]){let r=`.agents/skills/main/${n.displayPath}`;try{await UD(e,t,r)||await RD(e,t,r,n.content)}catch(e){console.warn(`Failed to seed skill file ${r}:`,e)}}for(let n of i.tools||[]){let r=`.agents/tools/main/${n.displayPath}`;try{(o||!await UD(e,t,r))&&await RD(e,t,r,n.content)}catch(e){console.warn(`Failed to seed tool file ${r}:`,e)}}}let p=typeof document<`u`&&(document.getElementById(`shadow-claw-static-manifest`)!==null||document.querySelector(`script[type="text/markdown"][data-shadow-claw-page]`)!==null||e7e()!==null);r.preferEmbedded!==!1&&p||await Y5e(e,t,!0);let m=l.filter(e=>H5e(e.path,{allowList:u,denyList:d,groupId:e.groupId}));return Object.defineProperty(m,"didPurge",{value:a,enumerable:!1,writable:!0,configurable:!0}),Object.defineProperty(m,"didPurgeSkills",{value:o,enumerable:!1,writable:!0,configurable:!0}),o7e(m)}var l7e,u7e,d7e,f7e,p7e,m7e=R((()=>{Mn(),D5e(),K6e(),H6e(),Gt(),xa(),VD(),k5e(),A5e(),Q6e(),G6e(),WD(),F5e(),zD(),W5e(),EO(),K5e(),l7e=`sc:purge-id`,u7e=`static_main_site_purge_id`,d7e=`__legacy_purge_pages__`,f7e=`static-main-manifest.json`,p7e=`static-main`})),h7e,g7e=R((()=>{qf(),h7e=class{_events;_handlers=[];_runs=/* @__PURE__ */ new Map;constructor(e){this._events=e}start(){this._listen(`streaming-start`,this._onStreamingStart),this._listen(`streaming-chunk`,this._onStreamingChunk),this._listen(`streaming-end`,this._onStreamingEnd),this._listen(`streaming-done`,this._onStreamingDone),this._listen(`streaming-error`,this._onStreamingError),this._listen(`tool-activity`,this._onToolActivity)}stop(){for(let{event:e,handler:t}of this._handlers)this._events.off(e,t);this._handlers=[],this._runs.clear()}_emit(e,t){window.dispatchEvent(new CustomEvent(`shadow-claw-agui-event`,{detail:{groupId:e,event:t}}))}_listen(e,t){this._events.on(e,t),this._handlers.push({event:e,handler:t})}_onStreamingChunk=({groupId:e,text:t})=>{let n=this._runs.get(e);n&&n.messageId&&this._emit(e,{type:`TEXT_MESSAGE_CONTENT`,messageId:n.messageId,delta:t,timestamp:Date.now()})};_onStreamingDone=({groupId:e})=>{let t=this._runs.get(e);t&&(t.messageId&&this._emit(e,{type:`TEXT_MESSAGE_END`,messageId:t.messageId,timestamp:Date.now()}),this._emit(e,{type:`RUN_FINISHED`,threadId:t.threadId,runId:t.runId,timestamp:Date.now()}),this._runs.delete(e))};_onStreamingEnd=({groupId:e})=>{let t=this._runs.get(e);t&&t.messageId&&(this._emit(e,{type:`TEXT_MESSAGE_END`,messageId:t.messageId,timestamp:Date.now()}),t.messageId=null)};_onStreamingError=({groupId:e,error:t})=>{let n=this._runs.get(e);n&&(n.messageId&&this._emit(e,{type:`TEXT_MESSAGE_END`,messageId:n.messageId,timestamp:Date.now()}),this._emit(e,{type:`RUN_ERROR`,message:t||`Unknown streaming error`,timestamp:Date.now()}),this._runs.delete(e))};_onStreamingStart=({groupId:e})=>{let t=Hf(),n=e,r=Hf();this._runs.set(e,{runId:t,threadId:n,messageId:r,activeToolCallIds:/* @__PURE__ */ new Set}),this._emit(e,{type:`RUN_STARTED`,threadId:n,runId:t,timestamp:Date.now()}),this._emit(e,{type:`TEXT_MESSAGE_START`,messageId:r,role:`assistant`,timestamp:Date.now()})};_onToolActivity=({groupId:e,tool:t,status:n})=>{let r=this._runs.get(e);if(r){if(n===`running`){let n=Hf();r.activeToolCallIds.add(n),this._emit(e,{type:`TOOL_CALL_START`,toolCallId:n,toolCallName:t,timestamp:Date.now()}),r._lastToolCallId=n}else if(n===`done`||n===`error`){let t=r._lastToolCallId;t&&(r.activeToolCallIds.delete(t),this._emit(e,{type:`TOOL_CALL_END`,toolCallId:t,timestamp:Date.now()}))}}}}})),_7e,v7e,AO,y7e=R((()=>{O8e(),_7e=5,v7e=class{#e=new fO.State(0);#t=/* @__PURE__ */ new Map;#n=new fO.State([]);clear(){this.#t.forEach((e,t)=>this.clearTimer(t)),this.#t.clear(),this.#n.set([])}clearTimer(e){let t=this.#t.get(e);t?.timeoutId&&clearTimeout(t.timeoutId),this.#t.delete(e)}dismiss(e){this.clearTimer(e),this.#n.set(this.#n.get().filter(t=>t.id!==e))}pause(e){let t=this.#t.get(e);t&&t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)),this.#t.set(e,t))}resolveAction(e){if(e&&typeof e.label==`string`&&typeof e.onClick==`function`)return e}resolveDuration(e){return typeof e!=`number`||Number.isNaN(e)||e<0?4e3:e}resolveType(e){return e&&[`success`,`warning`,`error`,`info`].includes(e)?e:`info`}resume(e){let t=this.#t.get(e);!t||t.timeoutId||t.remaining<=0||this.scheduleDismiss(e,t.remaining)}scheduleDismiss(e,t){this.clearTimer(e);let n=globalThis.setTimeout(()=>{this.dismiss(e)},t);this.#t.set(e,{timeoutId:n,remaining:t,startedAt:Date.now()})}show(e,t={}){let n=this.#e.get()+1;this.#e.set(n);let r={id:n,message:e,type:this.resolveType(t.type),duration:this.resolveDuration(t.duration),action:this.resolveAction(t.action),createdAt:Date.now()},i=[...this.#n.get(),r];if(i.length>_7e){let e=i[0];this.clearTimer(e.id),this.#n.set(i.slice(1))}else this.#n.set(i);return r.duration>0&&this.scheduleDismiss(r.id,r.duration),r.id}get toasts(){return this.#n.get()}async runAction(e){let t=this.#n.get().find(t=>t.id===e);t?.action&&await t.action.onClick()}},AO=new v7e}));function jO(e,t={}){return AO.show(e,t)}function b7e(e,t=4e3){return AO.show(e,{type:`success`,duration:t})}function MO(e,t=5e3){return AO.show(e,{type:`error`,duration:t})}var x7e=R((()=>{y7e()}));function S7e(e,t){if(!e||typeof e!=`object`)return e;let n=JSON.parse(JSON.stringify(e));for(let e of t)C7e(n,e);return n}function C7e(e,t){let{op:n,path:r,value:i}=t;if(!r||!r.startsWith(`/`))return;let a=r.split(`/`).slice(1).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)),o=a.pop();if(o===void 0)return;let s=e;for(let e of a){if(typeof s!=`object`||!s)return;s=s[e]}typeof s==`object`&&s&&(Array.isArray(s)?w7e(s,o,n,i):T7e(s,o,n,i))}function w7e(e,t,n,r){if(n===`add`){if(t===`-`)e.push(r);else{let n=parseInt(t,10);!isNaN(n)&&n>=0&&n<=e.length&&e.splice(n,0,r)}}else if(n===`replace`){let n=parseInt(t,10);!isNaN(n)&&n>=0&&n<e.length&&(e[n]=r)}else if(n===`remove`){let n=parseInt(t,10);!isNaN(n)&&n>=0&&n<e.length&&e.splice(n,1)}}function T7e(e,t,n,r){n===`add`||n===`replace`?e[t]=r:n===`remove`&&delete e[t]}var E7e=R((()=>{}));function D7e(e){if(e==null)return null;let t=String(e).trim().toLowerCase();return[`1`,`true`,`yes`,`on`].includes(t)?!0:![`0`,`false`,`no`,`off`].includes(t)&&null}function O7e(e,t=!1){if(e==null)return t;if(typeof e==`boolean`)return e;if(typeof e==`number`)return e===1;if(typeof e==`string`){let t=e.trim().toLowerCase();return t===`true`||t===`1`}return!1}var k7e=R((()=>{}));function A7e(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return TO(t.map(e=>String(e)))}catch{}return TO(e.split(`,`))}var j7e=R((()=>{EO()}));function M7e(e){if(typeof document>`u`)return null;let t=`shadow-claw-site-config`;if(e){let n=e.getAttribute(`config`)?.trim();n&&(t=n.replace(/^#/,``))}let n=document.getElementById(t);if(!n?.textContent)return NO.delete(t),null;let r=NO.get(t);if(r&&r.rawText===n.textContent)return r.config;try{let e=JSON.parse(n.textContent);if(!e||typeof e!=`object`)return NO.delete(t),null;let r={...e};return NO.set(t,{rawText:n.textContent,config:r}),r}catch(e){return console.warn(`[ShadowClaw] Failed to parse site configuration from #${t}:`,e),null}}var NO,N7e=R((()=>{NO=/* @__PURE__ */ new Map})),P7e,F7e=R((()=>{P7e={name:`bash`,description:`Execute a shell command. When WebVM is available, runs in a full Alpine Linux VM (x86) with all standard Linux commands. When WebVM is disabled or unavailable, falls back to a lightweight JavaScript shell emulator with 83 commands: alias, awk, base64, basename, bash, cat, cd, chmod, clear, column, comm, command, cp, curl, cut, date, diff, dirname, du, echo, egrep, env, expand, export, expr, false, fgrep, file, find, fold, grep, gunzip, gzip, head, help, html-to-markdown, join, jq, ln, ls, md5sum, mkdir, mv, nl, od, paste, printenv, printf, pwd, readlink, realpath, rev, rg, rm, rmdir, sed, seq, sh, sha1sum, sha256sum, sha384sum, sha512sum, sleep, sort, split, stat, strings, tac, tail, tar, tee, test, timeout, touch, tr, tree, true, unalias, uniq, wc, which, xargs, yes, zcat. Commands NOT available in fallback mode: node, npm, npx, git, apk, python, wget.Supports pipes (|), redirects (> >>), operators (&& || ;), newlines, and # comments. Prefer read_file/write_file for file inspection and edits — they are faster and more reliable than shell commands for that purpose.`,input_schema:{type:`object`,properties:{command:{type:`string`,description:`The bash command to execute`},stdin:{type:`string`,description:`Optional standard input (stdin) to pass to the command`},timeout:{type:`number`,description:`Timeout in seconds (default from Settings, initially 120; max: 1800)`}},required:[`command`]}}})),I7e,L7e,R7e=R((()=>{I7e={name:`clear_chat`,description:`Clear the current chat history and start a new session. Useful for scheduled tasks to prevent context from growing indefinitely.`,input_schema:{type:`object`,properties:{}}},L7e={name:`ask_user`,description:`Pause execution to ask the user a question or request confirmation. This halts the agent's work until the user provides an answer. Use this for human-in-the-loop checkpoints before taking destructive actions or when you need clarification to proceed.`,input_schema:{type:`object`,properties:{question:{type:`string`,description:`The question or confirmation message to present to the user.`},options:{type:`array`,items:{type:`string`},description:`Optional list of predefined choices for the user to select from.`}},required:[`question`]}}})),z7e,B7e,V7e,H7e=R((()=>{z7e={name:`manage_email`,description:`Manage email connection settings for IMAP/SMTP workflows. Supports status, connect/configure, enable/disable, delete, read_messages, send_message, mark_as_read, mark_as_unread, delete_messages, download_attachments, list available connection types, and lightweight test actions.`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`status`,`list_plugins`,`list_connections`,`connect`,`configure`,`enable`,`disable`,`delete`,`test`,`read_messages`,`send_message`,`mark_as_read`,`mark_as_unread`,`delete_messages`,`download_attachments`],description:`Email management action to perform.`},plugin_id:{type:`string`,description:`Optional connection type ID for connect operations (default: imap).`},connection_id:{type:`string`,description:`Connection ID or label for configure, enable, disable, delete, and test actions. For read_messages/send_message, it may be omitted when there is exactly one enabled IMAP connection.`},label:{type:`string`,description:`Human-readable connection label for new connections.`},enabled:{type:`boolean`,description:`Optional enabled flag used during connect/configure actions.`},config:{type:`object`,properties:{},description:`Email config object (host, port, secure, mailboxPath, smtpHost, smtpPort, smtpSecure, etc.).`},mailbox_path:{type:`string`,description:`Optional mailbox path override for read_messages (default: INBOX).`},limit:{type:`number`,description:`Optional max messages to fetch for read_messages (default 10, range 1-50).`},unread_only:{type:`boolean`,description:`If true, read_messages returns only unread messages.`},message_uids:{type:`array`,items:{type:`number`},description:`Message UIDs for mark_as_read, mark_as_unread, and delete_messages actions.`},message_uid:{type:`number`,description:`Single message UID used by download_attachments action.`},attachment_parts:{type:`array`,items:{type:`string`},description:`Optional IMAP MIME part IDs to download (for example: 2, 3.1). If omitted, all attachments in the message are downloaded.`},save_directory:{type:`string`,description:`Optional workspace directory for downloaded attachments (default: downloads/email).`},attachments:{type:`array`,items:{anyOf:[{type:`string`},{type:`object`,properties:{path:{type:`string`},filename:{type:`string`},content_type:{type:`string`}},required:[`path`]}]},description:`Optional workspace file attachments for send_message. Provide paths or objects with path/filename/content_type.`},to:{type:`array`,items:{type:`string`},description:`Recipient email addresses for send_message.`},cc:{type:`array`,items:{type:`string`},description:`Optional CC recipient addresses for send_message.`},bcc:{type:`array`,items:{type:`string`},description:`Optional BCC recipient addresses for send_message.`},subject:{type:`string`,description:`Message subject for send_message.`},body:{type:`string`,description:`Plaintext message body for send_message.`},html:{type:`string`,description:`Optional HTML body for send_message.`},from:{type:`string`,description:`Optional from address override for send_message.`},reply_to:{type:`string`,description:`Optional reply-to address for send_message.`},username:{type:`string`,description:`Optional username override for connect/configure/read_messages/send_message.`},password:{type:`string`,description:`Optional password override for connect/configure/read_messages/send_message.`}},required:[`action`]}},B7e={name:`email_read_messages`,description:`Read recent messages from a configured email connection (IMAP). Use this to check inbox mail from an agent workflow. Results include attachment metadata when available.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Email connection ID or label.`},mailbox_path:{type:`string`,description:`Optional mailbox path override (default: INBOX).`},limit:{type:`number`,description:`Optional max messages to fetch (default 10, range 1-50).`},unread_only:{type:`boolean`,description:`If true, only unread messages are returned.`}},required:[`connection_id`]}},V7e={name:`email_send_message`,description:`Send an email message through a configured email connection (SMTP).`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Email connection ID or label.`},to:{type:`array`,items:{type:`string`},description:`Recipient email addresses.`},cc:{type:`array`,items:{type:`string`},description:`Optional CC recipient addresses.`},bcc:{type:`array`,items:{type:`string`},description:`Optional BCC recipient addresses.`},subject:{type:`string`,description:`Message subject.`},body:{type:`string`,description:`Plaintext message body.`},html:{type:`string`,description:`Optional HTML message body.`},from:{type:`string`,description:`Optional from address override.`},reply_to:{type:`string`,description:`Optional reply-to address.`}},required:[`connection_id`,`to`,`subject`]}}})),U7e,W7e,G7e,K7e=R((()=>{U7e={name:`fetch_url`,description:`Fetch a URL via HTTP and return the response body. Subject to browser CORS restrictions — works with most public APIs. Response is truncated to 100KB. Set use_git_auth to true to automatically inject the saved Git PAT as an Authorization header (supports GitHub, Azure DevOps, GitLab, and other providers — auth format is auto-detected from the URL's host). If include_headers is true, the response will include both request and response headers.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`The URL to fetch`},method:{type:`string`,description:`HTTP method (default: GET)`},headers:{type:`object`,properties:{},description:`Request headers as key-value pairs`},body:{type:`string`,description:`Request body (for POST/PUT/PATCH)`},use_git_auth:{type:`boolean`,description:`If true, inject the saved Git credentials as an Authorization header. Auth format is auto-detected from the URL host: GitHub (token), Azure DevOps (Basic), GitLab (Bearer), or generic Bearer.`},git_account_id:{type:`string`,description:`Optional explicit Git account ID to use when use_git_auth is true. If omitted, account resolution uses hostPattern/default matching.`},use_account_auth:{type:`boolean`,description:`If true, inject a saved service account PAT as a Bearer Authorization header. The account is matched by hostPattern against the URL (longest match wins), then falls back to the default service account. Use this for non-Git services like Figma, Notion, or any other service whose PAT is stored under Settings → Accounts.`},account_id:{type:`string`,description:`Optional explicit service account ID to use when use_account_auth is true. If omitted, account resolution uses hostPattern/default matching.`},auth_mode:{type:`string`,enum:[`pat`,`oauth`],description:`Optional preferred credential mode when multiple accounts match. Valid values: pat or oauth.`},include_headers:{type:`boolean`,description:`If true, include request and response headers in the output.`}},required:[`url`]}},W7e={name:`fetch_file`,description:`Fetch a URL and save the response body directly to the workspace in one step. Equivalent to fetch_url + write_file but atomic. Text responses are saved as UTF-8; binary responses (images, PDFs, audio, video, zip, application/octet-stream) are saved as raw bytes. The destination path within the workspace is required. Supports the same authentication options as fetch_url (use_git_auth, use_account_auth, etc.). Returns the workspace path the file was saved to and the number of bytes written.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`The URL to fetch`},path:{type:`string`,description:`Destination path within the workspace (e.g. 'data/response.json'). Parent directories are created automatically. Must not contain '..' segments.`},method:{type:`string`,description:`HTTP method (default: GET)`},headers:{type:`object`,properties:{},description:`Request headers as key-value pairs`},body:{type:`string`,description:`Request body (for POST/PUT/PATCH)`},use_git_auth:{type:`boolean`,description:`If true, inject the saved Git credentials as an Authorization header. Auth format is auto-detected from the URL host: GitHub (token), Azure DevOps (Basic), GitLab (Bearer), or generic Bearer.`},git_account_id:{type:`string`,description:`Optional explicit Git account ID to use when use_git_auth is true. If omitted, account resolution uses hostPattern/default matching.`},use_account_auth:{type:`boolean`,description:`If true, inject a saved service account PAT as a Bearer Authorization header. The account is matched by hostPattern against the URL (longest match wins), then falls back to the default service account.`},account_id:{type:`string`,description:`Optional explicit service account ID to use when use_account_auth is true. If omitted, account resolution uses hostPattern/default matching.`},auth_mode:{type:`string`,enum:[`pat`,`oauth`],description:`Optional preferred credential mode when multiple accounts match. Valid values: pat or oauth.`}},required:[`url`,`path`]}},G7e={name:`web_search`,description:`Perform a web search using a search engine to discover information. Returns a plain-text summary of the top search results including titles, URLs, and snippets. Use this when you need to find information but don't know the exact URL to fetch.`,input_schema:{type:`object`,properties:{query:{type:`string`,description:`The search query to look up.`}},required:[`query`]}}})),q7e,J7e=R((()=>{q7e={name:`javascript`,description:`Execute JavaScript code in a sandboxed Worker and return the result. Lighter than bash — no VM boot required. Use for calculations, data transformations, JSON processing, string analysis, etc. Runs in strict mode. No access to DOM, eval(), Function(), self, postMessage, importScripts, navigator, or indexedDB — these are all undefined. fetch availability is controlled by Tool Configuration -> Internet Access (shared with bash). setTimeout is available but setInterval is blocked. IMPORTANT: You CANNOT call other agent tools (like read_file, write_file, or bash) from inside this sandbox. If you need to process file contents or tool outputs, you must fetch them in a previous turn and pass the data into this tool via the $PIPE_DATA variable. Write plain JavaScript expressions and statements — the return value of the last expression is captured as the result.`,input_schema:{type:`object`,properties:{code:{type:`string`,description:`JavaScript code to execute. The return value of the last expression is captured.`},data:{type:`string`,description:"Optional input data string. Accessible inside the code sandbox via the global constant `$PIPE_DATA`."}},required:[`code`]}}})),Y7e,X7e,Z7e=R((()=>{Y7e={name:`remote_mcp_list_tools`,description:`List available tools from a configured Remote MCP connection by connection ID or label.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Remote MCP connection ID or label`}},required:[`connection_id`]}},X7e={name:`remote_mcp_call_tool`,description:`Call a tool exposed by a configured Remote MCP connection.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Remote MCP connection ID or label`},tool_name:{type:`string`,description:`Remote MCP tool name`},arguments:{type:`object`,properties:{},description:`Arguments object passed to the remote MCP tool`}},required:[`connection_id`,`tool_name`]}}})),Q7e,$7e,e9e=R((()=>{Q7e={name:`manage_tools`,description:`Enable or disable specific tools, or activate a predefined tool profile. Use list_tool_profiles to see available profiles before activating one. This helps optimize the context window and focus capabilities. Changes take effect on the NEXT turn, not immediately within the current tool-use loop.`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`enable`,`disable`,`activate_profile`],description:`The management action to perform.`},tool_names:{type:`array`,items:{type:`string`},description:`List of tool names to enable or disable. Required for 'enable' and 'disable' actions.`},profile_id:{type:`string`,description:`The unique ID of the tool profile to activate. Required for 'activate_profile' action.`}},required:[`action`]}},$7e={name:`list_tool_profiles`,description:`List all available tool profiles that can be activated using manage_tools. Returns a list of profiles with their IDs, names, and the tools they contain.`,input_schema:{type:`object`,properties:{}}}})),t9e,n9e=R((()=>{t9e={name:`update_memory`,description:`Update the MEMORY.md memory file for this group. Use this to persist important context, user preferences, project state, and anything the agent should remember across conversations. This file is loaded as system context on every invocation.`,input_schema:{type:`object`,properties:{content:{type:`string`,description:`New content for the MEMORY.md memory file`}},required:[`content`]}}})),r9e,i9e,a9e=R((()=>{r9e={name:`show_toast`,description:`Show a toast notification to the user. Toasts are non-blocking, auto-dismissing notifications that appear in the bottom-right corner. Use for: operation status (success/failure), warnings, informational messages, progress updates. Avoid for: critical errors requiring acknowledgment (use clear error messages instead), lengthy content (keep messages concise).`,input_schema:{type:`object`,properties:{message:{type:`string`,description:`The message to display in the toast (keep concise)`},type:{type:`string`,description:`Type of toast: 'success', 'error', 'warning', or 'info' (default: 'info')`,enum:[`success`,`error`,`warning`,`info`]},duration:{type:`number`,description:`Auto-dismiss duration in milliseconds (default: 5000 for info/success, 8000 for warning/error). Set to 0 to disable auto-dismiss.`}},required:[`message`]}},i9e={name:`send_notification`,description:`Send an OS-level push notification to the user via Web Push. Unlike toasts (in-app only), push notifications appear even when the app is not focused or the tab is in the background. Use for: important alerts, long-running task completion, time-sensitive information. Requires the user to have enabled push notifications in Settings.`,input_schema:{type:`object`,properties:{title:{type:`string`,description:`Notification title (default: 'ShadowClaw')`},body:{type:`string`,description:`The notification body text`}},required:[`body`]}}})),o9e,s9e,c9e=R((()=>{o9e=`https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json`,s9e=`A2UI Basic Catalog — Component & Function Reference
3693
+ `)}\n${s}`}return s}async function t7e(e={}){let t=()=>{let e=null;if(typeof document<`u`){let t=document.getElementById(`shadow-claw-static-manifest`);if(t&&t.textContent)try{let n=JSON.parse(t.textContent);n&&Array.isArray(n.pages)&&(e={...n,pages:[...n.pages]})}catch(e){console.warn(`Failed to parse embedded static main manifest:`,e)}let n=document.querySelectorAll(`script[type="text/markdown"][data-shadow-claw-page]`);if(n.length>0){e||={pages:[]};for(let t of Array.from(n)){let n=t.getAttribute(`data-shadow-claw-page`)?.trim();if(n){let r=t.textContent||``;r=G5e(r),!r.trim()&&/^memory\.(md|markdown)$/iu.test(n)&&(r=HD),!r.trim()&&(n===`index.html`||/^index\.(html?|xhtml)$/iu.test(n))&&(r=kO(n)??YD);let i=e.pages.findIndex(e=>e.displayPath===n);i>=0?e.pages[i].content=r:e.pages.push({displayPath:n,content:r})}}}let r=document.getElementById(`shadow-claw-site-config`);if(r?.textContent)try{let t=JSON.parse(r.textContent);if(Array.isArray(t?.pages?.files)){e||={pages:[]};for(let n of t.pages.files)if(typeof n==`string`&&n.trim()){let t=n.trim(),r=``;/^memory\.(md|markdown)$/iu.test(t)?r=HD:(t===`index.html`||/^index\.(html?|xhtml)$/iu.test(t))&&(r=kO(t)??YD),e.pages.some(e=>e.displayPath===t)||e.pages.push({displayPath:t,content:r})}}}catch{}let i=e7e();if(i){e||={pages:[]};let t=i.getAttribute(`data-initial-path`)?.trim()||`index.html`;if(!e.pages.some(e=>e.displayPath===t)){let n=kO(t)??YD;e.pages.push({displayPath:t,content:n})}e.pages.some(e=>/^memory\.(md|markdown)$/iu.test(e.displayPath))||e.pages.push({displayPath:`MEMORY.md`,content:HD})}}return e};if(e.preferEmbedded!==!1){let e=t();if(e&&e.pages.length>0)return e}if(e.fetchFallback!==!1){let e=await Q5e();if(e&&e.pages.length>0)return e}if(e.preferEmbedded===!1){let e=t();if(e&&e.pages.length>0)return e}return{pages:[{displayPath:`index.html`,content:YD},{displayPath:`MEMORY.md`,content:HD}]}}async function n7e(e,t,n=[]){for(let[r,i]of Object.entries(t))if(r===`purgePreRenderedStaticPages`&&i===!0){if(n.length>0){let t=n[0],r=n.slice(1).join(`/`);try{r?await CO(e,t,r):await O5e(e,t)}catch(e){console.warn(`Failed to purge pre-rendered static pages for ${t}/${r}:`,e)}}}else typeof i==`object`&&i&&await n7e(e,i,[...n,r])}function r7e(){if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent);if(t?.pages?.sortOrder===`desc`)return`desc`;if(t?.pages?.sortOrder===`asc`)return`asc`}}catch{}return`desc`}function i7e(){if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent)?.pages?.defaultPinnedPage;if(typeof t==`string`&&t.trim().length>0)return t.trim()}}catch{}return null}function a7e(){if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent);return{allowList:TO(t?.pages?.allowList??t?.pages?.allowlist??t?.allowList??t?.allowlist??[]),denyList:TO(t?.pages?.denyList??t?.pages?.denylist??t?.denyList??t?.denylist??[])}}}catch{}return{allowList:[],denyList:[]}}function o7e(e,t){let n=t??r7e();return[...e].sort((e,t)=>{let r=e.path,i=t.path,a=r.split(`/`).pop()||``,o=i.split(`/`).pop()||``,s=/^index\.(html?|xhtml)$/iu.test(a),c=/^index\.(html?|xhtml)$/iu.test(o);if(s&&!c)return-1;if(!s&&c)return 1;let l=/^memory\.(md|markdown)$/iu.test(a),u=/^memory\.(md|markdown)$/iu.test(o);return l&&!u?1:!l&&u?-1:n===`asc`?r.localeCompare(i,void 0,{numeric:!0,sensitivity:`base`}):i.localeCompare(r,void 0,{numeric:!0,sensitivity:`base`})})}async function s7e(e,t,n=l7e,r=u7e){let i=t??d7e;try{if(T5e(n)===i)return!0}catch{}try{if(await ba(e,r)===i){try{E5e(n,i)}catch{}return!0}await BD(e,r,i);try{E5e(n,i)}catch{}}catch{try{E5e(n,i)}catch{}}return!1}async function c7e(e,t=fn,n=[],r={}){await X6e(e,t);let i=await t7e(r),a=!1;i.preRenderedStaticPages&&(await s7e(e,i.purgeId)||(a=!0,await n7e(e,i.preRenderedStaticPages)));let o=!1;if(t===`br:main`&&i.skillsPurgeId!==void 0&&!await s7e(e,i.skillsPurgeId,`sc:skills-purge-id`,`static_main_skills_purge_id`)){o=!0;try{await CO(e,t,`.agents/skills/main`)}catch(e){if(!(e&&typeof e==`object`&&`name`in e&&e.name===`NotFoundError`))throw e}try{await CO(e,t,`.agents/tools/main`)}catch(e){if(!(e&&typeof e==`object`&&`name`in e&&e.name===`NotFoundError`))throw e}}for(let n of i.pages)if(n.content?.includes(`slug: "shadow-claw--purge-pages"`)){!a&&!await s7e(e,i.purgeId)&&(a=!0,await O5e(e,t));break}let s=t===`br:main`&&await GD(e),c=new Set(i.pages.map(e=>wO(t,e.displayPath))),l=a?n.filter(e=>e.groupId!==t||c.has(wO(e.groupId,e.path))):[...n],{allowList:u,denyList:d}=a7e(),f=0;for(let n of i.pages)if(f++,f%5==0&&await new Promise(e=>setTimeout(e,0)),!n.content?.includes(`slug: "shadow-claw--purge-pages"`)&&H5e(n.displayPath,{allowList:u,denyList:d,groupId:t})){if(/^memory\.(md|markdown)$/iu.test(n.displayPath)){if(s)continue;let r=typeof n.content==`string`&&n.content.trim().length>0&&n.content!==HD?n.content:void 0;if(r===void 0?await qD(e,t):await qD(e,t,r)){let e=wO(t,n.displayPath);l.some(t=>wO(t.groupId,t.path)===e)||l.push({groupId:t,path:n.displayPath})}}else if(!await M5e(e,t,n.displayPath))try{if(!await UD(e,t,n.displayPath)){let r=n.content;(typeof r!=`string`||!r.trim())&&(r=n.displayPath===`index.html`?kO(`index.html`)??YD:await $5e(n.displayPath)??``),await RD(e,t,n.displayPath,r)}let r=wO(t,n.displayPath);l.some(e=>wO(e.groupId,e.path)===r)||l.push({groupId:t,path:n.displayPath})}catch(e){console.warn(`Failed to seed static page file ${n.displayPath}:`,e)}}if(t===`br:main`){for(let n of i.skills||[]){let r=`.agents/skills/main/${n.displayPath}`;try{await UD(e,t,r)||await RD(e,t,r,n.content)}catch(e){console.warn(`Failed to seed skill file ${r}:`,e)}}for(let n of i.tools||[]){let r=`.agents/tools/main/${n.displayPath}`;try{(o||!await UD(e,t,r))&&await RD(e,t,r,n.content)}catch(e){console.warn(`Failed to seed tool file ${r}:`,e)}}}let p=typeof document<`u`&&(document.getElementById(`shadow-claw-static-manifest`)!==null||document.querySelector(`script[type="text/markdown"][data-shadow-claw-page]`)!==null||e7e()!==null);r.preferEmbedded!==!1&&p||await Y5e(e,t,!0);let m=l.filter(e=>H5e(e.path,{allowList:u,denyList:d,groupId:e.groupId}));return Object.defineProperty(m,"didPurge",{value:a,enumerable:!1,writable:!0,configurable:!0}),Object.defineProperty(m,"didPurgeSkills",{value:o,enumerable:!1,writable:!0,configurable:!0}),o7e(m)}var l7e,u7e,d7e,f7e,p7e,m7e=R((()=>{Mn(),D5e(),K6e(),H6e(),Gt(),xa(),VD(),k5e(),A5e(),Q6e(),G6e(),WD(),F5e(),zD(),W5e(),EO(),K5e(),l7e=`sc:purge-id`,u7e=`static_main_site_purge_id`,d7e=`__legacy_purge_pages__`,f7e=`static-main-manifest.json`,p7e=`static-main`})),h7e,g7e=R((()=>{qf(),h7e=class{_events;_handlers=[];_runs=/* @__PURE__ */ new Map;constructor(e){this._events=e}start(){this._listen(`streaming-start`,this._onStreamingStart),this._listen(`streaming-chunk`,this._onStreamingChunk),this._listen(`streaming-end`,this._onStreamingEnd),this._listen(`streaming-done`,this._onStreamingDone),this._listen(`streaming-error`,this._onStreamingError),this._listen(`tool-activity`,this._onToolActivity)}stop(){for(let{event:e,handler:t}of this._handlers)this._events.off(e,t);this._handlers=[],this._runs.clear()}_emit(e,t){window.dispatchEvent(new CustomEvent(`shadow-claw-agui-event`,{detail:{groupId:e,event:t}}))}_listen(e,t){this._events.on(e,t),this._handlers.push({event:e,handler:t})}_onStreamingChunk=({groupId:e,text:t})=>{let n=this._runs.get(e);n&&n.messageId&&this._emit(e,{type:`TEXT_MESSAGE_CONTENT`,messageId:n.messageId,delta:t,timestamp:Date.now()})};_onStreamingDone=({groupId:e})=>{let t=this._runs.get(e);t&&(t.messageId&&this._emit(e,{type:`TEXT_MESSAGE_END`,messageId:t.messageId,timestamp:Date.now()}),this._emit(e,{type:`RUN_FINISHED`,threadId:t.threadId,runId:t.runId,timestamp:Date.now()}),this._runs.delete(e))};_onStreamingEnd=({groupId:e})=>{let t=this._runs.get(e);t&&t.messageId&&(this._emit(e,{type:`TEXT_MESSAGE_END`,messageId:t.messageId,timestamp:Date.now()}),t.messageId=null)};_onStreamingError=({groupId:e,error:t})=>{let n=this._runs.get(e);n&&(n.messageId&&this._emit(e,{type:`TEXT_MESSAGE_END`,messageId:n.messageId,timestamp:Date.now()}),this._emit(e,{type:`RUN_ERROR`,message:t||`Unknown streaming error`,timestamp:Date.now()}),this._runs.delete(e))};_onStreamingStart=({groupId:e})=>{let t=Hf(),n=e,r=Hf();this._runs.set(e,{runId:t,threadId:n,messageId:r,activeToolCallIds:/* @__PURE__ */ new Set}),this._emit(e,{type:`RUN_STARTED`,threadId:n,runId:t,timestamp:Date.now()}),this._emit(e,{type:`TEXT_MESSAGE_START`,messageId:r,role:`assistant`,timestamp:Date.now()})};_onToolActivity=({groupId:e,tool:t,status:n})=>{let r=this._runs.get(e);if(r){if(n===`running`){let n=Hf();r.activeToolCallIds.add(n),this._emit(e,{type:`TOOL_CALL_START`,toolCallId:n,toolCallName:t,timestamp:Date.now()}),r._lastToolCallId=n}else if(n===`done`||n===`error`){let t=r._lastToolCallId;t&&(r.activeToolCallIds.delete(t),this._emit(e,{type:`TOOL_CALL_END`,toolCallId:t,timestamp:Date.now()}))}}}}})),_7e,v7e,AO,y7e=R((()=>{O8e(),_7e=5,v7e=class{#e=new fO.State(0);#t=/* @__PURE__ */ new Map;#n=new fO.State([]);clear(){this.#t.forEach((e,t)=>this.clearTimer(t)),this.#t.clear(),this.#n.set([])}clearTimer(e){let t=this.#t.get(e);t?.timeoutId&&clearTimeout(t.timeoutId),this.#t.delete(e)}dismiss(e){this.clearTimer(e),this.#n.set(this.#n.get().filter(t=>t.id!==e))}pause(e){let t=this.#t.get(e);t&&t.timeoutId&&(clearTimeout(t.timeoutId),t.timeoutId=void 0,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)),this.#t.set(e,t))}resolveAction(e){if(e&&typeof e.label==`string`&&typeof e.onClick==`function`)return e}resolveDuration(e){return typeof e!=`number`||Number.isNaN(e)||e<0?4e3:e}resolveType(e){return e&&[`success`,`warning`,`error`,`info`].includes(e)?e:`info`}resume(e){let t=this.#t.get(e);!t||t.timeoutId||t.remaining<=0||this.scheduleDismiss(e,t.remaining)}scheduleDismiss(e,t){this.clearTimer(e);let n=globalThis.setTimeout(()=>{this.dismiss(e)},t);this.#t.set(e,{timeoutId:n,remaining:t,startedAt:Date.now()})}show(e,t={}){let n=this.#e.get()+1;this.#e.set(n);let r={id:n,message:e,type:this.resolveType(t.type),duration:this.resolveDuration(t.duration),action:this.resolveAction(t.action),createdAt:Date.now()},i=[...this.#n.get(),r];if(i.length>_7e){let e=i[0];this.clearTimer(e.id),this.#n.set(i.slice(1))}else this.#n.set(i);return r.duration>0&&this.scheduleDismiss(r.id,r.duration),r.id}get toasts(){return this.#n.get()}async runAction(e){let t=this.#n.get().find(t=>t.id===e);t?.action&&await t.action.onClick()}},AO=new v7e}));function jO(e,t={}){return AO.show(e,t)}function b7e(e,t=4e3){return AO.show(e,{type:`success`,duration:t})}function MO(e,t=5e3){return AO.show(e,{type:`error`,duration:t})}var x7e=R((()=>{y7e()}));function S7e(e,t){if(!e||typeof e!=`object`)return e;let n=JSON.parse(JSON.stringify(e));for(let e of t)C7e(n,e);return n}function C7e(e,t){let{op:n,path:r,value:i}=t;if(!r||!r.startsWith(`/`))return;let a=r.split(`/`).slice(1).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)),o=a.pop();if(o===void 0)return;let s=e;for(let e of a){if(typeof s!=`object`||!s)return;s=s[e]}typeof s==`object`&&s&&(Array.isArray(s)?w7e(s,o,n,i):T7e(s,o,n,i))}function w7e(e,t,n,r){if(n===`add`){if(t===`-`)e.push(r);else{let n=parseInt(t,10);!isNaN(n)&&n>=0&&n<=e.length&&e.splice(n,0,r)}}else if(n===`replace`){let n=parseInt(t,10);!isNaN(n)&&n>=0&&n<e.length&&(e[n]=r)}else if(n===`remove`){let n=parseInt(t,10);!isNaN(n)&&n>=0&&n<e.length&&e.splice(n,1)}}function T7e(e,t,n,r){n===`add`||n===`replace`?e[t]=r:n===`remove`&&delete e[t]}var E7e=R((()=>{}));function D7e(e){if(e==null)return null;let t=String(e).trim().toLowerCase();return[`1`,`true`,`yes`,`on`].includes(t)?!0:![`0`,`false`,`no`,`off`].includes(t)&&null}function O7e(e,t=!1){if(e==null)return t;if(typeof e==`boolean`)return e;if(typeof e==`number`)return e===1;if(typeof e==`string`){let t=e.trim().toLowerCase();return t===`true`||t===`1`}return!1}var k7e=R((()=>{}));function A7e(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return TO(t.map(e=>String(e)))}catch{}return TO(e.split(`,`))}var j7e=R((()=>{EO()}));function M7e(e){if(typeof document>`u`)return null;let t=`shadow-claw-site-config`;if(e){let n=e.getAttribute(`config`)?.trim();n&&(t=n.replace(/^#/,``))}let n=document.getElementById(t);if(!n?.textContent)return NO.delete(t),null;let r=NO.get(t);if(r&&r.rawText===n.textContent)return r.config;try{let e=JSON.parse(n.textContent);if(!e||typeof e!=`object`)return NO.delete(t),null;let r={...e};return NO.set(t,{rawText:n.textContent,config:r}),r}catch(e){return console.warn(`[ShadowClaw] Failed to parse site configuration from #${t}:`,e),null}}var NO,N7e=R((()=>{NO=/* @__PURE__ */ new Map})),P7e,F7e=R((()=>{P7e={name:`bash`,description:`Execute a shell command. When WebVM is available, runs in a full Alpine Linux VM (x86) with all standard Linux commands. When WebVM is disabled or unavailable, falls back to a lightweight JavaScript shell emulator with 83 commands: alias, awk, base64, basename, bash, cat, cd, chmod, clear, column, comm, command, cp, curl, cut, date, diff, dirname, du, echo, egrep, env, expand, export, expr, false, fgrep, file, find, fold, grep, gunzip, gzip, head, help, html-to-markdown, join, jq, ln, ls, md5sum, mkdir, mv, nl, od, paste, printenv, printf, pwd, readlink, realpath, rev, rg, rm, rmdir, sed, seq, sh, sha1sum, sha256sum, sha384sum, sha512sum, sleep, sort, split, stat, strings, tac, tail, tar, tee, test, timeout, touch, tr, tree, true, unalias, uniq, wc, which, xargs, yes, zcat. Commands NOT available in fallback mode: node, npm, npx, git, apk, python, wget.Supports pipes (|), redirects (> >>), operators (&& || ;), newlines, and # comments. Prefer read_file/write_file for file inspection and edits — they are faster and more reliable than shell commands for that purpose.`,input_schema:{type:`object`,properties:{command:{type:`string`,description:`The bash command to execute`},stdin:{type:`string`,description:`Optional standard input (stdin) to pass to the command`},timeout:{type:`number`,description:`Timeout in seconds (default from Settings, initially 120; max: 1800)`}},required:[`command`]}}})),I7e,L7e,R7e=R((()=>{I7e={name:`clear_chat`,description:`Clear the current chat history and start a new session. Useful for scheduled tasks to prevent context from growing indefinitely.`,input_schema:{type:`object`,properties:{}}},L7e={name:`ask_user`,description:`Pause execution to ask the user a question or request confirmation. This halts the agent's work until the user provides an answer. Use this for human-in-the-loop checkpoints before taking destructive actions or when you need clarification to proceed.`,input_schema:{type:`object`,properties:{question:{type:`string`,description:`The question or confirmation message to present to the user.`},options:{type:`array`,items:{type:`string`},description:`Optional list of predefined choices for the user to select from.`}},required:[`question`]}}})),z7e,B7e,V7e,H7e=R((()=>{z7e={name:`manage_email`,description:`Manage email connection settings for IMAP/SMTP workflows. Supports status, connect/configure, enable/disable, delete, read_messages, send_message, mark_as_read, mark_as_unread, delete_messages, download_attachments, list available connection types, and lightweight test actions.`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`status`,`list_plugins`,`list_connections`,`connect`,`configure`,`enable`,`disable`,`delete`,`test`,`read_messages`,`send_message`,`mark_as_read`,`mark_as_unread`,`delete_messages`,`download_attachments`],description:`Email management action to perform.`},plugin_id:{type:`string`,description:`Optional connection type ID for connect operations (default: imap).`},connection_id:{type:`string`,description:`Connection ID or label for configure, enable, disable, delete, and test actions. For read_messages/send_message, it may be omitted when there is exactly one enabled IMAP connection.`},label:{type:`string`,description:`Human-readable connection label for new connections.`},enabled:{type:`boolean`,description:`Optional enabled flag used during connect/configure actions.`},config:{type:`object`,properties:{},description:`Email config object (host, port, secure, mailboxPath, smtpHost, smtpPort, smtpSecure, etc.).`},mailbox_path:{type:`string`,description:`Optional mailbox path override for read_messages (default: INBOX).`},limit:{type:`number`,description:`Optional max messages to fetch for read_messages (default 10, range 1-50).`},unread_only:{type:`boolean`,description:`If true, read_messages returns only unread messages.`},message_uids:{type:`array`,items:{type:`number`},description:`Message UIDs for mark_as_read, mark_as_unread, and delete_messages actions.`},message_uid:{type:`number`,description:`Single message UID used by download_attachments action.`},attachment_parts:{type:`array`,items:{type:`string`},description:`Optional IMAP MIME part IDs to download (for example: 2, 3.1). If omitted, all attachments in the message are downloaded.`},save_directory:{type:`string`,description:`Optional workspace directory for downloaded attachments (default: downloads/email).`},attachments:{type:`array`,items:{anyOf:[{type:`string`},{type:`object`,properties:{path:{type:`string`},filename:{type:`string`},content_type:{type:`string`}},required:[`path`]}]},description:`Optional workspace file attachments for send_message. Provide paths or objects with path/filename/content_type.`},to:{type:`array`,items:{type:`string`},description:`Recipient email addresses for send_message.`},cc:{type:`array`,items:{type:`string`},description:`Optional CC recipient addresses for send_message.`},bcc:{type:`array`,items:{type:`string`},description:`Optional BCC recipient addresses for send_message.`},subject:{type:`string`,description:`Message subject for send_message.`},body:{type:`string`,description:`Plaintext message body for send_message.`},html:{type:`string`,description:`Optional HTML body for send_message.`},from:{type:`string`,description:`Optional from address override for send_message.`},reply_to:{type:`string`,description:`Optional reply-to address for send_message.`},username:{type:`string`,description:`Optional username override for connect/configure/read_messages/send_message.`},password:{type:`string`,description:`Optional password override for connect/configure/read_messages/send_message.`}},required:[`action`]}},B7e={name:`email_read_messages`,description:`Read recent messages from a configured email connection (IMAP). Use this to check inbox mail from an agent workflow. Results include attachment metadata when available.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Email connection ID or label.`},mailbox_path:{type:`string`,description:`Optional mailbox path override (default: INBOX).`},limit:{type:`number`,description:`Optional max messages to fetch (default 10, range 1-50).`},unread_only:{type:`boolean`,description:`If true, only unread messages are returned.`}},required:[`connection_id`]}},V7e={name:`email_send_message`,description:`Send an email message through a configured email connection (SMTP).`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Email connection ID or label.`},to:{type:`array`,items:{type:`string`},description:`Recipient email addresses.`},cc:{type:`array`,items:{type:`string`},description:`Optional CC recipient addresses.`},bcc:{type:`array`,items:{type:`string`},description:`Optional BCC recipient addresses.`},subject:{type:`string`,description:`Message subject.`},body:{type:`string`,description:`Plaintext message body.`},html:{type:`string`,description:`Optional HTML message body.`},from:{type:`string`,description:`Optional from address override.`},reply_to:{type:`string`,description:`Optional reply-to address.`}},required:[`connection_id`,`to`,`subject`]}}})),U7e,W7e,G7e,K7e=R((()=>{U7e={name:`fetch_url`,description:`Fetch a URL via HTTP and return the response body. Subject to browser CORS restrictions — works with most public APIs. Response is truncated to 100KB. Set use_git_auth to true to automatically inject the saved Git PAT as an Authorization header (supports GitHub, Azure DevOps, GitLab, and other providers — auth format is auto-detected from the URL's host). If include_headers is true, the response will include both request and response headers.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`The URL to fetch`},method:{type:`string`,description:`HTTP method (default: GET)`},headers:{type:`object`,properties:{},description:`Request headers as key-value pairs`},body:{type:`string`,description:`Request body (for POST/PUT/PATCH)`},use_git_auth:{type:`boolean`,description:`If true, inject the saved Git credentials as an Authorization header. Auth format is auto-detected from the URL host: GitHub (token), Azure DevOps (Basic), GitLab (Bearer), or generic Bearer.`},git_account_id:{type:`string`,description:`Optional explicit Git account ID to use when use_git_auth is true. If omitted, account resolution uses hostPattern/default matching.`},use_account_auth:{type:`boolean`,description:`If true, inject a saved service account PAT as a Bearer Authorization header. The account is matched by hostPattern against the URL (longest match wins), then falls back to the default service account. Use this for non-Git services like Figma, Notion, or any other service whose PAT is stored under Settings → Accounts.`},account_id:{type:`string`,description:`Optional explicit service account ID to use when use_account_auth is true. If omitted, account resolution uses hostPattern/default matching.`},auth_mode:{type:`string`,enum:[`pat`,`oauth`],description:`Optional preferred credential mode when multiple accounts match. Valid values: pat or oauth.`},include_headers:{type:`boolean`,description:`If true, include request and response headers in the output.`}},required:[`url`]}},W7e={name:`fetch_file`,description:`Fetch a URL and save the response body directly to the workspace in one step. Equivalent to fetch_url + write_file but atomic. Text responses are saved as UTF-8; binary responses (images, PDFs, audio, video, zip, application/octet-stream) are saved as raw bytes. The destination path within the workspace is required. Supports the same authentication options as fetch_url (use_git_auth, use_account_auth, etc.). Returns the workspace path the file was saved to and the number of bytes written.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`The URL to fetch`},path:{type:`string`,description:`Destination path within the workspace (e.g. 'data/response.json'). Parent directories are created automatically. Must not contain '..' segments.`},method:{type:`string`,description:`HTTP method (default: GET)`},headers:{type:`object`,properties:{},description:`Request headers as key-value pairs`},body:{type:`string`,description:`Request body (for POST/PUT/PATCH)`},use_git_auth:{type:`boolean`,description:`If true, inject the saved Git credentials as an Authorization header. Auth format is auto-detected from the URL host: GitHub (token), Azure DevOps (Basic), GitLab (Bearer), or generic Bearer.`},git_account_id:{type:`string`,description:`Optional explicit Git account ID to use when use_git_auth is true. If omitted, account resolution uses hostPattern/default matching.`},use_account_auth:{type:`boolean`,description:`If true, inject a saved service account PAT as a Bearer Authorization header. The account is matched by hostPattern against the URL (longest match wins), then falls back to the default service account.`},account_id:{type:`string`,description:`Optional explicit service account ID to use when use_account_auth is true. If omitted, account resolution uses hostPattern/default matching.`},auth_mode:{type:`string`,enum:[`pat`,`oauth`],description:`Optional preferred credential mode when multiple accounts match. Valid values: pat or oauth.`}},required:[`url`,`path`]}},G7e={name:`web_search`,description:`Perform a web search using a search engine to discover information. Returns a plain-text summary of the top search results including titles, URLs, and snippets. Use this when you need to find information but don't know the exact URL to fetch.`,input_schema:{type:`object`,properties:{query:{type:`string`,description:`The search query to look up.`}},required:[`query`]}}})),q7e,J7e=R((()=>{q7e={name:`javascript`,description:`Execute JavaScript code in a sandboxed Worker and return the result. Lighter than bash — no VM boot required. Use for calculations, data transformations, JSON processing, string analysis, etc. Runs in strict mode. No access to DOM, eval(), Function(), self, postMessage, importScripts, navigator, or indexedDB — these are all undefined. fetch availability is controlled by Tool Configuration -> Internet Access (shared with bash). setTimeout is available but setInterval is blocked. IMPORTANT: You CANNOT call other agent tools (like read_file, write_file, or bash) from inside this sandbox. If you need to process file contents or tool outputs, you must fetch them in a previous turn and pass the data into this tool via the $PIPE_DATA variable. Write plain JavaScript expressions and statements — the return value of the last expression is captured as the result.`,input_schema:{type:`object`,properties:{code:{type:`string`,description:`JavaScript code to execute. The return value of the last expression is captured.`},data:{type:`string`,description:"Optional input data string. Accessible inside the code sandbox via the global constant `$PIPE_DATA`."}},required:[`code`]}}})),Y7e,X7e,Z7e=R((()=>{Y7e={name:`remote_mcp_list_tools`,description:`List available tools from a configured Remote MCP connection by connection ID or label.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Remote MCP connection ID or label`}},required:[`connection_id`]}},X7e={name:`remote_mcp_call_tool`,description:`Call a tool exposed by a configured Remote MCP connection.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Remote MCP connection ID or label`},tool_name:{type:`string`,description:`Remote MCP tool name`},arguments:{type:`object`,properties:{},description:`Arguments object passed to the remote MCP tool`}},required:[`connection_id`,`tool_name`]}}})),Q7e,$7e,e9e=R((()=>{Q7e={name:`manage_tools`,description:`Enable or disable specific tools, or activate a predefined tool profile. Use list_tool_profiles to see available profiles before activating one. This helps optimize the context window and focus capabilities. Changes take effect on the NEXT turn, not immediately within the current tool-use loop.`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`enable`,`disable`,`activate_profile`],description:`The management action to perform.`},tool_names:{type:`array`,items:{type:`string`},description:`List of tool names to enable or disable. Required for 'enable' and 'disable' actions.`},profile_id:{type:`string`,description:`The unique ID of the tool profile to activate. Required for 'activate_profile' action.`}},required:[`action`]}},$7e={name:`list_tool_profiles`,description:`List all available tool profiles that can be activated using manage_tools. Returns a list of profiles with their IDs, names, and the tools they contain.`,input_schema:{type:`object`,properties:{}}}})),t9e,n9e=R((()=>{t9e={name:`update_memory`,description:`Update the MEMORY.md memory file for this group. Use this to persist important context, user preferences, project state, and anything the agent should remember across conversations. This file is loaded as system context on every invocation.`,input_schema:{type:`object`,properties:{content:{type:`string`,description:`New content for the MEMORY.md memory file`}},required:[`content`]}}})),r9e,i9e,a9e=R((()=>{r9e={name:`show_toast`,description:`Show a toast notification to the user. Toasts are non-blocking, auto-dismissing notifications that appear in the bottom-right corner. Use for: operation status (success/failure), warnings, informational messages, progress updates. Avoid for: critical errors requiring acknowledgment (use clear error messages instead), lengthy content (keep messages concise).`,input_schema:{type:`object`,properties:{message:{type:`string`,description:`The message to display in the toast (keep concise)`},type:{type:`string`,description:`Type of toast: 'success', 'error', 'warning', or 'info' (default: 'info')`,enum:[`success`,`error`,`warning`,`info`]},duration:{type:`number`,description:`Auto-dismiss duration in milliseconds (default: 5000 for info/success, 8000 for warning/error). Set to 0 to disable auto-dismiss.`}},required:[`message`]}},i9e={name:`send_notification`,description:`Send an OS-level push notification to the user via Web Push. Unlike toasts (in-app only), push notifications appear even when the app is not focused or the tab is in the background. Use for: important alerts, long-running task completion, time-sensitive information. Requires the user to have enabled push notifications in Settings.`,input_schema:{type:`object`,properties:{title:{type:`string`,description:`Notification title (default: 'ShadowClaw')`},body:{type:`string`,description:`The notification body text`}},required:[`body`]}}})),o9e,s9e,c9e=R((()=>{o9e=`https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json`,s9e=`A2UI Basic Catalog — Component & Function Reference
3694
3694
  =====================================================
3695
3695
 
3696
3696
  Catalog ID: ${o9e}
@@ -3798,7 +3798,7 @@ actions:
3798
3798
  updateComponents — add or replace components on an existing surface
3799
3799
  updateDataModel — update a single path in the data model (re-renders bound components)
3800
3800
  deleteSurface — remove the surface from the chat`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`],description:`The A2UI operation to perform`},surfaceId:{type:`string`,description:`Unique identifier for this surface. Use a stable ID so you can update it later.`},components:{type:`array`,description:`Flat array of component objects (required for createSurface/updateComponents). Each object MUST have an 'id' field and a 'component' field. The component with id 'root' is the tree root (required for createSurface). Component field values: Text | Row | Column | Button | TextField | Image | Icon | Video | AudioPlayer | List | Card | Tabs | Modal | Divider | CheckBox | ChoicePicker | Slider | DateTimeInput. Put all properties at the TOP LEVEL alongside 'component' and 'id'. DO NOT nest properties under a 'properties' key. Children arrays contain other component ID strings, not nested objects.`,items:{type:`object`,additionalProperties:!0}},dataModel:{type:`object`,description:`Initial data model for the surface (used with createSurface). Components can reference values via { "path": "/key" }.`,properties:{},additionalProperties:!0},path:{type:`string`,description:`JSON Pointer path to update (required for updateDataModel). Examples: "/result", "/user/name", "/count". Use "/" to replace the entire data model.`},value:{type:`string`,description:`New value to set at the specified path (used with updateDataModel). Omit to delete the key at the given path.`},surfaceProperties:{type:`object`,description:`Optional display/branding properties for this surface (e.g. agentDisplayName).`,properties:{},additionalProperties:!0}},required:[`action`,`surfaceId`]}}})),f9e,p9e=R((()=>{f9e={name:`spawn_subagent`,description:`Spawn one or more independent agent loops to work on subtasks in parallel and collect their results. Each subagent has its own tool-use loop, inherits the current API key, and can optionally override provider/model. and runs concurrently with other subagents via Promise.all. Use spawn_subagent when a task has independent parallel workstreams — for example: researching multiple topics simultaneously, processing a list of items in parallel, or delegating isolated subtasks to specialized agents. Do NOT use spawn_subagent for sequential tasks where step 2 depends on step 1's output — just do those steps directly. Do NOT use spawn_subagent for simple single-step work that takes one tool call. Use the parallel_agents field to fan out multiple subagents in a single call.`,input_schema:{type:`object`,properties:{prompt:{type:`string`,description:`The task prompt for a single subagent. Required unless using parallel_agents for multi-agent fan-out.`},tools:{type:`array`,description:`Optional list of tool names to allow in the subagent. If omitted, the subagent inherits the current tool set (minus spawn_subagent to prevent recursion). If provided, only these tools are available to the subagent.`,items:{type:`string`}},profile:{type:`string`,enum:[`current`,`fast`,`smart`,`powerful`],description:`Optional model profile to run the subagent on. Use 'fast' for simple/cheap subtasks (e.g., text formatting, basic search), 'smart' for moderate reasoning, 'powerful' for deep thinking or complex coding, and 'current' to inherit the parent model. Defaults to 'current'.`},workspace_group_id:{type:`string`,description:`Optional workspace group id override for subagent file/tool scope. Use 'parent' to reuse the parent workspace in automatic mode. When omitted, subagents use an isolated workspace by default.`},system_prompt:{type:`string`,description:`Optional system prompt override for the subagent. Defaults to the current system prompt.`},parallel_agents:{type:`array`,description:`Optional list of subagent specifications to run in parallel. When provided, all agents are launched concurrently and their results are combined. Note: There is a configurable maximum limit on parallel subagents (default 5). Each entry can specify a prompt, optional tools list, optional profile, and optional system_prompt.`,items:{type:`object`,properties:{prompt:{type:`string`,description:`The task prompt for this subagent.`},tools:{type:`array`,description:`Optional tool names for this subagent.`,items:{type:`string`}},profile:{type:`string`,enum:[`current`,`fast`,`smart`,`powerful`],description:`Optional model profile for this subagent. Defaults to 'current'.`},workspace_group_id:{type:`string`,description:`Optional workspace group id for this subagent. Use 'parent' for parent workspace in automatic mode.`},system_prompt:{type:`string`,description:`Optional system prompt override for this subagent.`}},required:[`prompt`]}}},required:[`prompt`]}}})),m9e,h9e=R((()=>{m9e={name:`get_current_time`,description:`Get the current date and time. Returns an ISO 8601 string representing the current date and time. Use this tool whenever you need to know the current time, instead of relying on shell tools which may be unavailable.`,input_schema:{type:`object`,properties:{timezone:{type:`string`,description:`Optional timezone to format the time in (e.g. 'America/New_York'). If omitted, returns UTC.`}}}}})),g9e,_9e,v9e,y9e,b9e,x9e,S9e,C9e,w9e,T9e,E9e,D9e,O9e,k9e=R((()=>{g9e={name:`attach_file_to_chat`,description:`Prepare a workspace file for chat delivery by generating an exact markdown attachment snippet. Validates the file path and returns markdown that works for inline image rendering in ShadowClaw and attachment upload in external channels like Telegram/iMessage.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},alt:{type:`string`,description:`Optional alt/caption text to use in the generated markdown`}},required:[`path`]}},_9e={name:`copy_file`,description:`Copy a file or directory in the group workspace to a new destination path. Supports copying single files or nested directories. Optionally supports copying between different conversation workspaces via source_group_id or target_group_id.`,input_schema:{type:`object`,properties:{source_path:{type:`string`,description:`Source file or directory path relative to workspace root`},target_path:{type:`string`,description:`Destination file or directory path relative to workspace root`},source_group_id:{type:`string`,description:`Optional source conversation group ID (defaults to current workspace)`},target_group_id:{type:`string`,description:`Optional target conversation group ID (defaults to current workspace)`}},required:[`source_path`,`target_path`]}},v9e={name:`create_directory`,description:`Create a new directory (and any missing parent directories) in the group workspace.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Directory path relative to the group workspace root`}},required:[`path`]}},y9e={name:`delete_file`,description:`Delete a file or directory from the group workspace. If the target path is a directory, it will be recursively deleted.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File or directory path relative to the group workspace root`}},required:[`path`]}},b9e={name:`diff_files`,description:`Compare two files in the workspace and output the differences. Useful for comparing generated code, checking before patching, or finding changes outside of git repositories.`,input_schema:{type:`object`,properties:{path_a:{type:`string`,description:`Path to the first file relative to the group workspace root.`},path_b:{type:`string`,description:`Path to the second file relative to the group workspace root.`}},required:[`path_a`,`path_b`]}},x9e={name:`list_files`,description:`List files and directories in the group workspace. Directory names end with /. Returns sorted entries.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Directory path relative to workspace root (default: root)`}}}},S9e={name:`move_file`,description:`Move or rename a file or directory in the group workspace to a target path. Supports moving single files or nested directories. Optionally supports moving between different conversation workspaces via source_group_id or target_group_id.`,input_schema:{type:`object`,properties:{source_path:{type:`string`,description:`Source file or directory path relative to workspace root`},target_path:{type:`string`,description:`Destination file or directory path relative to workspace root`},source_group_id:{type:`string`,description:`Optional source conversation group ID (defaults to current workspace)`},target_group_id:{type:`string`,description:`Optional target conversation group ID (defaults to current workspace)`}},required:[`source_path`,`target_path`]}},C9e={name:`open_file`,description:`Open a file from the group workspace in the UI file viewer dialog. Use this only when the user explicitly asks to inspect a file visually with preview support. Do not use this tool to send or attach files in chat responses.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`}},required:[`path`]}},w9e={name:`patch_file`,description:`Make a targeted text replacement in a file. Finds the single occurrence of old_string and replaces it with new_string. Fails if old_string is not found or matches more than once. Use this instead of write_file when you only need to change part of a file — it is safer and works well with large files. Include enough surrounding context in old_string to make the match unique. IMPORTANT: You must provide 'path', 'old_string', and 'new_string' parameters.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},old_string:{type:`string`,description:`The exact text to find in the file. Must match exactly once. Include 2-3 lines of surrounding context to ensure a unique match.`},new_string:{type:`string`,description:`The replacement text. Can be empty to delete old_string.`}},required:[`path`,`old_string`,`new_string`]}},T9e={name:`read_file`,description:`Read the contents of one or more files from the group workspace. IMPORTANT: You must specify either the 'path' parameter (for a single file) or the 'paths' parameter (an array of file paths for multiple files). When paths is provided, returns all file contents concatenated with --- filename --- headers. Prefer paths to batch reads in a single call. Image files (png, jpg, gif, webp, etc.) are returned as native image content that the model can see directly. Other binary files will be detected and an error returned suggesting alternative tools.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Single file path relative to the group workspace root`},paths:{type:`array`,items:{type:`string`},description:`Array of file paths relative to the group workspace root. Use this to read multiple files in a single tool call.`}}}},E9e={name:`search_files`,description:`Search for a pattern (regex or exact text) in files across the workspace. Useful for finding code references, function definitions, or specific content without needing to rely on a shell environment.`,input_schema:{type:`object`,properties:{pattern:{type:`string`,description:`The text or regular expression to search for.`},path:{type:`string`,description:`Optional directory path to restrict the search to (e.g. 'src/'). Defaults to workspace root.`},file_glob:{type:`string`,description:`Optional simple glob to filter files (e.g. '*.ts'). Supports * as wildcard.`},is_regex:{type:`boolean`,description:`Set to true to parse the pattern as a regular expression.`}},required:[`pattern`]}},D9e={name:`send_file`,description:`Send a workspace file directly to connected peer(s) over the P2P (PeerJS/WebRTC) data channel. Use this when the user is in a peer conversation or room, or specify peer_id to send to a remote peer directly. The file is read from the current workspace and transferred over WebRTC in binary chunks so there is no size limit.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},peer_id:{type:`string`,description:`Optional target PeerJS peer ID (or peer: groupId). If omitted, sends to the current peer/room conversation.`}},required:[`path`]}},O9e={name:`write_file`,description:`Write content to a file in the group workspace. Creates the file and any intermediate directories if they don't exist. Overwrites the file if it already exists. IMPORTANT: You must provide both the 'path' and 'content' parameters when calling this tool.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},content:{type:`string`,description:`Content to write to the file`}},required:[`path`,`content`]}}})),A9e,j9e,M9e,N9e,P9e,F9e,I9e,L9e,R9e,z9e,B9e,V9e,H9e,U9e,W9e,G9e,K9e,q9e,J9e,Y9e,X9e,Z9e,Q9e,$9e,eet=R((()=>{A9e={name:`git_add`,description:`Stage files in a cloned repo. Accepts an array of filepaths. If omitted or empty, stages the repo root.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},filepaths:{type:`array`,items:{type:`string`},description:`Array of file paths to stage (relative to repo root). Pass a single item for one file.`}},required:[`repo`]}},j9e={name:`git_branch`,description:`Create a new branch in a cloned repo. Optionally switch to it immediately (like git checkout -b).`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (returned by git_clone)`},name:{type:`string`,description:`Name for the new branch`},checkout:{type:`boolean`,description:`Switch to the new branch after creating it (default: false)`},start_point:{type:`string`,description:`Branch, tag, or commit SHA to branch from (default: HEAD)`}},required:[`repo`,`name`]}},M9e={name:`git_branches`,description:`List branches in a cloned repo. Current branch is marked with *.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},remote:{type:`boolean`,description:`List remote-tracking branches instead (default: false)`}},required:[`repo`]}},N9e={name:`git_checkout`,description:`Checkout a branch, tag, or commit SHA in a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (returned by git_clone)`},ref:{type:`string`,description:`Branch name, tag, or commit SHA to checkout`}},required:[`repo`,`ref`]}},P9e={name:`git_clone`,description:`Clone a git repository into browser-persistent OPFS storage. Files are stored directly under repos/<repo-name>/ in the workspace and are immediately accessible to other git_* tools without any extra sync step. Works with public and private repos (GitHub, GitLab, GitHub Enterprise, etc.). If a Git PAT is configured in Settings, it is used automatically for authentication. Uses a CORS proxy. Returns the short repo name used for subsequent git_* operations.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`Full HTTPS repo URL (e.g. https://github.com/user/repo)`},name:{type:`string`,description:`Optional short repo name to use for the clone directory; defaults to the repository name parsed from the URL.`},branch:{type:`string`,description:`Branch to clone (default: default branch)`},depth:{type:`number`,description:`Shallow clone depth (default: 20)`}},required:[`url`]}},F9e={name:`git_commit`,description:`Stage all changes and create a commit in a cloned repo. Uses configured git author name/email or defaults.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},message:{type:`string`,description:`Commit message`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`,`message`]}},I9e={name:`git_config`,description:`Get or set a git config value for a repo (e.g. user.name, user.email). Persistent per-repo identity avoids specifying author on every commit.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},command:{type:`string`,enum:[`get`,`set`],description:`Operation: get or set a config value`},key:{type:`string`,description:`Config key path (e.g. user.name, user.email, core.autocrlf)`},value:{type:`string`,description:`Value to set — required when command is set`}},required:[`repo`,`command`,`key`]}},L9e={name:`git_delete_branch`,description:`Delete a local branch from a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},name:{type:`string`,description:`Name of the branch to delete`}},required:[`repo`,`name`]}},R9e={name:`git_delete_repo`,description:"Delete the git metadata for a cloned repository while leaving the working tree files in place. Use this to clean up corrupted or stale repos that fail to re-clone. The repo directory remains under repos/<repo>, but the `.git/` metadata is removed.",input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (as returned by git_clone or git_list_repos)`}},required:[`repo`]}},z9e={name:`git_diff`,description:`Show changed files between HEAD and working tree, or between two refs.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref1:{type:`string`,description:`First ref (default: HEAD)`},ref2:{type:`string`,description:`Second ref (if omitted, diffs HEAD vs workdir)`}},required:[`repo`]}},B9e={name:`git_fetch`,description:`Fetch commits from the remote without merging. Safe for inspecting remote state before deciding to merge or rebase.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Remote branch to fetch (default: default branch)`},remote:{type:`string`,description:`Remote name (default: origin)`}},required:[`repo`]}},V9e={name:`git_init`,description:`Initialize a new empty git repository in browser storage. Use this to create a new project from scratch before using git_push to push to a remote.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short name for the new repo (used for all subsequent git_ operations)`}},required:[`repo`]}},H9e={name:`git_list_repos`,description:`List all git repositories currently cloned in browser storage.`,input_schema:{type:`object`,properties:{}}},U9e={name:`git_log`,description:`Show the commit log for a cloned repo. Returns commit SHA, date, author, and message.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Ref to log from (default: HEAD)`},depth:{type:`number`,description:`Number of commits to show (default: 10)`}},required:[`repo`]}},W9e={name:`git_merge`,description:`Merge a branch or ref into the current branch. Supports fast-forward and three-way merges. If the merge has conflicts, a detailed report is returned with the conflicted files and their conflict regions inline. To resolve: use read_file on each conflicted file, then write_file with the complete resolved content (no conflict markers). After all files are resolved, use git_add for each, then git_commit. Do NOT use bash/sed for conflict resolution.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},theirs:{type:`string`,description:`Branch name, tag, or commit SHA to merge into the current branch`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`,`theirs`]}},G9e={name:`git_pull`,description:`Fetch and merge commits from the remote repository. Uses configured git author name/email for merge commits if needed.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Branch to pull (default: current branch)`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`]}},K9e={name:`git_push`,description:`Push commits to the remote repository. Requires a GitHub personal access token (PAT) to be configured. The token is loaded from the encrypted credential store.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Local branch to push (default: current branch)`},remote_ref:{type:`string`,description:`Remote branch name to push to, if different from local branch. Example: push local 'feature-rebased' to remote 'feature/original'.`},force:{type:`boolean`,description:`Force push (default: false)`},tags:{type:`boolean`,description:`Also push all local tags to the remote (default: false)`}},required:[`repo`]}},q9e={name:`git_read_file_at_ref`,description:`Read a file's contents at a specific ref (branch, tag, or commit SHA) without checking it out. Useful for code review across branches.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Branch name, tag, or commit SHA`},filepath:{type:`string`,description:`File path relative to the repo root`}},required:[`repo`,`ref`,`filepath`]}},J9e={name:`git_remote`,description:`Manage git remotes: list, add, or remove a remote in a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},command:{type:`string`,enum:[`list`,`add`,`remove`],description:`Operation to perform`},remote:{type:`string`,description:`Remote name (e.g. origin, upstream) — required for add/remove`},url:{type:`string`,description:`Remote URL — required for add`}},required:[`repo`,`command`]}},Y9e={name:`git_reset`,description:`Reset the current branch HEAD to a specific ref or commit SHA. Updates the branch pointer and checks out the target, discarding local changes. Equivalent to 'git reset --hard <ref>'.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Branch name, tag, or commit SHA to reset to`}},required:[`repo`,`ref`]}},X9e={name:`git_show`,description:`Show the metadata and diff of a specific commit. Returns author, date, message, and a unified diff against the parent commit.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Commit SHA, branch, or tag to inspect (default: HEAD)`}},required:[`repo`,`ref`]}},Z9e={name:`git_status`,description:`Show the working tree status of a cloned repo. Reports modified, added, deleted, and unstaged files.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`}},required:[`repo`]}},Q9e={name:`git_tag`,description:`Create a lightweight or annotated tag at HEAD. Use git_push with tags=true to push tags to the remote.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},tag:{type:`string`,description:`Tag name (e.g. v1.2.3)`},message:{type:`string`,description:`Annotation message — if provided, creates an annotated tag; otherwise lightweight`},author_name:{type:`string`,description:`Tagger name (optional, uses configured default)`},author_email:{type:`string`,description:`Tagger email (optional, uses configured default)`}},required:[`repo`,`tag`]}},$9e={name:`git_unstage`,description:`Remove one or more staged files from the index without touching the working tree. The inverse of git_add — use to undo accidental staging.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},filepath:{type:`string`,description:`File path or array of file paths to unstage (relative to repo root)`}},required:[`repo`,`filepath`]}}})),tet,net,ret,iet,aet,oet,set,cet=R((()=>{tet={name:`create_task`,description:`Create a scheduled recurring task. The task will run automatically on the specified schedule and send the result back to this group. Uses cron expressions (minute hour day-of-month month day-of-week).`,input_schema:{type:`object`,properties:{schedule:{type:`string`,description:`Cron expression, e.g. "0 9 * * 1-5" for 9am weekdays`},prompt:{type:`string`,description:`The prompt/instruction to execute on each run (used if type is 'prompt')`},type:{type:`string`,enum:[`prompt`,`tools`],description:`The type of task to create. Defaults to 'prompt'.`},tools:{type:`array`,description:`A list of tools to execute sequentially (used if type is 'tools')`,items:{type:`object`,properties:{name:{type:`string`},input:{type:`object`}},required:[`name`,`input`]}},name:{type:`string`,description:`The optional title/name for the task, helping to identify its purpose.`}},required:[`prompt`,`type`]}},net={name:`list_tasks`,description:`List all scheduled recurring tasks for this group. Returns a list of tasks with their IDs, schedules, and prompts.`,input_schema:{type:`object`,properties:{}}},ret={name:`update_task`,description:`Update an existing scheduled task's schedule or prompt.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to update`},schedule:{type:`string`,description:`Standard cron expression (e.g. '0 9 * * *'). Leave empty for an unscheduled task.`},prompt:{type:`string`,description:`New prompt/instruction (optional)`},type:{type:`string`,enum:[`prompt`,`tools`],description:`New task type (optional)`},tools:{type:`array`,description:`New list of tools (optional)`,items:{type:`object`,properties:{name:{type:`string`},input:{type:`object`}},required:[`name`,`input`]}},enabled:{type:`boolean`,description:`Whether the task is enabled (optional)`},name:{type:`string`,description:`New name/title for the task (optional).`}},required:[`id`]}},iet={name:`delete_task`,description:`Delete a scheduled task by its ID.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to delete`}},required:[`id`]}},aet={name:`enable_task`,description:`Enable a scheduled task so it runs on its schedule.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to enable`}},required:[`id`]}},oet={name:`disable_task`,description:`Disable a scheduled task so it stops running.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to disable`}},required:[`id`]}},set={name:`run_task`,description:`Immediately trigger a scheduled task by its ID, outside of its normal cron schedule. Use this to manually fire a task on demand. Use list_tasks to find the task ID first.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to run immediately`}},required:[`id`]}}})),uet,det,fet,pet,met=R((()=>{uet={name:`create_room`,description:`Create a new multi-party room (a shared PeerJS conversation) hosted by this device. Other agents or humans can then be invited to participate. Returns the room so you can share or invite peers into it.`,input_schema:{type:`object`,properties:{name:{type:`string`,description:`A human-readable name for the room.`}},required:[`name`]}},det={name:`invite_to_room`,description:`Invite a peer (another agent or human, identified by their PeerJS peer ID) into a room so they can join the shared conversation. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{peer_id:{type:`string`,description:`The PeerJS peer ID of the participant to invite.`},room_id:{type:`string`,description:`The room id to invite into. Defaults to the current room conversation.`}},required:[`peer_id`]}},fet={name:`leave_room`,description:`Leave a room. If you are the host, the room is disbanded for all members. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{room_id:{type:`string`,description:`The room id to leave. Defaults to the current room conversation.`}}}},pet={name:`list_room_members`,description:`List the participants (humans and agents) currently in a room. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{room_id:{type:`string`,description:`The room id to inspect. Defaults to the current room conversation.`}}}}})),het,get,_et,vet,yet,bet,xet=R((()=>{het={name:`summarize_text`,description:`Summarize text using Web Platform's Summarizer API (or polyfill fallback). Produces key points, TLDR, teaser, or headline.`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text content to summarize.`},type:{type:`string`,enum:[`key-points`,`tldr`,`teaser`,`headline`],description:`The summary type (default: key-points).`},format:{type:`string`,enum:[`plain-text`,`markdown`],description:`Output format (default: markdown).`},length:{type:`string`,enum:[`short`,`medium`,`long`],description:`Summary length (default: short).`},preference:{type:`string`,enum:[`capability`,`speed`,`auto`],description:`Summarizer performance preference (default: auto).`},context:{type:`string`,description:`Optional background context for summarization.`},outputLanguage:{type:`string`,description:`Optional target language code (e.g. 'en', 'es').`},sharedContext:{type:`string`,description:`Optional shared context passed to the underlying model.`},overridePrompt:{type:`string`,description:`Optional custom system prompt overriding default summarization instructions.`}},required:[`text`]}},get={name:`write_text`,description:`Generate or draft text using Web Platform's Writer API (or polyfill fallback).`,input_schema:{type:`object`,properties:{prompt:{type:`string`,description:`The prompt or writing instructions.`},tone:{type:`string`,enum:[`formal`,`neutral`,`casual`],description:`Tone for drafting (default: neutral).`},format:{type:`string`,enum:[`plain-text`,`markdown`],description:`Output format (default: plain-text).`},length:{type:`string`,enum:[`short`,`medium`,`long`],description:`Target length (default: short).`},context:{type:`string`,description:`Optional background context for writing.`},outputLanguage:{type:`string`,description:`Optional target language code (e.g. 'en', 'es').`},sharedContext:{type:`string`,description:`Optional shared context passed to the underlying model.`}},required:[`prompt`]}},_et={name:`rewrite_text`,description:`Rewrite or rephrase text using Web Platform's Rewriter API (or polyfill fallback). Can adjust tone or length.`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to rewrite.`},tone:{type:`string`,enum:[`as-is`,`more-formal`,`more-casual`],description:`Tone adjustment (default: as-is).`},format:{type:`string`,enum:[`as-is`,`plain-text`,`markdown`],description:`Format adjustment (default: as-is).`},length:{type:`string`,enum:[`as-is`,`shorter`,`longer`],description:`Length adjustment (default: as-is).`},context:{type:`string`,description:`Optional background context for rewriting.`},outputLanguage:{type:`string`,description:`Optional target language code (e.g. 'en', 'es').`},sharedContext:{type:`string`,description:`Optional shared context passed to the underlying model.`}},required:[`text`]}},vet={name:`proofread_text`,description:`Proofread and correct grammar, spelling, and phrasing errors using Web Platform's Proofreader API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to proofread.`},context:{type:`string`,description:`Optional background context for proofreading.`}},required:[`text`]}},yet={name:`detect_language`,description:`Detect the language of input text using Web Platform's Language Detector API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to analyze for language detection.`}},required:[`text`]}},bet={name:`translate_text`,description:`Translate text using Web Platform's Translator API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to translate.`},sourceLanguage:{type:`string`,description:`Source language BCP 47 code (e.g. 'en', 'es', 'ja').`},targetLanguage:{type:`string`,description:`Target language BCP 47 code (e.g. 'en', 'es', 'ja').`}},required:[`text`,`sourceLanguage`,`targetLanguage`]}}})),Cet,wet,Tet=R((()=>{Cet={name:`prompt_peer`,description:`Send a prompt or message directly to another connected ShadowClaw peer or agent over WebRTC, triggering their orchestration loop and returning their answer. Use this to ask another agent to perform a task, answer a question, or analyze data.`,input_schema:{type:`object`,properties:{peer_id:{type:`string`,description:`The PeerJS peer ID or client ID of the target agent to prompt.`},prompt:{type:`string`,description:`The prompt, question, or instruction for the peer agent.`},timeout_seconds:{type:`number`,description:`Optional timeout in seconds to wait for the peer agent's response (default: 120).`}},required:[`peer_id`,`prompt`]}},wet={name:`list_peers`,description:`List the currently connected peers or clients available over WebRTC and the control plane. Returns peer IDs and device labels so you know which peers you can prompt or collaborate with.`,input_schema:{type:`object`,properties:{}}}})),Eet,Det=R((()=>{Eet={name:`activate_skill`,description:`Load the full instructions for a workspace skill when its description matches the current task.`,input_schema:{type:`object`,properties:{name:{type:`string`,description:`The exact skill name from the available skills catalog.`}},required:[`name`]}}})),Oet=/* @__PURE__ */ mt({TOOL_DEFINITIONS:()=>PO,activate_skill:()=>Eet,list_peers:()=>wet,prompt_peer:()=>Cet}),PO,ket=R((()=>{F7e(),R7e(),H7e(),K7e(),J7e(),Z7e(),e9e(),n9e(),a9e(),d9e(),p9e(),h9e(),k9e(),eet(),cet(),met(),xet(),Tet(),Det(),PO=[L7e,g9e,P7e,I7e,_9e,v9e,uet,tet,y9e,iet,yet,b9e,oet,B7e,V7e,aet,W7e,U7e,m9e,A9e,j9e,M9e,N9e,P9e,F9e,I9e,L9e,R9e,z9e,B9e,V9e,H9e,U9e,W9e,G9e,K9e,q9e,J9e,Y9e,X9e,Z9e,Q9e,$9e,det,q7e,fet,l9e,x9e,wet,pet,net,$7e,z7e,Q7e,S9e,C9e,w9e,Cet,vet,T9e,X7e,Y7e,u9e,_et,set,E9e,D9e,i9e,r9e,f9e,het,bet,t9e,ret,G7e,O9e,get]})),FO=R((()=>{ket()})),IO,LO=R((()=>{IO={id:`__builtin_default`,name:`Default`,providerId:`prompt_api`,enabledToolNames:[`javascript`,`list_files`,`open_file`,`read_file`,`write_file`],customTools:[],systemPromptOverride:"You are a helpful coding assistant.\nContent intended to be rendered as a `Page` (HTML or Markdown) SHOULD include frontmatter (title, created, updated, and slug).\nHTML content intended to be rendered as a `Page` SHOULD USE `<article><h2>${subTitle}</h2>...</article>` for its main body content."}}));function Aet(e,t){if(!t||typeof t!=`object`)throw Error(`Tool at ${e} must be a JSON object`);let n=t,r=typeof n.name==`string`?n.name.trim():``,i=typeof n.description==`string`?n.description.trim():``,a=n.input_schema??n.parameters,o=n.execution??n.evaluation;if(!zO.test(r))throw Error(`Tool name is invalid: ${r||`(missing)`}`);if(!i)throw Error(`Tool ${r} requires a description`);if(!a||typeof a!=`object`)throw Error(`Tool ${r} requires input_schema`);if(!o||typeof o!=`object`)throw Error(`Tool ${r} requires execution`);let s=o,c=s.type;if(c!==`bash`&&c!==`javascript`&&c!==`tool`)throw Error(`Tool ${r} execution type must be bash, javascript, or tool`);if(c===`tool`){if(typeof s.name!=`string`||!zO.test(s.name))throw Error(`Tool ${r} execution requires a valid tool name`);return{name:r,description:i,input_schema:a,execution:{type:c,name:s.name,...s.input&&typeof s.input==`object`?{input:s.input}:{}},path:e}}let l=c===`bash`?`command`:`code`,u=s[l]??s.expression;if(typeof u!=`string`||u.trim()===``)throw Error(`Tool ${r} execution requires ${l}`);return{name:r,description:i,input_schema:a,execution:{type:c,[l]:u},path:e}}async function RO(e,t=fn){let n=[],r=[],i=Np()||t===`br:main`?[t]:[t,fn];for(let t of i)try{let i=await Lp(e,t),a=[];async function o(e,t){for await(let[n,r]of e.entries()){let e=`${t}/${n}`;r.kind===`directory`?await o(r,e):n.endsWith(`.json`)&&e.startsWith(`.agents/tools/`)&&a.push(e)}}try{await o(await(await i.getDirectoryHandle(`.agents`)).getDirectoryHandle(`tools`),`.agents/tools`)}catch{continue}let s=a.sort((e,t)=>{let n=!e.startsWith(`.agents/tools/main/`);return n===!t.startsWith(`.agents/tools/main/`)?e.localeCompare(t):n?-1:1});for(let i of s)try{let r=Aet(i,JSON.parse(await Vp(e,t,i)));n.some(e=>e.name===r.name)||n.push(r)}catch(e){r.push(e instanceof Error?e.message:String(e))}}catch{}return{tools:n,diagnostics:r}}async function jet(e,t=fn,n){try{let{tools:r}=await RO(e,t),i=r.find(e=>e.name===n)||null;if(!i)return null;let a=await ba(e,V.DECLARATIVE_TOOLS_ENABLED);return Array.isArray(a)&&!a.includes(n)?null:i}catch{return null}}var zO,BO=R((()=>{Mn(),Ip(),xa(),Rp(),Hp(),zO=/^[a-z][a-z0-9_]{0,63}$/}));async function Met(e){if(typeof e==`string`)return new TextEncoder().encode(e).buffer;if(typeof Blob<`u`&&e instanceof Blob)return e.arrayBuffer();if(e instanceof ArrayBuffer)return e.slice(0);if(ArrayBuffer.isView(e)){let{buffer:t,byteOffset:n,byteLength:r}=e;return t.slice(n,n+r)}return/* @__PURE__ */ new ArrayBuffer(0)}function Net(e){return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function Pet(e){let t=await Met(e),r=globalThis.crypto?.subtle??globalThis.window?.crypto?.subtle??(n===void 0?void 0:(await import(`node:crypto`)).webcrypto?.subtle);if(!r)throw Error(`crypto.subtle is not available in current environment`);return Net(await r.digest(`SHA-256`,t))}var Fet=R((()=>{})),Iet=/* @__PURE__ */ mt({fetchDiscoveryManifest:()=>KO,parseGitHubRepoSource:()=>Let,resolveDiscoveryUrl:()=>VO,resolveManifestRelativeUrl:()=>HO,resolveManifestUrls:()=>UO,verifySha256Digest:()=>WO});function Let(e){let t=e.trim().replace(/\/+$/,``);if(!t)return null;let n=t.match(/^https?:\/\/github\.com\/([a-zA-Z0-9_.-]+)\/([a-zA-Z0-9_.-]+?)(?:\.git)?(?:\/tree\/([^/]+)(?:\/(.+))?)?(?:@([a-zA-Z0-9_.-]+))?$/i);if(n)return{owner:n[1],repo:n[2],ref:n[3]||`HEAD`,subpath:n[4],skillFilter:n[5]};if(!t.includes(`://`)){let e=t.match(/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+?)(?:@([a-zA-Z0-9_.-]+))?$/);if(e&&!e[1].includes(`.`))return{owner:e[1],repo:e[2],ref:`HEAD`,skillFilter:e[3]}}return null}function VO(e){let t=e.trim();if(!t)throw Error(`URL cannot be empty`);let n=t;!n.startsWith(`http://`)&&!n.startsWith(`https://`)&&(n=`https://${n}`),n=n.replace(/\/+$/,``);let r=n.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+)\/blob\/([^/]+)\/(.+\/skill\.md)$/i);if(r&&(n=`https://raw.githubusercontent.com/${r[1]}/${r[2]}/${r[3]}/${r[4]}`),/\/skill\.md$/i.test(n)){let e=n.replace(/\/skill\.md$/i,``);return{baseUrl:e,siteUrl:e,manifestUrl:n}}if(n.endsWith(qO)){let e=n.slice(0,-35).replace(/\/+$/,``);return{baseUrl:e,siteUrl:e,manifestUrl:n}}return{baseUrl:n,siteUrl:n,manifestUrl:`${n}/${qO}`}}function HO(e,t){if(!e)return``;try{return new URL(e,t).href}catch{return e}}function UO(e,t){let n=JSON.parse(JSON.stringify(e));return Array.isArray(n.tools)&&(n.tools=n.tools.map(e=>({...e,url:HO(e.url,t)}))),Array.isArray(n.scripts)&&(n.scripts=n.scripts.map(e=>({...e,url:HO(e.url,t)}))),Array.isArray(n.skills)&&(n.skills=n.skills.map(e=>({...e,url:HO(e.url,t),tools:Array.isArray(e.tools)?e.tools.map(e=>({...e,url:e.url?HO(e.url,t):void 0})):void 0,scripts:Array.isArray(e.scripts)?e.scripts.map(e=>({...e,url:e.url?HO(e.url,t):void 0})):void 0}))),n}async function WO(e,t){if(!t||!t.startsWith(`sha256:`))return!0;let n=t.slice(7).trim().toLowerCase();return!n||(await Pet(typeof e==`string`?new TextEncoder().encode(e):e)).toLowerCase()===n}async function GO(e,t,n,r){let i=Wp(e,n),a={name:i.name,type:`skill-md`,description:i.description,url:e,...r&&r.length>0?{files:r}:{}};return{manifest:{name:i.name,description:i.description,skills:[a]},siteUrl:t,manifestUrl:e}}async function Ret(e,t){let n=`https://raw.githubusercontent.com/${e.owner}/${e.repo}/${e.ref}`,r=`https://github.com/${e.owner}/${e.repo}`;if(e.subpath){let r=e.subpath.replace(/^\/+|\/+$/g,``).replace(/\/skill\.md$/i,``),i=`${n}/${r}/SKILL.md`,a=await t(i);if(!a.ok)throw Error(`Failed to fetch discovery manifest: HTTP ${a.status} ${a.statusText||``}`.trim());return GO(i,`${n}/${r}`,await a.text())}if(e.skillFilter){let r=[`skills/${e.skillFilter}/SKILL.md`,`.agents/skills/${e.skillFilter}/SKILL.md`,`.agents/skills/main/${e.skillFilter}/SKILL.md`,`${e.skillFilter}/SKILL.md`];for(let e of r){let r=`${n}/${e}`,i=await t(r);if(i.ok)return GO(r,r.replace(/\/skill\.md$/i,``),await i.text())}throw Error(`Failed to fetch skill "${e.skillFilter}" from ${e.owner}/${e.repo}`)}let i=`${n}/${qO}`;try{let e=await t(i,{headers:{Accept:`application/json`}});if(e.ok){let t=await e.json();if(t&&typeof t==`object`)return{manifest:UO(t,i),siteUrl:n,manifestUrl:i}}}catch{}let a=`https://api.github.com/repos/${e.owner}/${e.repo}/git/trees/${e.ref}?recursive=1`;try{let i=await t(a,{headers:{Accept:`application/vnd.github+json`}});if(i.ok){let o=((await i.json())?.tree||[]).filter(e=>e?.type===`blob`&&typeof e.path==`string`).map(e=>e.path),s=o.filter(e=>e===`SKILL.md`||e.endsWith(`/SKILL.md`));if(s.length>0){let i=[];for(let e of s){let r=e===`SKILL.md`?``:e.slice(0,-9),a=r?`${r}/`:``,s=o.filter(t=>(r?t.startsWith(a):!t.includes(`/`))&&t!==e).map(e=>r?e.slice(a.length):e),c=`${n}/${e}`,l=await t(c);if(!l.ok)continue;let u=await l.text();try{let t=Wp(e,u);i.push({name:t.name,type:`skill-md`,description:t.description,url:c,...s.length>0?{files:[`SKILL.md`,...s]}:{}})}catch{}}if(i.length>0)return{manifest:{name:`${e.owner}/${e.repo}`,description:`Agent skills from ${e.owner}/${e.repo}`,skills:i},siteUrl:r,manifestUrl:a}}}}catch{}let o=`${n}/SKILL.md`,s=await t(o);if(s.ok)return GO(o,n,await s.text());throw Error(`Failed to fetch discovery manifest from GitHub repository ${e.owner}/${e.repo}`)}async function KO(e,t=globalThis.fetch){let n=Let(e);if(n)return Ret(n,t);let{baseUrl:r,manifestUrl:i}=VO(e);if(/\/skill\.md$/i.test(i)){let e=await t(i);if(!e.ok)throw Error(`Failed to fetch discovery manifest: HTTP ${e.status} ${e.statusText}`.trim());return GO(i,r,await e.text())}let a=await t(i,{headers:{Accept:`application/json`}});if(!a.ok)throw Error(`Failed to fetch discovery manifest: HTTP ${a.status} ${a.statusText}`.trim());let o=await a.json();if(!o||typeof o!=`object`)throw Error(`Invalid discovery manifest: expected a JSON object`);return{manifest:UO(o,i),siteUrl:r,manifestUrl:i}}var qO,JO=R((()=>{Fet(),Kp(),qO=`.well-known/agent-skills/index.json`})),zet=/* @__PURE__ */ mt({importRemoteArtifacts:()=>$O,importRemoteScript:()=>ZO,importRemoteSkill:()=>QO,importRemoteTool:()=>XO});function YO(e,t){return t?.targetSubdir?`.agents/${e}/${t.targetSubdir}`:t?.siteSlug?`.agents/${e}/imported/${t.siteSlug}`:`.agents/${e}`}async function XO(e,t=fn,n,r){let i=(n.name||``).trim();if(Bet.has(i))return{name:i,path:``,status:`failed`,error:`Cannot shadow built-in tool: ${i}`};if(!Vet.test(i))return{name:i,path:``,status:`failed`,error:`Invalid tool name: ${i}`};let a=`${YO(`tools`,r)}/${i}.json`;try{if(await UD(e,t,a)&&!r?.overwrite)return{name:i,path:a,status:`skipped`};let o=await(r?.fetchFn||globalThis.fetch)(n.url);if(!o.ok)return{name:i,path:a,status:`failed`,error:`HTTP ${o.status} ${o.statusText}`};let s=await o.text();if(n.digest&&!await WO(s,n.digest))return{name:i,path:a,status:`failed`,error:`Integrity verification failed for tool definition`};let c;try{c=JSON.parse(s)}catch{return{name:i,path:a,status:`failed`,error:`Downloaded tool definition is not valid JSON`}}if(Aet(a,c),await RD(e,t,a,JSON.stringify(c,null,2)),r?.autoEnable){let t=await ba(e,V.DECLARATIVE_TOOLS_ENABLED),n=new Set(Array.isArray(t)?t:[]);n.add(i),await BD(e,V.DECLARATIVE_TOOLS_ENABLED,Array.from(n))}return{name:i,path:a,status:`imported`}}catch(e){return{name:i,path:a,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function ZO(e,t=fn,n,r){let i=(n.name||``).trim(),a=i.endsWith(`.js`)||i.endsWith(`.mjs`)?i:`${i}.js`,o=`${YO(`scripts`,r)}/${a}`;try{if(await UD(e,t,o)&&!r?.overwrite)return{name:i,path:o,status:`skipped`};let a=await(r?.fetchFn||globalThis.fetch)(n.url);if(!a.ok)return{name:i,path:o,status:`failed`,error:`HTTP ${a.status} ${a.statusText}`};let s=await a.text();return n.digest&&!await WO(s,n.digest)?{name:i,path:o,status:`failed`,error:`Integrity verification failed for script`}:(await RD(e,t,o,s),{name:i,path:o,status:`imported`})}catch(e){return{name:i,path:o,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function QO(e,t=fn,n,r){let i=(n.name||``).trim(),a=`${YO(`skills`,r)}/${i}`,o=`${a}/SKILL.md`;try{if(await UD(e,t,o)&&!r?.overwrite)return{name:i,path:o,status:`skipped`};let s=r?.fetchFn||globalThis.fetch,c=await s(n.url);if(!c.ok)return{name:i,path:o,status:`failed`,error:`HTTP ${c.status} ${c.statusText}`};let l=await c.text();if(n.digest&&!await WO(l,n.digest))return{name:i,path:o,status:`failed`,error:`Integrity verification failed for skill`};if(Wp(o,l),await RD(e,t,o,l),Array.isArray(n.files)&&n.files.length>0){let r=n.url.replace(/\/skill\.md$/i,`/`);for(let i of n.files){if(typeof i!=`string`)continue;let n=i.replace(/^\/+/,``).replace(/\\/g,`/`);if(n&&n.toLowerCase()!==`skill.md`&&!n.split(`/`).some(e=>e===`..`||e===`.`))try{let i=new URL(n,r.endsWith(`/`)?r:`${r}/`).href,o=await s(i);if(o.ok){let r=await o.text();await RD(e,t,`${a}/${n}`,r)}}catch{}}}return{name:i,path:o,status:`imported`}}catch(e){return{name:i,path:o,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function $O(e,t=fn,n,r,i){let a={tools:[],skills:[],scripts:[],diagnostics:[]},o=new Set(r.toolNames||[]),s=new Set(r.skillNames||[]),c=new Set(r.scriptNames||[]),l=n.tools||[],u=n.skills||[],d=n.scripts||[];for(let e of u)if(s.has(e.name)){if(Array.isArray(e.tools))for(let t of e.tools)o.add(t.name);if(Array.isArray(e.scripts))for(let t of e.scripts)c.add(t.name)}for(let n of d)if(c.has(n.name)){let r=await ZO(e,t,n,i);a.scripts.push(r),r.status===`failed`&&r.error&&a.diagnostics.push(`Script ${n.name}: ${r.error}`)}for(let n of l)if(o.has(n.name)){let r=await XO(e,t,n,i);a.tools.push(r),r.status===`failed`&&r.error&&a.diagnostics.push(`Tool ${n.name}: ${r.error}`)}for(let n of u)if(s.has(n.name)){let r=await QO(e,t,n,i);a.skills.push(r),r.status===`failed`&&r.error&&a.diagnostics.push(`Skill ${n.name}: ${r.error}`)}return a}var Bet,Vet,ek=R((()=>{Mn(),xa(),VD(),zD(),WD(),BO(),FO(),Kp(),JO(),Bet=new Set(PO.map(e=>e.name)),Vet=/^[a-z][a-z0-9_]{0,63}$/})),Het,tk,nk=R((()=>{O8e(),Mn(),xa(),VD(),FO(),LO(),BO(),JO(),ek(),Het=class{_activeProfile;_activeProfileId;_allTools;_customTools;_declarativeTools;_declarativeToolNamesEnabled;_enabledDeclarativeTools;_enabledToolNames;_enabledTools;_profiles;_systemPromptOverride;_webSearchProxyUrl;_webSearchUrl;_webSearchUseProxy;_searchFilesMaxFileBytes;_searchFilesMaxFilesVisited;_searchFilesSkipDirs;constructor(){this._enabledToolNames=new fO.State(new Set(IO.enabledToolNames)),this._customTools=new fO.State([]),this._declarativeTools=new fO.State([]),this._declarativeToolNamesEnabled=new fO.State(null),this._systemPromptOverride=new fO.State(``),this._profiles=new fO.State([]),this._activeProfileId=new fO.State(IO.id),this._webSearchUseProxy=new fO.State(!1),this._webSearchProxyUrl=new fO.State(`/proxy`),this._webSearchUrl=new fO.State(`https://html.duckduckgo.com/html/?q={query}`),this._searchFilesMaxFileBytes=new fO.State(524288),this._searchFilesMaxFilesVisited=new fO.State(1e3),this._searchFilesSkipDirs=new fO.State(`.git,node_modules,dist,dist-electron,.cache,.nx,.turbo,__pycache__,.venv,venv`),this._allTools=new fO.Computed(()=>[...PO,...this._customTools.get()]),this._enabledTools=new fO.Computed(()=>{let e=this._enabledToolNames.get();return this._allTools.get().filter(t=>e.has(t.name))}),this._enabledDeclarativeTools=new fO.Computed(()=>{let e=this._declarativeTools.get(),t=this._declarativeToolNamesEnabled.get();return!t||t.size===0?[]:e.filter(e=>t.has(e.name))}),this._activeProfile=new fO.Computed(()=>{let e=this._activeProfileId.get();return e?IO.id===e?IO:this._profiles.get().find(t=>t.id===e)||null:null})}get activeProfile(){return this._activeProfile.get()}get activeProfileId(){return this._activeProfileId.get()}get allTools(){return this._allTools.get()}get customTools(){return this._customTools.get()}get declarativeTools(){return this._declarativeTools.get()}get declarativeToolNamesEnabled(){return this._declarativeToolNamesEnabled.get()}get enabledDeclarativeTools(){return this._enabledDeclarativeTools.get()}get enabledToolNames(){return this._enabledToolNames.get()}get enabledTools(){return this._enabledTools.get()}isDeclarativeToolEnabled(e){let t=this._declarativeToolNamesEnabled.get();return t?t.has(e):!1}async refreshDeclarativeTools(e,t){try{let n=await RO(e,t||`br:main`),r=this.allTools,i=(n?.tools||[]).filter(e=>!r.some(t=>t.name===e.name)),a=this._declarativeTools.get();return a.length===i.length&&a.every((e,t)=>e.name===i[t].name&&e.description===i[t].description&&JSON.stringify(e.execution)===JSON.stringify(i[t].execution))||this._declarativeTools.set(i),i}catch{return this._declarativeTools.get().length>0&&this._declarativeTools.set([]),[]}}async setDeclarativeToolEnabled(e,t,n){let r=this._declarativeToolNamesEnabled.get(),i=new Set(r===null?[]:r);n?i.add(t):i.delete(t),this._declarativeToolNamesEnabled.set(i),await BD(e,V.DECLARATIVE_TOOLS_ENABLED,Array.from(i))}async setAllDeclarativeEnabled(e,t){let n=new Set(t);this._declarativeToolNamesEnabled.set(n),await BD(e,V.DECLARATIVE_TOOLS_ENABLED,t)}async fetchRemoteDiscoveryManifest(e){return await KO(e)}async importFromRemoteSite(e,t,n,r){let i=r?.groupId||`br:main`,a=await $O(e,i,t,n,r);return await this.refreshDeclarativeTools(e,i),a}exportBackup(){return JSON.stringify({enabledTools:[...this._enabledToolNames.get()],customTools:this._customTools.get(),declarativeToolsEnabled:this._declarativeToolNamesEnabled.get()?Array.from(this._declarativeToolNamesEnabled.get()):null,systemPromptOverride:this._systemPromptOverride.get(),profiles:this._profiles.get(),activeProfileId:this._activeProfileId.get(),webSearchUseProxy:this._webSearchUseProxy.get(),webSearchProxyUrl:this._webSearchProxyUrl.get(),webSearchUrl:this._webSearchUrl.get(),searchFilesMaxFileBytes:this._searchFilesMaxFileBytes.get(),searchFilesMaxFilesVisited:this._searchFilesMaxFilesVisited.get(),searchFilesSkipDirs:this._searchFilesSkipDirs.get()},null,2)}findProfilesForProvider(e,t){return this.profiles.filter(n=>!(n.providerId&&n.providerId!==e||n.model&&n.model!==t))}get profiles(){return[IO,...this._profiles.get()]}get systemPromptOverride(){return this._systemPromptOverride.get()}get webSearchProxyUrl(){return this._webSearchProxyUrl.get()}get webSearchUrl(){return this._webSearchUrl.get()}get webSearchUseProxy(){return this._webSearchUseProxy.get()}get searchFilesMaxFileBytes(){return this._searchFilesMaxFileBytes.get()}get searchFilesMaxFilesVisited(){return this._searchFilesMaxFilesVisited.get()}get searchFilesSkipDirs(){return this._searchFilesSkipDirs.get()}get searchFilesSkipDirsSet(){return new Set(this._searchFilesSkipDirs.get().split(`,`).map(e=>e.trim()).filter(Boolean))}async activateProfile(e,t){let n=this.profiles.find(e=>e.id===t);n&&(this._activeProfileId.set(t),this._enabledToolNames.set(new Set(n.enabledToolNames)),this._customTools.set(n.customTools),this._systemPromptOverride.set(n.systemPromptOverride||``),await Promise.all([BD(e,V.ACTIVE_TOOL_PROFILE,t),BD(e,V.ENABLED_TOOLS,n.enabledToolNames),BD(e,V.CUSTOM_TOOLS,n.customTools),BD(e,V.SYSTEM_PROMPT_OVERRIDE,n.systemPromptOverride||``)]))}async addCustomTool(e,t){let n=[...this._customTools.get(),t];this._customTools.set(n);let r=new Set(this._enabledToolNames.get());r.add(t.name),this._enabledToolNames.set(r),await Promise.all([BD(e,V.CUSTOM_TOOLS,n),BD(e,V.ENABLED_TOOLS,[...r])])}async addProfile(e,t){let n=[...this._profiles.get(),t];this._profiles.set(n),await BD(e,V.TOOL_PROFILES,n)}async cloneTool(e,t,n,r){let i=this.allTools.find(e=>e.name===t);if(!i||this.allTools.some(e=>e.name===n))return!1;let a={name:n,description:r||i.description,input_schema:JSON.parse(JSON.stringify(i.input_schema))};return await this.addCustomTool(e,a),!0}async deactivateProfile(e){this._activeProfileId.set(null),await BD(e,V.ACTIVE_TOOL_PROFILE,null)}async deleteProfile(e,t){if(t===IO.id)return;let n=this._profiles.get().filter(e=>e.id!==t);this._profiles.set(n),this._activeProfileId.get()===t&&(this._activeProfileId.set(null),await BD(e,V.ACTIVE_TOOL_PROFILE,null)),await BD(e,V.TOOL_PROFILES,n)}async importBackup(e,t){let n=JSON.parse(t);Array.isArray(n.enabledTools)&&(this._enabledToolNames.set(new Set(n.enabledTools)),await BD(e,V.ENABLED_TOOLS,n.enabledTools)),Array.isArray(n.customTools)&&(this._customTools.set(n.customTools),await BD(e,V.CUSTOM_TOOLS,n.customTools)),typeof n.systemPromptOverride==`string`&&(this._systemPromptOverride.set(n.systemPromptOverride),await BD(e,V.SYSTEM_PROMPT_OVERRIDE,n.systemPromptOverride)),Array.isArray(n.profiles)&&(this._profiles.set(n.profiles),await BD(e,V.TOOL_PROFILES,n.profiles)),(typeof n.activeProfileId==`string`||n.activeProfileId===null)&&(this._activeProfileId.set(n.activeProfileId),await BD(e,V.ACTIVE_TOOL_PROFILE,n.activeProfileId)),typeof n.webSearchUseProxy==`boolean`&&(this._webSearchUseProxy.set(n.webSearchUseProxy),await BD(e,V.WEB_SEARCH_USE_PROXY,n.webSearchUseProxy?`true`:`false`)),typeof n.webSearchProxyUrl==`string`&&(this._webSearchProxyUrl.set(n.webSearchProxyUrl),await BD(e,V.WEB_SEARCH_PROXY_URL,n.webSearchProxyUrl)),typeof n.webSearchUrl==`string`&&(this._webSearchUrl.set(n.webSearchUrl),await BD(e,V.WEB_SEARCH_URL,n.webSearchUrl)),typeof n.searchFilesMaxFileBytes==`number`&&n.searchFilesMaxFileBytes>0&&(this._searchFilesMaxFileBytes.set(n.searchFilesMaxFileBytes),await BD(e,V.SEARCH_FILES_MAX_FILE_BYTES,String(n.searchFilesMaxFileBytes))),typeof n.searchFilesMaxFilesVisited==`number`&&n.searchFilesMaxFilesVisited>0&&(this._searchFilesMaxFilesVisited.set(n.searchFilesMaxFilesVisited),await BD(e,V.SEARCH_FILES_MAX_FILES_VISITED,String(n.searchFilesMaxFilesVisited))),typeof n.searchFilesSkipDirs==`string`&&(this._searchFilesSkipDirs.set(n.searchFilesSkipDirs),await BD(e,V.SEARCH_FILES_SKIP_DIRS,n.searchFilesSkipDirs)),Array.isArray(n.declarativeToolsEnabled)?(this._declarativeToolNamesEnabled.set(new Set(n.declarativeToolsEnabled)),await BD(e,V.DECLARATIVE_TOOLS_ENABLED,n.declarativeToolsEnabled)):n.declarativeToolsEnabled===null&&(this._declarativeToolNamesEnabled.set(null),await BD(e,V.DECLARATIVE_TOOLS_ENABLED,null))}async load(e){let[t,n,r,i,a,o,s,c,l,u,d,f]=await Promise.all([ba(e,V.ENABLED_TOOLS),ba(e,V.CUSTOM_TOOLS),ba(e,V.SYSTEM_PROMPT_OVERRIDE),ba(e,V.TOOL_PROFILES),ba(e,V.ACTIVE_TOOL_PROFILE),ba(e,V.WEB_SEARCH_USE_PROXY),ba(e,V.WEB_SEARCH_PROXY_URL),ba(e,V.WEB_SEARCH_URL),ba(e,V.SEARCH_FILES_MAX_FILE_BYTES),ba(e,V.SEARCH_FILES_MAX_FILES_VISITED),ba(e,V.SEARCH_FILES_SKIP_DIRS),ba(e,V.DECLARATIVE_TOOLS_ENABLED)]);if(Array.isArray(t)&&this._enabledToolNames.set(new Set(t)),Array.isArray(n)&&this._customTools.set(n),Array.isArray(f)&&this._declarativeToolNamesEnabled.set(new Set(f)),typeof r==`string`&&this._systemPromptOverride.set(r),Array.isArray(i)&&this._profiles.set(i),typeof a==`string`&&this._activeProfileId.set(a),o!=null){let e=String(o).toLowerCase();this._webSearchUseProxy.set(e===`true`||e===`1`)}if(typeof s==`string`&&s.trim().length>0&&this._webSearchProxyUrl.set(s.trim()),typeof c==`string`&&c.trim().length>0&&this._webSearchUrl.set(c.trim()),l!=null){let e=Number(l);Number.isFinite(e)&&e>0&&this._searchFilesMaxFileBytes.set(e)}if(u!=null){let e=Number(u);Number.isFinite(e)&&e>0&&this._searchFilesMaxFilesVisited.set(e)}typeof d==`string`&&d.trim().length>0&&this._searchFilesSkipDirs.set(d.trim())}async setWebSearchProxyUrl(e,t){let n=t.trim()||`/proxy`;this._webSearchProxyUrl.set(n),await BD(e,V.WEB_SEARCH_PROXY_URL,n)}async setWebSearchUrl(e,t){let n=t.trim()||`https://html.duckduckgo.com/html/?q={query}`;this._webSearchUrl.set(n),await BD(e,V.WEB_SEARCH_URL,n)}async setWebSearchUseProxy(e,t){let n=!!t;this._webSearchUseProxy.set(n),await BD(e,V.WEB_SEARCH_USE_PROXY,n?`true`:`false`)}async setSearchFilesMaxFileBytes(e,t){let n=Math.max(1,Math.round(t));this._searchFilesMaxFileBytes.set(n),await BD(e,V.SEARCH_FILES_MAX_FILE_BYTES,String(n))}async setSearchFilesMaxFilesVisited(e,t){let n=Math.max(1,Math.round(t));this._searchFilesMaxFilesVisited.set(n),await BD(e,V.SEARCH_FILES_MAX_FILES_VISITED,String(n))}async setSearchFilesSkipDirs(e,t){let n=t.trim();this._searchFilesSkipDirs.set(n),await BD(e,V.SEARCH_FILES_SKIP_DIRS,n)}async removeCustomTool(e,t){let n=this._customTools.get().filter(e=>e.name!==t);this._customTools.set(n);let r=new Set(this._enabledToolNames.get());r.delete(t),this._enabledToolNames.set(r),await Promise.all([BD(e,V.CUSTOM_TOOLS,n),BD(e,V.ENABLED_TOOLS,[...r])])}async saveToActiveProfile(e){let t=this._activeProfileId.get();if(!t)return;let n=this._profiles.get().find(e=>e.id===t);if(!n)return;let r={...n,enabledToolNames:[...this._enabledToolNames.get()],customTools:[...this._customTools.get()],systemPromptOverride:this._systemPromptOverride.get()};await this.updateProfile(e,r)}async setAllEnabled(e,t){this._enabledToolNames.set(new Set(t));let n=[BD(e,V.ENABLED_TOOLS,t)];this._activeProfileId.get()&&(this._activeProfileId.set(null),n.push(BD(e,V.ACTIVE_TOOL_PROFILE,null))),await Promise.all(n)}async setSystemPromptOverride(e,t){this._systemPromptOverride.set(t),await BD(e,V.SYSTEM_PROMPT_OVERRIDE,t)}async setToolEnabled(e,t,n){let r=new Set(this._enabledToolNames.get());n?r.add(t):r.delete(t),this._enabledToolNames.set(r);let i=[BD(e,V.ENABLED_TOOLS,[...r])];this._activeProfileId.get()&&(this._activeProfileId.set(null),i.push(BD(e,V.ACTIVE_TOOL_PROFILE,null))),await Promise.all(i)}async updateProfile(e,t){let n=this._profiles.get().map(e=>e.id===t.id?t:e);this._profiles.set(n),await BD(e,V.TOOL_PROFILES,n)}},tk=new Het}));function Uet(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}var Wet=R((()=>{Mn()}));function Get(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 Ket(e){return e?e.startsWith(`text/`)||e===`json`||e===`xml`||e===`javascript`||e===`csv`||e===`markdown`:!1}function qet(e){let t=Get(e);if(t===0)return 0;switch(e.mediaType){case`image`:return Yet;case`audio`:return Xet;case`video`:return Zet;default:return Ket(e.mimeType)?Math.ceil(t/ak):Math.ceil(t/Qet)}}function rk(e){return e?Math.ceil(e.length/ak):0}function ik(e){let t=0;if(typeof e.content==`string`)t=rk(e.content);else if(Array.isArray(e.content))for(let n of e.content)if(n.type===`text`&&n.text)t+=rk(n.text);else if(n.type===`tool_use`)t+=rk(n.name),t+=rk(JSON.stringify(n.input));else if(n.type===`tool_result`){let e=n.content;t+=rk(typeof e==`string`?e:JSON.stringify(e))}else n.type===`attachment`&&(t+=rk(n.fileName),t+=rk(n.mimeType),t+=rk(n.path),t+=qet(n));return t+Jet}var ak,Jet,Yet,Xet,Zet,Qet,ok=R((()=>{ak=4,Jet=4,Yet=1500,Xet=1500,Zet=2500,Qet=16}));function $et(e,t){if(!e)return``;if(e.length<=t)return e;let n=e.slice(0,t).lastIndexOf(`
3801
- `),r=n>t*.5?n:t;return`${e.slice(0,r)}\n[...truncated ${e.length-r} chars]`}var ett=R((()=>{}));function ttt(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(rtt,Math.max(1e3,Math.floor(o*.6*4))),c=e.map(e=>ntt(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=ik(e),f<=o&&(d=e))}let p=o-f;for(let e=c.length-1;e>=+!!d;e--){let t=ik(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+=ik(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 ntt(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:$et(e.content,t)}:e);return{...e,content:n}}var rtt,itt=R((()=>{ok(),ett(),rtt=25e3}));function att(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)}function ott(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var stt=R((()=>{}));function sk(e){return e&&(e.split(/[?#]/,1)[0].replace(/\\/g,`/`).split(`/`).pop()||``).toLowerCase().split(`.`).pop()||``}function ck(e,t){let n=sk(e);return utt[n]??t}function lk(e){let t=sk(e);return dk[t]||null}function ctt(e){return lk(e)!==null}function ltt(e){let t=sk(e);if(t===`md`||t===`markdown`||t===`txt`)return`text/plain`;if(t===`pdf`)return`application/pdf`;if(dk[t])return dk[t]}function uk(e,t=``){return t||ck(e,`application/octet-stream`)}var dk,utt,fk=R((()=>{dk={apng:`image/apng`,avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,heic:`image/heic`,heif:`image/heif`,ico:`image/x-icon`,jpeg:`image/jpeg`,jpg:`image/jpeg`,png:`image/png`,svg:`image/svg+xml`,tif:`image/tiff`,tiff:`image/tiff`,webp:`image/webp`},utt={...dk,"3gp":`video/3gpp`,aac:`audio/aac`,avi:`video/x-msvideo`,bin:`application/octet-stream`,css:`text/css`,csv:`text/csv`,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`,gz:`application/gzip`,htm:`text/html`,html:`text/html`,iso:`application/octet-stream`,js:`text/javascript`,json:`application/json`,m4a:`audio/mp4`,m4v:`video/mp4`,markdown:`text/markdown`,md:`text/markdown`,mjs:`text/javascript`,mkv:`video/x-matroska`,mov:`video/mp4`,mp3:`audio/mpeg`,mp4:`video/mp4`,oga:`audio/ogg`,ogg:`audio/ogg`,ogv:`video/ogg`,pdf:`application/pdf`,rar:`application/vnd.rar`,so:`application/octet-stream`,sqlite:`application/vnd.sqlite3`,sqlite3:`application/vnd.sqlite3`,tar:`application/x-tar`,ts:`text/typescript`,tsx:`text/typescript`,txt:`text/plain`,wasm:`application/wasm`,wav:`audio/wav`,weba:`audio/webm`,webm:`video/webm`,wmv:`video/x-ms-wmv`,xml:`application/xml`,yaml:`text/yaml`,yml:`text/yaml`,zip:`application/zip`}}));function dtt(e=``,t=``){let n=(e&&e!==`application/octet-stream`?e:ck(t)||e).toLowerCase(),r=t.toLowerCase();return n.startsWith(`text/`)||n.includes(`json`)||n.includes(`xml`)||r.endsWith(`.md`)||r.endsWith(`.txt`)?`text`:n.startsWith(`image/`)?`image`:n.startsWith(`audio/`)?`audio`:n.startsWith(`video/`)?`video`:n===`application/pdf`||r.endsWith(`.pdf`)?`document`:`file`}function pk(e){let t=(e||``).toLowerCase(),n=wt.getModelInfo(t);if(n){let e=n.supportsImageInput===!0||n.routesByRequestFeatures===!0,t=n.supportsAudioInput===!0||n.routesByRequestFeatures===!0,r=n.supportsVideoInput===!0||n.routesByRequestFeatures===!0,i=n.supportsDocumentInput===!0||n.routesByRequestFeatures===!0;if(n.supportsImageInput!==void 0||n.supportsAudioInput!==void 0||n.supportsVideoInput!==void 0||n.supportsDocumentInput!==void 0||n.routesByRequestFeatures)return{images:e,audio:t,video:r,documents:i,routerByFeatures:!!n.routesByRequestFeatures,source:`metadata`}}let r=t.includes(`no-vision`)||t.includes(`non-vision`)||t.includes(`text-only`),i=t===`openrouter/free`||t===`openrouter/auto`,a=!r&&[`gpt-4o`,`gpt-4.1`,`gpt-5`,`gpt-6`,`astra`,`claude-3`,`claude-4`,`claude-5`,`claude-sonnet`,`claude-haiku`,`claude-opus`,`claude-fable`,`claude-mythos`,`gemini`,`omni`,`llava`,`qwen-vl`,`-vl`,`vision`,`pixtral`].some(e=>t.includes(e)),o=!r&&(t.includes(`claude-3-5`)||t.includes(`claude-3.5`)||t.includes(`claude-3-7`)||t.includes(`claude-3.7`)||t.includes(`claude-4`)||t.includes(`claude-5`)||t.includes(`claude-fable`)||t.includes(`claude-mythos`)||t.includes(`gemini`)||t.includes(`gpt-4.1`)||t.includes(`gpt-5`)||t.includes(`gpt-6`)||t.includes(`astra`)||/claude-(?:sonnet|haiku|opus|fable|mythos)-\d/.test(t));return a?{images:!0,audio:t.includes(`omni`)||t.includes(`audio`),video:t.includes(`omni`)||t.includes(`video`)||t.includes(`gemini`),documents:o,routerByFeatures:i,source:`heuristic`}:{images:!1,audio:!1,video:!1,documents:!1,routerByFeatures:i,source:`unknown`}}var mk=R((()=>{Tt(),fk()}));async function hk(e=[],t,n={}){let r=n.maxInlineTextBytes??102400,i=[];for(let n of e){let e=n.mimeType||`application/octet-stream`,a=dtt(e,n.fileName),o=a===`text`?`file`:a===`document`?`document`:a,s=null;try{s=await t(n)}catch{s=null}let c=s?.length??(typeof n.size==`number`?n.size:0);if(a===`text`&&s&&c<=r)try{let e=new TextDecoder(`utf-8`).decode(s),t=e.includes("```")?`~~~~`:"```";i.push({type:`text`,text:`Attachment: ${n.fileName}\n${t}\n${e}\n${t}`});continue}catch{}let l={type:`attachment`,mediaType:o,fileName:n.fileName,mimeType:e,size:n.size,path:n.path};s&&(o===`image`&&c<=3145728||o===`audio`&&c<=5242880||o===`document`&&c<=20971520)&&(l.data=att(s)),i.push(l)}return i}var ftt=R((()=>{stt(),mk()}));async function ptt(e,t){let n=await Q8e(e,t),r=await aa();return await Promise.all(n.map(async t=>{if(t.isFromMe)return{role:`assistant`,content:t.content};let n=`${t.sender}: ${t.content}`,i=t.attachments||[];if(i.length===0)return{role:`user`,content:n};let a=await hk(i,async t=>!r||!t.path?null:ND(r,e,t.path));return a.length===0?{role:`user`,content:n}:{role:`user`,content:[{type:`text`,text:n},...a]}}))}var mtt=R((()=>{ftt(),PD(),da(),e5e()}));function htt(e){for(let t of _k)if(t.test(e))return!0;return!1}function gtt(e){let t=String(e||``),n=t;for(let e of _k)t=t.replace(e,``);return t!==n&&(t=t.replace(/^[ \t]+$/gm,``),t=t.replace(/\n{3,}/g,`
3801
+ `),r=n>t*.5?n:t;return`${e.slice(0,r)}\n[...truncated ${e.length-r} chars]`}var ett=R((()=>{}));function ttt(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(rtt,Math.max(1e3,Math.floor(o*.6*4))),c=e.map(e=>ntt(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=ik(e),f<=o&&(d=e))}let p=o-f;for(let e=c.length-1;e>=+!!d;e--){let t=ik(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+=ik(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 ntt(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:$et(e.content,t)}:e);return{...e,content:n}}var rtt,itt=R((()=>{ok(),ett(),rtt=25e3}));function att(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)}function ott(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var stt=R((()=>{}));function sk(e){return e&&(e.split(/[?#]/,1)[0].replace(/\\/g,`/`).split(`/`).pop()||``).toLowerCase().split(`.`).pop()||``}function ck(e,t){let n=sk(e);return utt[n]??t}function lk(e){let t=sk(e);return dk[t]||null}function ctt(e){return lk(e)!==null}function ltt(e){let t=sk(e);if(t===`md`||t===`markdown`||t===`txt`)return`text/plain`;if(t===`pdf`)return`application/pdf`;if(dk[t])return dk[t]}function uk(e,t=``){return t||ck(e,`application/octet-stream`)}var dk,utt,fk=R((()=>{dk={apng:`image/apng`,avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,heic:`image/heic`,heif:`image/heif`,ico:`image/x-icon`,jpeg:`image/jpeg`,jpg:`image/jpeg`,png:`image/png`,svg:`image/svg+xml`,tif:`image/tiff`,tiff:`image/tiff`,webp:`image/webp`},utt={...dk,"3gp":`video/3gpp`,aac:`audio/aac`,avi:`video/x-msvideo`,bin:`application/octet-stream`,css:`text/css`,csv:`text/csv`,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`,gz:`application/gzip`,htm:`text/html`,html:`text/html`,iso:`application/octet-stream`,js:`text/javascript`,json:`application/json`,m4a:`audio/mp4`,m4v:`video/mp4`,markdown:`text/markdown`,md:`text/markdown`,mjs:`text/javascript`,mkv:`video/x-matroska`,mov:`video/mp4`,mp3:`audio/mpeg`,mp4:`video/mp4`,oga:`audio/ogg`,ogg:`audio/ogg`,ogv:`video/ogg`,pdf:`application/pdf`,rar:`application/vnd.rar`,so:`application/octet-stream`,sqlite:`application/vnd.sqlite3`,sqlite3:`application/vnd.sqlite3`,tar:`application/x-tar`,ts:`text/typescript`,tsx:`text/typescript`,txt:`text/plain`,wasm:`application/wasm`,wav:`audio/wav`,weba:`audio/webm`,webm:`video/webm`,wmv:`video/x-ms-wmv`,xml:`application/xml`,yaml:`text/yaml`,yml:`text/yaml`,zip:`application/zip`}}));function dtt(e=``,t=``){let n=(e&&e!==`application/octet-stream`?e:ck(t)||e).toLowerCase(),r=t.toLowerCase();return n.startsWith(`text/`)||n.includes(`json`)||n.includes(`xml`)||r.endsWith(`.md`)||r.endsWith(`.txt`)?`text`:n.startsWith(`image/`)?`image`:n.startsWith(`audio/`)?`audio`:n.startsWith(`video/`)?`video`:n===`application/pdf`||r.endsWith(`.pdf`)?`document`:`file`}function pk(e){let t=(e||``).toLowerCase(),n=wt.getModelInfo(t);if(n){let e=n.supportsImageInput===!0||n.routesByRequestFeatures===!0,t=n.supportsAudioInput===!0||n.routesByRequestFeatures===!0,r=n.supportsVideoInput===!0||n.routesByRequestFeatures===!0,i=n.supportsDocumentInput===!0||n.routesByRequestFeatures===!0;if(n.supportsImageInput!==void 0||n.supportsAudioInput!==void 0||n.supportsVideoInput!==void 0||n.supportsDocumentInput!==void 0||n.routesByRequestFeatures)return{images:e,audio:t,video:r,documents:i,routerByFeatures:!!n.routesByRequestFeatures,source:`metadata`}}let r=t.includes(`no-vision`)||t.includes(`non-vision`)||t.includes(`text-only`),i=t===`openrouter/free`||t===`openrouter/auto`,a=!r&&[`gpt-4o`,`gpt-4.1`,`gpt-5`,`gpt-6`,`astra`,`claude-3`,`claude-4`,`claude-5`,`claude-sonnet`,`claude-haiku`,`claude-opus`,`claude-fable`,`claude-mythos`,`gemini`,`omni`,`llava`,`qwen-vl`,`-vl`,`vision`,`pixtral`].some(e=>t.includes(e)),o=!r&&(t.includes(`claude-3-5`)||t.includes(`claude-3.5`)||t.includes(`claude-3-7`)||t.includes(`claude-3.7`)||t.includes(`claude-4`)||t.includes(`claude-5`)||t.includes(`claude-fable`)||t.includes(`claude-mythos`)||t.includes(`gemini`)||t.includes(`gpt-4.1`)||t.includes(`gpt-5`)||t.includes(`gpt-6`)||t.includes(`astra`)||/claude-(?:sonnet|haiku|opus|fable|mythos)-\d/.test(t));return a?{images:!0,audio:t.includes(`omni`)||t.includes(`audio`),video:t.includes(`omni`)||t.includes(`video`)||t.includes(`gemini`),documents:o,routerByFeatures:i,source:`heuristic`}:{images:!1,audio:!1,video:!1,documents:!1,routerByFeatures:i,source:`unknown`}}var mk=R((()=>{Tt(),fk()}));async function hk(e=[],t,n={}){let r=n.maxInlineTextBytes??102400,i=n.maxImageBytes??3145728,a=[];for(let n of e){let e=n.mimeType||`application/octet-stream`,o=dtt(e,n.fileName),s=o===`text`?`file`:o===`document`?`document`:o,c=null;try{c=await t(n)}catch{c=null}let l=c?.length??(typeof n.size==`number`?n.size:0);if(o===`text`&&c&&l<=r)try{let e=new TextDecoder(`utf-8`).decode(c),t=e.includes("```")?`~~~~`:"```";a.push({type:`text`,text:`Attachment: ${n.fileName}\n${t}\n${e}\n${t}`});continue}catch{}let u={type:`attachment`,mediaType:s,fileName:n.fileName,mimeType:e,size:n.size,path:n.path};c&&(s===`image`&&l<=i||s===`audio`&&l<=5242880||s===`document`&&l<=20971520)&&(u.data=att(c)),a.push(u)}return a}var ftt=R((()=>{stt(),mk()}));async function ptt(e,t){let n=await Q8e(e,t),r=await aa();return await Promise.all(n.map(async t=>{if(t.isFromMe)return{role:`assistant`,content:t.content};let n=`${t.sender}: ${t.content}`,i=t.attachments||[];if(i.length===0)return{role:`user`,content:n};let a=await hk(i,async t=>!r||!t.path?null:ND(r,e,t.path));return a.length===0?{role:`user`,content:n}:{role:`user`,content:[{type:`text`,text:n},...a]}}))}var mtt=R((()=>{ftt(),PD(),da(),e5e()}));function htt(e){for(let t of _k)if(t.test(e))return!0;return!1}function gtt(e){let t=String(e||``),n=t;for(let e of _k)t=t.replace(e,``);return t!==n&&(t=t.replace(/^[ \t]+$/gm,``),t=t.replace(/\n{3,}/g,`
3802
3802
 
3803
3803
  `)),t}function gk(e,t){let n=gtt(e);return n!==e&&htt(e)&&console.info(`[ShadowClaw] Chat-template control token(s) detected and stripped from "${t}" output. The provider or model may not be applying its chat template correctly. Original length: ${e.length}, cleaned length: ${n.length}.`),n}var _k,vk=R((()=>{_k=[/<\|start_header_id\|>\s*(?:system|user|assistant|tool)\s*<\|end_header_id\|>/gi,/<\|(?:begin_of_text|end_of_text|eot_id|im_start|im_end|end_of_message)\|>/gi,/<\|(?:startofturn|endofturn|start_of_turn|end_of_turn)\|>/gi,/<\|(?:image|audio|video|tool_call|tool_response|tool_result|function_call)\|>|<\|\/function_call\|>/gi,/<|(?:system|user|assistant|im_start|im_end)|>/g,/\[\s*INST\s*\]|\[\s*\/INST\s*\]|<<\s*SYS\s*>>|<<\s*\/SYS\s*>>/gi,/<\/?s>|<\/?bos>|<\/?eos>|<\|(?:bos|eos|pad|unk)\|>/gi,/<\|(?:START_OF_TURN_TOKEN|END_OF_TURN_TOKEN|CHATBOT_TOKEN|USER_TOKEN|SYSTEM_TOKEN)\|>/gi,/<\|(?:system|user|assistant|end|endoftext|placeholder\d*)\|>/gi,/<|(?:begin▁of▁sentence|end▁of▁sentence)|>/g,/<\|start\|>\s*(?:system|user|assistant|tool)\s*<\|message\|>/gi]}));function yk(e,t,n,r){return{type:`thinking-log`,payload:{groupId:e,level:t,timestamp:Date.now(),label:n,message:r||``}}}var bk=R((()=>{}));function xk(e,t,n){return{type:`tool-activity`,payload:{groupId:e,tool:t,status:n}}}var Sk=R((()=>{}));async function Ck(e,t,n,r){let{dirs:i,filename:a}=zp(n);for(let n=0;n<2;n++)try{let n=await Lp(e,t);for(let e of i)n=await n.getDirectoryHandle(e,{create:!0});let o=await n.getFileHandle(a,{create:!0});try{await FD(o,r);return}catch(t){if(!((t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`)&&(await wp(e)).type===`opfs`))throw t}let s=t.replace(/:/g,`-`);await ID([yp(),`groups`,s,...i,a],r);return}catch(e){if(n===0&&Cp(e)){Sp();continue}throw e}}var _tt=R((()=>{Rp(),Bp(),Ep(),LD()}));function vtt(){return new Promise((e,t)=>{let n=indexedDB.open(btt,1);n.onupgradeneeded=()=>{n.result.createObjectStore(Ek)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function ytt(){let e=await vtt();if(!e)return null;let t=await new Promise((t,n)=>{let r=e.transaction(Ek,`readonly`).objectStore(Ek).get(Dk);r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)});if(t)return e.close(),t;let n=await crypto.subtle.generateKey({name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`]);try{await new Promise((t,r)=>{let i=e.transaction(Ek,`readwrite`);i.objectStore(Ek).put(n,Dk),i.oncomplete=()=>t(),i.onerror=()=>r(i.error)})}finally{e.close()}return n}async function wk(e){let t=await ytt();if(!t)return null;let n=crypto.getRandomValues(new Uint8Array(Ok)),r=await crypto.subtle.encrypt({name:`AES-GCM`,iv:n},t,new TextEncoder().encode(e)),i=new Uint8Array(n.length+new Uint8Array(r).length);return i.set(n),i.set(new Uint8Array(r),n.length),btoa(String.fromCharCode(...i))}async function Tk(e){let t=await ytt();if(!t)return null;let n=Uint8Array.from(atob(e),e=>e.charCodeAt(0)),r=n.slice(0,Ok),i=n.slice(Ok),a=await crypto.subtle.decrypt({name:`AES-GCM`,iv:r},t,i);return new TextDecoder().decode(a)}var btt,Ek,Dk,Ok,kk=R((()=>{btt=`shadowclaw-keystore`,Ek=`keys`,Dk=`api-key-encryption`,Ok=12}));function xtt(e){return!e||e.authMode===`token`||e.authMode===`pat`?`token`:e.authMode===`basic`?`basic`:e.authMode===`oauth`||e.oauthProviderId||e.oauthClientId||e.oauthClientSecret||e.refreshToken||e.accessTokenExpiresAt||e.tokenType||e.oauthReauthRequired?`oauth`:`token`}var Stt=R((()=>{}));function Ak(e){return xtt(e)}function Ctt(e,t){return Ak(e)!==`oauth`||e.oauthReauthRequired||!e.refreshToken||!e.oauthProviderId||!e.oauthClientId?!1:t.forceRefresh?!0:e.accessTokenExpiresAt?e.accessTokenExpiresAt<=Date.now()+Ott:!1}async function wtt(e,t,n){if(!n.refreshToken||!n.oauthProviderId||!n.oauthClientId)return n;let r=await Tk(n.refreshToken);if(!r)return n;let i=n.oauthClientSecret?await Tk(n.oauthClientSecret):void 0,a=async r=>{let i=t.findIndex(e=>e.id===n.id);i!==-1&&(t[i]=r,await BD(e,V.SERVICE_ACCOUNTS,t))},o=async()=>{let e=(n.oauthRefreshFailureCount||0)+1,t=e>=ktt,r={...n,oauthRefreshFailureCount:e,oauthReauthRequired:t,oauthReauthRequiredAt:t?n.oauthReauthRequiredAt||Date.now():void 0};return await a(r),r};try{let e=await fetch(`/oauth/refresh`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({providerId:n.oauthProviderId,clientId:n.oauthClientId,clientSecret:i,refreshToken:r,scope:n.scopes,tokenUrl:n.oauthCustomTokenUrl})});if(!e.ok)return o();let t=await e.json();if(!t.accessToken)return o();let s=await wk(t.accessToken);if(!s)return o();let c=n.refreshToken;if(t.refreshToken){let e=await wk(t.refreshToken);e&&(c=e)}let l={...n,token:s,refreshToken:c,accessTokenExpiresAt:t.expiresIn?Date.now()+t.expiresIn*1e3:n.accessTokenExpiresAt,tokenType:t.tokenType||n.tokenType,scopes:t.scope?t.scope.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):n.scopes,oauthRefreshFailureCount:0,oauthReauthRequired:!1,oauthReauthRequiredAt:void 0};return await a(l),l}catch{return o()}}function Ttt(e,t){if(e.oauthProviderId){let t=$t(e.oauthProviderId);if(t)return t}let n=[e.service,e.hostPattern,t].filter(e=>!!e).map(e=>e.toLowerCase());for(let e of Object.values(wn))if([e.providerId,...e.aliases||[]].map(e=>e.toLowerCase()).some(e=>n.some(t=>t.includes(e))))return e;return null}function Ett(e,t){let n=Ak(e),r=Ttt(e,t);if(r){let e;return e=n===`oauth`?r.tokenAuth.oauth:n===`basic`&&r.tokenAuth.basic?r.tokenAuth.basic:r.tokenAuth.token,{headerName:e.headerName,headerPrefix:e.headerPrefix||``}}return{headerName:`Authorization`,headerPrefix:n===`basic`?`Basic `:`Bearer `}}function Dtt(e,t){let n=[],r=-1,i=t.toLowerCase();for(let t of e){if(!t.hostPattern)continue;let e=t.hostPattern.toLowerCase();i.includes(e)&&(e.length>r?(r=e.length,n.length=0,n.push(t)):e.length===r&&n.push(t))}return n}function jk(e,t){return e.length?t&&e.find(e=>Ak(e)===t)||e[0]:void 0}async function Mk(e,t,n={}){let r=await ba(e,V.SERVICE_ACCOUNTS),i=Array.isArray(r)?r:[];if(i.length===0)return;let a;if(n.accountId&&(a=i.find(e=>e.id===n.accountId)),!a&&t){let e=Dtt(i,t);a=n.authMode?jk(e,n.authMode):jk(e,e[0]?Ttt(e[0],t)?.defaultMode:void 0)}if(!a){let t=await ba(e,V.SERVICE_DEFAULT_ACCOUNT);t&&(a=i.find(e=>e.id===t))}if(!a&&n.authMode&&(a=jk(i,n.authMode)),a||=i[0],!a)return;if(Ctt(a,n)&&(a=await wtt(e,i,a)),Ak(a)===`oauth`&&a.oauthReauthRequired)return{token:``,service:a.service,hostPattern:a.hostPattern,headerName:`Authorization`,headerValue:``,accountId:a.id,authMode:`oauth`,reauthRequired:!0};let o=``;a.token&&(o=await Tk(a.token)??``);let{headerName:s,headerPrefix:c}=Ett(a,t),l=o;Ak(a)===`basic`&&a.basicUsername&&(l=btoa(`${a.basicUsername}:${o}`));let u=c?`${c}${l}`:l;return{token:o,service:a.service,hostPattern:a.hostPattern,headerName:s,headerValue:u,accountId:a.id,authMode:Ak(a)}}var Ott,ktt,Nk=R((()=>{Mn(),xa(),VD(),kk(),Stt(),Ott=6e4,ktt=3}));function Pk(e){return xtt(e)}function Att(e){switch(e){case`azure-devops`:return`azure_devops`;default:return e}}function jtt(e){if(!e)return`generic`;let t=e.toLowerCase();return t.includes(`github`)?`github`:t.includes(`dev.azure.com`)||t.includes(`visualstudio.com`)?`azure-devops`:t.includes(`gitlab`)?`gitlab`:`generic`}function Fk(e){if(e.reauthRequired)return{};let t=e.provider||jtt(e.hostPattern||``),n=Att(t),r=e.authMode||`token`;if(e.token&&n===`azure_devops`&&en(n,r,`git_remote`)?.headerPrefix===`Basic `)return{Authorization:`Basic ${btoa(`:`+e.token)}`};if(t===`azure-devops`&&e.username&&e.password)return{Authorization:`Basic ${btoa(e.username+`:`+e.password)}`};if(e.token){let t=en(n,r,`git_remote`);return t?.headerName?{[t.headerName]:`${t.headerPrefix||``}${e.token}`}:{Authorization:`Bearer ${e.token}`}}return{}}function Mtt(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return n?t.hostname+n:t.hostname}catch{return}}function Ntt(e,t){let n=t.toLowerCase(),r=[],i=-1;for(let t of e){if(!t.hostPattern)continue;let e=t.hostPattern.toLowerCase();n.includes(e)&&(e.length>i?(i=e.length,r.length=0,r.push(t)):e.length===i&&r.push(t))}return r}function Ptt(e,t){if(!e.length)return;if(!t)return e[0];let n=e.find(e=>Pk(e)===t);if(n)return n;if(t===`token`){let t=e.find(e=>Pk(e)===`token`&&!e.authMode);if(t)return t}return e[0]}async function Ik(e){if(e)return await Tk(e)??void 0}function Ftt(e,t){return Pk(e)!==`oauth`||e.oauthReauthRequired||!e.refreshToken||!e.oauthProviderId||!e.oauthClientId?!1:t.forceRefresh?!0:e.accessTokenExpiresAt?e.accessTokenExpiresAt<=Date.now()+ztt:!1}async function Itt(e,t,n){if(!n.refreshToken||!n.oauthProviderId||!n.oauthClientId)return n;let r=await Ik(n.refreshToken);if(!r)return n;let i=n.oauthClientSecret?await Ik(n.oauthClientSecret):void 0,a=async r=>{let i=t.findIndex(e=>e.id===n.id);i!==-1&&(t[i]=r,await BD(e,V.GIT_ACCOUNTS,t))},o=async()=>{let e=(n.oauthRefreshFailureCount||0)+1,t=e>=Btt,r={...n,oauthRefreshFailureCount:e,oauthReauthRequired:t,oauthReauthRequiredAt:t?n.oauthReauthRequiredAt||Date.now():void 0};return await a(r),r};try{let e=await fetch(`/oauth/refresh`,{body:JSON.stringify({clientId:n.oauthClientId,clientSecret:i,providerId:n.oauthProviderId,refreshToken:r,scope:n.scopes}),headers:{"content-type":`application/json`},method:`POST`});if(!e.ok)return o();let t=await e.json();if(!t.accessToken)return o();let s=await wk(t.accessToken);if(!s)return o();let c=n.refreshToken;if(t.refreshToken){let e=await wk(t.refreshToken);e&&(c=e)}let l={...n,token:s,refreshToken:c,accessTokenExpiresAt:t.expiresIn?Date.now()+t.expiresIn*1e3:n.accessTokenExpiresAt,tokenType:t.tokenType||n.tokenType,scopes:t.scope?t.scope.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):n.scopes,oauthRefreshFailureCount:0,oauthReauthRequired:!1,oauthReauthRequiredAt:void 0};return await a(l),l}catch{return o()}}async function Lk(e,t,n={}){let r=await ba(e,V.GIT_ACCOUNTS);return Array.isArray(r)&&r.length>0?Ltt(e,r,t,n):Rtt(e)}async function Ltt(e,t,n,r={}){let i;if(r.accountId&&(i=t.find(e=>e.id===r.accountId)),!i&&n){let e=Mtt(n);e&&(i=Ptt(Ntt(t,e),r.authMode))}if(!i){let r=await ba(e,V.GIT_DEFAULT_ACCOUNT);if(r){let e=t.find(e=>e.id===r);if(e){if(!n)i=e;else{let t=Mtt(n);if(t&&e.hostPattern){let n=t?.toLowerCase(),r=e.hostPattern.toLowerCase();n?.includes(r)&&(i=e)}}}}}if(!i&&!n&&r.authMode&&(i=Ptt(t,r.authMode)),!i&&!n&&(i=t[0]),!i)return{authMode:`token`,authorEmail:void 0,authorName:void 0,password:void 0,provider:`generic`,token:void 0,username:void 0};Ftt(i,r)&&(i=await Itt(e,t,i));let a=i.provider||jtt(i.hostPattern||``);return Pk(i)===`oauth`&&i.oauthReauthRequired?{accountId:i.id,authMode:`oauth`,authorEmail:i.authorEmail||void 0,authorName:i.authorName||void 0,hostPattern:i.hostPattern||void 0,password:void 0,provider:a,reauthRequired:!0,token:void 0,username:i.username||void 0}:{accountId:i.id,authMode:Pk(i),authorEmail:i.authorEmail||void 0,authorName:i.authorName||void 0,hostPattern:i.hostPattern||void 0,password:await Ik(i.password),provider:a,token:await Ik(i.token),username:i.username||void 0}}async function Rtt(e){let t=await ba(e,V.GIT_TOKEN),n=await ba(e,V.GIT_PASSWORD);return{authMode:`token`,authorEmail:await ba(e,V.GIT_AUTHOR_EMAIL)||void 0,authorName:await ba(e,V.GIT_AUTHOR_NAME)||void 0,password:n?await Ik(n):void 0,provider:`generic`,token:t?await Ik(t):void 0,username:await ba(e,V.GIT_USERNAME)||void 0}}var ztt,Btt,Vtt=R((()=>{Mn(),Stt(),kk(),xa(),VD(),ztt=6e4,Btt=3}));function Htt(e){if(typeof e!=`string`||!e.trim())return!1;try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`}catch{return!1}}function Utt(e,t){if(!e||typeof e!=`object`)return null;let n=e;if(!n.serviceType||!n.authType)return null;if(n.serviceType!==t)throw Error(`Credential ref serviceType must match connection serviceType`);return{serviceType:n.serviceType,authType:n.authType,providerId:n.providerId||void 0,accountId:n.accountId||void 0,gitAccountId:n.gitAccountId||void 0,headerName:n.headerName||void 0,encryptedValue:n.encryptedValue||void 0}}function Wtt(e){if(!e||typeof e!=`object`)return null;let t=e;return!t.id||!t.label||!t.serviceType||!t.transport||typeof t.enabled!=`boolean`||typeof t.createdAt!=`number`||typeof t.updatedAt!=`number`||!Htt(t.serverUrl)||t.serviceType!==`mcp_remote`&&t.serviceType!==`webmcp_local`||t.transport!==`streamable_http`&&t.transport!==`sse`&&t.transport!==`websocket`?null:{id:t.id,label:t.label,serviceType:t.serviceType,serverUrl:t.serverUrl,transport:t.transport,enabled:t.enabled,autoReconnectOAuth:t.autoReconnectOAuth===!0,createdAt:t.createdAt,updatedAt:t.updatedAt,credentialRef:Utt(t.credentialRef,t.serviceType)}}async function Gtt(e){let t=await ba(e,V.REMOTE_MCP_CONNECTIONS);if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=Wtt(e);t&&n.push(t)}return n}async function Ktt(e){return Gtt(e)}async function Rk(e,t){if(!t)return null;let n=await Gtt(e);return n.find(e=>e.id===t)||n.find(e=>e.label.toLowerCase()===t.toLowerCase())||null}var zk=R((()=>{Mn(),xa(),VD()}));function qtt(e){return e===`oauth`?`oauth`:`token`}async function Jtt(e,t,n={}){let r=await Rk(e,t);if(!r)return null;let i=r.credentialRef;if(!i||i.authType===`none`)return{connection:r,authType:`none`,headers:{}};if(i.authType===`custom_header`){if(!i.headerName||!i.encryptedValue)return{connection:r,authType:`custom_header`,headers:{}};let e=await Tk(i.encryptedValue);return{connection:r,authType:`custom_header`,headers:e?{[i.headerName]:e}:{}}}let a=qtt(i.authType);if(i.accountId){let t=await Mk(e,r.serverUrl,{accountId:i.accountId,authMode:a,forceRefresh:n.forceRefresh});return t?t.reauthRequired?{connection:r,authType:i.authType,headers:{},reauthRequired:!0}:{connection:r,authType:i.authType,headers:t.headerValue?{[t.headerName]:t.headerValue}:{}}:{connection:r,authType:i.authType,headers:{}}}if(i.gitAccountId){let t=await Lk(e,r.serverUrl,{accountId:i.gitAccountId,authMode:a,forceRefresh:n.forceRefresh});return t.reauthRequired?{connection:r,authType:i.authType,headers:{},reauthRequired:!0}:{connection:r,authType:i.authType,headers:Fk(t)}}return{connection:r,authType:i.authType,headers:{}}}var Ytt=R((()=>{kk(),zk(),Nk(),Vtt()}));function Xtt(e){return typeof e==`object`&&!!e&&`method`in e&&`id`in e&&!(`result`in e)&&!(`error`in e)}function Ztt(e){let t=(e.requestedSchema||{}).properties||{},n={};for(let[e,r]of Object.entries(t))`default`in r?n[e]=r.default:r.type===`boolean`&&(n[e]=!0);return n}function Bk(e,t){return!e.headers||typeof e.headers.get!=`function`?null:e.headers.get(t)}function Qtt(e){return/no valid session id provided/i.test(e)}function Vk(e,t){let n=t&&`error`in t?t.error.message||`Remote MCP JSON-RPC error`:``;return Qtt(n)?new Gk(n):e.ok?Error(n||`Remote MCP JSON-RPC error`):new Kk(e.status,n?`Remote MCP HTTP error: ${e.status} (${n})`:`Remote MCP HTTP error: ${e.status}`)}function $tt(e){if(!e)return null;let t=null,n=e.split(/\r?\n/);for(let e of n){let n=e.trim();if(!n.startsWith(`data:`))continue;let r=n.slice(5).trim();if(r&&r!==`[DONE]`)try{let e=JSON.parse(r);e&&typeof e==`object`&&`jsonrpc`in e&&(t=e)}catch{}}return t}function ent(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}async function Hk(e,t,n){let r=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json, text/event-stream`,...t},body:JSON.stringify(n)}),i=(Bk(r,`content-type`)||``).toLowerCase(),a=null;if(typeof r.text==`function`){let e=await r.text();a=i.includes(`text/event-stream`)?$tt(e):ent(e)}else try{a=await r.json()}catch{a=null}return{response:r,payload:a}}async function tnt(e,t,n){let{response:r,payload:i}=await Hk(e,{...t,"mcp-session-id":n},{jsonrpc:`2.0`,method:`notifications/initialized`,params:{}});if(!r.ok||i&&`error`in i)throw Vk(r,i)}async function nnt(e,t,n){let r=Wk.get(e);if(r?.sessionId)return r;let{response:i,payload:a}=await Hk(t,n,{jsonrpc:`2.0`,id:`initialize-${Date.now().toString(36)}`,method:`initialize`,params:{protocolVersion:`2025-03-26`,capabilities:{elicitation:{}},clientInfo:{name:`shadowclaw-remote-mcp-client`,version:`1.0.0`}}});if(!i.ok||a&&`error`in a)throw Vk(i,a);let o=Bk(i,`mcp-session-id`)||`local-${Date.now()}-${Math.random().toString(36).slice(2)}`,s={sessionId:o,protocolVersion:Bk(i,`mcp-protocol-version`)||a?.result?.protocolVersion,lastUsedAt:Date.now()};return await tnt(t,n,o),Wk.set(e,s),s}async function rnt(e,t,n,r,i){let a=await nnt(e,t,n),o=async e=>{let a={jsonrpc:`2.0`,id:Date.now().toString(),method:r,params:i||{}},o={...n,"mcp-session-id":e},{response:s,payload:c}=await Hk(t,o,a),l=0;for(;Xtt(c)&&l<5&&(l++,c.method===`elicitation/create`);){let e=Ztt(c.params||{});({response:s,payload:c}=await Hk(t,o,{jsonrpc:`2.0`,id:c.id,result:{action:`accept`,content:e}}))}if(Xtt(c))throw Error(`Unsupported server request: ${c.method}`);if(!s.ok||!c||`error`in c)throw Vk(s,c);return c.result};try{let t=await o(a.sessionId);return a.lastUsedAt=Date.now(),Wk.set(e,a),t}catch(r){if(!(r instanceof Gk))throw r;Wk.delete(e),a=await nnt(e,t,n);let i=await o(a.sessionId);return a.lastUsedAt=Date.now(),Wk.set(e,a),i}}function Uk(e){e&&Wk.delete(e)}async function int(e,t,n,r){let i=await Jtt(e,t);if(!i)throw Error(`Remote MCP connection not found`);if(i.reauthRequired)throw new qk(t);let{connection:a,authType:o,headers:s}=i;if(a.transport!==`streamable_http`)throw Error(`Unsupported remote MCP transport`);try{return await rnt(t,a.serverUrl,s,n,r)}catch(i){if(!(i instanceof Kk)||i.status!==401||o!==`oauth`)throw i;Uk(t);let a=await Jtt(e,t,{forceRefresh:!0});if(!a||a.reauthRequired)throw new qk(t);try{return await rnt(t,a.connection.serverUrl,a.headers,n,r)}catch(e){throw e instanceof Kk&&e.status===401?new qk(t):e}}}async function ant(e,t){let n=await int(e,t,`tools/list`);return Array.isArray(n.tools)?n.tools:[]}async function ont(e,t,n,r={}){return int(e,t,`tools/call`,{name:n,arguments:r})}var Wk,Gk,Kk,qk,snt=R((()=>{Ytt(),Wk=/* @__PURE__ */ new Map,Gk=class extends Error{constructor(e){super(e),this.name=`InvalidRemoteMcpSessionError`}},Kk=class extends Error{status;constructor(e,t){super(t),this.name=`HttpRemoteMcpError`,this.status=e}},qk=class extends Error{connectionId;constructor(e){super(`OAuth reconnect required for remote MCP connection`),this.name=`McpReauthRequiredError`,this.connectionId=e}}}));async function cnt(e,t,n,r){let{dirs:i,filename:a}=zp(n);for(let n=0;n<2;n++)try{let n=await Lp(e,t);for(let e of i)n=await n.getDirectoryHandle(e,{create:!0});let o=await n.getFileHandle(a,{create:!0});try{await FD(o,r);return}catch(t){if(!((t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`)&&(await wp(e)).type===`opfs`))throw t}let s=t.replace(/:/g,`-`);await ID([yp(),`groups`,s,...i,a],r);return}catch(e){if(n===0&&Cp(e)){Sp();continue}throw e}}var lnt=R((()=>{Rp(),Bp(),Ep(),LD()}));function unt(){return[...Yk].sort((e,t)=>e.id.localeCompare(t.id))}function Jk(e){return e&&Yk.find(t=>t.id===e)||null}var Yk,dnt=R((()=>{Yk=[{id:`imap`,name:`IMAP Mail`,protocol:`imap`,description:`Read mailboxes and fetch message metadata/content.`,version:`0.1.0`,actions:[`messages.read`,`messages.send`],authTypes:[`basic_userpass`,`oauth`],serviceTypes:[`http_api`],configurableFields:[`host`,`port`,`secure`,`mailboxPath`,`smtpHost`,`smtpPort`,`smtpSecure`,`fromAddress`,`executionMode`,`pollIntervalSec`]}]}));function fnt(e){if(!e||typeof e!=`object`)return null;let t=e;return!t.serviceType||!t.authType?null:{serviceType:t.serviceType,authType:t.authType,providerId:t.providerId||void 0,accountId:t.accountId||void 0,username:t.username||void 0,headerName:t.headerName||void 0,encryptedSecret:t.encryptedSecret||void 0}}function pnt(e){if(!e||typeof e!=`object`)return null;let t=e;return!t.id||!t.label||!t.pluginId||typeof t.enabled!=`boolean`||typeof t.createdAt!=`number`||typeof t.updatedAt!=`number`||!Jk(t.pluginId)?null:{id:t.id,label:t.label,pluginId:t.pluginId,enabled:t.enabled,config:t.config&&typeof t.config==`object`?{...t.config}:{},credentialRef:fnt(t.credentialRef),createdAt:t.createdAt,updatedAt:t.updatedAt}}async function Xk(e){let t=await ba(e,V.INTEGRATION_CONNECTIONS);if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=pnt(e);t&&n.push(t)}return n}async function Zk(e,t){await BD(e,V.INTEGRATION_CONNECTIONS,t)}async function Qk(e){return Xk(e)}async function $k(e,t){if(!t)return null;let n=await Xk(e);return n.find(e=>e.id===t)||n.find(e=>e.label.toLowerCase()===t.toLowerCase())||null}async function eA(e,t){if(!t.label?.trim())throw Error(`Email connection label is required`);let n=Jk(t.pluginId);if(!n)throw Error(`Unknown email plugin: ${t.pluginId}`);let r=await Xk(e),i=Date.now();if(t.id){let a=r.findIndex(e=>e.id===t.id);if(a!==-1){let o=r[a],s={...o,label:t.label.trim(),pluginId:n.id,enabled:t.enabled??o.enabled,config:t.config?{...t.config}:o.config,updatedAt:i};return r[a]=s,await Zk(e,r),s}}let a={id:t.id||Hf(),label:t.label.trim(),pluginId:n.id,enabled:t.enabled??!0,config:t.config?{...t.config}:{},credentialRef:null,createdAt:i,updatedAt:i};return r.push(a),await Zk(e,r),a}async function mnt(e,t,n){if(!t)return null;let r=await Xk(e),i=r.findIndex(e=>e.id===t);if(i===-1)return null;let a={...r[i],credentialRef:n?fnt(n):null,updatedAt:Date.now()};return r[i]=a,await Zk(e,r),a}async function hnt(e,t){if(!t)return!1;let n=await Xk(e),r=n.filter(e=>e.id!==t);return r.length!==n.length&&(await Zk(e,r),!0)}var gnt=R((()=>{Mn(),xa(),VD(),qf(),dnt()}));function _nt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({path:e});continue}if(!n||typeof n!=`object`)continue;let e=typeof n.path==`string`?n.path.trim():``;if(!e)continue;let r=typeof n.filename==`string`?n.filename.trim():``,i=typeof n.content_type==`string`?n.content_type.trim():``;t.push({path:e,filename:r||void 0,contentType:i||void 0})}return t}var vnt=R((()=>{}));function ynt(e,t=`attachment.bin`){if(!e)return t;let n=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return n[n.length-1]||t}function bnt(e,t={}){let n=t.replacement??`_`,r=t.fallback??`attachment.bin`,i=e.trim();t.stripControlChars&&(i=i.replace(/[\u0000-\u001f\u007f]+/g,``)),t.stripLeadingDots&&(i=i.replace(/^\.+/,``));let a=t.stripControlChars?/[\\/:*?"<>|]/g:/[\\/:*?"<>|\x00-\x1f\u007f]/g;if(t.collapseReplacement&&n){let e=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);i=i.replace(t.stripControlChars?/[\\/:*?"<>|]+/g:/[\\/:*?"<>|\x00-\x1f\u007f]+/g,n),i=i.replace(RegExp(`${e}+`,`g`),n)}else i=i.replace(a,n);return i=i.trim(),t.stripLeadingDots&&(i=i.replace(/^\.+/,``).trim()),i||r}var tA=R((()=>{}));async function nA(e,t,n,r=!1){let i=(typeof n.username==`string`?n.username.trim():``)||t.credentialRef?.username||(typeof t.config.username==`string`?t.config.username:``);if(!i)return`Error: Integration connection ${t.id} is missing username credentials.`;if(t.credentialRef?.authType===`oauth`){let n=t.credentialRef.accountId;if(!n)return`Error: Integration connection ${t.id} is missing linked OAuth account.`;let a=await Mk(e,void 0,{accountId:n,authMode:`oauth`,forceRefresh:r});if(!a||a.reauthRequired||!a.token){let e=t.credentialRef?.providerId||`the configured`;return`Error: OAuth account reconnect required for integration ${t.id}.\nOpen Settings -> Integrations, edit this email connection, and click Connect OAuth for ${e} to re-authorize.`}return{authType:`oauth`,username:i,accessToken:a.token}}let a=(typeof n.password==`string`?n.password.trim():``)||t.credentialRef?.encryptedSecret&&await Tk(t.credentialRef.encryptedSecret)||``;return a?{authType:`basic_userpass`,username:i,password:a}:`Error: Integration connection ${t.id} is missing password credentials.`}var xnt=R((()=>{kk(),Nk()}));async function Snt(e,t,n,r){let i=bnt(r),a=i.lastIndexOf(`.`),o=a>0?i.slice(0,a):i,s=a>0?i.slice(a):``,c=n.trim().replace(/^\/+|\/+$/g,``);for(let n=0;n<1e3;n++){let r=n===0?i:`${o}-${n+1}${s}`,a=c?`${c}/${r}`:r;if(!await UD(e,t,a))return a}return c?`${c}/${Hf()}-${i}`:`${Hf()}-${i}`}var Cnt=R((()=>{WD(),qf(),tA()}));async function wnt(e,t,n){let r=typeof t.action==`string`?t.action.trim():``;if(!r)return`Error: manage_email requires action.`;if(r===`list_plugins`){let e=unt();return e.length?e.map(e=>`- ${e.id} (${e.protocol})\n Name: ${e.name}\n Actions: ${e.actions.join(`, `)}\n Auth: ${e.authTypes.join(`, `)}\n Fields: ${e.configurableFields.join(`, `)||`(none)`}`).join(`
3804
3804
 
@@ -8326,13 +8326,13 @@ Fetching text-generation ONNX models from Hugging Face...
8326
8326
  `),{success:!0,tool:l,headlessSafe:u,output:a}}catch(t){let i=t instanceof Error?t.message:String(t);return n.quiet||console.error(`Error executing tool "${e}": ${i}`),r.exitCode=1,{success:!1,error:i}}}if(!n.quiet){let e=u?`[headless-safe]`:`[browser-only]`;console.log(`Tool: ${l.name} ${e}\n`),console.log(`Description:\n ${l.description}\n`),l.input_schema&&(console.log(`Parameters (JSON Schema):`),console.log(JSON.stringify(l.input_schema,null,2)),console.log()),console.log(`Usage:`),console.log(` Direct CLI: npx shadow-claw agent tool ${l.name} '<json-input>'`),console.log(` Pipe input: echo '<text>' | npx shadow-claw agent tool ${l.name}`),console.log(` Agent Prompt: npx shadow-claw agent run "<instruction>"
8327
8327
  `)}return{success:!0,tool:l,headlessSafe:u}}async function w7t(e={}){let{db:t,core:n}=await N9(e),r=e.group||n.DEFAULT_SERVER_GROUP_ID||X9,{clearGroupMessages:i}=await Promise.resolve().then(()=>(V8e(),z8e));return await i(t,r),e.quiet||console.log(`Cleared conversation history for group "${r}".`),{success:!0,groupId:r}}async function T7t(e,t={}){let{db:n,core:r}=await N9(t),i=t.group||r.DEFAULT_SERVER_GROUP_ID||X9,a=await r.loadSkill(n,i,e);if(!a)throw Error(`Skill "${e}" not found in workspace.`);if(a.execution?.type===`tools`&&Array.isArray(a.execution.tools)){let e=a.execution.tools.map(e=>({name:e.name||e.tool,input:e.input||e.arguments||{},suppressOutput:e.suppressOutput})),t=await r.executeToolChain(n,i,e,{isManual:!0});return{success:!0,skill:a,results:t.results,rawOutputs:t.rawOutputs}}return{success:!0,skill:a,message:`Skill "${e}" loaded (no declarative tools defined).`}}async function E7t(e,t,n,i={}){let a=i.contentRoot??r.cwd(),o=await M9(n,a),s=o?.config||{},c=s.settings||{},l=s.agent||c.agent||{},u=i.provider||r.env.SHADOW_CLAW_PROVIDER||r.env.SHADOW_CLAW_DEFAULT_PROVIDER;if(!u&&typeof t.getConfig==`function`&&(u=await t.getConfig(e,t.CONFIG_KEYS?.PROVIDER||`provider`)),!u&&i.model){let{isLlamafile:e,isAgentfile:t}=await Promise.resolve().then(()=>(G9(),F9));t(i.model)?u=`agentfile`:e(i.model)?u=`llamafile`:/onnx/i.test(i.model)&&(u=`transformers_js_local`)}u||=l.defaultProvider||l.provider||c.defaultProvider||c.provider||s.defaultProvider;let d=i.stdin?!!i.stdin.isTTY:!!r.stdin.isTTY,f=!i.stdin&&!r.stdin.isTTY&&!!(r.stderr.isTTY||r.stdout.isTTY),p=i.isTTY===void 0?d||f:!!i.isTTY,m=i.isCI===void 0?i.isTTY===void 0&&!(!r.env.CI||[`0`,`false`].includes(r.env.CI.toLowerCase())):!!i.isCI,h=p&&!m&&!i.quiet&&i.interactive!==!1;if(!u){if(h){let{promptForAgentModel:e}=await Promise.resolve().then(()=>(G9(),F9)),t=await e({workspaceDir:n,contentRoot:a,cacheDir:i.cacheDir,stdin:i.stdin,stdout:i.stdout,quiet:i.quiet,isTTY:p,service:i._transformersService});u=t.providerId,i.model=t.model}else u=`openrouter`}let g=typeof t.getProvider==`function`?t.getProvider(u):null;if(!g){let e=`Error: Unknown provider "${u}".`;throw Error(e)}let _;if(i.apiKey!==void 0)_=i.apiKey;else{if(_=r.env.SHADOW_CLAW_API_KEY,!_)switch(u){case`openrouter`:_=r.env.OPENROUTER_API_KEY;break;case`huggingface`:_=r.env.HUGGINGFACE_API_KEY||r.env.HF_TOKEN;break;case`gemini_proxy`:_=r.env.GEMINI_API_KEY}!_&&typeof t.getConfig==`function`&&(_=await t.getConfig(e,`api_key:${u}`)||await t.getConfig(e,`apiKey`))}let v=i.model||r.env.SHADOW_CLAW_MODEL||r.env.SHADOW_CLAW_DEFAULT_MODEL||(typeof t.getConfig==`function`?await t.getConfig(e,t.CONFIG_KEYS?.MODEL||`model`):null)||l.defaultModel||l.model||c.defaultModel||c.model||s.defaultModel||g?.defaultModel||(u===`transformers_js_local`?(await Promise.resolve().then(()=>(G9(),F9))).DEFAULT_LOCAL_MODEL:`default`);if(u===`transformers_js_local`||u===`llamafile`||u===`agentfile`){let{isModelLocallyCached:e,downloadLocalModel:t}=await Promise.resolve().then(()=>(G9(),F9)),a=i.cacheDir||l.cacheDir||s.cacheDir||c.cacheDir;if(!(e(v,a)||n&&e(v,n))){let e=i.stdout||r.stderr;if(i.download||i.yes||i.y)i.quiet||e.write(`\nDownloading ${v} from Hugging Face...\n`),await t(v,{cacheDir:a||i.cacheDir,stream:e,isTTY:p,service:i._transformersService,progress:!i.quiet&&i.progress!==!1&&!i.noProgress,quiet:i.quiet,verbose:i.verbose});else if(h){let n=await import(`node:readline/promises`),o=await import(`node:tty`),s=await import(`node:fs`),c=i.stdin||r.stdin,l=e,u=!1,d=null;if(c===r.stdin&&!r.stdin.isTTY&&!r.env.CI&&(r.stderr.isTTY||r.stdout.isTTY))try{let e=r.platform===`win32`?`CONIN$`:`/dev/tty`;d=s.openSync(e,`r`),c=new o.ReadStream(d),l=r.stderr.isTTY?r.stderr:r.stdout,u=!0}catch{try{let e=r.platform===`win32`?`CONIN$`:`/dev/tty`;c=s.createReadStream(e),l=r.stderr.isTTY?r.stderr:r.stdout,u=!0}catch{}}let f=n.createInterface({input:c,output:l}),m=!1,h=()=>{if(!m){m=!0,l.write(`
8328
8328
  Operation cancelled.
8329
- `);try{f.close()}catch{}typeof i.onExit==`function`?i.onExit(130):r.exit(130)}};f.on(`SIGINT`,h),c&&typeof c.on==`function`&&c!==r.stdin&&c.on(`SIGINT`,h);let g=()=>h();r.on(`SIGINT`,g);let _=e=>{let t=typeof e==`string`?e:e.toString(`binary`);(t.includes(``)||t.includes(``))&&h()};c&&typeof c.on==`function`&&c.on(`data`,_);let y=``;try{y=(await f.question(`\nModel "${v}" is not yet downloaded to local disk.\nDownload model weights now? (Y/n) [default: Y]: `)).trim().toLowerCase()}finally{r.removeListener(`SIGINT`,g),c&&typeof c.removeListener==`function`&&(c!==r.stdin&&c.removeListener(`SIGINT`,h),c.removeListener(`data`,_));try{f.close()}catch{}if(u){if(c&&typeof c.destroy==`function`)try{c.destroy()}catch{}if(d!=null)try{s.closeSync(d)}catch{}}}if(y===``||y===`y`||y===`yes`)i.quiet||e.write(`\nDownloading ${v} from Hugging Face...\n`),await t(v,{cacheDir:a||i.cacheDir,stream:e,isTTY:p,service:i._transformersService,progress:!i.quiet&&i.progress!==!1&&!i.noProgress,quiet:i.quiet,verbose:i.verbose});else throw Error(`Model "${v}" is not downloaded. Download aborted.`)}else throw Error(`Model "${v}" is not downloaded. Run with --download or --yes to download model weights automatically.`)}}let y=i.baseUrl||i.providerBaseUrl||l?.baseUrl||c?.baseUrl||c?.providerBaseUrl;return y&&g&&(g={...g,baseUrl:y}),{providerId:u,providerConfig:g,apiKey:_||``,model:v,workspaceConfigData:o,workspaceConfig:s,workspaceSettings:c,workspaceAgent:l}}async function D7t(e,t,n,r,i,a,o){let s=[...t.TOOL_DEFINITIONS||[]];if(typeof t.loadDeclarativeTools==`function`)try{let r=await t.loadDeclarativeTools(e,n);if(r&&Array.isArray(r.tools))for(let e of r.tools)s.some(t=>t.name===e.name)||s.push(e)}catch{}let c=s.filter(e=>!Y9.has(e.name)),l=c,u=null;async function d(){let n=t.DEFAULT_BUILTIN_PROFILE||null,a=[];if(typeof t.getConfig==`function`)try{let n=await t.getConfig(e,t.CONFIG_KEYS?.TOOL_PROFILES||`tool_profiles`);typeof n==`string`?a=JSON.parse(n):Array.isArray(n)&&(a=n)}catch{}let o=r?.toolProfiles||i?.toolProfiles||r?.profiles||[];return[n,...a,...o].filter(Boolean)}if(o.noTools===!0||o.tools===!1||o.tools===`none`||o.tools===``)return l=[],{enabledTools:l,profileSystemPromptOverride:u};if(o.tools!==void 0&&o.tools!==null)return l=(Array.isArray(o.tools)?o.tools:String(o.tools).split(`,`)).map(e=>String(e).trim()).filter(Boolean).map(e=>c.find(t=>t.name===String(e))).filter(Boolean),{enabledTools:l,profileSystemPromptOverride:u};if(o.toolsProfile){let e=await d(),t=String(o.toolsProfile).trim().toLowerCase(),n=e.find(e=>e.id&&String(e.id).toLowerCase()===t||e.name&&String(e.name).toLowerCase()===t);if(!n)throw Error(`Error: Tool profile "${o.toolsProfile}" not found.`);let r=new Set(n.enabledToolNames||[]);if(l=c.filter(e=>r.has(e.name)),n.customTools&&Array.isArray(n.customTools))for(let e of n.customTools)!Y9.has(e.name)&&!l.some(t=>t.name===e.name)&&l.push(e);return n.systemPromptOverride&&(u=n.systemPromptOverride),{enabledTools:l,profileSystemPromptOverride:u}}let f=a?.tools??a?.enabledTools;if(f!=null)return f===!1||f===`none`||f===``?(l=[],{enabledTools:l,profileSystemPromptOverride:u}):(l=(Array.isArray(f)?f:String(f).split(`,`)).map(e=>String(e).trim()).filter(Boolean).map(e=>c.find(t=>t.name===e)).filter(Boolean),{enabledTools:l,profileSystemPromptOverride:u});let p=a?.toolsProfile||a?.defaultToolsProfile;if(p){let e=await d(),t=String(p).trim().toLowerCase(),n=e.find(e=>e.id&&String(e.id).toLowerCase()===t||e.name&&String(e.name).toLowerCase()===t);if(n){let e=new Set(n.enabledToolNames||[]);return l=c.filter(t=>e.has(t.name)),n.systemPromptOverride&&(u=n.systemPromptOverride),{enabledTools:l,profileSystemPromptOverride:u}}}return{enabledTools:l,profileSystemPromptOverride:u}}async function O7t(e,t={}){let{db:n,workspaceDir:i,core:a}=await N9(t),o=t.group||a.DEFAULT_SERVER_GROUP_ID||X9,s=t._stdinData??null;if(e===`-`?e=s||``:s&&(e=e?`${e}\n\n${s}`:s),!e){let e=`Error: Prompt required. Provide a prompt argument or pipe text to stdin.`;return t.quiet||console.error(e),r.exitCode=1,{success:!1,error:e}}let l=[],u=/* @__PURE__ */ new Map;try{let e=await L5t(I5t(t.file));for(let t of e)if(t.source?.kind===`local-file`){let e=await t.source.file.arrayBuffer();u.set(t.fileName,new Uint8Array(e))}l=await V5t(n,o,e);for(let e of l)e.path&&u.has(e.fileName)&&u.set(e.path,u.get(e.fileName))}catch(e){return t.quiet||console.error(e.message),r.exitCode=1,{success:!1,error:e.message}}let d,f,p,m,h,g,_,v;try{let e=await E7t(n,a,i,t);d=e.providerId,f=e.providerConfig,p=e.apiKey,m=e.model,h=e.workspaceConfigData,g=e.workspaceConfig,_=e.workspaceSettings,v=e.workspaceAgent}catch(e){return t.quiet||console.error(e.message),r.exitCode=1,{success:!1,error:e.message}}let y=t.internetAccess??t.allowInternet??_?.internetAccess??_?.vm_bash_full_internet_access??_?.fullInternetAccess??g?.internetAccess;if(y!==void 0&&typeof a.setConfig==`function`){let e=a.CONFIG_KEYS?.VM_BASH_FULL_INTERNET_ACCESS||`vm_bash_full_internet_access`;await a.setConfig(n,e,y?`true`:`false`)}if(f.requiresApiKey!==!1&&!p){let e=d===`huggingface`?`HUGGINGFACE_API_KEY`:`${d.toUpperCase()}_API_KEY`,n=`Error: Provider "${d}" requires an API key, but none was provided.\nPlease provide an API key via --api-key <key> or export ${e}="...".`;return t.quiet||console.error(n),r.exitCode=1,{success:!1,error:n}}let b=[];if(t.history!==!1&&typeof a.getRecentMessages==`function`)try{let e=await a.getRecentMessages(n,o,50);b=await Promise.all(e.map(async e=>{if(e?.role===`user`&&Array.isArray(e?.attachments)&&e.attachments.length>0){let t=await hk(e.attachments,async e=>{if(e.path&&n)try{return await ND(n,o,e.path)}catch{}return null});if(t.length>0){let n=typeof e.content==`string`?e.content:``;return{...e,content:n?[{type:`text`,text:n},...t]:t}}}return e}))}catch{}let x={id:`msg_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,groupId:o,role:`user`,sender:`user`,channel:`chat`,isFromMe:!1,isTrigger:!0,content:e,timestamp:Date.now(),...l.length>0?{attachments:l}:{}};if(typeof a.saveMessage==`function`)try{await a.saveMessage(n,x)}catch{}let S=x;if(l.length>0){let t=await hk(l,async e=>{if(e.path&&u.has(e.path))return u.get(e.path);if(u.has(e.fileName))return u.get(e.fileName);if(e.path&&n)try{return await ND(n,o,e.path)}catch{}return null});t.length>0&&(S={...x,content:e?[{type:`text`,text:e},...t]:t})}let C=f?.supportsStreaming===!0,w=t.stream!==!1&&t.streaming!==!1&&!t.noStream,T=C&&w,E=Number(t.maxTokens)||(typeof a.getModelMaxTokens==`function`?a.getModelMaxTokens(m):a.DEFAULT_MAX_TOKENS||8192);if(t.verbose&&!t.quiet){let e=f?.name||d,t=T?`streaming`:`standard`;r.stderr.write(`[Agent] Connecting to ${e} (${m}) [${t}]...\n`),r.stderr.write(`[Agent] Workspace: ${i}\n[Agent] Group: ${o}\n[Agent] Max tokens: ${E}\n`)}let D,O,k=!1,A=``,j=[];a.setPostHandler(async e=>{({"streaming-start":()=>{k=!0},"streaming-chunk":e=>{e.payload?.text&&(k=!0,A+=e.payload.text,D=(D||``)+e.payload.text,!t.quiet&&!t.output&&r.stdout.write(e.payload.text))},"streaming-done":()=>{},"streaming-end":()=>{k=!1,A=``},response:e=>{if(e.payload?.text){if(D=e.payload.text,t.output){let n=Ye(c.resolve(t.output),e.payload.text,`utf8`).then(()=>{t.quiet||r.stderr.write(`Output written to ${t.output}\n`)}).catch(()=>{});j.push(n)}else t.quiet||(k&&typeof A==`string`&&A.trim()===e.payload.text.trim()?e.payload.text.endsWith(`
8329
+ `);try{f.close()}catch{}typeof i.onExit==`function`?i.onExit(130):r.exit(130)}};f.on(`SIGINT`,h),c&&typeof c.on==`function`&&c!==r.stdin&&c.on(`SIGINT`,h);let g=()=>h();r.on(`SIGINT`,g);let _=e=>{let t=typeof e==`string`?e:e.toString(`binary`);(t.includes(``)||t.includes(``))&&h()};c&&typeof c.on==`function`&&c.on(`data`,_);let y=``;try{y=(await f.question(`\nModel "${v}" is not yet downloaded to local disk.\nDownload model weights now? (Y/n) [default: Y]: `)).trim().toLowerCase()}finally{r.removeListener(`SIGINT`,g),c&&typeof c.removeListener==`function`&&(c!==r.stdin&&c.removeListener(`SIGINT`,h),c.removeListener(`data`,_));try{f.close()}catch{}if(u){if(c&&typeof c.destroy==`function`)try{c.destroy()}catch{}if(d!=null)try{s.closeSync(d)}catch{}}}if(y===``||y===`y`||y===`yes`)i.quiet||e.write(`\nDownloading ${v} from Hugging Face...\n`),await t(v,{cacheDir:a||i.cacheDir,stream:e,isTTY:p,service:i._transformersService,progress:!i.quiet&&i.progress!==!1&&!i.noProgress,quiet:i.quiet,verbose:i.verbose});else throw Error(`Model "${v}" is not downloaded. Download aborted.`)}else throw Error(`Model "${v}" is not downloaded. Run with --download or --yes to download model weights automatically.`)}}let y=i.baseUrl||i.providerBaseUrl||l?.baseUrl||c?.baseUrl||c?.providerBaseUrl;return y&&g&&(g={...g,baseUrl:y}),{providerId:u,providerConfig:g,apiKey:_||``,model:v,workspaceConfigData:o,workspaceConfig:s,workspaceSettings:c,workspaceAgent:l}}async function D7t(e,t,n,r,i,a,o){let s=[...t.TOOL_DEFINITIONS||[]];if(typeof t.loadDeclarativeTools==`function`)try{let r=await t.loadDeclarativeTools(e,n);if(r&&Array.isArray(r.tools))for(let e of r.tools)s.some(t=>t.name===e.name)||s.push(e)}catch{}let c=s.filter(e=>!Y9.has(e.name)),l=c,u=null;async function d(){let n=t.DEFAULT_BUILTIN_PROFILE||null,a=[];if(typeof t.getConfig==`function`)try{let n=await t.getConfig(e,t.CONFIG_KEYS?.TOOL_PROFILES||`tool_profiles`);typeof n==`string`?a=JSON.parse(n):Array.isArray(n)&&(a=n)}catch{}let o=r?.toolProfiles||i?.toolProfiles||r?.profiles||[];return[n,...a,...o].filter(Boolean)}if(o.noTools===!0||o.tools===!1||o.tools===`none`||o.tools===``)return l=[],{enabledTools:l,profileSystemPromptOverride:u};if(o.tools!==void 0&&o.tools!==null)return l=(Array.isArray(o.tools)?o.tools:String(o.tools).split(`,`)).map(e=>String(e).trim()).filter(Boolean).map(e=>c.find(t=>t.name===String(e))).filter(Boolean),{enabledTools:l,profileSystemPromptOverride:u};if(o.toolsProfile){let e=await d(),t=String(o.toolsProfile).trim().toLowerCase(),n=e.find(e=>e.id&&String(e.id).toLowerCase()===t||e.name&&String(e.name).toLowerCase()===t);if(!n)throw Error(`Error: Tool profile "${o.toolsProfile}" not found.`);let r=new Set(n.enabledToolNames||[]);if(l=c.filter(e=>r.has(e.name)),n.customTools&&Array.isArray(n.customTools))for(let e of n.customTools)!Y9.has(e.name)&&!l.some(t=>t.name===e.name)&&l.push(e);return n.systemPromptOverride&&(u=n.systemPromptOverride),{enabledTools:l,profileSystemPromptOverride:u}}let f=a?.tools??a?.enabledTools;if(f!=null)return f===!1||f===`none`||f===``?(l=[],{enabledTools:l,profileSystemPromptOverride:u}):(l=(Array.isArray(f)?f:String(f).split(`,`)).map(e=>String(e).trim()).filter(Boolean).map(e=>c.find(t=>t.name===e)).filter(Boolean),{enabledTools:l,profileSystemPromptOverride:u});let p=a?.toolsProfile||a?.defaultToolsProfile;if(p){let e=await d(),t=String(p).trim().toLowerCase(),n=e.find(e=>e.id&&String(e.id).toLowerCase()===t||e.name&&String(e.name).toLowerCase()===t);if(n){let e=new Set(n.enabledToolNames||[]);return l=c.filter(t=>e.has(t.name)),n.systemPromptOverride&&(u=n.systemPromptOverride),{enabledTools:l,profileSystemPromptOverride:u}}}return{enabledTools:l,profileSystemPromptOverride:u}}async function O7t(e,t={}){let{db:n,workspaceDir:i,core:a}=await N9(t),o=t.group||a.DEFAULT_SERVER_GROUP_ID||X9,s=t._stdinData??null;if(e===`-`?e=s||``:s&&(e=e?`${e}\n\n${s}`:s),!e){let e=`Error: Prompt required. Provide a prompt argument or pipe text to stdin.`;return t.quiet||console.error(e),r.exitCode=1,{success:!1,error:e}}let l=typeof t.maxImageSize==`number`&&t.maxImageSize>0?Math.round(t.maxImageSize*1024*1024):3145728,u=[],d=/* @__PURE__ */ new Map;try{let e=await L5t(I5t(t.file));for(let t of e)if(t.source?.kind===`local-file`){let e=await t.source.file.arrayBuffer();d.set(t.fileName,new Uint8Array(e))}u=await V5t(n,o,e);for(let e of u)e.path&&d.has(e.fileName)&&d.set(e.path,d.get(e.fileName))}catch(e){return t.quiet||console.error(e.message),r.exitCode=1,{success:!1,error:e.message}}let f,p,m,h,g,_,v,y;try{let e=await E7t(n,a,i,t);f=e.providerId,p=e.providerConfig,m=e.apiKey,h=e.model,g=e.workspaceConfigData,_=e.workspaceConfig,v=e.workspaceSettings,y=e.workspaceAgent}catch(e){return t.quiet||console.error(e.message),r.exitCode=1,{success:!1,error:e.message}}let b=t.internetAccess??t.allowInternet??v?.internetAccess??v?.vm_bash_full_internet_access??v?.fullInternetAccess??_?.internetAccess;if(b!==void 0&&typeof a.setConfig==`function`){let e=a.CONFIG_KEYS?.VM_BASH_FULL_INTERNET_ACCESS||`vm_bash_full_internet_access`;await a.setConfig(n,e,b?`true`:`false`)}if(p.requiresApiKey!==!1&&!m){let e=f===`huggingface`?`HUGGINGFACE_API_KEY`:`${f.toUpperCase()}_API_KEY`,n=`Error: Provider "${f}" requires an API key, but none was provided.\nPlease provide an API key via --api-key <key> or export ${e}="...".`;return t.quiet||console.error(n),r.exitCode=1,{success:!1,error:n}}let x=[];if(t.history!==!1&&typeof a.getRecentMessages==`function`)try{let e=await a.getRecentMessages(n,o,50);x=await Promise.all(e.map(async e=>{if(e?.role===`user`&&Array.isArray(e?.attachments)&&e.attachments.length>0){let t=await hk(e.attachments,async e=>{if(e.path&&n)try{return await ND(n,o,e.path)}catch{}return null},{maxImageBytes:l});if(t.length>0){let n=typeof e.content==`string`?e.content:``;return{...e,content:n?[{type:`text`,text:n},...t]:t}}}return e}))}catch{}let S={id:`msg_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,groupId:o,role:`user`,sender:`user`,channel:`chat`,isFromMe:!1,isTrigger:!0,content:e,timestamp:Date.now(),...u.length>0?{attachments:u}:{}};if(typeof a.saveMessage==`function`)try{await a.saveMessage(n,S)}catch{}let C=S;if(u.length>0){let t=await hk(u,async e=>{if(e.path&&d.has(e.path))return d.get(e.path);if(d.has(e.fileName))return d.get(e.fileName);if(e.path&&n)try{return await ND(n,o,e.path)}catch{}return null},{maxImageBytes:l});t.length>0&&(C={...S,content:e?[{type:`text`,text:e},...t]:t})}let w=p?.supportsStreaming===!0,T=t.stream!==!1&&t.streaming!==!1&&!t.noStream,E=w&&T,D=Number(t.maxTokens)||(typeof a.getModelMaxTokens==`function`?a.getModelMaxTokens(h):a.DEFAULT_MAX_TOKENS||8192);if(t.verbose&&!t.quiet){let e=p?.name||f,t=E?`streaming`:`standard`;r.stderr.write(`[Agent] Connecting to ${e} (${h}) [${t}]...\n`),r.stderr.write(`[Agent] Workspace: ${i}\n[Agent] Group: ${o}\n[Agent] Max tokens: ${D}\n`)}let O,k,A=!1,j=``,M=[];a.setPostHandler(async e=>{({"streaming-start":()=>{A=!0},"streaming-chunk":e=>{e.payload?.text&&(A=!0,j+=e.payload.text,O=(O||``)+e.payload.text,!t.quiet&&!t.output&&r.stdout.write(e.payload.text))},"streaming-done":()=>{},"streaming-error":e=>{e.payload?.error&&(k=e.payload.error,t.quiet||console.error(`Error: ${e.payload.error}`))},"streaming-end":()=>{A=!1,j=``},response:e=>{if(e.payload?.text){if(O=e.payload.text,t.output){let n=Ye(c.resolve(t.output),e.payload.text,`utf8`).then(()=>{t.quiet||r.stderr.write(`Output written to ${t.output}\n`)}).catch(()=>{});M.push(n)}else t.quiet||(A&&typeof j==`string`&&j.trim()===e.payload.text.trim()?e.payload.text.endsWith(`
8330
8330
  `)||r.stdout.write(`
8331
8331
  `):r.stdout.write(e.payload.text+`
8332
- `))}},"intermediate-response":e=>{t.verbose&&!t.quiet&&e.payload?.text&&r.stderr.write(`[Thought] ${e.payload.text}\n`)},error:e=>{e.payload?.error&&(O=e.payload.error,t.quiet||console.error(`Error: ${e.payload.error}`))},"tool-activity":e=>{if(t.verbose&&!t.quiet&&e.payload){let t=e.payload.tool||`tool`,n=e.payload.status||`executing`;r.stderr.write(`[Tool] ${t} (${n})\n`)}},"thinking-log":e=>{if(t.verbose&&!t.quiet&&e.payload){let t=e.payload.label||e.payload.level||`Log`;r.stderr.write(`[${t}] ${e.payload.message||``}\n`)}},status:e=>{if(t.verbose&&!t.quiet&&e.payload){let t=e.payload.label?`[${e.payload.label}] `:``;r.stderr.write(`${t}${e.payload.message||``}\n`)}},log:e=>{if(t.verbose&&!t.quiet&&e.payload){let t=e.payload.label||e.payload.level||`Log`;r.stderr.write(`[${t}] ${e.payload.message||``}\n`)}},"token-usage":e=>{if(t.verbose&&!t.quiet&&e.payload?.usage){let t=e.payload.usage,n=t.prompt_tokens??t.input_tokens??0,i=t.completion_tokens??t.output_tokens??0,a=t.total_tokens??n+i;r.stderr.write(`[Tokens] Prompt: ${n}, Completion: ${i}, Total: ${a}\n`)}},"request-native-ai-task":e=>{A5t(a,n,e.payload)}})[e.type]?.(e)});let M;try{M=await D7t(n,a,o,g,_,v,t)}catch(e){let n=e.message||String(e);return t.quiet||console.error(n),r.exitCode=1,{success:!1,error:n}}let{enabledTools:ee,profileSystemPromptOverride:te}=M;if(ee.length>0&&!t.quiet){let{getCuratedModelToolSupport:e}=await Promise.resolve().then(()=>(G9(),F9));e(m)===!1&&r.stderr.write(`[Agent] Warning: Model "${m}" does not support tool calling; tools will be ignored. Use --tools none or choose a tool-capable model (e.g. onnx-community/gemma-4-E2B-it-ONNX).\n`)}if(l.length>0&&!t.quiet){let e=pk(m);for(let t of l){let n=dtt(t.mimeType,t.fileName);n===`image`&&!e.images&&!e.routerByFeatures?r.stderr.write(`[Agent] Warning: Model "${m}" does not accept image input; "${t.fileName}" will be passed as a reference only.\n`):n===`audio`&&!e.audio&&!e.routerByFeatures?r.stderr.write(`[Agent] Warning: Model "${m}" does not accept audio input; "${t.fileName}" will be passed as a reference only.\n`):n===`video`&&!e.video&&!e.routerByFeatures?r.stderr.write(`[Agent] Warning: Model "${m}" does not accept video input; "${t.fileName}" will be passed as a reference only.\n`):n===`document`&&!e.documents&&!e.routerByFeatures&&r.stderr.write(`[Agent] Warning: Model "${m}" does not accept PDF/document input; "${t.fileName}" will be passed as a reference only.\n`)}}let ne;if(t.systemPrompt===`none`||t.systemPrompt===``||t.systemPrompt===!1||t.noSystemPrompt===!0)ne=``;else{if(ne=t.systemPrompt,!ne&&t.systemPromptFile)try{let e=c.resolve(t.systemPromptFile);ne=await He(e,`utf8`)}catch(e){let n=`Error: Failed to read system prompt file "${t.systemPromptFile}": ${e.message}`;return t.quiet||console.error(n),r.exitCode=1,{success:!1,error:n}}if(ne||=r.env.SHADOW_CLAW_SYSTEM_PROMPT||r.env.SHADOWCLAW_SYSTEM_PROMPT,!ne&&te&&(ne=te),!ne&&v?.systemPromptFile)try{let e=h?.configPath?c.dirname(h.configPath):i,t=c.resolve(e,v.systemPromptFile);ne=await He(t,`utf8`)}catch(e){t.verbose&&!t.quiet&&console.error(`Warning: Failed to read systemPromptFile from config: ${e.message}`)}if(ne||=v?.systemPrompt||_?.systemPrompt||_?.systemPromptOverride,!ne&&typeof a.getConfig==`function`)try{let e=await a.getConfig(n,a.CONFIG_KEYS?.SYSTEM_PROMPT_OVERRIDE||`system_prompt_override`);e&&typeof e==`string`&&(ne=e)}catch{}ne||=`You are ShadowClaw, a helpful AI assistant operating in a headless workspace. Answer concisely.`}let re={apiKey:p||``,assistantName:`ShadowClaw`,enabledTools:ee,groupId:o,maxTokens:E,messages:[...b,S],model:m,provider:d,...f?.baseUrl?{baseUrl:f.baseUrl}:{},streaming:T,verbose:!!t.verbose,systemPrompt:ne},N=new AbortController;t.abortSignal&&(t.abortSignal.aborted?N.abort():t.abortSignal.addEventListener(`abort`,()=>N.abort(),{once:!0}));let ie=e=>{typeof t.onExit==`function`?t.onExit(e):!r.env.JEST_WORKER_ID&&r.env.NODE_ENV!==`test`&&r.exit(e)},ae=!1,oe=null,se=()=>{if(ae)oe&&=(clearTimeout(oe),null),ie(130);else{ae=!0,N.abort();try{typeof a.cleanupAllLlamafileProcesses==`function`&&a.cleanupAllLlamafileProcesses()}catch{}oe=setTimeout(()=>{ie(130)},1500),oe.unref?.()}};r.on(`SIGINT`,se);let ce=t.invokeHandler||a.handleInvoke;try{await ce(n,re,N.signal)}catch(e){O=e instanceof Error?e.message:String(e),!ae&&!t.quiet&&console.error(`Error: ${O}`)}finally{r.removeListener(`SIGINT`,se),oe&&=(clearTimeout(oe),null)}if(ae)return t.quiet||r.stderr.write(`
8332
+ `))}},"intermediate-response":e=>{t.verbose&&!t.quiet&&e.payload?.text&&r.stderr.write(`[Thought] ${e.payload.text}\n`)},error:e=>{e.payload?.error&&(k=e.payload.error,t.quiet||console.error(`Error: ${e.payload.error}`))},"tool-activity":e=>{if(t.verbose&&!t.quiet&&e.payload){let t=e.payload.tool||`tool`,n=e.payload.status||`executing`;r.stderr.write(`[Tool] ${t} (${n})\n`)}},"thinking-log":e=>{if(t.verbose&&!t.quiet&&e.payload){let t=e.payload.label||e.payload.level||`Log`;r.stderr.write(`[${t}] ${e.payload.message||``}\n`)}},status:e=>{if(t.verbose&&!t.quiet&&e.payload){let t=e.payload.label?`[${e.payload.label}] `:``;r.stderr.write(`${t}${e.payload.message||``}\n`)}},log:e=>{if(t.verbose&&!t.quiet&&e.payload){let t=e.payload.label||e.payload.level||`Log`;r.stderr.write(`[${t}] ${e.payload.message||``}\n`)}},"token-usage":e=>{if(t.verbose&&!t.quiet&&e.payload?.usage){let t=e.payload.usage,n=t.prompt_tokens??t.input_tokens??0,i=t.completion_tokens??t.output_tokens??0,a=t.total_tokens??n+i;r.stderr.write(`[Tokens] Prompt: ${n}, Completion: ${i}, Total: ${a}\n`)}},"request-native-ai-task":e=>{A5t(a,n,e.payload)}})[e.type]?.(e)});let ee;try{ee=await D7t(n,a,o,_,v,y,t)}catch(e){let n=e.message||String(e);return t.quiet||console.error(n),r.exitCode=1,{success:!1,error:n}}let{enabledTools:te,profileSystemPromptOverride:ne}=ee;if(te.length>0&&!t.quiet){let{getCuratedModelToolSupport:e}=await Promise.resolve().then(()=>(G9(),F9));e(h)===!1&&r.stderr.write(`[Agent] Warning: Model "${h}" does not support tool calling; tools will be ignored. Use --tools none or choose a tool-capable model (e.g. onnx-community/gemma-4-E2B-it-ONNX).\n`)}if(u.length>0&&!t.quiet){let e=pk(h);for(let t of u){let n=dtt(t.mimeType,t.fileName);n===`image`&&!e.images&&!e.routerByFeatures?r.stderr.write(`[Agent] Warning: Model "${h}" does not accept image input; "${t.fileName}" will be passed as a reference only.\n`):n===`audio`&&!e.audio&&!e.routerByFeatures?r.stderr.write(`[Agent] Warning: Model "${h}" does not accept audio input; "${t.fileName}" will be passed as a reference only.\n`):n===`video`&&!e.video&&!e.routerByFeatures?r.stderr.write(`[Agent] Warning: Model "${h}" does not accept video input; "${t.fileName}" will be passed as a reference only.\n`):n===`document`&&!e.documents&&!e.routerByFeatures&&r.stderr.write(`[Agent] Warning: Model "${h}" does not accept PDF/document input; "${t.fileName}" will be passed as a reference only.\n`);let i=typeof t.size==`number`?t.size:0;n===`image`&&i>l?r.stderr.write(`[Agent] Warning: "${t.fileName}" is ${(i/1024/1024).toFixed(1)} MB — exceeds the ${(l/1024/1024).toFixed(0)} MB image limit and will be passed as a text reference only. Resize or compress the image before attaching.\n`):n===`audio`&&i>5242880?r.stderr.write(`[Agent] Warning: "${t.fileName}" is ${(i/1024/1024).toFixed(1)} MB — exceeds the 5 MB audio limit and will be passed as a text reference only.\n`):n===`document`&&i>20971520&&r.stderr.write(`[Agent] Warning: "${t.fileName}" is ${(i/1024/1024).toFixed(1)} MB — exceeds the 20 MB document limit and will be passed as a text reference only.\n`)}}let re;if(t.systemPrompt===`none`||t.systemPrompt===``||t.systemPrompt===!1||t.noSystemPrompt===!0)re=``;else{if(re=t.systemPrompt,!re&&t.systemPromptFile)try{let e=c.resolve(t.systemPromptFile);re=await He(e,`utf8`)}catch(e){let n=`Error: Failed to read system prompt file "${t.systemPromptFile}": ${e.message}`;return t.quiet||console.error(n),r.exitCode=1,{success:!1,error:n}}if(re||=r.env.SHADOW_CLAW_SYSTEM_PROMPT||r.env.SHADOWCLAW_SYSTEM_PROMPT,!re&&ne&&(re=ne),!re&&y?.systemPromptFile)try{let e=g?.configPath?c.dirname(g.configPath):i,t=c.resolve(e,y.systemPromptFile);re=await He(t,`utf8`)}catch(e){t.verbose&&!t.quiet&&console.error(`Warning: Failed to read systemPromptFile from config: ${e.message}`)}if(re||=y?.systemPrompt||v?.systemPrompt||v?.systemPromptOverride,!re&&typeof a.getConfig==`function`)try{let e=await a.getConfig(n,a.CONFIG_KEYS?.SYSTEM_PROMPT_OVERRIDE||`system_prompt_override`);e&&typeof e==`string`&&(re=e)}catch{}re||=`You are ShadowClaw, a helpful AI assistant operating in a headless workspace. Answer concisely.`}let N={apiKey:m||``,assistantName:`ShadowClaw`,enabledTools:te,groupId:o,maxTokens:D,messages:[...x,C],model:h,provider:f,...p?.baseUrl?{baseUrl:p.baseUrl}:{},streaming:E,verbose:!!t.verbose,systemPrompt:re},ie=new AbortController;t.abortSignal&&(t.abortSignal.aborted?ie.abort():t.abortSignal.addEventListener(`abort`,()=>ie.abort(),{once:!0}));let ae=e=>{typeof t.onExit==`function`?t.onExit(e):!r.env.JEST_WORKER_ID&&r.env.NODE_ENV!==`test`&&r.exit(e)},oe=!1,se=null,ce=()=>{if(oe)se&&=(clearTimeout(se),null),ae(130);else{oe=!0,ie.abort();try{typeof a.cleanupAllLlamafileProcesses==`function`&&a.cleanupAllLlamafileProcesses()}catch{}se=setTimeout(()=>{ae(130)},1500),se.unref?.()}};r.on(`SIGINT`,ce);let le=t.invokeHandler||a.handleInvoke;try{await le(n,N,ie.signal)}catch(e){k=e instanceof Error?e.message:String(e),!oe&&!t.quiet&&console.error(`Error: ${k}`)}finally{r.removeListener(`SIGINT`,ce),se&&=(clearTimeout(se),null)}if(oe)return t.quiet||r.stderr.write(`
8333
8333
  Operation cancelled.
8334
- `),r.exitCode=130,typeof t.onExit==`function`&&t.onExit(130),{success:!1,error:`Operation cancelled.`};if(O&&k&&!t.quiet&&!t.output&&r.stdout.write(`
8335
- `),O)return r.exitCode=1,{success:!1,error:O};if(D&&typeof a.saveMessage==`function`)try{await a.saveMessage(n,{id:`msg_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,groupId:o,role:`assistant`,content:D,timestamp:Date.now()})}catch{}if(t.output&&D&&j.length===0){let e=Ye(c.resolve(t.output),D,`utf8`).then(()=>{t.quiet||r.stderr.write(`Output written to ${t.output}\n`)}).catch(()=>{});j.push(e)}return await Promise.all(j),typeof a.setPostHandler==`function`&&a.setPostHandler(null),{success:!0,response:D,model:m,provider:d}}async function k7t(e=`list`,t,n={}){let{listLocalModels:i,listLlamafileModels:a,downloadLocalModel:o,fetchRemoteModels:s,DEFAULT_LOCAL_MODEL:l}=await Promise.resolve().then(()=>(G9(),F9)),u=n.workspace?c.resolve(n.workspace):r.cwd(),d=e||`list`;if(d===`list`||d===`remote`){let e=d===`remote`||!!(n.remote||n.all||n.huggingface),o=await M9(u),c=o?.config?.agent?.defaultModel||o?.config?.settings?.defaultModel||l;if(e){n.quiet||r.stdout.write(`
8334
+ `),r.exitCode=130,typeof t.onExit==`function`&&t.onExit(130),{success:!1,error:`Operation cancelled.`};if(k&&A&&!t.quiet&&!t.output&&r.stdout.write(`
8335
+ `),k)return r.exitCode=1,{success:!1,error:k};if(O&&typeof a.saveMessage==`function`)try{await a.saveMessage(n,{id:`msg_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,groupId:o,role:`assistant`,content:O,timestamp:Date.now()})}catch{}if(t.output&&O&&M.length===0){let e=Ye(c.resolve(t.output),O,`utf8`).then(()=>{t.quiet||r.stderr.write(`Output written to ${t.output}\n`)}).catch(()=>{});M.push(e)}return await Promise.all(M),typeof a.setPostHandler==`function`&&a.setPostHandler(null),{success:!0,response:O,model:h,provider:f}}async function k7t(e=`list`,t,n={}){let{listLocalModels:i,listLlamafileModels:a,downloadLocalModel:o,fetchRemoteModels:s,DEFAULT_LOCAL_MODEL:l}=await Promise.resolve().then(()=>(G9(),F9)),u=n.workspace?c.resolve(n.workspace):r.cwd(),d=e||`list`;if(d===`list`||d===`remote`){let e=d===`remote`||!!(n.remote||n.all||n.huggingface),o=await M9(u),c=o?.config?.agent?.defaultModel||o?.config?.settings?.defaultModel||l;if(e){n.quiet||r.stdout.write(`
8336
8336
  Fetching available ONNX models from Hugging Face (onnx-community)...
8337
8337
  `);let e=await s({cacheDir:n.cacheDir,query:n.query||(d===`remote`&&t?t:void 0)});if(!n.quiet){if(e.length===0)r.stdout.write(`No models found on Hugging Face or could not reach huggingface.co.
8338
8338
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadow-claw",
3
- "version": "1.59.6",
3
+ "version": "1.60.0",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "ShadowClaw - multi-runtime AI assistant.",
@@ -1 +0,0 @@
1
- import{a as e,n as t}from"./chunk-BeREXUw8.js";async function n(n=[],r,i={}){let a=i.maxInlineTextBytes??102400,o=[];for(let i of n){let n=i.mimeType||`application/octet-stream`,s=t(n,i.fileName),c=s===`text`?`file`:s===`document`?`document`:s,l=null;try{l=await r(i)}catch{l=null}let u=l?.length??(typeof i.size==`number`?i.size:0);if(s===`text`&&l&&u<=a)try{let e=new TextDecoder(`utf-8`).decode(l),t=e.includes("```")?`~~~~`:"```";o.push({type:`text`,text:`Attachment: ${i.fileName}\n${t}\n${e}\n${t}`});continue}catch{}let d={type:`attachment`,mediaType:c,fileName:i.fileName,mimeType:n,size:i.size,path:i.path};l&&(c===`image`&&u<=3145728||c===`audio`&&u<=5242880||c===`document`&&u<=20971520)&&(d.data=e(l)),o.push(d)}return o}export{n as t};