shadow-claw 1.23.3 → 1.24.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 (286) hide show
  1. package/README.md +42 -5
  2. package/bin/assert-version-bump.mjs +60 -38
  3. package/bin/assert-version-bump.test.mjs +74 -11
  4. package/bin/cli.mjs +166 -0
  5. package/bin/cli.test.mjs +60 -0
  6. package/bin/commands/backup.mjs +70 -0
  7. package/bin/commands/clients.mjs +41 -0
  8. package/bin/commands/peer-id.mjs +76 -0
  9. package/bin/commands/peer-id.test.mjs +104 -0
  10. package/bin/commands/send.mjs +51 -0
  11. package/bin/commands/tasks.mjs +59 -0
  12. package/bin/commands/webrtc-listen.mjs +254 -0
  13. package/bin/prerender-dsd-shell/prerender-dsd-shell.test.mjs +46 -0
  14. package/bin/rolldown.config.test.mjs +401 -8
  15. package/bin/utils/control-client.mjs +243 -0
  16. package/bin/utils/control-client.test.mjs +83 -0
  17. package/bin/utils/ulid.mjs +45 -0
  18. package/bin/utils/webrtc-control-client.mjs +699 -0
  19. package/bin/utils/webrtc-control-client.test.mjs +318 -0
  20. package/dist/electron/main.cjs +1 -1
  21. package/dist/public/AGENTS.md +5 -3
  22. package/dist/public/README.md +42 -5
  23. package/dist/public/agent.worker.js +6 -6
  24. package/dist/public/{app-routes-B0ePT49v.js → app-routes-Bs-riIvr.js} +1 -1
  25. package/dist/public/backup-controller-C_s9in2t.js +1 -0
  26. package/dist/public/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.css +1 -0
  27. package/dist/public/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.html +1 -0
  28. package/dist/public/components/settings/shadow-claw-storage/shadow-claw-storage.html +1 -1
  29. package/dist/public/components/settings/shadow-claw-task-server/shadow-claw-task-server.css +1 -1
  30. package/dist/public/components/settings/shadow-claw-task-server/shadow-claw-task-server.html +1 -1
  31. package/dist/public/components/shadow-claw-files/shadow-claw-files.css +1 -1
  32. package/dist/public/components/shadow-claw-files/shadow-claw-files.html +1 -1
  33. package/dist/public/components/shadow-claw-settings/shadow-claw-settings.html +1 -1
  34. package/dist/public/config-CrHchneq.js +1 -0
  35. package/dist/public/{configurePeerJs-B7kNU8AQ.js → configurePeerJs-CxpZeDJJ.js} +1 -1
  36. package/dist/public/{connections-xd_66YVU.js → connections-DvbgdkaB.js} +1 -1
  37. package/dist/public/{custom-element-security-CZ92anB8.js → custom-element-security-NCqQ5lmC.js} +1 -1
  38. package/dist/public/docs/README.md +3 -1
  39. package/dist/public/docs/architecture/overview.md +12 -12
  40. package/dist/public/docs/architecture/storage.md +5 -2
  41. package/dist/public/docs/decisions/bundled-typescript-architecture.md +1 -1
  42. package/dist/public/docs/decisions/indexeddb-and-opfs-storage.md +6 -3
  43. package/dist/public/docs/decisions/native-web-components-and-signals.md +1 -1
  44. package/dist/public/docs/example/article/index.html +2 -2
  45. package/dist/public/docs/guides/configuring-messaging-channels.md +41 -6
  46. package/dist/public/docs/guides/server-development-configuration.md +24 -0
  47. package/dist/public/docs/publishing/index.html +19 -76
  48. package/dist/public/docs/skill-creator/index.html +2 -2
  49. package/dist/public/docs/subsystems/backup.md +56 -0
  50. package/dist/public/docs/subsystems/cli.md +124 -0
  51. package/dist/public/docs/subsystems/control-plane.md +158 -0
  52. package/dist/public/docs/subsystems/notifications.md +54 -2
  53. package/dist/public/docs/subsystems/reactive-ui.md +1 -0
  54. package/dist/public/downloadGroupFile-By0GR6eV.js +1 -0
  55. package/dist/public/e2e/README.md +5 -1
  56. package/dist/public/{e2e-bridge-DkS5xFGX.js → e2e-bridge-IGWsRl4i.js} +1 -1
  57. package/dist/public/file-viewer-D0eflgt6.js +1 -0
  58. package/dist/public/files/main/~/docs/publishing-to-github-pages.md +17 -82
  59. package/dist/public/getAllTasks-vpBlgGsc.js +1 -0
  60. package/dist/public/getGroupDir-P1h9wl6S.js +1 -0
  61. package/dist/public/{git-BkjrsRXX.js → git-7Vq_SJSp.js} +2 -2
  62. package/dist/public/{iframe-sanitizer-L6Jyu__Z.js → iframe-sanitizer-y2Z1pPwY.js} +1 -1
  63. package/dist/public/index.html +2 -2
  64. package/dist/public/index.js +1 -1
  65. package/dist/public/{initChatSplitResize-BslPXAXS.js → initChatSplitResize-CzV2E7Ul.js} +1 -1
  66. package/dist/public/initControlPlane-C9jpnWev.js +1 -0
  67. package/dist/public/llms.txt +1 -1
  68. package/dist/public/main/index.html +2 -2
  69. package/dist/public/main/memory/index.html +2 -2
  70. package/dist/public/{markdown-6MBrIo-S.js → markdown-BnpKxSxl.js} +1 -1
  71. package/dist/public/mcp-reconnect-9emsqGRe.js +1 -0
  72. package/dist/public/{memoryStorage-CjGseKI1.js → memoryStorage-C0KvLNUp.js} +1 -1
  73. package/dist/public/{orchestrator-B9KmIj8Q.js → orchestrator-3h9xxHUm.js} +676 -676
  74. package/dist/public/orchestrator-nJj59RqD.js +15 -0
  75. package/dist/public/pages/main/~/docs/publishing-to-github-pages.md +17 -82
  76. package/dist/public/{peerjs-Dv8JNm7v.js → peerjs-BP4laMXj.js} +1 -1
  77. package/dist/public/{push-client-Dqq06wbB.js → push-client-CrjEXK3U.js} +1 -1
  78. package/dist/public/service-worker/fetch-proxy.js +1 -1
  79. package/dist/public/service-worker/push-handler.js +1 -1
  80. package/dist/public/service-worker.js +1 -1
  81. package/dist/public/{shadow-claw-Bd1rfuVC.js → shadow-claw-CbwETBWf.js} +2 -2
  82. package/dist/public/{shadow-claw-accounts-DL2l3oM0.js → shadow-claw-accounts-B4sBTQEj.js} +3 -3
  83. package/dist/public/{shadow-claw-channels-BGXDsQ38.js → shadow-claw-channels-BDWG5Qa3.js} +1 -1
  84. package/dist/public/{shadow-claw-chat-NXg6zz_l.js → shadow-claw-chat-Crv0DTCY.js} +6 -6
  85. package/dist/public/shadow-claw-control-plane-CX1IGbh9.js +199 -0
  86. package/dist/public/{shadow-claw-conversations-C8eqGpP9.js → shadow-claw-conversations-_9qAaRXk.js} +1 -1
  87. package/dist/public/shadow-claw-dialog-BrOwAOdk.js +1 -0
  88. package/dist/public/shadow-claw-file-viewer-Blf6yGVD.js +577 -0
  89. package/dist/public/shadow-claw-files-CYySBDCl.js +840 -0
  90. package/dist/public/{shadow-claw-git-C0ntz7aX.js → shadow-claw-git-v8S0JjuR.js} +3 -3
  91. package/dist/public/{shadow-claw-integrations-DCXV2r69.js → shadow-claw-integrations-D7ufpwhX.js} +1 -1
  92. package/dist/public/{shadow-claw-llm-CudgFQsS.js → shadow-claw-llm-GWgoVfhI.js} +2 -2
  93. package/dist/public/{shadow-claw-mcp-remote-B8RkpX28.js → shadow-claw-mcp-remote-kY4LMFNN.js} +1 -1
  94. package/dist/public/{shadow-claw-networking-BLiRsrsK.js → shadow-claw-networking-qHbP95z9.js} +1 -1
  95. package/dist/public/{shadow-claw-notifications-CQhQcjtL.js → shadow-claw-notifications-YyHOK2Fr.js} +1 -1
  96. package/dist/public/{shadow-claw-page-header-NeRD0tKU.js → shadow-claw-page-header-DMKbkv3s.js} +1 -1
  97. package/dist/public/{shadow-claw-pages-DCHnFh6r.js → shadow-claw-pages-DFZHhzFZ.js} +3 -3
  98. package/dist/public/{shadow-claw-settings-VAfjKFQg.js → shadow-claw-settings-DhxrKIfA.js} +10 -3
  99. package/dist/public/shadow-claw-storage-BFynbP0j.js +219 -0
  100. package/dist/public/{shadow-claw-task-server-Dk33N_1G.js → shadow-claw-task-server-3BIeb5oZ.js} +25 -4
  101. package/dist/public/{shadow-claw-tasks-xA1VfmWN.js → shadow-claw-tasks-Caxc9atL.js} +4 -4
  102. package/dist/public/{shadow-claw-terminal-Du2r0ciq.js → shadow-claw-terminal-Beb5qF-U.js} +1 -1
  103. package/dist/public/{shadow-claw-tools-CZj4rq7l.js → shadow-claw-tools-BfJx3A9W.js} +2 -2
  104. package/dist/public/{shadow-claw-webvm-JYUkWICG.js → shadow-claw-webvm-BCS8ykeP.js} +1 -1
  105. package/dist/public/static-main/~/docs/publishing-to-github-pages.md +17 -82
  106. package/dist/public/static-main-manifest.json +1 -1
  107. package/dist/public/{syncWebMcpRegistration-DfpvASnh.js → syncWebMcpRegistration-B_M2fCjH.js} +1 -1
  108. package/dist/server.js +286 -189
  109. package/package.json +2 -1
  110. package/src/__mocks__/jszip.cjs +15 -5
  111. package/src/components/settings/shadow-claw-accounts/shadow-claw-accounts.test.ts +35 -0
  112. package/src/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.css +117 -0
  113. package/src/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.html +81 -0
  114. package/src/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.test.ts +127 -0
  115. package/src/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.ts +292 -0
  116. package/src/components/settings/shadow-claw-git/shadow-claw-git.test.ts +72 -0
  117. package/src/components/settings/shadow-claw-integrations/connection-test-auth.test.ts +20 -30
  118. package/src/components/settings/shadow-claw-integrations/shadow-claw-integrations.test.ts +116 -0
  119. package/src/components/settings/shadow-claw-llm/model-ranking.test.ts +143 -51
  120. package/src/components/settings/shadow-claw-llm/shadow-claw-llm.test.ts +307 -4
  121. package/src/components/settings/shadow-claw-llm/shadow-claw-llm.ts +8 -8
  122. package/src/components/settings/shadow-claw-mcp-remote/shadow-claw-mcp-remote.test.ts +31 -0
  123. package/src/components/settings/shadow-claw-peerjs/shadow-claw-peerjs.test.ts +186 -0
  124. package/src/components/settings/shadow-claw-storage/shadow-claw-storage.html +17 -0
  125. package/src/components/settings/shadow-claw-storage/shadow-claw-storage.test.ts +120 -0
  126. package/src/components/settings/shadow-claw-storage/shadow-claw-storage.ts +56 -0
  127. package/src/components/settings/shadow-claw-task-server/shadow-claw-task-server.css +23 -2
  128. package/src/components/settings/shadow-claw-task-server/shadow-claw-task-server.html +1 -1
  129. package/src/components/settings/shadow-claw-task-server/shadow-claw-task-server.test.ts +19 -0
  130. package/src/components/settings/shadow-claw-task-server/shadow-claw-task-server.ts +2 -1
  131. package/src/components/shadow-claw/utils/initChatSplitResize.test.ts +180 -13
  132. package/src/components/shadow-claw/utils/setupEffects.test.ts +39 -0
  133. package/src/components/shadow-claw-a2ui/catalog/basic/shared.test.ts +117 -0
  134. package/src/components/shadow-claw-a2ui/shadow-claw-a2ui.test.ts +1159 -1
  135. package/src/components/shadow-claw-chat/shadow-claw-chat.test.ts +1523 -19
  136. package/src/components/shadow-claw-chat/utils/escapeHtml.test.ts +13 -0
  137. package/src/components/shadow-claw-chat/utils/getPeerChatDisplayStatus.test.ts +20 -0
  138. package/src/components/shadow-claw-conversations/shadow-claw-conversations.test.ts +494 -0
  139. package/src/components/shadow-claw-dialog/shadow-claw-dialog.ts +13 -2
  140. package/src/components/shadow-claw-file-viewer/shadow-claw-file-viewer.test.ts +378 -0
  141. package/src/components/shadow-claw-file-viewer/shadow-claw-file-viewer.ts +11 -9
  142. package/src/components/shadow-claw-files/shadow-claw-files.css +41 -17
  143. package/src/components/shadow-claw-files/shadow-claw-files.html +35 -0
  144. package/src/components/shadow-claw-files/shadow-claw-files.test.ts +627 -1
  145. package/src/components/shadow-claw-files/shadow-claw-files.ts +170 -6
  146. package/src/components/shadow-claw-pages/utils/resolveWorkspaceLinkPath.test.ts +31 -0
  147. package/src/components/shadow-claw-pages/utils/resolveWorkspaceLinkPath.ts +2 -1
  148. package/src/components/shadow-claw-pages/utils/rewriteWorkspacePreviewHtml.test.ts +15 -0
  149. package/src/components/shadow-claw-pdf-viewer/utils/installGetOrInsertComputedPolyfill.test.ts +65 -0
  150. package/src/components/shadow-claw-settings/shadow-claw-settings.html +7 -0
  151. package/src/components/shadow-claw-settings/shadow-claw-settings.test.ts +221 -0
  152. package/src/components/shadow-claw-settings/shadow-claw-settings.ts +2 -0
  153. package/src/components/shadow-claw-tasks/shadow-claw-tasks.test.ts +407 -0
  154. package/src/components/shadow-claw-terminal/utils/consumeEscapeSequence.test.ts +58 -0
  155. package/src/components/shadow-claw-tools/shadow-claw-tools.test.ts +80 -0
  156. package/src/config/config.test.ts +9 -0
  157. package/src/config/config.ts +15 -0
  158. package/src/core/app-routes.test.ts +56 -0
  159. package/src/core/app-routes.ts +8 -1
  160. package/src/core/backup-controller.test.ts +101 -0
  161. package/src/core/backup-controller.ts +137 -0
  162. package/src/core/control-plane-client.test.ts +408 -0
  163. package/src/core/control-plane-client.ts +425 -0
  164. package/src/core/orchestrator/orchestrator.ts +4 -0
  165. package/src/core/orchestrator/utils/compactContext.test.ts +78 -0
  166. package/src/core/orchestrator/utils/operations/channel.test.ts +254 -9
  167. package/src/core/orchestrator/utils/operations/provider.test.ts +326 -34
  168. package/src/core/orchestrator/utils/operations/vm.test.ts +114 -2
  169. package/src/core/orchestrator/utils/syncProxyConfigToServiceWorker.test.ts +60 -0
  170. package/src/core/utils/initControlPlane.test.ts +276 -0
  171. package/src/core/utils/initControlPlane.ts +437 -0
  172. package/src/core/utils/initializeApp.ts +18 -0
  173. package/src/db/getSession.test.ts +13 -1
  174. package/src/db/openDatabase.test.ts +10 -1
  175. package/src/db/openDatabase.ts +3 -1
  176. package/src/server/app.test.ts +12 -0
  177. package/src/server/app.ts +18 -8
  178. package/src/server/client-registry.test.ts +250 -0
  179. package/src/server/client-registry.ts +477 -0
  180. package/src/server/config.ts +15 -0
  181. package/src/server/control-plane-types.ts +120 -0
  182. package/src/server/control-plane.test.ts +472 -0
  183. package/src/server/control-plane.ts +581 -0
  184. package/src/server/routes/backup.test.ts +263 -0
  185. package/src/server/routes/backup.ts +262 -0
  186. package/src/server/routes/integrations-email.test.ts +532 -0
  187. package/src/server/routes/llamafile.test.ts +172 -48
  188. package/src/server/routes/mesh-llm.test.ts +192 -0
  189. package/src/server/routes/ollama.test.ts +49 -0
  190. package/src/server/server-peer.test.ts +86 -0
  191. package/src/server/server-peer.ts +330 -0
  192. package/src/server/server.ts +35 -0
  193. package/src/server/services/llamafile-manager.test.ts +230 -6
  194. package/src/server/services/transformers-runtime.test.ts +186 -18
  195. package/src/server/webrtc.test.ts +21 -0
  196. package/src/server/webrtc.ts +72 -0
  197. package/src/service-worker/fetch-proxy.test.ts +64 -1
  198. package/src/service-worker/push-handler.ts +39 -0
  199. package/src/shell/vm.test.ts +744 -12
  200. package/src/storage/ensureMainGroupIndex.test.ts +153 -0
  201. package/src/storage/getGroupFile.test.ts +66 -0
  202. package/src/storage/memoryStorage.test.ts +82 -2
  203. package/src/storage/migrateLegacyOpfs.test.ts +327 -0
  204. package/src/storage/migrateLegacyOpfs.ts +117 -0
  205. package/src/storage/writeGroupFileBytes.test.ts +143 -0
  206. package/src/stores/chat-ui.test.ts +20 -0
  207. package/src/stores/orchestrator.test.ts +134 -0
  208. package/src/stores/toast.test.ts +50 -0
  209. package/src/stores/tools.test.ts +147 -10
  210. package/src/subsystems/channels/imessage.test.ts +59 -0
  211. package/src/subsystems/channels/peerjs.test.ts +500 -62
  212. package/src/subsystems/channels/peerjs.ts +71 -4
  213. package/src/subsystems/channels/telegram.test.ts +177 -0
  214. package/src/subsystems/email/catalog.test.ts +1 -0
  215. package/src/subsystems/email/connections.test.ts +39 -1
  216. package/src/subsystems/git/credentials.test.ts +160 -825
  217. package/src/subsystems/git/git.test.ts +463 -0
  218. package/src/subsystems/notifications/__mocks__/node-sqlite.cjs +12 -1
  219. package/src/subsystems/notifications/push-routes.test.ts +33 -0
  220. package/src/subsystems/notifications/push-routes.ts +23 -0
  221. package/src/subsystems/notifications/push-store.ts +1 -1
  222. package/src/subsystems/providers/builtin-ai-tasks.test.ts +74 -0
  223. package/src/subsystems/providers/litert-lm-provider.test.ts +212 -51
  224. package/src/subsystems/providers/model-registry.test.ts +115 -0
  225. package/src/subsystems/providers/providers.test.ts +94 -1
  226. package/src/subsystems/providers/transformers-js-provider.test.ts +279 -0
  227. package/src/subsystems/providers/utils/createModelCacheFetch.test.ts +2 -2
  228. package/src/subsystems/providers/utils/downloadModelToCache.test.ts +2 -2
  229. package/src/subsystems/providers/utils/loadModelStream.test.ts +2 -2
  230. package/src/subsystems/skills/activateSkill.test.ts +101 -0
  231. package/src/subsystems/skills/discoverSkills.test.ts +251 -0
  232. package/src/subsystems/tools/cron.test.ts +64 -0
  233. package/src/subsystems/tools/declarative.test.ts +255 -89
  234. package/src/testing/assets/v86.9pfs/libv86.mjs +63 -0
  235. package/src/testing/assets/v86.ext2/libv86.mjs +3 -0
  236. package/src/testing/assets_missing_v86/assets/v86.9pfs/libv86.mjs +1 -0
  237. package/src/testing/jest-setup.ts +328 -40
  238. package/src/testing/mock-v86.mjs +49 -0
  239. package/src/ui/a2ui/types.ts +4 -3
  240. package/src/ui/a2ui/utils/normaliseComponentsToMap.test.ts +102 -0
  241. package/src/ui/a2ui/utils/resolveChildIds.test.ts +63 -0
  242. package/src/ui/a2ui/utils/resolveDynamicNumber.test.ts +13 -1
  243. package/src/worker/tools/bash/utils/waitForVMReady.test.ts +40 -0
  244. package/src/worker/tools/email/email.test.ts +193 -8
  245. package/src/worker/tools/email/utils/asEmailAttachmentInputs.test.ts +47 -0
  246. package/src/worker/tools/git/git.test.ts +214 -3
  247. package/src/worker/tools/rooms/invite-to-room.test.ts +54 -0
  248. package/src/worker/tools/rooms/leave-room.test.ts +40 -0
  249. package/src/worker/tools/rooms/list-room-members.test.ts +75 -0
  250. package/src/worker/tools/tasks/tasks-utils.test.ts +22 -0
  251. package/src/worker/tools/ui/ask-user.test.ts +50 -0
  252. package/src/worker/tools/ui/clear-chat.test.ts +19 -0
  253. package/src/worker/tools/ui/get-current-time.test.ts +19 -0
  254. package/src/worker/tools/ui/javascript.test.ts +116 -0
  255. package/src/worker/tools/ui/list-components.test.ts +10 -0
  256. package/src/worker/tools/ui/list-tool-profiles.test.ts +42 -0
  257. package/src/worker/tools/ui/manage-tools.test.ts +34 -0
  258. package/src/worker/tools/ui/render-component.test.ts +346 -0
  259. package/src/worker/tools/ui/send-notification.test.ts +40 -0
  260. package/src/worker/tools/ui/utils/getAllowFullInternetAccess.test.ts +31 -0
  261. package/src/worker/tools/ui/utils/parseBooleanConfig.test.ts +25 -0
  262. package/src/worker/tools/workspace/attach-file.test.ts +84 -0
  263. package/src/worker/tools/workspace/copy-file.test.ts +69 -0
  264. package/src/worker/tools/workspace/create-directory.test.ts +40 -0
  265. package/src/worker/tools/workspace/delete-file.test.ts +73 -0
  266. package/src/worker/tools/workspace/diff-files.test.ts +94 -0
  267. package/src/worker/tools/workspace/list-files.test.ts +36 -0
  268. package/src/worker/tools/workspace/move-file.test.ts +66 -0
  269. package/src/worker/tools/workspace/open-file.test.ts +57 -0
  270. package/src/worker/tools/workspace/patch-file.test.ts +81 -0
  271. package/src/worker/tools/workspace/read-file.test.ts +116 -0
  272. package/src/worker/tools/workspace/send-file.test.ts +82 -0
  273. package/src/worker/tools/workspace/update-memory.test.ts +29 -0
  274. package/src/worker/tools/workspace/write-file.test.ts +28 -0
  275. package/src/worker/utils/rate-limit.test.ts +199 -0
  276. package/src/worker/utils/tool-state.test.ts +29 -0
  277. package/src/worker/utils/transformers-js-utils.test.ts +59 -0
  278. package/dist/public/config-AL77QAx4.js +0 -1
  279. package/dist/public/downloadGroupFile-BABv_1mJ.js +0 -1
  280. package/dist/public/file-viewer-CCSABMsE.js +0 -1
  281. package/dist/public/mcp-reconnect-DoicazQd.js +0 -1
  282. package/dist/public/orchestrator-4su7iyWj.js +0 -15
  283. package/dist/public/shadow-claw-dialog-ByyHgxM9.js +0 -1
  284. package/dist/public/shadow-claw-file-viewer-9Qkwc30T.js +0 -577
  285. package/dist/public/shadow-claw-files-aDyq6Hv7.js +0 -781
  286. package/dist/public/shadow-claw-storage-Cf31np81.js +0 -202
