shadow-claw 1.34.5 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.well-known/mcp/server-card.json +1 -1
- package/.well-known/mcp.json +1 -1
- package/README.md +5 -1
- package/dist/cli/chunk-BCLxzLO92.js +5 -0
- package/dist/cli/chunk-BHNCi3ui2.js +1 -0
- package/dist/cli/chunk-BMPhLSn8.js +1 -0
- package/dist/cli/chunk-BMW6QB5-2.js +27 -0
- package/dist/cli/chunk-BQCWtrzh.js +1 -0
- package/dist/cli/chunk-BQCWtrzh2.js +1 -0
- package/dist/cli/chunk-BdJUjMuz.js +1 -0
- package/dist/cli/chunk-C47WdxKx2.js +1 -0
- package/dist/cli/{chunk-D9dku_3t.js → chunk-CAqvQuGr.js} +1 -1
- package/dist/cli/{chunk-DoVxObGa2.js → chunk-CHzhUS1N2.js} +1 -1
- package/dist/cli/chunk-CUMlq7Jw2.js +263 -0
- package/dist/cli/chunk-CXi9LU9e2.js +110 -0
- package/dist/cli/chunk-ChefnX-r.js +110 -0
- package/dist/cli/{chunk-zvi71-77.js → chunk-D3JxbzjI2.js} +15 -15
- package/dist/cli/chunk-D7VYMl092.js +1 -0
- package/dist/cli/chunk-DNIduiJ82.js +91 -0
- package/dist/cli/{chunk-C4UfzPK4.js → chunk-DTbrldk_.js} +1 -1
- package/dist/cli/chunk-DZ8YBXax.js +969 -0
- package/dist/cli/chunk-DduRvw8B2.js +1 -0
- package/dist/cli/chunk-DnYxGjdu2.js +1 -0
- package/dist/cli/chunk-Ea7nXmgb2.js +1 -0
- package/dist/cli/{chunk-BRiGkTIi.js → chunk-EohNY8vW.js} +1 -1
- package/dist/cli/chunk-LIIpZlwP2.js +1 -0
- package/dist/cli/chunk-LIJZHJml2.js +1 -0
- package/dist/cli/chunk-MHBh2BgF2.js +91 -0
- package/dist/cli/{chunk-BQ7lHA7c.js → chunk-SKgLGyTY.js} +1 -1
- package/dist/cli/chunk-kcJSXcbq2.js +1 -0
- package/dist/cli/cli.js +12 -11
- package/dist/headless-agent.js +191 -187
- package/dist/lib/components/index.js +21 -21
- package/dist/lib/components/settings/shadow-claw-channel-config.js +1 -1
- package/dist/lib/components/settings/shadow-claw-control-plane.js +1 -1
- package/dist/lib/components/settings/shadow-claw-git.js +1 -1
- package/dist/lib/components/settings/shadow-claw-llm.js +1 -1
- package/dist/lib/components/settings/shadow-claw-networking.js +1 -1
- package/dist/lib/components/settings/shadow-claw-notifications.js +1 -1
- package/dist/lib/components/settings/shadow-claw-peerjs.js +1 -1
- package/dist/lib/components/settings/shadow-claw-storage.js +1 -1
- package/dist/lib/components/settings/shadow-claw-task-server.js +1 -1
- package/dist/lib/components/settings/shadow-claw-webvm.js +1 -1
- package/dist/lib/components/shadow-claw-channel-config.js +1 -1
- package/dist/lib/components/shadow-claw-channels.js +1 -1
- package/dist/lib/components/shadow-claw-chat.js +1 -1
- package/dist/lib/components/shadow-claw-control-plane.js +1 -1
- package/dist/lib/components/shadow-claw-conversations.js +1 -1
- package/dist/lib/components/shadow-claw-file-viewer.js +1 -1
- package/dist/lib/components/shadow-claw-files.js +1 -1
- package/dist/lib/components/shadow-claw-git.js +1 -1
- package/dist/lib/components/shadow-claw-llm.js +1 -1
- package/dist/lib/components/shadow-claw-networking.js +1 -1
- package/dist/lib/components/shadow-claw-notifications.js +1 -1
- package/dist/lib/components/shadow-claw-pages.js +1 -1
- package/dist/lib/components/shadow-claw-peerjs.js +1 -1
- package/dist/lib/components/shadow-claw-settings.js +1 -1
- package/dist/lib/components/shadow-claw-storage.js +1 -1
- package/dist/lib/components/shadow-claw-task-server.js +1 -1
- package/dist/lib/components/shadow-claw-tasks.js +1 -1
- package/dist/lib/components/shadow-claw-terminal.js +1 -1
- package/dist/lib/components/shadow-claw-tools.js +1 -1
- package/dist/lib/components/shadow-claw-webvm.js +1 -1
- package/dist/lib/components/shadow-claw.js +1 -1
- package/dist/lib/{configurePeerJs-DSRcNp3v.js → configurePeerJs-CdPzmpyI.js} +2 -2
- package/dist/lib/{configurePeerJs-DSRcNp3v.js.map → configurePeerJs-CdPzmpyI.js.map} +1 -1
- package/dist/lib/index.js +21 -21
- package/dist/lib/{initControlPlane-CWfE_Oan.js → initControlPlane-BLymRW34.js} +7 -7
- package/dist/lib/{initControlPlane-CWfE_Oan.js.map → initControlPlane-BLymRW34.js.map} +1 -1
- package/dist/lib/{orchestrator-BEUug1TW.js → orchestrator-DZkhJj7f.js} +13 -2
- package/dist/lib/{orchestrator-BEUug1TW.js.map → orchestrator-DZkhJj7f.js.map} +1 -1
- package/dist/lib/{orchestrator-CGUzfGbE.js → orchestrator-ZsQTRknI.js} +5 -5
- package/dist/lib/{orchestrator-CGUzfGbE.js.map → orchestrator-ZsQTRknI.js.map} +1 -1
- package/dist/lib/{peerjs-BSD88rT3.js → peerjs-CJYfnR5V.js} +3 -3
- package/dist/lib/{peerjs-BSD88rT3.js.map → peerjs-CJYfnR5V.js.map} +1 -1
- package/dist/lib/{push-client-CC3qifgc.js → push-client-C9hIPqLZ.js} +2 -2
- package/dist/lib/{push-client-CC3qifgc.js.map → push-client-C9hIPqLZ.js.map} +1 -1
- package/dist/lib/{shadow-claw-BWS-UVnE.js → shadow-claw-8qL2-QoK.js} +4 -4
- package/dist/lib/{shadow-claw-BWS-UVnE.js.map → shadow-claw-8qL2-QoK.js.map} +1 -1
- package/dist/lib/{shadow-claw-channel-config-DwMn3nFJ.js → shadow-claw-channel-config-CvnbqGBy.js} +3 -3
- package/dist/lib/{shadow-claw-channel-config-DwMn3nFJ.js.map → shadow-claw-channel-config-CvnbqGBy.js.map} +1 -1
- package/dist/lib/{shadow-claw-channels-BdE4cUlx.js → shadow-claw-channels-CkCvjWn1.js} +2 -2
- package/dist/lib/{shadow-claw-channels-BdE4cUlx.js.map → shadow-claw-channels-CkCvjWn1.js.map} +1 -1
- package/dist/lib/{shadow-claw-chat-DqaMoE9C.js → shadow-claw-chat-B1YEHKN3.js} +3 -3
- package/dist/lib/{shadow-claw-chat-DqaMoE9C.js.map → shadow-claw-chat-B1YEHKN3.js.map} +1 -1
- package/dist/lib/{shadow-claw-control-plane-D3DUDO29.js → shadow-claw-control-plane-jjo789IE.js} +6 -6
- package/dist/lib/{shadow-claw-control-plane-D3DUDO29.js.map → shadow-claw-control-plane-jjo789IE.js.map} +1 -1
- package/dist/lib/{shadow-claw-conversations-XT-OXogj.js → shadow-claw-conversations-MMT7wYH3.js} +2 -2
- package/dist/lib/{shadow-claw-conversations-XT-OXogj.js.map → shadow-claw-conversations-MMT7wYH3.js.map} +1 -1
- package/dist/lib/{shadow-claw-file-viewer-DJqxyd97.js → shadow-claw-file-viewer-qSkD1RQK.js} +2 -2
- package/dist/lib/{shadow-claw-file-viewer-DJqxyd97.js.map → shadow-claw-file-viewer-qSkD1RQK.js.map} +1 -1
- package/dist/lib/{shadow-claw-files-CUEJlA1o.js → shadow-claw-files-Cg8ycQ_N.js} +2 -2
- package/dist/lib/{shadow-claw-files-CUEJlA1o.js.map → shadow-claw-files-Cg8ycQ_N.js.map} +1 -1
- package/dist/lib/{shadow-claw-git-D_iVcb86.js → shadow-claw-git-gaClz-ZC.js} +3 -3
- package/dist/lib/{shadow-claw-git-D_iVcb86.js.map → shadow-claw-git-gaClz-ZC.js.map} +1 -1
- package/dist/lib/{shadow-claw-llm-C2msAsyU.js → shadow-claw-llm-DyOz0qzT.js} +2 -2
- package/dist/lib/{shadow-claw-llm-C2msAsyU.js.map → shadow-claw-llm-DyOz0qzT.js.map} +1 -1
- package/dist/lib/{shadow-claw-networking-D2NvodC-.js → shadow-claw-networking-B2xx0UUR.js} +2 -2
- package/dist/lib/{shadow-claw-networking-D2NvodC-.js.map → shadow-claw-networking-B2xx0UUR.js.map} +1 -1
- package/dist/lib/{shadow-claw-notifications-BcvVn_vu.js → shadow-claw-notifications-BjKfZy0k.js} +2 -2
- package/dist/lib/{shadow-claw-notifications-BcvVn_vu.js.map → shadow-claw-notifications-BjKfZy0k.js.map} +1 -1
- package/dist/lib/{shadow-claw-pages-CTMXRhEX.js → shadow-claw-pages-CJ2tsMtL.js} +2 -2
- package/dist/lib/{shadow-claw-pages-CTMXRhEX.js.map → shadow-claw-pages-CJ2tsMtL.js.map} +1 -1
- package/dist/lib/{shadow-claw-peerjs-C2YvypqM.js → shadow-claw-peerjs-CazCkXQ1.js} +3 -3
- package/dist/lib/{shadow-claw-peerjs-C2YvypqM.js.map → shadow-claw-peerjs-CazCkXQ1.js.map} +1 -1
- package/dist/lib/{shadow-claw-settings-B0hiDwEt.js → shadow-claw-settings-qro6pO9I.js} +2 -2
- package/dist/lib/{shadow-claw-settings-B0hiDwEt.js.map → shadow-claw-settings-qro6pO9I.js.map} +1 -1
- package/dist/lib/{shadow-claw-storage-Dt4yg4Q4.js → shadow-claw-storage-ewDdvCGa.js} +2 -2
- package/dist/lib/{shadow-claw-storage-Dt4yg4Q4.js.map → shadow-claw-storage-ewDdvCGa.js.map} +1 -1
- package/dist/lib/{shadow-claw-task-server-B2gbZaz4.js → shadow-claw-task-server-DpqQcNIs.js} +2 -2
- package/dist/lib/{shadow-claw-task-server-B2gbZaz4.js.map → shadow-claw-task-server-DpqQcNIs.js.map} +1 -1
- package/dist/lib/{shadow-claw-tasks-Bxq-niuM.js → shadow-claw-tasks-B2fMF4qE.js} +2 -2
- package/dist/lib/{shadow-claw-tasks-Bxq-niuM.js.map → shadow-claw-tasks-B2fMF4qE.js.map} +1 -1
- package/dist/lib/{shadow-claw-terminal-BfbW3xtg.js → shadow-claw-terminal-B25kQJC3.js} +2 -2
- package/dist/lib/{shadow-claw-terminal-BfbW3xtg.js.map → shadow-claw-terminal-B25kQJC3.js.map} +1 -1
- package/dist/lib/{shadow-claw-tools-BNSAaK0Y.js → shadow-claw-tools-B0y8JzoA.js} +10 -3
- package/dist/lib/{shadow-claw-tools-BNSAaK0Y.js.map → shadow-claw-tools-B0y8JzoA.js.map} +1 -1
- package/dist/lib/{shadow-claw-webvm-Dc2KmEXq.js → shadow-claw-webvm-CoCedIza.js} +2 -2
- package/dist/lib/{shadow-claw-webvm-Dc2KmEXq.js.map → shadow-claw-webvm-CoCedIza.js.map} +1 -1
- package/dist/lib/{syncWebMcpRegistration-BIL83P0Q.js → syncWebMcpRegistration-JKLALq4e.js} +2 -2
- package/dist/lib/{syncWebMcpRegistration-BIL83P0Q.js.map → syncWebMcpRegistration-JKLALq4e.js.map} +1 -1
- package/dist/lib/worker/utils/sandboxedEval.d.ts +8 -0
- package/dist/public/.well-known/mcp/server-card.json +1 -1
- package/dist/public/.well-known/mcp.json +1 -1
- package/dist/public/AGENTS.md +1 -1
- package/dist/public/README.md +5 -1
- package/dist/public/agent.worker.js +1 -1
- package/dist/public/components/shadow-claw-tools/shadow-claw-tools.html +1 -1
- package/dist/public/{configurePeerJs-B925t9C7.js → configurePeerJs-BrHeJGw1.js} +1 -1
- package/dist/public/docs/decisions/headless-cli-agent-participant.md +1 -1
- package/dist/public/docs/example/article/index.html +1 -1
- package/dist/public/docs/publishing/index.html +1 -1
- package/dist/public/docs/skill-creator/index.html +1 -1
- package/dist/public/docs/subsystems/cli.md +33 -23
- package/dist/public/docs/subsystems/skills.md +17 -0
- package/dist/public/docs/subsystems/tools.md +1 -1
- package/dist/public/e2e/README.md +2 -2
- package/dist/public/{e2e-bridge-CE1xleGn.js → e2e-bridge-D_lyH__p.js} +1 -1
- package/dist/public/{executeTool-DtTrsZHV.js → executeTool-b6DnRhcv.js} +2 -1
- package/dist/public/{file-viewer-LEEStSq-.js → file-viewer-CKrQoxZi.js} +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/index.js +1 -1
- package/dist/public/{initControlPlane-e2JgxXEb.js → initControlPlane-Dn-XFuxg.js} +1 -1
- package/dist/public/llms.txt +2 -0
- package/dist/public/main/index.html +1 -1
- package/dist/public/main/memory/index.html +1 -1
- package/dist/public/{orchestrator-Baif6kmu.js → orchestrator-0BnBtxHO.js} +3 -2
- package/dist/public/{orchestrator-TndREZPL.js → orchestrator-C3GKZriH.js} +1 -1
- package/dist/public/{peerjs-DE6WF3h2.js → peerjs-CgfLEp2N.js} +1 -1
- package/dist/public/{push-client-B_IkTpNm.js → push-client-D6DLiY1s.js} +1 -1
- package/dist/public/service-worker.js +1 -1
- package/dist/public/{shadow-claw-channels-BCGz36Zl.js → shadow-claw-channels-DSijinZ9.js} +1 -1
- package/dist/public/{shadow-claw-chat-H9U9jbqD.js → shadow-claw-chat-BeHlAjnA.js} +1 -1
- package/dist/public/{shadow-claw-control-plane-CeKh64s2.js → shadow-claw-control-plane-BfF_AZSg.js} +2 -2
- package/dist/public/{shadow-claw-conversations-C26t1HXN.js → shadow-claw-conversations-Bb_2bVLJ.js} +1 -1
- package/dist/public/{shadow-claw-DBeXILmk.js → shadow-claw-f71DlRdV.js} +2 -2
- package/dist/public/{shadow-claw-file-viewer-DWUoTjkr.js → shadow-claw-file-viewer-B67000Mm.js} +1 -1
- package/dist/public/{shadow-claw-files-BQ8DSX-z.js → shadow-claw-files-DeZZYt01.js} +1 -1
- package/dist/public/{shadow-claw-git-CIXyISw-.js → shadow-claw-git-Ccy25LuW.js} +2 -2
- package/dist/public/{shadow-claw-llm-D_GpOSZE.js → shadow-claw-llm-XjYcTlXT.js} +1 -1
- package/dist/public/{shadow-claw-networking-BYp5K3B7.js → shadow-claw-networking-efXQtydQ.js} +1 -1
- package/dist/public/{shadow-claw-notifications-ZiXmPweY.js → shadow-claw-notifications-Cq2ZSeJa.js} +1 -1
- package/dist/public/{shadow-claw-pages-BHXwf3BD.js → shadow-claw-pages-BVFNSSb1.js} +1 -1
- package/dist/public/{shadow-claw-settings-BfvDvt9c.js → shadow-claw-settings-B3sHxPh9.js} +2 -2
- package/dist/public/{shadow-claw-storage-Bvn85DII.js → shadow-claw-storage-DNdlzCgC.js} +1 -1
- package/dist/public/{shadow-claw-task-server-DZL_d8FC.js → shadow-claw-task-server-BJq0rpju.js} +1 -1
- package/dist/public/{shadow-claw-tasks-Cy8jzd8q.js → shadow-claw-tasks-CkF1uMeZ.js} +1 -1
- package/dist/public/{shadow-claw-terminal-BgEXr82T.js → shadow-claw-terminal-CnHhcpA-.js} +1 -1
- package/dist/public/{shadow-claw-tools-BjnssRSi.js → shadow-claw-tools-iw0fljud.js} +8 -1
- package/dist/public/{shadow-claw-webvm-tZ1VDoVA.js → shadow-claw-webvm-Bliu4V__.js} +1 -1
- package/dist/public/{syncWebMcpRegistration-CLMvJ4kV.js → syncWebMcpRegistration-D91usEMu.js} +1 -1
- package/package.json +1 -1
- package/src/cli/cli.ts +26 -2
- package/src/cli/commands/agent.test.ts +421 -0
- package/src/cli/commands/agent.ts +270 -20
- package/src/components/shadow-claw-tools/shadow-claw-tools.html +7 -0
- package/src/worker/headless-agent.ts +14 -0
- package/src/worker/headless-types.ts +39 -0
- package/src/worker/utils/native-eval-executor.test.ts +36 -0
- package/src/worker/utils/native-eval-executor.ts +58 -0
- package/src/worker/utils/sandboxedEval.ts +36 -0
- package/dist/cli/chunk-1BmpU7jO2.js +0 -1
- package/dist/cli/chunk-54Euq8Ji2.js +0 -1
- package/dist/cli/chunk-BTitwCgT2.js +0 -88
- package/dist/cli/chunk-Bjh76Dai.js +0 -1081
- package/dist/cli/chunk-C2HeZQ6K.js +0 -1
- package/dist/cli/chunk-CxdpafWg.js +0 -1
- package/dist/cli/chunk-DEy72ZNV2.js +0 -88
- package/dist/cli/chunk-Da1BZyqf.js +0 -1
- package/dist/cli/chunk-FHsJD-Sf2.js +0 -27
- package/dist/cli/chunk-aWgoVB7x2.js +0 -1
- package/dist/cli/chunk-hOceZVB92.js +0 -371
- package/dist/cli/chunk-pwNc6VtC2.js +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import{T as e,h as t,o as n,r}from"./chunk-BkKN8FNP.js";import{t as i}from"./chunk-DFLqhyP_.js";import{t as a}from"./chunk-Dhh0lHO62.js";import{r as o}from"./chunk-BQCWtrzh2.js";import{a as s}from"./chunk-Cx0FUKuw2.js";import{a as c,u as l}from"./chunk-LIIpZlwP2.js";import u from"gray-matter";async function d(e,...t){let n=e;for(let e of t){let t=await n.getDirectoryHandle(e,{create:!0});if(typeof n.isSameEntry==`function`&&await n.isSameEntry(t))throw Error(`Directory navigation failed: "${e}" resolved to the same directory as its parent. The stored directory handle may be stale — try re-selecting the storage folder.`);n=t}return n}let f=null;async function p(e,t){try{return await e.entries().next(),`granted`}catch{return t}}function m(){let n=e();return n?`${t}-${n}`:t}async function h(){try{if(typeof navigator<`u`&&navigator.storage&&typeof navigator.storage.getDirectory==`function`){let e=await navigator.storage.getDirectory(),t=m();return await e.getDirectoryHandle(t,{create:!0})}}catch(e){console.warn(`OPFS is unavailable (e.g. Firefox Private Browsing). Using in-memory storage fallback:`,e)}return s()}function g(e){if(!e||typeof e!=`object`)return!1;let t=globalThis.FileSystemDirectoryHandle;return t!==void 0&&e instanceof t||typeof e.getDirectoryHandle==`function`&&typeof e.getFileHandle==`function`}async function _(e){if(f)return f;try{let t=await a(e,r.STORAGE_HANDLE);if(g(t)){let e=t;if(typeof e.queryPermission==`function`&&await e.queryPermission({mode:`readwrite`})!==`granted`&&typeof e.requestPermission==`function`)try{await e.requestPermission({mode:`readwrite`})}catch{}return e}}catch(e){console.warn(`Failed to retrieve local storage handle from DB:`,e)}return h()}function v(e){f=e}function y(){f=null}function b(e){return e instanceof DOMException&&e.name===`InvalidStateError`}async function x(e){if(f)try{let e=await f.queryPermission({mode:`readwrite`});return{type:`local`,permission:e===`granted`?`granted`:await p(f,e),name:f.name}}catch{console.warn(`Getting storage status failed for explicit storage root.`)}try{let t=await a(e,r.STORAGE_HANDLE);if(g(t)){let e=t,n=await e.queryPermission({mode:`readwrite`});return{type:`local`,permission:n===`granted`?`granted`:await p(e,n),name:e.name}}}catch(e){console.warn(`Failed to check storage status:`,e)}return{type:`opfs`,permission:`granted`,name:`OPFS`}}async function S(e,t){let n=await _(e);return o()?n:d(n,`groups`,t.replace(/:/g,`-`))}function C(e){let t=e.replace(/\\/g,`/`).replace(/^\/home\/user\//,`/`).replace(/^\/+/,``).split(`/`).filter(Boolean);if(t.length===0)throw Error(`Empty file path`);return{dirs:t,filename:t.pop()||``}}function w(e,t,n){return i(e,`config`,`readwrite`,e=>e.put({key:t,value:n})).then(()=>void 0)}async function T(e,t,n){let r=await S(e,t),{dirs:i,filename:a}=C(n),o=r;for(let e of i)o=await o.getDirectoryHandle(e);let s=await o.getFileHandle(a);try{let e=await s.createSyncAccessHandle(),t=e.getSize(),n=new Uint8Array(t);return e.read(n,{at:0}),e.close(),new TextDecoder(`utf-8`).decode(n)}catch{return(await s.getFile()).text()}}const E={name:`bash`,description:`Execute a shell command. When WebVM is available, runs in a full Alpine Linux VM (x86) with all standard Linux commands. When WebVM is disabled or unavailable, falls back to a lightweight JavaScript shell emulator with 83 commands: alias, awk, base64, basename, bash, cat, cd, chmod, clear, column, comm, command, cp, curl, cut, date, diff, dirname, du, echo, egrep, env, expand, export, expr, false, fgrep, file, find, fold, grep, gunzip, gzip, head, help, html-to-markdown, join, jq, ln, ls, md5sum, mkdir, mv, nl, od, paste, printenv, printf, pwd, readlink, realpath, rev, rg, rm, rmdir, sed, seq, sh, sha1sum, sha256sum, sha384sum, sha512sum, sleep, sort, split, stat, strings, tac, tail, tar, tee, test, timeout, touch, tr, tree, true, unalias, uniq, wc, which, xargs, yes, zcat. Commands NOT available in fallback mode: node, npm, npx, git, apk, python, wget.Supports pipes (|), redirects (> >>), operators (&& || ;), newlines, and # comments. Prefer read_file/write_file for file inspection and edits — they are faster and more reliable than shell commands for that purpose.`,input_schema:{type:`object`,properties:{command:{type:`string`,description:`The bash command to execute`},stdin:{type:`string`,description:`Optional standard input (stdin) to pass to the command`},timeout:{type:`number`,description:`Timeout in seconds (default from Settings, initially 120; max: 1800)`}},required:[`command`]}},D={name:`clear_chat`,description:`Clear the current chat history and start a new session. Useful for scheduled tasks to prevent context from growing indefinitely.`,input_schema:{type:`object`,properties:{}}},O={name:`ask_user`,description:`Pause execution to ask the user a question or request confirmation. This halts the agent's work until the user provides an answer. Use this for human-in-the-loop checkpoints before taking destructive actions or when you need clarification to proceed.`,input_schema:{type:`object`,properties:{question:{type:`string`,description:`The question or confirmation message to present to the user.`},options:{type:`array`,items:{type:`string`},description:`Optional list of predefined choices for the user to select from.`}},required:[`question`]}},k={name:`manage_email`,description:`Manage email connection settings for IMAP/SMTP workflows. Supports status, connect/configure, enable/disable, delete, read_messages, send_message, mark_as_read, mark_as_unread, delete_messages, download_attachments, list available connection types, and lightweight test actions.`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`status`,`list_plugins`,`list_connections`,`connect`,`configure`,`enable`,`disable`,`delete`,`test`,`read_messages`,`send_message`,`mark_as_read`,`mark_as_unread`,`delete_messages`,`download_attachments`],description:`Email management action to perform.`},plugin_id:{type:`string`,description:`Optional connection type ID for connect operations (default: imap).`},connection_id:{type:`string`,description:`Connection ID or label for configure, enable, disable, delete, and test actions. For read_messages/send_message, it may be omitted when there is exactly one enabled IMAP connection.`},label:{type:`string`,description:`Human-readable connection label for new connections.`},enabled:{type:`boolean`,description:`Optional enabled flag used during connect/configure actions.`},config:{type:`object`,properties:{},description:`Email config object (host, port, secure, mailboxPath, smtpHost, smtpPort, smtpSecure, etc.).`},mailbox_path:{type:`string`,description:`Optional mailbox path override for read_messages (default: INBOX).`},limit:{type:`number`,description:`Optional max messages to fetch for read_messages (default 10, range 1-50).`},unread_only:{type:`boolean`,description:`If true, read_messages returns only unread messages.`},message_uids:{type:`array`,items:{type:`number`},description:`Message UIDs for mark_as_read, mark_as_unread, and delete_messages actions.`},message_uid:{type:`number`,description:`Single message UID used by download_attachments action.`},attachment_parts:{type:`array`,items:{type:`string`},description:`Optional IMAP MIME part IDs to download (for example: 2, 3.1). If omitted, all attachments in the message are downloaded.`},save_directory:{type:`string`,description:`Optional workspace directory for downloaded attachments (default: downloads/email).`},attachments:{type:`array`,items:{anyOf:[{type:`string`},{type:`object`,properties:{path:{type:`string`},filename:{type:`string`},content_type:{type:`string`}},required:[`path`]}]},description:`Optional workspace file attachments for send_message. Provide paths or objects with path/filename/content_type.`},to:{type:`array`,items:{type:`string`},description:`Recipient email addresses for send_message.`},cc:{type:`array`,items:{type:`string`},description:`Optional CC recipient addresses for send_message.`},bcc:{type:`array`,items:{type:`string`},description:`Optional BCC recipient addresses for send_message.`},subject:{type:`string`,description:`Message subject for send_message.`},body:{type:`string`,description:`Plaintext message body for send_message.`},html:{type:`string`,description:`Optional HTML body for send_message.`},from:{type:`string`,description:`Optional from address override for send_message.`},reply_to:{type:`string`,description:`Optional reply-to address for send_message.`},username:{type:`string`,description:`Optional username override for connect/configure/read_messages/send_message.`},password:{type:`string`,description:`Optional password override for connect/configure/read_messages/send_message.`}},required:[`action`]}},A={name:`email_read_messages`,description:`Read recent messages from a configured email connection (IMAP). Use this to check inbox mail from an agent workflow. Results include attachment metadata when available.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Email connection ID or label.`},mailbox_path:{type:`string`,description:`Optional mailbox path override (default: INBOX).`},limit:{type:`number`,description:`Optional max messages to fetch (default 10, range 1-50).`},unread_only:{type:`boolean`,description:`If true, only unread messages are returned.`}},required:[`connection_id`]}},j={name:`email_send_message`,description:`Send an email message through a configured email connection (SMTP).`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Email connection ID or label.`},to:{type:`array`,items:{type:`string`},description:`Recipient email addresses.`},cc:{type:`array`,items:{type:`string`},description:`Optional CC recipient addresses.`},bcc:{type:`array`,items:{type:`string`},description:`Optional BCC recipient addresses.`},subject:{type:`string`,description:`Message subject.`},body:{type:`string`,description:`Plaintext message body.`},html:{type:`string`,description:`Optional HTML message body.`},from:{type:`string`,description:`Optional from address override.`},reply_to:{type:`string`,description:`Optional reply-to address.`}},required:[`connection_id`,`to`,`subject`]}},ee={name:`fetch_url`,description:`Fetch a URL via HTTP and return the response body. Subject to browser CORS restrictions — works with most public APIs. Response is truncated to 100KB. Set use_git_auth to true to automatically inject the saved Git PAT as an Authorization header (supports GitHub, Azure DevOps, GitLab, and other providers — auth format is auto-detected from the URL's host). If include_headers is true, the response will include both request and response headers.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`The URL to fetch`},method:{type:`string`,description:`HTTP method (default: GET)`},headers:{type:`object`,properties:{},description:`Request headers as key-value pairs`},body:{type:`string`,description:`Request body (for POST/PUT/PATCH)`},use_git_auth:{type:`boolean`,description:`If true, inject the saved Git credentials as an Authorization header. Auth format is auto-detected from the URL host: GitHub (token), Azure DevOps (Basic), GitLab (Bearer), or generic Bearer.`},git_account_id:{type:`string`,description:`Optional explicit Git account ID to use when use_git_auth is true. If omitted, account resolution uses hostPattern/default matching.`},use_account_auth:{type:`boolean`,description:`If true, inject a saved service account PAT as a Bearer Authorization header. The account is matched by hostPattern against the URL (longest match wins), then falls back to the default service account. Use this for non-Git services like Figma, Notion, or any other service whose PAT is stored under Settings → Accounts.`},account_id:{type:`string`,description:`Optional explicit service account ID to use when use_account_auth is true. If omitted, account resolution uses hostPattern/default matching.`},auth_mode:{type:`string`,enum:[`pat`,`oauth`],description:`Optional preferred credential mode when multiple accounts match. Valid values: pat or oauth.`},include_headers:{type:`boolean`,description:`If true, include request and response headers in the output.`}},required:[`url`]}},te={name:`fetch_file`,description:`Fetch a URL and save the response body directly to the workspace in one step. Equivalent to fetch_url + write_file but atomic. Text responses are saved as UTF-8; binary responses (images, PDFs, audio, video, zip, application/octet-stream) are saved as raw bytes. The destination path within the workspace is required. Supports the same authentication options as fetch_url (use_git_auth, use_account_auth, etc.). Returns the workspace path the file was saved to and the number of bytes written.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`The URL to fetch`},path:{type:`string`,description:`Destination path within the workspace (e.g. 'data/response.json'). Parent directories are created automatically. Must not contain '..' segments.`},method:{type:`string`,description:`HTTP method (default: GET)`},headers:{type:`object`,properties:{},description:`Request headers as key-value pairs`},body:{type:`string`,description:`Request body (for POST/PUT/PATCH)`},use_git_auth:{type:`boolean`,description:`If true, inject the saved Git credentials as an Authorization header. Auth format is auto-detected from the URL host: GitHub (token), Azure DevOps (Basic), GitLab (Bearer), or generic Bearer.`},git_account_id:{type:`string`,description:`Optional explicit Git account ID to use when use_git_auth is true. If omitted, account resolution uses hostPattern/default matching.`},use_account_auth:{type:`boolean`,description:`If true, inject a saved service account PAT as a Bearer Authorization header. The account is matched by hostPattern against the URL (longest match wins), then falls back to the default service account.`},account_id:{type:`string`,description:`Optional explicit service account ID to use when use_account_auth is true. If omitted, account resolution uses hostPattern/default matching.`},auth_mode:{type:`string`,enum:[`pat`,`oauth`],description:`Optional preferred credential mode when multiple accounts match. Valid values: pat or oauth.`}},required:[`url`,`path`]}},ne={name:`web_search`,description:`Perform a web search using a search engine to discover information. Returns a plain-text summary of the top search results including titles, URLs, and snippets. Use this when you need to find information but don't know the exact URL to fetch.`,input_schema:{type:`object`,properties:{query:{type:`string`,description:`The search query to look up.`}},required:[`query`]}},re={name:`javascript`,description:`Execute JavaScript code in a sandboxed Worker and return the result. Lighter than bash — no VM boot required. Use for calculations, data transformations, JSON processing, string analysis, etc. Runs in strict mode. No access to DOM, eval(), Function(), self, postMessage, importScripts, navigator, or indexedDB — these are all undefined. fetch availability is controlled by Tool Configuration -> Internet Access (shared with bash). setTimeout is available but setInterval is blocked. IMPORTANT: You CANNOT call other agent tools (like read_file, write_file, or bash) from inside this sandbox. If you need to process file contents or tool outputs, you must fetch them in a previous turn and pass the data into this tool via the $PIPE_DATA variable. Write plain JavaScript expressions and statements — the return value of the last expression is captured as the result.`,input_schema:{type:`object`,properties:{code:{type:`string`,description:`JavaScript code to execute. The return value of the last expression is captured.`},data:{type:`string`,description:"Optional input data string. Accessible inside the code sandbox via the global constant `$PIPE_DATA`."}},required:[`code`]}},ie={name:`remote_mcp_list_tools`,description:`List available tools from a configured Remote MCP connection by connection ID or label.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Remote MCP connection ID or label`}},required:[`connection_id`]}},ae={name:`remote_mcp_call_tool`,description:`Call a tool exposed by a configured Remote MCP connection.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Remote MCP connection ID or label`},tool_name:{type:`string`,description:`Remote MCP tool name`},arguments:{type:`object`,properties:{},description:`Arguments object passed to the remote MCP tool`}},required:[`connection_id`,`tool_name`]}},oe={name:`manage_tools`,description:`Enable or disable specific tools, or activate a predefined tool profile. Use list_tool_profiles to see available profiles before activating one. This helps optimize the context window and focus capabilities. Changes take effect on the NEXT turn, not immediately within the current tool-use loop.`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`enable`,`disable`,`activate_profile`],description:`The management action to perform.`},tool_names:{type:`array`,items:{type:`string`},description:`List of tool names to enable or disable. Required for 'enable' and 'disable' actions.`},profile_id:{type:`string`,description:`The unique ID of the tool profile to activate. Required for 'activate_profile' action.`}},required:[`action`]}},se={name:`list_tool_profiles`,description:`List all available tool profiles that can be activated using manage_tools. Returns a list of profiles with their IDs, names, and the tools they contain.`,input_schema:{type:`object`,properties:{}}},ce={name:`update_memory`,description:`Update the MEMORY.md memory file for this group. Use this to persist important context, user preferences, project state, and anything the agent should remember across conversations. This file is loaded as system context on every invocation.`,input_schema:{type:`object`,properties:{content:{type:`string`,description:`New content for the MEMORY.md memory file`}},required:[`content`]}},M={name:`show_toast`,description:`Show a toast notification to the user. Toasts are non-blocking, auto-dismissing notifications that appear in the bottom-right corner. Use for: operation status (success/failure), warnings, informational messages, progress updates. Avoid for: critical errors requiring acknowledgment (use clear error messages instead), lengthy content (keep messages concise).`,input_schema:{type:`object`,properties:{message:{type:`string`,description:`The message to display in the toast (keep concise)`},type:{type:`string`,description:`Type of toast: 'success', 'error', 'warning', or 'info' (default: 'info')`,enum:[`success`,`error`,`warning`,`info`]},duration:{type:`number`,description:`Auto-dismiss duration in milliseconds (default: 5000 for info/success, 8000 for warning/error). Set to 0 to disable auto-dismiss.`}},required:[`message`]}},N={name:`send_notification`,description:`Send an OS-level push notification to the user via Web Push. Unlike toasts (in-app only), push notifications appear even when the app is not focused or the tab is in the background. Use for: important alerts, long-running task completion, time-sensitive information. Requires the user to have enabled push notifications in Settings.`,input_schema:{type:`object`,properties:{title:{type:`string`,description:`Notification title (default: 'ShadowClaw')`},body:{type:`string`,description:`The notification body text`}},required:[`body`]}},P=`https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json`,F=`A2UI Basic Catalog — Component & Function Reference
|
|
2
|
+
=====================================================
|
|
3
|
+
|
|
4
|
+
Catalog ID: ${P}
|
|
5
|
+
|
|
6
|
+
CRITICAL AUTHORING RULES
|
|
7
|
+
-------------------------
|
|
8
|
+
1. Put ALL properties at the TOP LEVEL of each component object alongside "component" and "id".
|
|
9
|
+
WRONG: {"id":"t","component":"Text","properties":{"text":"Hello"}}
|
|
10
|
+
RIGHT: {"id":"t","component":"Text","text":"Hello"}
|
|
11
|
+
|
|
12
|
+
2. "components" is a FLAT ARRAY of objects, each with a required "id" field.
|
|
13
|
+
The root of the component tree MUST have id "root".
|
|
14
|
+
WRONG: {"root": {"component":"Column","children":["title"]}}
|
|
15
|
+
RIGHT: [{"id":"root","component":"Column","children":["title"]},{"id":"title","component":"Text","text":"Hello"}]
|
|
16
|
+
|
|
17
|
+
3. To make a property UPDATABLE later via the "updateDataModel" action, bind it
|
|
18
|
+
using {"path": "/your_key"} and initialise that key in the dataModel.
|
|
19
|
+
STATIC (never changes): {"id":"t","component":"Text","text":"Result will appear here"}
|
|
20
|
+
DYNAMIC (updatable): {"id":"t","component":"Text","text":{"path":"/result"}}
|
|
21
|
+
|
|
22
|
+
4. "children" and "child" contain COMPONENT ID STRINGS, not nested objects.
|
|
23
|
+
WRONG: {"id":"col","component":"Column","children":[{"component":"Text","text":"Hi"}]}
|
|
24
|
+
RIGHT: [{"id":"col","component":"Column","children":["hi"]},{"id":"hi","component":"Text","text":"Hi"}]
|
|
25
|
+
|
|
26
|
+
5. Button "child" must be the id of a Text component in the same components array.
|
|
27
|
+
Button "action" must be {"event":{"name":"myActionId"}}.
|
|
28
|
+
|
|
29
|
+
6. Use updateDataModel with a single path and value per call:
|
|
30
|
+
action: "updateDataModel", surfaceId: "s", path: "/result", value: "done!"
|
|
31
|
+
To update multiple fields, call render_component once per field.
|
|
32
|
+
|
|
33
|
+
7. To concatenate or inject data bindings into strings, use formatString:
|
|
34
|
+
{"call":"formatString","args":{"value":"Hello \${/user/name}"}}
|
|
35
|
+
|
|
36
|
+
Components
|
|
37
|
+
----------
|
|
38
|
+
Text — text (string or {"path":"/key"}, required), variant? ("caption"|"body")
|
|
39
|
+
Row — children (string[] or template {"path":"/list","componentId":"tmpl"}, required), justify?, align?
|
|
40
|
+
Column — children (string[] or template, required), justify?, align?
|
|
41
|
+
Button — child (string, required — id of a Text or Icon component),
|
|
42
|
+
action ({"event":{"name":"myActionId"}}, required), variant? ("default"|"primary"|"borderless")
|
|
43
|
+
TextField — label (required), value? ({"path":"/key"}), placeholder?,
|
|
44
|
+
variant? ("shortText"|"longText"|"number"|"obscured")
|
|
45
|
+
Image — url (required), description?, fit?, variant?
|
|
46
|
+
Icon — name (required; enum string, {"svgPath":"..."}, or {"path":"/key"})
|
|
47
|
+
Video — url (required), posterUrl?
|
|
48
|
+
AudioPlayer — url (required), description?
|
|
49
|
+
List — children (string[] or template, required), direction?, align?
|
|
50
|
+
Card — child (required; component id string)
|
|
51
|
+
Tabs — tabs[] (each: {title, child}, required)
|
|
52
|
+
Modal — trigger (component id, required), content (component id, required)
|
|
53
|
+
Divider — axis? ("horizontal"|"vertical")
|
|
54
|
+
CheckBox — label (required), value ({"path":"/key"} or boolean, required)
|
|
55
|
+
ChoicePicker — label?, variant? ("mutuallyExclusive"|"multipleSelection"),
|
|
56
|
+
options[] (each: {label, value}, required), value ({"path":"/key"}, required),
|
|
57
|
+
displayStyle? ("checkbox"|"chips"), filterable?
|
|
58
|
+
Slider — max (required), value ({"path":"/key"} or number, required), label?, min?, steps?
|
|
59
|
+
DateTimeInput — value (required; {"path":"/key"} or ISO 8601 string), enableDate?, enableTime?,
|
|
60
|
+
min?, max?, label?
|
|
61
|
+
|
|
62
|
+
Functions (data binding & validation)
|
|
63
|
+
---------------------------------------
|
|
64
|
+
formatString(value) — string interpolation: {"call":"formatString","args":{"value":"Hi \${/name}"}}
|
|
65
|
+
formatNumber(value,decimals?,grouping?) — number formatting
|
|
66
|
+
formatCurrency(value,currency,decimals?,grouping?) — currency formatting
|
|
67
|
+
formatDate(value,format) — date formatting using Unicode TR35 patterns
|
|
68
|
+
pluralize(value,one,other,...) — CLDR plural-aware string selection
|
|
69
|
+
openUrl(url) — open a URL (action function, no return value)
|
|
70
|
+
required(value) — validation: checks value is not empty
|
|
71
|
+
regex(value,pattern) — validation: checks value matches regex
|
|
72
|
+
length(value,min?,max?) — validation: checks string length
|
|
73
|
+
numeric(value,min?,max?) — validation: checks number range
|
|
74
|
+
email(value) — validation: checks value is a valid email
|
|
75
|
+
and(values[]) — logical AND of boolean values
|
|
76
|
+
or(values[]) — logical OR of boolean values
|
|
77
|
+
not(value) — logical NOT of a boolean value
|
|
78
|
+
|
|
79
|
+
NOTE: ShadowClaw additionally supports "capitalize" as an extension function
|
|
80
|
+
(not in the official spec): {"call":"capitalize","args":{"value":{"path":"/name"}}}
|
|
81
|
+
|
|
82
|
+
Validator / boolean functions evaluate to boolean and are used in "checks" rules;
|
|
83
|
+
they do not produce a displayable string.
|
|
84
|
+
|
|
85
|
+
Example (correct — createSurface)
|
|
86
|
+
----------------------------------
|
|
87
|
+
action: "createSurface"
|
|
88
|
+
surfaceId: "my-surface"
|
|
89
|
+
components: [
|
|
90
|
+
{"id":"root", "component":"Column","children":["title","btn"]},
|
|
91
|
+
{"id":"title", "component":"Text","text":"Hello World","variant":"body"},
|
|
92
|
+
{"id":"btn_lbl", "component":"Text","text":"Click Me"},
|
|
93
|
+
{"id":"btn", "component":"Button","child":"btn_lbl","action":{"event":{"name":"submit"}},"variant":"primary"}
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
Example (updateDataModel)
|
|
97
|
+
--------------------------
|
|
98
|
+
action: "updateDataModel"
|
|
99
|
+
surfaceId: "my-surface"
|
|
100
|
+
path: "/result"
|
|
101
|
+
value: "done!"
|
|
102
|
+
`,I=[O,{name:`attach_file_to_chat`,description:`Prepare a workspace file for chat delivery by generating an exact markdown attachment snippet. Validates the file path and returns markdown that works for inline image rendering in ShadowClaw and attachment upload in external channels like Telegram/iMessage.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},alt:{type:`string`,description:`Optional alt/caption text to use in the generated markdown`}},required:[`path`]}},E,D,{name:`copy_file`,description:`Copy a file or directory in the group workspace to a new destination path. Supports copying single files or nested directories. Optionally supports copying between different conversation workspaces via source_group_id or target_group_id.`,input_schema:{type:`object`,properties:{source_path:{type:`string`,description:`Source file or directory path relative to workspace root`},target_path:{type:`string`,description:`Destination file or directory path relative to workspace root`},source_group_id:{type:`string`,description:`Optional source conversation group ID (defaults to current workspace)`},target_group_id:{type:`string`,description:`Optional target conversation group ID (defaults to current workspace)`}},required:[`source_path`,`target_path`]}},{name:`create_directory`,description:`Create a new directory (and any missing parent directories) in the group workspace.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Directory path relative to the group workspace root`}},required:[`path`]}},{name:`create_room`,description:`Create a new multi-party room (a shared PeerJS conversation) hosted by this device. Other agents or humans can then be invited to participate. Returns the room so you can share or invite peers into it.`,input_schema:{type:`object`,properties:{name:{type:`string`,description:`A human-readable name for the room.`}},required:[`name`]}},{name:`create_task`,description:`Create a scheduled recurring task. The task will run automatically on the specified schedule and send the result back to this group. Uses cron expressions (minute hour day-of-month month day-of-week).`,input_schema:{type:`object`,properties:{schedule:{type:`string`,description:`Cron expression, e.g. "0 9 * * 1-5" for 9am weekdays`},prompt:{type:`string`,description:`The prompt/instruction to execute on each run (used if type is 'prompt')`},type:{type:`string`,enum:[`prompt`,`tools`],description:`The type of task to create. Defaults to 'prompt'.`},tools:{type:`array`,description:`A list of tools to execute sequentially (used if type is 'tools')`,items:{type:`object`,properties:{name:{type:`string`},input:{type:`object`}},required:[`name`,`input`]}},name:{type:`string`,description:`The optional title/name for the task, helping to identify its purpose.`}},required:[`prompt`,`type`]}},{name:`delete_file`,description:`Delete a file or directory from the group workspace. If the target path is a directory, it will be recursively deleted.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File or directory path relative to the group workspace root`}},required:[`path`]}},{name:`delete_task`,description:`Delete a scheduled task by its ID.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to delete`}},required:[`id`]}},{name:`detect_language`,description:`Detect the language of input text using Web Platform's Language Detector API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to analyze for language detection.`}},required:[`text`]}},{name:`diff_files`,description:`Compare two files in the workspace and output the differences. Useful for comparing generated code, checking before patching, or finding changes outside of git repositories.`,input_schema:{type:`object`,properties:{path_a:{type:`string`,description:`Path to the first file relative to the group workspace root.`},path_b:{type:`string`,description:`Path to the second file relative to the group workspace root.`}},required:[`path_a`,`path_b`]}},{name:`disable_task`,description:`Disable a scheduled task so it stops running.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to disable`}},required:[`id`]}},A,j,{name:`enable_task`,description:`Enable a scheduled task so it runs on its schedule.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to enable`}},required:[`id`]}},te,ee,{name:`get_current_time`,description:`Get the current date and time. Returns an ISO 8601 string representing the current date and time. Use this tool whenever you need to know the current time, instead of relying on shell tools which may be unavailable.`,input_schema:{type:`object`,properties:{timezone:{type:`string`,description:`Optional timezone to format the time in (e.g. 'America/New_York'). If omitted, returns UTC.`}}}},{name:`git_add`,description:`Stage files in a cloned repo. Accepts an array of filepaths. If omitted or empty, stages the repo root.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},filepaths:{type:`array`,items:{type:`string`},description:`Array of file paths to stage (relative to repo root). Pass a single item for one file.`}},required:[`repo`]}},{name:`git_branch`,description:`Create a new branch in a cloned repo. Optionally switch to it immediately (like git checkout -b).`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (returned by git_clone)`},name:{type:`string`,description:`Name for the new branch`},checkout:{type:`boolean`,description:`Switch to the new branch after creating it (default: false)`},start_point:{type:`string`,description:`Branch, tag, or commit SHA to branch from (default: HEAD)`}},required:[`repo`,`name`]}},{name:`git_branches`,description:`List branches in a cloned repo. Current branch is marked with *.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},remote:{type:`boolean`,description:`List remote-tracking branches instead (default: false)`}},required:[`repo`]}},{name:`git_checkout`,description:`Checkout a branch, tag, or commit SHA in a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (returned by git_clone)`},ref:{type:`string`,description:`Branch name, tag, or commit SHA to checkout`}},required:[`repo`,`ref`]}},{name:`git_clone`,description:`Clone a git repository into browser-persistent OPFS storage. Files are stored directly under repos/<repo-name>/ in the workspace and are immediately accessible to other git_* tools without any extra sync step. Works with public and private repos (GitHub, GitLab, GitHub Enterprise, etc.). If a Git PAT is configured in Settings, it is used automatically for authentication. Uses a CORS proxy. Returns the short repo name used for subsequent git_* operations.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`Full HTTPS repo URL (e.g. https://github.com/user/repo)`},name:{type:`string`,description:`Optional short repo name to use for the clone directory; defaults to the repository name parsed from the URL.`},branch:{type:`string`,description:`Branch to clone (default: default branch)`},depth:{type:`number`,description:`Shallow clone depth (default: 20)`}},required:[`url`]}},{name:`git_commit`,description:`Stage all changes and create a commit in a cloned repo. Uses configured git author name/email or defaults.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},message:{type:`string`,description:`Commit message`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`,`message`]}},{name:`git_config`,description:`Get or set a git config value for a repo (e.g. user.name, user.email). Persistent per-repo identity avoids specifying author on every commit.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},command:{type:`string`,enum:[`get`,`set`],description:`Operation: get or set a config value`},key:{type:`string`,description:`Config key path (e.g. user.name, user.email, core.autocrlf)`},value:{type:`string`,description:`Value to set — required when command is set`}},required:[`repo`,`command`,`key`]}},{name:`git_delete_branch`,description:`Delete a local branch from a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},name:{type:`string`,description:`Name of the branch to delete`}},required:[`repo`,`name`]}},{name:`git_delete_repo`,description:"Delete the git metadata for a cloned repository while leaving the working tree files in place. Use this to clean up corrupted or stale repos that fail to re-clone. The repo directory remains under repos/<repo>, but the `.git/` metadata is removed.",input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (as returned by git_clone or git_list_repos)`}},required:[`repo`]}},{name:`git_diff`,description:`Show changed files between HEAD and working tree, or between two refs.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref1:{type:`string`,description:`First ref (default: HEAD)`},ref2:{type:`string`,description:`Second ref (if omitted, diffs HEAD vs workdir)`}},required:[`repo`]}},{name:`git_fetch`,description:`Fetch commits from the remote without merging. Safe for inspecting remote state before deciding to merge or rebase.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Remote branch to fetch (default: default branch)`},remote:{type:`string`,description:`Remote name (default: origin)`}},required:[`repo`]}},{name:`git_init`,description:`Initialize a new empty git repository in browser storage. Use this to create a new project from scratch before using git_push to push to a remote.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short name for the new repo (used for all subsequent git_ operations)`}},required:[`repo`]}},{name:`git_list_repos`,description:`List all git repositories currently cloned in browser storage.`,input_schema:{type:`object`,properties:{}}},{name:`git_log`,description:`Show the commit log for a cloned repo. Returns commit SHA, date, author, and message.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Ref to log from (default: HEAD)`},depth:{type:`number`,description:`Number of commits to show (default: 10)`}},required:[`repo`]}},{name:`git_merge`,description:`Merge a branch or ref into the current branch. Supports fast-forward and three-way merges. If the merge has conflicts, a detailed report is returned with the conflicted files and their conflict regions inline. To resolve: use read_file on each conflicted file, then write_file with the complete resolved content (no conflict markers). After all files are resolved, use git_add for each, then git_commit. Do NOT use bash/sed for conflict resolution.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},theirs:{type:`string`,description:`Branch name, tag, or commit SHA to merge into the current branch`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`,`theirs`]}},{name:`git_pull`,description:`Fetch and merge commits from the remote repository. Uses configured git author name/email for merge commits if needed.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Branch to pull (default: current branch)`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`]}},{name:`git_push`,description:`Push commits to the remote repository. Requires a GitHub personal access token (PAT) to be configured. The token is loaded from the encrypted credential store.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Local branch to push (default: current branch)`},remote_ref:{type:`string`,description:`Remote branch name to push to, if different from local branch. Example: push local 'feature-rebased' to remote 'feature/original'.`},force:{type:`boolean`,description:`Force push (default: false)`},tags:{type:`boolean`,description:`Also push all local tags to the remote (default: false)`}},required:[`repo`]}},{name:`git_read_file_at_ref`,description:`Read a file's contents at a specific ref (branch, tag, or commit SHA) without checking it out. Useful for code review across branches.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Branch name, tag, or commit SHA`},filepath:{type:`string`,description:`File path relative to the repo root`}},required:[`repo`,`ref`,`filepath`]}},{name:`git_remote`,description:`Manage git remotes: list, add, or remove a remote in a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},command:{type:`string`,enum:[`list`,`add`,`remove`],description:`Operation to perform`},remote:{type:`string`,description:`Remote name (e.g. origin, upstream) — required for add/remove`},url:{type:`string`,description:`Remote URL — required for add`}},required:[`repo`,`command`]}},{name:`git_reset`,description:`Reset the current branch HEAD to a specific ref or commit SHA. Updates the branch pointer and checks out the target, discarding local changes. Equivalent to 'git reset --hard <ref>'.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Branch name, tag, or commit SHA to reset to`}},required:[`repo`,`ref`]}},{name:`git_show`,description:`Show the metadata and diff of a specific commit. Returns author, date, message, and a unified diff against the parent commit.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Commit SHA, branch, or tag to inspect (default: HEAD)`}},required:[`repo`,`ref`]}},{name:`git_status`,description:`Show the working tree status of a cloned repo. Reports modified, added, deleted, and unstaged files.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`}},required:[`repo`]}},{name:`git_tag`,description:`Create a lightweight or annotated tag at HEAD. Use git_push with tags=true to push tags to the remote.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},tag:{type:`string`,description:`Tag name (e.g. v1.2.3)`},message:{type:`string`,description:`Annotation message — if provided, creates an annotated tag; otherwise lightweight`},author_name:{type:`string`,description:`Tagger name (optional, uses configured default)`},author_email:{type:`string`,description:`Tagger email (optional, uses configured default)`}},required:[`repo`,`tag`]}},{name:`git_unstage`,description:`Remove one or more staged files from the index without touching the working tree. The inverse of git_add — use to undo accidental staging.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},filepath:{anyOf:[{type:`string`},{type:`array`,items:{type:`string`}}],description:`File path or array of file paths to unstage (relative to repo root)`}},required:[`repo`,`filepath`]}},{name:`invite_to_room`,description:`Invite a peer (another agent or human, identified by their PeerJS peer ID) into a room so they can join the shared conversation. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{peer_id:{type:`string`,description:`The PeerJS peer ID of the participant to invite.`},room_id:{type:`string`,description:`The room id to invite into. Defaults to the current room conversation.`}},required:[`peer_id`]}},re,{name:`leave_room`,description:`Leave a room. If you are the host, the room is disbanded for all members. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{room_id:{type:`string`,description:`The room id to leave. Defaults to the current room conversation.`}}}},{name:`list_components`,description:`List all available A2UI v1.0 Basic catalog components and their schemas. Returns a human-readable reference of component types, their required/optional properties, data binding syntax, and examples. Call this before render_component to understand what components are available and how to structure the input correctly.`,input_schema:{type:`object`,properties:{},required:[]}},{name:`list_files`,description:`List files and directories in the group workspace. Directory names end with /. Returns sorted entries.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Directory path relative to workspace root (default: root)`}}}},{name:`list_room_members`,description:`List the participants (humans and agents) currently in a room. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{room_id:{type:`string`,description:`The room id to inspect. Defaults to the current room conversation.`}}}},{name:`list_tasks`,description:`List all scheduled recurring tasks for this group. Returns a list of tasks with their IDs, schedules, and prompts.`,input_schema:{type:`object`,properties:{}}},se,k,oe,{name:`move_file`,description:`Move or rename a file or directory in the group workspace to a target path. Supports moving single files or nested directories. Optionally supports moving between different conversation workspaces via source_group_id or target_group_id.`,input_schema:{type:`object`,properties:{source_path:{type:`string`,description:`Source file or directory path relative to workspace root`},target_path:{type:`string`,description:`Destination file or directory path relative to workspace root`},source_group_id:{type:`string`,description:`Optional source conversation group ID (defaults to current workspace)`},target_group_id:{type:`string`,description:`Optional target conversation group ID (defaults to current workspace)`}},required:[`source_path`,`target_path`]}},{name:`open_file`,description:`Open a file from the group workspace in the UI file viewer dialog. Use this only when the user explicitly asks to inspect a file visually with preview support. Do not use this tool to send or attach files in chat responses.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`}},required:[`path`]}},{name:`patch_file`,description:`Make a targeted text replacement in a file. Finds the single occurrence of old_string and replaces it with new_string. Fails if old_string is not found or matches more than once. Use this instead of write_file when you only need to change part of a file — it is safer and works well with large files. Include enough surrounding context in old_string to make the match unique. IMPORTANT: You must provide 'path', 'old_string', and 'new_string' parameters.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},old_string:{type:`string`,description:`The exact text to find in the file. Must match exactly once. Include 2-3 lines of surrounding context to ensure a unique match.`},new_string:{type:`string`,description:`The replacement text. Can be empty to delete old_string.`}},required:[`path`,`old_string`,`new_string`]}},{name:`proofread_text`,description:`Proofread and correct grammar, spelling, and phrasing errors using Web Platform's Proofreader API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to proofread.`},context:{type:`string`,description:`Optional background context for proofreading.`}},required:[`text`]}},{name:`read_file`,description:`Read the contents of one or more files from the group workspace. IMPORTANT: You must specify either the 'path' parameter (for a single file) or the 'paths' parameter (an array of file paths for multiple files). When paths is provided, returns all file contents concatenated with --- filename --- headers. Prefer paths to batch reads in a single call. Image files (png, jpg, gif, webp, etc.) are returned as native image content that the model can see directly. Other binary files will be detected and an error returned suggesting alternative tools.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Single file path relative to the group workspace root`},paths:{type:`array`,items:{type:`string`},description:`Array of file paths relative to the group workspace root. Use this to read multiple files in a single tool call.`}}}},ae,ie,{name:`render_component`,description:`Render an interactive A2UI v1.0 UI surface in the peer's chat window using the Basic catalog. The surface appears inline in the conversation on the remote peer's side (or locally if no peer). Components: Text, Row, Column, Button, TextField, Image, Icon, Video, AudioPlayer, List, Card, Tabs, Modal, Divider, CheckBox, ChoicePicker, Slider, DateTimeInput. Use list_components first to understand available components and their schemas. All user input (button clicks, form field changes) automatically routes back to the agent. For media components (Image/Video/AudioPlayer), use workspace file paths (e.g. 'song.mp3') or HTTPS URLs.
|
|
103
|
+
|
|
104
|
+
actions:
|
|
105
|
+
createSurface — render a new surface (requires components array with a root component)
|
|
106
|
+
updateComponents — add or replace components on an existing surface
|
|
107
|
+
updateDataModel — update a single path in the data model (re-renders bound components)
|
|
108
|
+
deleteSurface — remove the surface from the chat`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`],description:`The A2UI operation to perform`},surfaceId:{type:`string`,description:`Unique identifier for this surface. Use a stable ID so you can update it later.`},components:{type:`array`,description:`Flat array of component objects (required for createSurface/updateComponents). Each object MUST have an 'id' field and a 'component' field. The component with id 'root' is the tree root (required for createSurface). Component field values: Text | Row | Column | Button | TextField | Image | Icon | Video | AudioPlayer | List | Card | Tabs | Modal | Divider | CheckBox | ChoicePicker | Slider | DateTimeInput. Put all properties at the TOP LEVEL alongside 'component' and 'id'. DO NOT nest properties under a 'properties' key. Children arrays contain other component ID strings, not nested objects.`,items:{type:`object`,additionalProperties:!0}},dataModel:{type:`object`,description:`Initial data model for the surface (used with createSurface). Components can reference values via { "path": "/key" }.`,additionalProperties:!0},path:{type:`string`,description:`JSON Pointer path to update (required for updateDataModel). Examples: "/result", "/user/name", "/count". Use "/" to replace the entire data model.`},value:{description:`New value to set at the specified path (used with updateDataModel). Omit to delete the key at the given path.`},surfaceProperties:{type:`object`,description:`Optional display/branding properties for this surface (e.g. agentDisplayName).`,additionalProperties:!0}},required:[`action`,`surfaceId`]}},{name:`rewrite_text`,description:`Rewrite or rephrase text using Web Platform's Rewriter API (or polyfill fallback). Can adjust tone or length.`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to rewrite.`},tone:{type:`string`,enum:[`as-is`,`more-formal`,`more-casual`],description:`Tone adjustment (default: as-is).`},length:{type:`string`,enum:[`as-is`,`shorter`,`longer`],description:`Length adjustment (default: as-is).`},context:{type:`string`,description:`Optional background context for rewriting.`}},required:[`text`]}},{name:`run_task`,description:`Immediately trigger a scheduled task by its ID, outside of its normal cron schedule. Use this to manually fire a task on demand. Use list_tasks to find the task ID first.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to run immediately`}},required:[`id`]}},{name:`search_files`,description:`Search for a pattern (regex or exact text) in files across the workspace. Useful for finding code references, function definitions, or specific content without needing to rely on a shell environment.`,input_schema:{type:`object`,properties:{pattern:{type:`string`,description:`The text or regular expression to search for.`},path:{type:`string`,description:`Optional directory path to restrict the search to (e.g. 'src/'). Defaults to workspace root.`},file_glob:{type:`string`,description:`Optional simple glob to filter files (e.g. '*.ts'). Supports * as wildcard.`},is_regex:{type:`boolean`,description:`Set to true to parse the pattern as a regular expression.`}},required:[`pattern`]}},{name:`send_file`,description:`Send a workspace file directly to connected peer(s) over the P2P (PeerJS/WebRTC) data channel. Use this when the user is in a peer conversation or room and asks to send or transfer a file. Do NOT use this for local-browser or other non-peer conversations — it only works when the active conversation is a peer or room session (peer: or room: group). The file is read from the current group workspace and transferred in binary chunks so there is no size limit.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`}},required:[`path`]}},N,M,{name:`spawn_subagent`,description:`Spawn one or more independent agent loops to work on subtasks in parallel and collect their results. Each subagent has its own tool-use loop, inherits the current API key, and can optionally override provider/model. and runs concurrently with other subagents via Promise.all. Use spawn_subagent when a task has independent parallel workstreams — for example: researching multiple topics simultaneously, processing a list of items in parallel, or delegating isolated subtasks to specialized agents. Do NOT use spawn_subagent for sequential tasks where step 2 depends on step 1's output — just do those steps directly. Do NOT use spawn_subagent for simple single-step work that takes one tool call. Use the parallel_agents field to fan out multiple subagents in a single call.`,input_schema:{type:`object`,properties:{prompt:{type:`string`,description:`The task prompt for a single subagent. Required unless using parallel_agents for multi-agent fan-out.`},tools:{type:`array`,description:`Optional list of tool names to allow in the subagent. If omitted, the subagent inherits the current tool set (minus spawn_subagent to prevent recursion). If provided, only these tools are available to the subagent.`,items:{type:`string`}},profile:{type:`string`,enum:[`current`,`fast`,`smart`,`powerful`],description:`Optional model profile to run the subagent on. Use 'fast' for simple/cheap subtasks (e.g., text formatting, basic search), 'smart' for moderate reasoning, 'powerful' for deep thinking or complex coding, and 'current' to inherit the parent model. Defaults to 'current'.`},workspace_group_id:{type:`string`,description:`Optional workspace group id override for subagent file/tool scope. Use 'parent' to reuse the parent workspace in automatic mode. When omitted, subagents use an isolated workspace by default.`},system_prompt:{type:`string`,description:`Optional system prompt override for the subagent. Defaults to the current system prompt.`},parallel_agents:{type:`array`,description:`Optional list of subagent specifications to run in parallel. When provided, all agents are launched concurrently and their results are combined. Note: There is a configurable maximum limit on parallel subagents (default 5). Each entry can specify a prompt, optional tools list, optional profile, and optional system_prompt.`,items:{type:`object`,properties:{prompt:{type:`string`,description:`The task prompt for this subagent.`},tools:{type:`array`,description:`Optional tool names for this subagent.`,items:{type:`string`}},profile:{type:`string`,enum:[`current`,`fast`,`smart`,`powerful`],description:`Optional model profile for this subagent. Defaults to 'current'.`},workspace_group_id:{type:`string`,description:`Optional workspace group id for this subagent. Use 'parent' for parent workspace in automatic mode.`},system_prompt:{type:`string`,description:`Optional system prompt override for this subagent.`}},required:[`prompt`]}}},required:[`prompt`]}},{name:`summarize_text`,description:`Summarize text using Web Platform's Summarizer API (or polyfill fallback). Produces key points, TLDR, teaser, or headline.`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text content to summarize.`},type:{type:`string`,enum:[`key-points`,`tldr`,`teaser`,`headline`],description:`The summary type (default: key-points).`},format:{type:`string`,enum:[`plain-text`,`markdown`],description:`Output format (default: markdown).`},length:{type:`string`,enum:[`short`,`medium`,`long`],description:`Summary length (default: short).`},preference:{type:`string`,enum:[`capability`,`speed`,`auto`],description:`Summarizer performance preference (default: auto).`},context:{type:`string`,description:`Optional background context for summarization.`}},required:[`text`]}},{name:`translate_text`,description:`Translate text using Web Platform's Translator API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to translate.`},sourceLanguage:{type:`string`,description:`Source language BCP 47 code (e.g. 'en', 'es', 'ja').`},targetLanguage:{type:`string`,description:`Target language BCP 47 code (e.g. 'en', 'es', 'ja').`}},required:[`text`,`sourceLanguage`,`targetLanguage`]}},ce,{name:`update_task`,description:`Update an existing scheduled task's schedule or prompt.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to update`},schedule:{type:`string`,description:`Standard cron expression (e.g. '0 9 * * *'). Leave empty for an unscheduled task.`},prompt:{type:`string`,description:`New prompt/instruction (optional)`},type:{type:`string`,enum:[`prompt`,`tools`],description:`New task type (optional)`},tools:{type:`array`,description:`New list of tools (optional)`,items:{type:`object`,properties:{name:{type:`string`},input:{type:`object`}},required:[`name`,`input`]}},enabled:{type:`boolean`,description:`Whether the task is enabled (optional)`},name:{type:`string`,description:`New name/title for the task (optional).`}},required:[`id`]}},ne,{name:`write_file`,description:`Write content to a file in the group workspace. Creates the file and any intermediate directories if they don't exist. Overwrites the file if it already exists. IMPORTANT: You must provide both the 'path' and 'content' parameters when calling this tool.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},content:{type:`string`,description:`Content to write to the file`}},required:[`path`,`content`]}},{name:`write_text`,description:`Generate or draft text using Web Platform's Writer API (or polyfill fallback).`,input_schema:{type:`object`,properties:{prompt:{type:`string`,description:`The prompt or writing instructions.`},context:{type:`string`,description:`Optional background context for writing.`}},required:[`prompt`]}}],L=/^[a-z][a-z0-9_]{0,63}$/;function R(e,t){if(!t||typeof t!=`object`)throw Error(`Tool at ${e} must be a JSON object`);let n=t,r=typeof n.name==`string`?n.name.trim():``,i=typeof n.description==`string`?n.description.trim():``,a=n.input_schema??n.parameters,o=n.execution??n.evaluation;if(!L.test(r))throw Error(`Tool name is invalid: ${r||`(missing)`}`);if(!i)throw Error(`Tool ${r} requires a description`);if(!a||typeof a!=`object`)throw Error(`Tool ${r} requires input_schema`);if(!o||typeof o!=`object`)throw Error(`Tool ${r} requires execution`);let s=o,c=s.type;if(c!==`bash`&&c!==`javascript`&&c!==`tool`)throw Error(`Tool ${r} execution type must be bash, javascript, or tool`);if(c===`tool`){if(typeof s.name!=`string`||!L.test(s.name))throw Error(`Tool ${r} execution requires a valid tool name`);return{name:r,description:i,input_schema:a,execution:{type:c,name:s.name,...s.input&&typeof s.input==`object`?{input:s.input}:{}},path:e}}let l=c===`bash`?`command`:`code`,u=s[l]??s.expression;if(typeof u!=`string`||u.trim()===``)throw Error(`Tool ${r} execution requires ${l}`);return{name:r,description:i,input_schema:a,execution:{type:c,[l]:u},path:e}}async function z(e,t=n){let r=[],i=[],a=t===`br:main`?[n]:[t,n];for(let t of a)try{let n=await S(e,t),a=[];async function o(e,t){for await(let[n,r]of e.entries()){let e=`${t}/${n}`;r.kind===`directory`?await o(r,e):n.endsWith(`.json`)&&e.startsWith(`.agents/tools/`)&&a.push(e)}}try{await o(await(await n.getDirectoryHandle(`.agents`)).getDirectoryHandle(`tools`),`.agents/tools`)}catch{continue}for(let n of a.sort())try{let i=R(n,JSON.parse(await T(e,t,n)));r.some(e=>e.name===i.name)||r.push(i)}catch(e){i.push(e instanceof Error?e.message:String(e))}}catch{}return{tools:r,diagnostics:i}}async function B(e,t=n,i){try{let{tools:n}=await z(e,t),o=n.find(e=>e.name===i)||null;if(!o)return null;let s=await a(e,r.DECLARATIVE_TOOLS_ENABLED);return Array.isArray(s)&&!s.includes(i)?null:o}catch{return null}}async function V(e,t){let n=e?.createWritable,r=Reflect.get(e,`createWriteable`),i=typeof n==`function`?n.bind(e):typeof r==`function`?r.bind(e):null;if(i){let e=await i();await e.write(U(t)),await e.close();return}if(typeof e.createSyncAccessHandle==`function`){let n=await e.createSyncAccessHandle();try{let e=await W(t);n.truncate(0),n.write(e,{at:0}),typeof n.flush==`function`&&n.flush()}finally{n.close()}return}throw Error(`Writable file streams are not supported by this browser/storage backend.`)}async function H(e,t){if(typeof globalThis.Worker!=`function`)throw Error(`Writable file streams are not supported by this browser/storage backend.`);let n=await W(t);return new Promise((t,r)=>{let i=``,a=null;try{let e=[`self.onmessage = async (e) => {`,` try {`,` const { pathSegments, bytes } = e.data;`,` let dir = await navigator.storage.getDirectory();`,` for (let i = 0; i < pathSegments.length - 1; i++) {`,` dir = await dir.getDirectoryHandle(pathSegments[i], { create: true });`,` }`,` const filename = pathSegments[pathSegments.length - 1];`,` const fh = await dir.getFileHandle(filename, { create: true });`,` const h = await fh.createSyncAccessHandle();`,` try {`,` h.truncate(0);`,` h.write(bytes, { at: 0 });`,` if (typeof h.flush === 'function') h.flush();`,` } finally { h.close(); }`,` self.postMessage({ ok: true });`,` } catch (err) {`,` self.postMessage({ error: err.message || String(err) });`,` }`,`};`].join(`
|
|
109
|
+
`);i=URL.createObjectURL(new Blob([e],{type:`text/javascript`})),a=new Worker(l(i))}catch{i&&URL.revokeObjectURL(i),r(Error(`Writable file streams are not supported by this browser/storage backend.`));return}let o=()=>{a&&a.terminate(),URL.revokeObjectURL(i)};a.onmessage=e=>{o(),e.data?.error?r(Error(e.data.error)):t()},a.onerror=e=>{o(),r(Error(e.message||`Worker file write failed`))},a.postMessage({pathSegments:e,bytes:n},[n.buffer])})}function U(e){if(typeof e==`string`||e instanceof Blob)return e;if(e instanceof Uint8Array){let t=new Uint8Array(e.byteLength);return t.set(e),new Blob([t])}return new Blob([e])}async function W(e){return e instanceof Uint8Array?e:typeof e==`string`?new TextEncoder().encode(e):e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array}async function G(e,t,n,r){let{dirs:i,filename:a}=C(n);for(let n=0;n<2;n++)try{let n=await S(e,t);for(let e of i)n=await n.getDirectoryHandle(e,{create:!0});let o=await n.getFileHandle(a,{create:!0});try{await V(o,r);return}catch(t){if(!((t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`)&&(await x(e)).type===`opfs`))throw t}let s=t.replace(/:/g,`-`);await H([m(),`groups`,s,...i,a],r);return}catch(e){if(n===0&&b(e)){y();continue}throw e}}async function K(e,t,n){try{return await T(e,t,n),!0}catch{return!1}}const le=/^[a-z0-9](?:[a-z0-9]|-(?!-))*[a-z0-9]$|^[a-z0-9]$/;function ue(e){try{let t=u(e);return{data:t.data&&typeof t.data==`object`?t.data:{},content:t.content||``}}catch{let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(t){let e=t[1],n=t[2]||``,r=e.split(/\r?\n/).map(e=>{let t=e.match(/^([a-zA-Z0-9_-]+):\s*(.+)$/);if(t){let[,e,n]=t,r=n.trim();if(r&&r!==`true`&&r!==`false`&&r!==`null`&&!r.startsWith(`"`)&&!r.startsWith(`'`)&&!r.startsWith(`[`)&&!r.startsWith(`{`)&&r!==`>`&&r!==`|`&&r!==`>-`&&r!==`|-`&&!/^-?\d+(?:\.\d+)?$/.test(r))return`${e}: ${JSON.stringify(r)}`}return e});try{let e=u(`---\n${r.join(`
|
|
110
|
+
`)}\n---\n${n}`);return{data:e.data&&typeof e.data==`object`?e.data:{},content:e.content||``}}catch{}let i={},a=e.match(/^name:\s*["']?([^"'\r\n]+)["']?/m);a&&(i.name=a[1].trim());let o=e.match(/^description:\s*(.+)$/m);if(o){let e=o[1].trim();(e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`))&&(e=e.slice(1,-1)),i.description=e}let s=e.match(/^user-invocable:\s*(true|false)/im);s&&(i[`user-invocable`]=s[1].toLowerCase()===`true`);let c=e.match(/^disable-model-invocation:\s*(true|false)/im);c&&(i[`disable-model-invocation`]=c[1].toLowerCase()===`true`);let l=e.match(/^allowed-tools:\s*["']?([^"'\r\n]+)["']?/m);l&&(i[`allowed-tools`]=l[1].trim());let d=e.match(/allowed-tools:\s*\n((?:\s*-\s*[^\r\n]+\r?\n?)+)/m);if(d){let e=d[1].split(/\r?\n/).map(e=>e.replace(/^\s*-\s*/,``).trim()).filter(Boolean);e.length>0&&(i[`allowed-tools`]=e)}return{data:i,content:n}}return{data:{},content:e}}}function q(e){if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(Array.isArray(e)){let t=e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t.join(` `):void 0}}function J(e,t){let n=ue(t),r=n.data,i=typeof r.name==`string`?r.name.trim():``,a=typeof r.description==`string`?r.description.trim():``;if(!i)throw Error(`Skill at ${e} requires a name`);if(!a)throw Error(`Skill ${i} requires a description`);if(i.length>64||!le.test(i))throw Error(`Skill name must be 1-64 lowercase characters and hyphens: ${i}`);if(a.length>1024)throw Error(`Skill ${i} description must be 1024 characters or fewer`);let o=e.replace(/\/SKILL\.md$/u,``),s=r.metadata&&typeof r.metadata==`object`?r.metadata:void 0,c=q(s?.[`allowed-tools`])||q(s?.allowedTools)||q(r[`allowed-tools`])||q(r.allowedTools),l=[];if(s){for(let[e,t]of Object.entries(s))if(!(e===`execution`||t==null)){if(e===`allowed-tools`||e===`allowedTools`)c&&l.push([e,c]);else if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)l.push([e,String(t)]);else if(Array.isArray(t)){let n=t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean);n.length>0&&l.push([e,n.join(` `)])}}}let u=l.length>0?Object.fromEntries(l):void 0,d=s?.execution,f;if(d!==void 0){if(!d||typeof d!=`object`||d.type!==`tools`||!Array.isArray(d.tools))throw Error(`Skill ${i} has invalid tools execution`);let e=d,t=typeof e.suppressToast==`boolean`?e.suppressToast:void 0,n=typeof e.suppressOutput==`boolean`?e.suppressOutput:void 0,r=e.tools.map(e=>({...e,...t!==void 0&&e.suppressToast===void 0?{suppressToast:t}:{},...n!==void 0&&e.suppressOutput===void 0?{suppressOutput:n}:{}}));f={type:`tools`,...t===void 0?{}:{suppressToast:t},...n===void 0?{}:{suppressOutput:n},tools:r}}return{name:i,description:a,...typeof r.license==`string`?{license:r.license}:{},...typeof r.compatibility==`string`?{compatibility:r.compatibility}:{},...u?{metadata:u}:{},...typeof c==`string`?{allowedTools:c}:{},...typeof r[`user-invocable`]==`boolean`?{userInvocable:r[`user-invocable`]}:typeof r[`user-invocable`]==`string`&&(r[`user-invocable`].toLowerCase()===`true`||r[`user-invocable`].toLowerCase()===`false`)?{userInvocable:r[`user-invocable`].toLowerCase()===`true`}:{},...typeof r[`disable-model-invocation`]==`boolean`?{disableModelInvocation:r[`disable-model-invocation`]}:typeof r[`disable-model-invocation`]==`string`&&(r[`disable-model-invocation`].toLowerCase()===`true`||r[`disable-model-invocation`].toLowerCase()===`false`)?{disableModelInvocation:r[`disable-model-invocation`].toLowerCase()===`true`}:{},...f?{execution:f}:{},body:n.content.trim(),path:e,basePath:o}}const Y=new Set(I.map(e=>e.name)),de=/^[a-z][a-z0-9_]{0,63}$/;function X(e){return e?.targetSubdir?e.targetSubdir:e?.siteSlug?`imported/${e.siteSlug}`:`main`}async function Z(e,t=n,i,o){let s=(i.name||``).trim();if(Y.has(s))return{name:s,path:``,status:`failed`,error:`Cannot shadow built-in tool: ${s}`};if(!de.test(s))return{name:s,path:``,status:`failed`,error:`Invalid tool name: ${s}`};let l=`.agents/tools/${X(o)}/${s}.json`;try{if(await K(e,t,l)&&!o?.overwrite)return{name:s,path:l,status:`skipped`};let n=await(o?.fetchFn||globalThis.fetch)(i.url);if(!n.ok)return{name:s,path:l,status:`failed`,error:`HTTP ${n.status} ${n.statusText}`};let u=await n.text();if(i.digest&&!await c(u,i.digest))return{name:s,path:l,status:`failed`,error:`Integrity verification failed for tool definition`};let d;try{d=JSON.parse(u)}catch{return{name:s,path:l,status:`failed`,error:`Downloaded tool definition is not valid JSON`}}if(R(l,d),await G(e,t,l,JSON.stringify(d,null,2)),o?.autoEnable){let t=await a(e,r.DECLARATIVE_TOOLS_ENABLED),n=new Set(Array.isArray(t)?t:[]);n.add(s),await w(e,r.DECLARATIVE_TOOLS_ENABLED,Array.from(n))}return{name:s,path:l,status:`imported`}}catch(e){return{name:s,path:l,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function Q(e,t=n,r,i){let a=(r.name||``).trim(),o=`.agents/scripts/${X(i)}/${a.endsWith(`.js`)||a.endsWith(`.mjs`)?a:`${a}.js`}`;try{if(await K(e,t,o)&&!i?.overwrite)return{name:a,path:o,status:`skipped`};let n=await(i?.fetchFn||globalThis.fetch)(r.url);if(!n.ok)return{name:a,path:o,status:`failed`,error:`HTTP ${n.status} ${n.statusText}`};let s=await n.text();return r.digest&&!await c(s,r.digest)?{name:a,path:o,status:`failed`,error:`Integrity verification failed for script`}:(await G(e,t,o,s),{name:a,path:o,status:`imported`})}catch(e){return{name:a,path:o,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function $(e,t=n,r,i){let a=(r.name||``).trim(),o=`.agents/skills/${X(i)}/${a}/SKILL.md`;try{if(await K(e,t,o)&&!i?.overwrite)return{name:a,path:o,status:`skipped`};let n=await(i?.fetchFn||globalThis.fetch)(r.url);if(!n.ok)return{name:a,path:o,status:`failed`,error:`HTTP ${n.status} ${n.statusText}`};let s=await n.text();return r.digest&&!await c(s,r.digest)?{name:a,path:o,status:`failed`,error:`Integrity verification failed for skill`}:(J(o,s),await G(e,t,o,s),{name:a,path:o,status:`imported`})}catch(e){return{name:a,path:o,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function fe(e,t=n,r,i,a){let o={tools:[],skills:[],scripts:[],diagnostics:[]},s=new Set(i.toolNames||[]),c=new Set(i.skillNames||[]),l=new Set(i.scriptNames||[]),u=r.tools||[],d=r.skills||[],f=r.scripts||[];for(let e of d)if(c.has(e.name)){if(Array.isArray(e.tools))for(let t of e.tools)s.add(t.name);if(Array.isArray(e.scripts))for(let t of e.scripts)l.add(t.name)}for(let n of f)if(l.has(n.name)){let r=await Q(e,t,n,a);o.scripts.push(r),r.status===`failed`&&r.error&&o.diagnostics.push(`Script ${n.name}: ${r.error}`)}for(let n of u)if(s.has(n.name)){let r=await Z(e,t,n,a);o.tools.push(r),r.status===`failed`&&r.error&&o.diagnostics.push(`Tool ${n.name}: ${r.error}`)}for(let n of d)if(c.has(n.name)){let r=await $(e,t,n,a);o.skills.push(r),r.status===`failed`&&r.error&&o.diagnostics.push(`Skill ${n.name}: ${r.error}`)}return o}export{b as C,y as S,C as _,J as a,_ as b,V as c,z as d,I as f,w as g,T as h,Z as i,H as l,F as m,Q as n,K as o,P as p,$ as r,G as s,fe as t,B as u,S as v,v as w,x,m as y};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import{a as e}from"./chunk-8V8biNmG.js";import{t}from"./chunk-B4TVZApP.js";import{T as n,h as r,o as i,r as a}from"./chunk-BkKN8FNP.js";import{t as o}from"./chunk-DFLqhyP_.js";import{t as s}from"./chunk-Dhh0lHO6.js";import{r as c}from"./chunk-BQCWtrzh.js";import{a as l}from"./chunk-Cx0FUKuw2.js";import{a as u,u as d}from"./chunk-BCLxzLO92.js";async function f(e,...t){let n=e;for(let e of t){let t=await n.getDirectoryHandle(e,{create:!0});if(typeof n.isSameEntry==`function`&&await n.isSameEntry(t))throw Error(`Directory navigation failed: "${e}" resolved to the same directory as its parent. The stored directory handle may be stale — try re-selecting the storage folder.`);n=t}return n}let p=null;async function m(e,t){try{return await e.entries().next(),`granted`}catch{return t}}function h(){let e=n();return e?`${r}-${e}`:r}async function g(){try{if(typeof navigator<`u`&&navigator.storage&&typeof navigator.storage.getDirectory==`function`){let e=await navigator.storage.getDirectory(),t=h();return await e.getDirectoryHandle(t,{create:!0})}}catch(e){console.warn(`OPFS is unavailable (e.g. Firefox Private Browsing). Using in-memory storage fallback:`,e)}return l()}function _(e){if(!e||typeof e!=`object`)return!1;let t=globalThis.FileSystemDirectoryHandle;return t!==void 0&&e instanceof t||typeof e.getDirectoryHandle==`function`&&typeof e.getFileHandle==`function`}async function v(e){if(p)return p;try{let t=await s(e,a.STORAGE_HANDLE);if(_(t)){let e=t;if(typeof e.queryPermission==`function`&&await e.queryPermission({mode:`readwrite`})!==`granted`&&typeof e.requestPermission==`function`)try{await e.requestPermission({mode:`readwrite`})}catch{}return e}}catch(e){console.warn(`Failed to retrieve local storage handle from DB:`,e)}return g()}function y(e){p=e}function b(){p=null}function x(e){return e instanceof DOMException&&e.name===`InvalidStateError`}async function S(e){if(p)try{let e=await p.queryPermission({mode:`readwrite`});return{type:`local`,permission:e===`granted`?`granted`:await m(p,e),name:p.name}}catch{console.warn(`Getting storage status failed for explicit storage root.`)}try{let t=await s(e,a.STORAGE_HANDLE);if(_(t)){let e=t,n=await e.queryPermission({mode:`readwrite`});return{type:`local`,permission:n===`granted`?`granted`:await m(e,n),name:e.name}}}catch(e){console.warn(`Failed to check storage status:`,e)}return{type:`opfs`,permission:`granted`,name:`OPFS`}}async function C(e,t){let n=await v(e);return c()?n:f(n,`groups`,t.replace(/:/g,`-`))}function w(e){let t=e.replace(/\\/g,`/`).replace(/^\/home\/user\//,`/`).replace(/^\/+/,``).split(`/`).filter(Boolean);if(t.length===0)throw Error(`Empty file path`);return{dirs:t,filename:t.pop()||``}}function T(e,t,n){return o(e,`config`,`readwrite`,e=>e.put({key:t,value:n})).then(()=>void 0)}async function E(e,t,n){let r=await C(e,t),{dirs:i,filename:a}=w(n),o=r;for(let e of i)o=await o.getDirectoryHandle(e);let s=await o.getFileHandle(a);try{let e=await s.createSyncAccessHandle(),t=e.getSize(),n=new Uint8Array(t);return e.read(n,{at:0}),e.close(),new TextDecoder(`utf-8`).decode(n)}catch{return(await s.getFile()).text()}}const D={name:`bash`,description:`Execute a shell command. When WebVM is available, runs in a full Alpine Linux VM (x86) with all standard Linux commands. When WebVM is disabled or unavailable, falls back to a lightweight JavaScript shell emulator with 83 commands: alias, awk, base64, basename, bash, cat, cd, chmod, clear, column, comm, command, cp, curl, cut, date, diff, dirname, du, echo, egrep, env, expand, export, expr, false, fgrep, file, find, fold, grep, gunzip, gzip, head, help, html-to-markdown, join, jq, ln, ls, md5sum, mkdir, mv, nl, od, paste, printenv, printf, pwd, readlink, realpath, rev, rg, rm, rmdir, sed, seq, sh, sha1sum, sha256sum, sha384sum, sha512sum, sleep, sort, split, stat, strings, tac, tail, tar, tee, test, timeout, touch, tr, tree, true, unalias, uniq, wc, which, xargs, yes, zcat. Commands NOT available in fallback mode: node, npm, npx, git, apk, python, wget.Supports pipes (|), redirects (> >>), operators (&& || ;), newlines, and # comments. Prefer read_file/write_file for file inspection and edits — they are faster and more reliable than shell commands for that purpose.`,input_schema:{type:`object`,properties:{command:{type:`string`,description:`The bash command to execute`},stdin:{type:`string`,description:`Optional standard input (stdin) to pass to the command`},timeout:{type:`number`,description:`Timeout in seconds (default from Settings, initially 120; max: 1800)`}},required:[`command`]}},O={name:`clear_chat`,description:`Clear the current chat history and start a new session. Useful for scheduled tasks to prevent context from growing indefinitely.`,input_schema:{type:`object`,properties:{}}},k={name:`ask_user`,description:`Pause execution to ask the user a question or request confirmation. This halts the agent's work until the user provides an answer. Use this for human-in-the-loop checkpoints before taking destructive actions or when you need clarification to proceed.`,input_schema:{type:`object`,properties:{question:{type:`string`,description:`The question or confirmation message to present to the user.`},options:{type:`array`,items:{type:`string`},description:`Optional list of predefined choices for the user to select from.`}},required:[`question`]}},A={name:`manage_email`,description:`Manage email connection settings for IMAP/SMTP workflows. Supports status, connect/configure, enable/disable, delete, read_messages, send_message, mark_as_read, mark_as_unread, delete_messages, download_attachments, list available connection types, and lightweight test actions.`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`status`,`list_plugins`,`list_connections`,`connect`,`configure`,`enable`,`disable`,`delete`,`test`,`read_messages`,`send_message`,`mark_as_read`,`mark_as_unread`,`delete_messages`,`download_attachments`],description:`Email management action to perform.`},plugin_id:{type:`string`,description:`Optional connection type ID for connect operations (default: imap).`},connection_id:{type:`string`,description:`Connection ID or label for configure, enable, disable, delete, and test actions. For read_messages/send_message, it may be omitted when there is exactly one enabled IMAP connection.`},label:{type:`string`,description:`Human-readable connection label for new connections.`},enabled:{type:`boolean`,description:`Optional enabled flag used during connect/configure actions.`},config:{type:`object`,properties:{},description:`Email config object (host, port, secure, mailboxPath, smtpHost, smtpPort, smtpSecure, etc.).`},mailbox_path:{type:`string`,description:`Optional mailbox path override for read_messages (default: INBOX).`},limit:{type:`number`,description:`Optional max messages to fetch for read_messages (default 10, range 1-50).`},unread_only:{type:`boolean`,description:`If true, read_messages returns only unread messages.`},message_uids:{type:`array`,items:{type:`number`},description:`Message UIDs for mark_as_read, mark_as_unread, and delete_messages actions.`},message_uid:{type:`number`,description:`Single message UID used by download_attachments action.`},attachment_parts:{type:`array`,items:{type:`string`},description:`Optional IMAP MIME part IDs to download (for example: 2, 3.1). If omitted, all attachments in the message are downloaded.`},save_directory:{type:`string`,description:`Optional workspace directory for downloaded attachments (default: downloads/email).`},attachments:{type:`array`,items:{anyOf:[{type:`string`},{type:`object`,properties:{path:{type:`string`},filename:{type:`string`},content_type:{type:`string`}},required:[`path`]}]},description:`Optional workspace file attachments for send_message. Provide paths or objects with path/filename/content_type.`},to:{type:`array`,items:{type:`string`},description:`Recipient email addresses for send_message.`},cc:{type:`array`,items:{type:`string`},description:`Optional CC recipient addresses for send_message.`},bcc:{type:`array`,items:{type:`string`},description:`Optional BCC recipient addresses for send_message.`},subject:{type:`string`,description:`Message subject for send_message.`},body:{type:`string`,description:`Plaintext message body for send_message.`},html:{type:`string`,description:`Optional HTML body for send_message.`},from:{type:`string`,description:`Optional from address override for send_message.`},reply_to:{type:`string`,description:`Optional reply-to address for send_message.`},username:{type:`string`,description:`Optional username override for connect/configure/read_messages/send_message.`},password:{type:`string`,description:`Optional password override for connect/configure/read_messages/send_message.`}},required:[`action`]}},j={name:`email_read_messages`,description:`Read recent messages from a configured email connection (IMAP). Use this to check inbox mail from an agent workflow. Results include attachment metadata when available.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Email connection ID or label.`},mailbox_path:{type:`string`,description:`Optional mailbox path override (default: INBOX).`},limit:{type:`number`,description:`Optional max messages to fetch (default 10, range 1-50).`},unread_only:{type:`boolean`,description:`If true, only unread messages are returned.`}},required:[`connection_id`]}},M={name:`email_send_message`,description:`Send an email message through a configured email connection (SMTP).`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Email connection ID or label.`},to:{type:`array`,items:{type:`string`},description:`Recipient email addresses.`},cc:{type:`array`,items:{type:`string`},description:`Optional CC recipient addresses.`},bcc:{type:`array`,items:{type:`string`},description:`Optional BCC recipient addresses.`},subject:{type:`string`,description:`Message subject.`},body:{type:`string`,description:`Plaintext message body.`},html:{type:`string`,description:`Optional HTML message body.`},from:{type:`string`,description:`Optional from address override.`},reply_to:{type:`string`,description:`Optional reply-to address.`}},required:[`connection_id`,`to`,`subject`]}},ee={name:`fetch_url`,description:`Fetch a URL via HTTP and return the response body. Subject to browser CORS restrictions — works with most public APIs. Response is truncated to 100KB. Set use_git_auth to true to automatically inject the saved Git PAT as an Authorization header (supports GitHub, Azure DevOps, GitLab, and other providers — auth format is auto-detected from the URL's host). If include_headers is true, the response will include both request and response headers.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`The URL to fetch`},method:{type:`string`,description:`HTTP method (default: GET)`},headers:{type:`object`,properties:{},description:`Request headers as key-value pairs`},body:{type:`string`,description:`Request body (for POST/PUT/PATCH)`},use_git_auth:{type:`boolean`,description:`If true, inject the saved Git credentials as an Authorization header. Auth format is auto-detected from the URL host: GitHub (token), Azure DevOps (Basic), GitLab (Bearer), or generic Bearer.`},git_account_id:{type:`string`,description:`Optional explicit Git account ID to use when use_git_auth is true. If omitted, account resolution uses hostPattern/default matching.`},use_account_auth:{type:`boolean`,description:`If true, inject a saved service account PAT as a Bearer Authorization header. The account is matched by hostPattern against the URL (longest match wins), then falls back to the default service account. Use this for non-Git services like Figma, Notion, or any other service whose PAT is stored under Settings → Accounts.`},account_id:{type:`string`,description:`Optional explicit service account ID to use when use_account_auth is true. If omitted, account resolution uses hostPattern/default matching.`},auth_mode:{type:`string`,enum:[`pat`,`oauth`],description:`Optional preferred credential mode when multiple accounts match. Valid values: pat or oauth.`},include_headers:{type:`boolean`,description:`If true, include request and response headers in the output.`}},required:[`url`]}},te={name:`fetch_file`,description:`Fetch a URL and save the response body directly to the workspace in one step. Equivalent to fetch_url + write_file but atomic. Text responses are saved as UTF-8; binary responses (images, PDFs, audio, video, zip, application/octet-stream) are saved as raw bytes. The destination path within the workspace is required. Supports the same authentication options as fetch_url (use_git_auth, use_account_auth, etc.). Returns the workspace path the file was saved to and the number of bytes written.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`The URL to fetch`},path:{type:`string`,description:`Destination path within the workspace (e.g. 'data/response.json'). Parent directories are created automatically. Must not contain '..' segments.`},method:{type:`string`,description:`HTTP method (default: GET)`},headers:{type:`object`,properties:{},description:`Request headers as key-value pairs`},body:{type:`string`,description:`Request body (for POST/PUT/PATCH)`},use_git_auth:{type:`boolean`,description:`If true, inject the saved Git credentials as an Authorization header. Auth format is auto-detected from the URL host: GitHub (token), Azure DevOps (Basic), GitLab (Bearer), or generic Bearer.`},git_account_id:{type:`string`,description:`Optional explicit Git account ID to use when use_git_auth is true. If omitted, account resolution uses hostPattern/default matching.`},use_account_auth:{type:`boolean`,description:`If true, inject a saved service account PAT as a Bearer Authorization header. The account is matched by hostPattern against the URL (longest match wins), then falls back to the default service account.`},account_id:{type:`string`,description:`Optional explicit service account ID to use when use_account_auth is true. If omitted, account resolution uses hostPattern/default matching.`},auth_mode:{type:`string`,enum:[`pat`,`oauth`],description:`Optional preferred credential mode when multiple accounts match. Valid values: pat or oauth.`}},required:[`url`,`path`]}},ne={name:`web_search`,description:`Perform a web search using a search engine to discover information. Returns a plain-text summary of the top search results including titles, URLs, and snippets. Use this when you need to find information but don't know the exact URL to fetch.`,input_schema:{type:`object`,properties:{query:{type:`string`,description:`The search query to look up.`}},required:[`query`]}},re={name:`javascript`,description:`Execute JavaScript code in a sandboxed Worker and return the result. Lighter than bash — no VM boot required. Use for calculations, data transformations, JSON processing, string analysis, etc. Runs in strict mode. No access to DOM, eval(), Function(), self, postMessage, importScripts, navigator, or indexedDB — these are all undefined. fetch availability is controlled by Tool Configuration -> Internet Access (shared with bash). setTimeout is available but setInterval is blocked. IMPORTANT: You CANNOT call other agent tools (like read_file, write_file, or bash) from inside this sandbox. If you need to process file contents or tool outputs, you must fetch them in a previous turn and pass the data into this tool via the $PIPE_DATA variable. Write plain JavaScript expressions and statements — the return value of the last expression is captured as the result.`,input_schema:{type:`object`,properties:{code:{type:`string`,description:`JavaScript code to execute. The return value of the last expression is captured.`},data:{type:`string`,description:"Optional input data string. Accessible inside the code sandbox via the global constant `$PIPE_DATA`."}},required:[`code`]}},ie={name:`remote_mcp_list_tools`,description:`List available tools from a configured Remote MCP connection by connection ID or label.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Remote MCP connection ID or label`}},required:[`connection_id`]}},ae={name:`remote_mcp_call_tool`,description:`Call a tool exposed by a configured Remote MCP connection.`,input_schema:{type:`object`,properties:{connection_id:{type:`string`,description:`Remote MCP connection ID or label`},tool_name:{type:`string`,description:`Remote MCP tool name`},arguments:{type:`object`,properties:{},description:`Arguments object passed to the remote MCP tool`}},required:[`connection_id`,`tool_name`]}},oe={name:`manage_tools`,description:`Enable or disable specific tools, or activate a predefined tool profile. Use list_tool_profiles to see available profiles before activating one. This helps optimize the context window and focus capabilities. Changes take effect on the NEXT turn, not immediately within the current tool-use loop.`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`enable`,`disable`,`activate_profile`],description:`The management action to perform.`},tool_names:{type:`array`,items:{type:`string`},description:`List of tool names to enable or disable. Required for 'enable' and 'disable' actions.`},profile_id:{type:`string`,description:`The unique ID of the tool profile to activate. Required for 'activate_profile' action.`}},required:[`action`]}},se={name:`list_tool_profiles`,description:`List all available tool profiles that can be activated using manage_tools. Returns a list of profiles with their IDs, names, and the tools they contain.`,input_schema:{type:`object`,properties:{}}},ce={name:`update_memory`,description:`Update the MEMORY.md memory file for this group. Use this to persist important context, user preferences, project state, and anything the agent should remember across conversations. This file is loaded as system context on every invocation.`,input_schema:{type:`object`,properties:{content:{type:`string`,description:`New content for the MEMORY.md memory file`}},required:[`content`]}},le={name:`show_toast`,description:`Show a toast notification to the user. Toasts are non-blocking, auto-dismissing notifications that appear in the bottom-right corner. Use for: operation status (success/failure), warnings, informational messages, progress updates. Avoid for: critical errors requiring acknowledgment (use clear error messages instead), lengthy content (keep messages concise).`,input_schema:{type:`object`,properties:{message:{type:`string`,description:`The message to display in the toast (keep concise)`},type:{type:`string`,description:`Type of toast: 'success', 'error', 'warning', or 'info' (default: 'info')`,enum:[`success`,`error`,`warning`,`info`]},duration:{type:`number`,description:`Auto-dismiss duration in milliseconds (default: 5000 for info/success, 8000 for warning/error). Set to 0 to disable auto-dismiss.`}},required:[`message`]}},N={name:`send_notification`,description:`Send an OS-level push notification to the user via Web Push. Unlike toasts (in-app only), push notifications appear even when the app is not focused or the tab is in the background. Use for: important alerts, long-running task completion, time-sensitive information. Requires the user to have enabled push notifications in Settings.`,input_schema:{type:`object`,properties:{title:{type:`string`,description:`Notification title (default: 'ShadowClaw')`},body:{type:`string`,description:`The notification body text`}},required:[`body`]}},P=`https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json`,F=`A2UI Basic Catalog — Component & Function Reference
|
|
2
|
+
=====================================================
|
|
3
|
+
|
|
4
|
+
Catalog ID: ${P}
|
|
5
|
+
|
|
6
|
+
CRITICAL AUTHORING RULES
|
|
7
|
+
-------------------------
|
|
8
|
+
1. Put ALL properties at the TOP LEVEL of each component object alongside "component" and "id".
|
|
9
|
+
WRONG: {"id":"t","component":"Text","properties":{"text":"Hello"}}
|
|
10
|
+
RIGHT: {"id":"t","component":"Text","text":"Hello"}
|
|
11
|
+
|
|
12
|
+
2. "components" is a FLAT ARRAY of objects, each with a required "id" field.
|
|
13
|
+
The root of the component tree MUST have id "root".
|
|
14
|
+
WRONG: {"root": {"component":"Column","children":["title"]}}
|
|
15
|
+
RIGHT: [{"id":"root","component":"Column","children":["title"]},{"id":"title","component":"Text","text":"Hello"}]
|
|
16
|
+
|
|
17
|
+
3. To make a property UPDATABLE later via the "updateDataModel" action, bind it
|
|
18
|
+
using {"path": "/your_key"} and initialise that key in the dataModel.
|
|
19
|
+
STATIC (never changes): {"id":"t","component":"Text","text":"Result will appear here"}
|
|
20
|
+
DYNAMIC (updatable): {"id":"t","component":"Text","text":{"path":"/result"}}
|
|
21
|
+
|
|
22
|
+
4. "children" and "child" contain COMPONENT ID STRINGS, not nested objects.
|
|
23
|
+
WRONG: {"id":"col","component":"Column","children":[{"component":"Text","text":"Hi"}]}
|
|
24
|
+
RIGHT: [{"id":"col","component":"Column","children":["hi"]},{"id":"hi","component":"Text","text":"Hi"}]
|
|
25
|
+
|
|
26
|
+
5. Button "child" must be the id of a Text component in the same components array.
|
|
27
|
+
Button "action" must be {"event":{"name":"myActionId"}}.
|
|
28
|
+
|
|
29
|
+
6. Use updateDataModel with a single path and value per call:
|
|
30
|
+
action: "updateDataModel", surfaceId: "s", path: "/result", value: "done!"
|
|
31
|
+
To update multiple fields, call render_component once per field.
|
|
32
|
+
|
|
33
|
+
7. To concatenate or inject data bindings into strings, use formatString:
|
|
34
|
+
{"call":"formatString","args":{"value":"Hello \${/user/name}"}}
|
|
35
|
+
|
|
36
|
+
Components
|
|
37
|
+
----------
|
|
38
|
+
Text — text (string or {"path":"/key"}, required), variant? ("caption"|"body")
|
|
39
|
+
Row — children (string[] or template {"path":"/list","componentId":"tmpl"}, required), justify?, align?
|
|
40
|
+
Column — children (string[] or template, required), justify?, align?
|
|
41
|
+
Button — child (string, required — id of a Text or Icon component),
|
|
42
|
+
action ({"event":{"name":"myActionId"}}, required), variant? ("default"|"primary"|"borderless")
|
|
43
|
+
TextField — label (required), value? ({"path":"/key"}), placeholder?,
|
|
44
|
+
variant? ("shortText"|"longText"|"number"|"obscured")
|
|
45
|
+
Image — url (required), description?, fit?, variant?
|
|
46
|
+
Icon — name (required; enum string, {"svgPath":"..."}, or {"path":"/key"})
|
|
47
|
+
Video — url (required), posterUrl?
|
|
48
|
+
AudioPlayer — url (required), description?
|
|
49
|
+
List — children (string[] or template, required), direction?, align?
|
|
50
|
+
Card — child (required; component id string)
|
|
51
|
+
Tabs — tabs[] (each: {title, child}, required)
|
|
52
|
+
Modal — trigger (component id, required), content (component id, required)
|
|
53
|
+
Divider — axis? ("horizontal"|"vertical")
|
|
54
|
+
CheckBox — label (required), value ({"path":"/key"} or boolean, required)
|
|
55
|
+
ChoicePicker — label?, variant? ("mutuallyExclusive"|"multipleSelection"),
|
|
56
|
+
options[] (each: {label, value}, required), value ({"path":"/key"}, required),
|
|
57
|
+
displayStyle? ("checkbox"|"chips"), filterable?
|
|
58
|
+
Slider — max (required), value ({"path":"/key"} or number, required), label?, min?, steps?
|
|
59
|
+
DateTimeInput — value (required; {"path":"/key"} or ISO 8601 string), enableDate?, enableTime?,
|
|
60
|
+
min?, max?, label?
|
|
61
|
+
|
|
62
|
+
Functions (data binding & validation)
|
|
63
|
+
---------------------------------------
|
|
64
|
+
formatString(value) — string interpolation: {"call":"formatString","args":{"value":"Hi \${/name}"}}
|
|
65
|
+
formatNumber(value,decimals?,grouping?) — number formatting
|
|
66
|
+
formatCurrency(value,currency,decimals?,grouping?) — currency formatting
|
|
67
|
+
formatDate(value,format) — date formatting using Unicode TR35 patterns
|
|
68
|
+
pluralize(value,one,other,...) — CLDR plural-aware string selection
|
|
69
|
+
openUrl(url) — open a URL (action function, no return value)
|
|
70
|
+
required(value) — validation: checks value is not empty
|
|
71
|
+
regex(value,pattern) — validation: checks value matches regex
|
|
72
|
+
length(value,min?,max?) — validation: checks string length
|
|
73
|
+
numeric(value,min?,max?) — validation: checks number range
|
|
74
|
+
email(value) — validation: checks value is a valid email
|
|
75
|
+
and(values[]) — logical AND of boolean values
|
|
76
|
+
or(values[]) — logical OR of boolean values
|
|
77
|
+
not(value) — logical NOT of a boolean value
|
|
78
|
+
|
|
79
|
+
NOTE: ShadowClaw additionally supports "capitalize" as an extension function
|
|
80
|
+
(not in the official spec): {"call":"capitalize","args":{"value":{"path":"/name"}}}
|
|
81
|
+
|
|
82
|
+
Validator / boolean functions evaluate to boolean and are used in "checks" rules;
|
|
83
|
+
they do not produce a displayable string.
|
|
84
|
+
|
|
85
|
+
Example (correct — createSurface)
|
|
86
|
+
----------------------------------
|
|
87
|
+
action: "createSurface"
|
|
88
|
+
surfaceId: "my-surface"
|
|
89
|
+
components: [
|
|
90
|
+
{"id":"root", "component":"Column","children":["title","btn"]},
|
|
91
|
+
{"id":"title", "component":"Text","text":"Hello World","variant":"body"},
|
|
92
|
+
{"id":"btn_lbl", "component":"Text","text":"Click Me"},
|
|
93
|
+
{"id":"btn", "component":"Button","child":"btn_lbl","action":{"event":{"name":"submit"}},"variant":"primary"}
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
Example (updateDataModel)
|
|
97
|
+
--------------------------
|
|
98
|
+
action: "updateDataModel"
|
|
99
|
+
surfaceId: "my-surface"
|
|
100
|
+
path: "/result"
|
|
101
|
+
value: "done!"
|
|
102
|
+
`,I=[k,{name:`attach_file_to_chat`,description:`Prepare a workspace file for chat delivery by generating an exact markdown attachment snippet. Validates the file path and returns markdown that works for inline image rendering in ShadowClaw and attachment upload in external channels like Telegram/iMessage.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},alt:{type:`string`,description:`Optional alt/caption text to use in the generated markdown`}},required:[`path`]}},D,O,{name:`copy_file`,description:`Copy a file or directory in the group workspace to a new destination path. Supports copying single files or nested directories. Optionally supports copying between different conversation workspaces via source_group_id or target_group_id.`,input_schema:{type:`object`,properties:{source_path:{type:`string`,description:`Source file or directory path relative to workspace root`},target_path:{type:`string`,description:`Destination file or directory path relative to workspace root`},source_group_id:{type:`string`,description:`Optional source conversation group ID (defaults to current workspace)`},target_group_id:{type:`string`,description:`Optional target conversation group ID (defaults to current workspace)`}},required:[`source_path`,`target_path`]}},{name:`create_directory`,description:`Create a new directory (and any missing parent directories) in the group workspace.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Directory path relative to the group workspace root`}},required:[`path`]}},{name:`create_room`,description:`Create a new multi-party room (a shared PeerJS conversation) hosted by this device. Other agents or humans can then be invited to participate. Returns the room so you can share or invite peers into it.`,input_schema:{type:`object`,properties:{name:{type:`string`,description:`A human-readable name for the room.`}},required:[`name`]}},{name:`create_task`,description:`Create a scheduled recurring task. The task will run automatically on the specified schedule and send the result back to this group. Uses cron expressions (minute hour day-of-month month day-of-week).`,input_schema:{type:`object`,properties:{schedule:{type:`string`,description:`Cron expression, e.g. "0 9 * * 1-5" for 9am weekdays`},prompt:{type:`string`,description:`The prompt/instruction to execute on each run (used if type is 'prompt')`},type:{type:`string`,enum:[`prompt`,`tools`],description:`The type of task to create. Defaults to 'prompt'.`},tools:{type:`array`,description:`A list of tools to execute sequentially (used if type is 'tools')`,items:{type:`object`,properties:{name:{type:`string`},input:{type:`object`}},required:[`name`,`input`]}},name:{type:`string`,description:`The optional title/name for the task, helping to identify its purpose.`}},required:[`prompt`,`type`]}},{name:`delete_file`,description:`Delete a file or directory from the group workspace. If the target path is a directory, it will be recursively deleted.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File or directory path relative to the group workspace root`}},required:[`path`]}},{name:`delete_task`,description:`Delete a scheduled task by its ID.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to delete`}},required:[`id`]}},{name:`detect_language`,description:`Detect the language of input text using Web Platform's Language Detector API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to analyze for language detection.`}},required:[`text`]}},{name:`diff_files`,description:`Compare two files in the workspace and output the differences. Useful for comparing generated code, checking before patching, or finding changes outside of git repositories.`,input_schema:{type:`object`,properties:{path_a:{type:`string`,description:`Path to the first file relative to the group workspace root.`},path_b:{type:`string`,description:`Path to the second file relative to the group workspace root.`}},required:[`path_a`,`path_b`]}},{name:`disable_task`,description:`Disable a scheduled task so it stops running.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to disable`}},required:[`id`]}},j,M,{name:`enable_task`,description:`Enable a scheduled task so it runs on its schedule.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to enable`}},required:[`id`]}},te,ee,{name:`get_current_time`,description:`Get the current date and time. Returns an ISO 8601 string representing the current date and time. Use this tool whenever you need to know the current time, instead of relying on shell tools which may be unavailable.`,input_schema:{type:`object`,properties:{timezone:{type:`string`,description:`Optional timezone to format the time in (e.g. 'America/New_York'). If omitted, returns UTC.`}}}},{name:`git_add`,description:`Stage files in a cloned repo. Accepts an array of filepaths. If omitted or empty, stages the repo root.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},filepaths:{type:`array`,items:{type:`string`},description:`Array of file paths to stage (relative to repo root). Pass a single item for one file.`}},required:[`repo`]}},{name:`git_branch`,description:`Create a new branch in a cloned repo. Optionally switch to it immediately (like git checkout -b).`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (returned by git_clone)`},name:{type:`string`,description:`Name for the new branch`},checkout:{type:`boolean`,description:`Switch to the new branch after creating it (default: false)`},start_point:{type:`string`,description:`Branch, tag, or commit SHA to branch from (default: HEAD)`}},required:[`repo`,`name`]}},{name:`git_branches`,description:`List branches in a cloned repo. Current branch is marked with *.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},remote:{type:`boolean`,description:`List remote-tracking branches instead (default: false)`}},required:[`repo`]}},{name:`git_checkout`,description:`Checkout a branch, tag, or commit SHA in a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (returned by git_clone)`},ref:{type:`string`,description:`Branch name, tag, or commit SHA to checkout`}},required:[`repo`,`ref`]}},{name:`git_clone`,description:`Clone a git repository into browser-persistent OPFS storage. Files are stored directly under repos/<repo-name>/ in the workspace and are immediately accessible to other git_* tools without any extra sync step. Works with public and private repos (GitHub, GitLab, GitHub Enterprise, etc.). If a Git PAT is configured in Settings, it is used automatically for authentication. Uses a CORS proxy. Returns the short repo name used for subsequent git_* operations.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`Full HTTPS repo URL (e.g. https://github.com/user/repo)`},name:{type:`string`,description:`Optional short repo name to use for the clone directory; defaults to the repository name parsed from the URL.`},branch:{type:`string`,description:`Branch to clone (default: default branch)`},depth:{type:`number`,description:`Shallow clone depth (default: 20)`}},required:[`url`]}},{name:`git_commit`,description:`Stage all changes and create a commit in a cloned repo. Uses configured git author name/email or defaults.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},message:{type:`string`,description:`Commit message`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`,`message`]}},{name:`git_config`,description:`Get or set a git config value for a repo (e.g. user.name, user.email). Persistent per-repo identity avoids specifying author on every commit.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},command:{type:`string`,enum:[`get`,`set`],description:`Operation: get or set a config value`},key:{type:`string`,description:`Config key path (e.g. user.name, user.email, core.autocrlf)`},value:{type:`string`,description:`Value to set — required when command is set`}},required:[`repo`,`command`,`key`]}},{name:`git_delete_branch`,description:`Delete a local branch from a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},name:{type:`string`,description:`Name of the branch to delete`}},required:[`repo`,`name`]}},{name:`git_delete_repo`,description:"Delete the git metadata for a cloned repository while leaving the working tree files in place. Use this to clean up corrupted or stale repos that fail to re-clone. The repo directory remains under repos/<repo>, but the `.git/` metadata is removed.",input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (as returned by git_clone or git_list_repos)`}},required:[`repo`]}},{name:`git_diff`,description:`Show changed files between HEAD and working tree, or between two refs.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref1:{type:`string`,description:`First ref (default: HEAD)`},ref2:{type:`string`,description:`Second ref (if omitted, diffs HEAD vs workdir)`}},required:[`repo`]}},{name:`git_fetch`,description:`Fetch commits from the remote without merging. Safe for inspecting remote state before deciding to merge or rebase.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Remote branch to fetch (default: default branch)`},remote:{type:`string`,description:`Remote name (default: origin)`}},required:[`repo`]}},{name:`git_init`,description:`Initialize a new empty git repository in browser storage. Use this to create a new project from scratch before using git_push to push to a remote.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short name for the new repo (used for all subsequent git_ operations)`}},required:[`repo`]}},{name:`git_list_repos`,description:`List all git repositories currently cloned in browser storage.`,input_schema:{type:`object`,properties:{}}},{name:`git_log`,description:`Show the commit log for a cloned repo. Returns commit SHA, date, author, and message.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Ref to log from (default: HEAD)`},depth:{type:`number`,description:`Number of commits to show (default: 10)`}},required:[`repo`]}},{name:`git_merge`,description:`Merge a branch or ref into the current branch. Supports fast-forward and three-way merges. If the merge has conflicts, a detailed report is returned with the conflicted files and their conflict regions inline. To resolve: use read_file on each conflicted file, then write_file with the complete resolved content (no conflict markers). After all files are resolved, use git_add for each, then git_commit. Do NOT use bash/sed for conflict resolution.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},theirs:{type:`string`,description:`Branch name, tag, or commit SHA to merge into the current branch`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`,`theirs`]}},{name:`git_pull`,description:`Fetch and merge commits from the remote repository. Uses configured git author name/email for merge commits if needed.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Branch to pull (default: current branch)`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`]}},{name:`git_push`,description:`Push commits to the remote repository. Requires a GitHub personal access token (PAT) to be configured. The token is loaded from the encrypted credential store.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Local branch to push (default: current branch)`},remote_ref:{type:`string`,description:`Remote branch name to push to, if different from local branch. Example: push local 'feature-rebased' to remote 'feature/original'.`},force:{type:`boolean`,description:`Force push (default: false)`},tags:{type:`boolean`,description:`Also push all local tags to the remote (default: false)`}},required:[`repo`]}},{name:`git_read_file_at_ref`,description:`Read a file's contents at a specific ref (branch, tag, or commit SHA) without checking it out. Useful for code review across branches.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Branch name, tag, or commit SHA`},filepath:{type:`string`,description:`File path relative to the repo root`}},required:[`repo`,`ref`,`filepath`]}},{name:`git_remote`,description:`Manage git remotes: list, add, or remove a remote in a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},command:{type:`string`,enum:[`list`,`add`,`remove`],description:`Operation to perform`},remote:{type:`string`,description:`Remote name (e.g. origin, upstream) — required for add/remove`},url:{type:`string`,description:`Remote URL — required for add`}},required:[`repo`,`command`]}},{name:`git_reset`,description:`Reset the current branch HEAD to a specific ref or commit SHA. Updates the branch pointer and checks out the target, discarding local changes. Equivalent to 'git reset --hard <ref>'.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Branch name, tag, or commit SHA to reset to`}},required:[`repo`,`ref`]}},{name:`git_show`,description:`Show the metadata and diff of a specific commit. Returns author, date, message, and a unified diff against the parent commit.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Commit SHA, branch, or tag to inspect (default: HEAD)`}},required:[`repo`,`ref`]}},{name:`git_status`,description:`Show the working tree status of a cloned repo. Reports modified, added, deleted, and unstaged files.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`}},required:[`repo`]}},{name:`git_tag`,description:`Create a lightweight or annotated tag at HEAD. Use git_push with tags=true to push tags to the remote.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},tag:{type:`string`,description:`Tag name (e.g. v1.2.3)`},message:{type:`string`,description:`Annotation message — if provided, creates an annotated tag; otherwise lightweight`},author_name:{type:`string`,description:`Tagger name (optional, uses configured default)`},author_email:{type:`string`,description:`Tagger email (optional, uses configured default)`}},required:[`repo`,`tag`]}},{name:`git_unstage`,description:`Remove one or more staged files from the index without touching the working tree. The inverse of git_add — use to undo accidental staging.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},filepath:{anyOf:[{type:`string`},{type:`array`,items:{type:`string`}}],description:`File path or array of file paths to unstage (relative to repo root)`}},required:[`repo`,`filepath`]}},{name:`invite_to_room`,description:`Invite a peer (another agent or human, identified by their PeerJS peer ID) into a room so they can join the shared conversation. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{peer_id:{type:`string`,description:`The PeerJS peer ID of the participant to invite.`},room_id:{type:`string`,description:`The room id to invite into. Defaults to the current room conversation.`}},required:[`peer_id`]}},re,{name:`leave_room`,description:`Leave a room. If you are the host, the room is disbanded for all members. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{room_id:{type:`string`,description:`The room id to leave. Defaults to the current room conversation.`}}}},{name:`list_components`,description:`List all available A2UI v1.0 Basic catalog components and their schemas. Returns a human-readable reference of component types, their required/optional properties, data binding syntax, and examples. Call this before render_component to understand what components are available and how to structure the input correctly.`,input_schema:{type:`object`,properties:{},required:[]}},{name:`list_files`,description:`List files and directories in the group workspace. Directory names end with /. Returns sorted entries.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Directory path relative to workspace root (default: root)`}}}},{name:`list_room_members`,description:`List the participants (humans and agents) currently in a room. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{room_id:{type:`string`,description:`The room id to inspect. Defaults to the current room conversation.`}}}},{name:`list_tasks`,description:`List all scheduled recurring tasks for this group. Returns a list of tasks with their IDs, schedules, and prompts.`,input_schema:{type:`object`,properties:{}}},se,A,oe,{name:`move_file`,description:`Move or rename a file or directory in the group workspace to a target path. Supports moving single files or nested directories. Optionally supports moving between different conversation workspaces via source_group_id or target_group_id.`,input_schema:{type:`object`,properties:{source_path:{type:`string`,description:`Source file or directory path relative to workspace root`},target_path:{type:`string`,description:`Destination file or directory path relative to workspace root`},source_group_id:{type:`string`,description:`Optional source conversation group ID (defaults to current workspace)`},target_group_id:{type:`string`,description:`Optional target conversation group ID (defaults to current workspace)`}},required:[`source_path`,`target_path`]}},{name:`open_file`,description:`Open a file from the group workspace in the UI file viewer dialog. Use this only when the user explicitly asks to inspect a file visually with preview support. Do not use this tool to send or attach files in chat responses.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`}},required:[`path`]}},{name:`patch_file`,description:`Make a targeted text replacement in a file. Finds the single occurrence of old_string and replaces it with new_string. Fails if old_string is not found or matches more than once. Use this instead of write_file when you only need to change part of a file — it is safer and works well with large files. Include enough surrounding context in old_string to make the match unique. IMPORTANT: You must provide 'path', 'old_string', and 'new_string' parameters.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},old_string:{type:`string`,description:`The exact text to find in the file. Must match exactly once. Include 2-3 lines of surrounding context to ensure a unique match.`},new_string:{type:`string`,description:`The replacement text. Can be empty to delete old_string.`}},required:[`path`,`old_string`,`new_string`]}},{name:`proofread_text`,description:`Proofread and correct grammar, spelling, and phrasing errors using Web Platform's Proofreader API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to proofread.`},context:{type:`string`,description:`Optional background context for proofreading.`}},required:[`text`]}},{name:`read_file`,description:`Read the contents of one or more files from the group workspace. IMPORTANT: You must specify either the 'path' parameter (for a single file) or the 'paths' parameter (an array of file paths for multiple files). When paths is provided, returns all file contents concatenated with --- filename --- headers. Prefer paths to batch reads in a single call. Image files (png, jpg, gif, webp, etc.) are returned as native image content that the model can see directly. Other binary files will be detected and an error returned suggesting alternative tools.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Single file path relative to the group workspace root`},paths:{type:`array`,items:{type:`string`},description:`Array of file paths relative to the group workspace root. Use this to read multiple files in a single tool call.`}}}},ae,ie,{name:`render_component`,description:`Render an interactive A2UI v1.0 UI surface in the peer's chat window using the Basic catalog. The surface appears inline in the conversation on the remote peer's side (or locally if no peer). Components: Text, Row, Column, Button, TextField, Image, Icon, Video, AudioPlayer, List, Card, Tabs, Modal, Divider, CheckBox, ChoicePicker, Slider, DateTimeInput. Use list_components first to understand available components and their schemas. All user input (button clicks, form field changes) automatically routes back to the agent. For media components (Image/Video/AudioPlayer), use workspace file paths (e.g. 'song.mp3') or HTTPS URLs.
|
|
103
|
+
|
|
104
|
+
actions:
|
|
105
|
+
createSurface — render a new surface (requires components array with a root component)
|
|
106
|
+
updateComponents — add or replace components on an existing surface
|
|
107
|
+
updateDataModel — update a single path in the data model (re-renders bound components)
|
|
108
|
+
deleteSurface — remove the surface from the chat`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`],description:`The A2UI operation to perform`},surfaceId:{type:`string`,description:`Unique identifier for this surface. Use a stable ID so you can update it later.`},components:{type:`array`,description:`Flat array of component objects (required for createSurface/updateComponents). Each object MUST have an 'id' field and a 'component' field. The component with id 'root' is the tree root (required for createSurface). Component field values: Text | Row | Column | Button | TextField | Image | Icon | Video | AudioPlayer | List | Card | Tabs | Modal | Divider | CheckBox | ChoicePicker | Slider | DateTimeInput. Put all properties at the TOP LEVEL alongside 'component' and 'id'. DO NOT nest properties under a 'properties' key. Children arrays contain other component ID strings, not nested objects.`,items:{type:`object`,additionalProperties:!0}},dataModel:{type:`object`,description:`Initial data model for the surface (used with createSurface). Components can reference values via { "path": "/key" }.`,additionalProperties:!0},path:{type:`string`,description:`JSON Pointer path to update (required for updateDataModel). Examples: "/result", "/user/name", "/count". Use "/" to replace the entire data model.`},value:{description:`New value to set at the specified path (used with updateDataModel). Omit to delete the key at the given path.`},surfaceProperties:{type:`object`,description:`Optional display/branding properties for this surface (e.g. agentDisplayName).`,additionalProperties:!0}},required:[`action`,`surfaceId`]}},{name:`rewrite_text`,description:`Rewrite or rephrase text using Web Platform's Rewriter API (or polyfill fallback). Can adjust tone or length.`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to rewrite.`},tone:{type:`string`,enum:[`as-is`,`more-formal`,`more-casual`],description:`Tone adjustment (default: as-is).`},length:{type:`string`,enum:[`as-is`,`shorter`,`longer`],description:`Length adjustment (default: as-is).`},context:{type:`string`,description:`Optional background context for rewriting.`}},required:[`text`]}},{name:`run_task`,description:`Immediately trigger a scheduled task by its ID, outside of its normal cron schedule. Use this to manually fire a task on demand. Use list_tasks to find the task ID first.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to run immediately`}},required:[`id`]}},{name:`search_files`,description:`Search for a pattern (regex or exact text) in files across the workspace. Useful for finding code references, function definitions, or specific content without needing to rely on a shell environment.`,input_schema:{type:`object`,properties:{pattern:{type:`string`,description:`The text or regular expression to search for.`},path:{type:`string`,description:`Optional directory path to restrict the search to (e.g. 'src/'). Defaults to workspace root.`},file_glob:{type:`string`,description:`Optional simple glob to filter files (e.g. '*.ts'). Supports * as wildcard.`},is_regex:{type:`boolean`,description:`Set to true to parse the pattern as a regular expression.`}},required:[`pattern`]}},{name:`send_file`,description:`Send a workspace file directly to connected peer(s) over the P2P (PeerJS/WebRTC) data channel. Use this when the user is in a peer conversation or room and asks to send or transfer a file. Do NOT use this for local-browser or other non-peer conversations — it only works when the active conversation is a peer or room session (peer: or room: group). The file is read from the current group workspace and transferred in binary chunks so there is no size limit.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`}},required:[`path`]}},N,le,{name:`spawn_subagent`,description:`Spawn one or more independent agent loops to work on subtasks in parallel and collect their results. Each subagent has its own tool-use loop, inherits the current API key, and can optionally override provider/model. and runs concurrently with other subagents via Promise.all. Use spawn_subagent when a task has independent parallel workstreams — for example: researching multiple topics simultaneously, processing a list of items in parallel, or delegating isolated subtasks to specialized agents. Do NOT use spawn_subagent for sequential tasks where step 2 depends on step 1's output — just do those steps directly. Do NOT use spawn_subagent for simple single-step work that takes one tool call. Use the parallel_agents field to fan out multiple subagents in a single call.`,input_schema:{type:`object`,properties:{prompt:{type:`string`,description:`The task prompt for a single subagent. Required unless using parallel_agents for multi-agent fan-out.`},tools:{type:`array`,description:`Optional list of tool names to allow in the subagent. If omitted, the subagent inherits the current tool set (minus spawn_subagent to prevent recursion). If provided, only these tools are available to the subagent.`,items:{type:`string`}},profile:{type:`string`,enum:[`current`,`fast`,`smart`,`powerful`],description:`Optional model profile to run the subagent on. Use 'fast' for simple/cheap subtasks (e.g., text formatting, basic search), 'smart' for moderate reasoning, 'powerful' for deep thinking or complex coding, and 'current' to inherit the parent model. Defaults to 'current'.`},workspace_group_id:{type:`string`,description:`Optional workspace group id override for subagent file/tool scope. Use 'parent' to reuse the parent workspace in automatic mode. When omitted, subagents use an isolated workspace by default.`},system_prompt:{type:`string`,description:`Optional system prompt override for the subagent. Defaults to the current system prompt.`},parallel_agents:{type:`array`,description:`Optional list of subagent specifications to run in parallel. When provided, all agents are launched concurrently and their results are combined. Note: There is a configurable maximum limit on parallel subagents (default 5). Each entry can specify a prompt, optional tools list, optional profile, and optional system_prompt.`,items:{type:`object`,properties:{prompt:{type:`string`,description:`The task prompt for this subagent.`},tools:{type:`array`,description:`Optional tool names for this subagent.`,items:{type:`string`}},profile:{type:`string`,enum:[`current`,`fast`,`smart`,`powerful`],description:`Optional model profile for this subagent. Defaults to 'current'.`},workspace_group_id:{type:`string`,description:`Optional workspace group id for this subagent. Use 'parent' for parent workspace in automatic mode.`},system_prompt:{type:`string`,description:`Optional system prompt override for this subagent.`}},required:[`prompt`]}}},required:[`prompt`]}},{name:`summarize_text`,description:`Summarize text using Web Platform's Summarizer API (or polyfill fallback). Produces key points, TLDR, teaser, or headline.`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text content to summarize.`},type:{type:`string`,enum:[`key-points`,`tldr`,`teaser`,`headline`],description:`The summary type (default: key-points).`},format:{type:`string`,enum:[`plain-text`,`markdown`],description:`Output format (default: markdown).`},length:{type:`string`,enum:[`short`,`medium`,`long`],description:`Summary length (default: short).`},preference:{type:`string`,enum:[`capability`,`speed`,`auto`],description:`Summarizer performance preference (default: auto).`},context:{type:`string`,description:`Optional background context for summarization.`}},required:[`text`]}},{name:`translate_text`,description:`Translate text using Web Platform's Translator API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to translate.`},sourceLanguage:{type:`string`,description:`Source language BCP 47 code (e.g. 'en', 'es', 'ja').`},targetLanguage:{type:`string`,description:`Target language BCP 47 code (e.g. 'en', 'es', 'ja').`}},required:[`text`,`sourceLanguage`,`targetLanguage`]}},ce,{name:`update_task`,description:`Update an existing scheduled task's schedule or prompt.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to update`},schedule:{type:`string`,description:`Standard cron expression (e.g. '0 9 * * *'). Leave empty for an unscheduled task.`},prompt:{type:`string`,description:`New prompt/instruction (optional)`},type:{type:`string`,enum:[`prompt`,`tools`],description:`New task type (optional)`},tools:{type:`array`,description:`New list of tools (optional)`,items:{type:`object`,properties:{name:{type:`string`},input:{type:`object`}},required:[`name`,`input`]}},enabled:{type:`boolean`,description:`Whether the task is enabled (optional)`},name:{type:`string`,description:`New name/title for the task (optional).`}},required:[`id`]}},ne,{name:`write_file`,description:`Write content to a file in the group workspace. Creates the file and any intermediate directories if they don't exist. Overwrites the file if it already exists. IMPORTANT: You must provide both the 'path' and 'content' parameters when calling this tool.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},content:{type:`string`,description:`Content to write to the file`}},required:[`path`,`content`]}},{name:`write_text`,description:`Generate or draft text using Web Platform's Writer API (or polyfill fallback).`,input_schema:{type:`object`,properties:{prompt:{type:`string`,description:`The prompt or writing instructions.`},context:{type:`string`,description:`Optional background context for writing.`}},required:[`prompt`]}}],L=/^[a-z][a-z0-9_]{0,63}$/;function R(e,t){if(!t||typeof t!=`object`)throw Error(`Tool at ${e} must be a JSON object`);let n=t,r=typeof n.name==`string`?n.name.trim():``,i=typeof n.description==`string`?n.description.trim():``,a=n.input_schema??n.parameters,o=n.execution??n.evaluation;if(!L.test(r))throw Error(`Tool name is invalid: ${r||`(missing)`}`);if(!i)throw Error(`Tool ${r} requires a description`);if(!a||typeof a!=`object`)throw Error(`Tool ${r} requires input_schema`);if(!o||typeof o!=`object`)throw Error(`Tool ${r} requires execution`);let s=o,c=s.type;if(c!==`bash`&&c!==`javascript`&&c!==`tool`)throw Error(`Tool ${r} execution type must be bash, javascript, or tool`);if(c===`tool`){if(typeof s.name!=`string`||!L.test(s.name))throw Error(`Tool ${r} execution requires a valid tool name`);return{name:r,description:i,input_schema:a,execution:{type:c,name:s.name,...s.input&&typeof s.input==`object`?{input:s.input}:{}},path:e}}let l=c===`bash`?`command`:`code`,u=s[l]??s.expression;if(typeof u!=`string`||u.trim()===``)throw Error(`Tool ${r} execution requires ${l}`);return{name:r,description:i,input_schema:a,execution:{type:c,[l]:u},path:e}}async function z(e,t=i){let n=[],r=[],a=t===`br:main`?[i]:[t,i];for(let t of a)try{let i=await C(e,t),a=[];async function o(e,t){for await(let[n,r]of e.entries()){let e=`${t}/${n}`;r.kind===`directory`?await o(r,e):n.endsWith(`.json`)&&e.startsWith(`.agents/tools/`)&&a.push(e)}}try{await o(await(await i.getDirectoryHandle(`.agents`)).getDirectoryHandle(`tools`),`.agents/tools`)}catch{continue}for(let i of a.sort())try{let r=R(i,JSON.parse(await E(e,t,i)));n.some(e=>e.name===r.name)||n.push(r)}catch(e){r.push(e instanceof Error?e.message:String(e))}}catch{}return{tools:n,diagnostics:r}}async function B(e,t=i,n){try{let{tools:r}=await z(e,t),i=r.find(e=>e.name===n)||null;if(!i)return null;let o=await s(e,a.DECLARATIVE_TOOLS_ENABLED);return Array.isArray(o)&&!o.includes(n)?null:i}catch{return null}}async function V(e,t){let n=e?.createWritable,r=Reflect.get(e,`createWriteable`),i=typeof n==`function`?n.bind(e):typeof r==`function`?r.bind(e):null;if(i){let e=await i();await e.write(U(t)),await e.close();return}if(typeof e.createSyncAccessHandle==`function`){let n=await e.createSyncAccessHandle();try{let e=await W(t);n.truncate(0),n.write(e,{at:0}),typeof n.flush==`function`&&n.flush()}finally{n.close()}return}throw Error(`Writable file streams are not supported by this browser/storage backend.`)}async function H(e,t){if(typeof globalThis.Worker!=`function`)throw Error(`Writable file streams are not supported by this browser/storage backend.`);let n=await W(t);return new Promise((t,r)=>{let i=``,a=null;try{let e=[`self.onmessage = async (e) => {`,` try {`,` const { pathSegments, bytes } = e.data;`,` let dir = await navigator.storage.getDirectory();`,` for (let i = 0; i < pathSegments.length - 1; i++) {`,` dir = await dir.getDirectoryHandle(pathSegments[i], { create: true });`,` }`,` const filename = pathSegments[pathSegments.length - 1];`,` const fh = await dir.getFileHandle(filename, { create: true });`,` const h = await fh.createSyncAccessHandle();`,` try {`,` h.truncate(0);`,` h.write(bytes, { at: 0 });`,` if (typeof h.flush === 'function') h.flush();`,` } finally { h.close(); }`,` self.postMessage({ ok: true });`,` } catch (err) {`,` self.postMessage({ error: err.message || String(err) });`,` }`,`};`].join(`
|
|
109
|
+
`);i=URL.createObjectURL(new Blob([e],{type:`text/javascript`})),a=new Worker(d(i))}catch{i&&URL.revokeObjectURL(i),r(Error(`Writable file streams are not supported by this browser/storage backend.`));return}let o=()=>{a&&a.terminate(),URL.revokeObjectURL(i)};a.onmessage=e=>{o(),e.data?.error?r(Error(e.data.error)):t()},a.onerror=e=>{o(),r(Error(e.message||`Worker file write failed`))},a.postMessage({pathSegments:e,bytes:n},[n.buffer])})}function U(e){if(typeof e==`string`||e instanceof Blob)return e;if(e instanceof Uint8Array){let t=new Uint8Array(e.byteLength);return t.set(e),new Blob([t])}return new Blob([e])}async function W(e){return e instanceof Uint8Array?e:typeof e==`string`?new TextEncoder().encode(e):e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array}async function G(e,t,n,r){let{dirs:i,filename:a}=w(n);for(let n=0;n<2;n++)try{let n=await C(e,t);for(let e of i)n=await n.getDirectoryHandle(e,{create:!0});let o=await n.getFileHandle(a,{create:!0});try{await V(o,r);return}catch(t){if(!((t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`)&&(await S(e)).type===`opfs`))throw t}let s=t.replace(/:/g,`-`);await H([h(),`groups`,s,...i,a],r);return}catch(e){if(n===0&&x(e)){b();continue}throw e}}async function K(e,t,n){try{return await E(e,t,n),!0}catch{return!1}}var q=e(t(),1);const ue=/^[a-z0-9](?:[a-z0-9]|-(?!-))*[a-z0-9]$|^[a-z0-9]$/;function de(e){try{let t=(0,q.default)(e);return{data:t.data&&typeof t.data==`object`?t.data:{},content:t.content||``}}catch{let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(t){let e=t[1],n=t[2]||``,r=e.split(/\r?\n/).map(e=>{let t=e.match(/^([a-zA-Z0-9_-]+):\s*(.+)$/);if(t){let[,e,n]=t,r=n.trim();if(r&&r!==`true`&&r!==`false`&&r!==`null`&&!r.startsWith(`"`)&&!r.startsWith(`'`)&&!r.startsWith(`[`)&&!r.startsWith(`{`)&&r!==`>`&&r!==`|`&&r!==`>-`&&r!==`|-`&&!/^-?\d+(?:\.\d+)?$/.test(r))return`${e}: ${JSON.stringify(r)}`}return e});try{let e=(0,q.default)(`---\n${r.join(`
|
|
110
|
+
`)}\n---\n${n}`);return{data:e.data&&typeof e.data==`object`?e.data:{},content:e.content||``}}catch{}let i={},a=e.match(/^name:\s*["']?([^"'\r\n]+)["']?/m);a&&(i.name=a[1].trim());let o=e.match(/^description:\s*(.+)$/m);if(o){let e=o[1].trim();(e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`))&&(e=e.slice(1,-1)),i.description=e}let s=e.match(/^user-invocable:\s*(true|false)/im);s&&(i[`user-invocable`]=s[1].toLowerCase()===`true`);let c=e.match(/^disable-model-invocation:\s*(true|false)/im);c&&(i[`disable-model-invocation`]=c[1].toLowerCase()===`true`);let l=e.match(/^allowed-tools:\s*["']?([^"'\r\n]+)["']?/m);l&&(i[`allowed-tools`]=l[1].trim());let u=e.match(/allowed-tools:\s*\n((?:\s*-\s*[^\r\n]+\r?\n?)+)/m);if(u){let e=u[1].split(/\r?\n/).map(e=>e.replace(/^\s*-\s*/,``).trim()).filter(Boolean);e.length>0&&(i[`allowed-tools`]=e)}return{data:i,content:n}}return{data:{},content:e}}}function J(e){if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(Array.isArray(e)){let t=e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t.join(` `):void 0}}function Y(e,t){let n=de(t),r=n.data,i=typeof r.name==`string`?r.name.trim():``,a=typeof r.description==`string`?r.description.trim():``;if(!i)throw Error(`Skill at ${e} requires a name`);if(!a)throw Error(`Skill ${i} requires a description`);if(i.length>64||!ue.test(i))throw Error(`Skill name must be 1-64 lowercase characters and hyphens: ${i}`);if(a.length>1024)throw Error(`Skill ${i} description must be 1024 characters or fewer`);let o=e.replace(/\/SKILL\.md$/u,``),s=r.metadata&&typeof r.metadata==`object`?r.metadata:void 0,c=J(s?.[`allowed-tools`])||J(s?.allowedTools)||J(r[`allowed-tools`])||J(r.allowedTools),l=[];if(s){for(let[e,t]of Object.entries(s))if(!(e===`execution`||t==null)){if(e===`allowed-tools`||e===`allowedTools`)c&&l.push([e,c]);else if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)l.push([e,String(t)]);else if(Array.isArray(t)){let n=t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean);n.length>0&&l.push([e,n.join(` `)])}}}let u=l.length>0?Object.fromEntries(l):void 0,d=s?.execution,f;if(d!==void 0){if(!d||typeof d!=`object`||d.type!==`tools`||!Array.isArray(d.tools))throw Error(`Skill ${i} has invalid tools execution`);let e=d,t=typeof e.suppressToast==`boolean`?e.suppressToast:void 0,n=typeof e.suppressOutput==`boolean`?e.suppressOutput:void 0,r=e.tools.map(e=>({...e,...t!==void 0&&e.suppressToast===void 0?{suppressToast:t}:{},...n!==void 0&&e.suppressOutput===void 0?{suppressOutput:n}:{}}));f={type:`tools`,...t===void 0?{}:{suppressToast:t},...n===void 0?{}:{suppressOutput:n},tools:r}}return{name:i,description:a,...typeof r.license==`string`?{license:r.license}:{},...typeof r.compatibility==`string`?{compatibility:r.compatibility}:{},...u?{metadata:u}:{},...typeof c==`string`?{allowedTools:c}:{},...typeof r[`user-invocable`]==`boolean`?{userInvocable:r[`user-invocable`]}:typeof r[`user-invocable`]==`string`&&(r[`user-invocable`].toLowerCase()===`true`||r[`user-invocable`].toLowerCase()===`false`)?{userInvocable:r[`user-invocable`].toLowerCase()===`true`}:{},...typeof r[`disable-model-invocation`]==`boolean`?{disableModelInvocation:r[`disable-model-invocation`]}:typeof r[`disable-model-invocation`]==`string`&&(r[`disable-model-invocation`].toLowerCase()===`true`||r[`disable-model-invocation`].toLowerCase()===`false`)?{disableModelInvocation:r[`disable-model-invocation`].toLowerCase()===`true`}:{},...f?{execution:f}:{},body:n.content.trim(),path:e,basePath:o}}const fe=new Set(I.map(e=>e.name)),pe=/^[a-z][a-z0-9_]{0,63}$/;function X(e){return e?.targetSubdir?e.targetSubdir:e?.siteSlug?`imported/${e.siteSlug}`:`main`}async function Z(e,t=i,n,r){let o=(n.name||``).trim();if(fe.has(o))return{name:o,path:``,status:`failed`,error:`Cannot shadow built-in tool: ${o}`};if(!pe.test(o))return{name:o,path:``,status:`failed`,error:`Invalid tool name: ${o}`};let c=`.agents/tools/${X(r)}/${o}.json`;try{if(await K(e,t,c)&&!r?.overwrite)return{name:o,path:c,status:`skipped`};let i=await(r?.fetchFn||globalThis.fetch)(n.url);if(!i.ok)return{name:o,path:c,status:`failed`,error:`HTTP ${i.status} ${i.statusText}`};let l=await i.text();if(n.digest&&!await u(l,n.digest))return{name:o,path:c,status:`failed`,error:`Integrity verification failed for tool definition`};let d;try{d=JSON.parse(l)}catch{return{name:o,path:c,status:`failed`,error:`Downloaded tool definition is not valid JSON`}}if(R(c,d),await G(e,t,c,JSON.stringify(d,null,2)),r?.autoEnable){let t=await s(e,a.DECLARATIVE_TOOLS_ENABLED),n=new Set(Array.isArray(t)?t:[]);n.add(o),await T(e,a.DECLARATIVE_TOOLS_ENABLED,Array.from(n))}return{name:o,path:c,status:`imported`}}catch(e){return{name:o,path:c,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function Q(e,t=i,n,r){let a=(n.name||``).trim(),o=`.agents/scripts/${X(r)}/${a.endsWith(`.js`)||a.endsWith(`.mjs`)?a:`${a}.js`}`;try{if(await K(e,t,o)&&!r?.overwrite)return{name:a,path:o,status:`skipped`};let i=await(r?.fetchFn||globalThis.fetch)(n.url);if(!i.ok)return{name:a,path:o,status:`failed`,error:`HTTP ${i.status} ${i.statusText}`};let s=await i.text();return n.digest&&!await u(s,n.digest)?{name:a,path:o,status:`failed`,error:`Integrity verification failed for script`}:(await G(e,t,o,s),{name:a,path:o,status:`imported`})}catch(e){return{name:a,path:o,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function $(e,t=i,n,r){let a=(n.name||``).trim(),o=`.agents/skills/${X(r)}/${a}/SKILL.md`;try{if(await K(e,t,o)&&!r?.overwrite)return{name:a,path:o,status:`skipped`};let i=await(r?.fetchFn||globalThis.fetch)(n.url);if(!i.ok)return{name:a,path:o,status:`failed`,error:`HTTP ${i.status} ${i.statusText}`};let s=await i.text();return n.digest&&!await u(s,n.digest)?{name:a,path:o,status:`failed`,error:`Integrity verification failed for skill`}:(Y(o,s),await G(e,t,o,s),{name:a,path:o,status:`imported`})}catch(e){return{name:a,path:o,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function me(e,t=i,n,r,a){let o={tools:[],skills:[],scripts:[],diagnostics:[]},s=new Set(r.toolNames||[]),c=new Set(r.skillNames||[]),l=new Set(r.scriptNames||[]),u=n.tools||[],d=n.skills||[],f=n.scripts||[];for(let e of d)if(c.has(e.name)){if(Array.isArray(e.tools))for(let t of e.tools)s.add(t.name);if(Array.isArray(e.scripts))for(let t of e.scripts)l.add(t.name)}for(let n of f)if(l.has(n.name)){let r=await Q(e,t,n,a);o.scripts.push(r),r.status===`failed`&&r.error&&o.diagnostics.push(`Script ${n.name}: ${r.error}`)}for(let n of u)if(s.has(n.name)){let r=await Z(e,t,n,a);o.tools.push(r),r.status===`failed`&&r.error&&o.diagnostics.push(`Tool ${n.name}: ${r.error}`)}for(let n of d)if(c.has(n.name)){let r=await $(e,t,n,a);o.skills.push(r),r.status===`failed`&&r.error&&o.diagnostics.push(`Skill ${n.name}: ${r.error}`)}return o}export{x as C,b as S,w as _,Y as a,v as b,V as c,z as d,I as f,T as g,E as h,Z as i,H as l,F as m,Q as n,K as o,P as p,$ as r,G as s,me as t,B as u,C as v,y as w,S as x,h as y};
|