@@ -51,10 +51,10 @@ on:
51
51
  branches: [main]
52
52
  workflow_dispatch:
53
53
  inputs:
54
- shadowclaw_ref:
55
- description: "ShadowClaw version tag (e.g. v1.20.0), commit SHA, or branch"
54
+ shadowclaw_version:
55
+ description: "ShadowClaw npm version (e.g. latest, 1.23.3)"
56
56
  required: false
57
- default: ""
57
+ default: "latest"
58
58
 
59
59
  permissions:
60
60
  contents: read
@@ -66,87 +66,33 @@ concurrency:
66
66
  cancel-in-progress: true
67
67
 
68
68
  jobs:
69
- build:
69
+ build-and-deploy:
70
+ environment:
71
+ name: github-pages
72
+ url: ${{ steps.deployment.outputs.page_url }}
70
73
  runs-on: ubuntu-latest
71
74
  steps:
72
- - name: Checkout content repo
73
- uses: actions/checkout@v4
74
- with:
75
- path: content
75
+ - name: Checkout repository
76
+ uses: actions/checkout@v6
76
77
 
77
- - name: Resolve ShadowClaw version / ref
78
- id: resolve-ref
79
- shell: bash
80
- run: |
81
- REF="${{ github.event.inputs.shadowclaw_ref }}"
82
- if [ -z "$REF" ]; then
83
- REF=$(node -e '
84
- try {
85
- const fs = require("fs");
86
- const configPath = "content/site-config.json";
87
- if (fs.existsSync(configPath)) {
88
- const cfg = JSON.parse(fs.readFileSync(configPath, "utf8"));
89
- const v = cfg.shadowClawVersion || cfg.shadowClawRef || cfg.shadowclawVersion || cfg.shadowclawRef || "";
90
- if (v) process.stdout.write(String(v).trim());
91
- }
92
- } catch (e) {
93
- process.stdout.write("");
94
- }
95
- ')
96
- fi
97
- if [ -z "$REF" ] && [ -f "content/.shadowclaw-version" ]; then
98
- REF=$(tr -d ' \n\r\t' < content/.shadowclaw-version)
99
- fi
100
- if [ -z "$REF" ]; then
101
- REF="${SHADOWCLAW_REF:-main}"
102
- fi
103
- echo "Resolved ShadowClaw ref: $REF"
104
- echo "ref=$REF" >> "$GITHUB_OUTPUT"
105
-
106
- - name: Checkout ShadowClaw core (build toolchain)
107
- uses: actions/checkout@v4
108
- with:
109
- repository: xt-ml/shadow-claw
110
- path: shadow-claw
111
- ref: ${{ steps.resolve-ref.outputs.ref }}
112
-
113
- - uses: actions/setup-node@v4
78
+ - name: Setup Node.js
79
+ uses: actions/setup-node@v6
114
80
  with:
115
81
  node-version: "24"
116
- cache: npm
117
- cache-dependency-path: shadow-claw/package-lock.json
118
-
119
- - name: Install ShadowClaw build dependencies
120
- run: npm ci
121
- working-directory: shadow-claw
122
82
 
123
- - name: Inject content into ShadowClaw build root
124
- run: |
125
- rm -rf shadow-claw/pages
126
- if [ -d "content/pages" ]; then cp -r content/pages shadow-claw/; fi
127
- if [ -f "content/site-config.json" ]; then cp content/site-config.json shadow-claw/; fi
128
- mkdir -p shadow-claw/pages
129
-
130
- - name: Build production bundle
131
- working-directory: shadow-claw
83
+ - name: Build static site via ShadowClaw CLI
132
84
  env:
133
- NODE_ENV: production
134
85
  PAGES_ORIGIN: "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/"
135
86
  PAGES_BASE_PATH: "/${{ github.event.repository.name }}/"
136
- run: npm run build:prod
87
+ run: |
88
+ VERSION="${{ github.event.inputs.shadowclaw_version || 'latest' }}"
89
+ npx --yes "shadow-claw@$VERSION" build --prod
137
90
 
138
91
  - name: Upload Pages artifact
139
92
  uses: actions/upload-pages-artifact@v3
140
93
  with:
141
- path: shadow-claw/dist/public
94
+ path: dist/public
142
95
 
143
- deploy:
144
- needs: build
145
- runs-on: ubuntu-latest
146
- environment:
147
- name: github-pages
148
- url: ${{ steps.deployment.outputs.page_url }}
149
- steps:
150
96
  - name: Deploy to GitHub Pages
151
97
  id: deployment
152
98
  uses: actions/deploy-pages@v4
@@ -154,18 +100,7 @@ jobs:
154
100
 
155
101
  ### Version Pinning
156
102
 
157
- You can pin your template site to a specific ShadowClaw release tag (e.g. `v1.20.0`) or git commit SHA (e.g. `62253c53`) to ensure reproducible builds:
158
-
159
- - **In `site-config.json` at the repository root**:
160
-
161
- ```json
162
- {
163
- "shadowClawVersion": "v1.20.0"
164
- }
165
- ```
166
-
167
- - **In `.shadowclaw-version`**: Create a file named `.shadowclaw-version` in the root of your content repository containing the version tag or commit SHA.
168
- - **Workflow Dispatch**: Run the workflow manually from GitHub Actions UI and supply any tag, SHA, or branch in the `shadowclaw_ref` input.
103
+ ShadowClaw builds via `npx --yes shadow-claw@latest build --prod`. To pin to a specific npm release (e.g. `1.23.3`), specify the version in `.github/workflows/deploy-pages.yml` or supply `shadowclaw_version` when triggering the GitHub Actions workflow manually.
169
104
 
170
105
  For a **custom apex domain** (e.g. `example.com`), override:
171
106
 
@@ -10,7 +10,7 @@
10
10
  },
11
11
  {
12
12
  "displayPath": "~/docs/publishing-to-github-pages.md",
13
- "content": "---\ntitle: \"Publishing to GitHub Pages\"\ncreated: \"1970-01-01T00:00:00Z\"\nupdated: \"1970-01-01T00:00:00Z\"\nslug: \"publishing-to-github-pages\"\n---\n\n## Publishing to GitHub Pages\n\nShadowClaw can drive a fully automated static-site publishing pipeline directly from the browser, with the only server-side requirement being a GitHub Actions workflow that runs the Node.js build.\n\n---\n\n## Deployment strategies\n\n### Strategy A — Full fork\n\nClone the entire ShadowClaw repository, add your pages to `pages/main/`, push to a new repo you own, and let CI build and deploy it.\n\n### Strategy B — Pages-only repo (Git clone & inject in CI)\n\nYour repo contains your content, an optional root-level `site-config.json`, and a GitHub Actions workflow. Content lives under `pages/`; the workflow checks out ShadowClaw as a build toolchain in CI and builds into `dist/public`.\n\n### Strategy C — NPM Package & CLI (`npx shadow-claw`)\n\nRun or deploy using the `shadow-claw` npm package directly:\n\n- Locally: `npx shadow-claw dev` (or `shadow-claw run`) to preview with dev server.\n- In CI: `npx shadow-claw build --prod` builds `dist/public` without needing to clone ShadowClaw or copy files.\n- In `package.json`: add `\"shadow-claw\": \"^1.22.4\"` as a devDependency and run `npm run build`.\n\n**Strategy B and Strategy C are both fully supported for content-only repositories and knowledge hubs.**\n\n---\n\n## Strategy B — Step-by-step\n\n### 1. Create a new GitHub repository\n\nCreate an empty repo at `github.com/<you>/<your-site>`. Enable **Settings → Pages → Source: GitHub Actions**.\n\n### 2. Add the workflow\n\nCreate `.github/workflows/deploy-pages.yml`:\n\n```yaml\nname: Build and Deploy via ShadowClaw\n\non:\n push:\n branches: [main]\n workflow_dispatch:\n inputs:\n shadowclaw_ref:\n description: \"ShadowClaw version tag (e.g. v1.20.0), commit SHA, or branch\"\n required: false\n default: \"\"\n\npermissions:\n contents: read\n pages: write\n id-token: write\n\nconcurrency:\n group: pages\n cancel-in-progress: true\n\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout content repo\n uses: actions/checkout@v4\n with:\n path: content\n\n - name: Resolve ShadowClaw version / ref\n id: resolve-ref\n shell: bash\n run: |\n REF=\"${{ github.event.inputs.shadowclaw_ref }}\"\n if [ -z \"$REF\" ]; then\n REF=$(node -e '\n try {\n const fs = require(\"fs\");\n const configPath = \"content/site-config.json\";\n if (fs.existsSync(configPath)) {\n const cfg = JSON.parse(fs.readFileSync(configPath, \"utf8\"));\n const v = cfg.shadowClawVersion || cfg.shadowClawRef || cfg.shadowclawVersion || cfg.shadowclawRef || \"\";\n if (v) process.stdout.write(String(v).trim());\n }\n } catch (e) {\n process.stdout.write(\"\");\n }\n ')\n fi\n if [ -z \"$REF\" ] && [ -f \"content/.shadowclaw-version\" ]; then\n REF=$(tr -d ' \\n\\r\\t' < content/.shadowclaw-version)\n fi\n if [ -z \"$REF\" ]; then\n REF=\"${SHADOWCLAW_REF:-main}\"\n fi\n echo \"Resolved ShadowClaw ref: $REF\"\n echo \"ref=$REF\" >> \"$GITHUB_OUTPUT\"\n\n - name: Checkout ShadowClaw core (build toolchain)\n uses: actions/checkout@v4\n with:\n repository: xt-ml/shadow-claw\n path: shadow-claw\n ref: ${{ steps.resolve-ref.outputs.ref }}\n\n - uses: actions/setup-node@v4\n with:\n node-version: \"24\"\n cache: npm\n cache-dependency-path: shadow-claw/package-lock.json\n\n - name: Install ShadowClaw build dependencies\n run: npm ci\n working-directory: shadow-claw\n\n - name: Inject content into ShadowClaw build root\n run: |\n rm -rf shadow-claw/pages\n if [ -d \"content/pages\" ]; then cp -r content/pages shadow-claw/; fi\n if [ -f \"content/site-config.json\" ]; then cp content/site-config.json shadow-claw/; fi\n mkdir -p shadow-claw/pages\n\n - name: Build production bundle\n working-directory: shadow-claw\n env:\n NODE_ENV: production\n PAGES_ORIGIN: \"https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/\"\n PAGES_BASE_PATH: \"/${{ github.event.repository.name }}/\"\n run: npm run build:prod\n\n - name: Upload Pages artifact\n uses: actions/upload-pages-artifact@v3\n with:\n path: shadow-claw/dist/public\n\n deploy:\n needs: build\n runs-on: ubuntu-latest\n environment:\n name: github-pages\n url: ${{ steps.deployment.outputs.page_url }}\n steps:\n - name: Deploy to GitHub Pages\n id: deployment\n uses: actions/deploy-pages@v4\n```\n\n### Version Pinning\n\nYou can pin your template site to a specific ShadowClaw release tag (e.g. `v1.20.0`) or git commit SHA (e.g. `62253c53`) to ensure reproducible builds:\n\n- **In `site-config.json` at the repository root**:\n\n```json\n{\n \"shadowClawVersion\": \"v1.20.0\"\n}\n```\n\n- **In `.shadowclaw-version`**: Create a file named `.shadowclaw-version` in the root of your content repository containing the version tag or commit SHA.\n- **Workflow Dispatch**: Run the workflow manually from GitHub Actions UI and supply any tag, SHA, or branch in the `shadowclaw_ref` input.\n\nFor a **custom apex domain** (e.g. `example.com`), override:\n\n```yaml\nPAGES_ORIGIN: \"https://example.com/\"\nPAGES_BASE_PATH: \"/\"\n```\n\n### 3. Add your content\n\n```text\npages/\n main/\n index.html ← home page\n ~/content/\n about.md ← any other pages\n routes.json ← pretty-path config (optional)\n\nsite-config.json ← branding, default tool settings, and build configuration (optional)\n```\n\nSite configurations can also specify tool defaults under `settings`:\n\n```json\n{\n \"settings\": {\n \"defaultToolsProfile\": \"__builtin_default\",\n \"enabledTools\": [\"javascript\", \"read_file\", \"write_file\"]\n }\n}\n```\n\nThe `pages/` directory is optional. If it is absent, the build succeeds and\nShadowClaw publishes its built-in `index.html` and `MEMORY.md` Pages content.\nPretty paths are skipped unless a `routes.json` file is present.\n\nMinimal `pages/routes.json`:\n\n```json\n{\n \"routes\": {\n \"/pages/main/index.html\": { \"prettyPath\": \"/main\" },\n \"/pages/main/~/content/about.md\": { \"prettyPath\": \"/main/about\" },\n \"/pages/main/MEMORY.md\": { \"prettyPath\": \"/main/memory\" }\n }\n}\n```\n\n> **Reserved path prefixes** — the following first-path-segments are owned by\n> ShadowClaw's own router and **must not** be used as pretty path prefixes:\n> `/`, `/chat`, `/files`, `/tasks`, `/pages`, `/settings`, `/tools`, `/channels`.\n> `/` (root) is also reserved as the default pinned page and is unreachable as\n> a pretty path. Use a safe namespace like `/main/`, `/articles/`, `/docs/`, or\n> any custom prefix that doesn't collide with the list above.\n\n#### Default Pinned Page (`/`)\n\nWhen visitors navigate to the root URL (`/`) of your published site, ShadowClaw displays the **default pinned page**.\n\n**How ShadowClaw selects the default page for `/`:**\n\n1. Both the static site prerenderer (`prerender-dsd-shell`) and runtime page store (`orchestratorStore`) gather all page files in `pages/main/`. If `pages/main/` is absent, both use the built-in default `index.html` and `MEMORY.md` pages.\n2. `MEMORY.md` is always moved to the bottom of the list.\n3. All remaining pages are sorted by `pages.sortOrder` from `site-config.json` (`\"desc\"` by default, natural numeric, or `\"asc\"`).\n4. The first file in this sorted list (`pages[0]`) becomes the default page rendered at `/`.\n\n**How to ensure your intended home page is rendered at `/`:**\nName your landing page file so it sorts first in reverse-alphabetical order relative to other files in `pages/main/`:\n\n- `index.md` or `index.html` will sort ahead of `about.md`, `contact.md`, or `faq.md`.\n- If you have files starting with letters after `i` (e.g. `welcome.md`), `welcome.md` will sort ahead of `index.md`. Ensure your preferred landing page filename sorts highest in reverse-alphabetical order.\n\n### 4. Push — CI does the rest\n\nEvery push to `main` triggers a build (~3–5 min on a cold runner, faster with the npm cache warm) and deploys to `https://<you>.github.io/<your-site>/`.\n\n---\n\n## In-browser automation (no LLM, no server)\n\nShadowClaw can publish to your content repo entirely from the browser using a `type: \"tools\"` task chain. The chain is deterministic — it makes **zero LLM calls**.\n\n### Prerequisites\n\n- Clone your content repo into the workspace: ask the agent to `git_clone https://github.com/<you>/<your-site>`, or do it manually.\n- Configure a GitHub Personal Access Token in **Settings → Git → PAT** (needs `repo` scope for private repos, `public_repo` for public ones).\n\n### Minimal publish chain\n\n```json\n{\n \"type\": \"tools\",\n \"tools\": [\n {\n \"name\": \"write_file\",\n \"input\": {\n \"path\": \"repos/your-site/pages/main/post.md\",\n \"content\": \"---\\ntitle: My Post\\n---\\n\\n# Hello World\\n\\nContent here.\"\n }\n },\n {\n \"name\": \"git_add\",\n \"input\": {\n \"repo\": \"your-site\",\n \"files\": [\"pages/main/post.md\"]\n }\n },\n {\n \"name\": \"git_commit\",\n \"input\": {\n \"repo\": \"your-site\",\n \"message\": \"publish: new post\"\n }\n },\n {\n \"name\": \"git_push\",\n \"input\": {\n \"repo\": \"your-site\"\n }\n }\n ]\n}\n```\n\n### Fetch-transform-publish chain (fully automated data pipeline)\n\nThis chain fetches an external data source, transforms it to markdown via the JavaScript sandbox, writes it as a page, and pushes — no human in the loop:\n\n```json\n{\n \"type\": \"tools\",\n \"tools\": [\n {\n \"name\": \"fetch_url\",\n \"input\": {\n \"url\": \"https://api.github.com/repos/xt-ml/shadow-claw/releases/latest\"\n }\n },\n {\n \"name\": \"javascript\",\n \"input\": {\n \"code\": \"const match = $PIPE_DATA.match(/--- BEGIN EXTERNAL CONTENT[\\\\s\\\\S]*?---\\\\n([\\\\s\\\\S]*?)\\\\n--- END EXTERNAL CONTENT ---/); const raw = match ? match[1] : $PIPE_DATA; const rel = JSON.parse(raw); const date = rel.published_at?.slice(0, 10) ?? 'unknown'; return `---\\\\ntitle: ShadowClaw ${rel.tag_name}\\\\ndate: ${date}\\\\n---\\\\n\\\\n# ${rel.name}\\\\n\\\\nPublished: ${date}\\\\n\\\\n${rel.body ?? ''}`;\",\n \"data\": { \"$pipe\": \"prev\" }\n }\n },\n {\n \"name\": \"write_file\",\n \"input\": {\n \"path\": \"repos/your-site/pages/main/release-notes.md\",\n \"content\": { \"$pipe\": \"prev\" }\n }\n },\n {\n \"name\": \"git_add\",\n \"input\": {\n \"repo\": \"your-site\",\n \"files\": [\"pages/main/release-notes.md\"]\n }\n },\n {\n \"name\": \"git_commit\",\n \"input\": {\n \"repo\": \"your-site\",\n \"message\": \"shadow-claw[bot]: sync release notes\"\n }\n },\n {\n \"name\": \"git_push\",\n \"input\": {\n \"repo\": \"your-site\"\n }\n }\n ]\n}\n```\n\n---\n\n## Strategy C — NPM Package & CLI Workflow\n\nIf you prefer building directly with `npx shadowclaw` without cloning the ShadowClaw repository in CI, use this minimal workflow:\n\n```yaml\nname: Build and Deploy via ShadowClaw CLI\n\non:\n push:\n branches: [main]\n workflow_dispatch:\n\npermissions:\n contents: read\n pages: write\n id-token: write\n\nconcurrency:\n group: pages\n cancel-in-progress: true\n\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout content repo\n uses: actions/checkout@v4\n\n - uses: actions/setup-node@v4\n with:\n node-version: \"24\"\n\n - name: Build production bundle\n env:\n NODE_ENV: production\n PAGES_ORIGIN: \"https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/\"\n PAGES_BASE_PATH: \"/${{ github.event.repository.name }}/\"\n run: npx shadow-claw build --prod\n\n - name: Upload Pages artifact\n uses: actions/upload-pages-artifact@v3\n with:\n path: dist/public\n\n deploy:\n needs: build\n runs-on: ubuntu-latest\n environment:\n name: github-pages\n url: ${{ steps.deployment.outputs.page_url }}\n steps:\n - name: Deploy to GitHub Pages\n id: deployment\n uses: actions/deploy-pages@v4\n```\n\n> **Tip:** Wrap this in a scheduled task (Tasks sidebar → New Task → type `tools`, set a cron interval) to run the pipeline automatically, e.g. every 24 hours. No LLM calls are made at execution time.\n\n---\n\n## Template repository\n\nA ready-to-fork starter template is available in the [`shadow-claw-template`](https://github.com/xt-ml/shadow-claw-template) repository. It contains the workflow, sample `pages/main/index.html`, `pages/main/~/content/about.md`, root-level `site-config.json`, and `pages/routes.json`.\n"
13
+ "content": "---\ntitle: \"Publishing to GitHub Pages\"\ncreated: \"1970-01-01T00:00:00Z\"\nupdated: \"1970-01-01T00:00:00Z\"\nslug: \"publishing-to-github-pages\"\n---\n\n## Publishing to GitHub Pages\n\nShadowClaw can drive a fully automated static-site publishing pipeline directly from the browser, with the only server-side requirement being a GitHub Actions workflow that runs the Node.js build.\n\n---\n\n## Deployment strategies\n\n### Strategy A — Full fork\n\nClone the entire ShadowClaw repository, add your pages to `pages/main/`, push to a new repo you own, and let CI build and deploy it.\n\n### Strategy B — Pages-only repo (Git clone & inject in CI)\n\nYour repo contains your content, an optional root-level `site-config.json`, and a GitHub Actions workflow. Content lives under `pages/`; the workflow checks out ShadowClaw as a build toolchain in CI and builds into `dist/public`.\n\n### Strategy C — NPM Package & CLI (`npx shadow-claw`)\n\nRun or deploy using the `shadow-claw` npm package directly:\n\n- Locally: `npx shadow-claw dev` (or `shadow-claw run`) to preview with dev server.\n- In CI: `npx shadow-claw build --prod` builds `dist/public` without needing to clone ShadowClaw or copy files.\n- In `package.json`: add `\"shadow-claw\": \"^1.22.4\"` as a devDependency and run `npm run build`.\n\n**Strategy B and Strategy C are both fully supported for content-only repositories and knowledge hubs.**\n\n---\n\n## Strategy B — Step-by-step\n\n### 1. Create a new GitHub repository\n\nCreate an empty repo at `github.com/<you>/<your-site>`. Enable **Settings → Pages → Source: GitHub Actions**.\n\n### 2. Add the workflow\n\nCreate `.github/workflows/deploy-pages.yml`:\n\n```yaml\nname: Build and Deploy via ShadowClaw\n\non:\n push:\n branches: [main]\n workflow_dispatch:\n inputs:\n shadowclaw_version:\n description: \"ShadowClaw npm version (e.g. latest, 1.23.3)\"\n required: false\n default: \"latest\"\n\npermissions:\n contents: read\n pages: write\n id-token: write\n\nconcurrency:\n group: pages\n cancel-in-progress: true\n\njobs:\n build-and-deploy:\n environment:\n name: github-pages\n url: ${{ steps.deployment.outputs.page_url }}\n runs-on: ubuntu-latest\n steps:\n - name: Checkout repository\n uses: actions/checkout@v6\n\n - name: Setup Node.js\n uses: actions/setup-node@v6\n with:\n node-version: \"24\"\n\n - name: Build static site via ShadowClaw CLI\n env:\n PAGES_ORIGIN: \"https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/\"\n PAGES_BASE_PATH: \"/${{ github.event.repository.name }}/\"\n run: |\n VERSION=\"${{ github.event.inputs.shadowclaw_version || 'latest' }}\"\n npx --yes \"shadow-claw@$VERSION\" build --prod\n\n - name: Upload Pages artifact\n uses: actions/upload-pages-artifact@v3\n with:\n path: dist/public\n\n - name: Deploy to GitHub Pages\n id: deployment\n uses: actions/deploy-pages@v4\n```\n\n### Version Pinning\n\nShadowClaw builds via `npx --yes shadow-claw@latest build --prod`. To pin to a specific npm release (e.g. `1.23.3`), specify the version in `.github/workflows/deploy-pages.yml` or supply `shadowclaw_version` when triggering the GitHub Actions workflow manually.\n\nFor a **custom apex domain** (e.g. `example.com`), override:\n\n```yaml\nPAGES_ORIGIN: \"https://example.com/\"\nPAGES_BASE_PATH: \"/\"\n```\n\n### 3. Add your content\n\n```text\npages/\n main/\n index.html ← home page\n ~/content/\n about.md ← any other pages\n routes.json ← pretty-path config (optional)\n\nsite-config.json ← branding, default tool settings, and build configuration (optional)\n```\n\nSite configurations can also specify tool defaults under `settings`:\n\n```json\n{\n \"settings\": {\n \"defaultToolsProfile\": \"__builtin_default\",\n \"enabledTools\": [\"javascript\", \"read_file\", \"write_file\"]\n }\n}\n```\n\nThe `pages/` directory is optional. If it is absent, the build succeeds and\nShadowClaw publishes its built-in `index.html` and `MEMORY.md` Pages content.\nPretty paths are skipped unless a `routes.json` file is present.\n\nMinimal `pages/routes.json`:\n\n```json\n{\n \"routes\": {\n \"/pages/main/index.html\": { \"prettyPath\": \"/main\" },\n \"/pages/main/~/content/about.md\": { \"prettyPath\": \"/main/about\" },\n \"/pages/main/MEMORY.md\": { \"prettyPath\": \"/main/memory\" }\n }\n}\n```\n\n> **Reserved path prefixes** — the following first-path-segments are owned by\n> ShadowClaw's own router and **must not** be used as pretty path prefixes:\n> `/`, `/chat`, `/files`, `/tasks`, `/pages`, `/settings`, `/tools`, `/channels`.\n> `/` (root) is also reserved as the default pinned page and is unreachable as\n> a pretty path. Use a safe namespace like `/main/`, `/articles/`, `/docs/`, or\n> any custom prefix that doesn't collide with the list above.\n\n#### Default Pinned Page (`/`)\n\nWhen visitors navigate to the root URL (`/`) of your published site, ShadowClaw displays the **default pinned page**.\n\n**How ShadowClaw selects the default page for `/`:**\n\n1. Both the static site prerenderer (`prerender-dsd-shell`) and runtime page store (`orchestratorStore`) gather all page files in `pages/main/`. If `pages/main/` is absent, both use the built-in default `index.html` and `MEMORY.md` pages.\n2. `MEMORY.md` is always moved to the bottom of the list.\n3. All remaining pages are sorted by `pages.sortOrder` from `site-config.json` (`\"desc\"` by default, natural numeric, or `\"asc\"`).\n4. The first file in this sorted list (`pages[0]`) becomes the default page rendered at `/`.\n\n**How to ensure your intended home page is rendered at `/`:**\nName your landing page file so it sorts first in reverse-alphabetical order relative to other files in `pages/main/`:\n\n- `index.md` or `index.html` will sort ahead of `about.md`, `contact.md`, or `faq.md`.\n- If you have files starting with letters after `i` (e.g. `welcome.md`), `welcome.md` will sort ahead of `index.md`. Ensure your preferred landing page filename sorts highest in reverse-alphabetical order.\n\n### 4. Push — CI does the rest\n\nEvery push to `main` triggers a build (~3–5 min on a cold runner, faster with the npm cache warm) and deploys to `https://<you>.github.io/<your-site>/`.\n\n---\n\n## In-browser automation (no LLM, no server)\n\nShadowClaw can publish to your content repo entirely from the browser using a `type: \"tools\"` task chain. The chain is deterministic — it makes **zero LLM calls**.\n\n### Prerequisites\n\n- Clone your content repo into the workspace: ask the agent to `git_clone https://github.com/<you>/<your-site>`, or do it manually.\n- Configure a GitHub Personal Access Token in **Settings → Git → PAT** (needs `repo` scope for private repos, `public_repo` for public ones).\n\n### Minimal publish chain\n\n```json\n{\n \"type\": \"tools\",\n \"tools\": [\n {\n \"name\": \"write_file\",\n \"input\": {\n \"path\": \"repos/your-site/pages/main/post.md\",\n \"content\": \"---\\ntitle: My Post\\n---\\n\\n# Hello World\\n\\nContent here.\"\n }\n },\n {\n \"name\": \"git_add\",\n \"input\": {\n \"repo\": \"your-site\",\n \"files\": [\"pages/main/post.md\"]\n }\n },\n {\n \"name\": \"git_commit\",\n \"input\": {\n \"repo\": \"your-site\",\n \"message\": \"publish: new post\"\n }\n },\n {\n \"name\": \"git_push\",\n \"input\": {\n \"repo\": \"your-site\"\n }\n }\n ]\n}\n```\n\n### Fetch-transform-publish chain (fully automated data pipeline)\n\nThis chain fetches an external data source, transforms it to markdown via the JavaScript sandbox, writes it as a page, and pushes — no human in the loop:\n\n```json\n{\n \"type\": \"tools\",\n \"tools\": [\n {\n \"name\": \"fetch_url\",\n \"input\": {\n \"url\": \"https://api.github.com/repos/xt-ml/shadow-claw/releases/latest\"\n }\n },\n {\n \"name\": \"javascript\",\n \"input\": {\n \"code\": \"const match = $PIPE_DATA.match(/--- BEGIN EXTERNAL CONTENT[\\\\s\\\\S]*?---\\\\n([\\\\s\\\\S]*?)\\\\n--- END EXTERNAL CONTENT ---/); const raw = match ? match[1] : $PIPE_DATA; const rel = JSON.parse(raw); const date = rel.published_at?.slice(0, 10) ?? 'unknown'; return `---\\\\ntitle: ShadowClaw ${rel.tag_name}\\\\ndate: ${date}\\\\n---\\\\n\\\\n# ${rel.name}\\\\n\\\\nPublished: ${date}\\\\n\\\\n${rel.body ?? ''}`;\",\n \"data\": { \"$pipe\": \"prev\" }\n }\n },\n {\n \"name\": \"write_file\",\n \"input\": {\n \"path\": \"repos/your-site/pages/main/release-notes.md\",\n \"content\": { \"$pipe\": \"prev\" }\n }\n },\n {\n \"name\": \"git_add\",\n \"input\": {\n \"repo\": \"your-site\",\n \"files\": [\"pages/main/release-notes.md\"]\n }\n },\n {\n \"name\": \"git_commit\",\n \"input\": {\n \"repo\": \"your-site\",\n \"message\": \"shadow-claw[bot]: sync release notes\"\n }\n },\n {\n \"name\": \"git_push\",\n \"input\": {\n \"repo\": \"your-site\"\n }\n }\n ]\n}\n```\n\n---\n\n## Strategy C — NPM Package & CLI Workflow\n\nIf you prefer building directly with `npx shadowclaw` without cloning the ShadowClaw repository in CI, use this minimal workflow:\n\n```yaml\nname: Build and Deploy via ShadowClaw CLI\n\non:\n push:\n branches: [main]\n workflow_dispatch:\n\npermissions:\n contents: read\n pages: write\n id-token: write\n\nconcurrency:\n group: pages\n cancel-in-progress: true\n\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout content repo\n uses: actions/checkout@v4\n\n - uses: actions/setup-node@v4\n with:\n node-version: \"24\"\n\n - name: Build production bundle\n env:\n NODE_ENV: production\n PAGES_ORIGIN: \"https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/\"\n PAGES_BASE_PATH: \"/${{ github.event.repository.name }}/\"\n run: npx shadow-claw build --prod\n\n - name: Upload Pages artifact\n uses: actions/upload-pages-artifact@v3\n with:\n path: dist/public\n\n deploy:\n needs: build\n runs-on: ubuntu-latest\n environment:\n name: github-pages\n url: ${{ steps.deployment.outputs.page_url }}\n steps:\n - name: Deploy to GitHub Pages\n id: deployment\n uses: actions/deploy-pages@v4\n```\n\n> **Tip:** Wrap this in a scheduled task (Tasks sidebar → New Task → type `tools`, set a cron interval) to run the pipeline automatically, e.g. every 24 hours. No LLM calls are made at execution time.\n\n---\n\n## Template repository\n\nA ready-to-fork starter template is available in the [`shadow-claw-template`](https://github.com/xt-ml/shadow-claw-template) repository. It contains the workflow, sample `pages/main/index.html`, `pages/main/~/content/about.md`, root-level `site-config.json`, and `pages/routes.json`.\n"
14
14
  },
15
15
  {
16
16
  "displayPath": "~/docs/example/article.html",
@@ -1,2 +1,2 @@
1
- import{o as e,r as t}from"./config-AL77QAx4.js";import{Lt as n,M as r,gn as i,mn as a,t as o}from"./orchestrator-B9KmIj8Q.js";import{t as s}from"./setConfig-DFMYnYLE.js";import{t as c}from"./effect-BEsuusE8.js";const l={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`]}};function u(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!u(e[r],t[r]))return!1;return!0}if(n===`object`){if(!e||!t)return e===t;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!u(e[r],t[r]))return!1;return!0}return e===t}function d(e){return encodeURI(f(e))}function f(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}const p={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},m={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},h={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};let g=typeof self<`u`&&self.location&&self.location.origin!==`null`?new URL(self.location.origin+self.location.pathname+location.search):new URL(`https://github.com/cfworker`);function _(e,t=Object.create(null),n=g,r=``){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let a=new URL(i,n.href);a.hash.length>1?t[a.href]=e:(a.hash=``,r===``?n=a:_(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(h[i])continue;let a=`${r}/${d(i)}`,o=e[i];if(Array.isArray(o)){if(p[i]){let e=o.length;for(let r=0;r<e;r++)_(o[r],t,n,`${a}/${r}`)}}else if(m[i])for(let e in o)_(o[e],t,n,`${a}/${d(e)}`);else _(o,t,n,a)}return t}const v=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,y=[0,31,28,31,30,31,30,31,31,30,31,30,31],ee=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,te=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,b=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,x=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,ne=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,re=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,ie=/^(?:\/(?:[^~/]|~0|~1)*)*$/,ae=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,S=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,C=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},w=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,oe=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,se=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function T(e){return e.test.bind(e)}const ce={date:le,time:D.bind(void 0,!1),"date-time":k,duration:se,uri:ue,"uri-reference":T(b),"uri-template":T(x),url:T(ne),email:C,hostname:T(te),ipv4:T(w),ipv6:T(oe),regex:fe,uuid:T(re),"json-pointer":T(ie),"json-pointer-uri-fragment":T(ae),"relative-json-pointer":T(S)};function E(e){return e%4==0&&(e%100!=0||e%400==0)}function le(e){let t=e.match(v);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&E(n)?29:y[r])}function D(e,t){let n=t.match(ee);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}const O=/t|\s/i;function k(e){let t=e.split(O);return t.length==2&&le(t[0])&&D(!0,t[1])}const A=/\/|:/,j=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function ue(e){return A.test(e)&&j.test(e)}const de=/[^\\]\\Z/;function fe(e){if(de.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function pe(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function M(e,t,n=`2019-09`,r=_(t),i=!0,a=null,o=`#`,s=`#`,c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:`false`,keywordLocation:o,error:`False boolean schema.`}]};let l=typeof e,f;switch(l){case`boolean`:case`number`:case`string`:f=l;break;case`object`:f=e===null?`null`:Array.isArray(e)?`array`:`object`;break;default:throw Error(`Instances of "${l}" type are not supported.`)}let{$ref:p,$recursiveRef:m,$recursiveAnchor:h,type:g,const:v,enum:y,required:ee,not:te,anyOf:b,allOf:x,oneOf:ne,if:re,then:ie,else:ae,format:S,properties:C,patternProperties:w,additionalProperties:oe,unevaluatedProperties:se,minProperties:T,maxProperties:E,propertyNames:le,dependentRequired:D,dependentSchemas:O,dependencies:k,prefixItems:A,items:j,additionalItems:ue,unevaluatedItems:de,contains:fe,minContains:N,maxContains:P,minItems:F,maxItems:I,uniqueItems:L,minimum:R,maximum:z,exclusiveMinimum:B,exclusiveMaximum:V,multipleOf:H,minLength:U,maxLength:W,pattern:me,__absolute_ref__:G,__absolute_recursive_ref__:he}=t,K=[];if(h===!0&&a===null&&(a=t),m===`#`){let l=a===null?r[he]:a,u=`${s}/$recursiveRef`,d=M(e,a===null?t:a,n,r,i,l,o,u,c);d.valid||K.push({instanceLocation:o,keyword:`$recursiveRef`,keywordLocation:u,error:`A subschema had errors.`},...d.errors)}if(p!==void 0){let t=r[G||p];if(t===void 0){let e=`Unresolved $ref "${p}".`;throw G&&G!==p&&(e+=` Absolute URI "${G}".`),e+=`\nKnown schemas:\n- ${Object.keys(r).join(`
1
+ import{o as e,r as t}from"./config-CrHchneq.js";import{Lt as n,M as r,gn as i,mn as a,t as o}from"./orchestrator-3h9xxHUm.js";import{t as s}from"./setConfig-DFMYnYLE.js";import{t as c}from"./effect-BEsuusE8.js";const l={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`]}};function u(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!u(e[r],t[r]))return!1;return!0}if(n===`object`){if(!e||!t)return e===t;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!u(e[r],t[r]))return!1;return!0}return e===t}function d(e){return encodeURI(f(e))}function f(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}const p={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},m={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},h={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};let g=typeof self<`u`&&self.location&&self.location.origin!==`null`?new URL(self.location.origin+self.location.pathname+location.search):new URL(`https://github.com/cfworker`);function _(e,t=Object.create(null),n=g,r=``){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let a=new URL(i,n.href);a.hash.length>1?t[a.href]=e:(a.hash=``,r===``?n=a:_(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(h[i])continue;let a=`${r}/${d(i)}`,o=e[i];if(Array.isArray(o)){if(p[i]){let e=o.length;for(let r=0;r<e;r++)_(o[r],t,n,`${a}/${r}`)}}else if(m[i])for(let e in o)_(o[e],t,n,`${a}/${d(e)}`);else _(o,t,n,a)}return t}const v=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,y=[0,31,28,31,30,31,30,31,31,30,31,30,31],ee=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,te=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,b=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,x=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,ne=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,re=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,ie=/^(?:\/(?:[^~/]|~0|~1)*)*$/,ae=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,S=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,C=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},w=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,oe=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,se=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function T(e){return e.test.bind(e)}const ce={date:le,time:D.bind(void 0,!1),"date-time":k,duration:se,uri:ue,"uri-reference":T(b),"uri-template":T(x),url:T(ne),email:C,hostname:T(te),ipv4:T(w),ipv6:T(oe),regex:fe,uuid:T(re),"json-pointer":T(ie),"json-pointer-uri-fragment":T(ae),"relative-json-pointer":T(S)};function E(e){return e%4==0&&(e%100!=0||e%400==0)}function le(e){let t=e.match(v);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&E(n)?29:y[r])}function D(e,t){let n=t.match(ee);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}const O=/t|\s/i;function k(e){let t=e.split(O);return t.length==2&&le(t[0])&&D(!0,t[1])}const A=/\/|:/,j=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function ue(e){return A.test(e)&&j.test(e)}const de=/[^\\]\\Z/;function fe(e){if(de.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function pe(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function M(e,t,n=`2019-09`,r=_(t),i=!0,a=null,o=`#`,s=`#`,c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:`false`,keywordLocation:o,error:`False boolean schema.`}]};let l=typeof e,f;switch(l){case`boolean`:case`number`:case`string`:f=l;break;case`object`:f=e===null?`null`:Array.isArray(e)?`array`:`object`;break;default:throw Error(`Instances of "${l}" type are not supported.`)}let{$ref:p,$recursiveRef:m,$recursiveAnchor:h,type:g,const:v,enum:y,required:ee,not:te,anyOf:b,allOf:x,oneOf:ne,if:re,then:ie,else:ae,format:S,properties:C,patternProperties:w,additionalProperties:oe,unevaluatedProperties:se,minProperties:T,maxProperties:E,propertyNames:le,dependentRequired:D,dependentSchemas:O,dependencies:k,prefixItems:A,items:j,additionalItems:ue,unevaluatedItems:de,contains:fe,minContains:N,maxContains:P,minItems:F,maxItems:I,uniqueItems:L,minimum:R,maximum:z,exclusiveMinimum:B,exclusiveMaximum:V,multipleOf:H,minLength:U,maxLength:W,pattern:me,__absolute_ref__:G,__absolute_recursive_ref__:he}=t,K=[];if(h===!0&&a===null&&(a=t),m===`#`){let l=a===null?r[he]:a,u=`${s}/$recursiveRef`,d=M(e,a===null?t:a,n,r,i,l,o,u,c);d.valid||K.push({instanceLocation:o,keyword:`$recursiveRef`,keywordLocation:u,error:`A subschema had errors.`},...d.errors)}if(p!==void 0){let t=r[G||p];if(t===void 0){let e=`Unresolved $ref "${p}".`;throw G&&G!==p&&(e+=` Absolute URI "${G}".`),e+=`\nKnown schemas:\n- ${Object.keys(r).join(`
2
2
  - `)}`,Error(e)}let l=`${s}/$ref`,u=M(e,t,n,r,i,a,o,l,c);if(u.valid||K.push({instanceLocation:o,keyword:`$ref`,keywordLocation:l,error:`A subschema had errors.`},...u.errors),n===`4`||n===`7`)return{valid:K.length===0,errors:K}}if(Array.isArray(g)){let t=g.length,n=!1;for(let r=0;r<t;r++)if(f===g[r]||g[r]===`integer`&&f===`number`&&e%1==0&&e===e){n=!0;break}n||K.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${f}" is invalid. Expected "${g.join(`", "`)}".`})}else g===`integer`?(f!==`number`||e%1||e!==e)&&K.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${f}" is invalid. Expected "${g}".`}):g!==void 0&&f!==g&&K.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${f}" is invalid. Expected "${g}".`});if(v!==void 0&&(f===`object`||f===`array`?u(e,v)||K.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(v)}.`}):e!==v&&K.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(v)}.`})),y!==void 0&&(f===`object`||f===`array`?y.some(t=>u(e,t))||K.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`}):y.some(t=>e===t)||K.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`})),te!==void 0){let t=`${s}/not`;M(e,te,n,r,i,a,o,t).valid&&K.push({instanceLocation:o,keyword:`not`,keywordLocation:t,error:`Instance matched "not" schema.`})}let q=[];if(b!==void 0){let t=`${s}/anyOf`,l=K.length,u=!1;for(let s=0;s<b.length;s++){let l=b[s],d=Object.create(c),f=M(e,l,n,r,i,h===!0?a:null,o,`${t}/${s}`,d);K.push(...f.errors),u||=f.valid,f.valid&&q.push(d)}u?K.length=l:K.splice(l,0,{instanceLocation:o,keyword:`anyOf`,keywordLocation:t,error:`Instance does not match any subschemas.`})}if(x!==void 0){let t=`${s}/allOf`,l=K.length,u=!0;for(let s=0;s<x.length;s++){let l=x[s],d=Object.create(c),f=M(e,l,n,r,i,h===!0?a:null,o,`${t}/${s}`,d);K.push(...f.errors),u&&=f.valid,f.valid&&q.push(d)}u?K.length=l:K.splice(l,0,{instanceLocation:o,keyword:`allOf`,keywordLocation:t,error:`Instance does not match every subschema.`})}if(ne!==void 0){let t=`${s}/oneOf`,l=K.length,u=ne.filter((s,l)=>{let u=Object.create(c),d=M(e,s,n,r,i,h===!0?a:null,o,`${t}/${l}`,u);return K.push(...d.errors),d.valid&&q.push(u),d.valid}).length;u===1?K.length=l:K.splice(l,0,{instanceLocation:o,keyword:`oneOf`,keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if((f===`object`||f===`array`)&&Object.assign(c,...q),re!==void 0){let t=`${s}/if`;if(M(e,re,n,r,i,a,o,t,c).valid){if(ie!==void 0){let l=M(e,ie,n,r,i,a,o,`${s}/then`,c);l.valid||K.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "then" schema.`},...l.errors)}}else if(ae!==void 0){let l=M(e,ae,n,r,i,a,o,`${s}/else`,c);l.valid||K.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "else" schema.`},...l.errors)}}if(f===`object`){if(ee!==void 0)for(let t of ee)t in e||K.push({instanceLocation:o,keyword:`required`,keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});let t=Object.keys(e);if(T!==void 0&&t.length<T&&K.push({instanceLocation:o,keyword:`minProperties`,keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${T} properties.`}),E!==void 0&&t.length>E&&K.push({instanceLocation:o,keyword:`maxProperties`,keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${E} properties.`}),le!==void 0){let t=`${s}/propertyNames`;for(let s in e){let e=`${o}/${d(s)}`,c=M(s,le,n,r,i,a,e,t);c.valid||K.push({instanceLocation:o,keyword:`propertyNames`,keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(D!==void 0){let t=`${s}/dependantRequired`;for(let n in D)if(n in e){let r=D[n];for(let i of r)i in e||K.push({instanceLocation:o,keyword:`dependentRequired`,keywordLocation:t,error:`Instance has "${n}" but does not have "${i}".`})}}if(O!==void 0)for(let t in O){let l=`${s}/dependentSchemas`;if(t in e){let s=M(e,O[t],n,r,i,a,o,`${l}/${d(t)}`,c);s.valid||K.push({instanceLocation:o,keyword:`dependentSchemas`,keywordLocation:l,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(k!==void 0){let t=`${s}/dependencies`;for(let s in k)if(s in e){let c=k[s];if(Array.isArray(c))for(let n of c)n in e||K.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not have "${n}".`});else{let l=M(e,c,n,r,i,a,o,`${t}/${d(s)}`);l.valid||K.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...l.errors)}}}let l=Object.create(null),u=!1;if(C!==void 0){let t=`${s}/properties`;for(let s in C){if(!(s in e))continue;let f=`${o}/${d(s)}`,p=M(e[s],C[s],n,r,i,a,f,`${t}/${d(s)}`);if(p.valid)c[s]=l[s]=!0;else if(u=i,K.push({instanceLocation:o,keyword:`properties`,keywordLocation:t,error:`Property "${s}" does not match schema.`},...p.errors),u)break}}if(!u&&w!==void 0){let t=`${s}/patternProperties`;for(let s in w){let f=new RegExp(s,`u`),p=w[s];for(let m in e){if(!f.test(m))continue;let h=`${o}/${d(m)}`,g=M(e[m],p,n,r,i,a,h,`${t}/${d(s)}`);g.valid?c[m]=l[m]=!0:(u=i,K.push({instanceLocation:o,keyword:`patternProperties`,keywordLocation:t,error:`Property "${m}" matches pattern "${s}" but does not match associated schema.`},...g.errors))}}}if(!u&&oe!==void 0){let t=`${s}/additionalProperties`;for(let s in e){if(l[s])continue;let f=`${o}/${d(s)}`,p=M(e[s],oe,n,r,i,a,f,t);p.valid?c[s]=!0:(u=i,K.push({instanceLocation:o,keyword:`additionalProperties`,keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...p.errors))}}else if(!u&&se!==void 0){let t=`${s}/unevaluatedProperties`;for(let s in e)if(!c[s]){let l=`${o}/${d(s)}`,u=M(e[s],se,n,r,i,a,l,t);u.valid?c[s]=!0:K.push({instanceLocation:o,keyword:`unevaluatedProperties`,keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else if(f===`array`){I!==void 0&&e.length>I&&K.push({instanceLocation:o,keyword:`maxItems`,keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${I}).`}),F!==void 0&&e.length<F&&K.push({instanceLocation:o,keyword:`minItems`,keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${F}).`});let t=e.length,l=0,d=!1;if(A!==void 0){let u=`${s}/prefixItems`,f=Math.min(A.length,t);for(;l<f;l++){let t=M(e[l],A[l],n,r,i,a,`${o}/${l}`,`${u}/${l}`);if(c[l]=!0,!t.valid&&(d=i,K.push({instanceLocation:o,keyword:`prefixItems`,keywordLocation:u,error:`Items did not match schema.`},...t.errors),d))break}}if(j!==void 0){let u=`${s}/items`;if(Array.isArray(j)){let s=Math.min(j.length,t);for(;l<s;l++){let t=M(e[l],j[l],n,r,i,a,`${o}/${l}`,`${u}/${l}`);if(c[l]=!0,!t.valid&&(d=i,K.push({instanceLocation:o,keyword:`items`,keywordLocation:u,error:`Items did not match schema.`},...t.errors),d))break}}else for(;l<t;l++){let t=M(e[l],j,n,r,i,a,`${o}/${l}`,u);if(c[l]=!0,!t.valid&&(d=i,K.push({instanceLocation:o,keyword:`items`,keywordLocation:u,error:`Items did not match schema.`},...t.errors),d))break}if(!d&&ue!==void 0){let u=`${s}/additionalItems`;for(;l<t;l++){let t=M(e[l],ue,n,r,i,a,`${o}/${l}`,u);c[l]=!0,t.valid||(d=i,K.push({instanceLocation:o,keyword:`additionalItems`,keywordLocation:u,error:`Items did not match additional items schema.`},...t.errors))}}}if(fe!==void 0)if(t===0&&N===void 0)K.push({instanceLocation:o,keyword:`contains`,keywordLocation:`${s}/contains`,error:`Array is empty. It must contain at least one item matching the schema.`});else if(N!==void 0&&t<N)K.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${N}).`});else{let l=`${s}/contains`,u=K.length,d=0;for(let s=0;s<t;s++){let t=M(e[s],fe,n,r,i,a,`${o}/${s}`,l);t.valid?(c[s]=!0,d++):K.push(...t.errors)}d>=(N||0)&&(K.length=u),N===void 0&&P===void 0&&d===0?K.splice(u,0,{instanceLocation:o,keyword:`contains`,keywordLocation:l,error:`Array does not contain item matching schema.`}):N!==void 0&&d<N?K.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array must contain at least ${N} items matching schema. Only ${d} items were found.`}):P!==void 0&&d>P&&K.push({instanceLocation:o,keyword:`maxContains`,keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${P} items matching schema. ${d} items were found.`})}if(!d&&de!==void 0){let u=`${s}/unevaluatedItems`;for(;l<t;l++){if(c[l])continue;let t=M(e[l],de,n,r,i,a,`${o}/${l}`,u);c[l]=!0,t.valid||K.push({instanceLocation:o,keyword:`unevaluatedItems`,keywordLocation:u,error:`Items did not match unevaluated items schema.`},...t.errors)}}if(L)for(let n=0;n<t;n++){let r=e[n],i=typeof r==`object`&&!!r;for(let a=0;a<t;a++){if(n===a)continue;let t=e[a];(r===t||i&&typeof t==`object`&&t&&u(r,t))&&(K.push({instanceLocation:o,keyword:`uniqueItems`,keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${n} and ${a}.`}),n=2**53-1,a=2**53-1)}}}else if(f===`number`){if(n===`4`?(R!==void 0&&(B===!0&&e<=R||e<R)&&K.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${B?`or equal to `:``} ${R}.`}),z!==void 0&&(V===!0&&e>=z||e>z)&&K.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${V?`or equal to `:``} ${z}.`})):(R!==void 0&&e<R&&K.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${R}.`}),z!==void 0&&e>z&&K.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${z}.`}),B!==void 0&&e<=B&&K.push({instanceLocation:o,keyword:`exclusiveMinimum`,keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${B}.`}),V!==void 0&&e>=V&&K.push({instanceLocation:o,keyword:`exclusiveMaximum`,keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${V}.`})),H!==void 0){let t=e%H;Math.abs(0-t)>=1.1920929e-7&&Math.abs(H-t)>=1.1920929e-7&&K.push({instanceLocation:o,keyword:`multipleOf`,keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${H}.`})}}else if(f===`string`){let t=U===void 0&&W===void 0?0:pe(e);U!==void 0&&t<U&&K.push({instanceLocation:o,keyword:`minLength`,keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${U}).`}),W!==void 0&&t>W&&K.push({instanceLocation:o,keyword:`maxLength`,keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${W}).`}),me!==void 0&&!new RegExp(me,`u`).test(e)&&K.push({instanceLocation:o,keyword:`pattern`,keywordLocation:`${s}/pattern`,error:`String does not match pattern.`}),S!==void 0&&ce[S]&&!ce[S](e)&&K.push({instanceLocation:o,keyword:`format`,keywordLocation:`${s}/format`,error:`String does not match format "${S}".`})}return{valid:K.length===0,errors:K}}var N=class{schema;draft;shortCircuit;lookup;constructor(e,t=`2019-09`,n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=_(e)}validate(e){return M(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),_(e,this.lookup)}};const P=`Failed to parse input arguments`,F=`Tool was executed but the invocation failed. For example, the script function threw an error`,I=`Tool was cancelled`,L={type:`object`,properties:{}},R=[`draft-2020-12`,`draft-07`],z=Symbol(`standardValidator`),B={installed:!1,previousNavigatorModelContextDescriptor:void 0,previousNavigatorModelContextTestingDescriptor:void 0,previousDocumentModelContextDescriptor:void 0,installedNavigatorModelContext:!1,installedNavigatorModelContextTesting:!1,installedDocumentModelContext:!1};var V=class extends EventTarget{tools=new Map;testingShim=null;_ontoolchange=null;unregisterToolDeprecationWarned=!1;get ontoolchange(){return this._ontoolchange}set ontoolchange(e){this._ontoolchange=e}registerTool(e,t){let n=t?.signal;if(n?.aborted){console.warn(`[WebMCPPolyfill] registerTool("${e?.name??`<unknown>`}") skipped: options.signal was already aborted.`);return}let r=ye(e,this.tools);this.tools.set(r.name,r),this.notifyToolsChanged(),n&&n.addEventListener(`abort`,()=>{this.tools.delete(r.name)&&this.notifyToolsChanged()},{once:!0})}unregisterTool(e){this.warnUnregisterToolDeprecationOnce();let t=me(e);this.tools.delete(t)&&this.notifyToolsChanged()}getTools(){return Promise.resolve(this.getRegisteredToolInfos())}executeTool(e,t,n){return this.executeToolByName(e.name,t,n,!1)}getTestingShim(){return this.testingShim||=new H(this),this.testingShim}getToolInfos(){return[...this.tools.values()].map(e=>{let t;try{t=JSON.stringify(e.inputSchema??{type:`object`})}catch{t=`{"type":"object"}`}return{name:e.name,description:e.description,inputSchema:t}})}getRegisteredToolInfos(){return this.getToolInfos().map(e=>{let t=this.tools.get(e.name);return{...e,title:t?.title??``,origin:globalThis.location?.origin??``,window:globalThis.window}})}async executeToolForTesting(e,t,n){return this.executeToolByName(e,t,n,!0)}async executeToolByName(e,t,n,r){if(n?.signal?.aborted)throw U(I);let i=this.tools.get(e);if(!i)throw U(`Tool not found: ${e}`);let a=W(t),o=await Ce(a,i);if(o)throw U(o);let s=!0,c={requestUserInteraction:async t=>{if(!s)throw Error(`ModelContextClient for tool "${e}" is no longer active after execute() resolved`);if(typeof t!=`function`)throw TypeError(`requestUserInteraction(callback) requires a function callback`);return t()}};try{let e=i.execute(a,c),t=await Me(Promise.resolve(e),n?.signal);if(r)return je(ke(t));let o=JSON.stringify(t);return o===void 0?null:o}catch(e){throw U(e instanceof Error?`${F}: ${e.message}`:F)}finally{s=!1}}notifyToolsChanged(){queueMicrotask(()=>{let e=new Event(`toolchange`);try{this._ontoolchange?.call(this,e)}catch(e){console.warn(`[WebMCPPolyfill] navigator.modelContext.ontoolchange handler threw:`,e)}this.dispatchEvent(e),this.testingShim?.dispatchToolChange()})}warnUnregisterToolDeprecationOnce(){this.unregisterToolDeprecationWarned||(this.unregisterToolDeprecationWarned=!0,console.warn(`[WebMCPPolyfill] navigator.modelContext.unregisterTool() is deprecated. The April 23, 2026 WebMCP draft removed it in favor of registerTool(tool, { signal }) — pass an AbortSignal and abort it to unregister.`))}},H=class extends EventTarget{context;_ontoolchange=null;constructor(e){super(),this.context=e}listTools(){return this.context.getToolInfos()}executeTool(e,t,n){return this.context.executeToolForTesting(e,t,n)}getCrossDocumentScriptToolResult(){return Promise.resolve(`[]`)}get ontoolchange(){return this._ontoolchange}set ontoolchange(e){this._ontoolchange=e}registerToolsChangedCallback(e){if(typeof e!=`function`)throw TypeError(`Failed to execute 'registerToolsChangedCallback' on 'ModelContextTesting': parameter 1 is not of type 'Function'.`);this.addEventListener(`toolchange`,e)}dispatchToolChange(){let e=new Event(`toolchange`);try{this._ontoolchange?.call(this,e)}catch(e){console.warn(`[WebMCPPolyfill] ontoolchange handler threw:`,e)}this.dispatchEvent(e),this.dispatchEvent(new Event(`toolschanged`))}};function U(e){try{return new DOMException(e,`UnknownError`)}catch{let t=Error(e);return t.name=`UnknownError`,t}}function W(e){let t;try{t=JSON.parse(e)}catch{throw U(P)}if(!t||typeof t!=`object`||Array.isArray(t))throw U(P);return t}function me(e){if(typeof e==`string`)return e;if(G(e)&&typeof e.name==`string`)return e.name;throw TypeError(`Failed to execute 'unregisterTool' on 'ModelContext': parameter 1 must be a string or an object with a string name.`)}function G(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function he(e){if(!G(e))return null;let t=e[`~standard`];return G(t)?t:null}function K(e){let t=he(e);return!!(t&&t.version===1&&typeof t.validate==`function`)}function q(e){let t=he(e);return!t||t.version!==1||!G(t.jsonSchema)?!1:typeof t.jsonSchema.input==`function`}function J(e){return{"~standard":{version:1,vendor:`@mcp-b/webmcp-polyfill-json-schema`,validate(t){if(!G(t))return{issues:[{message:`expected object arguments`}]};let n=be(t,e);return n?{issues:[n]}:{value:t}}}}}function ge(e){for(let t of R)try{let n=e[`~standard`].jsonSchema.input({target:t});return ve(n),n}catch(e){console.warn(`[WebMCPPolyfill] Standard JSON Schema conversion failed for target "${t}":`,e)}throw Error(`Failed to convert Standard JSON Schema inputSchema to a JSON Schema object`)}function _e(e){if(e===void 0){let e=L;return{inputSchema:e,standardValidator:J(e)}}if(q(e)){let t=ge(e);return{inputSchema:t,standardValidator:J(t)}}if(K(e))return{inputSchema:L,standardValidator:e};if(ve(e),Object.keys(e).length===0)return{inputSchema:L,standardValidator:J(L)};let t=e.type===void 0?{type:`object`,...e}:e;return{inputSchema:t,standardValidator:J(t)}}function ve(e){if(!G(e))throw Error(`inputSchema must be a JSON Schema object`);Y(e,`$`)}function Y(e,t){let n=e.type;if(n!==void 0&&typeof n!=`string`&&!(Array.isArray(n)&&n.every(e=>typeof e==`string`&&e.length>0)))throw Error(`Invalid JSON Schema at ${t}: "type" must be a string or string[]`);let r=e.required;if(r!==void 0&&!(Array.isArray(r)&&r.every(e=>typeof e==`string`)))throw Error(`Invalid JSON Schema at ${t}: "required" must be an array of strings`);let i=e.properties;if(i!==void 0){if(!G(i))throw Error(`Invalid JSON Schema at ${t}: "properties" must be an object`);for(let[e,n]of Object.entries(i)){if(!G(n))throw Error(`Invalid JSON Schema at ${t}.properties.${e}: expected object schema`);Y(n,`${t}.properties.${e}`)}}let a=e.items;if(a!==void 0)if(Array.isArray(a))for(let[e,n]of a.entries()){if(!G(n))throw Error(`Invalid JSON Schema at ${t}.items[${e}]: expected object schema`);Y(n,`${t}.items[${e}]`)}else if(G(a))Y(a,`${t}.items`);else throw Error(`Invalid JSON Schema at ${t}: "items" must be an object or object[]`);for(let n of[`allOf`,`anyOf`,`oneOf`]){let r=e[n];if(r!==void 0){if(!Array.isArray(r))throw Error(`Invalid JSON Schema at ${t}: "${n}" must be an array`);for(let[e,i]of r.entries()){if(!G(i))throw Error(`Invalid JSON Schema at ${t}.${n}[${e}]: expected object schema`);Y(i,`${t}.${n}[${e}]`)}}}let o=e.not;if(o!==void 0){if(!G(o))throw Error(`Invalid JSON Schema at ${t}: "not" must be an object schema`);Y(o,`${t}.not`)}try{JSON.stringify(e)}catch{throw Error(`Invalid JSON Schema at ${t}: schema must be JSON-serializable`)}}function ye(e,t){if(!e||typeof e!=`object`)throw TypeError(`registerTool(tool) requires a tool object`);if(typeof e.name!=`string`||e.name.length===0)throw TypeError(`Tool "name" must be a non-empty string`);if(typeof e.description!=`string`||e.description.length===0)throw TypeError(`Tool "description" must be a non-empty string`);if(typeof e.execute!=`function`)throw TypeError(`Tool "execute" must be a function`);if(t.has(e.name))throw Error(`Tool already registered: ${e.name}`);let n=_e(e.inputSchema),r=e.annotations,i=r?{...r,...r.readOnlyHint===`true`?{readOnlyHint:!0}:r.readOnlyHint===`false`?{readOnlyHint:!1}:{},...r.destructiveHint===`true`?{destructiveHint:!0}:r.destructiveHint===`false`?{destructiveHint:!1}:{},...r.idempotentHint===`true`?{idempotentHint:!0}:r.idempotentHint===`false`?{idempotentHint:!1}:{},...r.openWorldHint===`true`?{openWorldHint:!0}:r.openWorldHint===`false`?{openWorldHint:!1}:{}}:void 0;return{...e,...i?{annotations:i}:{},inputSchema:n.inputSchema,[z]:n.standardValidator}}function be(e,t){let n=new N(t,`2020-12`,!0).validate(e);if(n.valid)return null;let r=n.errors[n.errors.length-1];return r?{message:r.error}:{message:`Input validation failed`}}function xe(e){if(!e||e.length===0)return null;let t=e.map(e=>G(e)&&`key`in e?e.key:e).map(e=>String(e)).filter(e=>e.length>0);return t.length===0?null:t.join(`.`)}async function Se(e,t){let n;try{n=await Promise.resolve(t[`~standard`].validate(e))}catch(e){let t=e instanceof Error?`: ${e.message}`:``;return console.error(`[WebMCPPolyfill] Standard Schema validation threw unexpectedly:`,e),`Input validation error: schema validation failed${t}`}if(!n.issues||n.issues.length===0)return null;let r=n.issues[0];if(!r)return`Input validation error`;let i=xe(r?.path);return i?`Input validation error: ${r.message} at ${i}`:`Input validation error: ${r.message}`}async function Ce(e,t){return Se(e,t[z])}function we(e){return G(e)&&Array.isArray(e.content)}function Te(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function Ee(e){return Te(e)?Number.isFinite(e)||typeof e!=`number`:Array.isArray(e)?e.every(e=>Ee(e)):G(e)?Object.values(e).every(e=>Ee(e)):!1}function De(e){if(!(!G(e)||!Ee(e)))return e}function Oe(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function ke(e){if(we(e))return e;let t=De(e);return{content:[{type:`text`,text:Oe(e)}],...t?{structuredContent:t}:{},isError:!1}}function Ae(e){for(let t of e.content??[])if(t.type===`text`&&`text`in t&&typeof t.text==`string`)return t.text;return null}function je(e){if(e.isError)throw U(Ae(e)?.replace(/^Error:\s*/i,``).trim()||F);let t=e.metadata;if(t&&typeof t==`object`&&t.willNavigate)return null;try{return JSON.stringify(e)}catch{throw U(F)}}function Me(e,t){return t?t.aborted?Promise.reject(U(I)):new Promise((n,r)=>{let i=()=>{a(),r(U(I))},a=()=>{t.removeEventListener(`abort`,i)};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{a(),n(e)},e=>{a(),r(e)})}):e}function Ne(){return typeof navigator<`u`?navigator:null}function Pe(){return typeof document<`u`?document:null}function Fe(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!1,value:n})}function Ie(e,t){Object.defineProperty(e,"modelContext",{configurable:!0,enumerable:!0,writable:!1,value:t})}let X=!1;function Le(e,t){Object.defineProperty(e,"modelContext",{configurable:!0,enumerable:!0,get(){return X||(X=!0,console.warn(`[WebMCPPolyfill] navigator.modelContext is deprecated. The May 27, 2026 WebMCP draft moved the modelContext getter from Navigator to Document — use document.modelContext instead. See https://github.com/webmachinelearning/webmcp/pull/184.`)),t}})}function Re(e){let t=Ne(),n=Pe();if(!t&&!n||n?.modelContext)return;let r=t?.modelContext,i=!!r;if(B.installed&&ze(),n&&r){B.previousDocumentModelContextDescriptor=Object.getOwnPropertyDescriptor(n,`modelContext`),Ie(n,r),B.installedDocumentModelContext=!0,B.installed=!0;return}if(i)return;let a=new V,o=a;if(o.__isWebMCPPolyfill=!0,n&&(B.previousDocumentModelContextDescriptor=Object.getOwnPropertyDescriptor(n,`modelContext`),Ie(n,o),B.installedDocumentModelContext=!0),t){B.previousNavigatorModelContextDescriptor=Object.getOwnPropertyDescriptor(t,`modelContext`),B.previousNavigatorModelContextTestingDescriptor=Object.getOwnPropertyDescriptor(t,`modelContextTesting`),X=!1,Le(t,o),B.installedNavigatorModelContext=!0;let n=e?.installTestingShim??`if-missing`,r=!!t.modelContextTesting;(n===`always`||(n===!0||n===`if-missing`)&&!r)&&(Fe(t,`modelContextTesting`,a.getTestingShim()),B.installedNavigatorModelContextTesting=!0)}B.installed=!0}function ze(){if(!B.installed)return;let e=(e,t,n)=>{if(n){Object.defineProperty(e,t,n);return}delete e[t]},t=Ne(),n=Pe();n&&B.installedDocumentModelContext&&e(n,`modelContext`,B.previousDocumentModelContextDescriptor),t&&B.installedNavigatorModelContext&&e(t,`modelContext`,B.previousNavigatorModelContextDescriptor),t&&B.installedNavigatorModelContextTesting&&e(t,`modelContextTesting`,B.previousNavigatorModelContextTestingDescriptor),B.installed=!1,B.previousDocumentModelContextDescriptor=void 0,B.previousNavigatorModelContextDescriptor=void 0,B.previousNavigatorModelContextTestingDescriptor=void 0,B.installedDocumentModelContext=!1,B.installedNavigatorModelContext=!1,B.installedNavigatorModelContextTesting=!1,X=!1}if(typeof window<`u`&&typeof document<`u`){let e=window.__webMCPPolyfillOptions;if(e?.autoInitialize!==!1)try{Re(e)}catch(e){console.error(`[WebMCPPolyfill] Auto-initialization failed:`,e)}}const Z=new Map,Q=new Set;let Be=`polyfill`;function Ve(e){Be=e}function He(){return Be}function Ue(){try{Re()}catch(e){console.warn(`WebMCP polyfill initialization failed:`,e)}}function We(){if(typeof document>`u`&&typeof navigator>`u`)return null;Be===`polyfill`&&Ue();try{let e=typeof document<`u`&&document.modelContext!==void 0?Reflect.get(document,`modelContext`):typeof navigator<`u`&&navigator.modelContext!==void 0?Reflect.get(navigator,`modelContext`):void 0;if(!e||typeof e!=`object`)return null;let t=e;return typeof t.registerTool==`function`?t:null}catch(e){return console.warn(`WebMCP modelContext access failed:`,e),null}}function Ge(e){if(typeof e==`string`){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return{type:`object`,properties:{}}}return e&&typeof e==`object`&&!Array.isArray(e)?e:{type:`object`,properties:{}}}function Ke(e){if(e){if(typeof AbortSignal<`u`&&e instanceof AbortSignal)return e;if(typeof e==`object`&&`signal`in e&&typeof AbortSignal<`u`&&e.signal instanceof AbortSignal)return e.signal}}async function qe(t,n,r=e,a){let o=Array.isArray(a)?a:i;if(o.length===0)return!0;let s=We();if(!s)return!1;for(let e of o){if(Q.has(e.name))continue;let n=new AbortController;Z.set(e.name,n),Q.add(e.name);try{let i={name:e.name,description:e.description,inputSchema:Ge(e.input_schema),annotations:{readOnlyHint:!1,untrustedContentHint:!0},execute:(n,i)=>{if(!t)throw Error(`Cannot execute tool: agent worker is not ready`);let a=Ke(i);return a?.aborted?Promise.reject(Error(`Tool execution aborted`)):new Promise((i,o)=>{let s=Date.now().toString(36)+Math.random().toString(36).slice(2),c=null,l=()=>{c!==null&&(clearTimeout(c),c=null),t?.removeEventListener(`message`,d),a&&u&&a.removeEventListener(`abort`,u)},u=()=>{l(),o(Error(`Tool execution aborted`))};a&&a.addEventListener(`abort`,u,{once:!0}),c=setTimeout(()=>{l(),o(Error(`Timeout waiting for tool execution`))},6e5);let d=e=>{let t=e.data;t&&t.type===`execute-tool-result`&&t.callId===s&&(l(),t.error?o(Error(t.error)):i(t.result))};t.addEventListener(`message`,d),t.postMessage({type:`execute-tool`,callId:s,payload:{name:e.name,input:n||{},groupId:r}})})}};await s.registerTool(i,{signal:n.signal}),await new Promise(e=>setTimeout(e,0))}catch(t){if(Z.delete(e.name),Q.delete(e.name),!(t instanceof Error&&(t.message.includes(`already registered`)||t.message.includes(`Duplicate tool name`))))throw console.error(`Failed to register tool ${e.name}:`,t),t}}return!0}function $(){for(let e of Z.values())try{e.abort()}catch{}Z.clear(),Q.clear()}function Je(e,t){if(typeof e.webMcpEffectCleanup==`function`&&(e.webMcpEffectCleanup(),e.webMcpEffectCleanup=null),!e.webMcpToolsEnabled){$();return}e.webMcpEffectCleanup=c(()=>{let i=o.activeGroupId,s=a.allTools,c=a.enabledTools;a.declarativeTools,a.declarativeToolNamesEnabled;let u=o.groups.find(e=>e.groupId===i);e.webMcpRegistrationLock=e.webMcpRegistrationLock.then(async()=>{$(),await new Promise(e=>setTimeout(e,0));let o=[];try{o=await a.refreshDeclarativeTools(t,i)}catch{}let d=o.filter(e=>a.isDeclarativeToolEnabled(e.name)),f=[...s,...o],p=u?.toolTags&&u.toolTags.length>0?f.filter(e=>u.toolTags.includes(e.name)):[...c,...d],m={skills:[]};try{m=await n(t,i)}catch{}m.skills.length>0&&!p.some(e=>e.name===l.name)&&(p=[...p,l]),await qe(e.agentWorker,async n=>{await r(e,t,n)},i,p)}).catch(e=>{console.error(`WebMCP registration failed:`,e)})})}async function Ye(e,n,r,i){$(),Ve(r),await s(n,t.WEBMCP_MODE,r),Je(i.orchestrator,n)}async function Xe(e,n,r,i){e.webMcpToolsEnabled=!!r,await s(n,t.WEBMCP_TOOLS_ENABLED,e.webMcpToolsEnabled?`true`:`false`),Je(i.orchestrator,n)}export{Ve as a,He as i,Xe as n,$ as o,Je as r,l as s,Ye as t};